cgma
RefEntityFactory Class Reference

#include <RefEntityFactory.hpp>

Inheritance diagram for RefEntityFactory:
CubitObserver

List of all members.

Public Member Functions

virtual RefVertexconstruct_RefVertex (TBPoint *point=NULL)
virtual RefEdgeconstruct_RefEdge (Curve *curve=NULL)
virtual RefFaceconstruct_RefFace (Surface *surface=NULL)
virtual RefVolumeconstruct_RefVolume (Lump *lump=NULL)
virtual Bodyconstruct_Body (BodySM *body_sm=NULL)
virtual RefGroupconstruct_RefGroup (const char *name=NULL)
virtual RefGroupconstruct_RefGroup (DLIList< RefEntity * > &entity_list)
virtual CubitStatus ref_entity_list (char const *keyword, DLIList< RefEntity * > &entity_list, const CubitBoolean print_errors=CUBIT_TRUE)
virtual void bodies (DLIList< Body * > &bodies)
virtual void ref_volumes (DLIList< RefVolume * > &ref_volumes)
virtual void ref_groups (DLIList< RefGroup * > &ref_groups)
virtual void ref_faces (DLIList< RefFace * > &ref_faces)
virtual void ref_edges (DLIList< RefEdge * > &ref_edges)
virtual void ref_vertices (DLIList< RefVertex * > &ref_vertices)
virtual int num_bodies () const
virtual int num_ref_volumes () const
virtual int num_ref_groups () const
virtual int num_ref_faces () const
virtual int num_ref_edges () const
virtual int num_ref_vertices () const
virtual RefEntityget_ref_entity (const char *type, int id)
virtual RefEntityget_ref_entity (const std::type_info &type, int id)
virtual Bodyget_body (int id)
virtual RefVolumeget_ref_volume (int id)
virtual RefGroupget_ref_group (int id)
virtual RefFaceget_ref_face (int id)
virtual RefEdgeget_ref_edge (int id)
virtual RefVertexget_ref_vertex (int id)
virtual Bodyget_first_body ()
virtual RefVolumeget_first_ref_volume ()
virtual RefGroupget_first_ref_group ()
virtual RefFaceget_first_ref_face ()
virtual RefEdgeget_first_ref_edge ()
virtual RefVertexget_first_ref_vertex ()
virtual Bodyget_next_body ()
virtual RefVolumeget_next_ref_volume ()
virtual RefGroupget_next_ref_group ()
virtual RefFaceget_next_ref_face ()
virtual RefEdgeget_next_ref_edge ()
virtual RefVertexget_next_ref_vertex ()
virtual Bodyget_last_body ()
virtual RefVolumeget_last_ref_volume ()
virtual RefGroupget_last_ref_group ()
virtual RefFaceget_last_ref_face ()
virtual RefEdgeget_last_ref_edge ()
virtual RefVertexget_last_ref_vertex ()
virtual void add (RefEntity *ref_entity)
virtual void add (Body *bodyPtr)
virtual void add (RefVolume *refVolumePtr)
virtual void add (RefGroup *refGroupPtr)
virtual void add (RefFace *refFacePtr)
virtual void add (RefEdge *refEdgePtr)
virtual void add (RefVertex *refVertexPtr)
virtual void remove (RefEntity *ref_entity)
virtual void remove (RefVertex *refVertexPtr)
virtual void remove (RefEdge *refEdgePtr)
virtual void remove (RefFace *refFacePtr)
virtual void remove (RefGroup *refGroupPtr)
virtual void remove (RefVolume *refVolumePtr)
virtual void remove (Body *bodyPtr)
int next_body_id ()
int next_ref_volume_id ()
int next_ref_group_id ()
int next_ref_face_id ()
int next_ref_edge_id ()
int next_ref_vertex_id ()
int next_surf_sub_domain_id ()
int next_curve_sub_domain_id ()
int current_body_id ()
int current_volume_id ()
int current_group_id ()
int current_face_id ()
int current_edge_id ()
int current_vertex_id ()
void incorporate_id (RefEntity *ref_ent)
int maximum_id (const char *entity_type)
int maximum_id (RefEntity *ref_ent)
void maximum_id (const std::type_info &type, int max_id)
void compress_ref_ids (const char *entity_type, int retain_max_id)
void reset_ids ()
virtual void renumber_geometry_by_properties (CubitBoolean retain_max_ids)
void notify_observer (const CubitEvent *observer_event)

Static Public Member Functions

static RefEntityFactoryinstance ()
static void delete_instance ()
static void compress_ids (DLIList< CubitEntity * > &list)

Protected Member Functions

 RefEntityFactory (bool make_lists=true)
virtual ~RefEntityFactory ()

Protected Attributes

bool ManageListSorting
int maxBodyId
int maxRefVolumeId
int maxRefGroupId
int maxRefFaceId
int maxRefEdgeId
int maxRefVertexId
int maxRefCoordSysId
int maxSurfSubDomainId
int maxCurveSubDomainId

Static Protected Attributes

static RefEntityFactoryinstance_ = NULL

Private Attributes

bool refVertexListIsSorted
bool refEdgeListIsSorted
bool refFaceListIsSorted
bool refVolumeListIsSorted
bool bodyListIsSorted
bool refGroupListIsSorted
DLIList< RefVertex * > * refVertexList
DLIList< RefEdge * > * refEdgeList
DLIList< RefFace * > * refFaceList
DLIList< RefGroup * > * refGroupList
DLIList< RefVolume * > * refVolumeList
DLIList< Body * > * bodyList

Detailed Description

Definition at line 46 of file RefEntityFactory.hpp.


Constructor & Destructor Documentation

RefEntityFactory::RefEntityFactory ( bool  make_lists = true) [protected]

Definition at line 80 of file RefEntityFactory.cpp.

RefEntityFactory::~RefEntityFactory ( ) [protected, virtual]

Definition at line 125 of file RefEntityFactory.cpp.

{
  if (refVertexList != NULL) delete refVertexList;
  if (refEdgeList != NULL) delete refEdgeList;
  if (refFaceList != NULL) delete refFaceList;
  if (refGroupList != NULL) delete refGroupList;
  if (refVolumeList != NULL) delete refVolumeList;
  if (bodyList != NULL) delete bodyList;
  unregister_observer(this);
  instance_ = NULL;
}

Member Function Documentation

void RefEntityFactory::add ( RefEntity ref_entity) [virtual]

Definition at line 219 of file RefEntityFactory.cpp.

{
  assert(ref_entity != 0);
  
  RefGroup *group;
  RefVolume *volume;
  RefFace *face;
  RefEdge *edge;
  RefVertex *vertex;
  Body *body;

  if ( (group = CAST_TO(ref_entity, RefGroup)) != NULL ) {
    add(group);
  }
  else if ( (volume = CAST_TO(ref_entity, RefVolume)) != NULL ) {
    add(volume);
  }
  else if ( (face = CAST_TO(ref_entity, RefFace)) != NULL ) {
    add(face);
  }
  else if ( (edge = CAST_TO(ref_entity, RefEdge)) != NULL ) {
    add(edge);
  }
  else if ( (vertex = CAST_TO(ref_entity, RefVertex)) != NULL ) {
    add(vertex);
  }
  else if ( (body = CAST_TO(ref_entity, Body)) != NULL ) {
    add(body);
  }
}
void RefEntityFactory::add ( Body bodyPtr) [virtual]

Definition at line 263 of file RefEntityFactory.cpp.

{
   assert(!bodyList->is_in_list(bodyPtr));
   if(bodyList->size() > 0)
   {
    bodyList->last();
    if(ManageListSorting && bodyPtr->id() < bodyList->get()->id())
      bodyListIsSorted = false;
   }
   bodyList->append(bodyPtr);
   if (bodyPtr->id() > maxBodyId) maxBodyId = bodyPtr->id();
}
void RefEntityFactory::add ( RefVolume refVolumePtr) [virtual]

Definition at line 276 of file RefEntityFactory.cpp.

{
   assert(!refVolumeList->is_in_list(refVPtr));
   if(refVolumeList->size() > 0)
   {
    refVolumeList->last();
    if(ManageListSorting && refVPtr->id() < refVolumeList->get()->id())
      refVolumeListIsSorted = false;
   }
   refVolumeList->append(refVPtr);
   if (refVPtr->id() > maxRefVolumeId)
       maxRefVolumeId = refVPtr->id();
}
void RefEntityFactory::add ( RefGroup refGroupPtr) [virtual]

Definition at line 250 of file RefEntityFactory.cpp.

{
   assert(!refGroupList->is_in_list(refGPtr));
   if(refGroupList->size() > 0)
   {
    refGroupList->last();
    if(ManageListSorting && refGPtr->id() < refGroupList->get()->id())
      refGroupListIsSorted = false;
   }
   refGroupList->append(refGPtr);
   if (refGPtr->id() > maxRefGroupId) maxRefGroupId = refGPtr->id();
}
void RefEntityFactory::add ( RefFace refFacePtr) [virtual]

Definition at line 290 of file RefEntityFactory.cpp.

{
   assert(!refFaceList->is_in_list(refFPtr));
   if(refFaceList->size() > 0)
   {
    refFaceList->last();
    if(ManageListSorting && refFPtr->id() < refFaceList->get()->id())
      refFaceListIsSorted = false;
   }
   refFaceList->append(refFPtr);
   if (refFPtr->entityId > maxRefFaceId)
       maxRefFaceId = refFPtr->entityId;
}
void RefEntityFactory::add ( RefEdge refEdgePtr) [virtual]

Definition at line 304 of file RefEntityFactory.cpp.

{
   assert(!refEdgeList->is_in_list(refEPtr));
   if(refEdgeList->size() > 0)
   {
    refEdgeList->last();
    if(ManageListSorting && refEPtr->id() < refEdgeList->get()->id())
      refEdgeListIsSorted = false;
   }
   refEdgeList->append(refEPtr);
   if (refEPtr->id() > maxRefEdgeId)
       maxRefEdgeId = refEPtr->id();
}
void RefEntityFactory::add ( RefVertex refVertexPtr) [virtual]

Definition at line 318 of file RefEntityFactory.cpp.

{
   assert(!refVertexList->is_in_list(refVPtr));
   if(refVertexList->size() > 0)
   {
    refVertexList->last();
    if(ManageListSorting && refVPtr->id() < refVertexList->get()->id())
      refVertexListIsSorted = false;
   }
   refVertexList->append(refVPtr);
   if (refVPtr->id() > maxRefVertexId)
       maxRefVertexId = refVPtr->id();
}
void RefEntityFactory::bodies ( DLIList< Body * > &  bodies) [virtual]

Definition at line 436 of file RefEntityFactory.cpp.

{
  bodies = *bodyList;
}
void RefEntityFactory::compress_ids ( DLIList< CubitEntity * > &  list) [static]

Definition at line 1110 of file RefEntityFactory.cpp.

{
  int id = 1;
  CubitEntity* entity;
  
  if (list.size())
  {
    list.reset();
      // if these are ref volumes, recompute color
    CubitBoolean set_color = CUBIT_FALSE;
    if (CAST_TO(list.get(), RefVolume)) set_color = CUBIT_TRUE;

    // sort list so ids of entities are ascending order
    list.sort( sort_by_ascending_ids); 

    for (int i=list.size(); i > 0; i--)
    {
      entity = list.get_and_step();
      if (entity->id() != id){
        entity->set_id(id);
        if (set_color) {
          entity->color(CUBIT_DEFAULT_COLOR_INDEX);
        }
      }
      id++;
    }
  }
}
void RefEntityFactory::compress_ref_ids ( const char *  entity_type,
int  retain_max_id 
)

Definition at line 1061 of file RefEntityFactory.cpp.

{
  const std::type_info& type = RefEntity::get_entity_type_info(entity_type);
  assert(type != typeid(InvalidEntity));
  
  /*
#ifdef VIRTUAL_GEOMETRY_ENGINE_HPP
  VirtualGeometryEngine::instance()->
    hidden_entity_mngr.compress_hidden_ids(type);
#endif
  */
/*  
  DLIList<GeometryQueryEngine*> gqeList;
  GeometryQueryTool::instance()->get_gqe_list(gqeList);//Get the gqeList from the GQT 
  gqeList.reset();
  int i;
  for (i = 0; i < gqeList.size(); i++)//Step through the list and call compress_ids.
  {                                   //The VGE is the only engine that will do work. 
    gqeList.get_and_step()->compress_ids(type);
  }
*/

  DLIList<CubitEntity*> list;
  DLIList<RefEntity*> temp_list;
  CubitStatus result = ref_entity_list(entity_type, temp_list, CUBIT_FALSE);
  if (  result == CUBIT_SUCCESS ) {
    CAST_LIST_TO_PARENT(temp_list, list);
    compress_ids(list);
  }
  
    // set the maximum entity id to the new max values.
  if (!retain_max_id)
  {
        // must use the num_xxx() functions here, since we may have a derived factory!
    if( type == typeid(RefGroup) )
       maxRefGroupId = num_ref_groups();
    else if( type == typeid(Body) )
       maxBodyId = num_bodies();
    else if( type == typeid(RefVolume) )
       maxRefVolumeId = num_ref_volumes();
    else if( type == typeid(RefFace) )
       maxRefFaceId = num_ref_faces();
    else if( type == typeid(RefEdge) )
       maxRefEdgeId = num_ref_edges();
    else if( type == typeid(RefVertex) )
       maxRefVertexId = num_ref_vertices();
  }
}
Body * RefEntityFactory::construct_Body ( BodySM body_sm = NULL) [virtual]

Definition at line 165 of file RefEntityFactory.cpp.

{
  Body *temp = new Body(body_sm);
  AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED, temp));
  return temp;
}
RefEdge * RefEntityFactory::construct_RefEdge ( Curve curve = NULL) [virtual]

Definition at line 144 of file RefEntityFactory.cpp.

{
  RefEdge *temp = new RefEdge(curve);
  AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED, temp));
  return temp;
}
RefFace * RefEntityFactory::construct_RefFace ( Surface surface = NULL) [virtual]

Definition at line 151 of file RefEntityFactory.cpp.

{
  RefFace *temp = new RefFace(surface);
  AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED, temp));
  return temp;
}
RefGroup * RefEntityFactory::construct_RefGroup ( const char *  name = NULL) [virtual]

Definition at line 172 of file RefEntityFactory.cpp.

{
  RefGroup *temp = new RefGroup(name);
  AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED, temp));
  return temp;
}
RefGroup * RefEntityFactory::construct_RefGroup ( DLIList< RefEntity * > &  entity_list) [virtual]

Definition at line 179 of file RefEntityFactory.cpp.

{
  RefGroup *temp = new RefGroup(entity_list);
  AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED, temp));
  return temp;
}
RefVertex * RefEntityFactory::construct_RefVertex ( TBPoint point = NULL) [virtual]

Definition at line 137 of file RefEntityFactory.cpp.

{
  RefVertex *temp = new RefVertex(point);
  AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED, temp));
  return temp;
}
RefVolume * RefEntityFactory::construct_RefVolume ( Lump lump = NULL) [virtual]

Definition at line 158 of file RefEntityFactory.cpp.

{
  RefVolume *temp = new RefVolume(lump);
  AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED, temp));
  return temp;
}

Definition at line 151 of file RefEntityFactory.hpp.

{return maxBodyId;};

Definition at line 155 of file RefEntityFactory.hpp.

{return maxRefEdgeId;};

Definition at line 154 of file RefEntityFactory.hpp.

{return maxRefFaceId;};

Definition at line 153 of file RefEntityFactory.hpp.

{return maxRefGroupId;};

Definition at line 156 of file RefEntityFactory.hpp.

{return maxRefVertexId;};

Definition at line 152 of file RefEntityFactory.hpp.

{return maxRefVolumeId;};

Definition at line 116 of file RefEntityFactory.cpp.

{
  if( NULL != instance_ )
  {
    delete instance_;
    instance_ = NULL;
  }
}
Body * RefEntityFactory::get_body ( int  id) [virtual]

Definition at line 539 of file RefEntityFactory.cpp.

{
   if (!bodyList->size())
       return NULL;
   
   // Make sure the list is sorted for the binary search.
   if(ManageListSorting && !bodyListIsSorted)
   {
     bodyList->sort(sort_by_ascending_ids);
     bodyListIsSorted = true;
   }

   // Do a binary search on the sorted list.  We are making the assumption
   // here that there are no NULL entries in the list.
   bool found = false;
   int left_index = 0;
   int right_index = bodyList->size()-1;
   int mid_index = (left_index + right_index)/2;
   int mid_id = ((*bodyList)[mid_index])->id();

   while(!found && (right_index-left_index) > 1)
   {
     if(mid_id == id)
       found = true;
     else
     {
       if(mid_id > id)
         right_index = mid_index;
       else
         left_index = mid_index;
       mid_index = (left_index + right_index)/2;
       mid_id = ((*bodyList)[mid_index])->id();
     }
   }

   if(!found)
   {
     if(((*bodyList)[left_index])->id() == id)
       return ((*bodyList)[left_index]);
     else if(((*bodyList)[right_index])->id() == id)
       return ((*bodyList)[right_index]);
   }
   else
     return ((*bodyList)[mid_index]);
   
   return NULL ;
}

Definition at line 872 of file RefEntityFactory.cpp.

{
    bodyList->reset(); 
    return bodyList->size() ? bodyList->get() : 0;
}

Definition at line 896 of file RefEntityFactory.cpp.

{
    refEdgeList->reset(); 
    return refEdgeList->size() ? refEdgeList->get() : 0;
}

Definition at line 890 of file RefEntityFactory.cpp.

{
    refFaceList->reset(); 
    return refFaceList->size() ? refFaceList->get() : 0;
}

Definition at line 884 of file RefEntityFactory.cpp.

{
    refGroupList->reset(); 
    return refGroupList->size() ? refGroupList->get() : 0;
}

Definition at line 902 of file RefEntityFactory.cpp.

{
    refVertexList->reset(); 
    return refVertexList->size() ? refVertexList->get() : 0;
}

Definition at line 878 of file RefEntityFactory.cpp.

{
    refVolumeList->reset(); 
    return refVolumeList->size() ? refVolumeList->get() : 0;
}

Definition at line 927 of file RefEntityFactory.cpp.

{
    bodyList->last(); 
    return bodyList->size() ? bodyList->get() : 0;
}

Definition at line 951 of file RefEntityFactory.cpp.

{
    refEdgeList->last(); 
    return refEdgeList->size() ? refEdgeList->get() : 0;
}

Definition at line 945 of file RefEntityFactory.cpp.

{
    refFaceList->last(); 
    return refFaceList->size() ? refFaceList->get() : 0;
}

Definition at line 939 of file RefEntityFactory.cpp.

{
    refGroupList->last(); 
    return refGroupList->size() ? refGroupList->get() : 0;
}

Definition at line 957 of file RefEntityFactory.cpp.

{
    refVertexList->last(); 
    return refVertexList->size() ? refVertexList->get() : 0;
}

Definition at line 933 of file RefEntityFactory.cpp.

{
    refVolumeList->last(); 
    return refVolumeList->size() ? refVolumeList->get() : 0;
}

Definition at line 909 of file RefEntityFactory.cpp.

{return bodyList->size() ? bodyList->step_and_get() : 0;}

Definition at line 921 of file RefEntityFactory.cpp.

{return refEdgeList->size() ? refEdgeList->step_and_get() : 0;}

Definition at line 918 of file RefEntityFactory.cpp.

{return refFaceList->size() ? refFaceList->step_and_get() : 0;}

Definition at line 915 of file RefEntityFactory.cpp.

Definition at line 924 of file RefEntityFactory.cpp.

Definition at line 912 of file RefEntityFactory.cpp.

RefEdge * RefEntityFactory::get_ref_edge ( int  id) [virtual]

Definition at line 731 of file RefEntityFactory.cpp.

{
   if (!refEdgeList->size())
       return NULL;
   
   // Make sure the list is sorted for the binary search.
   if(ManageListSorting && !refEdgeListIsSorted)
   {
     refEdgeList->sort(sort_by_ascending_ids);
     refEdgeListIsSorted = true;
   }

   // Do a binary search on the sorted list.  We are making the assumption
   // here that there are no NULL entries in the list.
   bool found = false;
   int left_index = 0;
   int right_index = refEdgeList->size()-1;
   int mid_index = (left_index + right_index)/2;
   int mid_id = ((*refEdgeList)[mid_index])->id();

   while(!found && (right_index-left_index) > 1)
   {
     if(mid_id == id)
       found = true;
     else
     {
       if(mid_id > id)
         right_index = mid_index;
       else
         left_index = mid_index;
       mid_index = (left_index + right_index)/2;
       mid_id = ((*refEdgeList)[mid_index])->id();
     }
   }

   if(!found)
   {
     if(((*refEdgeList)[left_index])->id() == id)
       return ((*refEdgeList)[left_index]);
     else if(((*refEdgeList)[right_index])->id() == id)
       return ((*refEdgeList)[right_index]);
   }
   else
     return ((*refEdgeList)[mid_index]);

   return NULL ;
}
RefEntity * RefEntityFactory::get_ref_entity ( const char *  type,
int  id 
) [virtual]

Definition at line 485 of file RefEntityFactory.cpp.

{
     // Call the right function, cast it.
  switch( toupper(*type_string) )
  {
    case 'B':
      if( !strcmp(type_string+1,"ody") )
        return get_body(id);
      break;
    case 'V':
      if( !strcmp(type_string+1,"olume" ) )
        return get_ref_volume(id);
      else if(!strcmp(type_string+1,"ertex") )
        return get_ref_vertex(id);
      break;
    case 'S':
      if( !strcmp(type_string+1,"urface") )
        return get_ref_face(id);
      break;
    case 'C':
      if( !strcmp(type_string+1,"urve") )
        return get_ref_edge(id);
      break;
    case 'G':
      if( !strcmp(type_string+1,"roup") )
        return get_ref_group(id);
      break;
  }   

  PRINT_ERROR("Invalid list type for the get_ref_entity "
              "function: %s\n", type_string);
  return NULL;
}
RefEntity * RefEntityFactory::get_ref_entity ( const std::type_info &  type,
int  id 
) [virtual]

Definition at line 519 of file RefEntityFactory.cpp.

{
   // Call the right function, cast it.
  if( type == typeid(RefGroup) )
     return CAST_TO(get_ref_group(id), RefEntity);
  else if( type == typeid(Body) )
     return CAST_TO(get_body(id), RefEntity);
  else if( type == typeid(RefVolume) )
     return CAST_TO(get_ref_volume(id), RefEntity);
  else if( type == typeid(RefFace) )
     return CAST_TO(get_ref_face(id), RefEntity);
  else if( type == typeid(RefEdge) )
     return CAST_TO(get_ref_edge(id), RefEntity);
  else if( type == typeid(RefVertex) )
     return CAST_TO(get_ref_vertex(id), RefEntity);
      
   return NULL;
}
RefFace * RefEntityFactory::get_ref_face ( int  id) [virtual]

Definition at line 683 of file RefEntityFactory.cpp.

{
   if (!refFaceList->size())
       return NULL;
   
   // Make sure the list is sorted for the binary search.
   if(ManageListSorting && !refFaceListIsSorted)
   {
     refFaceList->sort(sort_by_ascending_ids);
     refFaceListIsSorted = true;
   }

   // Do a binary search on the sorted list.  We are making the assumption
   // here that there are no NULL entries in the list.
   bool found = false;
   int left_index = 0;
   int right_index = refFaceList->size()-1;
   int mid_index = (left_index + right_index)/2;
   int mid_id = ((*refFaceList)[mid_index])->id();

   while(!found && (right_index-left_index) > 1)
   {
     if(mid_id == id)
       found = true;
     else
     {
       if(mid_id > id)
         right_index = mid_index;
       else
         left_index = mid_index;
       mid_index = (left_index + right_index)/2;
       mid_id = ((*refFaceList)[mid_index])->id();
     }
   }

   if(!found)
   {
     if(((*refFaceList)[left_index])->id() == id)
       return ((*refFaceList)[left_index]);
     else if(((*refFaceList)[right_index])->id() == id)
       return ((*refFaceList)[right_index]);
   }
   else
     return ((*refFaceList)[mid_index]);

   return NULL ;
}
RefGroup * RefEntityFactory::get_ref_group ( int  id) [virtual]

Definition at line 587 of file RefEntityFactory.cpp.

{
   if (!refGroupList->size())
       return NULL;
   
   // Make sure the list is sorted for the binary search.
   if(ManageListSorting && !refGroupListIsSorted)
   {
     refGroupList->sort(sort_by_ascending_ids);
     refGroupListIsSorted = true;
   }

   // Do a binary search on the sorted list.  We are making the assumption
   // here that there are no NULL entries in the list.
   bool found = false;
   int left_index = 0;
   int right_index = refGroupList->size()-1;
   int mid_index = (left_index + right_index)/2;
   int mid_id = ((*refGroupList)[mid_index])->id();

   while(!found && (right_index-left_index) > 1)
   {
     if(mid_id == id)
       found = true;
     else
     {
       if(mid_id > id)
         right_index = mid_index;
       else
         left_index = mid_index;
       mid_index = (left_index + right_index)/2;
       mid_id = ((*refGroupList)[mid_index])->id();
     }
   }

   if(!found)
   {
     if(((*refGroupList)[left_index])->id() == id)
       return ((*refGroupList)[left_index]);
     else if(((*refGroupList)[right_index])->id() == id)
       return ((*refGroupList)[right_index]);
   }
   else
     return ((*refGroupList)[mid_index]);

   return NULL ;
}

Definition at line 779 of file RefEntityFactory.cpp.

{
   if (!refVertexList->size())
       return NULL;
   
   // Make sure the list is sorted for the binary search.
   if(ManageListSorting && !refVertexListIsSorted)
   {
     refVertexList->sort(sort_by_ascending_ids);
     refVertexListIsSorted = true;
   }

   // Do a binary search on the sorted list.  We are making the assumption
   // here that there are no NULL entries in the list.
   bool found = false;
   int left_index = 0;
   int right_index = refVertexList->size()-1;
   int mid_index = (left_index + right_index)/2;
   int mid_id = ((*refVertexList)[mid_index])->id();

   while(!found && (right_index-left_index) > 1)
   {
     if(mid_id == id)
       found = true;
     else
     {
       if(mid_id > id)
         right_index = mid_index;
       else
         left_index = mid_index;
       mid_index = (left_index + right_index)/2;
       mid_id = ((*refVertexList)[mid_index])->id();
     }
   }

   if(!found)
   {
     if(((*refVertexList)[left_index])->id() == id)
       return ((*refVertexList)[left_index]);
     else if(((*refVertexList)[right_index])->id() == id)
       return ((*refVertexList)[right_index]);
   }
   else
     return ((*refVertexList)[mid_index]);

   return NULL ;
}

Definition at line 635 of file RefEntityFactory.cpp.

{
   if (!refVolumeList->size())
       return NULL;
   
   // Make sure the list is sorted for the binary search.
   if(ManageListSorting && !refVolumeListIsSorted)
   {
     refVolumeList->sort(sort_by_ascending_ids);
     refVolumeListIsSorted = true;
   }

   // Do a binary search on the sorted list.  We are making the assumption
   // here that there are no NULL entries in the list.
   bool found = false;
   int left_index = 0;
   int right_index = refVolumeList->size()-1;
   int mid_index = (left_index + right_index)/2;
   int mid_id = ((*refVolumeList)[mid_index])->id();

   while(!found && (right_index-left_index) > 1)
   {
     if(mid_id == id)
       found = true;
     else
     {
       if(mid_id > id)
         right_index = mid_index;
       else
         left_index = mid_index;
       mid_index = (left_index + right_index)/2;
       mid_id = ((*refVolumeList)[mid_index])->id();
     }
   }

   if(!found)
   {
     if(((*refVolumeList)[left_index])->id() == id)
       return ((*refVolumeList)[left_index]);
     else if(((*refVolumeList)[right_index])->id() == id)
       return ((*refVolumeList)[right_index]);
   }
   else
     return ((*refVolumeList)[mid_index]);

   return NULL ;
}

Definition at line 963 of file RefEntityFactory.cpp.

{
  if (ref_ent)
  {
//________  Change Code by DZ of Cat,  3/17/99 10:47:39 AM  ________
     int max_ent_id = 0;

     max_ent_id = ref_ent->id();
        // Do nothing with groups
     if( CAST_TO( ref_ent, RefGroup ) ) {
       if (maxRefGroupId < max_ent_id)
         maxRefGroupId = max_ent_id;
     }
     else if( CAST_TO( ref_ent, Body ) )
     {
       if (maxBodyId < max_ent_id)
          maxBodyId = max_ent_id;
     }
     else if( CAST_TO( ref_ent, RefVolume ) )
     {
       if (maxRefVolumeId < max_ent_id)
          maxRefVolumeId = max_ent_id;
     }
     else if( CAST_TO( ref_ent, RefFace ) )
     {
       if (maxRefFaceId < max_ent_id)
          maxRefFaceId = max_ent_id;
     }
     else if( CAST_TO( ref_ent, RefEdge ) )
     {
       if (maxRefEdgeId < max_ent_id)
          maxRefEdgeId = max_ent_id;
     }
     else if( CAST_TO( ref_ent, RefVertex ) )
     {
       if (maxRefVertexId < max_ent_id)
          maxRefVertexId = max_ent_id;
     }
//________  Change End by DZ of Cat,  3/17/99 10:47:39 AM  ________
  }
}

Definition at line 71 of file RefEntityFactory.cpp.

{
  if (instance_ == NULL) {
    new RefEntityFactory();
  }

  return instance_;
}
int RefEntityFactory::maximum_id ( const char *  entity_type)

Definition at line 1005 of file RefEntityFactory.cpp.

{
   if (strcmp("body", entity_type) == 0)
       return maxBodyId;
   else if (strcmp("curve", entity_type) == 0)
       return maxRefEdgeId;
   else if (strcmp("group", entity_type) == 0)
       return maxRefGroupId;
   else if (strcmp("volume", entity_type) == 0)
       return maxRefVolumeId;
   else if (strcmp("vertex", entity_type) == 0)
       return maxRefVertexId;
   else if (strcmp("surface", entity_type) == 0)
       return maxRefFaceId;
   else {
      PRINT_ERROR("Unrecognized entity_type: '%s'\n", entity_type);
      return 0;
   }
}

Definition at line 1041 of file RefEntityFactory.cpp.

{
   if (!ref_ent)
      return 0;
   else if( CAST_TO( ref_ent, RefGroup ) )
      return maxRefGroupId;
   else if( CAST_TO( ref_ent, Body ) )
      return maxBodyId;
   else if( CAST_TO( ref_ent, RefVolume ) )
      return maxRefVolumeId;
   else if( CAST_TO( ref_ent, RefFace ) )
      return maxRefFaceId;
   else if( CAST_TO( ref_ent, RefEdge ) )
      return maxRefEdgeId;
   else if( CAST_TO( ref_ent, RefVertex ) )
      return maxRefVertexId;
   else
      return 0;
}
void RefEntityFactory::maximum_id ( const std::type_info &  type,
int  max_id 
)

Definition at line 1025 of file RefEntityFactory.cpp.

{
  if( type == typeid(RefGroup) )
     maxRefGroupId = max_id;
  else if( type == typeid(Body) )
     maxBodyId = max_id;
  else if( type == typeid(RefVolume) )
     maxRefVolumeId = max_id;
  else if( type == typeid(RefFace) )
     maxRefFaceId = max_id;
  else if( type == typeid(RefEdge) )
     maxRefEdgeId = max_id;
  else if( type == typeid(RefVertex) )
     maxRefVertexId = max_id;
}

Definition at line 830 of file RefEntityFactory.cpp.

{
   return ++maxBodyId;
}

Definition at line 850 of file RefEntityFactory.cpp.

{
   return ++maxRefEdgeId;
}

Definition at line 845 of file RefEntityFactory.cpp.

{
   return ++maxRefFaceId;
}

Definition at line 835 of file RefEntityFactory.cpp.

{
   return ++maxRefGroupId;
}

Definition at line 855 of file RefEntityFactory.cpp.

{
   return ++maxRefVertexId;
}

Definition at line 840 of file RefEntityFactory.cpp.

{
   return ++maxRefVolumeId;
}
void RefEntityFactory::notify_observer ( const CubitEvent observer_event) [virtual]

Implements CubitObserver.

Definition at line 1179 of file RefEntityFactory.cpp.

{

  const GeometryEvent* geom_event = dynamic_cast<const GeometryEvent*>(observer_event);
  if(!geom_event)
    return;

  RefEntity* entity = geom_event->get_entity();
  
    //- handle MODEL_ENTITY_DESTRUCTED/MODEL_ENTITY_CONSTRUCTED events
  if (geom_event->get_type() == GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED)
    add(entity);
  else if (geom_event->get_type() == GeometryEvent::TOPOLOGY_ENTITY_DESTRUCTED)
    remove(entity);
  else if (geom_event->get_type() == GeometryEvent::ID_SET)
  {
    if(CAST_TO(entity, RefEdge) && ManageListSorting)
      refEdgeListIsSorted = false;
    else if(CAST_TO(entity, RefFace) && ManageListSorting)
      refFaceListIsSorted = false;
    else if(CAST_TO(entity, RefVertex) && ManageListSorting)
      refVertexListIsSorted = false;
    else if(CAST_TO(entity, RefVolume) && ManageListSorting)
      refVolumeListIsSorted = false;
    else if(CAST_TO(entity, RefGroup) && ManageListSorting)
      refGroupListIsSorted = false;
    else if(CAST_TO(entity, Body) && ManageListSorting)
      bodyListIsSorted = false;
  }
}
int RefEntityFactory::num_bodies ( ) const [virtual]

Definition at line 478 of file RefEntityFactory.cpp.

{return bodyList->size();}
int RefEntityFactory::num_ref_edges ( ) const [virtual]

Definition at line 482 of file RefEntityFactory.cpp.

{return refEdgeList->size();}
int RefEntityFactory::num_ref_faces ( ) const [virtual]

Definition at line 481 of file RefEntityFactory.cpp.

{return refFaceList->size();}
int RefEntityFactory::num_ref_groups ( ) const [virtual]

Definition at line 480 of file RefEntityFactory.cpp.

{return refGroupList->size();}
int RefEntityFactory::num_ref_vertices ( ) const [virtual]

Definition at line 483 of file RefEntityFactory.cpp.

{return refVertexList->size();}
int RefEntityFactory::num_ref_volumes ( ) const [virtual]

Definition at line 479 of file RefEntityFactory.cpp.

{return refVolumeList->size();}
void RefEntityFactory::ref_edges ( DLIList< RefEdge * > &  ref_edges) [virtual]

Definition at line 456 of file RefEntityFactory.cpp.

{
  ref_edges = *refEdgeList;
}
CubitStatus RefEntityFactory::ref_entity_list ( char const *  keyword,
DLIList< RefEntity * > &  entity_list,
const CubitBoolean  print_errors = CUBIT_TRUE 
) [virtual]

Definition at line 186 of file RefEntityFactory.cpp.

{
   if ( !strcmp( keyword, "body" ) || !strcmp( keyword, "Body" )) {
     CAST_LIST_TO_PARENT((*bodyList), entity_list) ;
   }
   else if ( !strcmp( keyword, "curve" ) || !strcmp( keyword, "Curve" ) ) {
     CAST_LIST_TO_PARENT((*refEdgeList), entity_list) ;
   }
   else if ( !strcmp( keyword, "volume" ) || !strcmp( keyword, "Volume" ) ) {
     CAST_LIST_TO_PARENT((*refVolumeList), entity_list) ; 
   }
   else if ( !strcmp( keyword, "vertex" ) || !strcmp( keyword, "Vertex" ) ) {
     CAST_LIST_TO_PARENT((*refVertexList), entity_list) ;
   }
   else if ( !strcmp( keyword, "surface" ) || !strcmp( keyword, "Surface" ) ) {
     CAST_LIST_TO_PARENT((*refFaceList), entity_list) ; 
   }
   else if ( !strcmp( keyword, "group" ) || !strcmp( keyword, "Group" ) ) {
     CAST_LIST_TO_PARENT((*refGroupList), entity_list) ;
   }
   else 
   {
     if (print_errors)
       PRINT_ERROR("Invalid list type for the ref_entity_list "
                   "function: %s\n", keyword);
     return CUBIT_FAILURE;
   }

   return CUBIT_SUCCESS;
}
void RefEntityFactory::ref_faces ( DLIList< RefFace * > &  ref_faces) [virtual]

Definition at line 451 of file RefEntityFactory.cpp.

{
  ref_faces = *refFaceList;
}
void RefEntityFactory::ref_groups ( DLIList< RefGroup * > &  ref_groups) [virtual]

Definition at line 446 of file RefEntityFactory.cpp.

{
  ref_groups = *refGroupList;
}
void RefEntityFactory::ref_vertices ( DLIList< RefVertex * > &  ref_vertices) [virtual]

Definition at line 461 of file RefEntityFactory.cpp.

{
  ref_vertices = *refVertexList;
}
void RefEntityFactory::ref_volumes ( DLIList< RefVolume * > &  ref_volumes) [virtual]

Definition at line 441 of file RefEntityFactory.cpp.

{
  ref_volumes = *refVolumeList;
}
void RefEntityFactory::remove ( RefEntity ref_entity) [virtual]

Definition at line 333 of file RefEntityFactory.cpp.

{
  assert(ref_entity != 0);
  
  RefGroup *group;
  RefVolume *volume;
  RefFace *face;
  RefEdge *edge;
  RefVertex *vertex;
  Body *body;

  if ( (group = CAST_TO(ref_entity, RefGroup)) != NULL ) {
    remove(group);
  }
  else if ( (volume = CAST_TO(ref_entity, RefVolume)) != NULL ) {
    remove(volume);
  }
  else if ( (face = CAST_TO(ref_entity, RefFace)) != NULL ) {
    remove(face);
  }
  else if ( (edge = CAST_TO(ref_entity, RefEdge)) != NULL ) {
    remove(edge);
  }
  else if ( (vertex = CAST_TO(ref_entity, RefVertex)) != NULL ) {
    remove(vertex);
  }
  else if ( (body = CAST_TO(ref_entity, Body)) != NULL ) {
    remove(body);
  }
}
void RefEntityFactory::remove ( RefVertex refVertexPtr) [virtual]

Definition at line 364 of file RefEntityFactory.cpp.

{
  if (!refVertexList) return;
  
   if (ref_vertex_ptr != NULL)
   {
      if (refVertexList->move_to ( ref_vertex_ptr )) 
          refVertexList->remove ();
      else assert(0);
   }
}
void RefEntityFactory::remove ( RefEdge refEdgePtr) [virtual]

Definition at line 376 of file RefEntityFactory.cpp.

{
  if (!refEdgeList) return;

   if (ref_edge_ptr != NULL)
   {
      if (refEdgeList->move_to ( ref_edge_ptr ))
          refEdgeList->remove ();
      else assert(0);
   }
}
void RefEntityFactory::remove ( RefFace refFacePtr) [virtual]

Definition at line 388 of file RefEntityFactory.cpp.

{
  if (!refFaceList) return;

   if (ref_face_ptr != NULL)
   {
      if (refFaceList->move_to ( ref_face_ptr ))
          refFaceList->remove ();
      else assert(0);
   }
}
void RefEntityFactory::remove ( RefGroup refGroupPtr) [virtual]

Definition at line 412 of file RefEntityFactory.cpp.

{
  if (!refGroupList) return;

  if (ref_group_ptr != NULL)
  {
    if (refGroupList->move_to ( ref_group_ptr ))
      refGroupList->remove ();
    else assert(0);
  }
}
void RefEntityFactory::remove ( RefVolume refVolumePtr) [virtual]

Definition at line 400 of file RefEntityFactory.cpp.

{
  if (!refVolumeList) return;

  if (ref_volume_ptr != NULL)
   {
      if (refVolumeList->move_to ( ref_volume_ptr ))
          refVolumeList->remove ();
      else assert(0);
   }
}
void RefEntityFactory::remove ( Body bodyPtr) [virtual]

Definition at line 424 of file RefEntityFactory.cpp.

{
  if (!bodyList) return;

  if (body_ptr != NULL)
  {
    if (bodyList->move_to ( body_ptr ))
      bodyList->remove ();
    else assert(0);
  }
}

Definition at line 1165 of file RefEntityFactory.cpp.

{
    // See MRefEntityFactory::renumber_geometry_by_properties.
    // If you want this implemented, copy what was done there.
  PRINT_ERROR("'Sort' option not supported.\n"
              "       Compressing IDs without sorting.");
  compress_ref_ids("group", retain_max);
  compress_ref_ids("body", retain_max);
  compress_ref_ids("volume", retain_max);
  compress_ref_ids("surface", retain_max);
  compress_ref_ids("curve", retain_max);
  compress_ref_ids("vertex", retain_max);
}

Definition at line 1139 of file RefEntityFactory.cpp.

{
  maxBodyId           = 0;
  maxRefVolumeId      = 0;
  maxRefGroupId       = 0;
  maxRefFaceId        = 0;
  maxRefEdgeId        = 0;
  maxRefVertexId      = 0;
  maxSurfSubDomainId  = 0;
  maxCurveSubDomainId = 0;
  maxRefCoordSysId    = 0;
#ifdef PROE
  maxRefAssemblyId    = 0;
  maxRefPartId        = 0;
#endif
}

Member Data Documentation

Definition at line 226 of file RefEntityFactory.hpp.

Definition at line 218 of file RefEntityFactory.hpp.

RefEntityFactory * RefEntityFactory::instance_ = NULL [static, protected]

Definition at line 194 of file RefEntityFactory.hpp.

Definition at line 197 of file RefEntityFactory.hpp.

int RefEntityFactory::maxBodyId [protected]

Definition at line 198 of file RefEntityFactory.hpp.

Definition at line 206 of file RefEntityFactory.hpp.

Definition at line 204 of file RefEntityFactory.hpp.

Definition at line 202 of file RefEntityFactory.hpp.

Definition at line 201 of file RefEntityFactory.hpp.

Definition at line 200 of file RefEntityFactory.hpp.

Definition at line 203 of file RefEntityFactory.hpp.

Definition at line 199 of file RefEntityFactory.hpp.

Definition at line 205 of file RefEntityFactory.hpp.

Definition at line 222 of file RefEntityFactory.hpp.

Definition at line 215 of file RefEntityFactory.hpp.

Definition at line 223 of file RefEntityFactory.hpp.

Definition at line 216 of file RefEntityFactory.hpp.

Definition at line 224 of file RefEntityFactory.hpp.

Definition at line 219 of file RefEntityFactory.hpp.

Definition at line 221 of file RefEntityFactory.hpp.

Definition at line 214 of file RefEntityFactory.hpp.

Definition at line 225 of file RefEntityFactory.hpp.

Definition at line 217 of file RefEntityFactory.hpp.


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