cgma
RefEntityFactory.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : RefEntityFactory.hpp
00003 //
00004 // Purpose       : This file produces RefEntity and derived classes; it is
00005 //                 the interface through which RE's should be created;
00006 //                 applications of the geometry module can provide their
00007 //                 own factory, otherwise this factory is used
00008 //
00009 // Creator       : Tim Tautges (in its new state)
00010 //
00011 // Creation Date : 9/99
00012 //-------------------------------------------------------------------------
00013 
00014 #ifndef REFENTITYFACTORY_HPP
00015 #define REFENTITYFACTORY_HPP
00016 
00017 #include "CubitObserver.hpp"
00018 #include "CubitDefines.h"
00019 #include "CGMGeomConfigure.h" 
00020 
00021 class RefVertex;
00022 class RefEdge;
00023 class RefFace;
00024 class RefVolume;
00025 class RefGroup;
00026 class Body;
00027 class RefEntity;
00028 #ifdef PROE
00029 class RefAssembly;
00030 class RefPart;
00031 #endif
00032 class TBPoint;
00033 class Curve;
00034 class Surface;
00035 class Lump;
00036 class BodySM;
00037 
00038 class RefVertex;
00039 class RefEdge;
00040 class RefFace;
00041 class RefGroup;
00042 class RefVolume;
00043 template <class X> class DLIList;
00044 class CubitEntity;
00045 
00046 class CUBIT_GEOM_EXPORT RefEntityFactory : public CubitObserver
00047 {
00048 public:
00049 
00050   static RefEntityFactory *instance();
00051     //- the function used to access the singleton instance
00052 
00053   static void delete_instance();
00054 
00055   virtual RefVertex *construct_RefVertex(TBPoint *point = NULL);
00056 
00057   virtual RefEdge *construct_RefEdge(Curve *curve = NULL);
00058 
00059   virtual RefFace *construct_RefFace(Surface *surface = NULL);
00060 
00061   virtual RefVolume *construct_RefVolume(Lump *lump = NULL);
00062 
00063   virtual Body *construct_Body(BodySM *body_sm = NULL);
00064 
00065   virtual RefGroup *construct_RefGroup(const char* name = NULL);
00066   virtual RefGroup *construct_RefGroup (DLIList<RefEntity*>& entity_list);
00067 
00068   virtual CubitStatus ref_entity_list( char const* keyword,
00069                                        DLIList<RefEntity*> &entity_list,
00070                                        const CubitBoolean print_errors = CUBIT_TRUE);
00071     //- return entities of type keyword from the global list in entity_list;
00072     //- virtual to allow derived factories to work from their native lists
00073 
00074   virtual void bodies               (DLIList<Body*> &bodies);
00075   virtual void ref_volumes          (DLIList<RefVolume*> &ref_volumes);
00076   virtual void ref_groups           (DLIList<RefGroup*> &ref_groups);
00077   virtual void ref_faces            (DLIList<RefFace*> &ref_faces);
00078   virtual void ref_edges            (DLIList<RefEdge*> &ref_edges);
00079   virtual void ref_vertices         (DLIList<RefVertex*> &ref_vertices);
00080 #ifdef PROE
00081   virtual void ref_parts            (DLIList<RefPart*> &ref_parts);
00082   virtual void ref_assemblies       (DLIList<RefAssembly*> &ref_assemblies);
00083 #endif
00084 
00085   virtual int num_bodies() const;
00086   virtual int num_ref_volumes() const;
00087   virtual int num_ref_groups() const;
00088   virtual int num_ref_faces() const;
00089   virtual int num_ref_edges() const;
00090   virtual int num_ref_vertices() const;
00091 
00092   virtual RefEntity          *get_ref_entity          (const char *type, int id);
00093   virtual RefEntity          *get_ref_entity          (const std::type_info& type, int id);
00094   virtual Body               *get_body                ( int id );
00095   virtual RefVolume          *get_ref_volume          ( int id );
00096   virtual RefGroup           *get_ref_group           ( int id );
00097   virtual RefFace            *get_ref_face            ( int id );
00098   virtual RefEdge            *get_ref_edge            ( int id );
00099   virtual RefVertex          *get_ref_vertex          ( int id );
00100 
00101   virtual Body *get_first_body                ();
00102   virtual RefVolume *get_first_ref_volume          ();
00103   virtual RefGroup *get_first_ref_group           ();
00104   virtual RefFace *get_first_ref_face            ();
00105   virtual RefEdge *get_first_ref_edge            ();
00106   virtual RefVertex *get_first_ref_vertex          ();
00107 
00108   virtual Body *get_next_body                ();
00109   virtual RefVolume *get_next_ref_volume          ();
00110   virtual RefGroup *get_next_ref_group           ();
00111   virtual RefFace *get_next_ref_face            ();
00112   virtual RefEdge *get_next_ref_edge            ();
00113   virtual RefVertex *get_next_ref_vertex          ();
00114 
00115   virtual Body *get_last_body                ();
00116   virtual RefVolume *get_last_ref_volume          ();
00117   virtual RefGroup *get_last_ref_group           ();
00118   virtual RefFace *get_last_ref_face            ();
00119   virtual RefEdge *get_last_ref_edge            ();
00120   virtual RefVertex *get_last_ref_vertex          ();
00121 
00122   virtual void add ( RefEntity    *ref_entity );
00123   virtual void add ( Body         *bodyPtr  );
00124   virtual void add ( RefVolume    *refVolumePtr  );
00125   virtual void add ( RefGroup     *refGroupPtr  );
00126   virtual void add ( RefFace      *refFacePtr  );
00127   virtual void add ( RefEdge      *refEdgePtr  );
00128   virtual void add ( RefVertex    *refVertexPtr  );
00129 
00130   virtual void remove (RefEntity    *ref_entity );
00131   virtual void remove (RefVertex* refVertexPtr);
00132   virtual void remove (RefEdge*   refEdgePtr);
00133   virtual void remove (RefFace*   refFacePtr);
00134   virtual void remove (RefGroup*  refGroupPtr);
00135   virtual void remove (RefVolume* refVolumePtr);
00136   virtual void remove (Body*      bodyPtr);
00137 
00138   int next_body_id   ();
00139   int next_ref_volume_id ();
00140   int next_ref_group_id  ();
00141   int next_ref_face_id   ();
00142   int next_ref_edge_id   ();
00143   int next_ref_vertex_id ();
00144   int next_surf_sub_domain_id ();
00145   int next_curve_sub_domain_id();
00146 #ifdef PROE
00147   int next_ref_assembly_id();
00148   int next_ref_part_id();
00149 #endif
00150 
00151   int current_body_id() {return maxBodyId;};
00152   int current_volume_id() {return maxRefVolumeId;};
00153   int current_group_id() {return maxRefGroupId;};
00154   int current_face_id() {return maxRefFaceId;};
00155   int current_edge_id() {return maxRefEdgeId;};
00156   int current_vertex_id() {return maxRefVertexId;};
00157 
00158   void incorporate_id (RefEntity *ref_ent);
00159   
00160   int maximum_id(const char *entity_type);
00161   int maximum_id (RefEntity *ref_ent);
00162     //- get max id of specified type
00163   
00164   void maximum_id (const std::type_info& type, int max_id);
00165     //- set max id of specified type
00166   
00167   void compress_ref_ids(const char *entity_type, int retain_max_id);
00168     //- take out holes in the id space; make virtual so that factory can work
00169     //- off of native lists
00170 
00171   static void compress_ids(DLIList<CubitEntity*> &list);
00172     //- compress ids of the entities in this list; this function should really be
00173     //- in CubitEntity, but it references label drawing functions, which aren't
00174     //- accessable from CubitEntity
00175 
00176   void reset_ids();
00177     //- resets all the id counters to 0
00178   
00179   virtual void renumber_geometry_by_properties(CubitBoolean retain_max_ids);
00180     //- Renumbers all geometry based on geometric properties such as volume,
00181     //- bounding box, etc.  Used to get consistent numbering, no matter
00182     //- what order the entities appear in the input file.
00183   
00184   void notify_observer(const CubitEvent *observer_event);
00185     //- handle MODEL_ENTITY_DESTRUCTED/MODEL_ENTITY_CONSTRUCTED events
00186 
00187 protected: 
00188 
00189   RefEntityFactory(bool make_lists = true) ;
00190     //- This is a singleton class, but derived classes need to be able
00191     //- to instantiate it
00192   virtual ~RefEntityFactory ();
00193 
00194   static RefEntityFactory *instance_;
00195     //- the singleton instance
00196   
00197   bool ManageListSorting;
00198   int maxBodyId;
00199   int maxRefVolumeId;
00200   int maxRefGroupId;
00201   int maxRefFaceId;
00202   int maxRefEdgeId;
00203   int maxRefVertexId;
00204   int maxRefCoordSysId;
00205   int maxSurfSubDomainId;
00206   int maxCurveSubDomainId;
00207 #ifdef PROE
00208   int maxRefAssemblyId;
00209   int maxRefPartId;
00210 #endif
00211 
00212 private:
00213 
00214   bool refVertexListIsSorted;
00215   bool refEdgeListIsSorted;
00216   bool refFaceListIsSorted;
00217   bool refVolumeListIsSorted;
00218   bool bodyListIsSorted;
00219   bool refGroupListIsSorted;
00220 
00221   DLIList<RefVertex*> *refVertexList;
00222   DLIList<RefEdge*> *refEdgeList;
00223   DLIList<RefFace*> *refFaceList;
00224   DLIList<RefGroup*> *refGroupList;
00225   DLIList<RefVolume*> *refVolumeList;
00226   DLIList<Body*> *bodyList;
00227 #ifdef PROE
00228   DLIList<RefAssembly*> *refAssemblyList;
00229   DLIList<RefPart*> *refPartList;
00230 #endif
00231 
00232 };
00233 
00234 #endif
00235 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines