1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 |
#include "CGMHistory.hpp"
#include "TopologyBridge.hpp"
#include "CubitMessage.hpp"
#include "RefEntity.hpp"
const char* event_names[] =
{
"TOP_LEVEL_ENTITY_CREATED",
"TOP_LEVEL_ENTITY_DELETED",
"ENTITY_CREATED",
"ENTITY_DELETED",
"TOPOLOGY_CHANGED",
"GEOMETRY_CHANGED",
"GEOMETRY_TRANSFORMED",
"ENTITY_ID_CHANGED",
"ENTITY_NAME_CHANGED",
"ENTITY_COLOR_CHANGED",
"SUBDIVISION",
"ABSORPTION",
"SUBDIVISION_ABSORPTION",
"MERGE",
"COPY",
"CUT"
};
CGMHistory::CGMHistory()
{
mTracking = false;
//mTracking = true;
}
CGMHistory::~CGMHistory()
{
}
CGMHistory::Event::Event(CGMHistory::EventType type, RefEntity* refentity)
{
eventType = type;
entities.push_back(refentity);
}
CGMHistory::Event::Event(CGMHistory::EventType type, const std::vector<RefEntity*>& refentity_list)
{
eventType = type;
entities = refentity_list;
}
CGMHistory::Event::~Event()
{
}
CGMHistory::EventType CGMHistory::Event::get_event_type() const
{
return eventType;
}
const std::vector<RefEntity*>& CGMHistory::Event::get_entities() const
{
return entities;
}
void CGMHistory::start_tracking()
{
mTracking = true;
}
void CGMHistory::end_tracking()
{
mTracking = false;
}
bool CGMHistory::is_tracking() const
{
return mTracking;
}
int CGMHistory::get_number_of_events() const
{
return eventList.size();
}
const CGMHistory::Event* CGMHistory::get_event( int index ) const
{
if (index >= 0 && (size_t)index < eventList.size())
return &eventList[index];
return NULL;
}
void CGMHistory::add_event( const CGMHistory::Event &event )
{
if(mTracking)
eventList.push_back(event);
}
void CGMHistory::add_port_event( const CGMHistory::PortEvent &event )
{
if(mTracking)
portEventList.push_back(event);
}
void CGMHistory::compress()
{
// TODO
}
void CGMHistory::clear()
{
eventList.clear();
portEventList.clear();
}
void CGMHistory::print_port_events()
{
std::vector<PortEvent>::iterator iter = portEventList.begin();
for(; iter != portEventList.end(); iter++ )<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
{
PortEvent port_event = *iter;
PRINT_INFO("Event type = %s RefEntities ", event_names[ port_event.eventType ]);
size_t i;
for ( i = 0; i < port_event.RefEnts.size(); i++ )
{
RefEntity *ref_ent = port_event.RefEnts[i];
PRINT_INFO(" %s %d ", ref_ent->class_name(), ref_ent->id() );
}
PRINT_INFO(" ---> ");
for ( i = 0; i < port_event.TopologyBridges.size(); i++ )
{
TopologyBridge *tb = port_event.TopologyBridges[i];
PRINT_INFO(" %p", (void*)tb );
}
PRINT_INFO("\n");
}
}
CGMHistory::PortEvent::PortEvent(CGMHistory::EventType type )
{
eventType = type;
// if( eventType != GEOMETRY_TRANSFORMED )
// TopologyBridges = new std::vector<TopologyBridge*>;
// else
// TopologyBridges = NULL;
}
CGMHistory::PortEvent::~PortEvent()
{
// if( TopologyBridges )
// delete TopologyBridges;
}
CGMHistory::EventType CGMHistory::PortEvent::get_event_type() const
{
return eventType;
}
|