cgma
RefEntity.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : RefEntity.hpp
00003 //
00004 // Purpose       : This file consolidates functionality from several
00005 //                 base classes in CUBIT, and serves as the entry point
00006 //                 to geometry from the meshing and other CUBIT classes
00007 //
00008 // Creator       : Tim Tautges (in it's new state)
00009 //
00010 // Creation Date : 9/99
00011 //-------------------------------------------------------------------------
00012 
00013 #ifndef REFENTITY_HPP
00014 #define REFENTITY_HPP
00015 
00016 // ********** BEGIN CUBIT INCLUDES         **********
00017 #include "CubitObservable.hpp"
00018 #include "CubitEntity.hpp"
00019 #include "CubitAttribUser.hpp"
00020 #include "CubitColor.hpp"
00021 #include "ToolDataUser.hpp"
00022 #include "DagType.hpp"
00023 #include "GeometryEvent.hpp"
00024 
00025 // ********** END CUBIT INCLUDES           **********
00026 
00027 // ********** BEGIN FORWARD DECLARATIONS   **********
00028 
00029 class CubitString;
00030 template <class X> class DLIList;
00031 class RefVolume;
00032 class RefFace;
00033 class RefEdge;
00034 class RefVertex;
00035 class RefEntity;
00036 class MeshEntity;
00037 class CubitEntity;
00038 
00039 class Body;
00040 class RefGroup;
00041 class RefEdge;
00042 class RefFace;
00043 class RefVolume;
00044 class RefVertex;
00045 
00046 // ********** END FORWARD DECLARATIONS     **********
00047 
00048 // ********** BEGIN MACRO DEFINITIONS     **********
00049 // ********** END MACRO DEFINITIONS       **********
00050 
00051 // ********** BEGIN ENUM DEFINITIONS     **********
00052 
00053 enum AutoMergeStatus {
00054   AUTO_MERGE_AUTO = 2,
00055   AUTO_MERGE_ON   = 1,
00056   AUTO_MERGE_OFF  = 0
00057 };
00058 
00059 
00060 // ********** END ENUM DEFINITIONS       **********
00062 class CUBIT_GEOM_EXPORT RefEntity: public CubitEntity,
00063                  public CubitObservable,
00064                  public ToolDataUser,
00065                  public CubitAttribUser
00066 {
00067 public:
00068   
00069   RefEntity() ;
00070     //- The default constructor
00071   
00072   virtual ~RefEntity ();
00073     //- A pure virtual destructor - this ensures that the class is
00074     //- non-instantiable.
00075 
00077   static const char* get_ref_class_name(const std::type_info& ref_type);
00078   
00080   static RefEntity* get_by_name(const CubitString& name);
00081 
00083   virtual CubitString entity_name() const;
00084   
00086   CubitStatus entity_name (CubitString name);
00087 
00089   void entity_names(DLIList<CubitString> &names) const;
00090 
00092   int num_names() const;
00093 
00096   CubitStatus generate_default_name ( CubitString &name );
00097 
00099   CubitStatus assign_default_name( CubitBoolean user_setting = CUBIT_FALSE );
00100 
00101   CubitStatus remove_entity_name(CubitString const & name);
00102   CubitStatus remove_entity_names();
00103   void merge_entity_names(RefEntity* dead_entity);
00104   void switch_entity_names(RefEntity *other_entity);
00105  
00107   //- Generic flag for temporary use by algorithms.
00108   //- Value is volatile and may change unexpectedly.
00109   virtual void marked(int value);
00110   virtual int  marked ();
00112   
00114   virtual void is_mergeable(AutoMergeStatus val);
00115 
00117   AutoMergeStatus merge_status() const;
00118 
00120   bool is_mergeable();
00121 
00123   CubitBoolean is_merged();
00124   // return true if this RefEntity has multiple TopologyBridges.
00125 
00127   void update_auto_merge_state();
00128     
00130   virtual bool children_mergeable();
00131   
00135   virtual int can_modify();
00136   
00139   virtual int dimension() const; 
00140   
00143   virtual void get_child_ref_entities(DLIList<RefEntity*>& entity_list); 
00144   
00147   void get_all_child_ref_entities(DLIList<RefEntity*>& entity_list);
00148   
00150   static void get_all_child_ref_entities(DLIList<RefEntity*>& input_list,
00151                   DLIList<RefEntity*>& output_list );
00152 
00153 
00158   static void gather_bdy_entities( DLIList<RefEntity*> &entity_list, 
00159                                    DLIList<RefEntity*> &bdy_list );
00160 
00165   virtual void get_parent_ref_entities(DLIList<RefEntity*>& entity_list) = 0;
00166   
00169   void get_all_parent_ref_entities(DLIList<RefEntity*>& entity_list,
00170                                    const int get_bodies = CUBIT_FALSE );
00171   
00174   static void change_to_parent_ref_entities( DLIList<RefEntity*>& ancestors );
00175  
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189   RefEntity *join( RefEntity* ref_entity_2, DLIList<RefEntity*> &join_set );
00190   static RefEntity *join( DLIList<RefEntity*> &ref_entities, 
00191                           DLIList<RefEntity*> &join_set );
00193   
00195   //- like join, except returns the lower order entities common to the input 
00196   //- entities
00197   RefEntity *meet( RefEntity* ref_entity_2, DLIList<RefEntity*> &join_set );
00198   static RefEntity *meet( DLIList<RefEntity*> &ref_entities, 
00199                           DLIList<RefEntity*> &join_set );
00201 
00204   int valence(RefEntity *parent = NULL);
00205 
00206   
00208   //- Return TRUE if this is entity, or a direct child (parent) of entity.
00209   virtual CubitBoolean is_child(RefEntity *entity);
00210   virtual CubitBoolean is_parent(RefEntity *entity);
00212 
00215   int num_parent_ref_entities();
00216   
00217 //   void common_draw_label(int color, const int label_style);
00218 //     //- Common code used for drawing labels. Actually, the entire
00219 //     //- draw_label function could be implemented here if the
00220 //     //- is_*_labeling_on() functions were virtual or better implemented.
00221 
00222   //CubitBoolean is_free_ref_entity();
00223     //- return CUBIT_TRUE if this ref entity has no non-virtual parents
00224 
00226   virtual CubitVector center_point();
00227   
00235   virtual double measure();
00236   
00238   virtual CubitString measure_label();
00239   
00241   virtual int validate();
00242   
00244   virtual DagType dag_type() const = 0;
00245 
00247   virtual const std::type_info& entity_type_info() const = 0;
00248 
00250   static DagType dag_type( const std::type_info& );
00251  
00253   DagType get_parent_ref_entity_type() const;
00254 
00256   DagType get_child_ref_entity_type() const;
00257 
00259   static DagType get_parent_ref_entity_type( DagType child_type );
00260 
00262   static DagType get_child_ref_entity_type( DagType parent_type );
00263   
00266   void notify_sub_all_observers(const GeometryEvent::Type& event);
00267 
00270   void comparison_found(RefEntity* partner);
00271   
00278   void add_compare_data(RefEntity* partner) ;
00279   
00281   void remove_compare_data() ;
00282     
00286   RefEntity* get_compare_partner() ;
00287 
00288 //========  Change Code by RY of Cat,  5/7/99 11:08:12 AM  ========
00289   void get_related_entity_list(const std::type_info& related_entity_type,
00290                    DLIList<RefEntity*>& entity_list);
00291   //- to parse group in <ref_entity> commands
00292 //========  Change End by RY of Cat,  5/7/99 11:08:12 AM  ========
00293 
00295   virtual void set_id(int i );
00296  
00298   void set_id(int i, CubitBoolean emit_event );
00299 
00301   static const std::type_info& get_entity_type_info(const char* entity_type);
00302    
00304   static DagType dag_type( const char* cli_type_name );
00305   
00307   virtual void color(int value);
00308 
00310   virtual int color() const;
00311 
00313   inline void local_tolerance( double value ){ localTolerance = value; }
00314   inline double local_tolerance( void ){ return localTolerance; }
00315 
00316 protected :
00317 
00318   int          autoMergeStatus;//- Whether entity will participate
00319                                //- in 'merge all XXX' operation.
00320   int markedFlag;      //- Scratch flag for algorithm use.
00321                        //- NOTE: should be Bit markedFlag: 8 ntfolwe
00322   Bit listFlag : 1;    //- Scratch flag for low-level use
00323 
00324   int mColor; // color of this entity
00325    
00326 private:
00327 
00328   RefEntity( const RefEntity& );
00329   void operator=( const RefEntity& );
00330 
00331   void list_mark(int value);
00332   int  list_mark();
00333     //- Generic flag for marking whether an entity is in a list or not.
00334     //- For internal use by RefEntity.
00335 
00336   // This local tolerance is used in tolerant imprinting
00337   // This local tolerance is set automatically by LocalToleranceTool class
00338   double localTolerance;
00339 
00340 };
00341 
00342 // ********** BEGIN INLINE FUNCTIONS       **********
00343 
00344 inline void
00345 RefEntity::marked(int value)
00346 {markedFlag = value;}
00347 
00348 inline int
00349 RefEntity::marked()
00350 {return (int) markedFlag;}
00351 
00352 inline void
00353 RefEntity::list_mark(int value)
00354 {listFlag = value;}
00355 
00356 inline int
00357 RefEntity::list_mark()
00358 {return listFlag;}
00359 
00360 // ********** END INLINE FUNCTIONS         **********
00361 
00362 // ********** BEGIN FRIEND FUNCTIONS       **********
00363 // ********** END FRIEND FUNCTIONS         **********
00364 
00365 // ********** BEGIN EXTERN FUNCTIONS       **********
00366 // ********** END EXTERN FUNCTIONS         **********
00367 
00368 // ********** BEGIN HELPER CLASS DECLARATIONS **********
00369 // ********** END   HELPER CLASS DECLARATIONS **********
00370 
00371 template <> struct DLIListSorter<RefEntity*>
00372 {
00373   bool operator()(RefEntity* a, RefEntity* b)
00374   {
00375     if (a == NULL)
00376     {
00377       if(a == b)
00378         return false;
00379       else
00380         return true;
00381     }
00382     else if(b == NULL)
00383     {
00384       return false;
00385     }
00386     else if (a->id() < b->id())
00387     {
00388       return true;
00389     }
00390     else if (a->id() > b->id())
00391     {
00392       return false;
00393     }
00394     // equal id, sort on dimension
00395     return a->dimension() < b->dimension();
00396   }
00397 };
00398 
00399 #endif
00400 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines