Branch data Line data Source code
1 : : // ********** BEGIN STANDARD INCLUDES **********
2 : :
3 : : #include <assert.h>
4 : :
5 : : // ********** END STANDARD INCLUDES **********
6 : :
7 : : // ********** BEGIN MOTIF INCLUDES **********
8 : : // ********** END MOTIF INCLUDES **********
9 : :
10 : : // ********** BEGIN OPEN INVENTOR INCLUDES **********
11 : : // ********** END OPEN INVENTOR INCLUDES **********
12 : :
13 : : // ********** BEGIN CUBIT INCLUDES **********
14 : :
15 : : #include "RefEntity.hpp"
16 : : #include "CubitDefines.h"
17 : : #include "CubitMessage.hpp"
18 : : #include "CubitString.hpp"
19 : :
20 : : #include "Body.hpp"
21 : : #include "BodySM.hpp"
22 : : #include "RefGroup.hpp"
23 : : #include "RefVolume.hpp"
24 : : #include "RefFace.hpp"
25 : : #include "RefEdge.hpp"
26 : : #include "RefEntityName.hpp"
27 : : #include "RefCollection.hpp"
28 : : #include "RefVertex.hpp"
29 : :
30 : : #include "CollectionEntity.hpp"
31 : :
32 : : #include "ModelQueryEngine.hpp"
33 : :
34 : : #include "TDCompare.hpp"
35 : :
36 : :
37 : : #include "GeometryQueryTool.hpp"
38 : : #include "RefEntityFactory.hpp"
39 : :
40 : : #include "DLIList.hpp"
41 : : #include "CubitUtil.hpp"
42 : : #include "AppUtil.hpp"
43 : :
44 : : // need to include VGE here for free entity test; since virtual geom
45 : : // is so tied into ref entities, I think it's ok (tjt)
46 : : //#include "VirtualGeometryEngine.hpp"
47 : : // Dependency on virtual classes removed, so the VGE does not need
48 : : // to be included. 10-18-01 (wjg)
49 : :
50 : : // The following include generates the inline functions for casting
51 : : // a list of A objects to a list of B objects.
52 : : #include "CastTo.hpp"
53 : :
54 : : #include "MergeTool.hpp"
55 : :
56 : : // ********** END CUBIT INCLUDES **********
57 : :
58 : : // ********** BEGIN STATIC DECLARATIONS **********
59 : : // ********** END STATIC DECLARATIONS **********
60 : :
61 : : // ********** BEGIN PUBLIC FUNCTIONS **********
62 : :
63 [ + - ][ + - ]: 162964 : RefEntity::RefEntity()
[ + - ]
64 : : {
65 : 81482 : autoMergeStatus = AUTO_MERGE_AUTO | AUTO_MERGE_ON;
66 : 81482 : markedFlag = CUBIT_FALSE;
67 : 81482 : listFlag = CUBIT_FALSE;
68 : 81482 : mColor = CUBIT_DEFAULT_COLOR_INDEX;
69 : 81482 : localTolerance = 0.0;
70 : :
71 [ + - ]: 81482 : CGMHistory::Event evt(CGMHistory::ENTITY_CREATED, this);
72 [ + - ][ + - ]: 81482 : GeometryQueryTool::instance()->history().add_event(evt);
[ + - ][ + - ]
73 : 81482 : }
74 : :
75 [ + - ][ + - ]: 100666 : RefEntity::~RefEntity()
[ + - ]
76 : : {
77 [ + - ]: 50333 : CGMHistory::Event evt(CGMHistory::ENTITY_DELETED, this);
78 [ + - ][ + - ]: 50333 : GeometryQueryTool::instance()->history().add_event(evt);
[ + - ]
79 : :
80 : : // Remove the name of this entity from the entity name map
81 [ + - ][ + - ]: 50333 : RefEntityName::instance()->remove_refentity_name(this, CUBIT_FALSE);
82 : :
83 [ + - ][ + - ]: 50333 : remove_from_observers();
84 [ - + ]: 50333 : }
85 : :
86 : 0 : RefEntity* RefEntity::get_by_name(const CubitString& name)
87 : : {
88 : 0 : return RefEntityName::instance()->get_refentity(name);
89 : : }
90 : :
91 : 414 : CubitStatus RefEntity::entity_name (CubitString name)
92 : : {
93 : : // Add the new {RefEntity, Name} tuple to the RefEntityNameMap class.
94 : : // Note that if this name already exists for another RefEntity, then
95 : : // it will return with an error.
96 : : CubitStatus success = RefEntityName::instance()->
97 : 414 : add_refentity_name(this, name);
98 : :
99 [ + - ]: 414 : if (success == CUBIT_SUCCESS)
100 [ + - ][ + - ]: 414 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::ENTITY_NAME_CHANGED, this));
101 : :
102 : 414 : return success;
103 : : }
104 : :
105 : 323 : CubitString RefEntity::entity_name() const
106 : : {
107 [ + - ]: 323 : DLIList<CubitString> names;
108 : :
109 : : // Get the name(s) associated with this RefEntity.
110 [ + - ][ + - ]: 323 : RefEntityName::instance()->get_refentity_name(this, names);
111 : :
112 [ + - ]: 323 : CubitString name;
113 : :
114 : : // If there are no names, then create the default name and return it.
115 [ + - ][ + + ]: 323 : if (names.size() == 0)
116 : : {
117 [ + - ][ + - ]: 88 : name = class_name();
[ + - ][ + - ]
118 [ + - ][ + - ]: 88 : name += " ";
[ + - ]
119 [ + - ][ + - ]: 88 : name += CubitString::number(entityId);
[ + - ]
120 : : }
121 : : else
122 : : {
123 [ + - ][ + - ]: 235 : name = names.get();
124 : : }
125 : :
126 [ + - ]: 323 : return name;
127 : : }
128 : :
129 : 284 : int RefEntity::num_names() const
130 : : {
131 [ + - ]: 284 : DLIList<CubitString> names;
132 : :
133 : : // Get the name(s) associated with this RefEntity.
134 [ + - ][ + - ]: 284 : RefEntityName::instance()->get_refentity_name(this, names);
135 [ + - ][ + - ]: 284 : return names.size();
136 : : }
137 : :
138 : 20 : void RefEntity::entity_names(DLIList<CubitString>& names) const
139 : : {
140 : 20 : RefEntityName::instance()->get_refentity_name(this, names);
141 : 20 : }
142 : :
143 : 0 : CubitStatus RefEntity::remove_entity_name(CubitString const & name)
144 : : {
145 : 0 : RefEntity* entity = RefEntityName::instance()->get_refentity(name);
146 [ # # ]: 0 : if (entity != this)
147 : 0 : return CUBIT_FAILURE;
148 : :
149 : 0 : RefEntityName::instance()->remove_refentity_name(this, name);
150 [ # # ][ # # ]: 0 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::ENTITY_NAME_CHANGED, this));
151 : 0 : return CUBIT_SUCCESS;
152 : : }
153 : :
154 : 20 : CubitStatus RefEntity::remove_entity_names()
155 : : {
156 : 20 : RefEntityName::instance()->remove_refentity_name(this, CUBIT_TRUE);
157 [ + - ][ + - ]: 20 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::ENTITY_NAME_CHANGED, this));
158 : 20 : return CUBIT_SUCCESS;
159 : : }
160 : :
161 : : // All this function basically does is assign the default name.
162 : : // It will do this as an attribute so they get actuated to the
163 : : // solid model.
164 : 0 : CubitStatus RefEntity::generate_default_name( CubitString &name )
165 : : {
166 [ # # ][ # # ]: 0 : if ( CAST_TO( this, Body ) )
167 [ # # ]: 0 : name += CubitString("bod");
168 [ # # ][ # # ]: 0 : else if ( CAST_TO( this, RefVolume ) )
169 [ # # ]: 0 : name += CubitString("vol");
170 [ # # ][ # # ]: 0 : else if ( CAST_TO( this, RefFace ) )
171 [ # # ]: 0 : name += CubitString("sur");
172 [ # # ][ # # ]: 0 : else if ( CAST_TO( this, RefEdge ) )
173 [ # # ]: 0 : name += CubitString("cur");
174 [ # # ][ # # ]: 0 : else if ( CAST_TO( this, RefVertex ) )
175 [ # # ]: 0 : name += CubitString("ver");
176 [ # # ][ # # ]: 0 : else if ( CAST_TO( this, RefGroup ) ) {
177 : : //PRINT_INFO( "Debug: RefGroup entity name set in RefEntity::generate_default_name\n" );
178 [ # # ]: 0 : name += CubitString("gro");
179 : : }
180 : : else
181 : : {
182 [ # # ][ # # ]: 0 : PRINT_ERROR("Invalid entity: %s.\n",
[ # # ][ # # ]
183 [ # # ]: 0 : entity_name().c_str() );
184 : 0 : return CUBIT_FAILURE;
185 : : }
186 : :
187 [ # # ]: 0 : name += CubitString::number(entityId);
188 : 0 : return CUBIT_SUCCESS;
189 : : }
190 : :
191 : 81482 : CubitStatus RefEntity::assign_default_name( CubitBoolean user_setting )
192 : : {
193 : :
194 [ - + ]: 162964 : if ( RefEntityName::instance()->get_generate_default_names()
195 [ + - ][ - + ]: 81482 : || user_setting == CUBIT_TRUE )
196 : : {
197 : : // first generate the default name
198 [ # # ]: 0 : CubitString name;
199 [ # # ]: 0 : CubitStatus result = generate_default_name( name );
200 [ # # ]: 0 : if (result == CUBIT_FAILURE) return result;
201 : :
202 : : // now assign it to this entity and return
203 [ # # ][ # # ]: 0 : RefEntityName::instance()->add_refentity_name(this, name);
204 [ # # ]: 0 : return CUBIT_SUCCESS;
205 : : }
206 : 81482 : return CUBIT_SUCCESS;
207 : : }
208 : :
209 : :
210 : 846 : void RefEntity::merge_entity_names(RefEntity* dead_entity)
211 : : {
212 : 846 : RefEntityName::instance()->merge_refentity_names(this, dead_entity);
213 : 846 : }
214 : :
215 : 0 : void RefEntity::switch_entity_names(RefEntity* other_entity)
216 : : {
217 : 0 : RefEntityName::instance()->switch_refentity_names(this, other_entity);
218 : 0 : }
219 : :
220 : :
221 : : //-------------------------------------------------------------------------
222 : : // Purpose : Target types for parent/child queries
223 : : //
224 : : // Special Notes :
225 : : //
226 : : // Creator : Jason Kraftcheck
227 : : //
228 : : // Creation Date : 07/24/03
229 : : //-------------------------------------------------------------------------
230 : 4440 : DagType RefEntity::get_parent_ref_entity_type() const
231 : 4440 : { return get_parent_ref_entity_type(dag_type()); }
232 : 4440 : DagType RefEntity::get_parent_ref_entity_type(DagType my_type)
233 : : {
234 : 4440 : int dimension = my_type.dimension();
235 : :
236 : : // special case for bodies
237 [ - + ]: 4440 : if (dimension == 3)
238 : : {
239 [ # # ]: 0 : if (my_type.functional_type() == DagType::BasicTopologyEntity_TYPE)
240 : 0 : return DagType::body_type();
241 : : else
242 : 0 : return DagType::invalid_type();
243 : : }
244 : :
245 : 4440 : return DagType( dimension + 1, DagType::BasicTopologyEntity_TYPE);
246 : : }
247 : 75380 : DagType RefEntity::get_child_ref_entity_type() const
248 : 75380 : { return get_child_ref_entity_type(dag_type()); }
249 : 125194 : DagType RefEntity::get_child_ref_entity_type( DagType my_type )
250 : : {
251 : 125194 : int dimension = my_type.dimension();
252 [ + + ]: 125194 : if (my_type.functional_type() == DagType::BasicTopologyEntity_TYPE)
253 : 109942 : return DagType(dimension - 1, DagType::BasicTopologyEntity_TYPE);
254 : : else
255 : 15252 : return DagType(dimension, DagType::BasicTopologyEntity_TYPE);
256 : : }
257 : :
258 : 0 : DagType RefEntity::dag_type( const std::type_info& type )
259 : : {
260 [ # # ]: 0 : if (type == typeid(Body))
261 : 0 : return DagType::body_type();
262 [ # # ]: 0 : else if (type == typeid(RefVolume))
263 : 0 : return DagType::ref_volume_type();
264 [ # # ]: 0 : else if (type == typeid(RefFace))
265 : 0 : return DagType::ref_face_type();
266 [ # # ]: 0 : else if (type == typeid(RefEdge))
267 : 0 : return DagType::ref_edge_type();
268 [ # # ]: 0 : else if (type == typeid(RefVertex))
269 : 0 : return DagType::ref_vertex_type();
270 : :
271 : 0 : assert(0);
272 : : return DagType::invalid_type();
273 : : }
274 : :
275 : 39317 : void RefEntity::get_child_ref_entities(DLIList<RefEntity*>& entity_list)
276 : : {
277 : : // First get the type of RefEntity that is a child of "this" one
278 [ + - ]: 39317 : DagType child_type = get_child_ref_entity_type();
279 : :
280 [ + - ]: 39317 : DLIList<TopologyEntity*> tempList ;
281 : :
282 : : // Now retrieve the appropriate type of child entities of this one
283 : : // if the child_type is a valid type
284 [ + - ][ + + ]: 39317 : if (child_type.is_valid())
285 : : {
286 [ - + ]: 27247 : TopologyEntity* TopologyEntityPtr = CAST_TO(this, TopologyEntity) ;
287 : :
288 [ - + ]: 27247 : assert(TopologyEntityPtr != 0);
289 : :
290 : : CubitStatus result = ModelQueryEngine::instance()->
291 [ + - ][ + - ]: 27247 : query_model( *TopologyEntityPtr, child_type, tempList );
292 [ - + ]: 27247 : if (result == CUBIT_FAILURE)
293 : : {
294 [ # # ][ # # ]: 0 : PRINT_ERROR("In RefEntity::get_child_ref_entities\n");
[ # # ][ # # ]
295 [ # # ][ # # ]: 0 : PRINT_ERROR(" Query failed for unknown reason.\n");
[ # # ][ # # ]
296 : 39317 : return;
297 : : }
298 : :
299 [ + - ][ + - ]: 94155 : CAST_LIST(tempList, entity_list, RefEntity) ;
[ + - ][ - + ]
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ]
300 : 39317 : }
301 : : }
302 : :
303 : :
304 : : //-------------------------------------------------------------------------
305 : : // Purpose : Get all types of child RefEntity
306 : : //
307 : : // Special Notes :
308 : : //
309 : : // Creator : Jason Kraftcheck
310 : : //
311 : : // Creation Date : 07/29/03
312 : : //-------------------------------------------------------------------------
313 : 35217 : void RefEntity::get_all_child_ref_entities(DLIList<RefEntity*>& entity_list)
314 : : {
315 : :
316 [ + - ]: 35217 : ModelQueryEngine *const mqe = ModelQueryEngine::instance();
317 [ + - ]: 35217 : DagType child_type = get_child_ref_entity_type();
318 [ + - ]: 35217 : DLIList<TopologyEntity*> query_output;
319 [ - + ]: 35217 : TopologyEntity* this_me = dynamic_cast<TopologyEntity*>(this);
320 : :
321 : : // note that RefGroups are kind of shoe-horned into RefEntity
322 : : // there are no children of a refgroup
323 [ - + ]: 35217 : if(!this_me)
324 : 35217 : return; //
325 : :
326 : : //While there are more child types
327 [ + - ][ + + ]: 76601 : while (child_type.is_valid())
[ + - ][ + - ]
328 : : {
329 [ + - ]: 41384 : mqe->query_model(*this_me, child_type, query_output);
330 [ + - ]: 41384 : query_output.reset();
331 [ + - ][ + + ]: 214175 : for (int i = query_output.size(); i--; )
332 : : {
333 [ + - ][ - + ]: 172791 : RefEntity* ref_ptr = dynamic_cast<RefEntity*>(query_output.get_and_step());
334 [ + - ]: 172791 : if (ref_ptr)
335 [ + - ]: 172791 : entity_list.append(ref_ptr);
336 : : }
337 : :
338 [ + - ]: 41384 : child_type = get_child_ref_entity_type( child_type );
339 : 35217 : }
340 : : }
341 : :
342 : :
343 : :
344 : : //-------------------------------------------------------------------------
345 : : // Purpose : Get all parent RefEntities for each passed entity.
346 : : //
347 : : // Special Notes :
348 : : //
349 : : // Creator : Jason Kraftcheck
350 : : //
351 : : // Creation Date : 07/29/03
352 : : //-------------------------------------------------------------------------
353 : 1743 : void RefEntity::get_all_child_ref_entities( DLIList<RefEntity*>& input_list,
354 : : DLIList<RefEntity*>& output_list )
355 : : {
356 [ + - ]: 1743 : DLIList<TopologyEntity*> query_output;
357 [ + - ]: 1743 : ModelQueryEngine *const mqe = ModelQueryEngine::instance();
358 : : int i;
359 : :
360 : : // Find parent-most type from all passed entities
361 [ + - ]: 1743 : DagType target_type = DagType::ref_vertex_type();
362 [ + - ][ + + ]: 5841 : for (i = input_list.size(); i--; )
363 : : {
364 [ + - ][ + - ]: 4098 : DagType type = input_list.step_and_get()->dag_type();
365 [ + - ][ + - ]: 4098 : if (type.is_valid() && type > target_type)
[ + - ][ + + ]
[ + + ]
366 : 4098 : target_type = type;
367 : : }
368 : :
369 [ + - ]: 1743 : target_type = get_child_ref_entity_type( target_type );
370 [ + - ][ + + ]: 8430 : while (target_type.is_valid())
371 : : {
372 [ + - ]: 6687 : input_list.reset();
373 [ + - ][ + + ]: 19957 : for (i = input_list.size(); i--; )
374 : : {
375 [ + - ]: 13270 : RefEntity* input_ptr = input_list.get_and_step();
376 [ + - ]: 13270 : DagType source_type = input_ptr->dag_type();
377 : :
378 [ + - ][ + - ]: 13270 : if (source_type.is_valid() && source_type > target_type)
[ + - ][ + - ]
[ + - ]
379 : : {
380 [ - + ]: 13270 : TopologyEntity* me_ptr = dynamic_cast<TopologyEntity*>(input_ptr);
381 [ - + ]: 13270 : assert(!!me_ptr);
382 [ + - ]: 13270 : mqe->query_model (*me_ptr, target_type, query_output);
383 : :
384 [ + - ]: 13270 : query_output.size();
385 [ + - ][ + + ]: 103935 : for ( int j = query_output.size(); j--; )
386 : : {
387 [ + - ][ - + ]: 90665 : RefEntity* ref_ent = dynamic_cast<RefEntity*>(query_output.get_and_step());
388 [ + - ]: 90665 : output_list.append( ref_ent );
389 : : }
390 : : }
391 : : }
392 : :
393 [ + - ]: 6687 : target_type = get_child_ref_entity_type( target_type );
394 : :
395 [ + - ]: 1743 : }
396 : 1743 : }
397 : :
398 : : //-------------------------------------------------------------------------
399 : : // Purpose : Get all types of parent RefEntity
400 : : //
401 : : // Special Notes :
402 : : //
403 : : // Creator : Jason Kraftcheck
404 : : //
405 : : // Creation Date : 07/29/03
406 : : //-------------------------------------------------------------------------
407 : 0 : void RefEntity::get_all_parent_ref_entities(DLIList<RefEntity*>& entity_list,
408 : : const int get_bodies)
409 : : {
410 : :
411 [ # # ]: 0 : ModelQueryEngine *const mqe = ModelQueryEngine::instance();
412 [ # # ]: 0 : DagType parent_type = get_parent_ref_entity_type();
413 [ # # ]: 0 : DLIList<TopologyEntity*> query_output;
414 [ # # ]: 0 : TopologyEntity* this_me = dynamic_cast<TopologyEntity*>(this);
415 [ # # ]: 0 : assert(!!this_me);
416 : :
417 : : //While there are more parent types
418 [ # # ][ # # ]: 0 : while ( parent_type.is_valid() &&
[ # # ][ # # ]
419 [ # # ][ # # ]: 0 : (get_bodies || (parent_type != DagType::body_type())) )
[ # # ]
420 : : {
421 [ # # ]: 0 : mqe->query_model(*this_me, parent_type, query_output);
422 [ # # ]: 0 : query_output.reset();
423 [ # # ][ # # ]: 0 : for (int i = query_output.size(); i--; )
424 : : {
425 [ # # ][ # # ]: 0 : RefEntity* ref_ptr = dynamic_cast<RefEntity*>(query_output.get_and_step());
426 [ # # ]: 0 : assert(!!ref_ptr);
427 [ # # ]: 0 : entity_list.append(ref_ptr);
428 : : }
429 : :
430 [ # # ]: 0 : parent_type = get_parent_ref_entity_type( parent_type );
431 [ # # ]: 0 : }
432 : 0 : }
433 : :
434 : :
435 : 0 : void RefEntity::change_to_parent_ref_entities( DLIList<RefEntity*>& ancestors )
436 : : {
437 [ # # ][ # # ]: 0 : DLIList<RefEntity*> new_ancestors, temp_list;
[ # # ][ # # ]
438 [ # # ][ # # ]: 0 : if ( ancestors.size() == 0 ) return;
439 : :
440 [ # # ]: 0 : ancestors.reset();
441 [ # # ]: 0 : do
442 : : {
443 [ # # ]: 0 : temp_list.clean_out();
444 [ # # ][ # # ]: 0 : ancestors.get_and_step()->get_parent_ref_entities( temp_list );
445 [ # # ]: 0 : new_ancestors.merge_unique( temp_list );
446 [ # # ]: 0 : } while ( !ancestors.is_at_beginning() );
447 : :
448 : : // Overwrite the input list
449 [ # # ][ # # ]: 0 : ancestors = new_ancestors;
[ # # ]
450 : : }
451 : :
452 : 4355 : int RefEntity::dimension() const
453 : : {
454 : : // Virtual function. This is the default return value.
455 : : // Override in subclass if different return value is needed.
456 : 4355 : return -1;
457 : : }
458 : :
459 : :
460 : 0 : RefEntity *RefEntity::join( DLIList<RefEntity*> &ref_entities,
461 : : DLIList<RefEntity*> &join_set )
462 : : {
463 [ # # ]: 0 : join_set.clean_out();
464 : :
465 : : // Trivial cases
466 : :
467 : : // empty set
468 [ # # ][ # # ]: 0 : if ( !ref_entities.size() )
469 : 0 : return NULL;
470 : :
471 : : // All entities are the same, e.g. list is size 1
472 : : int i, j;
473 : 0 : int all_same = CUBIT_TRUE;
474 : : RefEntity *e1, *e2;
475 [ # # ][ # # ]: 0 : for (i = ref_entities.size()-1; all_same && i--; )
[ # # ][ # # ]
476 : : {
477 [ # # ]: 0 : e1 = ref_entities.get_and_step();
478 [ # # ]: 0 : e2 = ref_entities.get();
479 : 0 : all_same = ( e1 == e2 );
480 : : }
481 [ # # ]: 0 : if ( all_same )
482 : : {
483 [ # # ][ # # ]: 0 : join_set.append( ref_entities.get() );
484 [ # # ]: 0 : return join_set.get();
485 : : }
486 : :
487 : : // Generic test, build ancestor lists until dimensions are equal
488 [ # # ]: 0 : const int size = ref_entities.size();
489 : :
490 : : // Lists of ancestors
491 [ # # ][ # # ]: 0 : DLIList<RefEntity*> *ancestors = new DLIList<RefEntity*> [ size ];
[ # # ]
[ # # # # ]
492 : : // current dimension of ancestors of each entity
493 [ # # ][ # # ]: 0 : int *dimension = new int [size];
494 : : // Set ancestors and dimension: Start with the entities themselves
495 : 0 : int d1, max_dimension = -1;
496 [ # # ]: 0 : ref_entities.reset();
497 [ # # ]: 0 : for ( i = 0; i < size; i++ )
498 : : {
499 [ # # ]: 0 : e1 = ref_entities.get_and_step();
500 [ # # ]: 0 : ancestors[i].append( e1 );
501 [ # # ]: 0 : dimension[i] = d1 = e1->dimension();
502 [ # # ]: 0 : if ( d1 > max_dimension )
503 : 0 : max_dimension = d1;
504 : : }
505 : :
506 [ # # ]: 0 : do
507 : : {
508 : :
509 : : // Bump dimensions up to max dimension
510 [ # # ]: 0 : for ( i = 0; i < size; i++ )
511 : : {
512 [ # # ]: 0 : while ( dimension[i] < max_dimension )
513 : : {
514 [ # # ]: 0 : change_to_parent_ref_entities( ancestors[i] );
515 : : // no ancestor of max dimension -> join is nothing
516 [ # # ][ # # ]: 0 : if ( !ancestors[i].size() )
517 : 0 : goto clean_return;
518 [ # # ][ # # ]: 0 : dimension[i] = d1 = ancestors[i].get()->dimension();
519 : : // if somehow a dimension was skipped, go through the list again.
520 [ # # ]: 0 : if ( d1 > max_dimension )
521 : : {
522 : 0 : max_dimension = d1;
523 : 0 : i = 0; // restart loop
524 : : }
525 : : }
526 : : }
527 : :
528 : : // dimensions are the same, see if any entities common to *all* lists
529 [ # # ][ # # ]: 0 : for ( j = ancestors[0].size(); j--; )
530 : : {
531 [ # # ]: 0 : e1 = ancestors[0].get_and_step();
532 : 0 : int in_all_lists = CUBIT_TRUE;
533 [ # # ][ # # ]: 0 : for ( i = 1; in_all_lists && i < size; i++ )
534 : : {
535 [ # # ]: 0 : in_all_lists = ancestors[i].is_in_list( e1 );
536 : : }
537 [ # # ]: 0 : if ( in_all_lists )
538 [ # # ]: 0 : join_set.append( e1 );
539 : : }
540 : :
541 : : // iterate
542 : 0 : max_dimension++;
543 : :
544 : : // they had common entities in the current dimension - return
545 [ # # ]: 0 : } while ( join_set.size() == 0 );
546 : :
547 : : clean_return:
548 [ # # ]: 0 : delete [] dimension;
549 [ # # ][ # # ]: 0 : delete [] ancestors;
[ # # ]
550 : :
551 [ # # ][ # # ]: 0 : if ( join_set.size() )
552 : : {
553 [ # # ]: 0 : join_set.reset();
554 [ # # ]: 0 : return join_set.get();
555 : : }
556 [ # # ]: 0 : return NULL;
557 : : }
558 : :
559 : :
560 : 0 : RefEntity *RefEntity::join( RefEntity* ref_entity_2, DLIList<RefEntity*> &join_set )
561 : : {
562 [ # # ]: 0 : join_set.clean_out();
563 [ # # ]: 0 : assert( this != 0 );
564 : :
565 : : // Trivial case :-)
566 : : // Both entities are the same, or
567 : : // The join of the empty set and any thing is defined to be the thing.
568 [ # # ][ # # ]: 0 : if (this == ref_entity_2 || ref_entity_2 == NULL )
569 : : {
570 [ # # ]: 0 : join_set.append( this );
571 : 0 : return this;
572 : : }
573 : :
574 : : // call generic function that takes a list
575 [ # # ]: 0 : DLIList<RefEntity*> both_entities;
576 [ # # ]: 0 : both_entities.append( this );
577 [ # # ]: 0 : both_entities.append( ref_entity_2 );
578 [ # # ][ # # ]: 0 : return join( both_entities, join_set );
579 : : }
580 : :
581 : 0 : RefEntity *RefEntity::meet( DLIList<RefEntity*> &ref_entities,
582 : : DLIList<RefEntity*> &join_set )
583 : : {
584 [ # # ]: 0 : join_set.clean_out();
585 : :
586 : : // Trivial cases
587 : :
588 : : // empty set
589 [ # # ][ # # ]: 0 : if ( !ref_entities.size() )
590 : 0 : return NULL;
591 : :
592 : : // All entities are the same, e.g. list is size 1
593 : : int i, j;
594 : 0 : int all_same = CUBIT_TRUE;
595 : : RefEntity *e1, *e2;
596 [ # # ][ # # ]: 0 : for (i = ref_entities.size()-1; all_same && i--; )
[ # # ][ # # ]
597 : : {
598 [ # # ]: 0 : e1 = ref_entities.get_and_step();
599 [ # # ]: 0 : e2 = ref_entities.get();
600 : 0 : all_same = ( e1 == e2 );
601 : : }
602 [ # # ]: 0 : if ( all_same )
603 : : {
604 [ # # ][ # # ]: 0 : join_set.append(ref_entities.get());
605 [ # # ]: 0 : return ref_entities.get();
606 : : }
607 : :
608 : : // they aren't all the same; get all the children, intersect the lists,
609 : : // and remove any related entities
610 [ # # ]: 0 : DLIList<RefEntity*> temp_list;
611 [ # # ][ # # ]: 0 : ref_entities.get()->get_all_child_ref_entities(join_set);
612 [ # # ][ # # ]: 0 : join_set.append(ref_entities.get_and_step());
613 : :
614 [ # # ][ # # ]: 0 : for (i = ref_entities.size(); i > 1; i--) {
615 [ # # ]: 0 : temp_list.clean_out();
616 [ # # ][ # # ]: 0 : ref_entities.get()->get_all_child_ref_entities(temp_list);
617 [ # # ][ # # ]: 0 : temp_list.append(ref_entities.get_and_step());
618 [ # # ]: 0 : join_set.intersect(temp_list);
619 : :
620 : : // if the join set is null at any time, there's no common entity
621 [ # # ][ # # ]: 0 : if (join_set.size() == 0) return NULL;
622 : : }
623 : :
624 [ # # ]: 0 : temp_list.clean_out();
625 : :
626 : : // clean out any duplicates before checking for relations
627 [ # # ]: 0 : temp_list.merge_unique(join_set);
628 [ # # ]: 0 : join_set = temp_list;
629 [ # # ]: 0 : temp_list.clean_out();
630 : :
631 : : // now remove any related entities
632 [ # # ]: 0 : join_set.reset();
633 [ # # ]: 0 : join_set.step();
634 [ # # ][ # # ]: 0 : for (i = join_set.size()-1; i > 0; i--) {
635 [ # # ]: 0 : RefEntity *entity = join_set.get();
636 [ # # ][ # # ]: 0 : if (temp_list.move_to(entity)) continue;
637 : :
638 [ # # ][ # # ]: 0 : for (j = join_set.size()-i; j > 0; j--) {
639 [ # # ]: 0 : RefEntity *other_entity = join_set.prev(j);
640 [ # # ][ # # ]: 0 : if (temp_list.move_to(other_entity)) continue;
641 [ # # ][ # # ]: 0 : if (entity->is_child(other_entity)) temp_list.append(entity);
[ # # ]
642 [ # # ][ # # ]: 0 : else if (entity->is_parent(other_entity)) temp_list.append(other_entity);
[ # # ]
643 : : }
644 [ # # ]: 0 : join_set.step();
645 : : }
646 : :
647 [ # # ][ # # ]: 0 : if (temp_list.size() > 0) join_set -= temp_list;
[ # # ]
648 : :
649 [ # # ][ # # ]: 0 : return (join_set.size() ? join_set.get() : NULL);
[ # # ][ # # ]
650 : : }
651 : :
652 : 0 : RefEntity *RefEntity::meet( RefEntity* ref_entity_2, DLIList<RefEntity*> &join_set )
653 : : {
654 [ # # ]: 0 : join_set.clean_out();
655 [ # # ]: 0 : assert( this != 0 );
656 : :
657 : : // Trivial case :-)
658 : : // Both entities are the same, or
659 : : // The join of the empty set and any thing is defined to be the thing.
660 [ # # ][ # # ]: 0 : if (this == ref_entity_2 || ref_entity_2 == NULL )
661 : : {
662 [ # # ]: 0 : join_set.append( this );
663 : 0 : return this;
664 : : }
665 : :
666 : : // call generic function that takes a list
667 [ # # ]: 0 : DLIList<RefEntity*> both_entities;
668 [ # # ]: 0 : both_entities.append( this );
669 [ # # ]: 0 : both_entities.append( ref_entity_2 );
670 [ # # ][ # # ]: 0 : return meet( both_entities, join_set );
671 : : }
672 : :
673 : 0 : int RefEntity::valence(RefEntity *parent)
674 : : {
675 [ # # ]: 0 : DLIList<RefEntity*> parents;
676 [ # # ]: 0 : get_parent_ref_entities(parents);
677 [ # # ][ # # ]: 0 : if (parent == NULL) return parents.size();
678 : :
679 [ # # ]: 0 : int val = parents.size();
680 : : int i;
681 [ # # ]: 0 : BasicTopologyEntity *topo_ent = CAST_TO(this, BasicTopologyEntity);
682 [ # # ]: 0 : for (i = val; i > 0; i--) {
683 [ # # ]: 0 : RefEntity *other_ent = parents.get_and_step();
684 [ # # ][ # # ]: 0 : if (!topo_ent->is_directly_related(CAST_TO(other_ent, BasicTopologyEntity))) val--;
[ # # ]
685 : : }
686 : :
687 [ # # ]: 0 : return val;
688 : : }
689 : :
690 : 0 : CubitVector RefEntity::center_point()
691 : : {
692 [ # # ]: 0 : return bounding_box().center();
693 : : }
694 : :
695 : : // autoMergeStatus :
696 : : // bit 0: 1 = mergeable, 0 = not mergeable
697 : : // bit 1: 1 = auto, 0 = explicit
698 : :
699 : 0 : void RefEntity::is_mergeable(AutoMergeStatus val)
700 : : {
701 : 0 : AutoMergeStatus old_status = (AutoMergeStatus)(autoMergeStatus & 1);
702 : 0 : autoMergeStatus = (int)val;
703 : :
704 : : // always want to update children, but update_auto_merge_state
705 : : // recursively updates the children, so don't update the
706 : : // children twice if we call update_auto_merge_state.
707 [ # # ]: 0 : if( val == AUTO_MERGE_AUTO )
708 : : {
709 : 0 : this->update_auto_merge_state();
710 : : }
711 [ # # ]: 0 : else if( old_status != val )
712 : : {
713 [ # # ]: 0 : DLIList<RefEntity*> children;
714 [ # # ]: 0 : get_child_ref_entities( children );
715 [ # # ][ # # ]: 0 : for( int i = children.size(); i--; )
716 [ # # ][ # # ]: 0 : children.get_and_step()->update_auto_merge_state();
[ # # ]
717 : : }
718 : 0 : }
719 : :
720 : 3782 : bool RefEntity::is_mergeable()
721 : : {
722 : : // return 0-bit of autoMergeState
723 : 3782 : return (bool)(autoMergeStatus & 1);
724 : : }
725 : :
726 : 0 : CubitBoolean RefEntity::is_merged()
727 : : {
728 [ # # ]: 0 : TopologyEntity* topo = CAST_TO(this, TopologyEntity);
729 [ # # ]: 0 : if (!topo)
730 : 0 : return CUBIT_FALSE;
731 : :
732 : 0 : return MergeTool::instance()->entity_merged(topo);
733 : : }
734 : :
735 : 10348 : AutoMergeStatus RefEntity::merge_status() const
736 : : {
737 : 10348 : return autoMergeStatus > 1 ? AUTO_MERGE_AUTO : (AutoMergeStatus)autoMergeStatus;
738 : : }
739 : :
740 : 114 : bool RefEntity::children_mergeable()
741 : : {
742 [ + - ]: 114 : DLIList<RefEntity*> children;
743 [ + - ]: 114 : get_all_child_ref_entities( children );
744 : :
745 [ + - ][ + + ]: 966 : for( int i = children.size(); i--; )
746 [ + - ][ - + ]: 852 : if( children.get_and_step()->autoMergeStatus == 0 )
747 : 0 : return false;
748 : :
749 [ + - ]: 114 : return true;
750 : : }
751 : :
752 : 0 : void RefEntity::update_auto_merge_state()
753 : : {
754 : : int i;
755 : :
756 [ # # ]: 0 : if( autoMergeStatus & 2 )
757 : : {
758 : 0 : int mergeable = 1;
759 : :
760 [ # # ]: 0 : DLIList<RefEntity*> list;
761 : :
762 [ # # ]: 0 : get_parent_ref_entities( list );
763 [ # # ][ # # ]: 0 : for( i = list.size(); i--; )
764 [ # # ][ # # ]: 0 : if( ! list.get_and_step()->is_mergeable() )
[ # # ]
765 : 0 : mergeable = 0;
766 : :
767 : 0 : int old_value = autoMergeStatus & 1;
768 [ # # ]: 0 : if( old_value != mergeable )
769 : : {
770 : 0 : autoMergeStatus = (autoMergeStatus & 2) | mergeable;
771 : :
772 [ # # ]: 0 : list.clean_out();
773 [ # # ]: 0 : get_child_ref_entities( list );
774 : :
775 [ # # ][ # # ]: 0 : for( i = list.size(); i--; )
776 [ # # ][ # # ]: 0 : list.get_and_step()->update_auto_merge_state();
777 [ # # ]: 0 : }
778 : : }
779 : 0 : }
780 : :
781 : 0 : int RefEntity::can_modify() { return 1; }
782 : :
783 : 0 : double RefEntity::measure()
784 : : {
785 : 0 : return 0.0;
786 : : }
787 : :
788 : 0 : CubitString RefEntity::measure_label()
789 : : {
790 : 0 : return "N/A";
791 : : }
792 : :
793 : :
794 : 11 : void RefEntity::notify_sub_all_observers(const GeometryEvent::Type& event)
795 : : {
796 [ + - ]: 11 : DLIList<RefEntity*> entity_list;
797 [ + - ]: 11 : get_all_child_ref_entities( entity_list );
798 [ + - ][ + + ]: 308 : for ( int i = entity_list.size(); i>0; i-- )
799 : : {
800 [ + - ]: 297 : RefEntity* ent = entity_list.get_and_step();
801 [ + - ][ + - ]: 297 : AppUtil::instance()->send_event(GeometryEvent(event, ent));
[ + - ][ + - ]
802 : : }
803 [ + - ][ + - ]: 11 : AppUtil::instance()->send_event(GeometryEvent(event, this));
[ + - ][ + - ]
[ + - ]
804 : 11 : }
805 : :
806 : :
807 : : //-------------------------------------------------------------------------
808 : : // Purpose : This function takes actions depending on the type of
809 : : // event it is notified of.
810 : : //
811 : : // Special Notes :
812 : : //
813 : : // Creator : Raikanta Sahu
814 : : //
815 : : // Creation Date : 11/25/96
816 : : //-------------------------------------------------------------------------
817 : :
818 : 1597 : void RefEntity::comparison_found(RefEntity* partner)
819 : : {
820 : 1597 : add_compare_data(partner);
821 : 1597 : MergeTool::instance()->compare_notify(this) ;
822 : 1597 : MergeTool::instance()->compare_notify(partner) ;
823 : 1597 : }
824 : :
825 : : //-------------------------------------------------------------------------
826 : : // Purpose : This function makes the connection between the two
827 : : // RefEntities, this and partner. At the end of this
828 : : // function the two entities would know who they
829 : : // compare with.
830 : : //
831 : : // Special Notes :
832 : : //
833 : : // Creator : Raikanta Sahu
834 : : //
835 : : // Creation Date : 11/25/96
836 : : //-------------------------------------------------------------------------
837 : :
838 : 1597 : void RefEntity::add_compare_data(RefEntity* partner)
839 : : {
840 : 1597 : TDCompare* compareDataPtr = (TDCompare*)(this->get_TD(&TDCompare::is_compare));
841 [ + + ]: 1597 : if (compareDataPtr == NULL)
842 : : {
843 [ + - ]: 857 : compareDataPtr = new TDCompare() ;
844 : 857 : this->add_TD(compareDataPtr) ;
845 : : }
846 : 1597 : compareDataPtr->set_compare_partner(partner) ;
847 : :
848 : :
849 : 1597 : compareDataPtr = (TDCompare*)(partner->get_TD(&TDCompare::is_compare));
850 [ + + ]: 1597 : if (compareDataPtr == NULL)
851 : : {
852 [ + - ]: 857 : compareDataPtr = new TDCompare() ;
853 : 857 : partner->add_TD(compareDataPtr) ;
854 : : }
855 : 1597 : compareDataPtr->set_compare_partner(this) ;
856 : 1597 : }
857 : :
858 : : //-------------------------------------------------------------------------
859 : : // Purpose : This function clears the compare related temporary data.
860 : : //
861 : : // Special Notes :
862 : : //
863 : : // Creator : Raikanta Sahu
864 : : //
865 : : // Creation Date : 11/25/96
866 : : //-------------------------------------------------------------------------
867 : :
868 : 2190 : void RefEntity::remove_compare_data()
869 : : {
870 : 2190 : ToolData* tdPtr = this->get_TD(&TDCompare::is_compare) ;
871 [ + + ]: 2190 : TDCompare* tdComparePtr = CAST_TO(tdPtr, TDCompare) ;
872 : :
873 [ + + ]: 2190 : if (tdComparePtr == NULL)
874 : : {
875 : 2190 : return ;
876 : : }
877 : 857 : RefEntity* partner = tdComparePtr->get_compare_partner() ;
878 : :
879 [ + - ]: 857 : if (partner != NULL)
880 : : {
881 [ - + ][ # # ]: 857 : PRINT_DEBUG_19(
882 : : "RefEntity::remove_compare_data - Removing TDCompare from"
883 : : " %s %d, via partner %s %d\n",
884 : : partner->class_name(),
885 : : partner->id(),
886 : : this->class_name(),
887 [ # # ]: 0 : this->id());
888 : 857 : partner->delete_TD(&TDCompare::is_compare) ;
889 : : }
890 : :
891 : 857 : this->delete_TD(&TDCompare::is_compare) ;
892 : : // partner->delete_TD(&TDCompare::is_compare) ;
893 : : }
894 : :
895 : 1920 : RefEntity* RefEntity::get_compare_partner()
896 : : {
897 : 1920 : ToolData* tdPtr = get_TD(&TDCompare::is_compare) ;
898 [ + + ]: 1920 : TDCompare* tdComparePtr = CAST_TO(tdPtr, TDCompare) ;
899 [ + + ]: 1920 : return tdComparePtr ? tdComparePtr->get_compare_partner() : 0;
900 : : }
901 : :
902 : 0 : int RefEntity::validate()
903 : : {
904 : : //- This function determines whether the entity is valid.
905 : : //- Several types of checks can be done,
906 : :
907 : : // Check that measure is positive
908 : 0 : int error = 0;
909 : :
910 [ # # ]: 0 : Body *tmp_body = CAST_TO( this, Body);
911 : 0 : bool is_sheet_body = false;
912 [ # # ]: 0 : if( tmp_body )
913 : 0 : is_sheet_body = tmp_body->is_sheet_body();
914 : :
915 [ # # ]: 0 : if( false == is_sheet_body )
916 : : {
917 : 0 : double this_measure = measure();
918 [ # # ]: 0 : if (this_measure <= 0.0) {
919 [ # # ][ # # ]: 0 : PRINT_WARNING("\tWARNING: non-positive %s (%f) for %s, (%s %d)\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
920 : : measure_label().c_str(), this_measure,
921 [ # # ]: 0 : entity_name().c_str(), class_name(), id());
922 : 0 : error++;
923 : : }
924 : : }
925 : 0 : return error;
926 : : }
927 : :
928 : :
929 : 0 : CubitBoolean RefEntity::is_child(RefEntity *entity)
930 : : {
931 : : // same?
932 [ # # ]: 0 : if ( this == entity )
933 : 0 : return CUBIT_TRUE;
934 : :
935 : : // wrong dimensions?
936 [ # # ][ # # ]: 0 : if (!entity || dimension() >= entity->dimension() )
[ # # ]
937 : 0 : return CUBIT_FALSE;
938 : :
939 : : // Topological query.
940 : : // Usually slightly faster to search up in dimension.
941 [ # # ]: 0 : TopologyEntity *topo_this = CAST_TO( this, TopologyEntity );
942 [ # # ]: 0 : TopologyEntity *topo_entity = CAST_TO( entity, TopologyEntity );
943 : 0 : return topo_this->is_directly_related( topo_entity );
944 : : }
945 : :
946 : 0 : CubitBoolean RefEntity::is_parent(RefEntity *entity)
947 : : {
948 : : // same?
949 [ # # ]: 0 : if ( this == entity )
950 : 0 : return CUBIT_TRUE;
951 : :
952 : : // wrong dimensions?
953 [ # # ][ # # ]: 0 : if (!entity || dimension() <= entity->dimension() )
[ # # ]
954 : 0 : return CUBIT_FALSE;
955 : :
956 : : // Topological query.
957 : : // Usually slightly faster to search up in dimension.
958 [ # # ]: 0 : BasicTopologyEntity *topo_this = CAST_TO( this, BasicTopologyEntity );
959 [ # # ]: 0 : BasicTopologyEntity *topo_entity = CAST_TO( entity, BasicTopologyEntity );
960 : 0 : return topo_entity->is_directly_related( topo_this );
961 : : }
962 : :
963 : 1692 : int RefEntity::num_parent_ref_entities()
964 : : {
965 : : // First get the type of RefEntity that is a parent of "this" one
966 [ + - ]: 1692 : DagType parent_type = get_parent_ref_entity_type();
967 : :
968 [ + - ]: 1692 : DLIList<TopologyEntity*> tempList ;
969 : :
970 : : // Now retrieve the appropriate type of parent entities of this one,
971 : : // if the parent_type is a valid type
972 [ + - ][ + - ]: 1692 : if (parent_type.is_valid())
973 : : {
974 [ - + ]: 1692 : TopologyEntity* TopologyEntityPtr = CAST_TO(this, TopologyEntity) ;
975 : :
976 : : //Make sure that we have a valid pointer
977 [ - + ]: 1692 : assert(TopologyEntityPtr != NULL) ;
978 : :
979 : : CubitStatus result = ModelQueryEngine::instance()->
980 : : query_model( *TopologyEntityPtr,
981 : : parent_type,
982 [ + - ][ + - ]: 1692 : tempList );
983 [ - + ]: 1692 : if (result == CUBIT_FAILURE)
984 : : {
985 [ # # ][ # # ]: 0 : PRINT_ERROR("In RefEntity::num_parent_ref_entities\n");
[ # # ][ # # ]
986 [ # # ][ # # ]: 0 : PRINT_ERROR(" Query failed for unknown reason.\n");
[ # # ][ # # ]
987 : 0 : return -1;
988 : : }
989 [ + - ]: 1692 : return tempList.size();
990 : : }
991 : :
992 [ + - ]: 1692 : return -1;
993 : : }
994 : : /*
995 : : CubitBoolean RefEntity::is_free_ref_entity()
996 : : {
997 : : // return true if this RefEntity has no non-virtual parents
998 : : // first look for Body type or # of parents
999 : : if (entity_type_info() == typeid(Body) ||
1000 : : num_parent_ref_entities() == 0) return CUBIT_TRUE;
1001 : :
1002 : :
1003 : : // now look at immediate parents to quickly rule out some entities
1004 : : DLIList<RefEntity*> parents;
1005 : : get_parent_ref_entities(parents);
1006 : : if (!VGE->check_for_virtual(CAST_TO(parents.get(), TopologyEntity)))
1007 : : return CUBIT_FALSE;
1008 : :
1009 : : // now look at all the parents; work back from the list, as this is most
1010 : : // likely to be non-virtual
1011 : : parents.clean_out();
1012 : : get_all_parent_ref_entities(parents);
1013 : : parents.last();
1014 : : RefEntity *ref_entity;
1015 : : int i;
1016 : : for (i = parents.size(); i > 0; i--) {
1017 : : ref_entity = parents.get_and_back();
1018 : : if (!VGE->check_for_virtual(CAST_TO(ref_entity, TopologyEntity)))
1019 : : return CUBIT_FALSE;
1020 : : }
1021 : :
1022 : : // if we've gotten here, we have no non-virtual parents
1023 : : return CUBIT_TRUE;
1024 : : }
1025 : : */
1026 : 0 : void RefEntity::gather_bdy_entities( DLIList<RefEntity*> &entity_list,
1027 : : DLIList<RefEntity*> &bdy_list )
1028 : : {
1029 : : RefEntity *entity;
1030 [ # # ]: 0 : DLIList<RefEntity*> tmp_bdy_list;
1031 : : int i;
1032 : :
1033 [ # # ][ # # ]: 0 : for ( i = entity_list.size(); i--; )
1034 : : {
1035 [ # # ]: 0 : entity = entity_list.get_and_step();
1036 [ # # ]: 0 : entity->list_mark( CUBIT_TRUE );
1037 : : //entity->get_all_child_ref_entities( tmp_bdy_list );
1038 : : }
1039 : :
1040 [ # # ]: 0 : get_all_child_ref_entities(entity_list, tmp_bdy_list);
1041 : :
1042 : :
1043 : : // copy non-duplicate and non-entity_list entities
1044 [ # # ][ # # ]: 0 : for ( i = tmp_bdy_list.size(); i--; ) {
1045 [ # # ]: 0 : entity = tmp_bdy_list.get_and_step();
1046 [ # # ][ # # ]: 0 : if ( !entity->list_mark() ) {
1047 [ # # ]: 0 : bdy_list.append( entity );
1048 [ # # ]: 0 : entity->list_mark( CUBIT_TRUE );
1049 : : }
1050 : : }
1051 : : // clean-up
1052 [ # # ][ # # ]: 0 : for ( i = bdy_list.size(); i--; ) {
1053 [ # # ]: 0 : entity = bdy_list.get_and_step();
1054 [ # # ]: 0 : entity->list_mark( CUBIT_FALSE );
1055 : : }
1056 [ # # ][ # # ]: 0 : for ( i = entity_list.size(); i--; ) {
1057 [ # # ]: 0 : entity = entity_list.get_and_step();
1058 [ # # ]: 0 : entity->list_mark( CUBIT_FALSE );
1059 [ # # ]: 0 : }
1060 : 0 : }
1061 : :
1062 : : //-------------------------------------------------------------------------
1063 : : // Purpose : Most RefEntites related_to another RefEntity can be done
1064 : : // through query model as is in CommandHandler, but
1065 : : // group in <ref_entity> crashes when query model is called, instead
1066 : : // this function will be called
1067 : : //
1068 : : // Special Notes :
1069 : : //
1070 : : // Creator : RY (CAT)
1071 : : //
1072 : : // Creation Date : 5-99
1073 : : //-------------------------------------------------------------------------
1074 : 0 : void RefEntity::get_related_entity_list(const std::type_info& related_entity_type,
1075 : : DLIList<RefEntity*>& entity_list)
1076 : : {
1077 [ # # ]: 0 : if (related_entity_type == typeid(RefGroup)){
1078 [ # # ]: 0 : DLIList <CubitObserver*> observer_list;
1079 [ # # ]: 0 : this->get_observer_list (observer_list);
1080 [ # # ][ # # ]: 0 : for (int i = observer_list.size(); i > 0; i--){
1081 [ # # ][ # # ]: 0 : entity_list.append_unique (CAST_TO (observer_list.get(), RefEntity));
[ # # ]
1082 [ # # ]: 0 : observer_list.step();
1083 [ # # ]: 0 : }
1084 : : }
1085 : 0 : }
1086 : :
1087 : 88 : void RefEntity::set_id(int i )
1088 : : {
1089 : 88 : set_id( i, CUBIT_TRUE );
1090 : 88 : }
1091 : :
1092 : 360 : void RefEntity::set_id(int i, CubitBoolean emit_event )
1093 : : {
1094 [ - + ]: 360 : if (entityId == i)
1095 : 360 : return;
1096 : :
1097 : 360 : int old_id = entityId;
1098 : 360 : entityId = i;
1099 : :
1100 [ + + ]: 360 : if( emit_event )
1101 [ + - ][ + - ]: 88 : AppUtil::instance()->send_event(GeometryIdSetEvent(this, old_id, entityId) );
1102 : :
1103 : 360 : int old_max = RefEntityFactory::instance()->maximum_id(this);
1104 : :
1105 [ + + ]: 360 : if (old_max < entityId)
1106 : : // Need to reset the maxId for this entitytype
1107 : 227 : RefEntityFactory::instance()->incorporate_id(this);
1108 [ + - ]: 133 : else if (old_max == old_id)
1109 : : {
1110 : : // We just reset the entity with the max id to something less
1111 : : // than that - should search and find out what the max id
1112 : : // is now.
1113 [ + - ]: 133 : DLIList<RefEntity*> ent_list;
1114 [ + - ][ + - ]: 133 : if(this->entity_type_info() == typeid(Body))
[ - + ]
1115 [ # # ][ # # ]: 0 : RefEntityFactory::instance()->ref_entity_list("body", ent_list);
1116 [ + - ][ + - ]: 133 : else if(this->entity_type_info() == typeid(RefVolume))
[ - + ]
1117 [ # # ][ # # ]: 0 : RefEntityFactory::instance()->ref_entity_list("volume", ent_list);
1118 [ + - ][ + - ]: 133 : else if(this->entity_type_info() == typeid(RefFace))
[ + + ]
1119 [ + - ][ + - ]: 40 : RefEntityFactory::instance()->ref_entity_list("surface", ent_list);
1120 [ + - ][ + - ]: 93 : else if(this->entity_type_info() == typeid(RefEdge))
[ + + ]
1121 [ + - ][ + - ]: 72 : RefEntityFactory::instance()->ref_entity_list("curve", ent_list);
1122 [ + - ][ + - ]: 21 : else if(this->entity_type_info() == typeid(RefVertex))
[ + + ]
1123 [ + - ][ + - ]: 10 : RefEntityFactory::instance()->ref_entity_list("vertex", ent_list);
1124 : :
1125 : 133 : int max_id = 0;
1126 [ + - ][ + + ]: 1743 : for(int i=ent_list.size()-1; i>-1; i--)
1127 : : {
1128 [ + - ][ + - ]: 1610 : if(ent_list[i]->id() > max_id)
[ + + ]
1129 [ + - ][ + - ]: 122 : max_id = ent_list[i]->id();
1130 : : }
1131 [ + - ][ + - ]: 133 : RefEntityFactory::instance()->maximum_id(this->entity_type_info(), max_id);
[ + - ][ + - ]
1132 : : }
1133 : : }
1134 : :
1135 : 0 : const std::type_info& RefEntity::get_entity_type_info(const char* entity_type)
1136 : : {
1137 [ # # ]: 0 : CubitString string(entity_type);
1138 [ # # ]: 0 : string.to_lower();
1139 : :
1140 [ # # ][ # # ]: 0 : if( string == "group" )
[ # # ][ # # ]
1141 : 0 : return typeid(RefGroup);
1142 [ # # ][ # # ]: 0 : else if (string == "body" )
[ # # ][ # # ]
1143 : 0 : return typeid(Body);
1144 [ # # ][ # # ]: 0 : else if( string == "volume" )
[ # # ][ # # ]
1145 : 0 : return typeid(RefVolume);
1146 [ # # ][ # # ]: 0 : else if( string == "surface" )
[ # # ][ # # ]
1147 : 0 : return typeid(RefFace);
1148 [ # # ][ # # ]: 0 : else if( string == "curve" )
[ # # ][ # # ]
1149 : 0 : return typeid(RefEdge);
1150 [ # # ][ # # ]: 0 : else if( string == "vertex" )
[ # # ][ # # ]
1151 : 0 : return typeid(RefVertex);
1152 : : else
1153 [ # # ]: 0 : return typeid(InvalidEntity);
1154 : : }
1155 : :
1156 : 0 : DagType RefEntity::dag_type(const char* name)
1157 : : {
1158 [ # # ]: 0 : if (CubitUtil::compare(name,"body"))
1159 : 0 : return DagType::body_type();
1160 [ # # ]: 0 : else if (CubitUtil::compare(name,"volume"))
1161 : 0 : return DagType::ref_volume_type();
1162 [ # # ]: 0 : else if (CubitUtil::compare(name,"surface"))
1163 : 0 : return DagType::ref_face_type();
1164 [ # # ]: 0 : else if (CubitUtil::compare(name,"curve"))
1165 : 0 : return DagType::ref_edge_type();
1166 [ # # ]: 0 : else if (CubitUtil::compare(name,"vertex"))
1167 : 0 : return DagType::ref_vertex_type();
1168 : : else
1169 : 0 : return DagType();
1170 : : }
1171 : :
1172 : : #ifdef CAT
1173 : : const char* RefEntity::get_ref_class_name(const std::type_info& ref_type)
1174 : : {
1175 : : if( ref_type == typeid(RefGroup) )
1176 : : return RefGroup::get_class_name();
1177 : : else if( ref_type == typeid(Body) )
1178 : : return Body::get_class_name();
1179 : : else if( ref_type == typeid(RefVolume) )
1180 : : return RefVolume::get_class_name();
1181 : : else if( ref_type == typeid(RefFace) )
1182 : : return RefFace::get_class_name();
1183 : : else if( ref_type == typeid(RefEdge) )
1184 : : return RefEdge::get_class_name();
1185 : : else if( ref_type == typeid(RefVertex) )
1186 : : return RefVertex::get_class_name();
1187 : : else
1188 : : return NULL;
1189 : : }
1190 : : #endif
1191 : :
1192 : :
1193 : 121 : void RefEntity::color(int value)
1194 : : {
1195 : 121 : mColor = value;
1196 [ + - ][ + - ]: 121 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::ENTITY_GEOMETRY_COLOR_CHANGED, this));
1197 : 121 : }
1198 : :
1199 : 0 : int RefEntity::color() const
1200 : : {
1201 : 0 : return mColor;
1202 [ + - ][ + - ]: 6540 : }
1203 : :
1204 : :
|