cgma
RefEntity Class Reference

Base class for all geometry entities, body, volume, surface... More...

#include <RefEntity.hpp>

Inheritance diagram for RefEntity:
CubitEntity CubitObservable ToolDataUser CubitAttribUser BasicTopologyEntity Body RefCollection RefEdge RefFace RefVertex RefVolume RefGroup

List of all members.

Public Member Functions

 RefEntity ()
virtual ~RefEntity ()
virtual CubitString entity_name () const
 Gets the name of this RefEntity.
CubitStatus entity_name (CubitString name)
 Sets the name of this RefEntity.
void entity_names (DLIList< CubitString > &names) const
 Gets the names of this RefEntity.
int num_names () const
 Get the number of names this RefEntity has.
CubitStatus generate_default_name (CubitString &name)
 Generates a default name for this RefEntity. 'name' is prepended to the default name.
CubitStatus assign_default_name (CubitBoolean user_setting=CUBIT_FALSE)
 Assigns a default name to the entity.
CubitStatus remove_entity_name (CubitString const &name)
CubitStatus remove_entity_names ()
void merge_entity_names (RefEntity *dead_entity)
void switch_entity_names (RefEntity *other_entity)
virtual void is_mergeable (AutoMergeStatus val)
 Setting auto merge status flag.
AutoMergeStatus merge_status () const
 Gets auto merge status flag.
bool is_mergeable ()
 Query to see if entity is free to merge.
CubitBoolean is_merged ()
 Query to see if entity is merged.
void update_auto_merge_state ()
 Updates the auto merge state of the entity.
virtual bool children_mergeable ()
 Get whether all child entities are mergeable.
virtual int can_modify ()
virtual int dimension () const
virtual void get_child_ref_entities (DLIList< RefEntity * > &entity_list)
void get_all_child_ref_entities (DLIList< RefEntity * > &entity_list)
virtual void get_parent_ref_entities (DLIList< RefEntity * > &entity_list)=0
void get_all_parent_ref_entities (DLIList< RefEntity * > &entity_list, const int get_bodies=CUBIT_FALSE)
int valence (RefEntity *parent=NULL)
int num_parent_ref_entities ()
virtual CubitVector center_point ()
 Return the approximate (spatial) center of this RefEntity.
virtual double measure ()
virtual CubitString measure_label ()
 Returns the type of measure: (volume, area, length, or N/A)
virtual int validate ()
 Perform checks to see if entity valid.
virtual DagType dag_type () const =0
 Returns the dag type of this enity.
virtual const std::type_info & entity_type_info () const =0
 Returns the type info of this enity.
DagType get_parent_ref_entity_type () const
 Gets the parent RefEntity type.
DagType get_child_ref_entity_type () const
 Gets the child RefEntity type.
void notify_sub_all_observers (const GeometryEvent::Type &event)
void comparison_found (RefEntity *partner)
void add_compare_data (RefEntity *partner)
void remove_compare_data ()
RefEntityget_compare_partner ()
void get_related_entity_list (const std::type_info &related_entity_type, DLIList< RefEntity * > &entity_list)
virtual void set_id (int i)
 Set the id of this RefEntity to i.
void set_id (int i, CubitBoolean emit_event)
 Sets the id of this RefEntity and emits specified event static observers.
virtual void color (int value)
 Sets the color of this RefEntity.
virtual int color () const
 Gets the color of this RefEntity.
void local_tolerance (double value)
 Get and set the local tolerance of this RefEntity. This is used in tolerant imprinting.
double local_tolerance (void)
virtual void marked (int value)
virtual int marked ()
virtual CubitBoolean is_child (RefEntity *entity)
virtual CubitBoolean is_parent (RefEntity *entity)

Static Public Member Functions

static const char * get_ref_class_name (const std::type_info &ref_type)
 Gets the class name of a RefEntity type.
static RefEntityget_by_name (const CubitString &name)
 Gets the RefEntity with the passed in name.
static void get_all_child_ref_entities (DLIList< RefEntity * > &input_list, DLIList< RefEntity * > &output_list)
 Appends all child RefEntities owned by entities in input_list to output_list.
static void gather_bdy_entities (DLIList< RefEntity * > &entity_list, DLIList< RefEntity * > &bdy_list)
static void change_to_parent_ref_entities (DLIList< RefEntity * > &ancestors)
static DagType dag_type (const std::type_info &)
 Translates the type info into dag type.
static DagType get_parent_ref_entity_type (DagType child_type)
 Given a child dag type, returns the parent dag type.
static DagType get_child_ref_entity_type (DagType parent_type)
 Given a parent dag type, returns the child dag type.
static const std::type_info & get_entity_type_info (const char *entity_type)
 Returns the type of a class given the class name.
static DagType dag_type (const char *cli_type_name)
 Returns a dag type based on name passed in, i.e., body, volume, surface..

Protected Attributes

int autoMergeStatus
int markedFlag
Bit listFlag: 1
int mColor

Private Member Functions

 RefEntity (const RefEntity &)
void operator= (const RefEntity &)
void list_mark (int value)
int list_mark ()

Private Attributes

double localTolerance
RefEntityjoin (RefEntity *ref_entity_2, DLIList< RefEntity * > &join_set)
static RefEntityjoin (DLIList< RefEntity * > &ref_entities, DLIList< RefEntity * > &join_set)
RefEntitymeet (RefEntity *ref_entity_2, DLIList< RefEntity * > &join_set)
static RefEntitymeet (DLIList< RefEntity * > &ref_entities, DLIList< RefEntity * > &join_set)

Detailed Description

Base class for all geometry entities, body, volume, surface...

Definition at line 62 of file RefEntity.hpp.


Constructor & Destructor Documentation

RefEntity::~RefEntity ( ) [virtual]

Definition at line 75 of file RefEntity.cpp.

{
  CGMHistory::Event evt(CGMHistory::ENTITY_DELETED, this);
  GeometryQueryTool::instance()->history().add_event(evt);

  // Remove the name of this entity from the entity name map
  RefEntityName::instance()->remove_refentity_name(this, CUBIT_FALSE);
  
  remove_from_observers();
}
RefEntity::RefEntity ( const RefEntity ) [private]

Member Function Documentation

R void I partner I- The compare partner for this object This function makes the connection between the two RefEntities, this and partner. At the end of this function the two entities would know who they compare with.

Definition at line 838 of file RefEntity.cpp.

{
  TDCompare* compareDataPtr = (TDCompare*)(this->get_TD(&TDCompare::is_compare));
  if (compareDataPtr == NULL)
  {
    compareDataPtr = new TDCompare() ;
    this->add_TD(compareDataPtr) ;
  }
  compareDataPtr->set_compare_partner(partner) ;
  
  
  compareDataPtr = (TDCompare*)(partner->get_TD(&TDCompare::is_compare));
  if (compareDataPtr == NULL)
  {
    compareDataPtr = new TDCompare() ;
    partner->add_TD(compareDataPtr) ;
  }
  compareDataPtr->set_compare_partner(this) ;
}

Assigns a default name to the entity.

Definition at line 191 of file RefEntity.cpp.

{

  if ( RefEntityName::instance()->get_generate_default_names() 
    || user_setting == CUBIT_TRUE )
  {
      // first generate the default name
    CubitString name;
    CubitStatus result = generate_default_name( name );
    if (result == CUBIT_FAILURE) return result;

      // now assign it to this entity and return
    RefEntityName::instance()->add_refentity_name(this, name);
    return CUBIT_SUCCESS;
  }
  return CUBIT_SUCCESS;
}
int RefEntity::can_modify ( ) [virtual]

Allow unmerging and other operations. Default in RefEntity always returns true. Provided for derived classes to override.

Definition at line 781 of file RefEntity.cpp.

{ return 1; }

Return the approximate (spatial) center of this RefEntity.

Reimplemented from CubitEntity.

Reimplemented in RefEdge, RefFace, RefVolume, RefGroup, Body, and RefVertex.

Definition at line 690 of file RefEntity.cpp.

{
  return bounding_box().center();
}
void RefEntity::change_to_parent_ref_entities ( DLIList< RefEntity * > &  ancestors) [static]

Modify the input list to contain the list of RefEntities that are the parents of each of the RefEntities in the original list.

Definition at line 435 of file RefEntity.cpp.

{
  DLIList<RefEntity*> new_ancestors, temp_list;
  if ( ancestors.size() == 0 ) return;
  
  ancestors.reset();
  do 
  {
    temp_list.clean_out();
    ancestors.get_and_step()->get_parent_ref_entities( temp_list );
    new_ancestors.merge_unique( temp_list );
  } while ( !ancestors.is_at_beginning() );
  
    // Overwrite the input list
  ancestors = new_ancestors;
}
bool RefEntity::children_mergeable ( ) [virtual]

Get whether all child entities are mergeable.

Definition at line 740 of file RefEntity.cpp.

{
   DLIList<RefEntity*> children;
   get_all_child_ref_entities( children );
   
   for( int i = children.size(); i--; )
     if( children.get_and_step()->autoMergeStatus == 0 ) 
       return false;

   return true;
}
void RefEntity::color ( int  value) [virtual]

Sets the color of this RefEntity.

Reimplemented from CubitEntity.

Reimplemented in Body.

Definition at line 1193 of file RefEntity.cpp.

int RefEntity::color ( ) const [virtual]

Gets the color of this RefEntity.

Reimplemented from CubitEntity.

Reimplemented in Body.

Definition at line 1199 of file RefEntity.cpp.

{
  return mColor;
}

Make temporary TDCompare objects and attach to "this" and the "partner" object.

Definition at line 818 of file RefEntity.cpp.

virtual DagType RefEntity::dag_type ( ) const [pure virtual]

Returns the dag type of this enity.

Implemented in RefFace, BasicTopologyEntity, RefVolume, RefEdge, RefGroup, Body, and RefVertex.

DagType RefEntity::dag_type ( const std::type_info &  type) [static]

Translates the type info into dag type.

Definition at line 258 of file RefEntity.cpp.

{
  if (type == typeid(Body))
    return DagType::body_type();
  else if (type == typeid(RefVolume))
    return DagType::ref_volume_type();
  else if (type == typeid(RefFace))
    return DagType::ref_face_type();
  else if (type == typeid(RefEdge))
    return DagType::ref_edge_type();
  else if (type == typeid(RefVertex))
    return DagType::ref_vertex_type();
  
  assert(0);
  return DagType::invalid_type();
}
DagType RefEntity::dag_type ( const char *  cli_type_name) [static]

Returns a dag type based on name passed in, i.e., body, volume, surface..

Definition at line 1156 of file RefEntity.cpp.

{
  if (CubitUtil::compare(name,"body"))
    return DagType::body_type();
  else if (CubitUtil::compare(name,"volume"))
    return DagType::ref_volume_type();
  else if (CubitUtil::compare(name,"surface"))
    return DagType::ref_face_type();
  else if (CubitUtil::compare(name,"curve"))
    return DagType::ref_edge_type();
  else if (CubitUtil::compare(name,"vertex"))
    return DagType::ref_vertex_type();
  else
    return DagType();
}
int RefEntity::dimension ( ) const [virtual]

Returns the geometric dimension of the entity. vertex == 0, edge == 1, etc.

Reimplemented in RefFace, RefVolume, RefEdge, and RefVertex.

Definition at line 452 of file RefEntity.cpp.

{
    // Virtual function. This is the default return value. 
    // Override in subclass if different return value is needed.
  return -1;
}
CubitString RefEntity::entity_name ( ) const [virtual]

Gets the name of this RefEntity.

Implements CubitEntity.

Definition at line 105 of file RefEntity.cpp.

{
  DLIList<CubitString> names;
  
    // Get the name(s) associated with this RefEntity.
  RefEntityName::instance()->get_refentity_name(this, names);
  
  CubitString name;
  
    // If there are no names, then create the default name and return it.
  if (names.size() == 0) 
  {
    name = class_name();
    name += " ";
    name += CubitString::number(entityId);
  } 
  else 
  {
    name = names.get();
  }
  
  return name;
}

Sets the name of this RefEntity.

Definition at line 91 of file RefEntity.cpp.

{
    // Add the new {RefEntity, Name} tuple to the RefEntityNameMap class.
    // Note that if this name already exists for another RefEntity, then
    // it will return with an error. 
  CubitStatus success = RefEntityName::instance()->
    add_refentity_name(this, name);
  
  if (success == CUBIT_SUCCESS)
    AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::ENTITY_NAME_CHANGED, this));

  return success;
}
void RefEntity::entity_names ( DLIList< CubitString > &  names) const

Gets the names of this RefEntity.

Definition at line 138 of file RefEntity.cpp.

virtual const std::type_info& RefEntity::entity_type_info ( ) const [pure virtual]

Returns the type info of this enity.

Implements CubitEntity.

Implemented in RefFace, RefVolume, RefEdge, RefGroup, Body, and RefVertex.

void RefEntity::gather_bdy_entities ( DLIList< RefEntity * > &  entity_list,
DLIList< RefEntity * > &  bdy_list 
) [static]

Gather the boundary entities of the entity_list into the bdy_list. Entities appear once in bdy_list, and will not appear in bdy_list if they are already in the entity_list. Uses listMark.

Definition at line 1026 of file RefEntity.cpp.

{
  RefEntity *entity;
  DLIList<RefEntity*> tmp_bdy_list;
  int i;

  for ( i = entity_list.size(); i--; )
  {
    entity = entity_list.get_and_step();
    entity->list_mark( CUBIT_TRUE );
    //entity->get_all_child_ref_entities( tmp_bdy_list );
  }
    
  get_all_child_ref_entities(entity_list, tmp_bdy_list);


    // copy non-duplicate and non-entity_list entities
  for ( i = tmp_bdy_list.size(); i--; ) {
    entity = tmp_bdy_list.get_and_step();
    if ( !entity->list_mark() ) {
      bdy_list.append( entity );
      entity->list_mark( CUBIT_TRUE );
    }
  }
    // clean-up
  for ( i = bdy_list.size(); i--; ) {
    entity = bdy_list.get_and_step();
    entity->list_mark( CUBIT_FALSE );
  }
  for ( i = entity_list.size(); i--; ) {
    entity = entity_list.get_and_step();
    entity->list_mark( CUBIT_FALSE );
  }
}

Generates a default name for this RefEntity. 'name' is prepended to the default name.

Definition at line 164 of file RefEntity.cpp.

{
  if ( CAST_TO( this, Body ) )
     name += CubitString("bod");
  else if ( CAST_TO( this, RefVolume ) )
     name += CubitString("vol");
  else if ( CAST_TO( this, RefFace ) )
     name += CubitString("sur");
  else if ( CAST_TO( this, RefEdge ) )
     name += CubitString("cur");
  else if ( CAST_TO( this, RefVertex ) )
     name += CubitString("ver");
  else if ( CAST_TO( this, RefGroup ) ) {
     //PRINT_INFO( "Debug: RefGroup entity name set in RefEntity::generate_default_name\n" );
    name += CubitString("gro");
  }
  else
  {
    PRINT_ERROR("Invalid entity: %s.\n",
                entity_name().c_str() );
    return CUBIT_FAILURE;
  }
    
  name += CubitString::number(entityId);
  return CUBIT_SUCCESS;
}

Appends all child RefEntities owned by this entity to entity_list. (The query recurses all the way down to RefEntities of dimension 0).

Definition at line 313 of file RefEntity.cpp.

{
  
  ModelQueryEngine *const mqe = ModelQueryEngine::instance();
  DagType child_type = get_child_ref_entity_type();
  DLIList<TopologyEntity*> query_output;
  TopologyEntity* this_me = dynamic_cast<TopologyEntity*>(this);

  // note that RefGroups are kind of shoe-horned into RefEntity
  // there are no children of a refgroup
  if(!this_me)
    return;  // 
 
    //While there are more child types
  while (child_type.is_valid())
  {
    mqe->query_model(*this_me, child_type, query_output);
    query_output.reset();
    for (int i = query_output.size(); i--; )
    {
      RefEntity* ref_ptr = dynamic_cast<RefEntity*>(query_output.get_and_step());
      if (ref_ptr)
        entity_list.append(ref_ptr);
    }
    
    child_type = get_child_ref_entity_type( child_type );
  }
}
void RefEntity::get_all_child_ref_entities ( DLIList< RefEntity * > &  input_list,
DLIList< RefEntity * > &  output_list 
) [static]

Appends all child RefEntities owned by entities in input_list to output_list.

Definition at line 353 of file RefEntity.cpp.

{
  DLIList<TopologyEntity*> query_output;
  ModelQueryEngine *const mqe = ModelQueryEngine::instance();
  int i;
  
    // Find parent-most type from all passed entities
  DagType target_type = DagType::ref_vertex_type();
  for (i = input_list.size(); i--; )
  {
    DagType type = input_list.step_and_get()->dag_type();
    if (type.is_valid() && type > target_type)
      target_type = type;
  }
  
  target_type = get_child_ref_entity_type( target_type );
  while (target_type.is_valid())
  {
    input_list.reset();
    for (i = input_list.size(); i--; )
    {
      RefEntity* input_ptr = input_list.get_and_step();
      DagType source_type = input_ptr->dag_type();

      if (source_type.is_valid() && source_type > target_type)
      {
        TopologyEntity* me_ptr = dynamic_cast<TopologyEntity*>(input_ptr);
        assert(!!me_ptr);
        mqe->query_model (*me_ptr, target_type, query_output);
        
        query_output.size();
        for ( int j = query_output.size(); j--; )
        {
          RefEntity* ref_ent = dynamic_cast<RefEntity*>(query_output.get_and_step());
          output_list.append( ref_ent );
        }
      }
    }
    
    target_type = get_child_ref_entity_type( target_type );

  }
}
void RefEntity::get_all_parent_ref_entities ( DLIList< RefEntity * > &  entity_list,
const int  get_bodies = CUBIT_FALSE 
)

Appends all parent RefEntities owned by this entity to entity_list. Recurses up to RefVolumes, or RefBodies if get_bodies is true.

Definition at line 407 of file RefEntity.cpp.

{
  
  ModelQueryEngine *const mqe = ModelQueryEngine::instance();
  DagType parent_type = get_parent_ref_entity_type();
  DLIList<TopologyEntity*> query_output;
  TopologyEntity* this_me = dynamic_cast<TopologyEntity*>(this);
  assert(!!this_me);
 
    //While there are more parent types
  while ( parent_type.is_valid() && 
          (get_bodies || (parent_type != DagType::body_type())) )
  {
    mqe->query_model(*this_me, parent_type, query_output);
    query_output.reset();
    for (int i = query_output.size(); i--; )
    {
      RefEntity* ref_ptr = dynamic_cast<RefEntity*>(query_output.get_and_step());
      assert(!!ref_ptr);
      entity_list.append(ref_ptr);
    }
    
    parent_type = get_parent_ref_entity_type( parent_type );
  }
}
RefEntity * RefEntity::get_by_name ( const CubitString name) [static]

Gets the RefEntity with the passed in name.

Definition at line 86 of file RefEntity.cpp.

void RefEntity::get_child_ref_entities ( DLIList< RefEntity * > &  entity_list) [virtual]

Appends all immediate (child) RefEntities owned by this RefEntity to entity_list. (The query goes down just one dimension.)

Reimplemented in RefGroup.

Definition at line 275 of file RefEntity.cpp.

{
  // First get the type of RefEntity that is a child of "this" one
  DagType child_type = get_child_ref_entity_type();
  
  DLIList<TopologyEntity*> tempList ;
  
    // Now retrieve the appropriate type of child entities of this one
    // if the child_type is a valid type
  if (child_type.is_valid())
  {
    TopologyEntity* TopologyEntityPtr = CAST_TO(this, TopologyEntity) ;
    
    assert(TopologyEntityPtr != 0);
    
    CubitStatus result = ModelQueryEngine::instance()->
        query_model( *TopologyEntityPtr, child_type, tempList );
    if (result == CUBIT_FAILURE)
    {
      PRINT_ERROR("In RefEntity::get_child_ref_entities\n");
      PRINT_ERROR("       Query failed for unknown reason.\n");
      return;
    }
   
    CAST_LIST(tempList, entity_list, RefEntity) ;
  }
}

Gets the child RefEntity type.

Definition at line 247 of file RefEntity.cpp.

Given a parent dag type, returns the child dag type.

Definition at line 249 of file RefEntity.cpp.

{
  int dimension = my_type.dimension();
  if (my_type.functional_type() == DagType::BasicTopologyEntity_TYPE)
    return DagType(dimension - 1, DagType::BasicTopologyEntity_TYPE);
  else
    return DagType(dimension, DagType::BasicTopologyEntity_TYPE);
}

R RefEntity* R- The partner set in add_compare_data(), or NULL if none R- has been set.

Definition at line 895 of file RefEntity.cpp.

{
  ToolData* tdPtr = get_TD(&TDCompare::is_compare) ;
  TDCompare* tdComparePtr = CAST_TO(tdPtr, TDCompare) ;
  return tdComparePtr ? tdComparePtr->get_compare_partner() : 0;
}
const std::type_info & RefEntity::get_entity_type_info ( const char *  entity_type) [static]

Returns the type of a class given the class name.

Definition at line 1135 of file RefEntity.cpp.

{
  CubitString string(entity_type);
  string.to_lower();
  
  if( string == "group" )
     return typeid(RefGroup);
  else if (string == "body" )
     return typeid(Body);
  else if( string == "volume" )
     return typeid(RefVolume);
  else if( string == "surface" )
     return typeid(RefFace);
  else if( string == "curve" )
     return typeid(RefEdge);
  else if( string == "vertex" )
     return typeid(RefVertex);
  else
     return typeid(InvalidEntity);
}
virtual void RefEntity::get_parent_ref_entities ( DLIList< RefEntity * > &  entity_list) [pure virtual]

Appends all RefEntities that own this (parent RefEntities) to entity_list. (The query goes up just one dimension. For example, if this is a vertex, the resulting list contains only RefEdges).

Implemented in RefFace, RefGroup, RefVolume, RefEdge, RefVertex, and Body.

Gets the parent RefEntity type.

Definition at line 230 of file RefEntity.cpp.

Given a child dag type, returns the parent dag type.

Definition at line 232 of file RefEntity.cpp.

{
  int dimension = my_type.dimension();

    // special case for bodies
  if (dimension == 3)
  {
    if (my_type.functional_type() == DagType::BasicTopologyEntity_TYPE)
      return DagType::body_type();
    else
      return DagType::invalid_type();
  }
  
  return DagType( dimension + 1, DagType::BasicTopologyEntity_TYPE);
}
static const char* RefEntity::get_ref_class_name ( const std::type_info &  ref_type) [static]

Gets the class name of a RefEntity type.

void RefEntity::get_related_entity_list ( const std::type_info &  related_entity_type,
DLIList< RefEntity * > &  entity_list 
)

Definition at line 1074 of file RefEntity.cpp.

{
  if (related_entity_type == typeid(RefGroup)){
    DLIList <CubitObserver*> observer_list;
    this->get_observer_list (observer_list);
    for (int i = observer_list.size(); i > 0; i--){
      entity_list.append_unique (CAST_TO (observer_list.get(), RefEntity));
      observer_list.step();
    }
  }
}
CubitBoolean RefEntity::is_child ( RefEntity entity) [virtual]

Definition at line 929 of file RefEntity.cpp.

{
    // same?
  if ( this == entity )
    return CUBIT_TRUE;
  
    // wrong dimensions?
  if (!entity || dimension() >= entity->dimension() )
    return CUBIT_FALSE;
  
    // Topological query.
    // Usually slightly faster to search up in dimension.
  TopologyEntity *topo_this = CAST_TO( this, TopologyEntity );
  TopologyEntity *topo_entity = CAST_TO( entity, TopologyEntity );  
  return topo_this->is_directly_related( topo_entity );
}
void RefEntity::is_mergeable ( AutoMergeStatus  val) [virtual]

Setting auto merge status flag.

Reimplemented in RefGroup.

Definition at line 699 of file RefEntity.cpp.

{
  AutoMergeStatus old_status = (AutoMergeStatus)(autoMergeStatus & 1);
  autoMergeStatus = (int)val;
  
    // always want to update children, but update_auto_merge_state
    // recursively updates the children, so don't update the
    // children twice if we call update_auto_merge_state.
  if( val == AUTO_MERGE_AUTO )
  {
    this->update_auto_merge_state();
  }
  else if( old_status != val )
  {
    DLIList<RefEntity*> children;
    get_child_ref_entities( children );
    for( int i = children.size(); i--; )
      children.get_and_step()->update_auto_merge_state();
  }
}

Query to see if entity is free to merge.

Reimplemented in RefGroup.

Definition at line 720 of file RefEntity.cpp.

{
    // return 0-bit of autoMergeState
  return (bool)(autoMergeStatus & 1);
}

Query to see if entity is merged.

Definition at line 726 of file RefEntity.cpp.

{
  TopologyEntity* topo = CAST_TO(this, TopologyEntity);
  if (!topo)
    return CUBIT_FALSE;

  return MergeTool::instance()->entity_merged(topo);
}
CubitBoolean RefEntity::is_parent ( RefEntity entity) [virtual]

Definition at line 946 of file RefEntity.cpp.

{
    // same?
  if ( this == entity )
    return CUBIT_TRUE;
  
    // wrong dimensions?
  if (!entity || dimension() <= entity->dimension() )
    return CUBIT_FALSE;

    // Topological query. 
    // Usually slightly faster to search up in dimension.
  BasicTopologyEntity *topo_this = CAST_TO( this, BasicTopologyEntity );
  BasicTopologyEntity *topo_entity = CAST_TO( entity, BasicTopologyEntity );  
  return topo_entity->is_directly_related( topo_this );
}
RefEntity * RefEntity::join ( RefEntity ref_entity_2,
DLIList< RefEntity * > &  join_set 
)

RefEntity* join( RefEntity* ref_entity_2 ); Computes the geometric "join" of elements (elements on the list or this and ref_entity_2). Definition "Join" = The lowest dimensional entitity that is a higher dimensional ancestor of them all. Note join could be one of the entities itself, NULL, or multiple elements. E.g. The join of a vertex and a curve containing the vertex is the curve. The join of two curves of a split cylinder is both containing surfaces. The join of two entities in separate, unmerged volumes is null. Returns the first element of the join_set, or NULL if set is empty.

Definition at line 560 of file RefEntity.cpp.

{
  join_set.clean_out();
  assert( this != 0 );
  
    // Trivial case :-)
    // Both entities are the same, or 
    // The join of the empty set and any thing is defined to be the thing.
  if (this == ref_entity_2 || ref_entity_2 == NULL ) 
  { 
    join_set.append( this );
    return this;
  }
  
    // call generic function that takes a list
  DLIList<RefEntity*> both_entities;
  both_entities.append( this );
  both_entities.append( ref_entity_2 );
  return join( both_entities, join_set );
}
RefEntity * RefEntity::join ( DLIList< RefEntity * > &  ref_entities,
DLIList< RefEntity * > &  join_set 
) [static]

RefEntity* join( RefEntity* ref_entity_2 ); Computes the geometric "join" of elements (elements on the list or this and ref_entity_2). Definition "Join" = The lowest dimensional entitity that is a higher dimensional ancestor of them all. Note join could be one of the entities itself, NULL, or multiple elements. E.g. The join of a vertex and a curve containing the vertex is the curve. The join of two curves of a split cylinder is both containing surfaces. The join of two entities in separate, unmerged volumes is null. Returns the first element of the join_set, or NULL if set is empty.

Definition at line 460 of file RefEntity.cpp.

{
  join_set.clean_out();

    // Trivial cases 
  
    // empty set
  if ( !ref_entities.size() )
    return NULL;
  
    // All entities are the same, e.g. list is size 1
  int i, j;
  int all_same = CUBIT_TRUE;
  RefEntity *e1, *e2;
  for (i = ref_entities.size()-1; all_same && i--; )
  {
    e1 = ref_entities.get_and_step();
    e2 = ref_entities.get();
    all_same = ( e1 == e2 );
  }
  if ( all_same )
  {
    join_set.append( ref_entities.get() );
    return join_set.get();
  }  
  
    // Generic test, build ancestor lists until dimensions are equal
  const int size = ref_entities.size();

    // Lists of ancestors
  DLIList<RefEntity*> *ancestors = new DLIList<RefEntity*> [ size ];
    // current dimension of ancestors of each entity
  int *dimension = new int [size];
    // Set ancestors and dimension: Start with the entities themselves
  int d1, max_dimension = -1;
  ref_entities.reset();
  for ( i = 0; i < size; i++ )
  {
    e1 = ref_entities.get_and_step();
    ancestors[i].append( e1 );
    dimension[i] = d1 = e1->dimension();
    if ( d1 > max_dimension )
      max_dimension = d1;
  }
  
  do
  {

    // Bump dimensions up to max dimension
    for ( i = 0; i < size; i++ )
    {
      while ( dimension[i] < max_dimension ) 
      {
        change_to_parent_ref_entities( ancestors[i] );
          // no ancestor of max dimension -> join is nothing
        if ( !ancestors[i].size() )
          goto clean_return;
        dimension[i] = d1 = ancestors[i].get()->dimension();
          // if somehow a dimension was skipped, go through the list again.
        if ( d1 > max_dimension )
        {
          max_dimension = d1;
          i = 0; // restart loop
        }
      }
    }

      // dimensions are the same, see if any entities common to *all* lists
    for ( j = ancestors[0].size(); j--; )
    {
      e1 = ancestors[0].get_and_step();
      int in_all_lists = CUBIT_TRUE;
      for ( i = 1; in_all_lists && i < size; i++ )
      {
        in_all_lists = ancestors[i].is_in_list( e1 );
      }
      if ( in_all_lists )
        join_set.append( e1 );
    } 
    
      // iterate
    max_dimension++;
    
      // they had common entities in the current dimension - return
  } while ( join_set.size() == 0 );
  
    clean_return:
  delete [] dimension;
  delete [] ancestors;

  if ( join_set.size() )
  {
    join_set.reset();
    return join_set.get();
  }
  return NULL;
}
void RefEntity::list_mark ( int  value) [inline, private]

Definition at line 353 of file RefEntity.hpp.

{listFlag = value;}
int RefEntity::list_mark ( ) [inline, private]

Definition at line 357 of file RefEntity.hpp.

{return listFlag;}
void RefEntity::local_tolerance ( double  value) [inline]

Get and set the local tolerance of this RefEntity. This is used in tolerant imprinting.

Definition at line 313 of file RefEntity.hpp.

{ localTolerance = value; }
double RefEntity::local_tolerance ( void  ) [inline]

Definition at line 314 of file RefEntity.hpp.

{ return localTolerance; }
void RefEntity::marked ( int  value) [inline, virtual]

Definition at line 345 of file RefEntity.hpp.

{markedFlag = value;}
int RefEntity::marked ( ) [inline, virtual]

Definition at line 349 of file RefEntity.hpp.

{return (int) markedFlag;}
double RefEntity::measure ( ) [virtual]

A generic geometric extent function. Returns volume for RefVolumes, area for RefFaces, length for RefEdge, and 1.0 for RefVertices A RefGroup calculates the maximum dimension of its contained entities and returns the sum of the measures() of all entities of that dimension. Default return value is 0.0 for all other entities.

Reimplemented in RefFace, RefEdge, BasicTopologyEntity, and Body.

Definition at line 783 of file RefEntity.cpp.

{
  return 0.0;
}

Returns the type of measure: (volume, area, length, or N/A)

Reimplemented in RefFace, RefEdge, RefVolume, and Body.

Definition at line 788 of file RefEntity.cpp.

{
  return "N/A";
}
RefEntity * RefEntity::meet ( RefEntity ref_entity_2,
DLIList< RefEntity * > &  join_set 
)

Definition at line 652 of file RefEntity.cpp.

{
  join_set.clean_out();
  assert( this != 0 );
  
    // Trivial case :-)
    // Both entities are the same, or 
    // The join of the empty set and any thing is defined to be the thing.
  if (this == ref_entity_2 || ref_entity_2 == NULL ) 
  { 
    join_set.append( this );
    return this;
  }
  
    // call generic function that takes a list
  DLIList<RefEntity*> both_entities;
  both_entities.append( this );
  both_entities.append( ref_entity_2 );
  return meet( both_entities, join_set );
}
RefEntity * RefEntity::meet ( DLIList< RefEntity * > &  ref_entities,
DLIList< RefEntity * > &  join_set 
) [static]

Definition at line 581 of file RefEntity.cpp.

{
  join_set.clean_out();

    // Trivial cases 
  
    // empty set
  if ( !ref_entities.size() )
    return NULL;
  
    // All entities are the same, e.g. list is size 1
  int i, j;
  int all_same = CUBIT_TRUE;
  RefEntity *e1, *e2;
  for (i = ref_entities.size()-1; all_same && i--; )
  {
    e1 = ref_entities.get_and_step();
    e2 = ref_entities.get();
    all_same = ( e1 == e2 );
  }
  if ( all_same )
  {
    join_set.append(ref_entities.get());
    return ref_entities.get();
  }  

    // they aren't all the same; get all the children, intersect the lists,
    // and remove any related entities
  DLIList<RefEntity*> temp_list;
  ref_entities.get()->get_all_child_ref_entities(join_set);
  join_set.append(ref_entities.get_and_step());
  
  for (i = ref_entities.size(); i > 1; i--) {
    temp_list.clean_out();
    ref_entities.get()->get_all_child_ref_entities(temp_list);
    temp_list.append(ref_entities.get_and_step());
    join_set.intersect(temp_list);

      // if the join set is null at any time, there's no common entity
    if (join_set.size() == 0) return NULL;
  }

  temp_list.clean_out();

    // clean out any duplicates before checking for relations
  temp_list.merge_unique(join_set);
  join_set = temp_list;
  temp_list.clean_out();
  
    // now remove any related entities
  join_set.reset();
  join_set.step();
  for (i = join_set.size()-1; i > 0; i--) {
    RefEntity *entity = join_set.get();
    if (temp_list.move_to(entity)) continue;
    
    for (j = join_set.size()-i; j > 0; j--) {
      RefEntity *other_entity = join_set.prev(j);
      if (temp_list.move_to(other_entity)) continue;
      if (entity->is_child(other_entity)) temp_list.append(entity);
      else if (entity->is_parent(other_entity)) temp_list.append(other_entity);
    }
    join_set.step();
  }
  
  if (temp_list.size() > 0) join_set -= temp_list;

  return (join_set.size() ? join_set.get() : NULL);
}
void RefEntity::merge_entity_names ( RefEntity dead_entity)

Definition at line 210 of file RefEntity.cpp.

Gets auto merge status flag.

Definition at line 735 of file RefEntity.cpp.

send event to all observers (static and non-static) for this entity and all children

Definition at line 794 of file RefEntity.cpp.

{
  DLIList<RefEntity*> entity_list;
  get_all_child_ref_entities( entity_list );
  for ( int i = entity_list.size(); i>0; i-- )
  {
    RefEntity* ent = entity_list.get_and_step();
    AppUtil::instance()->send_event(GeometryEvent(event, ent));
  }
  AppUtil::instance()->send_event(GeometryEvent(event, this));
}
int RefEntity::num_names ( ) const

Get the number of names this RefEntity has.

Definition at line 129 of file RefEntity.cpp.

{
  DLIList<CubitString> names;
  
  // Get the name(s) associated with this RefEntity.
  RefEntityName::instance()->get_refentity_name(this, names);
  return names.size();
}

returns the number of parent entities of this; also useful for determining whether an entity is free or not; returns -1 on error

Definition at line 963 of file RefEntity.cpp.

{
    // First get the type of RefEntity that is a parent of "this" one
  DagType parent_type = get_parent_ref_entity_type();
  
  DLIList<TopologyEntity*> tempList ;
  
    // Now retrieve the appropriate type of parent entities of this one,
    // if the parent_type is a valid type
  if (parent_type.is_valid())
  {
    TopologyEntity* TopologyEntityPtr = CAST_TO(this, TopologyEntity) ;
    
      //Make sure that we have a valid pointer
    assert(TopologyEntityPtr != NULL) ;
    
    CubitStatus result = ModelQueryEngine::instance()->
        query_model( *TopologyEntityPtr,
                     parent_type,
                     tempList );
    if (result == CUBIT_FAILURE)
    {
      PRINT_ERROR("In RefEntity::num_parent_ref_entities\n");
      PRINT_ERROR("       Query failed for unknown reason.\n");
      return -1;
    }
    return tempList.size();
  }

  return -1;
}
void RefEntity::operator= ( const RefEntity ) [private]
  • This function clears the compare related temporary data.

Definition at line 868 of file RefEntity.cpp.

{
  ToolData* tdPtr = this->get_TD(&TDCompare::is_compare) ;
  TDCompare* tdComparePtr = CAST_TO(tdPtr, TDCompare) ;
  
  if (tdComparePtr == NULL)
  {
    return ;
  }
  RefEntity* partner = tdComparePtr->get_compare_partner() ;

  if (partner != NULL)
    {
      PRINT_DEBUG_19(
          "RefEntity::remove_compare_data - Removing TDCompare from"
          " %s %d, via partner %s %d\n",
          partner->class_name(),
          partner->id(),
          this->class_name(),
          this->id());
      partner->delete_TD(&TDCompare::is_compare) ;
    }
  
  this->delete_TD(&TDCompare::is_compare) ;
//   partner->delete_TD(&TDCompare::is_compare) ;
}
void RefEntity::set_id ( int  i) [virtual]

Set the id of this RefEntity to i.

Reimplemented from CubitEntity.

Definition at line 1087 of file RefEntity.cpp.

{
  set_id( i, CUBIT_TRUE );
}
void RefEntity::set_id ( int  i,
CubitBoolean  emit_event 
)

Sets the id of this RefEntity and emits specified event static observers.

Definition at line 1092 of file RefEntity.cpp.

{
  if (entityId == i)
    return;
 
  int old_id = entityId;
  entityId = i;

  if( emit_event )
    AppUtil::instance()->send_event(GeometryIdSetEvent(this, old_id, entityId) );

  int old_max = RefEntityFactory::instance()->maximum_id(this);
  
  if (old_max < entityId)
      // Need to reset the maxId for this entitytype
    RefEntityFactory::instance()->incorporate_id(this);
  else if (old_max == old_id) 
  {
      // We just reset the entity with the max id to something less
      // than that - should search and find out what the max id
      // is now.
    DLIList<RefEntity*> ent_list;
    if(this->entity_type_info() == typeid(Body))
      RefEntityFactory::instance()->ref_entity_list("body", ent_list);
    else if(this->entity_type_info() == typeid(RefVolume))
      RefEntityFactory::instance()->ref_entity_list("volume", ent_list);
    else if(this->entity_type_info() == typeid(RefFace))
      RefEntityFactory::instance()->ref_entity_list("surface", ent_list);
    else if(this->entity_type_info() == typeid(RefEdge))
      RefEntityFactory::instance()->ref_entity_list("curve", ent_list);
    else if(this->entity_type_info() == typeid(RefVertex))
      RefEntityFactory::instance()->ref_entity_list("vertex", ent_list);

    int max_id = 0;
    for(int i=ent_list.size()-1; i>-1; i--)
    {
      if(ent_list[i]->id() > max_id)
        max_id = ent_list[i]->id();
    }
    RefEntityFactory::instance()->maximum_id(this->entity_type_info(), max_id);
  }
}
void RefEntity::switch_entity_names ( RefEntity other_entity)

Definition at line 215 of file RefEntity.cpp.

{
  RefEntityName::instance()->switch_refentity_names(this, other_entity);
}

Updates the auto merge state of the entity.

Definition at line 752 of file RefEntity.cpp.

{
  int i;
  
  if( autoMergeStatus & 2 )
  {
    int mergeable = 1;
    
    DLIList<RefEntity*> list;

    get_parent_ref_entities( list );
    for( i = list.size(); i--; )
      if( ! list.get_and_step()->is_mergeable() )
        mergeable = 0;
  
    int old_value = autoMergeStatus & 1;
    if( old_value != mergeable )
    {
      autoMergeStatus = (autoMergeStatus & 2) | mergeable;
  
      list.clean_out();
      get_child_ref_entities( list );
    
      for( i = list.size(); i--; )
        list.get_and_step()->update_auto_merge_state();
    }    
  }
}
int RefEntity::valence ( RefEntity parent = NULL)

the valence of this entity with respect to parent (absolute valence if parent is null)

Definition at line 673 of file RefEntity.cpp.

{
  DLIList<RefEntity*> parents;
  get_parent_ref_entities(parents);
  if (parent == NULL) return parents.size();
  
  int val = parents.size();
  int i;
  BasicTopologyEntity *topo_ent = CAST_TO(this, BasicTopologyEntity);
  for (i = val; i > 0; i--) {
    RefEntity *other_ent = parents.get_and_step();
    if (!topo_ent->is_directly_related(CAST_TO(other_ent, BasicTopologyEntity))) val--; 
  }
  
  return val;
}
int RefEntity::validate ( ) [virtual]

Perform checks to see if entity valid.

Reimplemented in RefEdge, RefFace, RefVolume, RefGroup, and Body.

Definition at line 902 of file RefEntity.cpp.

{
    //- This function determines whether the entity is valid.
    //- Several types of checks can be done, 
  
    // Check that measure is positive
  int error = 0;

  Body *tmp_body = CAST_TO( this, Body);
  bool is_sheet_body = false;
  if( tmp_body )
    is_sheet_body = tmp_body->is_sheet_body();
  
  if( false == is_sheet_body )
  {
    double this_measure = measure();
    if (this_measure <= 0.0) {
      PRINT_WARNING("\tWARNING: non-positive %s (%f) for %s, (%s %d)\n",
                    measure_label().c_str(), this_measure,
                    entity_name().c_str(), class_name(), id());
      error++;
    }  
  }
  return error;
}

Member Data Documentation

int RefEntity::autoMergeStatus [protected]

Definition at line 318 of file RefEntity.hpp.

Bit RefEntity::listFlag [protected]

Definition at line 322 of file RefEntity.hpp.

double RefEntity::localTolerance [private]

Definition at line 338 of file RefEntity.hpp.

int RefEntity::markedFlag [protected]

Reimplemented in RefEdge.

Definition at line 320 of file RefEntity.hpp.

int RefEntity::mColor [protected]

Definition at line 324 of file RefEntity.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines