cgma
CGMHistory.hpp
Go to the documentation of this file.
00001 
00002 
00003 #ifndef CGMHistory_hpp
00004 #define CGMHistory_hpp
00005 
00006 #include <vector>
00007 #include "CubitTransformMatrix.hpp"
00008 #include "CGMGeomConfigure.h"
00009 class RefEntity;
00010 class TopologyBridge;
00011 
00012 class CUBIT_GEOM_EXPORT CGMHistory
00013 {
00014   public:
00015     CGMHistory();
00016     ~CGMHistory();
00017             
00018     enum EventType
00019     {
00020       // Top level creation means an entity with no parent is created
00021       // this could be bodies, surfaces, curves or vertices
00022       TOP_LEVEL_ENTITY_CREATED,
00023       
00024       // Top level deleted means an entity no longer has top level status
00025       // it may have been deleted or it may have been consumed into a higher
00026       // dimensional entity
00027       TOP_LEVEL_ENTITY_DELETED,
00028       
00029       // An entity has been created
00030       ENTITY_CREATED,
00031       
00032       // An entity has been deleted
00033       ENTITY_DELETED,
00034       
00035       // An entity's topology changes, meaning it has gained new child entities
00036       // or lost old child entities.  This can result from solid modeling
00037       // operations or from operations within cgm such as merging.
00038       TOPOLOGY_CHANGED, 
00039 
00040       // The geometry of an entity is changed such that it might have been
00041       // stretched, warped or other such changes where the topology may be the
00042       // same.  If child entities changed, they'll have their own event.
00043       GEOMETRY_CHANGED,
00044 
00045       // A transformation happend to this entity, all child entities are
00046       // transformed as well.  In this case, a GEOMETRY_CHANGED does not occur.
00047       GEOMETRY_TRANSFORMED,
00048 
00049       // The id of an entity changes
00050       ENTITY_ID_CHANGED,
00051       
00052       // The name of an entity changes
00053       ENTITY_NAME_CHANGED,
00054       
00055       // The name of an entity changes
00056       ENTITY_COLOR_CHANGED,
00057 
00058       // An entity is subdivided into multiple entities
00059       // this is a supplemental event such that other events completely
00060       // describe the topology changes, but this event specifies where the
00061       // subdivision occurred
00062       SUBDIVISION,
00063 
00064       // Multiple entities are absorbed into one entity
00065       // this is a supplemental event such that other events completely
00066       // describe the topology changes, but this event specifies where the
00067       // absorption occurred
00068       ABSORPTION,
00069 
00070       // Multiple entities modified by a combination of subdivision and
00071       // absorption, and intermediate entities don't exist by the time
00072       // this history object is given to someone
00073       // this is a supplemental event such that other events completely
00074       // describe the topology changes, but this event specifies where the
00075       // subdivision/absorption occurred
00076       SUBDIVISION_ABSORPTION,
00077 
00078       // An entity is merged into another
00079       // this is a supplemental event such that other events completely
00080       // describe the topology changes, but this event specifies where the
00081       // merge occurred
00082       MERGE,
00083 
00084       // An entity is copied from another
00085       // you may also get this when an unmerge happens in cgm
00086       // this is a supplemental event such that other events completely
00087       // describe the topology changes, but this event specifies where the
00088       // copy occurred
00089       COPY,
00090       
00091       // Cousin to SUBDIVISION.  Think of it as a 1-to-n subdivision where
00092       // only 1 of the n actually survives, so it's really and 1-to-1
00093       // modification.
00094       CUT
00095     };
00096 
00097     //Event is a record of a change that occurred during an operation
00098     class CUBIT_GEOM_EXPORT Event
00099     {
00100     public:
00101       Event(EventType type, RefEntity* refentity);
00102       Event(EventType type, const std::vector<RefEntity*>& refentity_list);
00103       ~Event();
00104 
00105       EventType get_event_type() const;
00106       const std::vector<RefEntity*>& get_entities() const;
00107 
00108     private:
00109 
00110       // the type of event this is
00111       EventType eventType;
00112       // the entities this event applies to
00113       std::vector<RefEntity*> entities;
00114 
00115       // extra data associated with event
00116       union 
00117       {
00118         std::vector<RefEntity*> *other_entities;
00119         CubitTransformMatrix *matrix;
00120         // TODO add data types for other events
00121       };
00122     };
00123 
00124     
00125     class CUBIT_GEOM_EXPORT PortEvent
00126     {
00127       public:
00128         PortEvent(EventType type, std::vector<RefEntity*> &source_entities,
00129                               std::vector<TopologyBridge*> &result_entities );
00130         PortEvent( EventType type );
00131         ~PortEvent();
00132 
00133         EventType get_event_type() const;
00134         const std::vector<RefEntity*>& get_entities() const;
00135 
00136         EventType eventType;
00137         // the entities this event applies to
00138         std::vector<RefEntity*> RefEnts; 
00139         std::vector<TopologyBridge*> TopologyBridges;
00140 
00141         // extra data associated with event
00142         //union 
00143        // {
00144         //  std::vector<TopologyBridge*> *TopologyBridges;
00145         //  CubitTransformMatrix *matrix;
00146           // TODO add data types for other events
00147        // };
00148     };
00149 
00150 
00151 
00152     // get the number of events in this history
00153     int get_number_of_events() const;
00154     // get an event by index
00155     const Event* get_event( int index ) const;
00156 
00157     void print_port_events(); 
00158 
00159     // add an event to this history
00160     void add_event( const Event &new_event );
00161     // compress the events in this history
00162     // for example, if an event for volume 1 created and an event for volume 1
00163     // deleted exists, both are removed
00164 
00165     void add_port_event( const PortEvent &event );
00166 
00167     void compress();
00168     
00169     // cleans out the history
00170     void clear();
00171 
00172     // start tracking events
00173     void start_tracking();
00174     // stop tracking events
00175     void end_tracking();
00176     // ask if tracking
00177     bool is_tracking() const;
00178 
00179   private:
00180     // the list of events
00181     std::vector<Event> eventList;
00182     std::vector<PortEvent> portEventList;
00183     bool mTracking;
00184 };
00185 
00186 #endif
00187 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines