cgma
CGMHistory.cpp
Go to the documentation of this file.
00001 
00002 #include "CGMHistory.hpp"
00003 #include "TopologyBridge.hpp"
00004 #include "CubitMessage.hpp"
00005 #include "RefEntity.hpp"
00006 
00007 const char* event_names[] = 
00008 {
00009   "TOP_LEVEL_ENTITY_CREATED",
00010   "TOP_LEVEL_ENTITY_DELETED",
00011   "ENTITY_CREATED",
00012   "ENTITY_DELETED",
00013   "TOPOLOGY_CHANGED",
00014   "GEOMETRY_CHANGED",
00015   "GEOMETRY_TRANSFORMED",
00016   "ENTITY_ID_CHANGED",
00017   "ENTITY_NAME_CHANGED",
00018   "ENTITY_COLOR_CHANGED",
00019   "SUBDIVISION",
00020   "ABSORPTION",
00021   "SUBDIVISION_ABSORPTION",
00022   "MERGE",
00023   "COPY",
00024   "CUT"
00025 };
00026 
00027 CGMHistory::CGMHistory()
00028 {
00029   mTracking = false;
00030   //mTracking = true;
00031 }
00032 
00033 CGMHistory::~CGMHistory()
00034 {
00035 }
00036 
00037 CGMHistory::Event::Event(CGMHistory::EventType type, RefEntity* refentity)
00038 {
00039   eventType = type;
00040   entities.push_back(refentity);
00041 }
00042 
00043 CGMHistory::Event::Event(CGMHistory::EventType type, const std::vector<RefEntity*>& refentity_list)
00044 {
00045   eventType = type;
00046   entities = refentity_list;
00047 }
00048 
00049 CGMHistory::Event::~Event()
00050 {
00051 }
00052       
00053 CGMHistory::EventType CGMHistory::Event::get_event_type() const
00054 {
00055   return eventType;
00056 }
00057       
00058 const std::vector<RefEntity*>& CGMHistory::Event::get_entities() const
00059 {
00060   return entities;
00061 }
00062 
00063 void CGMHistory::start_tracking()
00064 {
00065   mTracking = true;
00066 }
00067 
00068 void CGMHistory::end_tracking()
00069 {
00070   mTracking = false;
00071 }
00072 
00073 bool CGMHistory::is_tracking() const
00074 {
00075   return mTracking;
00076 }
00077 
00078 int CGMHistory::get_number_of_events() const
00079 {
00080   return eventList.size();
00081 }
00082     
00083 const CGMHistory::Event* CGMHistory::get_event( int index ) const
00084 {
00085   if (index >= 0 && (size_t)index < eventList.size())
00086     return &eventList[index];
00087   return NULL;
00088 }
00089 
00090 void CGMHistory::add_event( const CGMHistory::Event &event )
00091 {
00092   if(mTracking)
00093     eventList.push_back(event);
00094 }
00095 
00096 void CGMHistory::add_port_event( const CGMHistory::PortEvent &event )
00097 {
00098   if(mTracking)
00099     portEventList.push_back(event);
00100 }
00101 
00102 void CGMHistory::compress()
00103 {
00104   // TODO
00105 }
00106 
00107 void CGMHistory::clear()
00108 {
00109   eventList.clear();
00110   portEventList.clear();
00111 }
00112 
00113 void CGMHistory::print_port_events() 
00114 {
00115   
00116   std::vector<PortEvent>::iterator iter = portEventList.begin();
00117   for(; iter != portEventList.end(); iter++ )
00118   {
00119     PortEvent port_event = *iter;
00120     PRINT_INFO("Event type = %s RefEntities ", event_names[ port_event.eventType ]);
00121 
00122     size_t i;
00123     for ( i = 0; i < port_event.RefEnts.size(); i++ )
00124     {
00125       RefEntity *ref_ent = port_event.RefEnts[i];
00126       PRINT_INFO(" %s %d ", ref_ent->class_name(), ref_ent->id() );
00127     }
00128     PRINT_INFO(" ---> ");
00129     for ( i = 0; i < port_event.TopologyBridges.size(); i++ )
00130     {
00131       TopologyBridge *tb = port_event.TopologyBridges[i];
00132       PRINT_INFO(" %p", (void*)tb );
00133     }
00134     PRINT_INFO("\n"); 
00135   }
00136 }
00137 
00138 CGMHistory::PortEvent::PortEvent(CGMHistory::EventType type )
00139 {
00140   eventType = type;
00141 //  if( eventType != GEOMETRY_TRANSFORMED )
00142 //    TopologyBridges = new std::vector<TopologyBridge*>;
00143 //  else
00144 //    TopologyBridges = NULL;
00145 }
00146 
00147 CGMHistory::PortEvent::~PortEvent()
00148 {
00149 //  if( TopologyBridges )
00150 //    delete TopologyBridges;
00151 }
00152 
00153 CGMHistory::EventType CGMHistory::PortEvent::get_event_type() const
00154 {
00155   return eventType;
00156 }
00157 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines