cgma
GroupingEntity.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : GroupingEntity.hpp
00003 //
00004 // Purpose       : This file contains the declarations of the class 
00005 //                 GroupingEntity.
00006 //                 This class is the base class of all the grouping entities
00007 //                 Body, Shell, Loop, Chain.
00008 //
00009 // Special Notes : Each GroupingEntity is associated with a set of 
00010 //                 SenseEntity's (SE's). These SE's are ordered in a 
00011 //                 list.  Hence the GroupingEntity interface
00012 //                 not only provides the ability to get the entire list
00013 //                 of SE's, but also allows you to ask for the "first"
00014 //                 associated SE.  The SE interface thus provides a
00015 //                 function to ask for the "next" SE.  The linked
00016 //                 list of SE's ends when the next function returns a 
00017 //                 NULL pointer. 
00018 //
00019 //                 The same is true of GroupingEntities themselves. They
00020 //                 are an ordered list in the DAG, implying that a next()
00021 //                 function needs to be provided.
00022 //
00023 //                 This is a pure virtual class.
00024 //
00025 // Creator       : Xuechen Liu 
00026 //
00027 // Creation Date : 07/11/96
00028 //
00029 // Owner         : Malcolm J. Panthaki
00030 //-------------------------------------------------------------------------
00031 
00032 #ifndef GROUPING_ENTITY_HPP
00033 #define GROUPING_ENTITY_HPP
00034 
00035 // ********** BEGIN STANDARD INCLUDES      **********
00036 // ********** END STANDARD INCLUDES        **********
00037 
00038 // ********** BEGIN CUBIT INCLUDES         **********
00039 #include "CubitDefines.h"
00040 #include "TopologyEntity.hpp"
00041 // ********** END CUBIT INCLUDES           **********
00042 
00043 // ********** BEGIN MACROS DEFINITIONS     **********
00044 // ********** END MACROS DEFINITIONS       **********
00045 
00046 // ********** BEGIN FORWARD DECLARATIONS   **********
00047 class SenseEntity;
00048 class BasicTopologyEntity;
00049 
00050 // ********** END FORWARD DECLARATIONS     **********
00051 
00052 class CUBIT_GEOM_EXPORT GroupingEntity : public TopologyEntity
00053 {
00054    public :
00055    
00056    inline GroupingEntity() ;
00057      //- The default constructor
00058    
00059    virtual ~GroupingEntity();
00060 
00061    inline SenseEntity* get_first_sense_entity_ptr();
00062    inline SenseEntity* get_last_sense_entity_ptr();
00063      //R SenseEntity*
00064      //R- A pointer to the first of the list of SenseEntitys pointed
00065      //R- to by this object.
00066      //- This function returns a pointer to the first of the list of
00067      //- SenseEntity's pointed to by this GroupingEntity.
00068    
00069    CubitStatus get_sense_entity_list(DLIList<SenseEntity*>& list);
00070      //R CubitStatus
00071      //R- CUBIT_SUCCESS/CUBIT_FAILURE
00072      //O list
00073      //O- A list of SenseEntity pointers.
00074      //- This function returns a list of SenseEntity pointers
00075      //- associated with this GroupingEntity. If there are none, then
00076      //- CUBIT_FAILURE is returned.
00077    
00078    CubitStatus set_sense_entity_list(DLIList<SenseEntity*>& list,
00079                                      DLIList<SenseEntity*>& removed);
00080      //R CubitStatus
00081      //R- CUBIT_SUCCESS/CUBIT_FAILURE
00082      //I list
00083      //I- New set of child SenseEntitys for this GroupingEntity.
00084      //O removed
00085      //O- List of child SenseEntitys removed from this GroupingEntity
00086      //- Change/reorder child list.
00087      //- It is an error for any input SenseEntity to have a parent 
00088      //- GroupingEntity unless that parent GroupingEntity is this.
00089    
00090    
00091    inline GroupingEntity* next();
00092      //R GroupingEntity*
00093      //R- A GroupingEntity pointer
00094      //- This function returns a pointer to the GroupingEntity that is
00095      //- a child of this one in the DAG. If it is the end of the line,
00096      //- then a NULL pointer is returned.
00097      
00098     inline GroupingEntity* previous();
00099      //R GroupingEntity*
00100      //R- A GroupingEntity pointer
00101      //- This function returns a pointer to the GroupingEntity that is
00102      //- a child of this one in the DAG. If it is the end of the line,
00103      //- then a NULL pointer is returned.
00104    
00105     inline BasicTopologyEntity* get_basic_topology_entity_ptr();
00106      //R BasicTopologyEntity*
00107      //R- A pointer to the BasicTopologyEntity which the current grouping
00108      //R- entity is associated with.
00109      //- This function returns a pointer to the BasicTopologyEntity which
00110      //- the current sense entity is associated with.
00111          
00112    CubitStatus add_sense_entity(SenseEntity *sense_entity_ptr,
00113                                 SenseEntity *after_this = 0) ;
00114      //R CubitStatus
00115      //I senseEntityPtr
00116      //I- The pointer to a SenseEntity which will be added to the 
00117      //I- list of sense entities of the grouping entity.
00118      //- This function is used to add a SenseEntity to the list of
00119      //- sense entities of a grouping entity. If the input sense entity
00120      //- is not the appropriate type, nothing is done and the function
00121      //- returns CUBIT_FAILURE. If the sense entity is added successfully,
00122      //- the function returns CUBIT_SUCCESS.
00123      
00124    CubitStatus remove_sense_entity(SenseEntity* sense_entity_ptr);
00125    
00126    void reverse_direction();  
00127      // reverse order and sense of child sense entities
00128 
00129    virtual int get_parents( DLIList<TopologyEntity*>* list = 0 ) const;
00130    virtual int get_children(DLIList<TopologyEntity*>* list = 0 ) const;
00131 
00132 protected :
00133    
00134    virtual CubitBoolean query_append_parents( DLIList<TopologyEntity*>& list );
00135    virtual CubitBoolean query_append_children(DLIList<TopologyEntity*>& list );
00136 
00137    virtual CubitStatus remove_child_link( TopologyEntity* child_ptr );
00138 
00139    CubitStatus disconnect_all_children( DLIList<TopologyEntity*>* children = 0 );
00140    CubitStatus disconnect_all_parents( DLIList<TopologyEntity*>* parents = 0 );
00141    
00142 private :
00143    
00144     // for use by BasicTopologyEntity only
00145   friend class BasicTopologyEntity;
00146   inline CubitStatus remove_from_list();
00147   inline void set_basic_topology_entity_ptr( BasicTopologyEntity* );
00148   inline CubitStatus insert_after(GroupingEntity* next);
00149   inline CubitStatus insert_before(GroupingEntity* prev);
00150 
00151   BasicTopologyEntity* myParent;
00152   GroupingEntity* nextInParent;
00153   GroupingEntity* prevInParent;
00154   SenseEntity* firstSenseEntity;
00155   SenseEntity* lastSenseEntity;
00156   
00157   GroupingEntity( const GroupingEntity& );
00158   void operator=( const GroupingEntity& );
00159 };
00160 
00161 // ********** BEGIN HELPER CLASSES         **********
00162 // ********** END   HELPER CLASSES         **********
00163 
00164 // ********** BEGIN INLINE FUNCTIONS       **********
00165 
00166 inline GroupingEntity::GroupingEntity()
00167   : myParent(0), 
00168     nextInParent(0),
00169     prevInParent(0),
00170     firstSenseEntity(0),
00171     lastSenseEntity(0)
00172   {}
00173 
00174 inline SenseEntity* GroupingEntity::get_first_sense_entity_ptr()
00175   { return firstSenseEntity; }
00176 
00177 inline SenseEntity* GroupingEntity::get_last_sense_entity_ptr()
00178   { return lastSenseEntity; }
00179    
00180 inline GroupingEntity* GroupingEntity::next()
00181   { return nextInParent; }
00182    
00183 inline GroupingEntity* GroupingEntity::previous()
00184   { return prevInParent; }
00185    
00186 inline BasicTopologyEntity* GroupingEntity::get_basic_topology_entity_ptr()
00187   { return myParent; }
00188     
00189 inline CubitStatus GroupingEntity::remove_from_list()
00190 {
00191   if (nextInParent)
00192     nextInParent->prevInParent = prevInParent;
00193   if (prevInParent)
00194     prevInParent->nextInParent = nextInParent;
00195   prevInParent = nextInParent = 0;
00196   return CUBIT_SUCCESS;
00197 }
00198 
00199 inline CubitStatus GroupingEntity::insert_after( GroupingEntity* next_ptr )
00200 {
00201   prevInParent = next_ptr;
00202   nextInParent = next_ptr->nextInParent;
00203   if (nextInParent)
00204     nextInParent->prevInParent = this;
00205   next_ptr->nextInParent = this;
00206   return CUBIT_SUCCESS;
00207 }
00208 
00209 inline CubitStatus GroupingEntity::insert_before( GroupingEntity* prev_ptr )
00210 {
00211   nextInParent = prev_ptr;
00212   prevInParent = prev_ptr->prevInParent;
00213   if (prevInParent)
00214     prevInParent->nextInParent = this;
00215   prev_ptr->prevInParent = this;
00216   return CUBIT_SUCCESS;
00217 }
00218 
00219 inline void GroupingEntity::set_basic_topology_entity_ptr( BasicTopologyEntity* bte_ptr )
00220 {
00221   assert(!myParent || !bte_ptr);
00222   myParent = bte_ptr;
00223 }
00224 
00225  
00226 // ********** END INLINE FUNCTIONS         **********
00227 
00228 // ********** BEGIN FRIEND FUNCTIONS       **********
00229 // ********** END FRIEND FUNCTIONS         **********
00230 
00231 // ********** BEGIN EXTERN FUNCTIONS       **********
00232 // ********** END EXTERN FUNCTIONS         **********
00233 
00234 #endif
00235 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines