Branch data Line data Source code
1 : :
2 : : #include <assert.h>
3 : : #include <stdlib.h>
4 : : #include <math.h>
5 : :
6 : : #include "CubitDefines.h"
7 : : #include "AppUtil.hpp"
8 : : #include "ProgressTool.hpp"
9 : : #include "GeometryDefines.h"
10 : : #include "GeometryEntity.hpp"
11 : : #include "GeomMeasureTool.hpp"
12 : : #include "GeometryQueryTool.hpp"
13 : : #include "GeometryModifyTool.hpp"
14 : : #include "AnalyticGeometryTool.hpp"
15 : : #include "MergeTool.hpp"
16 : : #include "GeometryQueryEngine.hpp"
17 : : #include "GeometryModifyEngine.hpp" // for creation of temporary construction entities
18 : : #include "DAG.hpp"
19 : : #include "TBOwnerSet.hpp"
20 : :
21 : : #include "RefEntity.hpp"
22 : : #include "RefEntityFactory.hpp"
23 : : #include "BasicTopologyEntity.hpp"
24 : : #include "RefVertex.hpp"
25 : : #include "RefEdge.hpp"
26 : : #include "RefFace.hpp"
27 : : #include "RefVolume.hpp"
28 : : #include "RefGroup.hpp"
29 : :
30 : : #include "CoVertex.hpp"
31 : : #include "CoEdge.hpp"
32 : : #include "CoFace.hpp"
33 : : #include "CoVolume.hpp"
34 : :
35 : : #include "Chain.hpp"
36 : : #include "Loop.hpp"
37 : : #include "Shell.hpp"
38 : : #include "Body.hpp"
39 : :
40 : : #include "Lump.hpp"
41 : : #include "Surface.hpp"
42 : : #include "Curve.hpp"
43 : : #include "Point.hpp"
44 : : #include "BodySM.hpp"
45 : : #include "ShellSM.hpp"
46 : : #include "LoopSM.hpp"
47 : : #include "CoEdgeSM.hpp"
48 : :
49 : : #include "CubitUtil.hpp"
50 : : #include "CubitAttrib.hpp"
51 : : #include "CubitVector.hpp"
52 : : #include "CubitPlane.hpp"
53 : :
54 : : #include "DLIList.hpp"
55 : : #include "GSaveOpen.hpp"
56 : :
57 : : #include "CubitMessage.hpp"
58 : :
59 : : #include "CastTo.hpp"
60 : : #include "CpuTimer.hpp"
61 : :
62 : : #include "BridgeManager.hpp"
63 : : #include "TDUniqueId.hpp"
64 : : #include "CAMergePartner.hpp"
65 : : #include "CAActuateSet.hpp"
66 : : #include "CADeferredAttrib.hpp"
67 : : #include "CAUniqueId.hpp"
68 : :
69 : : #include "SettingHandler.hpp"
70 : : #include "ModelQueryEngine.hpp"
71 : :
72 : : #include "CubitTransformMatrix.hpp"
73 : : #include "CubitUndo.hpp"
74 : : #include "GMem.hpp"
75 : : #include "IntersectionTool.hpp"
76 : :
77 : : #include "GfxPreview.hpp" //DJQ
78 : : #include "GfxDebug.hpp" //DJQ
79 : : #include "RefEntityName.hpp"
80 : :
81 : : double GeometryQueryTool::geometryToleranceFactor = DEFAULT_GEOM_FACTOR;
82 : : GeometryQueryTool* GeometryQueryTool::instance_ = 0;
83 : : CubitBoolean GeometryQueryTool::useFacetBBox = CUBIT_FALSE;
84 : : CubitBoolean GeometryQueryTool::trackMergedAwayEnts = CUBIT_FALSE;
85 : : CubitBoolean GeometryQueryTool::importingSolidModel = CUBIT_FALSE;
86 : : CubitBoolean GeometryQueryTool::mergeGloballyOnImport = CUBIT_TRUE;
87 : : CubitBoolean GeometryQueryTool::clearUidMapBeforeImport = CUBIT_TRUE;
88 : 1635 : DLIList<int> GeometryQueryTool::uidsOfImportingEnts;
89 : : int GeometryQueryTool::entitiesMergedAway = 0;
90 : :
91 : : #ifndef CAT
92 : : // Keep checking bounding box and use internal surf check for Sandia
93 : : CubitBoolean GeometryQueryTool::bboxMergeTest = CUBIT_TRUE;
94 : : int GeometryQueryTool::internalSurfaceMergeTest = 2; // 0=off, 1=all, 2=splines only
95 : : #else
96 : : //test
97 : : // Cat prefers to avoid internal checks altogether as they cause problems with splines
98 : : CubitBoolean GeometryQueryTool::bboxMergeTest = CUBIT_FALSE;
99 : : int GeometryQueryTool::internalSurfaceMergeTest = 0; // 0=off, 1=all, 2=splines only
100 : : #endif // ndef CAT
101 : :
102 : 1635 : double GeometryQueryTool::curveSliverCleanUpTolerance = geometryToleranceFactor*GEOMETRY_RESABS ;
103 : : double GeometryQueryTool::surfaceSliverCleanUpTolerance = -1.0;
104 : :
105 : : // static CubitStatus import_actuate(DLIList<RefEntity*> &entity_list);
106 : :
107 : : // ********** END STATIC DECLARATIONS **********
108 : :
109 : : #define PRINT(var) cout << #var << " = " << var << endl;
110 : :
111 : : #define CUBIT_VERY_SMALL_NUMBER (CUBIT_RESABS * 1.0E-15)
112 : :
113 : : // ********** BEGIN PUBLIC FUNCTIONS **********
114 : : //-------------------------------------------------------------------------
115 : : // Purpose : Controls access and creation of the sole instance of this
116 : : // class.
117 : : //
118 : : // Special Notes :
119 : : //
120 : : // Creator : Xuechen Liu
121 : : //
122 : : // Creation Date : 07/11/96
123 : : //-------------------------------------------------------------------------
124 : :
125 : 211962 : GeometryQueryTool* GeometryQueryTool::instance(GeometryQueryEngine *GQEPtr)
126 : : {
127 : : // Check to see if we have created an instance of the class
128 : : // If proceed to create one.
129 : :
130 [ + + ]: 211962 : if (instance_ == 0)
131 : : {
132 : : // When creating the instance, we should always have a valid
133 : : // GQEPtr. If not, complain.
134 : :
135 [ + - ]: 874 : instance_ = new GeometryQueryTool (GQEPtr) ;
136 : :
137 : : // check to make sure there's a ref entity factory extant
138 : : //RefEntityFactory *factory =
139 : 874 : RefEntityFactory::instance();
140 : : }
141 : :
142 : : // If there is an existing instance of the class, check if there
143 : : // was a request to set default solid modeling engine. If so, be nice
144 : : // to the calling routine :) :) and kindly set the default solid
145 : : // modeling engine.
146 : :
147 [ - + ][ # # ]: 211088 : else if ( GQEPtr != NULL && !instance_->gqeList.move_to(GQEPtr)) {
[ - + ]
148 [ # # ]: 0 : delete instance_->gqeList.remove();
149 : 0 : instance_->gqeList.insert(GQEPtr);
150 : : }
151 : :
152 : : // Return the a pointer to the instance of the class.
153 : :
154 : 211962 : return instance_ ;
155 : : }
156 : :
157 : : //-------------------------------------------------------------------------
158 : : // Purpose : Destructor.
159 : : //
160 : : // Special Notes :
161 : : //
162 : : // Creator : Xuechen Liu
163 : : //
164 : : // Creation Date : 07/11/96
165 : : //-------------------------------------------------------------------------
166 [ + - ][ + - ]: 542 : GeometryQueryTool::~GeometryQueryTool ()
167 : : {
168 : :
169 : : //Kill the geometry query engine(s).
170 : : int i;
171 [ + - ][ + + ]: 813 : for (i = gqeList.size(); i > 0; i--)
172 : : {
173 [ + - ][ + - ]: 542 : delete gqeList.get_and_step();
[ + - ]
174 : : }
175 [ + - ]: 271 : gqeList.clean_out();
176 : :
177 : 271 : instance_ = NULL;
178 : 271 : }
179 : :
180 : : //-------------------------------------------------------------------------
181 : : // Purpose : Function to delete instance variable
182 : : //
183 : : // Special Notes :
184 : : //
185 : : // Creator : Corey Ernst
186 : : //
187 : : // Creation Date : 12/31/07
188 : : //-------------------------------------------------------------------------
189 : 322 : void GeometryQueryTool::delete_instance()
190 : : {
191 [ + + ]: 322 : if( NULL != instance_ )
192 : : {
193 [ + - ]: 271 : delete instance_;
194 : 271 : instance_ = NULL;
195 : : }
196 : 322 : }
197 : :
198 : : //-------------------------------------------------------------------------
199 : : // Purpose : Creates temporary geometry files for save/restore
200 : : //
201 : : // Special Notes :
202 : : //
203 : : // Creator : Corey Ernst
204 : : //
205 : : // Creation Date : 01/17/03
206 : : //-------------------------------------------------------------------------
207 : :
208 : 0 : CubitStatus GeometryQueryTool::save_temp_geom_files(DLIList<RefEntity*> &ref_entity_list,
209 : : const char *base_filename,
210 : : const CubitString &cubit_version,
211 : : std::list<CubitString> &files_written,
212 : : std::list<CubitString> &types_written)
213 : : {
214 : : int i;
215 : : // clear all attributes
216 [ # # ][ # # ]: 0 : if (ref_entity_list.size() == 0) {
217 : :
218 : : // All bodies are to be exported
219 [ # # ]: 0 : RefEntityFactory::instance()->ref_entity_list("Body",
220 [ # # ]: 0 : ref_entity_list);
221 : :
222 : : // add free ref entities
223 [ # # ]: 0 : get_free_ref_entities(ref_entity_list);
224 : :
225 : : }
226 : :
227 : : // get all child entities
228 [ # # ]: 0 : DLIList<RefEntity*> child_list;
229 [ # # ]: 0 : RefEntity::get_all_child_ref_entities( ref_entity_list, child_list );
230 : :
231 : : // merge lists
232 [ # # ][ # # ]: 0 : for(i = ref_entity_list.size(); i--; )
233 [ # # ][ # # ]: 0 : ref_entity_list.get_and_step()->marked(1);
234 [ # # ][ # # ]: 0 : for(i = child_list.size(); i--; )
235 [ # # ][ # # ]: 0 : child_list.get_and_step()->marked(0);
236 [ # # ][ # # ]: 0 : for(i = ref_entity_list.size(); i--; )
237 : : {
238 [ # # ]: 0 : RefEntity* ent = ref_entity_list.get_and_step();
239 [ # # ][ # # ]: 0 : if( ent->marked() )
240 : : {
241 [ # # ]: 0 : ent->marked(0);
242 [ # # ]: 0 : child_list.append(ent);
243 : : }
244 : : }
245 : :
246 : : // now call auto update on this combined list; this will update both visible
247 : : // and hidden entities; the combined list should be used here, but only the
248 : : // export list should be exported (some of the hidden entities might be directly
249 : : // related to other entities on the export list, and we want to avoid exporting
250 : : // those entities twice)
251 [ # # ]: 0 : CubitAttribUser::auto_update_cubit_attrib(child_list);
252 : :
253 : : // Get list of TopologyBridges to save
254 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> geometry_list(ref_entity_list.size()), ref_ent_bridges;
[ # # ][ # # ]
[ # # ]
255 [ # # ]: 0 : ref_entity_list.reset();
256 [ # # ][ # # ]: 0 : for ( i = ref_entity_list.size(); i--; )
257 : : {
258 [ # # ]: 0 : RefEntity* ref_ent = ref_entity_list.get_and_step();
259 [ # # ]: 0 : TopologyEntity* topo_ent = dynamic_cast<TopologyEntity*>(ref_ent);
260 [ # # ]: 0 : if ( !topo_ent )
261 : : {
262 [ # # ][ # # ]: 0 : PRINT_ERROR("Attempt to save %s (%s %d) as geometry.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
263 [ # # ]: 0 : ref_ent->entity_name().c_str(), ref_ent->class_name(), ref_ent->id());
264 : 0 : continue;
265 : : }
266 : :
267 [ # # ]: 0 : ref_ent_bridges.clean_out();
268 [ # # ][ # # ]: 0 : topo_ent->bridge_manager()->get_bridge_list(ref_ent_bridges);
269 [ # # ]: 0 : geometry_list += ref_ent_bridges;
270 : : }
271 : :
272 : : // Save virtual.
273 [ # # ][ # # ]: 0 : for (IGESet::reverse_iterator itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ # # ][ # # ]
[ # # ]
274 [ # # ][ # # ]: 0 : (*itor)->export_geometry(geometry_list);
275 : :
276 : : //we need this list around so that we can remove the CSAs off
277 : : // the entities under the virtual entities
278 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> geometry_list2 = geometry_list;
279 : :
280 : 0 : CubitStatus result = CUBIT_SUCCESS, temp_result;
281 : :
282 : 0 : GeometryQueryEngine* gqe = NULL;
283 : : //we're just going to mess with MBG stuff right now
284 [ # # ]: 0 : gqeList.reset();
285 [ # # ][ # # ]: 0 : for( int k=0; k<gqeList.size(); k++)
286 : : {
287 [ # # ]: 0 : gqe = gqeList.get_and_step();
288 : :
289 [ # # ]: 0 : CubitString file_written;
290 [ # # ][ # # ]: 0 : CubitString type_written;
291 : :
292 : : temp_result = gqe->save_temp_geom_file(geometry_list, base_filename,
293 : : cubit_version, file_written,
294 [ # # ]: 0 : type_written );
295 [ # # ][ # # ]: 0 : if( file_written.length() )
296 : : {
297 [ # # ]: 0 : files_written.push_back( file_written );
298 [ # # ]: 0 : types_written.push_back( type_written );
299 : : }
300 : :
301 [ # # ]: 0 : if (CUBIT_SUCCESS == temp_result) result = temp_result;
302 : :
303 [ # # ]: 0 : }
304 : :
305 : :
306 : : //if there is still geometry left over....could not be handled
307 [ # # ][ # # ]: 0 : if( geometry_list.size() )
308 [ # # ][ # # ]: 0 : PRINT_ERROR("Not all geometry could be handled for save.\n");
[ # # ][ # # ]
309 [ # # ]: 0 : CubitAttribUser::clear_all_simple_attrib(child_list);
310 : :
311 : : //remove attributes off underlying entities of virtual geometry
312 [ # # ][ # # ]: 0 : if( geometry_list2.size() )
313 [ # # ][ # # ]: 0 : GeometryQueryTool::instance()->ige_remove_attributes( geometry_list2 );
314 : :
315 [ # # ]: 0 : gqeList.reset();
316 [ # # ]: 0 : return result;
317 : : }
318 : :
319 : : //-------------------------------------------------------------------------
320 : : // Purpose : Export a list of solid model entities to a file.
321 : : //
322 : : // Special Notes :
323 : : //
324 : : // Creator : Steve Storm
325 : : //
326 : : // Creation Date : 03/17/99
327 : : //-------------------------------------------------------------------------
328 : :
329 : 296 : CubitStatus GeometryQueryTool::export_solid_model(DLIList<RefEntity*>& ref_entity_list,
330 : : char const* filename,
331 : : Model_File_Type filetype,
332 : : int &num_ents_exported,
333 : : const CubitString &cubit_version,
334 : : ModelExportOptions &export_options )
335 : : {
336 [ + - ][ - + ]: 296 : if (0 == gqeList.size())
337 : : {
338 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.\n");
[ # # ][ # # ]
339 : 0 : return CUBIT_FAILURE;
340 : : }
341 : :
342 : : int i;
343 : :
344 [ + - ][ + + ]: 296 : if (ref_entity_list.size() == 0) {
345 : :
346 : : // All bodies are to be exported
347 [ + - ]: 186 : RefEntityFactory::instance()->ref_entity_list("Body",
348 [ + - ]: 186 : ref_entity_list);
349 : :
350 : : // add free ref entities
351 [ + - ]: 186 : get_free_ref_entities(ref_entity_list);
352 : :
353 : : }
354 : :
355 : : // Get TopologyBridges from RefEntities.
356 [ + - ][ + - ]: 296 : DLIList<TopologyBridge*> bridge_list(ref_entity_list.size()),
357 [ + - ][ + - ]: 592 : parent_bridges, ref_ent_bridges;
[ + - ][ + - ]
358 [ + - ]: 296 : ref_entity_list.reset();
359 [ + - ][ + + ]: 1876 : for( i = ref_entity_list.size(); i--; )
360 : : {
361 [ + - ]: 1580 : ref_ent_bridges.clean_out();
362 [ + - ][ - + ]: 1580 : TopologyEntity* topo_ptr = dynamic_cast<TopologyEntity*>(ref_entity_list.get_and_step());
363 [ + - ]: 1580 : if( topo_ptr )
364 [ + - ][ + - ]: 1580 : topo_ptr->bridge_manager()->get_bridge_list( ref_ent_bridges );
365 [ + - ]: 1580 : bridge_list += ref_ent_bridges;
366 : : }
367 : :
368 : : // Get all child RefEntities
369 [ + - ][ + - ]: 592 : DLIList<RefEntity*> child_list;
370 [ + - ]: 296 : RefEntity::get_all_child_ref_entities( ref_entity_list, child_list );
371 : :
372 : : // Scan for free-but-merged entities in child list.
373 [ + - ]: 296 : child_list.reset();
374 [ + - ][ + + ]: 21616 : for (i = child_list.size(); i--; )
375 : : {
376 [ + - ]: 21320 : ref_ent_bridges.clean_out();
377 [ + - ][ - + ]: 21320 : TopologyEntity* topo_ptr = dynamic_cast<TopologyEntity*>(child_list.get_and_step());
378 [ - + ]: 21320 : assert(!!topo_ptr);
379 [ + - ][ + - ]: 21320 : topo_ptr->bridge_manager()->get_bridge_list( ref_ent_bridges );
380 [ + - ]: 21320 : ref_ent_bridges.reset();
381 [ + - ][ + + ]: 44152 : for (int j = ref_ent_bridges.size(); j--; )
382 : : {
383 [ + - ]: 22832 : TopologyBridge* bridge = ref_ent_bridges.get_and_step();
384 [ + - ]: 22832 : parent_bridges.clean_out();
385 [ + - ]: 22832 : bridge->get_parents(parent_bridges);
386 [ + - ][ - + ]: 22832 : if (parent_bridges.size() == 0)
387 [ # # ]: 22832 : bridge_list.append_unique(bridge);
388 : : }
389 : : }
390 : :
391 : : // Merge lists so we have one big list of every
392 : : // RefEntity to be saved.
393 [ + - ][ + + ]: 1876 : for(i = ref_entity_list.size(); i--; )
394 [ + - ][ + - ]: 1580 : ref_entity_list.get_and_step()->marked(1);
395 : :
396 [ + - ][ + + ]: 21616 : for(i = child_list.size(); i--; )
397 [ + - ][ + - ]: 21320 : child_list.get_and_step()->marked(0);
398 [ + - ][ + + ]: 1876 : for(i = ref_entity_list.size(); i--; )
399 : : {
400 [ + - ]: 1580 : RefEntity* ent = ref_entity_list.get_and_step();
401 [ + - ][ + - ]: 1580 : if( ent->marked() )
402 : : {
403 [ + - ]: 1580 : ent->marked(0);
404 [ + - ]: 1580 : child_list.append(ent);
405 : : }
406 : : }
407 : :
408 : : // Make a copy of the bridge list to be used below in
409 : : // removing the virtual geometry attributes. We can't
410 : : // use the original bridge list because it gets emptied.
411 [ + - ][ + - ]: 592 : DLIList<TopologyBridge*> copy_of_bridge_list = bridge_list;
412 : :
413 [ + - ]: 296 : int num_input_entities = bridge_list.size();
414 : :
415 : : // now call auto update on this combined list; this will update both visible
416 : : // and hidden entities; the combined list should be used here, but only the
417 : : // export list should be exported (some of the hidden entities might be directly
418 : : // related to other entities on the export list, and we want to avoid exporting
419 : : // those entities twice)
420 [ + - ]: 296 : CubitAttribUser::auto_update_cubit_attrib(child_list);
421 : :
422 : : // Save virtual.
423 [ + - ]: 296 : IGESet::reverse_iterator itor;
424 [ + - ][ + - ]: 888 : for (itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ + - ][ + - ]
[ + + ]
425 [ + - ][ + - ]: 592 : (*itor)->export_geometry(bridge_list);
426 : :
427 : 296 : CubitStatus result = CUBIT_SUCCESS, temp_result;
428 : :
429 [ + - ][ - + ]: 296 : if( !bridge_list.size() )
430 : : {
431 : 0 : return CUBIT_SUCCESS;
432 : : }
433 : : // GeometryQueryEngine* gqe = NULL;
434 : : //we're just going to mess with MBG stuff right now
435 [ + - ]: 296 : gqeList.reset();
436 : :
437 [ + - ]: 296 : int num_ents_before = bridge_list.size();
438 [ + - ]: 296 : temp_result = gqeList.get()->export_solid_model(bridge_list, filename, filetype,
439 [ + - ]: 296 : cubit_version, export_options );
440 [ + - ]: 296 : if (temp_result == CUBIT_SUCCESS )
441 : 296 : result = temp_result;
442 : :
443 : : //if all geometry wasn't exported, warn user and print out
444 : : //what wasn't
445 [ + - ][ - + ]: 296 : if( bridge_list.size() != 0 )
446 : : {
447 [ # # ][ # # ]: 0 : if( bridge_list.size() == num_ents_before )
448 [ # # ][ # # ]: 0 : PRINT_ERROR("No geometry exported. Must set geometry engine to another type.\n");
[ # # ][ # # ]
449 : : else
450 [ # # ][ # # ]: 0 : PRINT_WARNING("Not all geometry could be handled for save.\n");
[ # # ][ # # ]
451 : :
452 [ # # ][ # # ]: 0 : PRINT_INFO("Set the geometry engine appropriately to export the following geometry:\n");
[ # # ][ # # ]
453 : : int k;
454 [ # # ][ # # ]: 0 : for(k=bridge_list.size(); k--; )
455 : : {
456 [ # # ][ # # ]: 0 : TopologyEntity *te = bridge_list.get()->topology_entity();
457 [ # # ]: 0 : if( te )
458 : : {
459 [ # # ]: 0 : RefEntity *ref_ent = CAST_TO( te, RefEntity );
460 [ # # ]: 0 : if( ref_ent )
461 : : {
462 [ # # ][ # # ]: 0 : GeometryQueryEngine *gqe = bridge_list.get()->get_geometry_query_engine();
463 [ # # ][ # # ]: 0 : PRINT_INFO("%s is of Geometry Engine type %s\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
464 [ # # ]: 0 : ref_ent->entity_name().c_str(), gqe->modeler_type() );
465 : : }
466 : : }
467 [ # # ]: 0 : bridge_list.step();
468 : : }
469 : : }
470 : :
471 : : // clean off attributes off of underyling virtual geometry
472 [ + - ][ + - ]: 888 : for (itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ + - ][ + - ]
[ + + ]
473 [ + - ][ + - ]: 592 : (*itor)->remove_attributes(copy_of_bridge_list);
474 : :
475 [ + - ]: 296 : CubitAttribUser::clear_all_simple_attrib(child_list);
476 : :
477 [ + - ]: 296 : num_ents_exported = num_input_entities - bridge_list.size();
478 [ + - ]: 296 : gqeList.reset();
479 [ + - ]: 592 : return result;
480 : : }
481 : :
482 : : // export entities to buffer
483 : 0 : CubitStatus GeometryQueryTool::export_solid_model(DLIList<RefEntity*>& ref_entity_list,
484 : : char*& p_buffer,
485 : : int& n_buffer_size,
486 : : bool b_export_buffer)
487 : : {
488 [ # # ][ # # ]: 0 : if (0 == gqeList.size())
489 : : {
490 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.\n");
[ # # ][ # # ]
491 : 0 : return CUBIT_FAILURE;
492 : : }
493 : :
494 : : int i;
495 : :
496 [ # # ][ # # ]: 0 : if (ref_entity_list.size() == 0) {
497 : : // All bodies are to be exported
498 [ # # ]: 0 : RefEntityFactory::instance()->ref_entity_list("Body",
499 [ # # ]: 0 : ref_entity_list);
500 : :
501 : : // add free ref entities
502 [ # # ]: 0 : get_free_ref_entities(ref_entity_list);
503 : : }
504 : :
505 : : // Get TopologyBridges from RefEntities.
506 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> bridge_list(ref_entity_list.size()),
507 [ # # ][ # # ]: 0 : parent_bridges, ref_ent_bridges;
[ # # ][ # # ]
508 [ # # ]: 0 : ref_entity_list.reset();
509 [ # # ][ # # ]: 0 : for( i = ref_entity_list.size(); i--; ) {
510 [ # # ]: 0 : ref_ent_bridges.clean_out();
511 [ # # ][ # # ]: 0 : TopologyEntity* topo_ptr = dynamic_cast<TopologyEntity*>(ref_entity_list.get_and_step());
512 [ # # ]: 0 : if( topo_ptr )
513 [ # # ][ # # ]: 0 : topo_ptr->bridge_manager()->get_bridge_list( ref_ent_bridges );
514 [ # # ]: 0 : bridge_list += ref_ent_bridges;
515 : : }
516 : :
517 : : // Get all child RefEntities
518 [ # # ][ # # ]: 0 : DLIList<RefEntity*> child_list;
519 [ # # ]: 0 : RefEntity::get_all_child_ref_entities( ref_entity_list, child_list );
520 : :
521 : : // Scan for free-but-merged entities in child list.
522 [ # # ]: 0 : child_list.reset();
523 [ # # ][ # # ]: 0 : for (i = child_list.size(); i--; )
524 : : {
525 [ # # ]: 0 : ref_ent_bridges.clean_out();
526 [ # # ][ # # ]: 0 : TopologyEntity* topo_ptr = dynamic_cast<TopologyEntity*>(child_list.get_and_step());
527 [ # # ]: 0 : assert(!!topo_ptr);
528 [ # # ][ # # ]: 0 : topo_ptr->bridge_manager()->get_bridge_list( ref_ent_bridges );
529 [ # # ]: 0 : ref_ent_bridges.reset();
530 [ # # ][ # # ]: 0 : for (int j = ref_ent_bridges.size(); j--; )
531 : : {
532 [ # # ]: 0 : TopologyBridge* bridge = ref_ent_bridges.get_and_step();
533 [ # # ]: 0 : parent_bridges.clean_out();
534 [ # # ]: 0 : bridge->get_parents(parent_bridges);
535 [ # # ][ # # ]: 0 : if (parent_bridges.size() == 0)
536 [ # # ]: 0 : bridge_list.append_unique(bridge);
537 : : }
538 : : }
539 : :
540 : : // Merge lists so we have one big list of every
541 : : // RefEntity to be saved.
542 [ # # ][ # # ]: 0 : for(i = ref_entity_list.size(); i--; )
543 [ # # ][ # # ]: 0 : ref_entity_list.get_and_step()->marked(1);
544 : :
545 [ # # ][ # # ]: 0 : for(i = child_list.size(); i--; )
546 [ # # ][ # # ]: 0 : child_list.get_and_step()->marked(0);
547 [ # # ][ # # ]: 0 : for(i = ref_entity_list.size(); i--; )
548 : : {
549 [ # # ]: 0 : RefEntity* ent = ref_entity_list.get_and_step();
550 [ # # ][ # # ]: 0 : if( ent->marked() )
551 : : {
552 [ # # ]: 0 : ent->marked(0);
553 [ # # ]: 0 : child_list.append(ent);
554 : : }
555 : : }
556 : :
557 : : // Make a copy of the bridge list to be used below in
558 : : // removing the virtual geometry attributes. We can't
559 : : // use the original bridge list because it gets emptied.
560 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> copy_of_bridge_list = bridge_list;
561 : :
562 [ # # ]: 0 : /*int num_input_entities =*/ bridge_list.size();
563 : :
564 : : // now call auto update on this combined list; this will update both visible
565 : : // and hidden entities; the combined list should be used here, but only the
566 : : // export list should be exported (some of the hidden entities might be directly
567 : : // related to other entities on the export list, and we want to avoid exporting
568 : : // those entities twice)
569 [ # # ]: 0 : CubitAttribUser::auto_update_cubit_attrib(child_list);
570 : :
571 : : // Save virtual.
572 [ # # ]: 0 : IGESet::reverse_iterator itor;
573 [ # # ][ # # ]: 0 : for (itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ # # ][ # # ]
[ # # ]
574 [ # # ][ # # ]: 0 : (*itor)->export_geometry(bridge_list);
575 : :
576 : 0 : CubitStatus result = CUBIT_SUCCESS, temp_result;
577 : :
578 [ # # ][ # # ]: 0 : if( !bridge_list.size() )
579 : : {
580 : 0 : return CUBIT_SUCCESS;
581 : : }
582 : : // GeometryQueryEngine* gqe = NULL;
583 : : //we're just going to mess with MBG stuff right now
584 [ # # ]: 0 : gqeList.reset();
585 : :
586 [ # # ]: 0 : int num_ents_before = bridge_list.size();
587 [ # # ]: 0 : temp_result = gqeList.get()->export_solid_model(bridge_list, p_buffer,
588 [ # # ]: 0 : n_buffer_size, b_export_buffer);
589 [ # # ]: 0 : if (temp_result == CUBIT_SUCCESS )
590 : 0 : result = temp_result;
591 : :
592 : : //if all geometry wasn't exported, warn user and print out
593 : : //what wasn't
594 [ # # ][ # # ]: 0 : if( bridge_list.size() != 0 )
595 : : {
596 [ # # ][ # # ]: 0 : if( bridge_list.size() == num_ents_before )
597 [ # # ][ # # ]: 0 : PRINT_ERROR("No geometry exported. Must set geometry engine to another type.\n");
[ # # ][ # # ]
598 : : else
599 [ # # ][ # # ]: 0 : PRINT_WARNING("Not all geometry could be handled for save.\n");
[ # # ][ # # ]
600 : :
601 [ # # ][ # # ]: 0 : PRINT_INFO("Set the geometry engine appropriately to export the following geometry:\n");
[ # # ][ # # ]
602 : : int k;
603 [ # # ][ # # ]: 0 : for(k=bridge_list.size(); k--; )
604 : : {
605 [ # # ][ # # ]: 0 : TopologyEntity *te = bridge_list.get()->topology_entity();
606 [ # # ]: 0 : if( te )
607 : : {
608 [ # # ]: 0 : RefEntity *ref_ent = CAST_TO( te, RefEntity );
609 [ # # ]: 0 : if( ref_ent )
610 : : {
611 [ # # ][ # # ]: 0 : GeometryQueryEngine *gqe = bridge_list.get()->get_geometry_query_engine();
612 [ # # ][ # # ]: 0 : PRINT_INFO("%s is of Geometry Engine type %s\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
613 [ # # ]: 0 : ref_ent->entity_name().c_str(), gqe->modeler_type() );
614 : : }
615 : : }
616 [ # # ]: 0 : bridge_list.step();
617 : : }
618 : : }
619 : :
620 : : // clean off attributes off of underyling virtual geometry
621 [ # # ][ # # ]: 0 : for (itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ # # ][ # # ]
[ # # ]
622 [ # # ][ # # ]: 0 : (*itor)->remove_attributes(copy_of_bridge_list);
623 : :
624 [ # # ]: 0 : CubitAttribUser::clear_all_simple_attrib(child_list);
625 : :
626 : : //num_ents_exported = num_input_entities - bridge_list.size();
627 [ # # ]: 0 : gqeList.reset();
628 [ # # ]: 0 : return result;
629 : : }
630 : :
631 : : //-------------------------------------------------------------------------
632 : : // Purpose : Fire a ray at a list of entities and return the
633 : : // parameters along the ray (distance from origin of ray)
634 : : // where it hits the entities; optionally find the
635 : : // corresponding entities it hit.
636 : : //
637 : : // Special Notes :
638 : : //
639 : : // Creator : Steve Storm
640 : : //
641 : : // Creation Date : 3/29/2007
642 : : //-------------------------------------------------------------------------
643 : 0 : CubitStatus GeometryQueryTool::fire_ray( CubitVector &origin,
644 : : CubitVector &direction,
645 : : DLIList<RefEntity*> &at_entity_list,
646 : : DLIList<double> &ray_params,
647 : : int max_hits,
648 : : double ray_radius,
649 : : DLIList<RefEntity*> *hit_entity_list_ptr )
650 : : {
651 : : int i;
652 : :
653 : : // Do this in a way to account for the case if they happen to be from
654 : : // different geometry engines (could easily occur with virtual geometry)
655 : :
656 [ # # ]: 0 : DLIList<TopologyEntity*> te_fire_at_list;
657 [ # # ][ # # ]: 0 : DLIList<TopologyEntity*> te_hit_entity_list;
658 : 0 : DLIList<TopologyEntity*> *te_hit_entity_list_ptr = 0;
659 [ # # ]: 0 : if( hit_entity_list_ptr )
660 : 0 : te_hit_entity_list_ptr = &te_hit_entity_list;
661 : :
662 : 0 : GeometryQueryEngine *gqe = 0;
663 : 0 : GeometryQueryEngine *gqe_last = 0;
664 : : RefEntity *ref_entity_ptr;
665 : : TopologyEntity *topo_ptr;
666 : :
667 : 0 : int loc_max_hits = max_hits;
668 : 0 : CubitBoolean hits_limited = CUBIT_FALSE;
669 [ # # ]: 0 : if( max_hits > 0 )
670 : 0 : hits_limited = CUBIT_TRUE;
671 : :
672 : : // Note we care about order
673 [ # # ]: 0 : at_entity_list.reset();
674 [ # # ][ # # ]: 0 : for( i=at_entity_list.size(); i--; )
675 : : {
676 [ # # ]: 0 : ref_entity_ptr = at_entity_list.get_and_step();
677 : :
678 [ # # ]: 0 : topo_ptr = CAST_TO( ref_entity_ptr, TopologyEntity );
679 [ # # ]: 0 : if( !topo_ptr )
680 : : {
681 [ # # ][ # # ]: 0 : PRINT_ERROR( "Couldnt get topo_ptr\n" );
[ # # ][ # # ]
682 : 0 : continue;
683 : : }
684 : :
685 [ # # ]: 0 : gqe = topo_ptr->get_geometry_query_engine();
686 [ # # ]: 0 : if( !gqe )
687 : : {
688 [ # # ][ # # ]: 0 : PRINT_ERROR( "Unable to find geometry engine associated with an entity!\n" );
[ # # ][ # # ]
689 : 0 : return CUBIT_FAILURE;
690 : : }
691 : :
692 [ # # ]: 0 : if( !gqe_last )
693 : : {
694 : 0 : gqe_last = gqe;
695 : : }
696 [ # # ]: 0 : if( gqe != gqe_last )
697 : : {
698 [ # # ]: 0 : if( hits_limited == CUBIT_TRUE )
699 : : {
700 [ # # ]: 0 : loc_max_hits = max_hits - ray_params.size();
701 [ # # ]: 0 : if( loc_max_hits <= 0 )
702 : 0 : break;
703 : : }
704 : :
705 [ # # ]: 0 : if( fire_ray( origin, direction, te_fire_at_list, ray_params,
706 [ # # ]: 0 : loc_max_hits, ray_radius, te_hit_entity_list_ptr ) == CUBIT_FAILURE )
707 : 0 : return CUBIT_FAILURE;
708 : :
709 : : // Reset
710 : 0 : gqe_last = gqe;
711 [ # # ]: 0 : te_fire_at_list.clean_out();
712 : : }
713 : :
714 [ # # ]: 0 : te_fire_at_list.append( topo_ptr );
715 : : }
716 : :
717 : : // Do the last ray fire, if necessary
718 [ # # ]: 0 : if( hits_limited == CUBIT_TRUE )
719 [ # # ]: 0 : loc_max_hits = max_hits - ray_params.size();
720 [ # # ][ # # ]: 0 : if( hits_limited==CUBIT_FALSE || loc_max_hits>0 )
721 [ # # ]: 0 : if( fire_ray( origin, direction, te_fire_at_list, ray_params,
722 [ # # ]: 0 : loc_max_hits, ray_radius, te_hit_entity_list_ptr ) == CUBIT_FAILURE )
723 : 0 : return CUBIT_FAILURE;
724 : :
725 [ # # ]: 0 : if( hit_entity_list_ptr )
726 : : {
727 : : // Find RefEntities from TopologyEntities
728 [ # # ]: 0 : te_hit_entity_list.reset();
729 [ # # ][ # # ]: 0 : for( i=te_hit_entity_list.size(); i--; )
730 : : {
731 [ # # ]: 0 : topo_ptr = te_hit_entity_list.get_and_step();
732 [ # # ]: 0 : if( !topo_ptr )
733 : : {
734 [ # # ]: 0 : hit_entity_list_ptr->append( 0 );
735 : 0 : continue;
736 : : }
737 : :
738 [ # # ]: 0 : ref_entity_ptr = CAST_TO( topo_ptr, RefEntity );
739 [ # # ]: 0 : hit_entity_list_ptr->append( ref_entity_ptr );
740 : : }
741 : : }
742 : :
743 : : // Now, make sure we don't have more hits than asked for
744 [ # # ]: 0 : if( hits_limited == CUBIT_TRUE )
745 : : {
746 [ # # ][ # # ]: 0 : if( ray_params.size() <= max_hits )
747 : 0 : return CUBIT_SUCCESS;
748 : :
749 [ # # ][ # # ]: 0 : for( i=ray_params.size()-max_hits; i--; )
750 : : {
751 [ # # ]: 0 : ray_params.last();
752 [ # # ]: 0 : ray_params.remove();
753 [ # # ]: 0 : if( hit_entity_list_ptr )
754 : : {
755 [ # # ]: 0 : hit_entity_list_ptr->last();
756 [ # # ]: 0 : hit_entity_list_ptr->remove();
757 : : }
758 : : }
759 : : }
760 : :
761 [ # # ]: 0 : return CUBIT_SUCCESS;
762 : : }
763 : :
764 : : //-------------------------------------------------------------------------
765 : : // Purpose : Fire a ray at a list of entities and return the
766 : : // parameters along the ray (distance from origin of ray)
767 : : // where it hits the entities; optionally find the
768 : : // corresponding entities it hit.
769 : : //
770 : : // Special Notes : All entities must be from the same geometry engine.
771 : : //
772 : : // Creator : Steve Storm
773 : : //
774 : : // Creation Date : 5/19/2007
775 : : //-------------------------------------------------------------------------
776 : 0 : CubitStatus GeometryQueryTool::fire_ray( CubitVector &origin,
777 : : CubitVector &direction,
778 : : DLIList<TopologyEntity*> &at_entity_list,
779 : : DLIList<double> &ray_params,
780 : : int max_hits,
781 : : double ray_radius,
782 : : DLIList<TopologyEntity*> *hit_entity_list_ptr )
783 : : {
784 [ # # ][ # # ]: 0 : if( !at_entity_list.size() )
785 : 0 : return CUBIT_SUCCESS;
786 : :
787 : :
788 [ # # ]: 0 : TopologyEntity *topo_ptr = at_entity_list.get();
789 : :
790 [ # # ]: 0 : GeometryQueryEngine *gqe = topo_ptr->get_geometry_query_engine();
791 [ # # ]: 0 : if( !gqe )
792 : : {
793 [ # # ][ # # ]: 0 : PRINT_ERROR( "Unable to find geometry engine associated with an entity!\n" );
[ # # ][ # # ]
794 : 0 : return CUBIT_FAILURE;
795 : : }
796 : :
797 : :
798 [ # # ]: 0 : DLIList<TopologyBridge*> tb_list;
799 : : int i;
800 [ # # ]: 0 : at_entity_list.reset();
801 [ # # ][ # # ]: 0 : for( i=at_entity_list.size(); i--; )
802 : : {
803 [ # # ]: 0 : topo_ptr = at_entity_list.get_and_step();
804 [ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
805 [ # # ][ # # ]: 0 : topo_ptr->bridge_manager()->get_bridge_list( bridge_list );
806 [ # # ]: 0 : bridge_list.reset();
807 [ # # ][ # # ]: 0 : tb_list.append( bridge_list.get() );
808 [ # # ]: 0 : }
809 : :
810 : : // Setup temporary variables to pass
811 [ # # ][ # # ]: 0 : DLIList<double> tmp_ray_params;
812 : :
813 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> tb_hit_list;
814 : 0 : DLIList<TopologyBridge*> *tb_hit_list_ptr = NULL;
815 [ # # ]: 0 : if( hit_entity_list_ptr )
816 : 0 : tb_hit_list_ptr = &tb_hit_list;
817 : :
818 : : // Do the ray fire. Note we will sort the hits by distance and append to the output lists.
819 [ # # ]: 0 : if( gqe->fire_ray( origin, direction, tb_list, tmp_ray_params,
820 [ # # ]: 0 : max_hits, ray_radius, tb_hit_list_ptr ) == CUBIT_FAILURE )
821 : 0 : return CUBIT_FAILURE;
822 : :
823 [ # # ]: 0 : tmp_ray_params.reset();
824 [ # # ][ # # ]: 0 : if( tb_hit_list_ptr) tb_hit_list_ptr->reset();
825 : :
826 : : // Append to output lists
827 [ # # ]: 0 : ray_params += tmp_ray_params;
828 : :
829 : : // Get the TE's from the TopologyBridges
830 [ # # ]: 0 : if( hit_entity_list_ptr )
831 : : {
832 : : // First need to make sure that the entities hit are visible...entities hit
833 : : // may be hidden under virtual entities....we need to get the visible
834 : : // entities.
835 [ # # ]: 0 : DLIList<TopologyBridge*> vis_tb_hit_list;
836 [ # # ][ # # ]: 0 : DLIList<CubitVector*> cv_list;
837 : :
838 : : CubitVector *loc_ptr;
839 : : double param;
840 [ # # ]: 0 : tmp_ray_params.reset();
841 [ # # ][ # # ]: 0 : for( i=tmp_ray_params.size(); i--; )
842 : : {
843 [ # # ]: 0 : param = tmp_ray_params.get_and_step();
844 : :
845 [ # # ][ # # ]: 0 : loc_ptr = new CubitVector;
846 [ # # ]: 0 : origin.next_point( direction, param, *loc_ptr );
847 [ # # ]: 0 : cv_list.append( loc_ptr );
848 : : }
849 : :
850 : :
851 : : TopologyBridge *bridge_ptr;
852 [ # # ][ # # ]: 0 : for( i=0; i<tb_hit_list_ptr->size(); i++ )
853 : : {
854 [ # # ]: 0 : bridge_ptr = tb_hit_list_ptr->get_and_step();
855 : :
856 : 0 : TopologyBridge *visible_tb = NULL;
857 [ # # ]: 0 : TBOwner* o2 = bridge_ptr->owner();
858 : :
859 : 0 : bool broke_early = false;
860 : : BridgeManager* bridge_manager2;
861 [ # # ][ # # ]: 0 : while (!(bridge_manager2 = dynamic_cast<BridgeManager*>(o2)))
862 : : {
863 [ # # ][ # # ]: 0 : if (TopologyBridge* bridge2 = dynamic_cast<TopologyBridge*>(o2))
864 : : {
865 [ # # ]: 0 : GeometryQueryEngine* gqe2 = bridge2->get_geometry_query_engine();
866 : :
867 : : //Let the VQE handle the work
868 [ # # ][ # # ]: 0 : visible_tb = gqe2->get_visible_entity_at_point(bridge_ptr, cv_list[i]);
869 [ # # ]: 0 : if (visible_tb)
870 [ # # ]: 0 : o2 = visible_tb->owner();
871 : : else
872 [ # # ]: 0 : o2 = bridge2->owner();
873 : : }
874 : :
875 [ # # ][ # # ]: 0 : else if(TBOwnerSet* set = dynamic_cast<TBOwnerSet*>(o2))
876 : : {
877 [ # # ]: 0 : DLIList<TopologyBridge*> list2;
878 [ # # ]: 0 : set->get_owners(list2);
879 [ # # ]: 0 : list2.reset();
880 : :
881 : : // This had better be the Virtual QE.
882 [ # # ][ # # ]: 0 : GeometryQueryEngine* gqe2 = list2.get()->get_geometry_query_engine();
883 : :
884 : : //Let the VQE handle the work
885 [ # # ][ # # ]: 0 : visible_tb = gqe2->get_visible_entity_at_point(bridge_ptr, cv_list[i]);
886 [ # # ]: 0 : if (visible_tb)
887 [ # # ]: 0 : o2 = visible_tb->owner();
888 : : else
889 : : {
890 : 0 : broke_early = true;
891 [ # # ][ # # ]: 0 : break;
892 : 0 : }
893 : : }
894 : : else
895 : : {
896 : 0 : broke_early = true;
897 : 0 : break;
898 : : }
899 : : }
900 : :
901 [ # # ]: 0 : if (!broke_early)
902 [ # # ]: 0 : visible_tb = bridge_manager2->topology_bridge();
903 : :
904 : :
905 [ # # ]: 0 : if( visible_tb )
906 : : {
907 [ # # ]: 0 : topo_ptr = visible_tb->topology_entity();
908 [ # # ]: 0 : hit_entity_list_ptr->append( topo_ptr );
909 : : }
910 : : else
911 [ # # ]: 0 : hit_entity_list_ptr->append( 0 );
912 : : }
913 : :
914 : :
915 : : // Free memory
916 [ # # ][ # # ]: 0 : while( cv_list.size() ) delete cv_list.pop();
[ # # ][ # # ]
917 : : }
918 : :
919 : : // Sort ray_params (low to high) and sort hit_entity_list_ptr to match
920 : : // This will ensure entities are in order of who got hit first
921 : : // Do the sort by adding to a map (should auto-sort)
922 [ # # ][ # # ]: 0 : std::map<double, TopologyEntity*> temp_map;
923 [ # # ][ # # ]: 0 : for (i=0; i<ray_params.size(); i++)
924 : : temp_map.insert(std::map<double,
925 [ # # ]: 0 : TopologyEntity*>::value_type( ray_params.get_and_step(),
926 [ # # ][ # # ]: 0 : hit_entity_list_ptr ? hit_entity_list_ptr->get_and_step() : 0 ) );
[ # # ][ # # ]
927 : :
928 : : // The map should be sorted, so iterate through it and add to the official lists
929 [ # # ]: 0 : ray_params.clean_out();
930 [ # # ][ # # ]: 0 : if( hit_entity_list_ptr) hit_entity_list_ptr->clean_out();
931 : :
932 [ # # ]: 0 : std::map<double, TopologyEntity*>::iterator iter;
933 [ # # ][ # # ]: 0 : for (iter=temp_map.begin(); iter != temp_map.end(); iter++)
[ # # ][ # # ]
[ # # ]
934 : : {
935 [ # # ][ # # ]: 0 : ray_params.append(iter->first);
936 [ # # ][ # # ]: 0 : if( hit_entity_list_ptr) hit_entity_list_ptr->append(iter->second);
[ # # ]
937 : : }
938 : :
939 [ # # ]: 0 : return CUBIT_SUCCESS;
940 : : }
941 : :
942 : : //-------------------------------------------------------------------------
943 : : // Purpose : Reads in geometry and creates the necessary Reference
944 : : // entities associated with the input geometry. Has ability
945 : : // to read selectively read in either bodies, free surfaces,
946 : : // free curves or free vertices from the file.
947 : : //
948 : : // Valid file types are:
949 : : //
950 : : // "IGES" -- IGES file
951 : : // "STEP" -- STEP file
952 : : // "KCM" -- KCM file
953 : : //
954 : : // Special Notes :
955 : : //
956 : : // Creator : Steve Storm
957 : : //
958 : : // Creation Date : 03/17/99
959 : : //-------------------------------------------------------------------------
960 : 938 : CubitStatus GeometryQueryTool::import_solid_model( const char* file_name,
961 : : Model_File_Type file_type,
962 : : ModelImportOptions &import_options,
963 : : DLIList<RefEntity*> *imported_entities )
964 : : {
965 [ + - ][ - + ]: 938 : if (0 == gqeList.size())
966 : : {
967 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.\n");
[ # # ][ # # ]
968 : 0 : return CUBIT_FAILURE;
969 : : }
970 : :
971 : 938 : importingSolidModel = CUBIT_TRUE;
972 [ + - ]: 938 : uidsOfImportingEnts.clean_out();
973 : 938 : mergeGloballyOnImport = import_options.merge_globally;
974 : :
975 [ + - ]: 938 : if( clearUidMapBeforeImport )
976 [ + - ]: 938 : CAUniqueId::clear_out_old_to_new_map();
977 : :
978 [ - + ]: 938 : if( GSaveOpen::performingUndo )
979 : 0 : mergeGloballyOnImport = CUBIT_TRUE;
980 : :
981 [ + - ][ - + ]: 938 : if( CubitUndo::get_undo_enabled() )
982 [ # # ]: 0 : CubitUndo::save_state();
983 : :
984 : : // reset the attribImporteds flags to facilitate attribute reporting
985 : : // CubitAttrib::clear_attrib_importeds();
986 : :
987 : : // Use the default MQE to import a list of ToplogyBridges from the file.
988 [ + - ]: 938 : gqeList.reset();
989 [ + - ]: 938 : DLIList<TopologyBridge*> bridge_list;
990 : :
991 : 938 : import_options.print_results = CUBIT_TRUE;
992 : :
993 : : // We will turn off the printing of name change warnings during import and just
994 : : // keep track of how many happened.
995 [ + - ][ + - ]: 938 : bool prev_print_warning_flag = RefEntityName::instance()->print_name_change_warnings();
996 [ + - ][ + - ]: 938 : RefEntityName::instance()->print_name_change_warnings(false);
997 [ + - ][ + - ]: 938 : RefEntityName::instance()->num_name_change_warnings(0);
998 : :
999 [ + - ]: 938 : CubitStatus status = gqeList.get()->import_solid_model( file_name,
1000 [ + - ]: 938 : file_type, bridge_list, import_options );
1001 : :
1002 [ + - ][ - + ]: 938 : if( bridge_list.size() == 0 )
1003 : : {
1004 : 0 : importingSolidModel = CUBIT_FALSE;
1005 : 0 : mergeGloballyOnImport = CUBIT_FALSE;
1006 : 0 : return status;
1007 : : }
1008 : :
1009 [ + - ][ + - ]: 2814 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ + - ][ + - ]
[ + + ]
1010 [ + - ][ + - ]: 1876 : (*itor)->import_geometry(bridge_list);
1011 : :
1012 [ + - ]: 938 : bridge_list.reset();
1013 [ + - ][ + - ]: 1876 : DLIList<RefEntity*> tmp_ent_list;
1014 [ + - ]: 938 : status = construct_refentities(bridge_list, &tmp_ent_list);
1015 : :
1016 : : // Print out a summary warning message if names were changed.
1017 [ + - ][ + - ]: 938 : RefEntityName::instance()->print_name_change_warnings(prev_print_warning_flag);
1018 [ + - ][ + - ]: 938 : if(RefEntityName::instance()->num_name_change_warnings() > 0)
[ + + ]
1019 : : {
1020 [ + - ][ + - ]: 44 : PRINT_WARNING("%d invalid names were found during import.\n\n",
[ + - ][ + - ]
[ + - ]
1021 [ + - ]: 22 : RefEntityName::instance()->num_name_change_warnings());
1022 : : }
1023 : :
1024 [ + + ]: 938 : if( imported_entities )
1025 [ + - ]: 33 : (*imported_entities) += tmp_ent_list;
1026 : :
1027 [ + - ][ - + ]: 938 : if( CubitUndo::get_undo_enabled() )
1028 : : {
1029 [ # # ][ # # ]: 0 : if( tmp_ent_list.size() && status == CUBIT_SUCCESS )
[ # # ][ # # ]
1030 [ # # ]: 0 : CubitUndo::note_result_entities( tmp_ent_list );
1031 : : else
1032 [ # # ]: 0 : CubitUndo::remove_last_undo();
1033 : : }
1034 : :
1035 : : //clear out all attributes that were set to actuate
1036 [ + - ][ + - ]: 1876 : DLIList<RefEntity*> all_ents;
1037 [ + - ]: 938 : RefEntity::get_all_child_ref_entities( tmp_ent_list, all_ents );
1038 [ + - ]: 938 : all_ents += tmp_ent_list;
1039 [ + - ]: 938 : CubitAttribUser::clear_all_simple_attrib_set_to_actuate( all_ents );
1040 : :
1041 : : // report attribs imported
1042 : : // CubitAttrib::report_attrib_importeds();
1043 : :
1044 : 938 : importingSolidModel = CUBIT_FALSE;
1045 : 938 : mergeGloballyOnImport = CUBIT_FALSE;
1046 : : // now return
1047 [ + - ]: 938 : return status;
1048 : : }
1049 : :
1050 : : // import entities to buffer
1051 : 0 : CubitStatus GeometryQueryTool::import_solid_model(DLIList<RefEntity*> *imported_entities,
1052 : : const char* pBuffer,
1053 : : const int n_buffer_size)
1054 : : {
1055 [ # # ][ # # ]: 0 : if (0 == gqeList.size())
1056 : : {
1057 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.\n");
[ # # ][ # # ]
1058 : 0 : return CUBIT_FAILURE;
1059 : : }
1060 : :
1061 [ # # ][ # # ]: 0 : if( CubitUndo::get_undo_enabled() )
1062 [ # # ]: 0 : CubitUndo::save_state();
1063 : :
1064 : : // reset the attribImporteds flags to facilitate attribute reporting
1065 : : // CubitAttrib::clear_attrib_importeds();
1066 : :
1067 : : // Use the default MQE to import a list of ToplogyBridges from the file.
1068 [ # # ]: 0 : gqeList.reset();
1069 [ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
1070 : :
1071 : 0 : CubitStatus status = CUBIT_SUCCESS;
1072 [ # # ][ # # ]: 0 : for(int i = 0; i < gqeList.size(); i++)
1073 : : {
1074 [ # # ][ # # ]: 0 : status = gqeList.get_and_step()->import_solid_model( bridge_list, pBuffer, n_buffer_size );
1075 : :
1076 [ # # ][ # # ]: 0 : if( bridge_list.size() > 0 )
1077 : 0 : break;
1078 : : }
1079 [ # # ][ # # ]: 0 : if(bridge_list.size() == 0)
1080 : 0 : return status;
1081 : :
1082 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
1083 [ # # ][ # # ]: 0 : (*itor)->import_geometry(bridge_list);
1084 : :
1085 [ # # ]: 0 : bridge_list.reset();
1086 [ # # ][ # # ]: 0 : DLIList<RefEntity*> tmp_ent_list;
1087 [ # # ]: 0 : status = construct_refentities(bridge_list, &tmp_ent_list);
1088 : :
1089 [ # # ]: 0 : if( imported_entities )
1090 [ # # ]: 0 : (*imported_entities) += tmp_ent_list;
1091 : :
1092 [ # # ][ # # ]: 0 : if( CubitUndo::get_undo_enabled() )
1093 : : {
1094 [ # # ][ # # ]: 0 : if( tmp_ent_list.size() && status == CUBIT_SUCCESS )
[ # # ][ # # ]
1095 [ # # ]: 0 : CubitUndo::note_result_entities( tmp_ent_list );
1096 : : else
1097 [ # # ]: 0 : CubitUndo::remove_last_undo();
1098 : : }
1099 : :
1100 : : //clear out all attributes that were set to actuate
1101 : : // DLIList<RefEntity*> all_ents;
1102 : : // RefEntity::get_all_child_ref_entities( tmp_ent_list, all_ents );
1103 : : // all_ents += tmp_ent_list;
1104 : : // CubitAttribUser::clear_all_simple_attrib_set_to_actuate( all_ents );
1105 : :
1106 : : // report attribs imported
1107 : : // CubitAttrib::report_attrib_importeds();
1108 : :
1109 : :
1110 : : // now return
1111 [ # # ]: 0 : return status;
1112 : : }
1113 : :
1114 : 938 : CubitStatus GeometryQueryTool::construct_refentities(DLIList<TopologyBridge*> &bridge_list,
1115 : : DLIList<RefEntity*> *imported_entities)
1116 : : {
1117 : :
1118 : : // Construct VGI Topology from the TopologyBridges.
1119 [ + - ]: 938 : DLIList<Body*> body_list;
1120 [ + - ][ + - ]: 1876 : DLIList<RefFace*> face_list;
1121 [ + - ][ + - ]: 1876 : DLIList<RefEdge*> edge_list;
1122 [ + - ][ + - ]: 1876 : DLIList<RefVertex*> vtx_list;
1123 : : // We are going to pop entities from bridge_list,
1124 : : // so reverse the list so that the entities get
1125 : : // created in the old order and the IDs remain
1126 : : // the same.
1127 [ + - ]: 938 : bridge_list.reverse();
1128 [ + - ]: 938 : bridge_list.reset();
1129 : 938 : CubitStatus status = CUBIT_SUCCESS;
1130 : :
1131 [ + - ]: 938 : bool do_progress = bridge_list.size() > 2 ? true : false;
1132 : :
1133 [ + + ]: 938 : if(do_progress)
1134 : : {
1135 : : char message[128];
1136 [ + - ]: 106 : sprintf(message, "Building %d CUBIT Entities", bridge_list.size() );
1137 [ + - ][ + - ]: 106 : AppUtil::instance()->progress_tool()->start(0, bridge_list.size(), "Progress",
1138 [ + - ][ + - ]: 106 : message, TRUE, TRUE);
1139 : : }
1140 : :
1141 : :
1142 [ + - ][ + + ]: 2750 : while( bridge_list.size() && !AppUtil::instance()->interrupt() )
[ + - ][ + - ]
[ + - ][ + + ]
1143 : : {
1144 : : BodySM* bodysm_ptr;
1145 : : Surface* surface_ptr;
1146 : : Curve* curve_ptr;
1147 : : TBPoint* point_ptr;
1148 [ + - ]: 1812 : TopologyBridge* bridge_ptr = bridge_list.pop();
1149 [ - + ][ + + ]: 1812 : if( (bodysm_ptr = dynamic_cast<BodySM*>(bridge_ptr) ) != NULL )
1150 : : {
1151 [ + - ]: 1614 : Body* body_ptr = make_Body( bodysm_ptr );
1152 [ + - ]: 1614 : if( body_ptr )
1153 : : {
1154 [ + - ]: 1614 : body_list.append( body_ptr );
1155 : : }
1156 : : else
1157 : : {
1158 [ # # ][ # # ]: 0 : PRINT_ERROR("\nError constructing VGI Body.\n");
[ # # ][ # # ]
1159 : 1614 : status = CUBIT_FAILURE;
1160 : : }
1161 : : }
1162 [ - + ][ - + ]: 198 : else if( (surface_ptr = dynamic_cast<Surface*>(bridge_ptr) ) != NULL )
1163 : : {
1164 : 0 : bool is_free_face = true;
1165 [ # # ]: 0 : RefFace* face_ptr = make_free_RefFace( surface_ptr, is_free_face );
1166 [ # # ]: 0 : if( face_ptr )
1167 : : {
1168 [ # # ]: 0 : face_list.append( face_ptr );
1169 : : }
1170 : : else
1171 : : {
1172 [ # # ][ # # ]: 0 : PRINT_ERROR("\nError constructing free VGI Surface.\n");
[ # # ][ # # ]
1173 : 0 : status = CUBIT_FAILURE;
1174 : : }
1175 : : }
1176 [ - + ][ + - ]: 198 : else if( (curve_ptr = dynamic_cast<Curve*>(bridge_ptr) ) != NULL )
1177 : : {
1178 [ + - ]: 198 : RefEdge* edge_ptr = make_free_RefEdge( curve_ptr );
1179 [ + - ]: 198 : if( edge_ptr )
1180 : : {
1181 [ + - ]: 198 : edge_list.append( edge_ptr );
1182 : : }
1183 : : else
1184 : : {
1185 [ # # ][ # # ]: 0 : PRINT_ERROR("\nError constructing free VGI Curve.\n");
[ # # ][ # # ]
1186 : 198 : status = CUBIT_FAILURE;
1187 : : }
1188 : : }
1189 [ # # ][ # # ]: 0 : else if( (point_ptr = dynamic_cast<TBPoint*>(bridge_ptr) ) != NULL )
1190 : : {
1191 [ # # ]: 0 : RefVertex* vtx_ptr = make_free_RefVertex( point_ptr );
1192 [ # # ]: 0 : if( vtx_ptr )
1193 : : {
1194 [ # # ]: 0 : vtx_list.append( vtx_ptr );
1195 : : }
1196 : : else
1197 : : {
1198 [ # # ][ # # ]: 0 : PRINT_ERROR("\nError constructing free VGI Vertex.\n");
[ # # ][ # # ]
1199 : 0 : status = CUBIT_FAILURE;
1200 : : }
1201 : : }
1202 : : else
1203 : : {
1204 [ # # ][ # # ]: 0 : PRINT_ERROR("Unknown entity type imported by solid modeler. Ignored.\n");
[ # # ][ # # ]
1205 : 0 : status = CUBIT_FAILURE;
1206 : : }
1207 [ + + ]: 1812 : if(do_progress)
1208 [ + - ][ + - ]: 830 : AppUtil::instance()->progress_tool()->step();
[ + - ]
1209 : : }
1210 : :
1211 [ + + ]: 938 : if(do_progress)
1212 [ + - ][ + - ]: 106 : AppUtil::instance()->progress_tool()->end();
[ + - ]
1213 : :
1214 [ + - ][ + - ]: 938 : PRINT_INFO("\n");
[ + - ][ + - ]
1215 : :
1216 : : // If the above loop was interrupted, bridge_list will not be
1217 : : // empty. Free any bridges we did not make topology for.
1218 [ + - ][ + - ]: 938 : if( AppUtil::instance()->interrupt() )
[ - + ]
1219 : : {
1220 [ # # ][ # # ]: 0 : PRINT_WARNING("Aborted construction of %d entities.\n", bridge_list.size());
[ # # ][ # # ]
[ # # ]
1221 : : }
1222 [ + - ][ - + ]: 938 : while( bridge_list.size() )
1223 : : {
1224 [ # # ]: 0 : TopologyBridge* bridge_ptr = bridge_list.pop();
1225 [ # # ]: 0 : GeometryQueryEngine* gqe = bridge_ptr->get_geometry_query_engine();
1226 : : BodySM* body_ptr;
1227 : : Surface* surface_ptr;
1228 : : Curve* curve_ptr;
1229 : : TBPoint* point_ptr;
1230 [ # # ][ # # ]: 0 : if( (body_ptr = dynamic_cast<BodySM*>(bridge_ptr) ) != NULL )
1231 [ # # ]: 0 : gqe->delete_solid_model_entities( body_ptr );
1232 [ # # ][ # # ]: 0 : else if( (surface_ptr = dynamic_cast<Surface*>(bridge_ptr) ) != NULL )
1233 [ # # ]: 0 : gqe->delete_solid_model_entities( surface_ptr );
1234 [ # # ][ # # ]: 0 : else if( (curve_ptr = dynamic_cast<Curve*>(bridge_ptr) ) != NULL )
1235 [ # # ]: 0 : gqe->delete_solid_model_entities( curve_ptr );
1236 [ # # ][ # # ]: 0 : else if( (point_ptr = dynamic_cast<TBPoint*>(bridge_ptr) ) != NULL )
1237 [ # # ]: 0 : gqe->delete_solid_model_entities( point_ptr );
1238 : : }
1239 : :
1240 : : /*
1241 : : // If any geometry was pre-merged during the
1242 : : // RefEntity construction, adjust the sense of
1243 : : // the entities to match what it was originally.
1244 : : DLIList<BasicTopologyEntity*> bte_list;
1245 : : DLIList<RefFace*> child_face_list;
1246 : : DLIList<RefEdge*> child_edge_list;
1247 : : for( int b = body_list.size(); b--; )
1248 : : {
1249 : : body_list.get()->ref_faces( child_face_list );
1250 : : CAST_LIST_TO_PARENT( child_face_list, bte_list );
1251 : : adjust_merge_sense( bte_list );
1252 : : body_list.get()->ref_edges( child_edge_list );
1253 : : CAST_LIST_TO_PARENT( child_edge_list, bte_list );
1254 : : adjust_merge_sense( bte_list );
1255 : : body_list.step();
1256 : : }
1257 : : CAST_LIST_TO_PARENT( face_list, bte_list );
1258 : : adjust_merge_sense( bte_list );
1259 : : for( int f = face_list.size(); f--; )
1260 : : {
1261 : : face_list.get_and_step()->ref_edges( child_edge_list );
1262 : : CAST_LIST_TO_PARENT( child_edge_list, bte_list );
1263 : : adjust_merge_sense( bte_list );
1264 : : }
1265 : : CAST_LIST_TO_PARENT( edge_list, bte_list );
1266 : : adjust_merge_sense( bte_list );
1267 : : */
1268 : :
1269 : : // Actuate Attributes
1270 [ + - ][ + - ]: 1876 : DLIList<RefEntity*> ref_entity_list, temp_ref_list;
[ + - ][ + - ]
1271 : :
1272 [ + - ][ + - ]: 2552 : CAST_LIST_TO_PARENT( body_list, temp_ref_list );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ]
1273 [ + - ]: 938 : ref_entity_list += temp_ref_list;
1274 [ + - ][ + - ]: 938 : CAST_LIST_TO_PARENT( face_list, temp_ref_list );
[ + - ][ + - ]
[ + - ][ # # ]
[ # # ][ # # ]
[ - + ]
1275 [ + - ]: 938 : ref_entity_list += temp_ref_list;
1276 [ + - ][ + - ]: 1136 : CAST_LIST_TO_PARENT( edge_list, temp_ref_list );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ]
1277 [ + - ]: 938 : ref_entity_list += temp_ref_list;
1278 [ + - ][ + - ]: 938 : CAST_LIST_TO_PARENT( vtx_list, temp_ref_list );
[ + - ][ + - ]
[ + - ][ # # ]
[ # # ][ # # ]
[ - + ]
1279 [ + - ]: 938 : ref_entity_list += temp_ref_list;
1280 : :
1281 [ + - ]: 938 : import_actuate( ref_entity_list );
1282 : :
1283 : : // Pass back imported entities
1284 [ + - ]: 938 : if( imported_entities )
1285 : : {
1286 [ + - ]: 938 : *imported_entities = ref_entity_list;
1287 : : }
1288 : :
1289 : : char pre[100];
1290 [ + - ][ + + ]: 938 : if( body_list.size() )
1291 : : {
1292 [ + - ]: 927 : DLIList<RefVolume*> temp_vols;
1293 [ + - ][ + + ]: 2541 : for( int nv = body_list.size(); nv > 0; nv-- )
1294 : : {
1295 [ + - ]: 1614 : DLIList<RefVolume*> t2;
1296 [ + - ][ + - ]: 1614 : body_list.get_and_step()->ref_volumes( t2 );
1297 [ + - ]: 1614 : temp_vols += t2;
1298 [ + - ]: 1614 : }
1299 : :
1300 [ + - ][ + - ]: 1854 : DLIList<CubitEntity*> temp_list;
1301 [ + - ][ + - ]: 927 : if( DEBUG_FLAG( 153 ) )
[ - + ]
1302 : : {
1303 [ # # ][ # # ]: 0 : CAST_LIST_TO_PARENT(body_list, temp_list);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1304 [ # # ][ # # ]: 0 : if( temp_list.size() == 1 )
1305 [ # # ]: 0 : CubitUtil::list_entity_ids( "Constructed 1 Body: ", temp_list);
1306 : : else
1307 : : {
1308 [ # # ]: 0 : sprintf( pre, "Constructed %d Bodies: ", temp_list.size() );
1309 [ # # ]: 0 : CubitUtil::list_entity_ids( pre, temp_list );
1310 : : }
1311 : : }
1312 : :
1313 [ + - ]: 927 : temp_list.clean_out();
1314 [ + - ][ + - ]: 2552 : CAST_LIST_TO_PARENT( temp_vols, temp_list );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ]
1315 [ + - ][ + + ]: 927 : if( temp_list.size() == 1 )
1316 [ + - ]: 671 : CubitUtil::list_entity_ids( "Constructed 1 Volume: ", temp_list);
1317 : : else
1318 : : {
1319 [ + - ]: 256 : sprintf( pre, "Constructed %d Volumes: ", temp_list.size() );
1320 [ + - ]: 256 : CubitUtil::list_entity_ids( pre, temp_list );
1321 [ + - ]: 927 : }
1322 : : }
1323 [ + - ][ - + ]: 938 : if( face_list.size() )
1324 : : {
1325 [ # # ]: 0 : DLIList<CubitEntity*> temp_list;
1326 [ # # ][ # # ]: 0 : CAST_LIST_TO_PARENT(face_list, temp_list);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1327 [ # # ][ # # ]: 0 : if( temp_list.size() == 1 )
1328 [ # # ]: 0 : CubitUtil::list_entity_ids( "Constructed 1 Free Surface: ", temp_list );
1329 : : else
1330 : : {
1331 [ # # ]: 0 : sprintf( pre, "Constructed %d Free Surfaces: ", temp_list.size() );
1332 [ # # ]: 0 : CubitUtil::list_entity_ids( pre, temp_list );
1333 [ # # ]: 0 : }
1334 : : }
1335 [ + - ][ + + ]: 938 : if( edge_list.size() )
1336 : : {
1337 [ + - ]: 11 : DLIList<CubitEntity*> temp_list;
1338 [ + - ][ + - ]: 209 : CAST_LIST_TO_PARENT(edge_list, temp_list);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ]
1339 [ + - ][ - + ]: 11 : if( temp_list.size() == 1 )
1340 [ # # ]: 0 : CubitUtil::list_entity_ids( "Constructed 1 Free Curve: ", temp_list );
1341 : : else
1342 : : {
1343 [ + - ]: 11 : sprintf( pre, "Constructed %d Free Curves: ", temp_list.size() );
1344 [ + - ]: 11 : CubitUtil::list_entity_ids( pre, temp_list );
1345 [ + - ]: 11 : }
1346 : : }
1347 [ + - ][ - + ]: 938 : if( vtx_list.size() )
1348 : : {
1349 [ # # ]: 0 : DLIList<CubitEntity*> temp_list;
1350 [ # # ][ # # ]: 0 : CAST_LIST_TO_PARENT(vtx_list, temp_list);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1351 [ # # ][ # # ]: 0 : if( temp_list.size() == 1 )
1352 [ # # ]: 0 : CubitUtil::list_entity_ids( "Constructed 1 Free Vertex: ", temp_list );
1353 : : else
1354 : : {
1355 [ # # ]: 0 : sprintf( pre, "Constructed %d Free Vertices: ", temp_list.size() );
1356 [ # # ]: 0 : CubitUtil::list_entity_ids( pre, temp_list );
1357 [ # # ]: 0 : }
1358 : : }
1359 : :
1360 [ + - ]: 938 : return status;
1361 : : }
1362 : :
1363 : : //-------------------------------------------------------------------------
1364 : : // Purpose : Build/update Body topology
1365 : : //
1366 : : // Special Notes :
1367 : : //
1368 : : // Creator : Jason Kraftcheck
1369 : : //
1370 : : // Creation Date : 08/21/02
1371 : : //-------------------------------------------------------------------------
1372 : 3089 : Body* GeometryQueryTool::make_Body(BodySM *bodysm_ptr) const
1373 : : {
1374 : : int i;
1375 [ + - ]: 3089 : CpuTimer timer;
1376 : 3089 : bool body_created = false;
1377 : 3089 : bool body_modified = false;
1378 : 3089 : bool vol_modified = false, tmp_vol_modified;
1379 : :
1380 [ + - ][ + + ]: 3089 : Body* body = CAST_TO( bodysm_ptr->topology_entity(), Body );
1381 [ + + ]: 3089 : if( ! body )
1382 : : {
1383 [ + - ][ + - ]: 2716 : body = RefEntityFactory::instance()->construct_Body(bodysm_ptr);
1384 : 2716 : body_created = true;
1385 : : }
1386 [ - + ]: 3089 : if( ! body )
1387 : : {
1388 [ # # ][ # # ]: 0 : PRINT_ERROR("Body creation failed in GeometryQueryTool::make_Body\n");
[ # # ][ # # ]
1389 [ # # ]: 0 : assert( !!body );
1390 : 0 : return 0;
1391 : : }
1392 : :
1393 [ + - ]: 3089 : DLIList<Lump*> lumps;
1394 [ + - ]: 3089 : bodysm_ptr->lumps( lumps );
1395 : :
1396 [ + - ][ + - ]: 6178 : DLIList<SenseEntity*> dead_covols, new_covols(lumps.size());
[ + - ][ + - ]
[ + - ]
1397 [ + - ]: 3089 : lumps.reset();
1398 [ + - ][ + + ]: 6406 : for( i = lumps.size(); i--; )
1399 : : {
1400 [ + - ][ + - ]: 3317 : RefVolume* vol = make_RefVolume( lumps.get_and_step(), tmp_vol_modified );
1401 [ - + ]: 3317 : if( !vol )
1402 : : {
1403 [ # # ][ # # ]: 0 : PRINT_ERROR("RefVolume creation failed in GeometryQueryTool::make_Body\n");
[ # # ][ # # ]
1404 [ # # ][ # # ]: 0 : PRINT_ERROR("Aborting construction of Body %d\n", body->id() );
[ # # ][ # # ]
[ # # ]
1405 [ # # ]: 0 : assert( !!vol );
1406 : : }
1407 : :
1408 [ + + ]: 3317 : if (tmp_vol_modified)
1409 : 3031 : vol_modified = true;
1410 : :
1411 [ + - ]: 3317 : SenseEntity* covol = vol->find_sense_entity( body );
1412 [ + + ]: 3317 : if (!covol)
1413 : : {
1414 [ + - ][ + - ]: 2934 : covol = new CoVolume( vol );
1415 : 2934 : body_modified = true;
1416 : : }
1417 : :
1418 [ + - ]: 3317 : new_covols.append(covol);
1419 : : }
1420 : :
1421 [ + - ]: 3089 : body->set_sense_entity_list( new_covols, dead_covols );
1422 : :
1423 [ + - ][ - + ]: 3089 : while (dead_covols.size())
1424 : : {
1425 [ # # ][ # # ]: 0 : destroy_dead_entity(dead_covols.pop());
1426 : 0 : body_modified = true;
1427 : : }
1428 : :
1429 [ + - ][ + - ]: 3089 : PRINT_DEBUG_3("Constructed Body %d from BodySM in %f seconds.\n",
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1430 [ # # ]: 0 : body->id(), timer.cpu_secs() );
1431 : :
1432 [ + + ]: 3089 : if( body_created )
1433 : : {
1434 [ + - ][ + - ]: 2716 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::FREE_REF_ENTITY_GENERATED, body));
[ + - ][ + - ]
[ + - ]
1435 [ + - ][ + - ]: 2716 : CGMHistory::Event evt(CGMHistory::TOP_LEVEL_ENTITY_CREATED, body);
1436 [ + - ][ + - ]: 2716 : const_cast<CGMHistory&>(mHistory).add_event(evt);
1437 : : }
1438 [ - + ]: 373 : else if( body_modified )
1439 : : {
1440 [ # # ][ # # ]: 0 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_MODIFIED, body));
[ # # ][ # # ]
[ # # ]
1441 [ # # ][ # # ]: 0 : CGMHistory::Event evt(CGMHistory::TOPOLOGY_CHANGED, body);
1442 [ # # ][ # # ]: 0 : const_cast<CGMHistory&>(mHistory).add_event(evt);
1443 : : }
1444 [ + + ]: 373 : else if( vol_modified )
1445 : : {
1446 [ + - ][ + - ]: 185 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, body));
[ + - ][ + - ]
[ + - ]
1447 [ + - ][ + - ]: 185 : CGMHistory::Event evt(CGMHistory::GEOMETRY_CHANGED, body);
1448 [ + - ][ + - ]: 185 : const_cast<CGMHistory&>(mHistory).add_event(evt);
1449 : : }
1450 : :
1451 [ + - ][ + - ]: 3089 : PRINT_DEBUG_3("Updated graphics for Body %d in %f seconds.\n",
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1452 [ # # ]: 0 : body->id(), timer.cpu_secs() );
1453 : :
1454 [ + - ]: 3089 : return body;
1455 : : }
1456 : :
1457 : : //-------------------------------------------------------------------------
1458 : : // Purpose : Build/update RefVolume topology
1459 : : //
1460 : : // Special Notes :
1461 : : //
1462 : : // Creator : Jason Kraftcheck
1463 : : //
1464 : : // Creation Date : 08/21/02
1465 : : //-------------------------------------------------------------------------
1466 : 3317 : RefVolume* GeometryQueryTool::make_RefVolume( Lump* lump_ptr,
1467 : : bool& volume_modified ) const
1468 : : {
1469 : : int i;
1470 : :
1471 [ + - ]: 3317 : DLIList<ShellSM*> shellsms;
1472 [ + - ][ + - ]: 6634 : DLIList<GroupingEntity*> old_shells, new_shells;
[ + - ][ + - ]
1473 : :
1474 : 3317 : bool volume_created = false;
1475 : 3317 : volume_modified = false;
1476 [ + - ][ + + ]: 3317 : RefVolume* volume = CAST_TO( lump_ptr->topology_entity(), RefVolume );
1477 [ + + ]: 3317 : if( ! volume )
1478 : : {
1479 [ + - ][ + - ]: 2846 : volume = RefEntityFactory::instance()->construct_RefVolume(lump_ptr);
1480 : 2846 : volume_created = true;
1481 : : }
1482 [ - + ]: 3317 : if( ! volume )
1483 : : {
1484 [ # # ][ # # ]: 0 : PRINT_ERROR("Volume creation failed in GeometryQueryTool::make_RefVolume\n");
[ # # ][ # # ]
1485 [ # # ]: 0 : assert( !!volume );
1486 : 0 : return 0;
1487 : : }
1488 : :
1489 [ + - ]: 3317 : lump_ptr->shellsms( shellsms );
1490 [ + - ]: 3317 : shellsms.reset();
1491 [ + - ][ + + ]: 6694 : for( i = shellsms.size(); i--; )
1492 : : {
1493 : : bool shell_modified;
1494 : :
1495 : : // Don't use a shell if it is in a different RefVolume.
1496 : : // Can't move shells or other RefVolume may appear unmodified
1497 : : // in later call to make_RefVolume.
1498 : : // This breaks things -- live without it for now
1499 : : // ShellSM* shellsm = shellsms.get_and_step();
1500 : : // Shell* shell = dynamic_cast<Shell*>(shellsm->topology_entity());
1501 : : // if (shell && shell->get_basic_topology_entity_ptr() &&
1502 : : // shell->get_basic_topology_entity_ptr() != volume)
1503 : : // shell->bridge_manager()->remove_bridge(shellsm);
1504 : :
1505 : : // Build/update Shell
1506 [ + - ][ + - ]: 3377 : Shell* shell = make_Shell( shellsms.get_and_step(), shell_modified );
1507 : :
1508 [ - + ]: 3377 : if( !shell )
1509 : : {
1510 [ # # ][ # # ]: 0 : PRINT_ERROR("Shell creation failed in GeometryQueryTool::make_RefVolume\n");
[ # # ][ # # ]
1511 [ # # ][ # # ]: 0 : PRINT_ERROR("Aborting construction of Volume %d\n", volume->id() );
[ # # ][ # # ]
[ # # ]
1512 [ # # ]: 0 : assert( !!shell );
1513 : 0 : return 0;
1514 : : }
1515 [ + + ]: 3377 : if( shell_modified )
1516 : 3091 : volume_modified = true;
1517 : :
1518 : : // If the shell is new (not already part of RefVolume) then
1519 : : // we will be modifying the RefVolume when we add it later.
1520 [ + - ]: 3377 : BasicTopologyEntity* parent = shell->get_basic_topology_entity_ptr();
1521 [ + + ]: 3377 : if (parent != volume)
1522 : : {
1523 [ - + ]: 2906 : if (parent)
1524 [ # # ]: 0 : parent->remove_grouping_entity(shell);
1525 : 2906 : volume_modified = true;
1526 : : }
1527 : :
1528 [ + - ]: 3377 : new_shells.append( shell );
1529 : : }
1530 : :
1531 [ + - ]: 3317 : volume->set_grouping_entity_list( new_shells, old_shells );
1532 [ + - ][ - + ]: 3317 : while( old_shells.size() )
1533 : : {
1534 [ # # ]: 0 : GroupingEntity* shell = old_shells.pop();
1535 [ # # ]: 0 : destroy_dead_entity( shell );
1536 : 0 : volume_modified = true;
1537 : : }
1538 : :
1539 [ + - ][ - + ]: 3317 : if (volume->deactivated())
1540 : 0 : volume_modified = false;
1541 [ + + ][ + + ]: 3317 : else if(!volume_created && volume_modified )
1542 : : {
1543 : :
1544 : : #ifndef ALPHA_LAYTRACKS3D
1545 [ + - ][ + - ]: 185 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_MODIFIED, volume));
[ + - ][ + - ]
[ + - ]
1546 [ + - ][ + - ]: 185 : CGMHistory::Event evt(CGMHistory::TOPOLOGY_CHANGED, volume);
1547 [ + - ][ + - ]: 185 : const_cast<CGMHistory&>(mHistory).add_event(evt);
1548 : : #endif
1549 : : }
1550 : :
1551 [ + - ]: 6634 : return volume;
1552 : : }
1553 : :
1554 : : //-------------------------------------------------------------------------
1555 : : // Purpose : Build/update Shell topology
1556 : : //
1557 : : // Special Notes :
1558 : : //
1559 : : // Creator : Jason Kraftcheck
1560 : : //
1561 : : // Creation Date : 08/21/02
1562 : : //-------------------------------------------------------------------------
1563 : 3377 : Shell* GeometryQueryTool::make_Shell(ShellSM *shellsm_ptr, bool& shell_modified ) const
1564 : : {
1565 [ + - ][ + + ]: 3377 : Shell* shell = CAST_TO( shellsm_ptr->topology_entity(), Shell );
1566 : 3377 : shell_modified = false;
1567 [ + + ]: 3377 : if( !shell )
1568 [ + - ][ + - ]: 2906 : shell = new Shell(shellsm_ptr);
1569 [ - + ]: 3377 : assert( shell != NULL );
1570 : :
1571 [ + - ]: 3377 : DLIList<CoFace*> face_cofaces(2);
1572 : : //shell->co_faces( old_cofaces );
1573 [ + - ][ + - ]: 6754 : DLIList<SenseEntity*> new_cofaces, old_cofaces;
[ + - ][ + - ]
1574 : :
1575 [ + - ][ + - ]: 6754 : DLIList<Surface*> surfaces;
1576 [ + - ]: 3377 : shellsm_ptr->surfaces( surfaces );
1577 : :
1578 : : int i;
1579 [ + - ]: 3377 : surfaces.reset();
1580 [ + - ][ + + ]: 22261 : for( i = surfaces.size(); i--; )
1581 : : {
1582 [ + - ]: 18884 : Surface* surface = surfaces.get_and_step();
1583 [ + - ]: 18884 : RefFace* face = make_RefFace(surface);
1584 [ - + ]: 18884 : if( !face )
1585 : : {
1586 [ # # ][ # # ]: 0 : PRINT_ERROR("Surface creation failed in GeometryQueryTool::make_Shell\n");
[ # # ][ # # ]
1587 [ # # ]: 0 : assert( !!face );
1588 : 0 : return 0;
1589 : : }
1590 : :
1591 [ + - ]: 18884 : CubitSense sense = surface->get_shell_sense( shellsm_ptr );
1592 [ + - ][ + + ]: 18884 : if( surface->bridge_sense() == CUBIT_REVERSED )
1593 [ + - ]: 11 : sense = CubitUtil::opposite_sense( sense );
1594 : :
1595 : : // If sense is CUBIT_UNKNOWN, we have a two-sided
1596 : : // face and need to make two CoFaces.
1597 : 18884 : int num_cofaces = 1;
1598 [ + + ]: 18884 : if( sense == CUBIT_UNKNOWN )
1599 : : {
1600 [ + - ]: 674 : DLIList<ShellSM*> surf_shells(2);
1601 [ + - ]: 674 : surface->shellsms( surf_shells );
1602 [ + - ][ - + ]: 674 : assert( surf_shells.is_in_list(shellsm_ptr) );
1603 : 674 : num_cofaces = 2;
1604 [ + - ]: 674 : sense = CUBIT_FORWARD;
1605 : : }
1606 : :
1607 : : // If two CoFaces, loop once for each
1608 [ + - ]: 18884 : face_cofaces.clean_out();
1609 [ + - ]: 18884 : face->co_faces(face_cofaces);
1610 [ + + ]: 38442 : for( int k = 0; k < num_cofaces; k++ )
1611 : : {
1612 : :
1613 : 19558 : CoFace* coface = 0;
1614 [ + - ][ + + ]: 19706 : for( int j = face_cofaces.size(); j--; )
1615 : : {
1616 [ + - ]: 2431 : CoFace* tmp_coface = face_cofaces.get();
1617 [ + - ][ + + ]: 4714 : if( tmp_coface->get_sense() == sense &&
[ + - ][ + + ]
1618 [ + - ]: 2283 : tmp_coface->get_shell_ptr() == shell )
1619 : : {
1620 : 2283 : coface = tmp_coface;
1621 : 2283 : break;
1622 : : }
1623 : : }
1624 : :
1625 [ + + ]: 19558 : if (!coface)
1626 : : {
1627 [ + - ][ + - ]: 17275 : coface = new CoFace();
1628 [ + - ]: 17275 : coface->attach_basic_topology_entity( face );
1629 : 17275 : shell_modified = true;
1630 [ + - ][ + + ]: 17275 : if( coface->get_sense() != sense )
1631 [ + - ]: 8597 : coface->set_sense( sense );
1632 : : }
1633 : :
1634 [ + - ]: 19558 : new_cofaces.append(coface);
1635 : :
1636 : : // If we loop to create a second CoFace between
1637 : : // the same Surface-Shell pair, create it with
1638 : : // the opposite sense.
1639 [ + - ]: 19558 : sense = CubitUtil::opposite_sense(sense);
1640 : : }
1641 : : }
1642 : :
1643 [ + - ]: 3377 : shell->set_sense_entity_list( new_cofaces, old_cofaces );
1644 : :
1645 : : // Destroy any unwanted CoFaces (those remaining
1646 : : // in old_cofaces)
1647 [ + - ][ + + ]: 3531 : while( old_cofaces.size() )
1648 : : {
1649 [ + - ][ - + ]: 154 : CoFace* dead_coface = dynamic_cast<CoFace*>(old_cofaces.pop());
1650 [ + - ][ - + ]: 154 : assert(!dead_coface->get_shell_ptr());
1651 [ + - ]: 154 : destroy_dead_entity(dead_coface);
1652 : 154 : shell_modified = true;
1653 : : }
1654 : :
1655 [ + - ]: 6754 : return shell;
1656 : : }
1657 : :
1658 : :
1659 : : //-------------------------------------------------------------------------
1660 : : // Purpose : Find the CoEdgeSM in the passed Surface that should
1661 : : // be merged with the passed CoEdgeSM.
1662 : : //
1663 : : // Special Notes : Should be O(1) in the average case. See comments below.
1664 : : //
1665 : : // Creator : Jason Kraftcheck
1666 : : //
1667 : : // Creation Date : 08/21/02
1668 : : //-------------------------------------------------------------------------
1669 : 82 : CoEdgeSM* GeometryQueryTool::find_merged_coedgesm( Surface* on_this_surf,
1670 : : CoEdgeSM* merged_with_this ) const
1671 : : {
1672 : : // Get the relative sense of the merged surfaces
1673 [ + - ]: 82 : DLIList<Surface*> coedge_surfaces(1);
1674 [ + - ]: 82 : merged_with_this->surfaces( coedge_surfaces );
1675 [ + - ][ - + ]: 82 : if( coedge_surfaces.size() != 1 )
1676 : 0 : return 0;
1677 : : bool surfaces_reversed =
1678 [ + - ][ + - ]: 82 : (coedge_surfaces.get()->bridge_sense() != on_this_surf->bridge_sense());
[ + - ]
1679 : :
1680 : : // Get the Curve merge partner from the CoEdgeSM merge partner
1681 [ + - ][ + - ]: 164 : DLIList<Curve*> coedge_curves(1);
1682 [ + - ]: 82 : merged_with_this->curves( coedge_curves );
1683 [ + - ][ - + ]: 82 : if( coedge_curves.size() != 1 )
1684 : : {
1685 [ # # ][ # # ]: 0 : assert(coedge_curves.size() == 1);
1686 : 0 : return 0;
1687 : : }
1688 [ + - ]: 82 : Curve* merged_curve = coedge_curves.get();
1689 : :
1690 : : // If the curve doesn't have a bridge manager, it is
1691 : : // not merged.
1692 [ + - ][ - + ]: 82 : if (!merged_curve->bridge_manager())
1693 : 0 : return 0;
1694 : :
1695 : : // Get all curves merged with the merged_curve
1696 [ + - ][ + - ]: 82 : int num_bridges = merged_curve->bridge_manager()->number_of_bridges();
1697 [ + - ][ + - ]: 164 : DLIList<TopologyBridge*> curve_bridges( num_bridges );
1698 [ + - ][ + - ]: 82 : merged_curve->bridge_manager()->get_bridge_list( curve_bridges );
1699 : :
1700 : : // Loop through Curves, looking for the Curve with the
1701 : : // parent CoEdgeSM we want. This loop should be
1702 : : // roughly O(1) for manifold geometry (and most non-
1703 : : // manifold geometry), where n is the number of curves
1704 : : // merged together in the RefEdge. For manifold
1705 : : // geometry, there are never more than 2 CoEdgeSMs per
1706 : : // Curve. For most models, n is <= 4, so this entire
1707 : : // function can be considered O(1) for most models.
1708 [ + - ][ + - ]: 164 : DLIList<CoEdgeSM*> curve_coedges(2);
1709 [ + - ]: 82 : curve_bridges.reset();
1710 [ + - ][ + - ]: 164 : for( int i = curve_bridges.size(); i--; )
1711 : : {
1712 [ + - ]: 164 : TopologyBridge* curve = curve_bridges.get_and_step();
1713 : :
1714 [ + - ]: 164 : curve_coedges.clean_out();
1715 [ + - ]: 164 : curve->coedgesms( curve_coedges );
1716 [ + - ]: 164 : curve_coedges.reset();
1717 [ + - ][ + + ]: 369 : for( int j = curve_coedges.size(); j--; )
1718 : : {
1719 [ + - ]: 287 : CoEdgeSM* coedgesm = curve_coedges.get_and_step();
1720 : :
1721 : : // Get parent Surface of CoEdgeSM
1722 [ + - ]: 287 : coedge_surfaces.clean_out();
1723 [ + - ]: 287 : coedgesm->surfaces( coedge_surfaces );
1724 [ + - ][ - + ]: 287 : assert( coedge_surfaces.size() == 1 );
1725 : :
1726 : : // Is the parent Surface the one we are looking for?
1727 [ + - ][ + + ]: 287 : if( coedge_surfaces.get() == on_this_surf )
1728 : : {
1729 : : // Curve may occur in surface twice for non-manifold
1730 : : // topology. We need to make sure we have the CoEdgeSM
1731 : : // with the correct sense.
1732 : :
1733 : : // Are the curves reversed wrt to each other?
1734 : : bool curves_reversed =
1735 [ + - ][ + - ]: 82 : (merged_curve->bridge_sense() != curve->bridge_sense());
1736 : : // Should this coedgesm be reversed wrt to the merge partner?
1737 : 82 : bool should_be_reversed = (curves_reversed != surfaces_reversed);
1738 : : // Are the coedgesm actually reversed wrt to each other?
1739 [ + - ][ + - ]: 82 : bool are_reversed = (merged_with_this->sense() != coedgesm->sense());
1740 : :
1741 : : // Do the coedges have the appropriate senses
1742 [ + - ]: 82 : if( should_be_reversed == are_reversed )
1743 : : {
1744 : 82 : return coedgesm;
1745 : : }
1746 : : }
1747 : : } // for(j = curve_coedgesms)
1748 : : } // for(i = curve_coedges)
1749 : :
1750 [ + - ]: 82 : return 0;
1751 : : }
1752 : :
1753 : : //-------------------------------------------------------------------------
1754 : : // Purpose : Build/update RefFace topology
1755 : : //
1756 : : // Special Notes :
1757 : : //
1758 : : // Creator : Jason Kraftcheck
1759 : : //
1760 : : // Creation Date : 08/21/02
1761 : : //-------------------------------------------------------------------------
1762 : 18895 : RefFace* GeometryQueryTool::make_RefFace( Surface* surface_ptr ) const
1763 : : {
1764 : : int i;
1765 [ + - ]: 18895 : DLIList<LoopSM*> loopsms;
1766 [ + - ][ + - ]: 37790 : DLIList<CoEdgeSM*> coedgesms;
1767 [ + - ][ + - ]: 37790 : DLIList<Curve*> curves(1);
1768 : :
1769 : : // Get/construct RefFace for surface.
1770 : 18895 : bool face_created = false;
1771 : 18895 : bool face_modified = false;
1772 : 18895 : bool face_modified2 = false;
1773 [ + - ][ + + ]: 18895 : RefFace* face = CAST_TO( surface_ptr->topology_entity(), RefFace );
1774 [ + + ]: 18895 : if( !face )
1775 : : {
1776 [ + - ][ + + ]: 16128 : face = dynamic_cast<RefFace*>(check_mergeable_refentity(surface_ptr));
1777 : :
1778 : : //Including this call in here in case the surface a composite and
1779 : : //hidden curves need to be removed in the graphics.
1780 [ + + ]: 16128 : if( face )
1781 : : {
1782 : 82 : face_modified2 = true;
1783 : : }
1784 : : }
1785 [ + + ]: 18895 : if( !face )
1786 : : {
1787 [ + - ][ + - ]: 16046 : face = RefEntityFactory::instance()->construct_RefFace(surface_ptr);
1788 : 16046 : face_created = true;
1789 : : }
1790 [ - + ]: 18895 : assert(!!face);
1791 [ + - ][ + - ]: 18895 : bool merged = face->bridge_manager()->number_of_bridges() > 1;
1792 : :
1793 : : // First construct all the RefEdges. If the Curves
1794 : : // were merged, the RefEdges will be constructed merged.
1795 : : // We need the merged RefEdges to determined which
1796 : : // CoEdges and Loops need to be merged. We could do this
1797 : : // with one loop by getting the curves directly from the
1798 : : // surface. However, that might result in different
1799 : : // RefEdge IDs, so do it with nested loops like the old code.
1800 [ + - ]: 18895 : loopsms.clean_out();
1801 [ + - ]: 18895 : surface_ptr->loopsms( loopsms );
1802 [ + - ]: 18895 : loopsms.reset();
1803 [ + - ][ + + ]: 38947 : for( i = loopsms.size(); i--; )
1804 : : {
1805 [ + - ]: 20052 : LoopSM* loopsm = loopsms.get_and_step();
1806 [ + - ]: 20052 : coedgesms.clean_out();
1807 [ + - ]: 20052 : loopsm->coedgesms(coedgesms);
1808 [ + - ]: 20052 : coedgesms.reset();
1809 [ + - ][ + + ]: 96472 : for( int j = coedgesms.size(); j--; )
1810 : : {
1811 [ + - ]: 76420 : CoEdgeSM* coedgesm = coedgesms.get_and_step();
1812 [ + - ]: 76420 : curves.clean_out();
1813 [ + - ]: 76420 : coedgesm->curves(curves);
1814 [ + - ][ - + ]: 76420 : if( curves.size() != 1 )
1815 : : {
1816 [ # # ][ # # ]: 0 : PRINT_ERROR("Invalid SolidModel topology encountered in "
[ # # ][ # # ]
[ # # ]
1817 : : "GeometryQueryTool::make_RefFace. CoEdgeSM in "
1818 [ # # ]: 0 : "Surface %d has %d curves.\n", face->id(), curves.size());
1819 [ # # ][ # # ]: 0 : if( curves.size() == 0 )
1820 : 0 : continue;
1821 : : }
1822 : :
1823 [ + - ][ + - ]: 76420 : RefEdge* edge = make_RefEdge( curves.get() );
1824 [ - + ]: 76420 : if( !edge )
1825 : : {
1826 [ # # ][ # # ]: 0 : PRINT_ERROR("Failed to construct RefEdge in Surface %d\n",face->id());
[ # # ][ # # ]
[ # # ]
1827 : : }
1828 : : }
1829 : : }
1830 : :
1831 : : // If the Surface was merged, make sure it can remain merged
1832 [ + + ][ + - ]: 18895 : if (merged && !make_merged_RefFace(surface_ptr))
[ - + ][ - + ]
1833 : 0 : merged = false;
1834 : :
1835 : : // If !merged, then if necessary unmerge the RefFace
1836 [ + + ][ + - ]: 18895 : if( !merged && face->bridge_manager()->number_of_bridges() > 1 )
[ + - ][ - + ]
[ - + ]
1837 : : {
1838 [ # # ][ # # ]: 0 : PRINT_WARNING("Unmerging Surface %d.\n", face->id() );
[ # # ][ # # ]
[ # # ]
1839 : :
1840 : : // unmerge
1841 [ # # ][ # # ]: 0 : face->bridge_manager()->remove_bridge(surface_ptr);
1842 : :
1843 : : // reset bridge sense on unmerged surface
1844 [ # # ][ # # ]: 0 : if (surface_ptr->bridge_sense() == CUBIT_REVERSED)
1845 [ # # ]: 0 : surface_ptr->reverse_bridge_sense();
1846 : :
1847 : : // if the first bridge in the old refface is now reversed,
1848 : : // flip the refface.
1849 [ # # ][ # # ]: 0 : if (face->get_surface_ptr()->bridge_sense() == CUBIT_REVERSED)
[ # # ]
1850 : : {
1851 [ # # ][ # # ]: 0 : face->bridge_manager()->reverse_bridge_senses();
1852 [ # # ]: 0 : face->reverse_topology();
1853 : : }
1854 : :
1855 : : // construct new refface for unmerged surface.
1856 [ # # ][ # # ]: 0 : face = RefEntityFactory::instance()->construct_RefFace(surface_ptr);
1857 : 0 : face_created = true;
1858 : : }
1859 : :
1860 : : // If the sense of the Surface with respect to the RefFace is
1861 : : // reversed, need to construct Loops and CoEdges reversed.
1862 [ + - ]: 18895 : bool need_to_reverse = (surface_ptr->bridge_sense() == CUBIT_REVERSED);
1863 : :
1864 : : // Construct LoopSMs and CoEdgeSMs, and attach
1865 [ + - ]: 18895 : loopsms.clean_out();
1866 [ + - ]: 18895 : surface_ptr->loopsms( loopsms );
1867 [ + - ]: 18895 : loopsms.reset();
1868 [ + - ][ + - ]: 37790 : DLIList<SenseEntity*> coedges, old_coedges;
[ + - ][ + - ]
1869 [ + - ][ + - ]: 37790 : DLIList<GroupingEntity*> loops(loopsms.size()), dead_loops;
[ + - ][ + - ]
[ + - ]
1870 [ + - ][ + + ]: 38947 : for( i = loopsms.size(); i--; )
1871 : : {
1872 : : // Get/construct Loop
1873 [ + - ]: 20052 : LoopSM* loopsm = loopsms.get_and_step();
1874 [ + - ][ + + ]: 20052 : Loop* loop = dynamic_cast<Loop*>(loopsm->topology_entity());
1875 [ + + ][ + + ]: 20052 : if( loop && !merged && loop->bridge_manager()->number_of_bridges() > 1 )
[ + - ][ + - ]
[ - + ][ - + ]
1876 : : {
1877 [ # # ][ # # ]: 0 : loop->bridge_manager()->remove_bridge( loopsm );
1878 [ # # ][ # # ]: 0 : loop = new Loop( loopsm );
1879 : 0 : face_modified = true;
1880 : : }
1881 [ + + ]: 20052 : else if( !loop )
1882 : : {
1883 [ + - ][ + - ]: 17331 : loop = new Loop( loopsm );
1884 : 17331 : face_modified = true;
1885 : : }
1886 : :
1887 : : // If loop is already attached to some other RefFace
1888 : : // we cannot use it. NOTE: Removing the Loop from
1889 : : // the other RefFace is NOT an option, even if the
1890 : : // loop has only our loopsm. If we were to remove it
1891 : : // we could potentially miss the fact that the other
1892 : : // RefFace was modified when doing make_RefFace for
1893 : : // RefFace.
1894 [ + - ]: 20052 : RefFace* loop_face = loop->get_ref_face_ptr();
1895 [ + + ][ + + ]: 20052 : if( loop_face && loop_face != face )
1896 : : {
1897 [ + - ][ + - ]: 11 : loop->bridge_manager()->remove_bridge( loopsm );
1898 [ + - ][ + - ]: 11 : loop = new Loop( loopsm );
1899 : 11 : face_modified = true;
1900 : : }
1901 [ + - ]: 20052 : loops.append(loop);
1902 : :
1903 : : // Get CoEdges in the appropriate order
1904 [ + - ]: 20052 : coedgesms.clean_out();
1905 [ + - ]: 20052 : loopsm->coedgesms( coedgesms );
1906 [ + - ][ - + ]: 20052 : if( coedgesms.size() == 0 )
1907 : : {
1908 [ # # ][ # # ]: 0 : PRINT_ERROR("Encountered Loop with no CoEdges in Surface %d.\n",
[ # # ][ # # ]
1909 [ # # ]: 0 : face->id() );
1910 : 0 : continue;
1911 : : }
1912 [ + + ]: 20052 : if( need_to_reverse )
1913 [ + - ]: 11 : coedgesms.reverse();
1914 [ + - ]: 20052 : coedgesms.reset();
1915 : :
1916 : : // Consturct/update each CoEdge
1917 : : int j;
1918 [ + - ]: 20052 : coedges.clean_out();
1919 [ + - ][ + + ]: 96472 : for( j = coedgesms.size(); j--; )
1920 : : {
1921 [ + - ]: 76420 : CoEdgeSM* coedgesm = coedgesms.get_and_step();
1922 [ + - ][ + + ]: 76420 : CoEdge* coedge = dynamic_cast<CoEdge*>(coedgesm->topology_entity());
1923 : :
1924 : : // If the CoEdge is merged but the surface isn't, unmerge
1925 : : // the CoEdge
1926 [ + + ][ + + ]: 76420 : if( coedge && !merged && coedge->bridge_manager()->number_of_bridges() > 1 )
[ + - ][ + - ]
[ - + ][ - + ]
1927 : : {
1928 [ # # ][ # # ]: 0 : coedge->bridge_manager()->remove_bridge( coedgesm );
1929 : 0 : coedge = 0;
1930 : : }
1931 : :
1932 : : // If CoEdge belongs to a loop in some other face, don't
1933 : : // use it.
1934 [ + + ][ + - ]: 76420 : if( coedge && coedge->get_loop_ptr() && coedge->get_loop_ptr() != loop )
[ + - ][ + - ]
[ + + ][ + + ]
1935 : : {
1936 [ + - ][ + - ]: 44 : coedge->bridge_manager()->remove_bridge( coedgesm );
1937 : 44 : coedge = 0;
1938 : : }
1939 : :
1940 : : // If the CoEdgeSM doesn't already have an owning CoEdge
1941 : : // (or we unmerged) create a new CoEdge
1942 [ + + ]: 76420 : if( !coedge )
1943 : : {
1944 [ + - ][ + - ]: 67601 : coedge = new CoEdge();
1945 [ + - ][ + - ]: 67601 : coedge->bridge_manager()->add_bridge( coedgesm );
1946 : 67601 : face_modified = true;
1947 : : }
1948 [ + - ]: 76420 : coedges.append( coedge );
1949 : :
1950 : : // Find the RefEdge to attach to
1951 [ + - ]: 76420 : curves.clean_out();
1952 [ + - ]: 76420 : coedgesm->curves( curves );
1953 [ + - ][ - + ]: 76420 : if( curves.size() == 0 )
1954 : 0 : continue; // error message should have been printed already
1955 : :
1956 [ + - ]: 76420 : Curve* curve = curves.get();
1957 [ + - ][ - + ]: 76420 : RefEdge* edge = dynamic_cast<RefEdge*>(curve->topology_entity());
1958 [ - + ]: 76420 : assert( edge != NULL );
1959 : :
1960 : : // Figure out what the CoEdge sense should be.
1961 : : // The CoEdge sense should be the product ("product"
1962 : : // as in multiply) of three
1963 : : // senses: 1) the sense of the surface wrt its RefFace,
1964 : : // 2) the sense of the curve wrt its RefEdge, and 3)
1965 : : // the sense of the CoEdgeSM.
1966 [ + - ]: 76420 : bool curve_reversed = (CUBIT_REVERSED == curve->bridge_sense());
1967 : 76420 : bool reverse = (curve_reversed != need_to_reverse);
1968 [ + - ]: 76420 : CubitSense sense = coedgesm->sense();
1969 [ + + ]: 76420 : if( reverse )
1970 [ + - ]: 44 : sense = CubitUtil::opposite_sense(sense);
1971 [ + - ][ + + ]: 76420 : if( coedge->get_sense() != sense )
1972 [ + - ]: 30327 : coedge->set_sense( sense );
1973 : :
1974 : : // Attach RefEdge to CoEdge (if it isn't already)
1975 [ + - ]: 76420 : RefEdge* coedge_edge = coedge->get_ref_edge_ptr();
1976 [ + + ]: 76420 : if (coedge_edge != edge)
1977 : : {
1978 [ - + ]: 67601 : if (coedge_edge)
1979 : : {
1980 [ # # ]: 0 : coedge_edge->remove_sense_entity(coedge);
1981 [ # # ]: 0 : destroy_dead_entity(coedge_edge);
1982 : 0 : face_modified = true;
1983 : : }
1984 [ + - ]: 67601 : coedge->attach_basic_topology_entity(edge);
1985 : : }
1986 : : }
1987 : :
1988 : : // Attach CoEdges to Loop
1989 [ + - ]: 20052 : old_coedges.clean_out();
1990 [ + - ]: 20052 : loop->set_sense_entity_list(coedges, old_coedges);
1991 : :
1992 : : // Clean up dead coedges
1993 [ + - ][ + + ]: 21086 : while (old_coedges.size())
1994 : : {
1995 [ + - ][ - + ]: 1034 : CoEdge* dead_coedge = dynamic_cast<CoEdge*>(old_coedges.pop());
1996 [ + - ][ - + ]: 1034 : assert(!dead_coedge->get_loop_ptr());
1997 [ + - ]: 1034 : destroy_dead_entity(dead_coedge);
1998 : 1034 : face_modified = true;
1999 : : }
2000 : : } // end for( i == loopsms )
2001 : :
2002 : : // Attach loops
2003 [ + - ]: 18895 : face->set_grouping_entity_list( loops, dead_loops );
2004 : :
2005 : : // Remove any dead loops
2006 [ + - ][ + + ]: 19122 : while (dead_loops.size())
2007 : : {
2008 [ + - ]: 227 : GroupingEntity* loop = dead_loops.pop();
2009 [ + - ]: 227 : destroy_dead_entity(loop);
2010 : 227 : face_modified = true;
2011 : : }
2012 : :
2013 [ + + ][ + + ]: 18895 : if( !face_created && face_modified && !face->deactivated() )
[ + - ][ + - ]
[ + + ]
2014 : : {
2015 [ + - ][ + - ]: 744 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_TOPOLOGY_MODIFIED, face));
[ + - ][ + - ]
[ + - ]
2016 [ + - ][ + - ]: 744 : CGMHistory::Event evt2(CGMHistory::TOPOLOGY_CHANGED, face);
2017 [ + - ]: 744 : const_cast<CGMHistory&>(mHistory).add_event(evt2);
2018 [ + - ][ + - ]: 1488 : CGMHistory::Event evt(CGMHistory::GEOMETRY_CHANGED, face);
[ + - ]
2019 [ + - ][ + - ]: 1488 : const_cast<CGMHistory&>(mHistory).add_event(evt);
2020 : : }
2021 [ + + ]: 18151 : else if(face_modified2)
2022 : : {
2023 [ + - ][ + - ]: 82 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_MODIFIED, face));
[ + - ][ + - ]
[ + - ]
2024 [ + - ][ + - ]: 82 : CGMHistory::Event evt(CGMHistory::TOPOLOGY_CHANGED, face);
2025 [ + - ][ + - ]: 82 : const_cast<CGMHistory&>(mHistory).add_event(evt);
2026 : : }
2027 : :
2028 [ + - ]: 18895 : return face;
2029 : : }
2030 : :
2031 : :
2032 : : //-------------------------------------------------------------------------
2033 : : // Purpose : Check if Surface can remain merged.
2034 : : //
2035 : : // Special Notes :
2036 : : //
2037 : : // Creator : Jason Kraftcheck
2038 : : //
2039 : : // Creation Date : 12/12/03
2040 : : //-------------------------------------------------------------------------
2041 : 82 : CubitStatus GeometryQueryTool::make_merged_RefFace(Surface* surface_ptr) const
2042 : : {
2043 : : // Get the RefFace
2044 [ + - ][ - + ]: 82 : RefFace* face = dynamic_cast<RefFace*>(surface_ptr->topology_entity());
2045 [ - + ]: 82 : if (!face) // isn't merged
2046 : 0 : return CUBIT_FAILURE;
2047 : :
2048 : : // Get a Surface to compare to.
2049 [ + - ][ + - ]: 82 : int num_bridges = face->bridge_manager()->number_of_bridges();
2050 [ - + ]: 82 : if (num_bridges < 2) // isn't merged
2051 : 0 : return CUBIT_FAILURE;
2052 : :
2053 : : // Get some other Surface in merged RefFace to compare
2054 : : // topology with.
2055 [ + - ]: 82 : DLIList<TopologyBridge*> bridge_list(num_bridges);
2056 [ + - ][ + - ]: 82 : face->bridge_manager()->get_bridge_list(bridge_list);
2057 [ + - ]: 82 : bridge_list.reset();
2058 [ + - ][ - + ]: 82 : if (bridge_list.get() == surface_ptr)
2059 [ # # ]: 0 : bridge_list.step();
2060 [ + - ]: 82 : TopologyBridge* merged_bridge = bridge_list.get();
2061 [ - + ]: 82 : Surface* merged_surface = dynamic_cast<Surface*>(merged_bridge);
2062 [ + - ][ - + ]: 82 : assert(merged_surface && merged_surface != surface_ptr);
2063 : :
2064 : : // Get the relative sense of the Surfaces
2065 : : bool surfaces_reversed =
2066 [ + - ][ + - ]: 82 : (surface_ptr->bridge_sense() != merged_surface->bridge_sense());
2067 : :
2068 : : // Get LoopSMs for both surfaces
2069 [ + - ][ + - ]: 164 : DLIList<LoopSM*> merged_loops, loopsms;
[ + - ][ + - ]
2070 [ + - ]: 82 : surface_ptr->loopsms(loopsms);
2071 [ + - ]: 82 : merged_surface->loopsms(merged_loops);
2072 [ + - ][ + - ]: 82 : if( merged_loops.size() != loopsms.size() )
[ - + ]
2073 : 0 : return CUBIT_FAILURE;
2074 : :
2075 : : // For each LoopSM on the merged Surface, find the
2076 : : // corresponding LoopSM on this Surface and merge.
2077 [ + - ][ + - ]: 164 : DLIList<CoEdgeSM*> merged_coedges, coedgesms;
[ + - ][ + - ]
2078 [ + - ][ + - ]: 164 : DLIList<LoopSM*> coedge_loops(1);
2079 [ + - ][ + - ]: 164 : DLIList<Curve*> curves(1);
2080 [ + - ]: 82 : merged_loops.reset();
2081 [ + - ][ + + ]: 164 : for( int i = merged_loops.size(); i--; )
2082 : : {
2083 [ + - ]: 82 : LoopSM* merged_loop = merged_loops.get_and_step();
2084 : :
2085 : : // Find the LoopSM by choosing a CoEdgeSM from the
2086 : : // merged LoopSM, and finding corresponding CoEdgeSM
2087 : : // on the Surface we are building.
2088 : :
2089 [ + - ]: 82 : merged_coedges.clean_out();
2090 [ + - ]: 82 : merged_loop->coedgesms( merged_coedges );
2091 [ + - ]: 82 : merged_coedges.reset();
2092 [ + - ]: 82 : CoEdgeSM* merged_coedge = merged_coedges.get();
2093 : :
2094 [ + - ]: 82 : CoEdgeSM* coedgesm = find_merged_coedgesm( surface_ptr, merged_coedge );
2095 [ - + ]: 82 : if( !coedgesm )
2096 : 0 : return CUBIT_FAILURE;
2097 : :
2098 : : // Get the LoopSM in surface_ptr from the CoEdgeSM
2099 [ + - ]: 82 : coedge_loops.clean_out();
2100 [ + - ]: 82 : coedgesm->loopsms( coedge_loops );
2101 [ + - ][ - + ]: 82 : assert( coedge_loops.size() == 1 );
2102 [ + - ]: 82 : LoopSM* loopsm = coedge_loops.get();
2103 : :
2104 : : // Get all the CoEdgeSMs on the LoopSM we are going to merge.
2105 [ + - ]: 82 : coedgesms.clean_out();
2106 [ + - ]: 82 : loopsm->coedgesms( coedgesms );
2107 [ + - ][ + - ]: 82 : if( coedgesms.size() != merged_coedges.size() )
[ - + ]
2108 : 0 : return CUBIT_FAILURE;
2109 : :
2110 : : // Get the CoEdge list in the appropriate order and position
2111 [ + + ]: 82 : if( surfaces_reversed )
2112 [ + - ]: 11 : coedgesms.reverse();
2113 [ + - ]: 82 : coedgesms.move_to(coedgesm);
2114 [ + - ][ - + ]: 82 : assert( coedgesms.get() == coedgesm );
2115 : :
2116 : : // Now check and merge CoEdgeSM pairs
2117 [ + - ][ + + ]: 410 : for( int j = coedgesms.size(); j--; )
2118 : : {
2119 [ + - ]: 328 : coedgesm = coedgesms.get_and_step();
2120 [ + - ]: 328 : merged_coedge = merged_coedges.get_and_step();
2121 : :
2122 : : // Get Curve in surface_ptr
2123 [ + - ]: 328 : curves.clean_out();
2124 [ + - ]: 328 : coedgesm->curves(curves);
2125 [ + - ][ - + ]: 328 : if( curves.size() != 1 )
2126 : : {
2127 [ # # ][ # # ]: 0 : PRINT_ERROR("Invalid SolidModel topology encountered in "
[ # # ][ # # ]
2128 : : "GeometryQueryTool::make_RefFace. CoEdgeSM in "
2129 [ # # ]: 0 : "has %d curves.\n", curves.size());
2130 : 0 : return CUBIT_FAILURE;
2131 : : }
2132 [ + - ]: 328 : Curve* curve = curves.get();
2133 : :
2134 : : // Get Curve in merged_surface
2135 [ + - ]: 328 : curves.clean_out();
2136 [ + - ]: 328 : merged_coedge->curves(curves);
2137 [ + - ][ - + ]: 328 : if( curves.size() != 1 )
2138 : : {
2139 [ # # ][ # # ]: 0 : PRINT_ERROR("Invalid SolidModel topology encountered in "
[ # # ][ # # ]
2140 : : "GeometryQueryTool::make_RefFace. CoEdgeSM in "
2141 [ # # ]: 0 : "has %d curves.\n", curves.size());
2142 : 0 : return CUBIT_FAILURE;
2143 : : }
2144 [ + - ]: 328 : Curve* merged_curve = curves.get_and_step();
2145 : :
2146 : : // Check if curves are merged
2147 [ + - ][ + - ]: 328 : if( merged_curve->bridge_manager() != curve->bridge_manager() )
[ - + ]
2148 : 0 : return CUBIT_FAILURE;
2149 : :
2150 : : // Check that relative sense of CoEdgeSMs is correct
2151 : : bool curves_reversed =
2152 [ + - ][ + - ]: 328 : (merged_curve->bridge_sense() != curve->bridge_sense());
2153 : : // Should this coedgesm be reversed wrt to the merge partner?
2154 : 328 : bool should_be_reversed = (curves_reversed != surfaces_reversed);
2155 : : // Are the coedgesm actually reversed wrt to each other?
2156 [ + - ][ + - ]: 328 : bool are_reversed = (merged_coedge->sense() != coedgesm->sense());
2157 [ - + ]: 328 : if( should_be_reversed != are_reversed )
2158 : 0 : return CUBIT_FAILURE;
2159 : :
2160 : : // Merge the CoEdgeSMs
2161 [ + - ][ + - ]: 328 : CoEdge* coedge = dynamic_cast<CoEdge*>(coedgesm->topology_entity());
2162 [ + - ][ - + ]: 328 : CoEdge* merge = dynamic_cast<CoEdge*>(merged_coedge->topology_entity());
2163 : :
2164 : : // If this coedgesm is not the primary coedgesm in the
2165 : : // CoEdge, check to make sure the primary CoEdgeSM's curve
2166 : : // is merged with our curve.
2167 [ # # ][ # # ]: 328 : if (coedge && coedge->bridge_manager()->number_of_bridges() > 1
[ # # ][ - + ]
2168 [ # # ][ # # ]: 0 : && coedge->bridge_manager()->topology_bridge() != coedgesm
[ # # ]
2169 [ - + ][ # # ]: 328 : && coedge->bridge_manager()->topology_bridge() != merged_coedge )
[ # # ][ # # ]
2170 : : {
2171 [ # # ]: 0 : curves.clean_out();
2172 [ # # ][ # # ]: 0 : coedge->bridge_manager()->topology_bridge()->curves(curves);
[ # # ]
2173 [ # # ][ # # ]: 0 : assert(curves.size() == 1);
2174 [ # # ][ # # ]: 0 : if (curves.get()->owner() != curve->owner())
[ # # ][ # # ]
2175 : : {
2176 [ # # ][ # # ]: 0 : coedge->bridge_manager()->remove_bridge(coedgesm);
2177 [ # # ][ # # ]: 0 : assert(coedge->get_parents());
2178 : 0 : coedge = 0;
2179 : : }
2180 : : }
2181 [ + - ][ + - ]: 656 : if (merge && merge->bridge_manager()->number_of_bridges() > 1
[ - + ][ - + ]
2182 [ # # ][ # # ]: 0 : && merge->bridge_manager()->topology_bridge() != coedgesm
[ # # ]
2183 [ + - ][ # # ]: 656 : && merge->bridge_manager()->topology_bridge() != merged_coedge )
[ # # ][ # # ]
2184 : : {
2185 [ # # ]: 0 : curves.clean_out();
2186 [ # # ][ # # ]: 0 : merge->bridge_manager()->topology_bridge()->curves(curves);
[ # # ]
2187 [ # # ][ # # ]: 0 : assert(curves.size() == 1);
2188 [ # # ][ # # ]: 0 : if (curves.get()->owner() != curve->owner())
[ # # ][ # # ]
2189 : : {
2190 [ # # ][ # # ]: 0 : merge->bridge_manager()->remove_bridge(merged_coedge);
2191 [ # # ][ # # ]: 0 : assert(merge->get_parents());
2192 : 0 : merge = 0;
2193 : : }
2194 : : }
2195 : :
2196 : : // If the two CoEdgeSM's aren't in the same CoEdge,
2197 : : // merge them.
2198 [ + - ][ + - ]: 328 : if (merge && merge != coedge)
2199 : : {
2200 [ - + ]: 328 : if (coedge)
2201 : : {
2202 [ # # ][ # # ]: 0 : coedge->bridge_manager()->remove_bridge(coedgesm);
2203 [ # # ]: 0 : destroy_dead_entity(coedge);
2204 : : }
2205 [ + - ][ + - ]: 328 : merge->bridge_manager()->add_bridge(coedgesm);
2206 : : }
2207 : : // If for some reason (Composite curve creatation does
2208 : : // this) neither CoEdgeSM has a CoEdge, create one and
2209 : : // re-merge them.
2210 [ # # ][ # # ]: 0 : else if (!coedge && !merge)
2211 : : {
2212 [ # # ][ # # ]: 0 : coedge = new CoEdge(coedgesm);
2213 [ # # ][ # # ]: 0 : coedge->bridge_manager()->add_bridge(merged_coedge);
2214 : : }
2215 [ # # ]: 0 : else if(!coedge)
2216 : : {
2217 [ # # ][ # # ]: 0 : merge->bridge_manager()->add_bridge(coedgesm);
2218 : : }
2219 [ # # ]: 0 : else if(!merge)
2220 : : {
2221 [ # # ][ # # ]: 0 : coedge->bridge_manager()->add_bridge(merged_coedge);
2222 : : }
2223 : : } // for( j = coedgesms )
2224 : :
2225 : :
2226 [ + - ][ + - ]: 82 : Loop* loop = dynamic_cast<Loop*>(loopsm->topology_entity());
2227 [ + - ][ - + ]: 82 : Loop* merged = dynamic_cast<Loop*>(merged_loop->topology_entity());
2228 : : // If the two LoopSMs aren't in the same Loop, merge them
2229 [ + - ][ + - ]: 82 : if( merged != 0 && merged != loop )
2230 : : {
2231 [ - + ]: 82 : if( loop )
2232 [ # # ][ # # ]: 0 : loop->bridge_manager()->remove_bridge(loopsm);
2233 [ + - ][ + - ]: 82 : merged->bridge_manager()->add_bridge(loopsm);
2234 : : }
2235 [ # # ][ # # ]: 0 : else if( !loop && !merged )
2236 : : {
2237 [ # # ][ # # ]: 0 : loop = new Loop;
2238 [ # # ][ # # ]: 0 : loop->bridge_manager()->add_bridge(merged_loop);
2239 : : }
2240 [ # # ]: 0 : else if( !loop )
2241 : : {
2242 [ # # ][ # # ]: 0 : merged->bridge_manager()->add_bridge(loopsm);
2243 : : }
2244 [ # # ]: 0 : else if( !merged )
2245 : : {
2246 [ # # ][ # # ]: 82 : loop->bridge_manager()->add_bridge(merged_loop);
2247 : : }
2248 : : } // for( i = merged_loops )
2249 : :
2250 [ + - ]: 164 : return CUBIT_SUCCESS;
2251 : : }
2252 : :
2253 : : //-------------------------------------------------------------------------
2254 : : // Purpose : Get/construct/update a RefEdge from a Curve
2255 : : //
2256 : : // Special Notes :
2257 : : //
2258 : : // Creator : Jason Kraftcheck
2259 : : //
2260 : : // Creation Date : 08/22/02
2261 : : //-------------------------------------------------------------------------
2262 : 76838 : RefEdge* GeometryQueryTool::make_RefEdge( Curve* curve_ptr ) const
2263 : : {
2264 : : int i;
2265 : :
2266 : : // Get/construct RefEdge
2267 : 76838 : bool edge_created = false;
2268 : 76838 : bool edge_modified = false;
2269 [ + - ][ + + ]: 76838 : RefEdge* edge = dynamic_cast<RefEdge*>(curve_ptr->topology_entity());
2270 [ + + ]: 76838 : if( !edge )
2271 [ + - ][ + + ]: 35519 : edge = dynamic_cast<RefEdge*>(check_mergeable_refentity(curve_ptr));
2272 [ + + ]: 76838 : if( !edge )
2273 : : {
2274 [ + - ][ + - ]: 35251 : edge = RefEntityFactory::instance()->construct_RefEdge(curve_ptr);
2275 : 35251 : edge_created = true;
2276 : : }
2277 [ - + ]: 76838 : assert(edge != NULL);
2278 [ + - ]: 76838 : bool reversed = (CUBIT_REVERSED == curve_ptr->bridge_sense());
2279 [ + - ][ + - ]: 76838 : bool merged = edge->bridge_manager()->number_of_bridges() > 1;
2280 : :
2281 : : // Construct RefVertices
2282 [ + - ]: 76838 : DLIList<TBPoint*> points(2);
2283 [ + - ]: 76838 : curve_ptr->points( points );
2284 [ + + ]: 76838 : if( reversed )
2285 [ + - ]: 66 : points.reverse();
2286 : :
2287 [ + - ][ + - ]: 76838 : if( points.size() > 2 || points.size() < 1 )
[ + - ][ - + ]
[ - + ]
2288 : : {
2289 [ # # ][ # # ]: 0 : PRINT_ERROR("Invalid SolidModel topology encountered in "
[ # # ][ # # ]
[ # # ]
2290 : : "GeometryQueryTool::make_RefEdge. Curve %d "
2291 [ # # ]: 0 : "has %d vertices.\n", edge->id(), points.size() );
2292 [ # # ][ # # ]: 0 : assert( points.size() == 1 || points.size() == 2 );
[ # # ][ # # ]
2293 [ # # ][ # # ]: 0 : if( points.size() == 0 )
2294 : 0 : return edge;
2295 : : }
2296 : :
2297 [ + - ]: 76838 : points.reset();
2298 [ + - ][ + - ]: 76838 : RefVertex* start_vertex = make_RefVertex( points.get() );
2299 [ + - ]: 76838 : points.last();
2300 [ + - ][ + - ]: 76838 : RefVertex* end_vertex = make_RefVertex( points.get() );
2301 : :
2302 : : // If curves are merged, make sure vertices are merged.
2303 [ + + ]: 76838 : if( merged )
2304 : : {
2305 [ + - ][ + - ]: 536 : int num_bridges = edge->bridge_manager()->number_of_bridges();
2306 [ + - ]: 536 : DLIList<TopologyBridge*> bridge_list( num_bridges );
2307 [ + - ][ + - ]: 536 : edge->bridge_manager()->get_bridge_list( bridge_list );
2308 : :
2309 [ + - ]: 536 : bridge_list.reset();
2310 [ + - ][ + - ]: 536 : for( i = bridge_list.size(); i--; )
2311 [ + - ][ + - ]: 536 : if( bridge_list.get() != curve_ptr )
2312 : 536 : break;
2313 : : else
2314 [ # # ]: 0 : bridge_list.step();
2315 : :
2316 : : // Get points on some other Curve that this curve is merged with.
2317 [ + - ][ - + ]: 536 : Curve* other_curve = dynamic_cast<Curve*>(bridge_list.get());
2318 [ - + ]: 536 : assert( other_curve != curve_ptr) ;
2319 [ + - ]: 536 : points.clean_out();
2320 [ + - ]: 536 : other_curve->points(points);
2321 [ + - ][ - + ]: 536 : if( other_curve->bridge_sense() == CUBIT_REVERSED )
2322 [ # # ]: 0 : points.reverse();
2323 : :
2324 : : // Check that points merged.
2325 [ + - ]: 536 : points.reset();
2326 [ + - ][ + - ]: 536 : if( points.get()->topology_entity() != start_vertex )
[ - + ]
2327 : 0 : merged = false;
2328 [ + - ]: 536 : points.last();
2329 [ + - ][ + - ]: 536 : if( points.get()->topology_entity() != end_vertex )
[ - + ]
2330 : 0 : merged = false;
2331 : :
2332 : : //perhaps the bridge sense just needs to be swapped
2333 [ - + ]: 536 : if( merged == false )
2334 : : {
2335 [ # # ]: 0 : points.reverse();
2336 [ # # ]: 0 : points.reset();
2337 [ # # ]: 0 : TBPoint *point1 = points.get_and_step();
2338 [ # # ]: 0 : TBPoint *point2 = points.get_and_step();
2339 [ # # ][ # # ]: 0 : if( point1->topology_entity() == start_vertex &&
[ # # ][ # # ]
2340 [ # # ]: 0 : point2->topology_entity() == end_vertex )
2341 : : {
2342 : 0 : merged = true;
2343 [ # # ]: 0 : curve_ptr->reverse_bridge_sense();
2344 : : }
2345 [ + - ]: 536 : }
2346 : : }
2347 : : // Unmerge the curve, if necessary.
2348 [ + + ][ + - ]: 76838 : if( !merged && edge->bridge_manager()->number_of_bridges() > 1 )
[ + - ][ - + ]
[ - + ]
2349 : : {
2350 [ # # ][ # # ]: 0 : PRINT_WARNING("Unmerging Curve %d\n", edge->id() );
[ # # ][ # # ]
[ # # ]
2351 : :
2352 : : // unmerge
2353 [ # # ][ # # ]: 0 : edge->bridge_manager()->remove_bridge( curve_ptr );
2354 : :
2355 : : // reset bridge sense on un-merged curve
2356 [ # # ][ # # ]: 0 : if (curve_ptr->bridge_sense() == CUBIT_REVERSED)
2357 : : {
2358 [ # # ]: 0 : curve_ptr->reverse_bridge_sense();
2359 : : }
2360 : :
2361 : : // if first curve in old edge now has reversed sense,
2362 : : // reverse the old edge also.
2363 : : //if (edge->get_curve_ptr()->bridge_sense() == CUBIT_REVERSED)
2364 : : //{
2365 : : // edge->bridge_manager()->reverse_bridge_senses();
2366 : : // edge->reverse_topology();
2367 : : //}
2368 : :
2369 : : // Create new RefEdge for un-merged curve
2370 [ # # ][ # # ]: 0 : edge = RefEntityFactory::instance()->construct_RefEdge( curve_ptr );
2371 [ # # ][ # # ]: 0 : PRINT_WARNING("Creating edge %d that was supposed to be merged\n", edge->id() );
[ # # ][ # # ]
[ # # ]
2372 : 0 : edge_created = true;
2373 : :
2374 : : // If we had swapped the vertex order because the curve
2375 : : // was reversed, switch them back because we unmerged so
2376 : : // we're going to create the new curve with a forward sense.
2377 [ # # ]: 0 : if( reversed )
2378 [ # # ]: 0 : std::swap(start_vertex,end_vertex);
2379 : : }
2380 : :
2381 : : // Get/construct Chain
2382 [ + - ]: 76838 : Chain* chain = edge->get_chain_ptr();
2383 [ + + ]: 76838 : if( !chain )
2384 : : {
2385 [ + - ][ + - ]: 35251 : chain = new Chain();
2386 [ + - ]: 35251 : edge->add_grouping_entity( chain );
2387 : : }
2388 : :
2389 : : // Get any existing CoVertices
2390 [ + - ][ + - ]: 153676 : DLIList<CoVertex*> co_vertices(2);
2391 [ + - ]: 76838 : chain->co_vertices( co_vertices );
2392 [ + - ][ - + ]: 76838 : if( co_vertices.size() > 2 )
2393 : : {
2394 [ # # ][ # # ]: 0 : PRINT_ERROR("In GeometryQueryTool::make_RefEdge, encountered "
[ # # ][ # # ]
[ # # ]
2395 : : "a Chain with %d CoVertices on Curve %d\n",
2396 [ # # ]: 0 : co_vertices.size(), edge->id());
2397 [ # # ][ # # ]: 0 : assert( co_vertices.size() <= 2 );
2398 : : }
2399 : :
2400 : : // Now construct CoVertices if necessary, and attach
2401 : : // RefVertices.
2402 [ + - ][ + - ]: 153676 : DLIList<RefVertex*> vertices(1);
2403 : 76838 : CoVertex* prev = 0;
2404 : : // First iteration is for start RefVertex
2405 : 76838 : RefVertex* vertex = start_vertex;
2406 [ + - ]: 76838 : co_vertices.reset();
2407 : : // Loop twice, once for each CoVertex.
2408 [ + + ]: 230514 : for( i = 0; i < 2; i++ )
2409 : : {
2410 : : // Construct CoVertex if one does not already exist
2411 : 153676 : CoVertex* cvtx = 0;
2412 [ + - ][ + + ]: 153676 : if( co_vertices.size() > i )
2413 : : {
2414 [ + - ]: 83174 : cvtx = co_vertices.get_and_step();
2415 : : }
2416 : : else
2417 : : {
2418 [ + - ][ + - ]: 70502 : cvtx = new CoVertex();
2419 [ + - ]: 70502 : chain->add_sense_entity( cvtx , prev );
2420 : : }
2421 : 153676 : prev = cvtx;
2422 : :
2423 : : // Get existing RefVertex from CoVertex, if it has one.
2424 [ + - ]: 153676 : vertices.clean_out();
2425 [ + - ]: 153676 : cvtx->ref_vertices( vertices );
2426 [ + - ][ - + ]: 153676 : if( vertices.size() > 1 )
2427 : : {
2428 [ # # ][ # # ]: 0 : PRINT_ERROR("In GeometryQueryTool::make_RefEdge, encountered "
[ # # ][ # # ]
[ # # ]
2429 : : "a CoVertex with %d Vertices on Curve %d\n",
2430 [ # # ]: 0 : vertices.size(), edge->id());
2431 [ # # ][ # # ]: 0 : assert( vertices.size() <= 1 );
2432 [ # # ]: 0 : vertices.reset();
2433 : : }
2434 [ + - ][ + + ]: 153676 : RefVertex* cvtx_vertex = vertices.size() ? vertices.get() : 0;
[ + - ]
2435 : :
2436 : : // Attach RefVertex to CoVertex if necessary
2437 [ + + ]: 153676 : if( cvtx_vertex != vertex )
2438 : : {
2439 : : // Wrong RefVertex. Unhook from that one.
2440 [ + + ]: 71052 : if( cvtx_vertex )
2441 : : {
2442 [ + - ]: 550 : cvtx_vertex->remove_sense_entity(cvtx);
2443 [ + - ][ + - ]: 550 : if (NULL == cvtx_vertex->get_point_ptr())
2444 [ + - ]: 550 : destroy_dead_entity( cvtx_vertex );
2445 : : }
2446 : :
2447 [ + - ]: 71052 : cvtx->attach_basic_topology_entity( vertex );
2448 : 71052 : edge_modified = true;
2449 : : }
2450 : :
2451 : : // Second iteration is for end RefVertex
2452 : 153676 : vertex = end_vertex;
2453 : : }
2454 : :
2455 [ + + ][ + + ]: 76838 : if( !edge_created && edge_modified && !edge->deactivated() )
[ + - ][ + - ]
[ + + ]
2456 : : {
2457 [ + - ][ + - ]: 418 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_TOPOLOGY_MODIFIED, edge));
[ + - ][ + - ]
[ + - ]
2458 [ + - ][ + - ]: 418 : CGMHistory::Event evt2(CGMHistory::TOPOLOGY_CHANGED, edge);
2459 [ + - ]: 418 : const_cast<CGMHistory&>(mHistory).add_event(evt2);
2460 [ + - ][ + - ]: 836 : CGMHistory::Event evt(CGMHistory::GEOMETRY_CHANGED, edge);
[ + - ]
2461 [ + - ][ + - ]: 836 : const_cast<CGMHistory&>(mHistory).add_event(evt);
2462 : : }
2463 : :
2464 [ + - ]: 76838 : return edge;
2465 : : }
2466 : :
2467 : :
2468 : 76217 : RefEntity *GeometryQueryTool::check_mergeable_refentity(GeometryEntity *bridge) const
2469 : : {
2470 : : // Disable for surfaces until we can correctly handle
2471 : : // surfaces that have virtual curves.
2472 : : // J.Kraftcheck Apr.29,2002
2473 : : // if( dynamic_cast<Surface*>(bridge) )
2474 : : // return 0;
2475 : :
2476 [ + - ][ + - ]: 76217 : if (CUBIT_FALSE == CGMApp::instance()->attrib_manager()->auto_actuate_flag(CA_MERGE_PARTNER))
[ + - ][ + + ]
2477 : 26798 : return NULL;
2478 : :
2479 : : // checks the topology bridge for a merge attribute, which might lead to another
2480 : : // refentity
2481 [ + - ]: 49419 : DLIList<CubitSimpleAttrib> csa_list;
2482 [ + - ][ + - ]: 49419 : const char* name = CGMApp::instance()->attrib_manager()->att_internal_name(CA_MERGE_PARTNER);
[ + - ]
2483 [ + - ][ + - ]: 49419 : bridge->get_simple_attribute(name, csa_list);
[ + - ]
2484 : :
2485 : 49419 : RefEntity *re_ptr = NULL;
2486 : :
2487 [ + - ][ + + ]: 49419 : if(csa_list.size() > 0)
2488 : : {
2489 [ + - ][ + - ]: 1116 : const CubitSimpleAttrib &csa_ptr = csa_list.size() ? csa_list.get() : CubitSimpleAttrib();
[ + - ][ + - ]
[ # # ]
2490 : :
2491 : : // from the csa, call CAMP to get the partner, if one exists
2492 : : // (and return it)
2493 [ + - ][ + - ]: 1116 : int merge_id = csa_ptr.int_data_list()[0];
2494 : :
2495 [ + - ][ + - ]: 1116 : if( importingSolidModel && CUBIT_FALSE == GSaveOpen::performingUndo &&
[ + - ]
2496 : 1116 : !mergeGloballyOnImport )
2497 : : {
2498 : : //if the merge id isn't already on some other entity already imported,
2499 : : //this entity doesn't have anybody to merge with...return NULL
2500 [ + - ][ + + ]: 1116 : if( !uidsOfImportingEnts.is_in_list( merge_id) )
2501 : : {
2502 [ + - ]: 558 : GeometryQueryTool::uidsOfImportingEnts.append( merge_id );
2503 : 558 : return NULL;
2504 : : }
2505 : : }
2506 : :
2507 : 558 : bool unique_append = false;
2508 [ - + ]: 558 : if( GeometryQueryTool::trackMergedAwayEnts )
2509 [ # # ]: 0 : unique_append = GeometryQueryTool::uidsOfImportingEnts.append_unique( merge_id );
2510 : :
2511 [ + - ]: 558 : ToolDataUser *tdu = TDUniqueId::find_td_unique_id(merge_id);
2512 [ - + ]: 558 : TopologyEntity *te = dynamic_cast<TopologyEntity*>(tdu);
2513 : :
2514 [ + - ]: 558 : CubitSense sense = CAMergePartner::get_bridge_sense( csa_ptr );
2515 : :
2516 : : //We found the merge partner.....
2517 [ + - ]: 558 : if (te != NULL)
2518 : : {
2519 : : //it's the first time you found this uid and you found an entity
2520 : : //
2521 [ - + ][ # # ]: 558 : if(GeometryQueryTool::trackMergedAwayEnts && unique_append )
2522 : 0 : GeometryQueryTool::entitiesMergedAway++;
2523 : :
2524 : : // assume this merge attrib will be actuated, so remove the csa
2525 [ + - ]: 558 : bridge->remove_simple_attribute_virt(csa_ptr);
2526 : :
2527 : : // now do the actual merge
2528 [ - + ]: 558 : re_ptr = dynamic_cast<RefEntity*> (te);
2529 : :
2530 : : //compare relative sense.....reverse bridges as necessary
2531 [ - + ]: 558 : Surface *surface = CAST_TO( bridge, Surface );
2532 [ - + ]: 558 : Curve *curve= CAST_TO( bridge, Curve );
2533 : 558 : CubitSense rel_sense = CUBIT_FORWARD;
2534 : :
2535 [ + - ]: 558 : CubitBoolean is_survivor = CAMergePartner::is_survivor( csa_ptr );
2536 [ + + ]: 558 : if( surface )
2537 : : {
2538 [ + - ][ + - ]: 82 : TopologyBridge *other_bridge = te->bridge_manager()->topology_bridge();
2539 [ - + ]: 82 : Surface *other_surface = CAST_TO( other_bridge, Surface );
2540 [ + - ]: 82 : rel_sense = relative_sense( surface, other_surface );
2541 : : }
2542 [ + + ]: 476 : else if( curve )
2543 : : {
2544 [ + - ][ + - ]: 268 : TopologyBridge *other_bridge = te->bridge_manager()->topology_bridge();
2545 [ - + ]: 268 : Curve *other_curve = CAST_TO( other_bridge, Curve );
2546 [ + - ]: 268 : rel_sense = curve->relative_sense( other_curve );
2547 : : }
2548 : :
2549 : : //non-surviving merged entity is here....reverse
2550 : : //its bridge sense so that it will merge
2551 [ + - ][ + - ]: 558 : if( !is_survivor && sense != CUBIT_UNKNOWN && rel_sense == CUBIT_REVERSED )
[ + + ]
2552 [ + - ]: 44 : bridge->reverse_bridge_sense();
2553 : : //surviving merged entity is now being restored....
2554 : : //reverse the ref entity and make this entity the primary one
2555 [ - + ]: 558 : if( is_survivor )
2556 : : {
2557 : : //If the passed in new bridge is the real survivor of the merge,
2558 : : //it should be the first bridge in the bridge manager. The first
2559 : : //bridge in the bridge manager is always FORWARD wrt the TE.
2560 : : // If this new bridge is reversed wrt the current first bridge,
2561 : : // reverse all the other bridges so that they will all merge
2562 : : //successfully with this new first bridge. Also add this new bridge
2563 : : //as the first bridge, since it was the original survivor.
2564 [ # # ]: 0 : if( rel_sense == CUBIT_REVERSED )
2565 : : {
2566 [ # # ]: 0 : te->reverse_topology();
2567 : :
2568 : : //reverse the sense of the bridges of this refentity
2569 [ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
2570 [ # # ][ # # ]: 0 : te->bridge_manager()->get_bridge_list( bridge_list );
2571 : :
2572 : : int kk;
2573 [ # # ][ # # ]: 0 : for( kk=bridge_list.size(); kk--; )
2574 : : {
2575 [ # # ]: 0 : TopologyBridge *tmp_bridge = bridge_list.get_and_step();
2576 [ # # ]: 0 : tmp_bridge->reverse_bridge_sense();
2577 [ # # ]: 0 : }
2578 : : }
2579 : :
2580 : : //add this bridge as the primary bridge
2581 [ # # ][ # # ]: 0 : te->bridge_manager()->add_bridge_as_representation(bridge);
2582 : : }
2583 : : else
2584 [ + - ][ + - ]: 558 : te->bridge_manager()->add_bridge(bridge);
2585 : : }
2586 : :
2587 : : // Set the merge sense of the bridge, if it is saved in the
2588 : : // attribute.
2589 [ + - ][ - + ]: 558 : if( re_ptr && sense == CUBIT_UNKNOWN )
2590 : : {
2591 [ # # ][ # # ]: 0 : TopologyBridge* first = te->bridge_manager()->topology_bridge();
2592 : : Curve* curve;
2593 : : Surface* surface;
2594 [ # # ][ # # ]: 0 : if( (curve = dynamic_cast<Curve*>(bridge) ) != NULL )
2595 : : {
2596 [ # # ]: 0 : Curve* first_curve = dynamic_cast<Curve*>(first);
2597 [ # # ]: 0 : assert(first_curve != NULL);
2598 [ # # ]: 0 : sense = first_curve->bridge_sense();
2599 [ # # ][ # # ]: 0 : if( first_curve->relative_sense(curve) == CUBIT_REVERSED )
2600 [ # # ]: 0 : sense = CubitUtil::opposite_sense(sense);
2601 : : }
2602 [ # # ][ # # ]: 0 : else if( (surface = dynamic_cast<Surface*>(bridge) ) != NULL )
2603 : : {
2604 [ # # ]: 0 : Surface* first_surf = dynamic_cast<Surface*>(first);
2605 [ # # ]: 0 : assert(first_surf != NULL);
2606 [ # # ]: 0 : sense = first_surf->bridge_sense();
2607 [ # # ][ # # ]: 0 : if( relative_sense( first_surf, surface ) == CUBIT_REVERSED )
2608 [ # # ]: 0 : sense = CubitUtil::opposite_sense(sense);
2609 : : }
2610 : : }
2611 : :
2612 [ + - ]: 558 : int id = CAMergePartner::get_saved_id( csa_ptr );
2613 [ + - ]: 558 : if (id)
2614 [ + - ][ + - ]: 1116 : bridge->set_saved_id( id );
[ + + ]
2615 : : }
2616 : :
2617 [ + - ]: 76217 : return re_ptr;
2618 : : }
2619 : :
2620 : : //-------------------------------------------------------------------------
2621 : : // Purpose : Find relative senes of two Surfaces
2622 : : //
2623 : : // Special Notes : Used when CAMergePartner attrib is too old to
2624 : : // contain sense information.
2625 : : //
2626 : : // Creator : Jason Kraftcheck
2627 : : //
2628 : : // Creation Date : 08/22/02
2629 : : //-------------------------------------------------------------------------
2630 : 82 : CubitSense GeometryQueryTool::relative_sense( Surface* surf1, Surface* surf2 )
2631 : : {
2632 [ + - ][ + - ]: 82 : CubitVector point1 = surf1->bounding_box().center();
[ + - ]
2633 [ + - ][ + - ]: 82 : CubitVector point2 = surf2->bounding_box().center();
[ + - ]
2634 [ + - ][ + - ]: 82 : CubitVector point = 0.5 * (point1 + point2);
2635 : :
2636 [ + - ][ + - ]: 82 : CubitVector closest1, closest2, normal1, normal2;
[ + - ][ + - ]
2637 [ + - ][ + - ]: 82 : surf1->closest_point_trimmed( point, closest1 );
2638 [ + - ]: 82 : surf2->closest_point( closest1, &closest2, &normal2 );
2639 [ + - ]: 82 : surf1->closest_point( closest2, &closest1, &normal1 );
2640 : :
2641 [ + - ][ + + ]: 82 : return normal1 % normal2 < 0 ? CUBIT_REVERSED : CUBIT_FORWARD;
2642 : : }
2643 : :
2644 : 153676 : RefVertex* GeometryQueryTool::make_RefVertex(TBPoint* point) const
2645 : : {
2646 : : // first, handle making the new RefVertex's; check for
2647 : : // existing chain afterwards
2648 : 153676 : RefVertex* vertex = 0;
2649 : :
2650 : : // First check to make sure we haven't already created a RefVertex
2651 : : // from this point
2652 : 153676 : TopologyEntity* topo = point->topology_entity();
2653 [ + + ]: 153676 : vertex = CAST_TO(topo, RefVertex);
2654 : :
2655 [ + + ]: 153676 : if ( vertex == NULL)
2656 : : {
2657 [ - + ]: 24570 : assert( topo == NULL );
2658 : 24570 : RefEntity *re_ptr = check_mergeable_refentity(point);
2659 [ + + ]: 24570 : if (re_ptr != NULL)
2660 : : {
2661 [ - + ]: 24570 : vertex = dynamic_cast<RefVertex*>(re_ptr);
2662 : : }
2663 : : }
2664 : :
2665 [ + + ]: 153676 : if (vertex == NULL)
2666 : : {
2667 : : // Create a RefVertex from this TBPoint.
2668 : 24362 : vertex = RefEntityFactory::instance()->construct_RefVertex(point);
2669 : : }
2670 [ - + ]: 153676 : assert(vertex != NULL);
2671 : :
2672 : 153676 : return vertex;
2673 : : }
2674 : :
2675 : :
2676 : :
2677 : : //-------------------------------------------------------------------------
2678 : : // Purpose : Build a free RefFace given a SurfaceSM.
2679 : : //
2680 : : // Special Notes : Purpose is to build a free surface. Entities are
2681 : : // added to the graphics.
2682 : : //
2683 : : // Creator : Steve Storm
2684 : : //
2685 : : // Creation Date : 3/27/99
2686 : : //-------------------------------------------------------------------------
2687 : 0 : RefFace* GeometryQueryTool::make_free_RefFace(Surface *surface_ptr,
2688 : : bool is_free_face ) const
2689 : : {
2690 : 0 : RefFace* ref_face_ptr = make_RefFace( surface_ptr );
2691 [ # # ]: 0 : if( !ref_face_ptr )
2692 : : {
2693 [ # # ][ # # ]: 0 : PRINT_ERROR("Failed to construct free RefFace.\n");
2694 [ # # ]: 0 : assert(!!ref_face_ptr);
2695 : 0 : return 0;
2696 : : }
2697 : :
2698 : : // Add the new ref_face to the graphics
2699 [ # # ]: 0 : if( is_free_face )
2700 : : {
2701 [ # # ][ # # ]: 0 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::FREE_REF_ENTITY_GENERATED, ref_face_ptr));
[ # # ][ # # ]
[ # # ]
2702 : :
2703 [ # # ][ # # ]: 0 : CGMHistory::Event evt(CGMHistory::TOP_LEVEL_ENTITY_CREATED, ref_face_ptr);
2704 [ # # ][ # # ]: 0 : const_cast<CGMHistory&>(mHistory).add_event(evt);
2705 : : }
2706 : :
2707 : 0 : return ref_face_ptr;
2708 : : }
2709 : :
2710 : : //-------------------------------------------------------------------------
2711 : : // Purpose : Build a free RefEdge given a CurveSM.
2712 : : //
2713 : : // Special Notes : Purpose is to build a free curve. Entities are
2714 : : // added to the graphics.
2715 : : //
2716 : : // Creator : Steve Storm
2717 : : //
2718 : : // Creation Date : 3/27/99
2719 : : //-------------------------------------------------------------------------
2720 : 418 : RefEdge* GeometryQueryTool::make_free_RefEdge(Curve *curve_ptr ) const
2721 : : {
2722 [ + - ]: 418 : RefEdge* ref_edge_ptr = make_RefEdge(curve_ptr);
2723 [ - + ]: 418 : if( !ref_edge_ptr )
2724 : : {
2725 [ # # ][ # # ]: 0 : PRINT_ERROR("Failed to construct free RefEdge.\n");
[ # # ][ # # ]
2726 [ # # ]: 0 : assert(!!ref_edge_ptr);
2727 : 0 : return 0;
2728 : : }
2729 : :
2730 [ + - ][ + - ]: 418 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::FREE_REF_ENTITY_GENERATED, ref_edge_ptr));
[ + - ][ + - ]
[ + - ]
2731 : :
2732 [ + - ][ + - ]: 418 : CGMHistory::Event evt(CGMHistory::TOP_LEVEL_ENTITY_CREATED, ref_edge_ptr);
2733 [ + - ]: 418 : const_cast<CGMHistory&>(mHistory).add_event(evt);
2734 : :
2735 [ + - ]: 418 : return ref_edge_ptr;
2736 : : }
2737 : :
2738 : : //-------------------------------------------------------------------------
2739 : : // Purpose : Build a free RefVertex given a PointSM.
2740 : : //
2741 : : // Special Notes : Purpose is to build a free vertex. Vertex
2742 : : // is added to the graphics.
2743 : : //
2744 : : // Creator : Steve Storm
2745 : : //
2746 : : // Creation Date : 3/27/99
2747 : : //-------------------------------------------------------------------------
2748 : 0 : RefVertex* GeometryQueryTool::make_free_RefVertex(TBPoint *point_ptr ) const
2749 : : {
2750 [ # # ]: 0 : RefVertex* ref_vertex_ptr = make_RefVertex( point_ptr );
2751 [ # # ]: 0 : if( !ref_vertex_ptr )
2752 : : {
2753 [ # # ][ # # ]: 0 : PRINT_ERROR("Failed to construct free RefVertex.\n");
[ # # ][ # # ]
2754 [ # # ]: 0 : assert(!!ref_vertex_ptr);
2755 : 0 : return 0;
2756 : : }
2757 : :
2758 : : // Add the new ref_vertex to the graphics
2759 [ # # ][ # # ]: 0 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::FREE_REF_ENTITY_GENERATED, ref_vertex_ptr));
[ # # ][ # # ]
[ # # ]
2760 : :
2761 [ # # ][ # # ]: 0 : CGMHistory::Event evt(CGMHistory::TOP_LEVEL_ENTITY_CREATED, ref_vertex_ptr);
2762 [ # # ]: 0 : const_cast<CGMHistory&>(mHistory).add_event(evt);
2763 : :
2764 [ # # ]: 0 : return ref_vertex_ptr;
2765 : : }
2766 : :
2767 : 187 : void GeometryQueryTool::delete_Body(DLIList<Body*>& body_list)
2768 : : {
2769 : 187 : body_list.reset();
2770 [ + + ]: 737 : for (int i = body_list.size(); i--; )
2771 : 550 : delete_Body(body_list.get_and_step());
2772 : 187 : }
2773 : :
2774 : : //-------------------------------------------------------------------------
2775 : : // Purpose : Delete a Body
2776 : : //
2777 : : // Special Notes :
2778 : : //
2779 : : // Creator : Jason Kraftcheck
2780 : : //
2781 : : // Creation Date : 09/24/03
2782 : : //-------------------------------------------------------------------------
2783 : 1190 : CubitStatus GeometryQueryTool::delete_Body( Body* body_ptr )
2784 : : {
2785 : 1190 : BodySM* bodysm = body_ptr->get_body_sm_ptr();
2786 [ - + ]: 1190 : if (!bodysm)
2787 : : {
2788 [ # # ][ # # ]: 0 : PRINT_ERROR("Body %d is invalid -- no attached BodySM.\n",body_ptr->id());
2789 : : }
2790 : : else
2791 : : {
2792 : : // Ask owning model engine to delete the TopologyBridges
2793 : 1190 : GeometryQueryEngine* gqe = bodysm->get_geometry_query_engine();
2794 : 1190 : gqe->delete_solid_model_entities(bodysm);
2795 : :
2796 : : // Clean up any virtual geometry that was on the body
2797 [ + - ][ + - ]: 3570 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ + - ][ + - ]
[ + + ]
2798 [ + - ][ + - ]: 2380 : (*itor)->clean_out_deactivated_geometry();
2799 : : }
2800 : :
2801 : : // Check if body actually got deleted.
2802 : 1190 : return destroy_dead_entity( body_ptr );
2803 : : }
2804 : :
2805 : : //-------------------------------------------------------------------------
2806 : : // Purpose : Delete a Body
2807 : : //
2808 : : // Special Notes : Checks if child entities are merged and regenerates
2809 : : // graphics for them. This is necessary when 2 merged
2810 : : // entities have been "force-merged", usually meaning they
2811 : : // are not spatially equal.
2812 : : //
2813 : : // Creator : Corey Ernst
2814 : : //
2815 : : // Creation Date : 08/25/04
2816 : : //-------------------------------------------------------------------------
2817 : 0 : CubitStatus GeometryQueryTool::delete_single_Body( Body* body_ptr )
2818 : : {
2819 [ # # ]: 0 : BodySM* bodysm = body_ptr->get_body_sm_ptr();
2820 [ # # ]: 0 : DLIList<RefEntity*> merged_children;
2821 [ # # ][ # # ]: 0 : DLIList<RefFace*> faces_to_reverse;
2822 [ # # ][ # # ]: 0 : DLIList<RefEdge*> edges_to_reverse;
2823 [ # # ]: 0 : if (!bodysm)
2824 : : {
2825 [ # # ][ # # ]: 0 : PRINT_ERROR("Body %d is invalid -- no attached BodySM.\n",body_ptr->id());
[ # # ][ # # ]
[ # # ]
2826 : : }
2827 : : else
2828 : : {
2829 : : //get all the child entities that have been merged
2830 [ # # ]: 0 : DLIList<RefEntity*> tmp_merged_children;
2831 [ # # ][ # # ]: 0 : MergeTool::instance()->contains_merged_children( body_ptr, tmp_merged_children );
2832 : :
2833 : : //get the owning bodies for each entity
2834 : : int i;
2835 [ # # ][ # # ]: 0 : for(i=tmp_merged_children.size(); i--;)
2836 : : {
2837 [ # # ]: 0 : RefEntity *ref_ent = tmp_merged_children.get_and_step();
2838 [ # # ]: 0 : TopologyEntity *tmp_entity = CAST_TO( ref_ent, TopologyEntity);
2839 [ # # ]: 0 : DLIList<Body*> body_list;
2840 [ # # ]: 0 : tmp_entity->bodies( body_list );
2841 : : //if 2 bodies own it, get body that is not "body_ptr"
2842 : : //for later graphics regeneration
2843 [ # # ][ # # ]: 0 : if( body_list.size() > 1 )
2844 : : {
2845 [ # # ][ # # ]: 0 : if( body_list.get() != body_ptr )
2846 [ # # ]: 0 : merged_children.append( ref_ent );
2847 [ # # ][ # # ]: 0 : else if( body_list.step_and_get() != body_ptr )
2848 [ # # ]: 0 : merged_children.append( ref_ent );
2849 : : }
2850 [ # # ]: 0 : }
2851 : :
2852 : : // if( tmp_merged_children.size() )
2853 : : // MergeTool::instance()->unmerge( body_ptr );
2854 : :
2855 : : //fix up merged children -- some might need to be reversed
2856 [ # # ][ # # ]: 0 : for(i=merged_children.size(); i--; )
2857 : : {
2858 [ # # ]: 0 : RefEntity *merged_child = merged_children.get_and_step();
2859 [ # # ]: 0 : BasicTopologyEntity *bte = static_cast<BasicTopologyEntity*>(merged_child);
2860 : :
2861 : : //get the first bridge of the entity
2862 [ # # ]: 0 : DLIList<TopologyBridge*> child_bridge_list;
2863 [ # # ][ # # ]: 0 : bte->bridge_manager()->get_bridge_list( child_bridge_list );
2864 [ # # ]: 0 : child_bridge_list.reset();
2865 [ # # ]: 0 : TopologyBridge *first_bridge = child_bridge_list.get_and_step();
2866 : :
2867 : : //if it is not the body we're deleting just continue
2868 [ # # ]: 0 : BodySM *owning_body = first_bridge->bodysm();
2869 [ # # ]: 0 : if( owning_body != bodysm )
2870 : 0 : continue;
2871 : :
2872 [ # # ]: 0 : RefFace *ref_face = CAST_TO( merged_child, RefFace );
2873 [ # # ]: 0 : if( ref_face )
2874 : : {
2875 [ # # ]: 0 : TopologyBridge *second_bridge = child_bridge_list.get_and_step();
2876 : :
2877 [ # # ][ # # ]: 0 : if( first_bridge->bridge_sense() != second_bridge->bridge_sense() )
[ # # ]
2878 [ # # ]: 0 : faces_to_reverse.append( ref_face );
2879 : 0 : continue;
2880 : : }
2881 [ # # ]: 0 : RefEdge *ref_edge = CAST_TO( merged_child, RefEdge );
2882 [ # # ]: 0 : if( ref_edge )
2883 : : {
2884 : : //get merged_child's first topology bridge
2885 [ # # ]: 0 : TopologyBridge *second_bridge = child_bridge_list.get_and_step();
2886 : :
2887 [ # # ]: 0 : Curve *first_curve = CAST_TO( first_bridge, Curve );
2888 [ # # ]: 0 : Curve *second_curve = CAST_TO( second_bridge, Curve );
2889 : :
2890 [ # # ]: 0 : CubitSense relative_sense = first_curve->relative_sense( second_curve );
2891 : :
2892 [ # # ]: 0 : if( relative_sense == CUBIT_REVERSED )
2893 [ # # ]: 0 : edges_to_reverse.append( ref_edge );
2894 [ # # ][ # # ]: 0 : continue;
2895 : : }
2896 : 0 : }
2897 : :
2898 : : // Ask owning model engine to delete the TopologyBridges
2899 [ # # ]: 0 : GeometryQueryEngine* gqe = bodysm->get_geometry_query_engine();
2900 [ # # ]: 0 : gqe->delete_solid_model_entities(bodysm);
2901 : :
2902 : :
2903 : : // Clean up any virtual geometry that was on the body
2904 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
2905 [ # # ][ # # ]: 0 : (*itor)->clean_out_deactivated_geometry();
[ # # ]
2906 : : }
2907 : :
2908 : : int i;
2909 [ # # ][ # # ]: 0 : for( i=faces_to_reverse.size(); i--; )
2910 [ # # ][ # # ]: 0 : faces_to_reverse.get_and_step()->reverse_normal();
2911 [ # # ][ # # ]: 0 : for( i=edges_to_reverse.size(); i--; )
2912 [ # # ][ # # ]: 0 : edges_to_reverse.get_and_step()->reverse_tangent();
2913 : :
2914 : : //regenerate graphics of merged entities
2915 [ # # ][ # # ]: 0 : for( i=merged_children.size(); i--; )
2916 : : {
2917 [ # # ]: 0 : RefEntity* child = merged_children.get_and_step();
2918 [ # # ][ # # ]: 0 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_TOPOLOGY_MODIFIED, child));
[ # # ][ # # ]
2919 [ # # ]: 0 : CGMHistory::Event evt2(CGMHistory::TOPOLOGY_CHANGED, child);
2920 [ # # ]: 0 : const_cast<CGMHistory&>(mHistory).add_event(evt2);
2921 [ # # ][ # # ]: 0 : CGMHistory::Event evt(CGMHistory::GEOMETRY_CHANGED, child);
2922 [ # # ]: 0 : const_cast<CGMHistory&>(mHistory).add_event(evt);
2923 [ # # ]: 0 : }
2924 : :
2925 : : // Check if body actually got deleted.
2926 [ # # ]: 0 : CubitStatus ret = destroy_dead_entity( body_ptr );
2927 : :
2928 : : // Send an unmerge event out for surfaces that were a part
2929 : : // of the body that was deleted. Do this after the above
2930 : : // call to destroy_dead_entity() so that the Body
2931 : : // pointer associated with the deleted volume will no
2932 : : // longer be referenced by the merged surface. This code
2933 : : // was added so that sidesets which are watching surface
2934 : : // modifications will know to update their data when
2935 : : // the body is deleted.
2936 [ # # ][ # # ]: 0 : for( i=merged_children.size(); i--; )
2937 : : {
2938 [ # # ][ # # ]: 0 : RefFace* child = CAST_TO(merged_children.get_and_step(), RefFace);
2939 [ # # ]: 0 : if(child)
2940 : : {
2941 [ # # ][ # # ]: 0 : UnMergeEvent unmerge_event( child, child );
[ # # ]
2942 [ # # ][ # # ]: 0 : AppUtil::instance()->send_event(unmerge_event );
[ # # ]
2943 : : }
2944 : : }
2945 : :
2946 [ # # ]: 0 : return ret;
2947 : : }
2948 : :
2949 : : //-------------------------------------------------------------------------
2950 : : // Purpose : Delete a RefEntity
2951 : : //
2952 : : // Special Notes :
2953 : : //
2954 : : // Creator : Jason Kraftcheck
2955 : : //
2956 : : // Creation Date : 09/24/03
2957 : : //-------------------------------------------------------------------------
2958 : 555 : CubitStatus GeometryQueryTool::delete_RefEntity( RefEntity* ref_entity_ptr )
2959 : : {
2960 [ - + ][ + + ]: 555 : if (Body* body = dynamic_cast<Body*>(ref_entity_ptr))
2961 : 214 : return delete_Body(body);
2962 : :
2963 [ - + ][ - + ]: 341 : if(RefFace* face = dynamic_cast<RefFace*>(ref_entity_ptr))
2964 : 0 : return delete_RefFace(face);
2965 : :
2966 [ - + ][ + - ]: 341 : if(RefEdge* edge = dynamic_cast<RefEdge*>(ref_entity_ptr))
2967 : 341 : return delete_RefEdge(edge);
2968 : :
2969 [ # # ][ # # ]: 0 : if(RefVertex* vtx = dynamic_cast<RefVertex*>(ref_entity_ptr))
2970 : 0 : return delete_RefVertex(vtx);
2971 [ # # ][ # # ]: 0 : PRINT_ERROR("Cannot delete entity of type '%s'\n", ref_entity_ptr->class_name());
2972 : 555 : return CUBIT_FAILURE;
2973 : : }
2974 : :
2975 : : //-------------------------------------------------------------------------
2976 : : // Purpose : Delete a RefFace
2977 : : //
2978 : : // Special Notes :
2979 : : //
2980 : : // Creator : Jason Kraftcheck
2981 : : //
2982 : : // Creation Date : 09/24/03
2983 : : //-------------------------------------------------------------------------
2984 : 0 : CubitStatus GeometryQueryTool::delete_RefFace( RefFace* ref_face )
2985 : : {
2986 : : // Get the list of Surfaces owned by the RefFace
2987 [ # # ]: 0 : BridgeManager* manager = ref_face->bridge_manager();
2988 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> bridge_list(manager->number_of_bridges());
2989 [ # # ]: 0 : manager->get_bridge_list(bridge_list);
2990 : :
2991 : : // Ask each Surface's owning engine to destroy the surface.
2992 [ # # ][ # # ]: 0 : while( bridge_list.size() )
2993 : : {
2994 [ # # ]: 0 : TopologyBridge* bridge = bridge_list.pop();
2995 [ # # ]: 0 : Surface* surface = dynamic_cast<Surface*>(bridge);
2996 [ # # ]: 0 : if (!surface)
2997 : : {
2998 [ # # ][ # # ]: 0 : PRINT_ERROR("RefFace %d is invalid -- attached TopologyBridge "
[ # # ][ # # ]
2999 [ # # ]: 0 : "is not a Surface.\n", ref_face->id());
3000 : 0 : continue;
3001 : : }
3002 : :
3003 [ # # ]: 0 : surface->get_geometry_query_engine()->
3004 [ # # ]: 0 : delete_solid_model_entities( surface );
3005 : : }
3006 : :
3007 : : // Clean up any virtual geometry that was on the surface
3008 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
3009 [ # # ][ # # ]: 0 : (*itor)->clean_out_deactivated_geometry();
3010 : :
3011 : : // Check if all the Surfaces got deleted.
3012 [ # # ][ # # ]: 0 : return destroy_dead_entity( ref_face );
3013 : : }
3014 : :
3015 : : //-------------------------------------------------------------------------
3016 : : // Purpose : Delete a RefEdge
3017 : : //
3018 : : // Special Notes :
3019 : : //
3020 : : // Creator : Jason Kraftcheck
3021 : : //
3022 : : // Creation Date : 09/24/03
3023 : : //-------------------------------------------------------------------------
3024 : 374 : CubitStatus GeometryQueryTool::delete_RefEdge( RefEdge* ref_edge )
3025 : : {
3026 : : // Get the list of Curves owned by the RefEdge
3027 [ + - ]: 374 : BridgeManager* manager = ref_edge->bridge_manager();
3028 [ + - ][ + - ]: 374 : DLIList<TopologyBridge*> bridge_list(manager->number_of_bridges());
3029 [ + - ]: 374 : manager->get_bridge_list(bridge_list);
3030 : :
3031 : : // Ask each Curve's owning engine to destroy the surface.
3032 [ + - ][ + + ]: 748 : while( bridge_list.size() )
3033 : : {
3034 [ + - ]: 374 : TopologyBridge* bridge = bridge_list.pop();
3035 [ - + ]: 374 : Curve* curve = dynamic_cast<Curve*>(bridge);
3036 [ - + ]: 374 : if (!curve)
3037 : : {
3038 [ # # ][ # # ]: 0 : PRINT_ERROR("RefEdge %d is invalid -- attached TopologyBridge "
[ # # ][ # # ]
3039 [ # # ]: 0 : "is not a Curve.\n", ref_edge->id());
3040 : 0 : continue;
3041 : : }
3042 : :
3043 [ + - ]: 374 : curve->get_geometry_query_engine()->
3044 [ + - ]: 374 : delete_solid_model_entities( curve );
3045 : : }
3046 : :
3047 : : // Clean up any virtual geometry that was on the curve
3048 [ + - ][ + - ]: 1122 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ + - ][ + - ]
[ + + ]
3049 [ + - ][ + - ]: 748 : (*itor)->clean_out_deactivated_geometry();
3050 : :
3051 : : // Check if all the curves got deleted.
3052 [ + - ][ + - ]: 374 : return destroy_dead_entity( ref_edge );
3053 : : }
3054 : :
3055 : : //-------------------------------------------------------------------------
3056 : : // Purpose : Delete a RefVertex
3057 : : //
3058 : : // Special Notes :
3059 : : //
3060 : : // Creator : Jason Kraftcheck
3061 : : //
3062 : : // Creation Date : 09/24/03
3063 : : //-------------------------------------------------------------------------
3064 : 22 : CubitStatus GeometryQueryTool::delete_RefVertex( RefVertex* ref_vertex )
3065 : : {
3066 : : // Get the list of Points owned by the RefVertex
3067 [ + - ]: 22 : BridgeManager* manager = ref_vertex->bridge_manager();
3068 [ + - ][ + - ]: 22 : DLIList<TopologyBridge*> bridge_list(manager->number_of_bridges());
3069 [ + - ]: 22 : manager->get_bridge_list(bridge_list);
3070 : :
3071 : : // Ask each Curve's owning engine to destroy the surface.
3072 [ + - ][ + + ]: 44 : while( bridge_list.size() )
3073 : : {
3074 [ + - ]: 22 : TopologyBridge* bridge = bridge_list.pop();
3075 [ - + ]: 22 : TBPoint* point = dynamic_cast<TBPoint*>(bridge);
3076 [ - + ]: 22 : if (!point)
3077 : : {
3078 [ # # ][ # # ]: 0 : PRINT_ERROR("RefVertex %d is invalid -- attached TopologyBridge "
[ # # ][ # # ]
3079 [ # # ]: 0 : "is not a Point.\n", ref_vertex->id());
3080 : 0 : continue;
3081 : : }
3082 : :
3083 [ + - ]: 22 : point->get_geometry_query_engine()->
3084 [ + - ]: 22 : delete_solid_model_entities( point );
3085 : : }
3086 : :
3087 : : // Clean up any virtual geometry that was on the Point
3088 [ + - ][ + - ]: 66 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ + - ][ + - ]
[ + + ]
3089 [ + - ][ + - ]: 44 : (*itor)->clean_out_deactivated_geometry();
3090 : :
3091 : : // Check if all the Points got deleted.
3092 [ + - ][ + - ]: 22 : return destroy_dead_entity( ref_vertex );
3093 : : }
3094 : :
3095 : : //Initialize all settings in this class
3096 : 874 : void GeometryQueryTool::initialize_settings()
3097 : : {
3098 : :
3099 : : SettingHandler::instance()->add_setting("Merge Tolerance",
3100 : : GeometryQueryTool::set_geometry_factor,
3101 : 874 : GeometryQueryTool::get_geometry_factor);
3102 : :
3103 : : SettingHandler::instance()->add_setting("Merge Test BBox",
3104 : : GeometryQueryTool::set_merge_test_bbox,
3105 : 874 : GeometryQueryTool::get_merge_test_bbox);
3106 : :
3107 : : SettingHandler::instance()->add_setting("Merge Test InternalSurf",
3108 : : GeometryQueryTool::set_merge_test_internal,
3109 : 874 : GeometryQueryTool::get_merge_test_internal);
3110 : :
3111 : : SettingHandler::instance()->add_setting("Facet BBox",
3112 : : GeometryQueryTool::set_facet_bbox,
3113 : 874 : GeometryQueryTool::get_facet_bbox);
3114 : 874 : }
3115 : :
3116 : : //-------------------------------------------------------------------------
3117 : : // Purpose : Constructor of the GeometryQueryTool class.
3118 : : //
3119 : : // Special Notes :
3120 : : //
3121 : : // Creator : Xuechen Liu
3122 : : //
3123 : : // Creation Date : 07/11/96
3124 : : //-------------------------------------------------------------------------
3125 [ + - ][ + - ]: 1748 : GeometryQueryTool::GeometryQueryTool(GeometryQueryEngine*gqe_ptr)
3126 : : {
3127 [ - + ][ # # ]: 874 : if (gqe_ptr != NULL) add_gqe(gqe_ptr);
3128 : 874 : }
3129 : :
3130 : : // ********** END PROTECTED FUNCTIONS **********
3131 : :
3132 : : // ********** BEGIN PRIVATE FUNCTIONS **********
3133 : :
3134 : :
3135 : 0 : void GeometryQueryTool::geom_debug( DLIList<TopologyEntity*> topo_list )
3136 : : {
3137 : : //This function was created March 1998 to assist in debugging
3138 : : //the unmerge command. When sufficient time has passed and
3139 : : //it is no longer needed, this function can be deleted.
3140 : : //SR Jankovich
3141 [ # # ]: 0 : for( int i = topo_list.size(); i > 0; i-- )
3142 : : {
3143 [ # # ]: 0 : TopologyEntity *topo_entity = topo_list.get_and_step();
3144 [ # # ]: 0 : if( !topo_entity )
3145 : 0 : return;
3146 [ # # ]: 0 : RefEntity *ref_entity = CAST_TO( topo_entity, RefEntity );
3147 [ # # ]: 0 : if( !ref_entity )
3148 : 0 : return;
3149 : :
3150 [ # # ][ # # ]: 0 : PRINT_INFO( "%s\n", ref_entity->entity_name().c_str() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3151 [ # # ]: 0 : DLIList<TopologyEntity*> next_topo_list;
3152 [ # # ]: 0 : next_topo_list.clean_out();
3153 : :
3154 [ # # ][ # # ]: 0 : if( CAST_TO( ref_entity, Body ) )
[ # # ]
3155 : : {
3156 : :
3157 [ # # ]: 0 : DLIList<CoVolume*> co_vol_list;
3158 [ # # ][ # # ]: 0 : if( !topo_entity->co_volumes( co_vol_list ) )
3159 : 0 : return;
3160 [ # # ][ # # ]: 0 : for( int j = co_vol_list.size(); j > 0; j-- )
3161 : : {
3162 [ # # ]: 0 : CoVolume *co_vol = co_vol_list.get_and_step();
3163 [ # # ][ # # ]: 0 : PRINT_INFO( " CoVolume %d (not id)\n",
[ # # ][ # # ]
3164 [ # # ]: 0 : co_vol_list.size() - j );
3165 : 0 : TopologyEntity *temp_topo = CAST_TO( co_vol, TopologyEntity );
3166 [ # # ]: 0 : if( !temp_topo )
3167 : 0 : return;
3168 [ # # ]: 0 : DLIList<RefVolume*> vol_list;
3169 [ # # ][ # # ]: 0 : if( !temp_topo->ref_volumes( vol_list ) )
3170 : 0 : return;
3171 [ # # ][ # # ]: 0 : for( int k = vol_list.size(); k > 0; k-- )
[ # # ][ # # ]
3172 : : {
3173 [ # # ]: 0 : RefVolume *vol = vol_list.get_and_step();
3174 [ # # ][ # # ]: 0 : PRINT_INFO( " %s\n", vol->entity_name().c_str() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3175 : 0 : TopologyEntity *next_topo = CAST_TO( vol, TopologyEntity );
3176 [ # # ]: 0 : next_topo_list.append( next_topo );
3177 : : }
3178 : 0 : }
3179 [ # # ][ # # ]: 0 : GeometryQueryTool::geom_debug( next_topo_list );
[ # # ][ # # ]
[ # # ]
3180 : : }
3181 [ # # ][ # # ]: 0 : else if( CAST_TO( ref_entity, RefVolume ) )
[ # # ]
3182 : : {
3183 [ # # ]: 0 : DLIList<Shell*> shell_list;
3184 [ # # ][ # # ]: 0 : if( !topo_entity->shells( shell_list ) )
3185 : 0 : return;
3186 [ # # ][ # # ]: 0 : for( int m = shell_list.size(); m > 0; m-- )
3187 : : {
3188 [ # # ]: 0 : Shell *shell = shell_list.get_and_step();
3189 [ # # ][ # # ]: 0 : PRINT_INFO( " Shell %d (not id)\n", shell_list.size() - m );
[ # # ][ # # ]
[ # # ]
3190 : 0 : TopologyEntity *group_topo = CAST_TO( shell, TopologyEntity );
3191 [ # # ]: 0 : if( !group_topo )
3192 : 0 : return;
3193 [ # # ]: 0 : DLIList<CoFace*> co_face_list;
3194 [ # # ][ # # ]: 0 : if( !group_topo->co_faces( co_face_list ) )
3195 : 0 : return;
3196 [ # # ][ # # ]: 0 : for( int j = co_face_list.size(); j > 0; j-- )
[ # # ][ # # ]
3197 : : {
3198 [ # # ]: 0 : CoFace *co_face = co_face_list.get_and_step();
3199 [ # # ][ # # ]: 0 : PRINT_INFO( " CoFace %d (not id)\n",
[ # # ][ # # ]
3200 [ # # ]: 0 : co_face_list.size() - j );
3201 : 0 : TopologyEntity *temp_topo = CAST_TO( co_face, TopologyEntity );
3202 [ # # ]: 0 : if( !temp_topo )
3203 : 0 : return;
3204 [ # # ]: 0 : DLIList<RefFace*> face_list;
3205 [ # # ][ # # ]: 0 : if( !temp_topo->ref_faces( face_list ) )
3206 : 0 : return;
3207 [ # # ][ # # ]: 0 : for( int k = face_list.size(); k > 0; k-- )
[ # # ][ # # ]
3208 : : {
3209 [ # # ]: 0 : RefFace *face = face_list.get_and_step();
3210 [ # # ][ # # ]: 0 : PRINT_INFO( " %s\n", face->entity_name().c_str() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3211 : 0 : TopologyEntity *next_topo = CAST_TO( face, TopologyEntity );
3212 [ # # ]: 0 : next_topo_list.append( next_topo );
3213 : : }
3214 : 0 : }
3215 : 0 : }
3216 [ # # ][ # # ]: 0 : GeometryQueryTool::geom_debug( next_topo_list );
[ # # ][ # # ]
[ # # ]
3217 : : }
3218 [ # # ][ # # ]: 0 : else if( CAST_TO( ref_entity, RefFace ) )
[ # # ]
3219 : : {
3220 [ # # ]: 0 : DLIList<Loop*> loop_list;
3221 [ # # ][ # # ]: 0 : if( !topo_entity->loops( loop_list ) )
3222 : 0 : return;
3223 [ # # ][ # # ]: 0 : for( int m = loop_list.size(); m > 0; m-- )
3224 : : {
3225 [ # # ]: 0 : Loop *loop = loop_list.get_and_step();
3226 [ # # ][ # # ]: 0 : PRINT_INFO( " Loop %d (not id)\n", loop_list.size() - m );
[ # # ][ # # ]
[ # # ]
3227 : 0 : TopologyEntity *group_topo = CAST_TO( loop, TopologyEntity );
3228 [ # # ]: 0 : if( !group_topo )
3229 : 0 : return;
3230 [ # # ]: 0 : DLIList<CoEdge*> co_edge_list;
3231 [ # # ][ # # ]: 0 : if( !group_topo->co_edges( co_edge_list ) )
3232 : 0 : return;
3233 [ # # ][ # # ]: 0 : for( int j = co_edge_list.size(); j > 0; j-- )
[ # # ][ # # ]
3234 : : {
3235 [ # # ]: 0 : CoEdge *co_edge = co_edge_list.get_and_step();
3236 [ # # ][ # # ]: 0 : PRINT_INFO( " CoEdge %d (not id)\n",
[ # # ][ # # ]
3237 [ # # ]: 0 : co_edge_list.size() - j );
3238 : 0 : TopologyEntity *temp_topo = CAST_TO( co_edge, TopologyEntity );
3239 [ # # ]: 0 : if( !temp_topo )
3240 : 0 : return;
3241 [ # # ]: 0 : DLIList<RefEdge*> edge_list;
3242 [ # # ][ # # ]: 0 : if( !temp_topo->ref_edges( edge_list ) )
3243 : 0 : return;
3244 [ # # ][ # # ]: 0 : for( int k = edge_list.size(); k > 0; k-- )
[ # # ][ # # ]
3245 : : {
3246 [ # # ]: 0 : RefEdge *edge = edge_list.get_and_step();
3247 [ # # ][ # # ]: 0 : PRINT_INFO( " %s\n", edge->entity_name().c_str() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3248 : 0 : TopologyEntity *next_topo = CAST_TO( edge, TopologyEntity );
3249 [ # # ]: 0 : next_topo_list.append( next_topo );
3250 : : }
3251 : 0 : }
3252 : 0 : }
3253 [ # # ][ # # ]: 0 : GeometryQueryTool::geom_debug( next_topo_list );
[ # # ][ # # ]
[ # # ]
3254 : : }
3255 [ # # ][ # # ]: 0 : else if( CAST_TO( ref_entity, RefEdge ) )
[ # # ]
3256 : : {
3257 [ # # ]: 0 : DLIList<Chain*> chain_list;
3258 [ # # ][ # # ]: 0 : if( !topo_entity->chains( chain_list ) )
3259 : 0 : return;
3260 [ # # ][ # # ]: 0 : for( int m = chain_list.size(); m > 0; m-- )
3261 : : {
3262 [ # # ]: 0 : Chain *chain = chain_list.get_and_step();
3263 [ # # ][ # # ]: 0 : PRINT_INFO( " Chain %d (not id)\n", chain_list.size() - m );
[ # # ][ # # ]
[ # # ]
3264 : 0 : TopologyEntity *group_topo = CAST_TO( chain, TopologyEntity );
3265 [ # # ]: 0 : if( !group_topo )
3266 : 0 : return;
3267 [ # # ]: 0 : DLIList<CoVertex*> co_vertex_list;
3268 [ # # ][ # # ]: 0 : if( !group_topo->co_vertices( co_vertex_list ) )
3269 : 0 : return;
3270 [ # # ][ # # ]: 0 : for( int j = co_vertex_list.size(); j > 0; j-- )
[ # # ][ # # ]
3271 : : {
3272 [ # # ]: 0 : CoVertex *co_vertex = co_vertex_list.get_and_step();
3273 [ # # ][ # # ]: 0 : PRINT_INFO( " CoVertex %d (not id)\n",
[ # # ][ # # ]
3274 [ # # ]: 0 : co_vertex_list.size() - j );
3275 : 0 : TopologyEntity *temp_topo = CAST_TO( co_vertex, TopologyEntity );
3276 [ # # ]: 0 : if( !temp_topo )
3277 : 0 : return;
3278 [ # # ]: 0 : DLIList<RefVertex*> vertex_list;
3279 [ # # ][ # # ]: 0 : if( !temp_topo->ref_vertices( vertex_list ) )
3280 : 0 : return;
3281 [ # # ][ # # ]: 0 : for( int k = vertex_list.size(); k > 0; k-- )
[ # # ][ # # ]
3282 : : {
3283 [ # # ]: 0 : RefVertex *vertex = vertex_list.get_and_step();
3284 [ # # ][ # # ]: 0 : PRINT_INFO( " %s\n",
[ # # ][ # # ]
[ # # ][ # # ]
3285 [ # # ]: 0 : vertex->entity_name().c_str() );
3286 : 0 : TopologyEntity *next_topo = CAST_TO( vertex, TopologyEntity );
3287 [ # # ]: 0 : next_topo_list.append( next_topo );
3288 : : }
3289 : 0 : }
3290 : 0 : }
3291 [ # # ][ # # ]: 0 : GeometryQueryTool::geom_debug( next_topo_list );
[ # # ][ # # ]
[ # # ]
3292 : : }
3293 [ # # ][ # # ]: 0 : else if( CAST_TO( ref_entity, RefVertex ) )
[ # # ]
3294 : : ;//Do nothing
3295 : : else
3296 [ # # ][ # # ]: 0 : PRINT_INFO( "UNKNOWN ENTITY TYPE!!!\n" );
[ # # ][ # # ]
[ # # ][ # # ]
3297 : 0 : }
3298 : : }
3299 : :
3300 : 0 : CubitBoolean GeometryQueryTool::about_spatially_equal (RefVertex* refVertex1,
3301 : : RefVertex* refVertex2,
3302 : : double tolerance_factor)
3303 : : {
3304 : 0 : return ( refVertex1->about_spatially_equal( refVertex2, tolerance_factor));
3305 : : }
3306 : :
3307 : 22214 : CubitBoolean GeometryQueryTool::about_spatially_equal (const CubitVector &vector1,
3308 : : const CubitVector &vector2,
3309 : : double tolerance_factor)
3310 : : {
3311 : 22214 : double tol = GEOMETRY_RESABS * tolerance_factor;
3312 : 22214 : tol *= tol;
3313 : 22214 : double dist_sq = vector1.distance_between_squared(vector2);
3314 : 22214 : return !(dist_sq > tol);
3315 : : // within_tolerance() just checks coordinate aligned distances, not the actual distance.
3316 : : // return (vector1.within_tolerance( vector2, GEOMETRY_RESABS * tolerance_factor ));
3317 : : }
3318 : :
3319 : 0 : double GeometryQueryTool::geometric_angle(RefEdge* ref_edge_1,
3320 : : RefEdge* ref_edge_2,
3321 : : RefFace* ref_face )
3322 : : {
3323 : : // calculates internal surface angles given 2 refedges on the surface
3324 : : CoEdge *co_edge_1, *co_edge_2;
3325 : : //First get the two coedges that corrispond to the edges sent into
3326 : : //this function. The two coedges are found from the ref_face's loop
3327 : : //where co_edge_1 is followed by co_edge_2 in the loop and co_edge_1 is
3328 : : //associated with ref_edge_1 while co_edge_2 is associated with
3329 : : //ref_edge_2.
3330 : : ref_edge_1->get_two_co_edges( ref_edge_2, ref_face, co_edge_1,
3331 [ # # ]: 0 : co_edge_2 );
3332 : :
3333 [ # # ]: 0 : return geometric_angle( co_edge_1, co_edge_2 );
3334 : : }
3335 : :
3336 : 264 : double GeometryQueryTool::geometric_angle(CoEdge* co_edge_1,
3337 : : CoEdge* co_edge_2 )
3338 : : {
3339 : :
3340 [ + - ]: 264 : RefEdge *ref_edge_1 = co_edge_1->get_ref_edge_ptr();
3341 [ + - ]: 264 : RefEdge *ref_edge_2 = co_edge_2->get_ref_edge_ptr();
3342 : :
3343 : : // return 2 pi for the tip of a hard line.
3344 [ + - ][ - + ]: 264 : if ( co_edge_1 != co_edge_2 && ref_edge_1 == ref_edge_2 )
3345 : 0 : return 2.0 * CUBIT_PI;
3346 : :
3347 : : RefVertex *ref_vertex =
3348 [ + - ]: 264 : co_edge_1->get_sense() == CUBIT_FORWARD ?
3349 : : ref_edge_1->end_vertex() :
3350 [ + + ][ + - ]: 264 : ref_edge_1->start_vertex();
[ + - ]
3351 : :
3352 : : //RefVertex *junk_vertex1 = ref_edge_2->start_vertex();
3353 : : //RefVertex *junk_vertex2 = ref_edge_2->end_vertex();
3354 : : //CubitSense junk_sense = co_edge_2->get_sense();
3355 : :
3356 [ + - ][ + + ]: 264 : assert( ref_vertex ==
[ + - ][ + - ]
3357 : : ( co_edge_2->get_sense() == CUBIT_FORWARD ?
3358 : : ref_edge_2->start_vertex() :
3359 [ - + ]: 264 : ref_edge_2->end_vertex() ) );
3360 : :
3361 : : // coordinates of common point
3362 [ + - ]: 264 : CubitVector vertex_point = ref_vertex->coordinates();
3363 : :
3364 : : // Find normal to the the face at the common vertex of
3365 : : // the refedges. Use loop sense to artificially switch inner loops.
3366 : : // Use intrinsic normal.
3367 [ + - ]: 264 : RefFace *ref_face = co_edge_1->get_ref_face();
3368 [ + - ]: 264 : CubitVector normal = ref_face->normal_at(vertex_point, NULL);
3369 : :
3370 : : // Find directed tangents to determine interior angle
3371 : : // Use sense of edge with respect to this face's loop.
3372 [ + - ][ + - ]: 264 : CubitVector tangent_1, tangent_2;
3373 [ + - ]: 264 : ref_edge_1->tangent( vertex_point, tangent_1 );
3374 [ + - ]: 264 : ref_edge_2->tangent( vertex_point, tangent_2 );
3375 : :
3376 [ + - ][ + + ]: 264 : if ( co_edge_1->get_sense() == CUBIT_REVERSED )
3377 [ + - ][ + - ]: 132 : tangent_1 = -tangent_1;
3378 [ + - ][ + + ]: 264 : if ( co_edge_2->get_sense() == CUBIT_REVERSED )
3379 [ + - ][ + - ]: 132 : tangent_2 = -tangent_2;
3380 : :
3381 : : // At this point we have the tangents going in the correct loop
3382 : : // sense.
3383 : : // Now get tangent pointing away from the center for the correct
3384 : : // angle
3385 [ + - ][ + - ]: 264 : tangent_1 = -tangent_1;
3386 : : // Return angle from given tangents and normal to face
3387 [ + - ]: 264 : double angle = normal.vector_angle( tangent_2, tangent_1 );
3388 [ - + ]: 264 : if ( angle*180.0/CUBIT_PI > 360.0 - GEOMETRY_RESABS )
3389 : : {
3390 : : //try other points to make sure this is going the right way.
3391 [ # # ][ # # ]: 0 : CubitVector new_loc_1, new_loc_2;
3392 [ # # ][ # # ]: 0 : if ( ref_edge_1->start_vertex() == ref_vertex )
3393 : : ref_edge_1->position_from_fraction(0.01,
3394 [ # # ]: 0 : new_loc_1);
3395 : : else
3396 : : ref_edge_1->position_from_fraction(0.99,
3397 [ # # ]: 0 : new_loc_1);
3398 [ # # ][ # # ]: 0 : if ( ref_edge_2->start_vertex() == ref_vertex )
3399 : : ref_edge_2->position_from_fraction(0.01,
3400 [ # # ]: 0 : new_loc_2);
3401 : : else
3402 : : ref_edge_2->position_from_fraction(0.99,
3403 [ # # ]: 0 : new_loc_2);
3404 : : //Now just do the exact same thing as above but
3405 : : //use these new points...
3406 [ # # ]: 0 : ref_edge_1->tangent( new_loc_1, tangent_1 );
3407 [ # # ]: 0 : ref_edge_2->tangent( new_loc_2, tangent_2 );
3408 : :
3409 [ # # ][ # # ]: 0 : if ( co_edge_1->get_sense() == CUBIT_REVERSED )
3410 [ # # ][ # # ]: 0 : tangent_1 = -tangent_1;
3411 [ # # ][ # # ]: 0 : if ( co_edge_2->get_sense() == CUBIT_REVERSED )
3412 [ # # ][ # # ]: 0 : tangent_2 = -tangent_2;
3413 [ # # ][ # # ]: 0 : tangent_1 = -tangent_1;
3414 : : // Return angle from given tangents and normal to face
3415 [ # # ]: 0 : angle = normal.vector_angle( tangent_2, tangent_1 );
3416 [ # # ]: 0 : if ( angle < CUBIT_PI )
3417 : 0 : angle = 0.0;
3418 : : else
3419 : 0 : angle = 2.0*CUBIT_PI;
3420 : : }
3421 : 264 : return angle;
3422 : : }
3423 : :
3424 : 0 : CubitString GeometryQueryTool::get_engine_version_string()
3425 : : {
3426 [ # # ]: 0 : if (gqeList.size())
3427 : : {
3428 : 0 : gqeList.reset();
3429 : 0 : return gqeList.get()->get_engine_version_string();
3430 : : }
3431 : : else
3432 : : {
3433 : 0 : return CubitString("No Active GeometryEngine");
3434 : : }
3435 : : }
3436 : :
3437 : : CubitBoolean
3438 : 0 : GeometryQueryTool::does_geom_contain_query_engine(DLIList<TopologyEntity*> &topo_list,
3439 : : GeometryQueryEngine *engine) const
3440 : : {
3441 : : GeometryQueryEngine *ge_ptr;
3442 [ # # ]: 0 : for( int i=topo_list.size(); i--; )
3443 : : {
3444 : 0 : ge_ptr = topo_list.get_and_step()->get_geometry_query_engine();
3445 [ # # ]: 0 : if( ge_ptr == engine )
3446 : : {
3447 : 0 : return CUBIT_TRUE;
3448 : : }
3449 : : }
3450 : :
3451 : 0 : return CUBIT_FALSE;
3452 : : }
3453 : :
3454 : : CubitBoolean
3455 : 0 : GeometryQueryTool::does_geom_contain_query_engine(DLIList<RefEntity*> &ref_entity_list,
3456 : : GeometryQueryEngine *engine,
3457 : : CubitBoolean children_too) const
3458 : : {
3459 [ # # ]: 0 : DLIList<RefEntity*> complete_entity_list;
3460 : :
3461 : : // Check the check_children option and check all the children if necessary
3462 [ # # ]: 0 : if (children_too)
3463 : : {
3464 : : //Make a complete list of all the RefEntitys and their children
3465 [ # # ]: 0 : DLIList<RefEntity*> temp = ref_entity_list;
3466 : : RefEntity* ref_entity_ptr;
3467 : : int i;
3468 [ # # ][ # # ]: 0 : for( i=ref_entity_list.size(); i--; )
3469 : : {
3470 [ # # ]: 0 : ref_entity_ptr = ref_entity_list.get_and_step();
3471 [ # # ]: 0 : complete_entity_list.clean_out();
3472 [ # # ]: 0 : ref_entity_ptr->get_all_child_ref_entities(complete_entity_list);
3473 [ # # ]: 0 : temp += complete_entity_list;
3474 : : }
3475 [ # # ]: 0 : complete_entity_list.clean_out();
3476 [ # # ][ # # ]: 0 : complete_entity_list.merge_unique(temp);
3477 : : }
3478 : :
3479 : : // Now check the RefEntities for the given geometry engine
3480 [ # # ][ # # ]: 0 : DLIList<TopologyEntity*> te_list;
3481 [ # # ][ # # ]: 0 : CAST_LIST(complete_entity_list, te_list, TopologyEntity);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3482 [ # # ][ # # ]: 0 : return does_geom_contain_query_engine(te_list, engine);
3483 : : }
3484 : :
3485 : 0 : TopologyEntity* GeometryQueryTool::entity_from_bridge( TopologyBridge* bridge_ptr ) const
3486 : : {
3487 [ # # ]: 0 : if( !bridge_ptr )
3488 : 0 : return NULL;
3489 : 0 : TBOwner* owner = bridge_ptr->owner();
3490 : : BridgeManager* bridge_manager;
3491 [ # # ][ # # ]: 0 : while (!(bridge_manager = dynamic_cast<BridgeManager*>(owner)))
3492 : : {
3493 [ # # ][ # # ]: 0 : if (TopologyBridge* bridge = dynamic_cast<TopologyBridge*>(owner))
3494 : 0 : owner = bridge->owner();
3495 [ # # ][ # # ]: 0 : else if(TBOwnerSet* set = dynamic_cast<TBOwnerSet*>(owner))
3496 : : {
3497 [ # # ]: 0 : DLIList<TopologyBridge*> list;
3498 [ # # ]: 0 : set->get_owners(list);
3499 [ # # ]: 0 : list.reset();
3500 [ # # ][ # # ]: 0 : owner = list.get()->owner();
[ # # ]
3501 : : }
3502 : : else
3503 : 0 : break;
3504 : : }
3505 : :
3506 [ # # ]: 0 : return bridge_manager ? bridge_manager->topology_entity() : 0;
3507 : : }
3508 : :
3509 : :
3510 : 253 : CubitStatus GeometryQueryTool::set_default_gqe(GeometryQueryEngine* gqe)
3511 : : {
3512 : : int i;
3513 [ + - ]: 275 : for (i = 0; i < gqeList.size(); i++)
3514 : : {
3515 [ + + ]: 275 : if(gqe == gqeList.get())
3516 : 253 : break;
3517 : :
3518 : 22 : gqeList.step();
3519 : : }
3520 : :
3521 [ - + ]: 253 : if(i == gqeList.size()) return CUBIT_FAILURE;
3522 : :
3523 : 253 : GeometryQueryEngine* temp_ptr = gqeList.get();
3524 : 253 : gqeList.remove();
3525 : 253 : gqeList.insert_first(temp_ptr);
3526 [ + - ][ + - ]: 253 : PRINT_INFO("Geometry engine set to: %s\n", gqe->get_engine_version_string().c_str() );
[ + - ][ + - ]
[ + - ]
3527 : 253 : return CUBIT_SUCCESS;
3528 : : }
3529 : :
3530 : 0 : CubitStatus GeometryQueryTool::set_export_allint_version(int version)
3531 : : {
3532 [ # # ]: 0 : if (gqeList.size())
3533 : : {
3534 : 0 : gqeList.reset();
3535 : 0 : return gqeList.get()->set_export_allint_version(version);
3536 : : }
3537 : : else
3538 : : {
3539 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.");
3540 : 0 : return CUBIT_FAILURE;
3541 : : }
3542 : : }
3543 : :
3544 : 0 : int GeometryQueryTool::get_allint_version()
3545 : : {
3546 [ # # ]: 0 : if (gqeList.size())
3547 : : {
3548 : 0 : gqeList.reset();
3549 : 0 : return gqeList.get()->get_allint_version();
3550 : : }
3551 : : else
3552 : : {
3553 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.");
3554 : 0 : return 0;
3555 : : }
3556 : : }
3557 : :
3558 : 0 : CubitStatus GeometryQueryTool::list_engine_versions(CubitString &versions)
3559 : : {
3560 [ # # ]: 0 : if (gqeList.size())
3561 : : {
3562 : 0 : gqeList.reset();
3563 : 0 : return gqeList.get()->list_engine_versions(versions);
3564 : : }
3565 : : else
3566 : : {
3567 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.");
3568 : 0 : return CUBIT_FAILURE;
3569 : : }
3570 : : }
3571 : :
3572 : 0 : double GeometryQueryTool::get_sme_resabs_tolerance()
3573 : : {
3574 [ # # ]: 0 : if (gqeList.size())
3575 : : {
3576 : 0 : gqeList.reset();
3577 : 0 : return gqeList.get()->get_sme_resabs_tolerance();
3578 : : }
3579 : : else
3580 : : {
3581 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.");
3582 : 0 : return 0.0;
3583 : : }
3584 : : }
3585 : :
3586 : 0 : double GeometryQueryTool::set_sme_resabs_tolerance( double new_resabs )
3587 : : {
3588 [ # # ]: 0 : if (gqeList.size())
3589 : : {
3590 : 0 : gqeList.reset();
3591 : 0 : return gqeList.get()->set_sme_resabs_tolerance( new_resabs );
3592 : : }
3593 : : else
3594 : : {
3595 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.");
3596 : 0 : return 0.0;
3597 : : }
3598 : : }
3599 : :
3600 : 0 : CubitStatus GeometryQueryTool::set_sme_int_option( const char* opt_name, int val )
3601 : : {
3602 [ # # ]: 0 : if (gqeList.size())
3603 : : {
3604 : 0 : gqeList.reset();
3605 : 0 : return gqeList.get()->set_int_option( opt_name, val );
3606 : : }
3607 : : else
3608 : : {
3609 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.");
3610 : 0 : return CUBIT_FAILURE;
3611 : : }
3612 : : }
3613 : :
3614 : 0 : CubitStatus GeometryQueryTool::set_sme_dbl_option( const char* opt_name, double val )
3615 : : {
3616 [ # # ]: 0 : if (gqeList.size())
3617 : : {
3618 : 0 : gqeList.reset();
3619 : 0 : return gqeList.get()->set_dbl_option( opt_name, val );
3620 : : }
3621 : : else
3622 : : {
3623 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.");
3624 : 0 : return CUBIT_FAILURE;
3625 : : }
3626 : : }
3627 : :
3628 : 0 : CubitStatus GeometryQueryTool::set_sme_str_option( const char* opt_name, const char* val )
3629 : : {
3630 [ # # ]: 0 : if (gqeList.size())
3631 : : {
3632 : 0 : gqeList.reset();
3633 : 0 : return gqeList.get()->set_str_option( opt_name, val );
3634 : : }
3635 : : else
3636 : : {
3637 [ # # ][ # # ]: 0 : PRINT_WARNING("No active geometry engine.");
3638 : 0 : return CUBIT_FAILURE;
3639 : : }
3640 : : }
3641 : :
3642 : 0 : CubitStatus GeometryQueryTool::get_intersections( RefEdge* ref_edge1,
3643 : : CubitVector& point1,
3644 : : CubitVector& point2,
3645 : : DLIList<CubitVector>& intersection_list,
3646 : : CubitBoolean bounded,
3647 : : CubitBoolean closest)
3648 : : {
3649 : 0 : Curve* curve_ptr1 = ref_edge1->get_curve_ptr();
3650 [ # # ]: 0 : if( curve_ptr1 == NULL )
3651 : : {
3652 [ # # ]: 0 : if( curve_ptr1 == NULL )
3653 [ # # ][ # # ]: 0 : PRINT_ERROR("Unable to retrieve underlying geometric entity of Curve %d\n" " This is a bug - please report it\n", ref_edge1->id() );
3654 : 0 : return CUBIT_FAILURE;
3655 : : }
3656 : :
3657 [ # # ]: 0 : if ( curve_ptr1->geometry_type() == STRAIGHT_CURVE_TYPE )
3658 : : {
3659 [ # # ]: 0 : CubitVector dir = point2 - point1;
3660 : : return straightline_intersections(ref_edge1, point1, dir,
3661 [ # # ]: 0 : intersection_list, bounded, closest);
3662 : : }
3663 : :
3664 : : GeometryQueryEngine* GQE_ptr =
3665 : 0 : curve_ptr1->get_geometry_query_engine();
3666 : : return GQE_ptr->get_intersections( curve_ptr1, point1, point2,
3667 : 0 : intersection_list, bounded, closest);
3668 : : }
3669 : :
3670 : 0 : CubitStatus GeometryQueryTool::straightline_intersections(RefEdge* ref_edge1,
3671 : : CubitVector & origin2,
3672 : : CubitVector & dir,
3673 : : DLIList<CubitVector> &intersection_list,
3674 : : CubitBoolean bounded ,
3675 : : CubitBoolean closest)
3676 : : {
3677 [ # # ]: 0 : Curve* curve_ptr1 = ref_edge1->get_curve_ptr();
3678 : :
3679 [ # # ]: 0 : if( curve_ptr1 == NULL )
3680 : : {
3681 [ # # ]: 0 : if( curve_ptr1 == NULL )
3682 [ # # ][ # # ]: 0 : PRINT_ERROR("Unable to retrieve underlying geometric entity of Curve %d\n" " This is a bug - please report it\n", ref_edge1->id() );
[ # # ][ # # ]
[ # # ]
3683 : 0 : return CUBIT_FAILURE;
3684 : : }
3685 : :
3686 [ # # ]: 0 : CubitVector dir2 = dir;
3687 [ # # ]: 0 : dir2.normalize();
3688 [ # # ][ # # ]: 0 : assert( curve_ptr1->geometry_type() == STRAIGHT_CURVE_TYPE );
3689 : : // Proceed with the intersection calculation
3690 [ # # ][ # # ]: 0 : CubitVector origin1, dir1;
3691 : : double origin_pnt1[3], dir_vec1[3], origin_pnt2[3], dir_vec2[3];
3692 : :
3693 [ # # ][ # # ]: 0 : if( ref_edge1->get_point_direction( origin1, dir1 ) == CUBIT_FAILURE )
3694 : : {
3695 [ # # ][ # # ]: 0 : PRINT_ERROR( "Unable to get straight line information for Curve %d; aborting\n",
[ # # ][ # # ]
3696 [ # # ]: 0 : ref_edge1->id() );
3697 : 0 : return CUBIT_FAILURE;
3698 : : }
3699 : :
3700 [ # # ][ # # ]: 0 : origin1.get_xyz( origin_pnt1 ); origin2.get_xyz( origin_pnt2 );
3701 [ # # ][ # # ]: 0 : dir1.get_xyz( dir_vec1 ); dir2.get_xyz( dir_vec2 );
3702 : :
3703 [ # # ]: 0 : AnalyticGeometryTool* agt = AnalyticGeometryTool::instance();
3704 : :
3705 : : int num_int;
3706 : : double int_pnt1[3], int_pnt2[3];
3707 : : num_int = agt->int_ln_ln( origin_pnt1, dir_vec1, origin_pnt2, dir_vec2,
3708 [ # # ]: 0 : int_pnt1, int_pnt2 );
3709 [ # # ][ # # ]: 0 : if( num_int == 0 || (closest == CUBIT_FALSE && num_int == 2) )
[ # # ]
3710 : : {
3711 [ # # ]: 0 : if( num_int == 0 )
3712 [ # # ][ # # ]: 0 : PRINT_ERROR( "Curves %d and the straight line defined by position %g, %g, %g, and direction %g, %g, %g are parallel - no intersection exists\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
3713 [ # # ]: 0 : ref_edge1->id(), origin2.x(), origin2.y(), origin2.z(), dir2.x(), dir2.y(), dir2.z());
3714 : :
3715 : : else
3716 [ # # ][ # # ]: 0 : PRINT_ERROR( "Curves %d and the straight line defined by position %g, %g, %g, and direction %g, %g, %g do not intersect\n", ref_edge1->id(),
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
3717 [ # # ]: 0 : origin2.x(), origin2.y(), origin2.z(), dir2.x(), dir2.y(), dir2.z());
3718 : 0 : return CUBIT_FAILURE;
3719 : : }
3720 : :
3721 [ # # ]: 0 : if( bounded == CUBIT_TRUE )
3722 : : {
3723 [ # # ][ # # ]: 0 : CubitVector start1 = ref_edge1->start_vertex()->coordinates();
3724 [ # # ][ # # ]: 0 : CubitVector end1 = ref_edge1->end_vertex()->coordinates();
3725 [ # # ]: 0 : CubitVector start2 = origin2;
3726 [ # # ]: 0 : CubitVector end2 = origin2 + dir;
3727 : :
3728 : : double start_pnt1[3], end_pnt1[3], start_pnt2[3], end_pnt2[3];
3729 [ # # ][ # # ]: 0 : start1.get_xyz( start_pnt1 ); start2.get_xyz( start_pnt2 );
3730 [ # # ][ # # ]: 0 : end1.get_xyz( end_pnt1 ); end2.get_xyz( end_pnt2 );
3731 : :
3732 [ # # ]: 0 : if( num_int == 1 )
3733 : : {
3734 : : // Vertex must be on both curves
3735 [ # # ][ # # ]: 0 : if( agt->is_pnt_on_ln_seg( int_pnt1, start_pnt1, end_pnt1 ) &&
[ # # ][ # # ]
3736 [ # # ]: 0 : agt->is_pnt_on_ln_seg( int_pnt2, start_pnt2, end_pnt2 ) )
3737 : : {
3738 [ # # ][ # # ]: 0 : intersection_list.append( CubitVector(int_pnt1) );
3739 : : }
3740 : : else
3741 : : {
3742 [ # # ][ # # ]: 0 : PRINT_WARNING( "intersection point of Curves was not within bounds of both curves\n");
[ # # ][ # # ]
3743 : : }
3744 : : }
3745 : : else
3746 : : {
3747 : : // Only keep the vertices that are on the curve bounds
3748 [ # # ][ # # ]: 0 : if( agt->is_pnt_on_ln_seg( int_pnt1, start_pnt1, end_pnt1 ) )
3749 : : {
3750 [ # # ][ # # ]: 0 : intersection_list.append( CubitVector(int_pnt1) );
3751 : : }
3752 : : else
3753 : : {
3754 [ # # ][ # # ]: 0 : PRINT_WARNING( "intersection point on Curve %d was not within it's bounds\n",
[ # # ][ # # ]
3755 [ # # ]: 0 : ref_edge1->id() );
3756 : : }
3757 [ # # ][ # # ]: 0 : if( agt->is_pnt_on_ln_seg( int_pnt2, start_pnt2, end_pnt2 ) )
3758 : : {
3759 [ # # ][ # # ]: 0 : intersection_list.append( CubitVector(int_pnt2) );
3760 : : }
3761 : : else
3762 : : {
3763 [ # # ][ # # ]: 0 : PRINT_WARNING( "intersection point on the straight line defined by position %g, %g, %g, and direction %g, %g, %g was not within it's bounds\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3764 [ # # ]: 0 : origin2.x(), origin2.y(), origin2.z(), dir2.x(), dir2.y(), dir2.z() );
3765 : : }
3766 : : }
3767 [ # # ][ # # ]: 0 : if( intersection_list.size() == 0 )
3768 : 0 : return CUBIT_FAILURE;
3769 : :
3770 : 0 : return CUBIT_SUCCESS;
3771 : : }
3772 : : else // Not bounded
3773 : : {
3774 [ # # ][ # # ]: 0 : intersection_list.append( CubitVector(int_pnt1) );
3775 [ # # ]: 0 : if( num_int == 2 )
3776 : : {
3777 [ # # ][ # # ]: 0 : intersection_list.append( CubitVector(int_pnt2) );
3778 : : }
3779 : 0 : return CUBIT_SUCCESS;
3780 : : }
3781 : : }
3782 : :
3783 : 0 : CubitStatus GeometryQueryTool::get_intersections( RefEdge* ref_edge1,
3784 : : RefEdge* ref_edge2,
3785 : : DLIList<CubitVector>& intersection_list,
3786 : : CubitBoolean bounded,
3787 : : CubitBoolean closest)
3788 : : {
3789 : : // If both curves are straight, compute their intersection; otherwise
3790 : : // use the geometry engine to do it.
3791 : 0 : CubitStatus status = CUBIT_FAILURE;
3792 [ # # ]: 0 : Curve* curve_ptr1 = ref_edge1->get_curve_ptr();
3793 [ # # ]: 0 : Curve* curve_ptr2 = ref_edge2->get_curve_ptr();
3794 : :
3795 [ # # ][ # # ]: 0 : if( curve_ptr1 == NULL || curve_ptr2 == NULL )
3796 : : {
3797 [ # # ]: 0 : if( curve_ptr1 == NULL )
3798 [ # # ][ # # ]: 0 : PRINT_ERROR("Unable to retrieve underlying geometric entity of Curve %d\n"
[ # # ][ # # ]
3799 [ # # ]: 0 : " This is a bug - please report it\n", ref_edge1->id() );
3800 [ # # ]: 0 : if( curve_ptr2 == NULL )
3801 [ # # ][ # # ]: 0 : PRINT_ERROR("Unable to retrieve underlying geometry entity of Curve %d\n"
[ # # ][ # # ]
3802 [ # # ]: 0 : " This is a bug - please report it\n", ref_edge2->id() );
3803 : 0 : return CUBIT_FAILURE;
3804 : : }
3805 : :
3806 [ # # ][ # # ]: 0 : if( curve_ptr1->geometry_type() == STRAIGHT_CURVE_TYPE &&
[ # # ][ # # ]
3807 [ # # ]: 0 : curve_ptr2->geometry_type() == STRAIGHT_CURVE_TYPE )
3808 : : {
3809 : : // Proceed with the intersection calculation
3810 [ # # ][ # # ]: 0 : CubitVector origin2, dir2;
3811 : :
3812 [ # # ][ # # ]: 0 : if( ref_edge2->get_point_direction( origin2, dir2 ) == CUBIT_FAILURE )
3813 : : {
3814 [ # # ][ # # ]: 0 : PRINT_ERROR( "Unable to get straight line information for Curve %d; aborting\n",
[ # # ][ # # ]
3815 [ # # ]: 0 : ref_edge2->id() );
3816 : 0 : return CUBIT_FAILURE;
3817 : : }
3818 : :
3819 [ # # ]: 0 : if (bounded)
3820 : : {
3821 [ # # ][ # # ]: 0 : origin2 = ref_edge2->start_vertex()->coordinates();
[ # # ]
3822 [ # # ][ # # ]: 0 : dir2 = ref_edge2->end_vertex()->coordinates() - origin2;
[ # # ][ # # ]
3823 : : }
3824 : : return straightline_intersections(ref_edge1, origin2, dir2,
3825 [ # # ]: 0 : intersection_list, bounded, closest);
3826 : : }
3827 : :
3828 [ # # ]: 0 : if( closest == CUBIT_TRUE )
3829 : : {
3830 [ # # ][ # # ]: 0 : PRINT_ERROR( "'Near' option only works for straight lines\n" );
[ # # ][ # # ]
3831 : 0 : return CUBIT_FAILURE;
3832 : : }
3833 : :
3834 : : // Use geometry engine to find intersections
3835 [ # # ]: 0 : DLIList<TopologyEntity*> entity_list(2);
3836 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> bridge_list(2);
3837 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> curve_list1, curve_list2;
[ # # ][ # # ]
3838 [ # # ]: 0 : entity_list.append(ref_edge1);
3839 [ # # ]: 0 : entity_list.append(ref_edge2);
3840 : :
3841 : : //if there's virtual edge, find the underlying real curve.
3842 [ # # ][ # # ]: 0 : if (ref_edge1->get_geometry_query_engine())
3843 [ # # ][ # # ]: 0 : ref_edge1->get_geometry_query_engine()->get_underlying_curves(curve_ptr1, curve_list1);
3844 [ # # ][ # # ]: 0 : if (ref_edge2->get_geometry_query_engine())
3845 [ # # ][ # # ]: 0 : ref_edge2->get_geometry_query_engine()->get_underlying_curves(curve_ptr2, curve_list2);
3846 : :
3847 [ # # ]: 0 : GeometryQueryEngine* gqe = common_query_engine( entity_list, bridge_list );
3848 : :
3849 : : //if they are both virtual...set gqe to NULL
3850 [ # # ][ # # ]: 0 : if( is_intermediate_geometry(curve_ptr1) && is_intermediate_geometry( curve_ptr2 ) )
[ # # ][ # # ]
[ # # ]
3851 : 0 : gqe = NULL;
3852 : :
3853 [ # # ][ # # ]: 0 : if( gqe == NULL && (curve_list1.size() > 0 || curve_list2.size() > 0) )
[ # # ][ # # ]
[ # # ][ # # ]
3854 : : {
3855 [ # # ][ # # ]: 0 : if (curve_list1.size() == 0)
3856 [ # # ]: 0 : curve_list1.append (CAST_TO(curve_ptr1, TopologyBridge));
3857 [ # # ][ # # ]: 0 : if (curve_list2.size() == 0)
3858 [ # # ]: 0 : curve_list2.append (CAST_TO(curve_ptr2, TopologyBridge));
3859 : : int i, j;
3860 [ # # ][ # # ]: 0 : for (i = 0; i <curve_list1.size(); i++)
3861 : : {
3862 [ # # ]: 0 : TopologyBridge * tb1 = curve_list1.get_and_step();
3863 [ # # ]: 0 : GeometryQueryEngine *gqe_ptr1 = tb1->get_geometry_query_engine();
3864 [ # # ]: 0 : curve_ptr1 = CAST_TO(tb1, Curve);
3865 : :
3866 [ # # ][ # # ]: 0 : for(j = 0; j< curve_list2.size(); j++)
3867 : : {
3868 [ # # ]: 0 : TopologyBridge * tb2 = curve_list2.get_and_step();
3869 [ # # ]: 0 : GeometryQueryEngine *gqe_ptr2 = tb2->get_geometry_query_engine();
3870 [ # # ][ # # ]: 0 : if (gqe_ptr1 && gqe_ptr1 == gqe_ptr2 )
3871 : : {
3872 [ # # ]: 0 : curve_ptr2 = CAST_TO(tb2, Curve);
3873 : : status = gqe_ptr1->get_intersections(curve_ptr1, curve_ptr2,
3874 [ # # ]: 0 : intersection_list, bounded, closest );
3875 : : }
3876 : : }
3877 : : }
3878 : :
3879 : : //remove duplicate intersections
3880 [ # # ][ # # ]: 0 : for( int k=0; k<intersection_list.size(); k++ )
3881 : : {
3882 [ # # ]: 0 : intersection_list.reset();
3883 [ # # ]: 0 : intersection_list.step(k+1);
3884 [ # # ][ # # ]: 0 : for( int s=k+1; s<intersection_list.size();)
3885 : : {
3886 [ # # ][ # # ]: 0 : if( intersection_list[k].distance_between( intersection_list[s] ) < GEOMETRY_RESABS )
[ # # ][ # # ]
3887 : : {
3888 [ # # ]: 0 : intersection_list.remove();
3889 : : }
3890 : : else
3891 : : {
3892 : 0 : s++;
3893 [ # # ]: 0 : intersection_list.step();
3894 : : }
3895 : : }
3896 : : }
3897 : :
3898 : 0 : return status;
3899 : : }
3900 : :
3901 [ # # ]: 0 : else if (gqe == NULL)
3902 : : {
3903 [ # # ][ # # ]: 0 : PRINT_ERROR( "Curves %d and %d do not have the same underlying geometry modeling engine\n"
[ # # ][ # # ]
[ # # ]
3904 : : " For intersection calculations, they must be the same\n",
3905 [ # # ]: 0 : ref_edge1->id(), ref_edge2->id() );
3906 : 0 : return CUBIT_FAILURE;
3907 : : }
3908 : :
3909 [ # # ]: 0 : bridge_list.reset();
3910 [ # # ][ # # ]: 0 : curve_ptr1 = dynamic_cast<Curve*>(bridge_list.next(0));
3911 [ # # ][ # # ]: 0 : curve_ptr2 = dynamic_cast<Curve*>(bridge_list.next(1));
3912 : : return gqe->get_intersections( curve_ptr1, curve_ptr2,
3913 [ # # ][ # # ]: 0 : intersection_list, bounded, closest );
3914 : : }
3915 : :
3916 : : CubitStatus
3917 : 0 : GeometryQueryTool::get_intersections( RefEdge* ref_edge, RefFace* ref_face,
3918 : : DLIList<CubitVector>& intersection_list,
3919 : : CubitBoolean bounded )
3920 : : {
3921 : : // Use geometry engine to find intersections
3922 [ # # ]: 0 : DLIList<TopologyEntity*> entity_list(2);
3923 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> bridge_list(2);
3924 [ # # ]: 0 : entity_list.append(ref_edge);
3925 [ # # ]: 0 : entity_list.append(ref_face);
3926 [ # # ]: 0 : GeometryQueryEngine* gqe = common_query_engine( entity_list, bridge_list );
3927 : :
3928 [ # # ]: 0 : if( gqe == NULL )
3929 : : {
3930 [ # # ][ # # ]: 0 : PRINT_ERROR( "Curve %d and Surface %d do not have the same underlying geometry query engine\n"
[ # # ][ # # ]
[ # # ]
3931 : : " For intersection calculations, they must be the same\n",
3932 [ # # ]: 0 : ref_edge->id(), ref_face->id() );
3933 : 0 : return CUBIT_FAILURE;
3934 : : }
3935 : :
3936 [ # # ]: 0 : bridge_list.reset();
3937 [ # # ][ # # ]: 0 : Curve* curve = dynamic_cast<Curve*>(bridge_list.next(0));
3938 [ # # ][ # # ]: 0 : Surface* surf = dynamic_cast<Surface*>(bridge_list.next(1));
3939 [ # # ][ # # ]: 0 : return gqe->get_intersections( curve, surf, intersection_list, bounded );
3940 : : }
3941 : :
3942 : : CubitStatus
3943 : 0 : GeometryQueryTool::get_intersections(RefEdge* ref_edge, CubitPlane plane,
3944 : : DLIList<CubitVector> &intersection_list,
3945 : : CubitBoolean bounded, double extended_percent )
3946 : : {
3947 [ # # ]: 0 : CubitBox box = ref_edge->bounding_box();
3948 : :
3949 : : // create a Surface from the plane
3950 [ # # ][ # # ]: 0 : CubitVector p1, p2, p3, p4;
[ # # ][ # # ]
3951 [ # # ][ # # ]: 0 : AnalyticGeometryTool::instance()->min_pln_box_int_corners(plane, box, 1, extended_percent, p1, p2, p3, p4, true );
3952 : :
3953 : 0 : TopologyBridge* bridge = 0;
3954 [ # # ][ # # ]: 0 : GeometryModifyEngine* gme = GeometryModifyTool::instance()->get_engine( ref_edge, &bridge );
3955 [ # # ]: 0 : BodySM* sheet = gme->planar_sheet(p1, p2, p3, p4);
3956 [ # # ]: 0 : if (!sheet)
3957 : : {
3958 [ # # ][ # # ]: 0 : PRINT_INFO("%s", "Unable to test for planar intersections\n");
[ # # ][ # # ]
3959 : 0 : return CUBIT_FAILURE;
3960 : : }
3961 : :
3962 [ # # ][ # # ]: 0 : DLIList<Surface*> surfaces;
3963 [ # # ]: 0 : sheet->surfaces( surfaces );
3964 : :
3965 [ # # ]: 0 : Curve* curve = ref_edge->get_curve_ptr();
3966 [ # # ]: 0 : GeometryQueryEngine* gqe = ref_edge->get_geometry_query_engine();
3967 [ # # ][ # # ]: 0 : CubitStatus status = gqe->get_intersections( curve, surfaces[0], intersection_list, bounded );
3968 : :
3969 [ # # ]: 0 : gqe->delete_solid_model_entities(sheet);
3970 : :
3971 [ # # ]: 0 : return status;
3972 : : }
3973 : :
3974 : : //===============================================================================
3975 : : // Function : entity_extrema
3976 : : // Member Type: PUBLIC
3977 : : // Description: Find extrema location on entity
3978 : : // Author : Steve Storm
3979 : : // Date : 11/02
3980 : : //===============================================================================
3981 : : CubitStatus
3982 : 0 : GeometryQueryTool::entity_extrema( RefEntity *ref_entity_ptr,
3983 : : const CubitVector *dir1,
3984 : : const CubitVector *dir2,
3985 : : const CubitVector *dir3,
3986 : : CubitVector &extrema,
3987 : : RefEntity *&extrema_entity_ptr )
3988 : : {
3989 [ # # ]: 0 : DLIList<RefEntity*> ref_entity_list;
3990 [ # # ]: 0 : ref_entity_list.append( ref_entity_ptr );
3991 : :
3992 : : return entity_extrema( ref_entity_list, dir1, dir2, dir3, extrema,
3993 [ # # ][ # # ]: 0 : extrema_entity_ptr );
3994 : : }
3995 : :
3996 : : //===============================================================================
3997 : : // Function : entity_extrema
3998 : : // Member Type: PUBLIC
3999 : : // Description: Find extrema location on a list of entities
4000 : : // Author : Steve Storm
4001 : : // Date : 11/02
4002 : : //===============================================================================
4003 : : CubitStatus
4004 : 0 : GeometryQueryTool::entity_extrema( DLIList<RefEntity*> &ref_entity_list,
4005 : : const CubitVector *dir1,
4006 : : const CubitVector *dir2,
4007 : : const CubitVector *dir3,
4008 : : CubitVector &extrema,
4009 : : RefEntity *&extrema_entity_ptr )
4010 : : {
4011 [ # # ][ # # ]: 0 : if( ref_entity_list.size() == 0 )
4012 : : {
4013 [ # # ][ # # ]: 0 : PRINT_ERROR( "No entities found for extrema calculation.\n" );
[ # # ][ # # ]
4014 : 0 : return CUBIT_FAILURE;
4015 : : }
4016 : :
4017 [ # # ][ # # ]: 0 : DLIList<TopologyEntity*> entity_list(ref_entity_list.size());
4018 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> bridge_list(ref_entity_list.size());
[ # # ]
4019 [ # # ][ # # ]: 0 : DLIList<RefVolume*> ref_vols;
4020 : : // Can only do BasicTopologyEntitys. Relace Bodys with RefVolumes.
4021 [ # # ]: 0 : ref_entity_list.reset();
4022 [ # # ][ # # ]: 0 : for (int i = ref_entity_list.size(); i--; )
4023 : : {
4024 [ # # ]: 0 : RefEntity* entity = ref_entity_list.get_and_step();
4025 [ # # ][ # # ]: 0 : if (BasicTopologyEntity* bte = dynamic_cast<BasicTopologyEntity*>(entity))
4026 : : {
4027 [ # # ]: 0 : entity_list.append(bte);
4028 : 0 : continue;
4029 : : }
4030 : :
4031 [ # # ][ # # ]: 0 : if (Body* body = dynamic_cast<Body*>(entity))
4032 : : {
4033 [ # # ]: 0 : ref_vols.clean_out();
4034 [ # # ]: 0 : body->ref_volumes(ref_vols);
4035 [ # # ]: 0 : ref_vols.reset();
4036 [ # # ][ # # ]: 0 : for (int j = ref_vols.size(); j--;)
4037 [ # # ][ # # ]: 0 : entity_list.append(ref_vols.get_and_step());
4038 : 0 : continue;
4039 : : }
4040 : :
4041 [ # # ][ # # ]: 0 : PRINT_ERROR("Don't know how to handle entity of type '%s' in "
[ # # ][ # # ]
4042 [ # # ]: 0 : "GQT::entity_extrema.\n", entity->class_name());
4043 : 0 : return CUBIT_FAILURE;
4044 : : }
4045 : :
4046 : :
4047 [ # # ]: 0 : GeometryQueryEngine* gqe = common_query_engine(entity_list, bridge_list);
4048 [ # # ]: 0 : if( gqe == NULL )
4049 : : {
4050 [ # # ][ # # ]: 0 : PRINT_ERROR( "Entities specified for extrema do not have the same\n"
[ # # ]
4051 : : " underlying geometry query engine.\n"
4052 [ # # ]: 0 : " For extrema calculations, they must be the same.\n" );
4053 : 0 : return CUBIT_FAILURE;
4054 : : }
4055 : :
4056 : : // Need GeometryEntities.
4057 [ # # ][ # # ]: 0 : DLIList<GeometryEntity*> geom_list(bridge_list.size());
[ # # ]
4058 [ # # ][ # # ]: 0 : CAST_LIST(bridge_list, geom_list, GeometryEntity);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
4059 : :
4060 : : // Check direction inputs
4061 [ # # ]: 0 : if( dir1 == NULL )
4062 : : {
4063 [ # # ][ # # ]: 0 : PRINT_ERROR( "Direction not found for extrema calculation - it is required.\n" );
[ # # ][ # # ]
4064 : 0 : return CUBIT_FAILURE;
4065 : : }
4066 [ # # ][ # # ]: 0 : if( dir2 == NULL && dir3 )
4067 : : {
4068 [ # # ][ # # ]: 0 : PRINT_ERROR( "Second direction not specified but last direction\n"
[ # # ]
4069 [ # # ]: 0 : " was - this is not allowed for extrema calculation.\n" );
4070 : 0 : return CUBIT_FAILURE;
4071 : : }
4072 : :
4073 : 0 : GeometryEntity* extrema_geom = 0;
4074 : : CubitStatus status = gqe->entity_extrema( geom_list, dir1, dir2, dir3,
4075 [ # # ]: 0 : extrema, extrema_geom );
4076 [ # # ][ # # ]: 0 : extrema_entity_ptr = dynamic_cast<RefEntity*>(entity_from_bridge(extrema_geom));
4077 [ # # ]: 0 : return status;
4078 : : }
4079 : :
4080 : : CubitStatus
4081 : 0 : GeometryQueryTool::entity_entity_distance( RefEntity *ref_entity_ptr1,
4082 : : RefEntity *ref_entity_ptr2,
4083 : : CubitVector &pos1, CubitVector &pos2,
4084 : : double &distance )
4085 : : {
4086 [ # # ]: 0 : DLIList<TopologyEntity*> entity_list(2);
4087 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> bridge_list(2);
4088 : :
4089 [ # # ]: 0 : BasicTopologyEntity* bte1 = dynamic_cast<BasicTopologyEntity*>(ref_entity_ptr1);
4090 [ # # ]: 0 : BasicTopologyEntity* bte2 = dynamic_cast<BasicTopologyEntity*>(ref_entity_ptr2);
4091 [ # # ][ # # ]: 0 : if (!bte1 || !bte2)
4092 : : {
4093 [ # # ][ # # ]: 0 : const char* name = bte2 ? ref_entity_ptr1->class_name() : ref_entity_ptr2->class_name();
[ # # ]
4094 [ # # ][ # # ]: 0 : PRINT_ERROR("Cannot calculate entity distance for entity of type '%s'\n", name);
[ # # ][ # # ]
4095 : 0 : return CUBIT_FAILURE;
4096 : : }
4097 : :
4098 [ # # ]: 0 : entity_list.append(bte1);
4099 [ # # ]: 0 : entity_list.append(bte2);
4100 [ # # ]: 0 : GeometryQueryEngine* gqe = common_query_engine(entity_list, bridge_list);
4101 [ # # ]: 0 : if( gqe == NULL )
4102 : : {
4103 [ # # ][ # # ]: 0 : PRINT_ERROR( "%s and %s do not have the same underlying geometry query engine.\n"
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
4104 : : " For distance calculations, they must be the same.\n",
4105 [ # # ]: 0 : ref_entity_ptr1->entity_name().c_str(), ref_entity_ptr2->entity_name().c_str() );
4106 : 0 : return CUBIT_FAILURE;
4107 : : }
4108 : :
4109 [ # # ]: 0 : bridge_list.reset();
4110 [ # # ][ # # ]: 0 : GeometryEntity* geom1 = dynamic_cast<GeometryEntity*>(bridge_list.next(0));
4111 [ # # ][ # # ]: 0 : GeometryEntity* geom2 = dynamic_cast<GeometryEntity*>(bridge_list.next(1));
4112 [ # # ][ # # ]: 0 : return gqe->entity_entity_distance( geom1, geom2, pos1, pos2, distance );
4113 : : }
4114 : :
4115 : : CubitStatus
4116 : 0 : GeometryQueryTool::entity_entity_distance( GeometryEntity *ge1,
4117 : : GeometryEntity *ge2,
4118 : : CubitVector &pos1, CubitVector &pos2,
4119 : : double &distance )
4120 : : {
4121 : 0 : GeometryQueryEngine *gqe1 = ge1->get_geometry_query_engine();
4122 : 0 : GeometryQueryEngine *gqe2 = ge2->get_geometry_query_engine();
4123 : :
4124 [ # # ]: 0 : if(gqe1 != gqe2)
4125 : : {
4126 [ # # ]: 0 : if(gqe1->is_intermediate_engine())
4127 : 0 : return gqe1->entity_entity_distance(ge1, ge2, pos1, pos2, distance);
4128 [ # # ]: 0 : else if(gqe2->is_intermediate_engine())
4129 : 0 : return gqe2->entity_entity_distance(ge1, ge2, pos1, pos2, distance);
4130 : : else
4131 : : {
4132 [ # # ]: 0 : PRINT_ERROR( "Entities do not have the same underlying geometry query engine.\n"
4133 [ # # ]: 0 : " For distance calculations, they must be the same.\n" );
4134 : 0 : return CUBIT_FAILURE;
4135 : : }
4136 : : }
4137 : : else
4138 : : {
4139 : 0 : return gqe1->entity_entity_distance(ge1, ge2, pos1, pos2, distance);
4140 : : }
4141 : : }
4142 : :
4143 : 22 : CubitBox GeometryQueryTool::bounding_box_of_bodies()
4144 : : {
4145 : 22 : CubitBox total_bound;
4146 : : int i;
4147 : :
4148 [ + - ][ + - ]: 22 : if(GeometryQueryTool::instance()->num_bodies() > 0)
[ + - ]
4149 : : {
4150 [ + - ][ + - ]: 22 : GeometryQueryTool::instance()->get_last_body();
4151 : : // Assign the first body's bounding box to total_bound
4152 [ + - ][ + - ]: 22 : total_bound = GeometryQueryTool::instance()->get_last_body()->bounding_box();
[ + - ][ + - ]
[ + - ]
4153 : :
4154 : : // Create union of all remaining bounding boxes
4155 [ + - ][ + - ]: 22 : for (i = GeometryQueryTool::instance()->num_bodies(); --i; )
[ - + ]
4156 [ # # ][ # # ]: 0 : total_bound |= GeometryQueryTool::instance()->get_next_body()->bounding_box();
[ # # ][ # # ]
[ # # ]
4157 : : }
4158 : : else
4159 : : {
4160 : : // Set the box to [(0,0,0)(0,0,0)]
4161 [ # # ]: 0 : CubitVector temp(0,0,0);
4162 [ # # ]: 0 : total_bound.reset(temp);
4163 : : }
4164 : : // Return the box
4165 : 22 : return total_bound;
4166 : : }
4167 : :
4168 : 5054 : void GeometryQueryTool::cleanout_deactivated_geometry ()
4169 : : {
4170 : :
4171 : :
4172 : : // This routine removes from the model all RefEntities that have been
4173 : : // deactivated
4174 [ - + ][ # # ]: 5054 : PRINT_DEBUG_17("\n\n...Cleaning out deactivated RefEntities "
4175 [ # # ]: 0 : "and asociated Mesh Entities from the model\n");
4176 : :
4177 : : // First delete the meshes associated with the deactivated RefEntities
4178 : : // delete_meshes_of_deactivated_refEntities();
4179 : :
4180 : : // Now delete the deactivated RefEntities and remove all traces
4181 : : // of them from the DAG
4182 : 5054 : DAG::instance()->cleanout_deactivated_DAG_nodes();
4183 : :
4184 : : // Leave gracefully :-)
4185 [ - + ][ # # ]: 5054 : PRINT_DEBUG_17(
4186 : : "Successfully cleaned out all deactivated RefEntities "
4187 [ # # ]: 0 : "and associated Mesh Entities from the model.\n");
4188 : :
4189 : 5054 : return;
4190 : : }
4191 : :
4192 : 332 : void GeometryQueryTool::delete_geometry ()
4193 : : {
4194 : :
4195 : 332 : CubitStatus status = CUBIT_FAILURE;
4196 : :
4197 : : // Delete all RefGroups
4198 : 332 : RefGroup::delete_all_groups();
4199 : 332 : Body* bodyPtr = NULL;
4200 : : //DLIList<Body*> bodyList;
4201 : : //GeometryQueryTool::instance()->bodies(bodyList);
4202 : : //bodyList.reset();
4203 : : //for ( i = bodyList.size(); i > 0; i--)
4204 : : //{
4205 : : // bodyPtr = bodyList.get_and_step();
4206 : :
4207 [ + + ]: 736 : while( (bodyPtr = GeometryQueryTool::instance()->get_last_body() ) != NULL )
4208 : : {
4209 : : // Now delete this Body and its underlying solid model entities
4210 : 404 : status = GeometryQueryTool::instance()->delete_Body( bodyPtr );
4211 [ - + ]: 404 : if (status == CUBIT_FAILURE)
4212 : : {
4213 [ # # ]: 0 : PRINT_ERROR("In GeometryQueryTool::delete_geometry\n"
4214 : : " Could not delete Body %d.\n"
4215 : : " The Model database is likely corrupted due"
4216 : : " to\n this unsuccessful deletion.\n",
4217 [ # # ]: 0 : bodyPtr->id() );
4218 [ # # ]: 0 : assert( status != CUBIT_FAILURE) ;
4219 : 0 : break;
4220 : : }
4221 : : }
4222 : :
4223 : : // Remove free-floating RefFaces
4224 : 332 : RefFace* refFacePtr = NULL;
4225 : : //DLIList<RefFace*> refFaceList;
4226 : : //GeometryQueryTool::instance()->ref_faces(refFaceList);
4227 : : //refFaceList.reset();
4228 : : //for ( i = refFaceList.size(); i > 0; i--)
4229 : : //{
4230 : : // refFacePtr = refFaceList.get_and_step();
4231 : :
4232 [ - + ]: 332 : while( (refFacePtr = GeometryQueryTool::instance()->get_last_ref_face() ) != NULL )
4233 : : {
4234 : : // NOTE-
4235 : : // The following GeometryQueryTool call results in a call to
4236 : : // the RefFace destructor which notifies the Model of
4237 : : // the destruction event. Model, in turn, removes the RefFace
4238 : : // pointer from refFaceList. Hence, the size of this list
4239 : : // changes inside this "while" loop.
4240 : 0 : status = GeometryQueryTool::instance()->delete_RefFace( refFacePtr );
4241 [ # # ]: 0 : if (status == CUBIT_FAILURE)
4242 : : {
4243 [ # # ]: 0 : PRINT_ERROR("In GeometryQueryTool::delete_geometry\n"
4244 : : " Could not delete RefFace %d.\n"
4245 : : " The Model database is likely corrupted "
4246 : : "due to\n this unsuccessful deletion.\n",
4247 [ # # ]: 0 : refFacePtr->id());
4248 [ # # ]: 0 : assert( status != CUBIT_FAILURE) ;
4249 : 0 : break;
4250 : : }
4251 : : }
4252 : :
4253 : : // Remove free-floating RefEdges
4254 : 332 : RefEdge* refEdgePtr = NULL;
4255 : : //DLIList<RefEdge*> refEdgeList;
4256 : : //GeometryQueryTool::instance()->ref_edges(refEdgeList);
4257 : : //refEdgeList.reset();
4258 : : //for ( i = refEdgeList.size(); i > 0; i--)
4259 : : //{
4260 : : // refEdgePtr = refEdgeList.get_and_step();
4261 : :
4262 [ + + ]: 354 : while( (refEdgePtr = GeometryQueryTool::instance()->get_last_ref_edge() ) != NULL )
4263 : : {
4264 : : // NOTE-
4265 : : // The following GeometryQueryTool call results in a call to
4266 : : // the RefEdge destructor which notifies the Model of
4267 : : // the destruction event. Model, in turn, removes the RefEdge
4268 : : // pointer from refEdgeList. Hence, the size of this list
4269 : : // changes inside this "while" loop.
4270 : 22 : status = GeometryQueryTool::instance()->delete_RefEdge( refEdgePtr );
4271 [ - + ]: 22 : if (status == CUBIT_FAILURE)
4272 : : {
4273 [ # # ]: 0 : PRINT_ERROR("In GeometryQueryTool::delete_geometry\n"
4274 : : " Could not delete RefEdge %d.\n"
4275 : : " The Model database is likely corrupted "
4276 : : "due to\n this unsuccessful deletion.\n",
4277 [ # # ]: 0 : refEdgePtr->id());
4278 [ # # ]: 0 : assert( status != CUBIT_FAILURE) ;
4279 : 0 : break;
4280 : : }
4281 : : }
4282 : :
4283 : : // Remove free-floating RefVertex'es
4284 : 332 : RefVertex* refVertexPtr = NULL;
4285 : : //DLIList<RefVertex*> refVertexList;
4286 : : //GeometryQueryTool::instance()->ref_vertices(refVertexList);
4287 : : //refVertexList.reset();
4288 : : //for ( i = refVertexList.size(); i > 0; i--)
4289 : : //{
4290 : : // refVertexPtr = refVertexList.get_and_step();
4291 : :
4292 [ + + ]: 343 : while( (refVertexPtr = GeometryQueryTool::instance()->get_last_ref_vertex() ) != NULL )
4293 : : {
4294 : : // NOTE-
4295 : : // The following GeometryQueryTool call results in a call to
4296 : : // the RefVertex destructor which notifies the Model of
4297 : : // the destruction event. Model, in turn, removes the RefVertex
4298 : : // pointer from refVertexList. Hence, the size of this list
4299 : : // changes inside this "while" loop.
4300 : 11 : status = GeometryQueryTool::instance()->delete_RefVertex( refVertexPtr );
4301 [ - + ]: 11 : if (status == CUBIT_FAILURE)
4302 : : {
4303 [ # # ]: 0 : PRINT_ERROR("In GeometryQueryTool::delete_geometry\n"
4304 : : " Could not delete RefVertex %d.\n"
4305 : : " The Model database is likely corrupted "
4306 : : "due to\n this unsuccessful deletion.\n",
4307 [ # # ]: 0 : refVertexPtr->id());
4308 [ # # ]: 0 : assert( status != CUBIT_FAILURE) ;
4309 : 0 : break;
4310 : : }
4311 : : }
4312 : :
4313 : :
4314 : : // reset counters
4315 : 332 : RefEntityFactory::instance()->reset_ids();
4316 : :
4317 : 332 : }
4318 : :
4319 : 5981 : CubitStatus GeometryQueryTool::ref_entity_list(char const* keyword,
4320 : : DLIList<RefEntity*> &entity_list,
4321 : : const CubitBoolean print_errors)
4322 : : {
4323 : 5981 : return RefEntityFactory::instance()->ref_entity_list(keyword, entity_list,
4324 : 5981 : print_errors);
4325 : : }
4326 : :
4327 : 111 : CubitBox GeometryQueryTool::model_bounding_box()
4328 : : {
4329 : : int i;
4330 [ + - ]: 111 : CubitBox result;
4331 [ + - ][ + - ]: 222 : DLIList<Body*> bodies;
4332 [ + - ]: 111 : this->bodies(bodies);
4333 : :
4334 [ + - ][ + - ]: 222 : DLIList<RefEntity*> free_entity_list;
4335 [ + - ]: 111 : this->get_free_ref_entities(free_entity_list);
4336 : :
4337 [ + - ][ + - ]: 111 : if (!(bodies.size() + free_entity_list.size()))
[ - + ]
4338 : 0 : return result;
4339 : :
4340 [ + - ]: 111 : bodies.reset();
4341 [ + - ]: 111 : free_entity_list.reset();
4342 : :
4343 [ + - ][ + - ]: 111 : if( bodies.size() )
4344 : : {
4345 [ + - ][ + - ]: 111 : result = bodies.get_and_step()->bounding_box();
[ + - ][ + - ]
4346 [ + - ][ + + ]: 302 : for ( i = bodies.size()-1; i--; )
4347 [ + - ][ + - ]: 191 : result |= bodies.get_and_step()->bounding_box();
[ + - ][ + - ]
4348 [ + - ]: 111 : i = free_entity_list.size();
4349 : : }
4350 : : else
4351 : : {
4352 [ # # ][ # # ]: 0 : result = free_entity_list.get_and_step()->bounding_box();
[ # # ][ # # ]
4353 [ # # ]: 0 : i = free_entity_list.size()-1;
4354 : : }
4355 : :
4356 [ - + ]: 111 : for ( ; i>0 ; i-- )
4357 [ # # ][ # # ]: 0 : result |= free_entity_list.get_and_step()->bounding_box();
[ # # ][ # # ]
4358 : :
4359 : 111 : return result;
4360 : : }
4361 : :
4362 : 419 : void GeometryQueryTool::bodies(DLIList<Body*> &bodies)
4363 : : {
4364 : 419 : RefEntityFactory::instance()->bodies(bodies);
4365 : 419 : }
4366 : :
4367 : 0 : void GeometryQueryTool::ref_volumes(DLIList<RefVolume*> &ref_volumes)
4368 : : {
4369 : 0 : RefEntityFactory::instance()->ref_volumes(ref_volumes);
4370 : 0 : }
4371 : :
4372 : 376 : void GeometryQueryTool::ref_groups(DLIList<RefGroup*> &ref_groups)
4373 : : {
4374 : 376 : RefEntityFactory::instance()->ref_groups(ref_groups);
4375 : 376 : }
4376 : :
4377 : 33 : void GeometryQueryTool::ref_faces(DLIList<RefFace*> &ref_faces)
4378 : : {
4379 : 33 : RefEntityFactory::instance()->ref_faces(ref_faces);
4380 : 33 : }
4381 : :
4382 : 77 : void GeometryQueryTool::ref_edges(DLIList<RefEdge*> &ref_edges)
4383 : : {
4384 : 77 : RefEntityFactory::instance()->ref_edges(ref_edges);
4385 : 77 : }
4386 : :
4387 : 22 : void GeometryQueryTool::ref_vertices(DLIList<RefVertex*> &ref_vertices)
4388 : : {
4389 : 22 : RefEntityFactory::instance()->ref_vertices(ref_vertices);
4390 : 22 : }
4391 : :
4392 : 0 : void GeometryQueryTool::get_ordered_loops(RefFace* face, DLIList<Loop*> &loop_list)
4393 : : {
4394 : 0 : GeometryQueryEngine *gqe = face->get_geometry_query_engine();
4395 : 0 : gqe->get_ordered_loops(face, loop_list);
4396 : 0 : }
4397 : :
4398 : : #ifdef PROE
4399 : : void GeometryQueryTool::ref_parts (DLIList<RefPart*> &ref_parts)
4400 : : {
4401 : : RefEntityFactory::instance()->ref_parts(ref_parts);
4402 : : }
4403 : :
4404 : : void GeometryQueryTool::ref_assemblies (DLIList<RefAssembly*> &ref_assemblies)
4405 : : {
4406 : : RefEntityFactory::instance()->ref_assemblies(ref_assemblies);
4407 : : }
4408 : : #endif
4409 : :
4410 : 885 : int GeometryQueryTool::num_bodies() const
4411 : : {
4412 : 885 : return RefEntityFactory::instance()->num_bodies();
4413 : : }
4414 : :
4415 : 55 : int GeometryQueryTool::num_ref_volumes() const
4416 : : {
4417 : 55 : return RefEntityFactory::instance()->num_ref_volumes();
4418 : : }
4419 : :
4420 : 11 : int GeometryQueryTool::num_ref_groups() const
4421 : : {
4422 : 11 : return RefEntityFactory::instance()->num_ref_groups();
4423 : : }
4424 : :
4425 : 819 : int GeometryQueryTool::num_ref_faces() const
4426 : : {
4427 : 819 : return RefEntityFactory::instance()->num_ref_faces();
4428 : : }
4429 : :
4430 : 819 : int GeometryQueryTool::num_ref_edges() const
4431 : : {
4432 : 819 : return RefEntityFactory::instance()->num_ref_edges();
4433 : : }
4434 : :
4435 : 819 : int GeometryQueryTool::num_ref_vertices() const
4436 : : {
4437 : 819 : return RefEntityFactory::instance()->num_ref_vertices();
4438 : : }
4439 : :
4440 : 5288 : RefEntity *GeometryQueryTool::get_ref_entity(const char *type, int id)
4441 : : {
4442 : 5288 : return RefEntityFactory::instance()->get_ref_entity(type, id);
4443 : : }
4444 : :
4445 : 0 : RefEntity *GeometryQueryTool::get_ref_entity(const std::type_info& type, int id)
4446 : : {
4447 : 0 : return RefEntityFactory::instance()->get_ref_entity(type, id);
4448 : : }
4449 : :
4450 : 0 : Body *GeometryQueryTool::get_body( int id)
4451 : : {
4452 : 0 : return RefEntityFactory::instance()->get_body(id);
4453 : : }
4454 : :
4455 : 0 : RefVolume *GeometryQueryTool::get_ref_volume( int id)
4456 : : {
4457 : 0 : return RefEntityFactory::instance()->get_ref_volume(id);
4458 : : }
4459 : :
4460 : 0 : RefGroup *GeometryQueryTool::get_ref_group( int id)
4461 : : {
4462 : 0 : return RefEntityFactory::instance()->get_ref_group(id);
4463 : : }
4464 : :
4465 : 0 : RefFace *GeometryQueryTool::get_ref_face( int id)
4466 : : {
4467 : 0 : return RefEntityFactory::instance()->get_ref_face(id);
4468 : : }
4469 : :
4470 : 0 : RefEdge *GeometryQueryTool::get_ref_edge( int id)
4471 : : {
4472 : 0 : return RefEntityFactory::instance()->get_ref_edge(id);
4473 : : }
4474 : :
4475 : 0 : RefVertex *GeometryQueryTool::get_ref_vertex( int id)
4476 : : {
4477 : 0 : return RefEntityFactory::instance()->get_ref_vertex(id);
4478 : : }
4479 : :
4480 : 0 : Body *GeometryQueryTool::get_first_body()
4481 : : {
4482 : 0 : return RefEntityFactory::instance()->get_first_body();
4483 : : }
4484 : :
4485 : 0 : RefVolume *GeometryQueryTool::get_first_ref_volume()
4486 : : {
4487 : 0 : return RefEntityFactory::instance()->get_first_ref_volume();
4488 : : }
4489 : :
4490 : 0 : RefGroup *GeometryQueryTool::get_first_ref_group()
4491 : : {
4492 : 0 : return RefEntityFactory::instance()->get_first_ref_group();
4493 : : }
4494 : :
4495 : 0 : RefFace *GeometryQueryTool::get_first_ref_face()
4496 : : {
4497 : 0 : return RefEntityFactory::instance()->get_first_ref_face();
4498 : : }
4499 : :
4500 : 0 : RefEdge *GeometryQueryTool::get_first_ref_edge()
4501 : : {
4502 : 0 : return RefEntityFactory::instance()->get_first_ref_edge();
4503 : : }
4504 : :
4505 : 0 : RefVertex *GeometryQueryTool::get_first_ref_vertex()
4506 : : {
4507 : 0 : return RefEntityFactory::instance()->get_first_ref_vertex();
4508 : : }
4509 : :
4510 : 0 : Body *GeometryQueryTool::get_next_body()
4511 : : {
4512 : 0 : return RefEntityFactory::instance()->get_next_body();
4513 : : }
4514 : :
4515 : 0 : RefVolume *GeometryQueryTool::get_next_ref_volume()
4516 : : {
4517 : 0 : return RefEntityFactory::instance()->get_next_ref_volume();
4518 : : }
4519 : :
4520 : 0 : RefGroup *GeometryQueryTool::get_next_ref_group()
4521 : : {
4522 : 0 : return RefEntityFactory::instance()->get_next_ref_group();
4523 : : }
4524 : :
4525 : 0 : RefFace *GeometryQueryTool::get_next_ref_face()
4526 : : {
4527 : 0 : return RefEntityFactory::instance()->get_next_ref_face();
4528 : : }
4529 : :
4530 : 0 : RefEdge *GeometryQueryTool::get_next_ref_edge()
4531 : : {
4532 : 0 : return RefEntityFactory::instance()->get_next_ref_edge();
4533 : : }
4534 : :
4535 : 0 : RefVertex *GeometryQueryTool::get_next_ref_vertex()
4536 : : {
4537 : 0 : return RefEntityFactory::instance()->get_next_ref_vertex();
4538 : : }
4539 : :
4540 : :
4541 : 780 : Body *GeometryQueryTool::get_last_body()
4542 : : {
4543 : 780 : return RefEntityFactory::instance()->get_last_body();
4544 : : }
4545 : :
4546 : 0 : RefVolume *GeometryQueryTool::get_last_ref_volume()
4547 : : {
4548 : 0 : return RefEntityFactory::instance()->get_last_ref_volume();
4549 : : }
4550 : :
4551 : 11 : RefGroup *GeometryQueryTool::get_last_ref_group()
4552 : : {
4553 : 11 : return RefEntityFactory::instance()->get_last_ref_group();
4554 : : }
4555 : :
4556 : 332 : RefFace *GeometryQueryTool::get_last_ref_face()
4557 : : {
4558 : 332 : return RefEntityFactory::instance()->get_last_ref_face();
4559 : : }
4560 : :
4561 : 354 : RefEdge *GeometryQueryTool::get_last_ref_edge()
4562 : : {
4563 : 354 : return RefEntityFactory::instance()->get_last_ref_edge();
4564 : : }
4565 : :
4566 : 343 : RefVertex *GeometryQueryTool::get_last_ref_vertex()
4567 : : {
4568 : 343 : return RefEntityFactory::instance()->get_last_ref_vertex();
4569 : : }
4570 : :
4571 : 517 : CubitStatus GeometryQueryTool::get_free_ref_entities(DLIList<RefEntity*> &free_entities)
4572 : : {
4573 : : // go through the global entity lists looking for free entities
4574 : :
4575 : : // this algorithm works as follows: start by marking all entities in the model;
4576 : : // - bodies that don't have virtual children are NOT free, along with their children;
4577 : : // unmark them all
4578 : : // - for all remaining entities:
4579 : : // . entities that are unmarked are not free since they were unmarked during the
4580 : : // body check
4581 : : // . entities that are virtual are not free, but their underlying entities may be;
4582 : : // check this, and unmark the underlying non-free entities, but not their children
4583 : : // . entities that don't have a TopologyBridge connected to a bodysm are free
4584 : : //
4585 : : // - Removed virtual stuff - no longer required - J.Kraftcheck 10-8-2003
4586 : :
4587 : : int i, j;
4588 [ + - ]: 517 : RefEntityFactory *REF = RefEntityFactory::instance();
4589 : :
4590 : : // define a macro to mark all the children
4591 : : #define MARK_CHILDREN(entity, index) \
4592 : : {ref_list.clean_out(); entity->get_all_child_ref_entities(ref_list); \
4593 : : for (index=ref_list.size(); index>0; index--) ref_list.get_and_step()->marked(0);}
4594 : :
4595 : : // mark all entities first
4596 [ + - ][ + + ]: 1321 : for (i = REF->num_ref_volumes(); i > 0; i--)
4597 [ + - ][ + - ]: 804 : REF->get_next_ref_volume()->marked(1);
4598 [ + - ][ + + ]: 5180 : for (i = REF->num_ref_faces(); i > 0; i--)
4599 [ + - ][ + - ]: 4663 : REF->get_next_ref_face()->marked(1);
4600 [ + - ][ + + ]: 12485 : for (i = REF->num_ref_edges(); i > 0; i--)
4601 [ + - ][ + - ]: 11968 : REF->get_next_ref_edge()->marked(1);
4602 [ + - ][ + + ]: 9925 : for (i = REF->num_ref_vertices(); i > 0; i--)
4603 [ + - ][ + - ]: 9408 : REF->get_next_ref_vertex()->marked(1);
4604 : :
4605 [ + - ]: 517 : DLIList<RefEntity*> ref_list;
4606 : :
4607 : : // first, mark all the children of bodies
4608 : : Body *body;
4609 [ + - ][ + + ]: 1288 : for (i = REF->num_bodies(); i > 0; i--) {
4610 [ + - ]: 771 : body = REF->get_next_body();
4611 [ + - ][ + - ]: 26585 : MARK_CHILDREN(body, j);
[ + - ][ + - ]
[ + - ][ + + ]
4612 : : }
4613 : :
4614 : : // now go through them, checking for VG and free entities
4615 : : RefVolume *volume;
4616 [ + - ][ + + ]: 1321 : for (i = REF->num_ref_volumes(); i > 0; i--) {
4617 [ + - ]: 804 : volume = REF->get_next_ref_volume();
4618 [ + - ][ - + ]: 804 : if (volume->marked()) {
4619 : : // go through volume's children & unmark
4620 [ # # ][ # # ]: 0 : MARK_CHILDREN(volume, j);
[ # # ][ # # ]
[ # # ][ # # ]
4621 [ # # ][ # # ]: 0 : free_entities.append(volume);
4622 [ # # ]: 0 : volume->marked(0);
4623 : : }
4624 : : }
4625 : :
4626 : : RefFace *face;
4627 [ + - ][ + + ]: 5180 : for (i = REF->num_ref_faces(); i > 0; i--) {
4628 [ + - ]: 4663 : face = REF->get_next_ref_face();
4629 [ + - ][ - + ]: 4663 : if (face->marked()) {
4630 [ # # ][ # # ]: 0 : MARK_CHILDREN(face, j);
[ # # ][ # # ]
[ # # ][ # # ]
4631 [ # # ][ # # ]: 0 : free_entities.append(face);
4632 [ # # ]: 0 : face->marked(0);
4633 : : }
4634 : : }
4635 : :
4636 : : RefEdge *edge;
4637 [ + - ][ + + ]: 12485 : for (i = REF->num_ref_edges(); i > 0; i--) {
4638 [ + - ]: 11968 : edge = REF->get_next_ref_edge();
4639 [ + - ][ + + ]: 11968 : if (edge->marked()) {
4640 [ + - ][ + - ]: 2112 : MARK_CHILDREN(edge, j);
[ + - ][ + - ]
[ + - ][ + + ]
4641 [ + - ][ + - ]: 704 : free_entities.append(edge);
4642 [ + - ]: 704 : edge->marked(0);
4643 : : }
4644 : : }
4645 : :
4646 : : RefVertex *vertex;
4647 [ + - ][ + + ]: 9925 : for (i = REF->num_ref_vertices(); i > 0; i--) {
4648 [ + - ]: 9408 : vertex = REF->get_next_ref_vertex();
4649 [ + - ][ + + ]: 9408 : if (vertex->marked()) {
4650 [ + - ][ + - ]: 77 : free_entities.append(vertex);
4651 [ + - ]: 77 : vertex->marked(0);
4652 : : }
4653 : : }
4654 : :
4655 [ + - ]: 517 : return CUBIT_SUCCESS;
4656 : : }
4657 : :
4658 : :
4659 : 0 : double GeometryQueryTool::surface_angle(RefFace *ref_face_1, RefFace *ref_face_2,
4660 : : RefEdge *ref_edge,
4661 : : RefVolume *ref_volume,
4662 : : double frac)
4663 : : {
4664 : :
4665 : : // check for and supply missing ref edge if necessary
4666 [ # # ]: 0 : if (ref_edge == NULL) {
4667 [ # # ]: 0 : ref_edge = ref_face_1->common_ref_edge(ref_face_2);
4668 [ # # ]: 0 : assert (ref_edge != NULL);
4669 : : }
4670 : :
4671 [ # # ]: 0 : if (ref_volume == NULL) {
4672 [ # # ]: 0 : ref_volume = ref_face_1->common_ref_volume(ref_face_2);
4673 [ # # ]: 0 : assert(ref_volume != NULL);
4674 : : }
4675 : :
4676 : : //Find the dihedral angle for the ref_edge
4677 [ # # ]: 0 : CubitVector mid_point;
4678 [ # # ]: 0 : if ( frac != .5 )
4679 [ # # ]: 0 : ref_edge->position_from_fraction(frac, mid_point);
4680 : : else
4681 [ # # ][ # # ]: 0 : mid_point = ref_edge->center_point();
4682 : :
4683 : :
4684 : : //Now find the normals of the surfaces at this point, wrt volume
4685 [ # # ]: 0 : CubitVector surf_1_norm = ref_face_1->normal_at( mid_point, ref_volume );
4686 [ # # ]: 0 : CubitVector surf_2_norm = ref_face_2->normal_at( mid_point, ref_volume );
4687 : :
4688 : : //Now we need to get the correct normal
4689 [ # # ]: 0 : CubitVector tangent_vector;
4690 : :
4691 : : //This gets the correct tangent with respect for to the
4692 : : //ref_face_ptr. Do the following check for non-manifold volumes.
4693 : : //This function will assert if the ref_edge has more than
4694 : : //one co_edge for the two_faces. But this should be okay
4695 : : //since up above this function, that should be traped for...
4696 : :
4697 : : //Weed-out case where one edge is shared between more
4698 : : //than 2 surfaces of the same volume
4699 [ # # ]: 0 : DLIList<RefFace*> tmp_faces;
4700 [ # # ]: 0 : ref_edge->ref_faces( tmp_faces );
4701 : :
4702 [ # # ][ # # ]: 0 : if( tmp_faces.size() > 2 )
4703 : : {
4704 : : int kk;
4705 [ # # ][ # # ]: 0 : for(kk=tmp_faces.size(); kk--;)
4706 : : {
4707 [ # # ][ # # ]: 0 : if( !tmp_faces.get()->is_child( ref_volume ) )
[ # # ][ # # ]
4708 [ # # ]: 0 : tmp_faces.change_to(NULL);
4709 [ # # ]: 0 : tmp_faces.step();
4710 : : }
4711 [ # # ]: 0 : tmp_faces.remove_all_with_value( NULL );
4712 [ # # ][ # # ]: 0 : if( tmp_faces.size() > 2 )
4713 : : //this isn't the type of surface we are looking for...
4714 : 0 : return 0.0;
4715 : : }
4716 : :
4717 : :
4718 [ # # ]: 0 : ref_edge->tangent( mid_point, tangent_vector, ref_face_1 );
4719 [ # # ]: 0 : CubitSense face_1_sense = ref_face_1->sense( ref_volume );
4720 : :
4721 [ # # ][ # # ]: 0 : if( CUBIT_REVERSED != face_1_sense && CUBIT_FORWARD != face_1_sense )
4722 [ # # ][ # # ]: 0 : if(!(ref_volume->is_sheet()))
4723 : 0 : return 0.0;
4724 : :
4725 [ # # ]: 0 : if ( face_1_sense == CUBIT_REVERSED )
4726 [ # # ][ # # ]: 0 : tangent_vector = -tangent_vector;
4727 : :
4728 : : double angle = CUBIT_PI +
4729 [ # # ]: 0 : tangent_vector.vector_angle(surf_2_norm, surf_1_norm );
4730 : : // note 1 and 2 switched.
4731 : : // tangent is cw, opposite of rhr
4732 : :
4733 : : // Range of above is pi/2 to 5pi/2, shift to 0 to 2pi.
4734 [ # # ]: 0 : if ( angle >= 2.0* CUBIT_PI )
4735 : 0 : angle -= 2.0 * CUBIT_PI;
4736 : :
4737 : : // if the angle is close to 0 or 2pi, use a center point check
4738 : : // to figure out if the interior angle is zero or 2pi
4739 : 0 : const double min_tol = 0.1; // CUBIT_RESABS*100. too small
4740 : : // We could have a real overlap in some models, so keep
4741 : : // min_tol fairly big.
4742 : 0 : const double max_tol = 2.0*CUBIT_PI - min_tol;
4743 : :
4744 : : // angle near zero - 2pi, make some checks at nearby locations
4745 [ # # ][ # # ]: 0 : if (angle <= min_tol || angle >= max_tol )
4746 : : {
4747 : : // try to get the inside-outness where the surfaces have a gap
4748 : : // between them
4749 : :
4750 : : // get a non-shared edge with a shared vertex between the surfaces
4751 : :
4752 : : int i;
4753 : :
4754 : : // get the next edge in the loop
4755 [ # # ]: 0 : DLIList<DLIList<RefEdge*> > loops_1;
4756 : 0 : DLIList<RefEdge*> *loop_1 = NULL;
4757 [ # # ]: 0 : ref_face_1->ref_edge_loops( loops_1 );
4758 [ # # ][ # # ]: 0 : for ( i = loops_1.size(); i--; )
4759 : : {
4760 [ # # ]: 0 : loop_1 = &loops_1.get_and_step();
4761 [ # # ][ # # ]: 0 : if ( loop_1->move_to( ref_edge ) )
4762 : 0 : break;
4763 : : }
4764 [ # # ][ # # ]: 0 : assert( loop_1->get() == ref_edge );
4765 : :
4766 [ # # ][ # # ]: 0 : DLIList<DLIList<RefEdge*> > loops_2;
4767 : 0 : DLIList<RefEdge*> *loop_2 = NULL;
4768 [ # # ]: 0 : ref_face_2->ref_edge_loops( loops_2 );
4769 [ # # ][ # # ]: 0 : for ( i = loops_2.size(); i--; )
4770 : : {
4771 [ # # ]: 0 : loop_2 = &loops_2.get_and_step();
4772 [ # # ][ # # ]: 0 : if ( loop_2->move_to( ref_edge ) )
4773 : 0 : break;
4774 : : }
4775 [ # # ][ # # ]: 0 : assert( loop_2->get() == ref_edge );
4776 : :
4777 : 0 : RefEdge *common_edge = ref_edge, *next_edge,
4778 : 0 : *uncommon_edge_1 = NULL, *uncommon_edge_2 = NULL;
4779 : 0 : RefVertex *common_vertex = NULL;
4780 : :
4781 [ # # ][ # # ]: 0 : for ( i = loop_1->size(); !common_vertex && i--; )
[ # # ][ # # ]
4782 : : {
4783 [ # # ]: 0 : next_edge = loop_1->step_and_get();
4784 [ # # ][ # # ]: 0 : if ( loop_2->prev() == next_edge )
4785 : : {
4786 [ # # ]: 0 : loop_2->back();
4787 : 0 : common_edge = next_edge;
4788 : : }
4789 [ # # ][ # # ]: 0 : else if ( loop_2->next() == next_edge )
4790 : : {
4791 [ # # ]: 0 : loop_2->step();
4792 : 0 : common_edge = next_edge;
4793 : : }
4794 : : else
4795 : : {
4796 : 0 : uncommon_edge_1 = next_edge;
4797 : :
4798 : : // if both vertices are shared, it doesn't matter which we chose.
4799 [ # # ]: 0 : common_vertex = common_edge->common_ref_vertex( uncommon_edge_1 );
4800 : :
4801 [ # # ][ # # ]: 0 : if ( loop_2->next()->is_parent( common_vertex ) )
[ # # ][ # # ]
4802 [ # # ]: 0 : uncommon_edge_2 = loop_2->next();
4803 : : else
4804 : : {
4805 [ # # ][ # # ]: 0 : assert( loop_2->prev()->is_parent( common_vertex ) );
[ # # ][ # # ]
4806 [ # # ]: 0 : uncommon_edge_2 = loop_2->prev();
4807 : : }
4808 : : }
4809 : : }
4810 : :
4811 : : int too_far;
4812 : :
4813 [ # # ][ # # ]: 0 : CubitVector center_1, center_2, center_norm_1, center_norm_2;
[ # # ][ # # ]
4814 : :
4815 : : // we've found non-common edges with a common vertex
4816 : 0 : int bad_angle = CUBIT_TRUE;
4817 [ # # ]: 0 : if ( common_vertex )
4818 : : {
4819 : :
4820 : : // These two curves are only good geometrically if they
4821 : : // have a small angle between them: If the angle is too big,
4822 : : // then the closest pt will be the vertex, and we'll have to
4823 : : // start over with the surfaces or something.
4824 : :
4825 : : // reset midpoint and normals to common vertex...
4826 [ # # ]: 0 : CubitVector vertex_coord = common_vertex->coordinates();
4827 : :
4828 : : // get a pair of close points on each surface
4829 [ # # ][ # # ]: 0 : center_1 = uncommon_edge_1->center_point();
4830 [ # # ][ # # ]: 0 : center_2 = uncommon_edge_2->center_point();
4831 : :
4832 [ # # ][ # # ]: 0 : double d_1 = (center_1 - vertex_coord).length_squared();
4833 [ # # ][ # # ]: 0 : double d_2 = (center_2 - vertex_coord).length_squared();
4834 : 0 : int give_up = 0;
4835 : 0 : i = 0;
4836 [ # # ]: 0 : if ( d_1 <= d_2 )
4837 : : {
4838 [ # # ]: 0 : do
4839 : : {
4840 [ # # ]: 0 : center_2 = center_1;
4841 [ # # ]: 0 : uncommon_edge_2->move_to_curve( center_2 );
4842 [ # # ][ # # ]: 0 : d_2 = (center_2 - vertex_coord).length_squared();
4843 : 0 : bad_angle = d_2 < d_1 * 0.2;
4844 [ # # ][ # # ]: 0 : give_up = ( d_1 < GEOMETRY_RESABS*10 || i++ > 10 );
4845 [ # # ]: 0 : if ( give_up )
4846 : 0 : break;
4847 [ # # ]: 0 : if ( bad_angle )
4848 : : {
4849 [ # # ]: 0 : center_1 += vertex_coord;
4850 [ # # ]: 0 : center_1 /= 2.0;
4851 [ # # ]: 0 : uncommon_edge_1->move_to_curve( center_1 );
4852 [ # # ][ # # ]: 0 : d_1 = (center_1 - vertex_coord).length_squared();
4853 : : }
4854 : : } while ( bad_angle );
4855 : : }
4856 : : else
4857 : : {
4858 [ # # ]: 0 : do
4859 : : {
4860 [ # # ]: 0 : center_1 = center_2;
4861 [ # # ]: 0 : uncommon_edge_1->move_to_curve( center_1 );
4862 [ # # ][ # # ]: 0 : d_1 = (center_1 - vertex_coord).length_squared();
4863 : 0 : bad_angle = d_1 < d_2 * 0.2;
4864 [ # # ][ # # ]: 0 : give_up = ( d_2 < GEOMETRY_RESABS*10 || i++ > 10 );
4865 [ # # ]: 0 : if ( give_up )
4866 : 0 : break;
4867 [ # # ]: 0 : if ( bad_angle )
4868 : : {
4869 [ # # ]: 0 : center_2 += vertex_coord;
4870 [ # # ]: 0 : center_2 /= 2.0;
4871 [ # # ]: 0 : uncommon_edge_2->move_to_curve( center_2 );
4872 [ # # ][ # # ]: 0 : d_2 = (center_2 - vertex_coord).length_squared();
4873 : : }
4874 : : } while ( bad_angle );
4875 : : }
4876 [ # # ]: 0 : if ( !bad_angle )
4877 : : {
4878 [ # # ]: 0 : mid_point = vertex_coord;
4879 [ # # ][ # # ]: 0 : surf_1_norm = ref_face_1->normal_at( mid_point, ref_volume );
4880 [ # # ][ # # ]: 0 : surf_2_norm = ref_face_2->normal_at( mid_point, ref_volume );
4881 : :
4882 : :
4883 : 0 : double best_d_1 = CUBIT_DBL_MAX;
4884 : :
4885 [ # # ]: 0 : CubitVector test_center_1 = center_1;
4886 [ # # ]: 0 : CubitVector test_center_norm_1;
4887 : :
4888 : : // may be too far away - make sure normal is roughly the same
4889 : : // as at the midpoint
4890 : :
4891 : 0 : too_far = CUBIT_TRUE;
4892 [ # # ][ # # ]: 0 : for ( i = 12; i-- && too_far; )
[ # # ]
4893 : : {
4894 [ # # ]: 0 : test_center_norm_1 =
4895 [ # # ]: 0 : ref_face_1->normal_at( test_center_1, ref_volume );
4896 [ # # ]: 0 : d_1 = test_center_norm_1 % surf_1_norm;
4897 [ # # ]: 0 : if ( d_1 < best_d_1 )
4898 : : {
4899 [ # # ]: 0 : center_1 = test_center_1;
4900 [ # # ]: 0 : center_norm_1 = test_center_norm_1;
4901 : : }
4902 : 0 : too_far = d_1 < 0.2;
4903 [ # # ][ # # ]: 0 : if ( too_far && i ) // skip last time
4904 : : {
4905 [ # # ]: 0 : test_center_1 += mid_point;
4906 [ # # ]: 0 : test_center_1 /= 2.0;
4907 [ # # ]: 0 : uncommon_edge_1->move_to_curve( test_center_1 );
4908 : : }
4909 : : }
4910 : :
4911 : 0 : double best_d_2 = CUBIT_DBL_MAX;
4912 : :
4913 [ # # ]: 0 : CubitVector test_center_2 = center_2;
4914 [ # # ]: 0 : CubitVector test_center_norm_2;
4915 : :
4916 : : // may be too far away - make sure normal is roughly the same
4917 : : // as at the surface midpoint
4918 : 0 : too_far = CUBIT_TRUE;
4919 [ # # ][ # # ]: 0 : for ( i = 12; i-- && too_far; )
[ # # ]
4920 : : {
4921 [ # # ]: 0 : test_center_norm_2 =
4922 [ # # ]: 0 : ref_face_2->normal_at( test_center_2, ref_volume );
4923 [ # # ]: 0 : d_2 = test_center_norm_2 % surf_2_norm;
4924 [ # # ]: 0 : if ( d_2 < best_d_2 )
4925 : : {
4926 [ # # ]: 0 : center_2 = test_center_2;
4927 [ # # ]: 0 : center_norm_2 = test_center_norm_2;
4928 : : }
4929 : 0 : too_far = d_2 < 0.2;
4930 [ # # ][ # # ]: 0 : if ( too_far && i ) // skip last time
4931 : : {
4932 [ # # ]: 0 : test_center_2 += mid_point;
4933 [ # # ]: 0 : test_center_2 /= 2.0;
4934 [ # # ]: 0 : uncommon_edge_2->move_to_curve( test_center_2 );
4935 : : }
4936 : : }
4937 : : }
4938 : : }
4939 : : // surfaces share all edges! try the face center point
4940 [ # # ][ # # ]: 0 : if ( !common_vertex || bad_angle )
4941 : : {
4942 : :
4943 : : // get a pair of close points on each surface
4944 [ # # ][ # # ]: 0 : center_1 = ref_face_1->center_point();
4945 [ # # ][ # # ]: 0 : center_2 = ref_face_2->center_point();
4946 [ # # ][ # # ]: 0 : double d_1 = (center_1 - mid_point).length_squared();
4947 [ # # ][ # # ]: 0 : double d_2 = (center_2 - mid_point).length_squared();
4948 [ # # ]: 0 : if ( d_1 <= d_2 )
4949 : : {
4950 [ # # ]: 0 : center_2 = center_1;
4951 [ # # ]: 0 : ref_face_2->move_to_surface( center_2 );
4952 : : }
4953 : : else
4954 : : {
4955 [ # # ]: 0 : center_1 = center_2;
4956 [ # # ]: 0 : ref_face_1->move_to_surface( center_1 );
4957 : : }
4958 : :
4959 : 0 : double best_d_1 = CUBIT_DBL_MAX;
4960 : :
4961 [ # # ]: 0 : CubitVector test_center_1 = center_1;
4962 [ # # ]: 0 : CubitVector test_center_norm_1;
4963 : :
4964 : : // may be too far away - make sure normal is roughly the same
4965 : : // as at the curve midpoint
4966 : 0 : too_far = CUBIT_TRUE;
4967 [ # # ][ # # ]: 0 : for ( i = 12; i-- && too_far; )
[ # # ]
4968 : : {
4969 [ # # ]: 0 : test_center_norm_1 =
4970 [ # # ]: 0 : ref_face_1->normal_at( test_center_1, ref_volume );
4971 [ # # ]: 0 : d_1 = test_center_norm_1 % surf_1_norm;
4972 [ # # ]: 0 : if ( d_1 < best_d_1 )
4973 : : {
4974 [ # # ]: 0 : center_1 = test_center_1;
4975 [ # # ]: 0 : center_norm_1 = test_center_norm_1;
4976 : : }
4977 : 0 : too_far = d_1 < 0.2;
4978 [ # # ][ # # ]: 0 : if ( too_far && i ) // skip last time
4979 : : {
4980 [ # # ]: 0 : test_center_1 += mid_point;
4981 [ # # ]: 0 : test_center_1 /= 2.0;
4982 [ # # ]: 0 : ref_face_1->move_to_surface( test_center_1 );
4983 : : }
4984 : : }
4985 : :
4986 : : // surfaces share all edge! try the center point
4987 : 0 : double best_d_2 = CUBIT_DBL_MAX;
4988 : :
4989 [ # # ]: 0 : CubitVector test_center_2 = center_2;
4990 [ # # ]: 0 : CubitVector test_center_norm_2;
4991 : :
4992 : : // may be too far away - make sure normal is roughly the same
4993 : : // as at the curve midpoint
4994 : 0 : too_far = CUBIT_TRUE;
4995 [ # # ][ # # ]: 0 : for ( i = 12; i-- && too_far; )
[ # # ]
4996 : : {
4997 [ # # ]: 0 : test_center_norm_2 =
4998 [ # # ]: 0 : ref_face_2->normal_at( test_center_2, ref_volume );
4999 [ # # ]: 0 : d_2 = test_center_norm_2 % surf_2_norm;
5000 [ # # ]: 0 : if ( d_2 < best_d_2 )
5001 : : {
5002 [ # # ]: 0 : center_2 = test_center_2;
5003 [ # # ]: 0 : center_norm_2 = test_center_norm_2;
5004 : : }
5005 : 0 : too_far = d_2 < 0.2;
5006 [ # # ][ # # ]: 0 : if ( too_far && i ) // skip last time
5007 : : {
5008 [ # # ]: 0 : test_center_2 += mid_point;
5009 [ # # ]: 0 : test_center_2 /= 2.0;
5010 [ # # ]: 0 : ref_face_2->move_to_surface( test_center_2 );
5011 : : }
5012 : : }
5013 : : }
5014 : :
5015 : : // gap vector from center_1 to center_2
5016 [ # # ]: 0 : CubitVector gap_vector = center_2;
5017 [ # # ]: 0 : gap_vector -= center_1;
5018 : :
5019 [ # # ]: 0 : double gap_d = gap_vector % center_norm_1;
5020 [ # # ][ # # ]: 0 : gap_d += -gap_vector % center_norm_2;
5021 : :
5022 [ # # ]: 0 : if ( gap_d >= 0 )
5023 : : {
5024 [ # # ]: 0 : if ( angle < max_tol )
5025 : 0 : angle = 2*CUBIT_PI;
5026 : : // else leave at its current nearly-2pi value
5027 : : }
5028 : : else
5029 [ # # ]: 0 : if ( angle > min_tol )
5030 [ # # ]: 0 : angle = 0.;
5031 : : // else leave at its current nearly-zero value
5032 : :
5033 : : } // if angle near zero - 2pi
5034 : :
5035 [ # # ]: 0 : return angle;
5036 : : }
5037 : :
5038 : : //-------------------------------------------------------------------------
5039 : : // Purpose : Find a common geometry query engine
5040 : : //
5041 : : // Special Notes :
5042 : : //
5043 : : // Creator : Jason Kraftcheck
5044 : : //
5045 : : // Creation Date : 02/28/00
5046 : : //-------------------------------------------------------------------------
5047 : 0 : GeometryQueryEngine* GeometryQueryTool::common_query_engine(
5048 : : DLIList<TopologyEntity*>& topology_list,
5049 : : DLIList<TopologyBridge*>& engine_bridges,
5050 : : CubitBoolean allow_default_engine ) const
5051 : : {
5052 [ # # ]: 0 : topology_list.reset();
5053 : :
5054 [ # # ]: 0 : TopologyEntity* topo_ptr = topology_list.get_and_step();
5055 [ # # ]: 0 : DLIList<TopologyBridge*> first_bridge_list;
5056 [ # # ][ # # ]: 0 : topo_ptr->bridge_manager()->get_bridge_list( first_bridge_list );
5057 : :
5058 [ # # ]: 0 : first_bridge_list.reset();
5059 : 0 : GeometryQueryEngine* gqe_ptr = 0;
5060 [ # # ][ # # ]: 0 : for( int i = first_bridge_list.size(); i > 0; i-- )
5061 : : {
5062 [ # # ]: 0 : TopologyBridge* bridge_ptr = first_bridge_list.get_and_step();
5063 [ # # ]: 0 : engine_bridges.clean_out();
5064 [ # # ]: 0 : engine_bridges.append( bridge_ptr );
5065 [ # # ]: 0 : gqe_ptr = bridge_ptr->get_geometry_query_engine();
5066 : :
5067 [ # # ]: 0 : topology_list.reset();
5068 [ # # ]: 0 : topology_list.step(); //skip first entry
5069 [ # # ][ # # ]: 0 : for( int j = topology_list.size(); j > 1; j-- )
5070 : : {
5071 [ # # ]: 0 : topo_ptr = topology_list.get_and_step();
5072 [ # # ][ # # ]: 0 : bridge_ptr = topo_ptr->bridge_manager()->topology_bridge(gqe_ptr);
5073 [ # # ][ # # ]: 0 : if( bridge_ptr ) engine_bridges.append( bridge_ptr );
5074 : 0 : else break;
5075 : : }
5076 : :
5077 [ # # ][ # # ]: 0 : if( engine_bridges.size() == topology_list.size() )
[ # # ]
5078 : 0 : break;
5079 : :
5080 : 0 : gqe_ptr = 0;
5081 : : }
5082 : :
5083 [ # # ]: 0 : if( !gqe_ptr )
5084 : : {
5085 [ # # ]: 0 : engine_bridges.clean_out();
5086 : :
5087 [ # # ]: 0 : if( allow_default_engine )
5088 : : {
5089 [ # # ][ # # ]: 0 : PRINT_WARNING("Entities do not belong to the same geometry "
[ # # ]
5090 [ # # ]: 0 : "engine. Using the default geometry engine.\n");
5091 : 0 : gqe_ptr = default_gqe;
5092 [ # # ]: 0 : topology_list.reset();
5093 [ # # ][ # # ]: 0 : for( int j = topology_list.size(); j > 0; j-- )
5094 : : {
5095 [ # # ]: 0 : topo_ptr = topology_list.get_and_step();
5096 : : TopologyBridge* bridge_ptr =
5097 [ # # ][ # # ]: 0 : topo_ptr->bridge_manager()->topology_bridge( gqe_ptr );
5098 [ # # ]: 0 : if( ! bridge_ptr )
5099 [ # # ][ # # ]: 0 : bridge_ptr = topo_ptr->bridge_manager()->topology_bridge();
5100 [ # # ]: 0 : engine_bridges.append( bridge_ptr );
5101 : : }
5102 : : }
5103 : : }
5104 : :
5105 [ # # ]: 0 : return gqe_ptr;
5106 : : }
5107 : :
5108 : :
5109 : 0 : void GeometryQueryTool::get_connected_free_ref_entities(
5110 : : RefEntity *entity,
5111 : : const int merge_option,
5112 : : DLIList<Body*> &body_list,
5113 : : DLIList<RefFace*> &ref_face_list,
5114 : : DLIList<RefEdge*> &ref_edge_list,
5115 : : DLIList<RefVertex*> &ref_vertex_list )
5116 : : {
5117 : :
5118 [ # # ]: 0 : body_list.clean_out();
5119 [ # # ]: 0 : ref_face_list.clean_out();
5120 [ # # ]: 0 : ref_edge_list.clean_out();
5121 [ # # ]: 0 : ref_vertex_list.clean_out();
5122 : :
5123 [ # # ]: 0 : if ( !entity )
5124 : 0 : return;
5125 : :
5126 : : // cases are different enough, just do something totally different
5127 [ # # ]: 0 : if ( !merge_option )
5128 : : {
5129 : : // get top level entities
5130 [ # # ]: 0 : TopologyEntity *source_entity = CAST_TO(entity, TopologyEntity);
5131 : :
5132 [ # # ]: 0 : Body *body = CAST_TO( source_entity, Body );
5133 [ # # ]: 0 : if( body )
5134 [ # # ]: 0 : body_list.append( body );
5135 : : else
5136 : : // get attached bodies, if any
5137 [ # # ]: 0 : source_entity->bodies( body_list );
5138 : :
5139 [ # # ][ # # ]: 0 : if(body_list.size() == 0)
5140 : : {
5141 [ # # ]: 0 : RefEdge* ref_edge = CAST_TO(source_entity, RefEdge);
5142 [ # # ]: 0 : if ( ref_edge )
5143 [ # # ]: 0 : ref_edge_list.append( ref_edge );
5144 : : else
5145 : : {
5146 [ # # ]: 0 : source_entity->ref_edges( ref_edge_list );
5147 : : }
5148 [ # # ][ # # ]: 0 : if ( ref_edge_list.size() == 0 )
5149 : : {
5150 [ # # ]: 0 : RefVertex *vert = CAST_TO( source_entity, RefVertex );
5151 [ # # ]: 0 : if ( vert )
5152 [ # # ]: 0 : ref_vertex_list.append( vert );
5153 : : }
5154 : : }
5155 : : // this is the easy case, we're all done
5156 : 0 : return;
5157 : : }
5158 : :
5159 : :
5160 : : // merge_option == 1
5161 [ # # ]: 0 : DLIList <TopologyEntity*> source_list;
5162 [ # # ][ # # ]: 0 : DLIList <RefEntity*> source_entity_list;
5163 : :
5164 : : int i;
5165 : :
5166 [ # # ][ # # ]: 0 : DLIList <RefEntity*> free_list;
5167 : :
5168 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
5169 : :
5170 [ # # ]: 0 : TopologyEntity *topo_entity = CAST_TO( entity, TopologyEntity );
5171 [ # # ]: 0 : source_list.append( topo_entity );
5172 [ # # ][ # # ]: 0 : DLIList<RefEntity*> entity_list;
5173 [ # # ]: 0 : do
5174 : : {
5175 : : // get vertices (bottom level ref entities)
5176 [ # # ]: 0 : source_entity_list.clean_out();
5177 : :
5178 [ # # ][ # # ]: 0 : for (i = source_list.size(); i--; )
5179 : : {
5180 [ # # ]: 0 : TopologyEntity *source_entity = source_list.get_and_step();
5181 [ # # ]: 0 : DLIList<RefVertex*> local_vert_list;
5182 [ # # ][ # # ]: 0 : DLIList<RefEntity*> tmp_source_entity_list;
5183 [ # # ]: 0 : source_entity->ref_vertices( local_vert_list );
5184 [ # # ][ # # ]: 0 : if(local_vert_list.size() == 0)
5185 : : {
5186 [ # # ]: 0 : DLIList<RefEdge*> local_edge_list;
5187 [ # # ]: 0 : source_entity->ref_edges(local_edge_list);
5188 [ # # ][ # # ]: 0 : if(local_edge_list.size() == 0)
5189 : : {
5190 [ # # ]: 0 : DLIList<RefFace*> local_face_list;
5191 [ # # ]: 0 : source_entity->ref_faces(local_face_list);
5192 [ # # ][ # # ]: 0 : if(local_face_list.size() > 0)
5193 : : {
5194 [ # # ][ # # ]: 0 : CAST_LIST( local_face_list, tmp_source_entity_list, RefEntity);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5195 [ # # ]: 0 : source_entity_list += tmp_source_entity_list;
5196 [ # # ]: 0 : }
5197 : : }
5198 : : else
5199 : : {
5200 [ # # ][ # # ]: 0 : CAST_LIST( local_edge_list, tmp_source_entity_list, RefEntity);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5201 [ # # ]: 0 : source_entity_list += tmp_source_entity_list;
5202 [ # # ]: 0 : }
5203 : : }
5204 : : else
5205 : : {
5206 [ # # ][ # # ]: 0 : CAST_LIST( local_vert_list, tmp_source_entity_list, RefEntity);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5207 [ # # ]: 0 : source_entity_list += tmp_source_entity_list;
5208 : : }
5209 [ # # ]: 0 : }
5210 [ # # ]: 0 : source_list.clean_out();
5211 : :
5212 : : // get top level entities
5213 [ # # ][ # # ]: 0 : for ( i = source_entity_list.size(); i--; )
5214 : : {
5215 [ # # ]: 0 : RefEntity *source_entity = source_entity_list.get_and_step();
5216 : : // get all upwards related ref entities
5217 [ # # ]: 0 : entity_list.clean_out();
5218 : : // get the bodies, too!
5219 [ # # ]: 0 : source_entity->get_all_parent_ref_entities( entity_list, CUBIT_TRUE );
5220 [ # # ]: 0 : entity_list.append( source_entity );
5221 : :
5222 : : // check each one to see if it is a new top level in the solid
5223 : : // modeller
5224 : : int j;
5225 [ # # ][ # # ]: 0 : for ( j = entity_list.size(); j--; )
5226 : : {
5227 : : // entity is top level if it has a topology bridge that has a bodysm
5228 [ # # ]: 0 : RefEntity *ref_entity = entity_list.get_and_step();
5229 : :
5230 [ # # ][ # # ]: 0 : if ( !ref_entity->marked() )
5231 : : {
5232 [ # # ]: 0 : bridge_list.clean_out();
5233 [ # # ]: 0 : topo_entity = CAST_TO( ref_entity, TopologyEntity );
5234 [ # # ][ # # ]: 0 : topo_entity->bridge_manager()->get_bridge_list(bridge_list);
5235 : : int k;
5236 : 0 : bool no_parents = true;
5237 [ # # ][ # # ]: 0 : for ( k = bridge_list.size(); k--; )
5238 : : {
5239 [ # # ]: 0 : TopologyBridge* bridge = bridge_list.get_and_step();
5240 [ # # ]: 0 : DLIList<TopologyBridge*> parents;
5241 [ # # ]: 0 : bridge->get_parents( parents );
5242 [ # # ][ # # ]: 0 : if( parents.size() )
5243 : : {
5244 : 0 : no_parents = false;
5245 [ # # ][ # # ]: 0 : break;
5246 : : }
5247 : 0 : }
5248 [ # # ]: 0 : if( no_parents )
5249 : : {
5250 [ # # ]: 0 : ref_entity->marked( 1 );
5251 [ # # ]: 0 : topo_entity = CAST_TO( ref_entity, TopologyEntity );
5252 [ # # ]: 0 : source_list.append( topo_entity );
5253 [ # # ]: 0 : free_list.append( ref_entity );
5254 : 0 : continue;
5255 : : }
5256 : : }
5257 : : }
5258 : : }
5259 : :
5260 [ # # ]: 0 : } while( source_list.size() );
5261 : :
5262 : : // xfer data, clean up marks
5263 [ # # ][ # # ]: 0 : for ( i = free_list.size(); i--; )
5264 : : {
5265 [ # # ]: 0 : RefEntity *ref_entity = free_list.get_and_step();
5266 [ # # ]: 0 : ref_entity->marked(0);
5267 : : }
5268 [ # # ][ # # ]: 0 : CAST_LIST( free_list, body_list, Body );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5269 [ # # ][ # # ]: 0 : CAST_LIST( free_list, ref_face_list, RefFace);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5270 [ # # ][ # # ]: 0 : CAST_LIST( free_list, ref_edge_list, RefEdge);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5271 [ # # ][ # # ]: 0 : CAST_LIST( free_list, ref_vertex_list, RefVertex);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
5272 : : }
5273 : :
5274 : :
5275 : 1682 : CubitStatus GeometryQueryTool::register_intermediate_engine(
5276 : : IntermediateGeomEngine* engine_ptr )
5277 : : {
5278 : 1682 : return (CubitStatus)igeSet.insert(engine_ptr).second;
5279 : : }
5280 : :
5281 : 0 : void GeometryQueryTool::unregister_intermediate_engine(
5282 : : IntermediateGeomEngine* engine_ptr )
5283 : : {
5284 : 0 : igeSet.erase(engine_ptr);
5285 : 0 : }
5286 : :
5287 : 319 : void GeometryQueryTool::ige_export_geom( DLIList<TopologyBridge*> &geom_list )
5288 : : {
5289 [ + - ][ + - ]: 957 : for (IGESet::reverse_iterator itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ + - ][ + - ]
[ + + ]
5290 [ + - ][ + - ]: 638 : (*itor)->export_geometry(geom_list);
5291 : 319 : }
5292 : :
5293 : 0 : void GeometryQueryTool::ige_push_imprint_attributes_before_modify
5294 : : ( DLIList<BodySM*> &geom_list )
5295 : : {
5296 [ # # ][ # # ]: 0 : for (IGESet::reverse_iterator itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ # # ][ # # ]
[ # # ]
5297 [ # # ][ # # ]: 0 : (*itor)->push_imprint_attributes_before_modify(geom_list);
5298 : 0 : }
5299 : :
5300 : 0 : void GeometryQueryTool::ige_push_named_attributes_to_curves_and_points
5301 : : ( DLIList<TopologyBridge*> &tb_list, const char *name_in )
5302 : : {
5303 [ # # ][ # # ]: 0 : for (IGESet::reverse_iterator itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ # # ][ # # ]
[ # # ]
5304 [ # # ][ # # ]: 0 : (*itor)->push_named_attributes_to_curves_and_points(tb_list, name_in);
5305 : 0 : }
5306 : :
5307 : 0 : void GeometryQueryTool::ige_remove_imprint_attributes_after_modify
5308 : : ( DLIList<BodySM*> &old_sms,
5309 : : DLIList<BodySM*> &new_sms )
5310 : : {
5311 [ # # ][ # # ]: 0 : for (IGESet::reverse_iterator itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ # # ][ # # ]
[ # # ]
5312 [ # # ][ # # ]: 0 : (*itor)->remove_imprint_attributes_after_modify(old_sms, new_sms);
5313 : 0 : }
5314 : :
5315 : 0 : bool GeometryQueryTool::ige_is_composite(TBOwner *bridge_owner)
5316 : : {
5317 : 0 : bool ret = false;
5318 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end() && ret != true; ++itor)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
5319 : : {
5320 [ # # ][ # # ]: 0 : if((*itor)->is_composite(bridge_owner))
[ # # ]
5321 : : {
5322 : 0 : ret = true;
5323 : : }
5324 : : }
5325 : 0 : return ret;
5326 : : }
5327 : :
5328 : 0 : bool GeometryQueryTool::ige_is_composite(TopologyBridge *bridge)
5329 : : {
5330 : 0 : bool ret = false;
5331 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end() && ret != true; ++itor)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
5332 : : {
5333 [ # # ][ # # ]: 0 : if((*itor)->is_composite(bridge))
[ # # ]
5334 : : {
5335 : 0 : ret = true;
5336 : : }
5337 : : }
5338 : 0 : return ret;
5339 : : }
5340 : :
5341 : :
5342 : 0 : bool GeometryQueryTool::ige_is_partition(TBOwner *bridge_owner)
5343 : : {
5344 : 0 : bool ret = false;
5345 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end() && ret != true; ++itor)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
5346 : : {
5347 [ # # ][ # # ]: 0 : if((*itor)->is_partition(bridge_owner))
[ # # ]
5348 : : {
5349 : 0 : ret = true;
5350 : : }
5351 : : }
5352 : 0 : return ret;
5353 : : }
5354 : :
5355 : 319 : void GeometryQueryTool::ige_import_geom( DLIList<TopologyBridge*> &geom_list )
5356 : : {
5357 [ + - ][ + - ]: 957 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ + - ][ + - ]
[ + + ]
5358 [ + - ][ + - ]: 638 : (*itor)->import_geometry(geom_list);
5359 : 319 : }
5360 : :
5361 : 0 : void GeometryQueryTool::get_tbs_with_bridge_manager_as_owner( TopologyBridge *source_bridge,
5362 : : DLIList<TopologyBridge*> &tbs )
5363 : : {
5364 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
5365 [ # # ][ # # ]: 0 : (*itor)->get_tbs_with_bridge_manager_as_owner( source_bridge, tbs );
5366 : 0 : }
5367 : :
5368 : 0 : void GeometryQueryTool::ige_attribute_after_imprinting(DLIList<TopologyBridge*> &tb_list,
5369 : : DLIList<Body*> &old_bodies)
5370 : : {
5371 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
5372 [ # # ][ # # ]: 0 : (*itor)->attribute_after_imprinting(tb_list, old_bodies);
5373 : 0 : }
5374 : :
5375 : 319 : void GeometryQueryTool::ige_remove_attributes( DLIList<TopologyBridge*> &geom_list )
5376 : : {
5377 [ + - ][ + - ]: 957 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ + - ][ + - ]
[ + + ]
5378 [ + - ][ + - ]: 638 : (*itor)->remove_attributes(geom_list);
5379 : 319 : }
5380 : :
5381 : 0 : void GeometryQueryTool::ige_remove_attributes_from_unmodifed_virtual(DLIList<TopologyBridge*> &bridges)
5382 : : {
5383 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
5384 [ # # ][ # # ]: 0 : (*itor)->remove_attributes_from_unmodifed_virtual(bridges);
5385 : 0 : }
5386 : :
5387 : 0 : bool GeometryQueryTool::contains_intermediate_geometry(DLIList<RefEntity*>& ref_entity_list) const
5388 : : {
5389 : : // Unfortunately, the current implementation of partition creates virtual
5390 : : // bodies as well as virtual subentities. Thus, we have to go up the tree
5391 : : // as well as down it.
5392 : : // TODO: Partitioning HAS got to change. KGM 2/9/06
5393 : : //get the owning bodies
5394 [ # # ]: 0 : DLIList<Body*> body_list;
5395 : : int j;
5396 [ # # ][ # # ]: 0 : for(j=ref_entity_list.size(); j--;)
5397 : : {
5398 [ # # ][ # # ]: 0 : TopologyEntity* te = dynamic_cast<TopologyEntity*>( ref_entity_list.get_and_step());
5399 [ # # ]: 0 : te->bodies( body_list );
5400 : : }
5401 : : int i;
5402 [ # # ][ # # ]: 0 : for ( i = 0; i < body_list.size(); i++)
5403 [ # # ][ # # ]: 0 : if (GeometryQueryTool::instance()->
5404 [ # # ][ # # ]: 0 : is_intermediate_geometry(body_list.next(i)))
[ # # ]
5405 : 0 : return true;
5406 : :
5407 [ # # ][ # # ]: 0 : for ( i = 0; i < ref_entity_list.size(); i++)
5408 [ # # ][ # # ]: 0 : if (GeometryQueryTool::instance()->
5409 [ # # ][ # # ]: 0 : contains_intermediate_geometry(ref_entity_list.next(i)))
5410 : 0 : return true;
5411 : :
5412 [ # # ]: 0 : return false;
5413 : : }
5414 : :
5415 : 11 : bool GeometryQueryTool::contains_intermediate_geometry(RefEntity* entity_ptr) const
5416 : : {
5417 [ + - ][ - + ]: 11 : if (igeSet.empty())
5418 : 0 : return false;
5419 : :
5420 [ + - ]: 11 : DLIList<RefEntity*> children;
5421 [ + - ]: 11 : entity_ptr->get_all_child_ref_entities(children);
5422 [ + - ]: 11 : children.append(entity_ptr);
5423 : :
5424 [ + - ][ + + ]: 66 : while(children.size())
5425 [ + - ][ + - ]: 55 : if (is_intermediate_geometry(children.pop()))
[ - + ]
5426 : 0 : return true;
5427 : :
5428 [ + - ]: 11 : return false;
5429 : : }
5430 : :
5431 : 55 : bool GeometryQueryTool::is_intermediate_geometry(RefEntity* entity_ptr) const
5432 : : {
5433 [ - + ]: 55 : TopologyEntity* topo_ptr = CAST_TO(entity_ptr, TopologyEntity);
5434 [ - + ]: 55 : if (!topo_ptr)
5435 : 0 : return false;
5436 : :
5437 [ + - ]: 55 : DLIList<TopologyBridge*> bridge_list;
5438 [ + - ][ + - ]: 55 : topo_ptr->bridge_manager()->get_bridge_list(bridge_list);
5439 [ + - ][ + + ]: 110 : while(bridge_list.size())
5440 [ + - ][ + - ]: 55 : if (is_intermediate_geometry(bridge_list.pop()))
[ - + ]
5441 : 0 : return true;
5442 : :
5443 [ + - ]: 55 : return false;
5444 : : }
5445 : :
5446 : 9697 : bool GeometryQueryTool::is_intermediate_geometry( TopologyBridge* bridge ) const
5447 : : {
5448 [ - + ]: 9697 : if (bridge->get_geometry_query_engine() == NULL )
5449 : 0 : return true;
5450 : : else
5451 : 9697 : return bridge->get_geometry_query_engine()->is_intermediate_engine();
5452 : : }
5453 : :
5454 : :
5455 : : //-------------------------------------------------------------------------
5456 : : // Purpose : Destroy dead entity and dead children
5457 : : //
5458 : : // Special Notes :
5459 : : //
5460 : : // Creator : Jason Kraftcheck
5461 : : //
5462 : : // Creation Date : 12/08/03
5463 : : //-------------------------------------------------------------------------
5464 : 229551 : CubitStatus GeometryQueryTool::destroy_dead_entity(
5465 : : TopologyEntity* topo_ent,
5466 : : bool top ) const
5467 : : {
5468 [ + - ][ + + ]: 229551 : if (topo_ent->get_parents() || topo_ent->bridge_manager()->topology_bridge())
[ + - ][ + - ]
[ + + ][ + + ]
5469 : 49795 : return CUBIT_FAILURE;
5470 : :
5471 [ + - ]: 179756 : topo_ent->deactivated(CUBIT_TRUE);
5472 : :
5473 [ - + ]: 179756 : CubitObservable* ob = dynamic_cast<CubitObservable*>(topo_ent);
5474 [ + + ]: 179756 : if (ob)
5475 : : {
5476 [ + - ][ + + ]: 146076 : if (dynamic_cast<RefEntity*>(topo_ent))
[ + + ]
5477 : : {
5478 : : // "top" indicates if this call is the topmost call to this
5479 : : // recursive function. It should be the case that if it is
5480 : : // the topmost call and the passed entity is a RefEntity, then
5481 : : // the entity was top-level (had no parent entities in the
5482 : : // topology graph.) For cases where dead topology is cleaned
5483 : : // out and a dead RefEntity is not-top-most, it will have some
5484 : : // parent sense entity which this function will be called on and
5485 : : // that call will be the top-most one.
5486 [ + + ]: 49388 : if (top)
5487 : : {
5488 [ + - ][ + - ]: 2033 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOP_LEVEL_ENTITY_DESTRUCTED, static_cast<RefEntity*>(ob)));
[ + - ][ + - ]
[ + - ]
5489 [ + - ][ + - ]: 2033 : CGMHistory::Event evt(CGMHistory::TOP_LEVEL_ENTITY_DELETED, static_cast<RefEntity*>(ob));
5490 [ + - ][ + - ]: 2033 : const_cast<CGMHistory&>(mHistory).add_event(evt);
5491 : : }
5492 [ + - ][ + - ]: 49388 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_DESTRUCTED, static_cast<RefEntity*>(ob)));
[ + - ][ + - ]
[ + - ]
5493 : : }
5494 : : else
5495 [ + - ][ + - ]: 146076 : AppUtil::instance()->send_event(TopologyEvent(TopologyEvent::TOPOLOGY_ENTITY_DESTRUCTED, topo_ent));
[ + - ][ + - ]
5496 : : }
5497 : :
5498 [ + - ]: 179756 : DLIList<TopologyEntity*> child_list;
5499 [ + - ]: 179756 : topo_ent->disconnect_all_children(&child_list);
5500 [ + - ]: 179756 : child_list.reset();
5501 [ + - ][ + + ]: 405397 : for (int i = child_list.size(); i--; )
5502 : : {
5503 [ + - ]: 225641 : TopologyEntity* child = child_list.get_and_step();
5504 : 225641 : TopologyEntity* child_topo_ent = dynamic_cast<TopologyEntity*>(child);
5505 [ + - ]: 225641 : if (child_topo_ent)
5506 : : {
5507 [ + - ]: 225641 : destroy_dead_entity(child_topo_ent, false);
5508 [ + - ][ + + ]: 500615 : if (!child_topo_ent->deactivated() &&
[ + + ]
5509 [ + - ][ + - ]: 51924 : child_topo_ent->bridge_manager()->number_of_bridges() > 0 &&
[ + + ]
5510 [ + + ][ + - ]: 277565 : child_topo_ent->get_parents() == 0 &&
[ + - ]
5511 [ - + ]: 506 : NULL != (ob = dynamic_cast<CubitObservable*>(child_topo_ent)))
5512 : : {
5513 [ + - ][ + - ]: 1012 : DLIList<TopologyBridge*> list1, list2;
[ + - ]
5514 : 506 : bool has_parents = false;
5515 [ + - ][ + - ]: 506 : child_topo_ent->bridge_manager()->get_bridge_list(list1);
5516 [ + - ][ + + ]: 1012 : while (list1.size())
5517 : : {
5518 [ + - ]: 506 : list2.clean_out();
5519 [ + - ][ + - ]: 506 : list1.pop()->get_parents(list2);
5520 [ + - ][ + - ]: 506 : if (list2.size())
5521 : 506 : has_parents = true;
5522 : : }
5523 [ - + ]: 506 : if (!has_parents)
5524 : : {
5525 [ # # ][ # # ]: 0 : AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::FREE_REF_ENTITY_GENERATED, static_cast<RefEntity*>(ob)));
[ # # ][ # # ]
[ # # ]
5526 [ # # ][ # # ]: 0 : CGMHistory::Event evt(CGMHistory::TOP_LEVEL_ENTITY_CREATED, static_cast<RefEntity*>(ob));
5527 [ # # ][ # # ]: 0 : const_cast<CGMHistory&>(mHistory).add_event(evt);
5528 [ + - ]: 225641 : }
5529 : : }
5530 : : }
5531 : : }
5532 : :
5533 [ + + ]: 179756 : if (top)
5534 [ + - ][ + - ]: 3448 : GeometryQueryTool::instance()->cleanout_deactivated_geometry();
5535 : :
5536 [ + - ]: 229551 : return CUBIT_SUCCESS;
5537 : : }
5538 : :
5539 : : // TODO - find out where this functionality belongs
5540 : 1137 : CubitStatus GeometryQueryTool::import_actuate(DLIList<RefEntity*> &entity_list)
5541 : : {
5542 : : int i;
5543 : :
5544 : : // given a Body list, actuates first the merge partner attribute
5545 : : // on all entities in the list, then actuates all other types of
5546 : : // attributes
5547 : :
5548 [ + - ]: 1137 : DLIList<TopologyEntity*> temp_list;
5549 [ + - ][ + - ]: 2274 : DLIList<RefEntity*> refent_list;
5550 : :
5551 : : CubitBoolean auto_actuate_merge;
5552 [ + - ][ + - ]: 1137 : auto_actuate_merge = CGMApp::instance()->attrib_manager()->auto_actuate_flag(CA_MERGE_PARTNER);
[ + - ]
5553 : :
5554 : :
5555 [ + + ]: 1137 : if (auto_actuate_merge) {
5556 : :
5557 : : // Prevent MergeTool from destroying dead entities
5558 : : // after merging. Otherwise we get stale pointers
5559 : : // in our lists.
5560 : : // Don't forget to turn this back on later!
5561 [ + - ]: 940 : MergeTool::destroy_dead_geometry( false );
5562 : :
5563 [ + - ]: 940 : DLIList<TopologyEntity*> me_list;
5564 [ + - ][ + - ]: 6030 : CAST_LIST(entity_list, me_list, TopologyEntity);
[ + - ][ - + ]
[ + - ][ + - ]
[ + + ]
5565 : :
5566 [ + - ]: 940 : ModelQueryEngine *const mqe = ModelQueryEngine::instance();
5567 : :
5568 : : // vertices
5569 [ + - ][ + - ]: 940 : mqe->query_model(me_list, DagType::ref_vertex_type(), temp_list);
5570 [ + - ][ + - ]: 13797 : CAST_LIST(temp_list, refent_list, RefEntity);
[ + - ][ - + ]
[ + - ][ + - ]
[ + + ]
5571 : : // actuate merge attribute for vertices
5572 [ + - ][ + - ]: 940 : if (refent_list.size() > 0)
5573 [ + - ][ + - ]: 940 : refent_list.get()->actuate_cubit_attrib(refent_list, CA_MERGE_PARTNER);
[ + - ][ + - ]
5574 : :
5575 : : // edges
5576 [ + - ]: 940 : temp_list.clean_out();
5577 [ + - ]: 940 : refent_list.clean_out();
5578 [ + - ][ + - ]: 940 : mqe->query_model(me_list, DagType::ref_edge_type(), temp_list);
5579 [ + - ][ + - ]: 20928 : CAST_LIST(temp_list, refent_list, RefEntity);
[ + - ][ - + ]
[ + - ][ + - ]
[ + + ]
5580 : : // actuate merge attribute for edges
5581 [ + - ][ + - ]: 940 : if (refent_list.size() > 0)
5582 [ + - ][ + - ]: 940 : refent_list.get()->actuate_cubit_attrib(refent_list, CA_MERGE_PARTNER);
[ + - ][ + - ]
5583 : :
5584 : : // faces
5585 [ + - ]: 940 : temp_list.clean_out();
5586 [ + - ]: 940 : refent_list.clean_out();
5587 [ + - ][ + - ]: 940 : mqe->query_model(me_list, DagType::ref_face_type(), temp_list);
5588 [ + - ][ + - ]: 10392 : CAST_LIST(temp_list, refent_list, RefEntity);
[ + - ][ - + ]
[ + - ][ + - ]
[ + + ]
5589 : : // actuate merge attribute for faces
5590 [ + - ][ + - ]: 940 : if (refent_list.size() > 0)
5591 [ + - ][ + - ]: 940 : refent_list.get()->actuate_cubit_attrib(refent_list, CA_MERGE_PARTNER);
[ + - ][ + - ]
5592 : :
5593 : : // clean out entities destroyed during merge
5594 [ + - ]: 940 : entity_list.reset();
5595 [ + - ][ + + ]: 6030 : for( i = entity_list.size(); i--; )
5596 : : {
5597 [ + - ][ - + ]: 5090 : TopologyEntity* me_ptr = dynamic_cast<TopologyEntity*>(entity_list.get());
5598 [ + - ][ + - ]: 5090 : if( me_ptr && me_ptr->deactivated() )
[ - + ][ - + ]
5599 [ # # ]: 0 : entity_list.extract();
5600 : : else
5601 [ + - ]: 5090 : entity_list.step();
5602 : : }
5603 : :
5604 : : // Restore merge tool setting, and clean up dead geometry
5605 [ + - ]: 940 : MergeTool::destroy_dead_geometry( true );
5606 [ + - ][ + - ]: 940 : GeometryQueryTool::instance()->cleanout_deactivated_geometry();
[ + - ]
5607 : : }
5608 : :
5609 : : // now actuate other attributes
5610 : : RefEntity* entity_ptr;
5611 [ + - ][ + - ]: 2274 : CAActuateSet actuate_set( entity_list );
5612 : :
5613 : : // actuate in increasing dimension
5614 : : // (vtx = 0, ..., volume = 3, body = 4)
5615 [ + + ]: 6822 : for( i = 0; i < 5; i++ )
5616 : : {
5617 [ + - ]: 5685 : actuate_set.set_current_dimension( i );
5618 [ + - ][ + + ]: 67498 : while( (entity_ptr = actuate_set.remove_next() ) != NULL )
5619 [ + - ]: 61813 : entity_ptr->auto_actuate_cubit_attrib(CUBIT_FALSE);
5620 : : }
5621 : :
5622 : : // actuate deferred attribs
5623 [ + - ]: 1137 : CADeferredAttrib::cleanup_cadas(CUBIT_TRUE, CUBIT_TRUE);
5624 : :
5625 : : // finally, actuate the attributes that go after all other geometry changes
5626 [ + + ]: 5685 : for( i = 0; i < 4; i++ )
5627 : : {
5628 [ + - ]: 4548 : actuate_set.set_current_dimension( i );
5629 [ + - ][ + + ]: 64559 : while( (entity_ptr = actuate_set.remove_next() ) != NULL )
5630 [ + - ]: 60011 : entity_ptr->auto_actuate_cubit_attrib(CUBIT_FALSE, CUBIT_TRUE);
5631 : : }
5632 : :
5633 [ + - ]: 1137 : return CUBIT_SUCCESS;
5634 : : }
5635 : :
5636 : 389 : CubitBoolean GeometryQueryTool::okay_to_transform( Body* body ) const
5637 : : {
5638 [ + - ]: 389 : MergeTool* mt = MergeTool::instance();
5639 : : int i;
5640 : :
5641 : : // Check for merged vertices
5642 [ + - ]: 389 : DLIList<RefVertex*> vertices;
5643 [ + - ]: 389 : body->ref_vertices( vertices );
5644 [ + - ][ + + ]: 2661 : for (i = vertices.size(); i--; )
5645 [ + - ][ + - ]: 2272 : if ( mt->entity_merged( vertices.get_and_step() ) )
[ - + ]
5646 : : {
5647 [ # # ][ # # ]: 0 : PRINT_ERROR("Cannot transform %s (Body %d) with merged geomtery.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5648 [ # # ]: 0 : body->entity_name().c_str(), body->id() );
5649 : 0 : return CUBIT_FALSE;
5650 : : }
5651 : :
5652 : : // Need to check for merged surfaces because can have surfaces
5653 : : // w/out vertices.
5654 [ + - ][ + - ]: 778 : DLIList<RefFace*> surfaces;
5655 [ + - ]: 389 : body->ref_faces( surfaces );
5656 [ + - ][ + + ]: 2107 : for (i = surfaces.size(); i--; )
5657 [ + - ][ + - ]: 1718 : if ( mt->entity_merged( surfaces.get_and_step() ) )
[ - + ]
5658 : : {
5659 [ # # ][ # # ]: 0 : PRINT_ERROR("Cannot transform %s (Body %d) with merged geomtery.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5660 [ # # ]: 0 : body->entity_name().c_str(), body->id() );
5661 : 0 : return CUBIT_FALSE;
5662 : : }
5663 : :
5664 [ + - ]: 778 : return CUBIT_TRUE;
5665 : : }
5666 : :
5667 : 0 : void GeometryQueryTool::translate( DLIList<RefEntity*> &entities_to_transform,
5668 : : double x, double y, double z, bool check_before_transforming,
5669 : : DLIList<RefEntity*> &entities_transformed,
5670 : : bool preview /*= false*/)
5671 : : {
5672 [ # # ]: 0 : CubitVector delta(x,y,z);
5673 : :
5674 : : //translate free, merged-away entities first
5675 [ # # ]: 0 : DLIList<TopologyBridge*> free_ents;
5676 [ # # ]: 0 : get_merged_away_free_entities( entities_to_transform, free_ents );
5677 : :
5678 : : int i;
5679 [ # # ]: 0 : if (!preview)
5680 : : {
5681 [ # # ][ # # ]: 0 : for( i=free_ents.size(); i--; )
5682 : : {
5683 [ # # ]: 0 : TopologyBridge *bridge = free_ents.get_and_step();
5684 [ # # ]: 0 : Curve *curve= CAST_TO( bridge, Curve );
5685 [ # # ]: 0 : TBPoint *point = CAST_TO( bridge, TBPoint );
5686 : :
5687 [ # # ][ # # ]: 0 : if( curve || point )
5688 : : {
5689 [ # # ]: 0 : GeometryEntity *geom = CAST_TO( bridge, GeometryEntity );
5690 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
5691 [ # # ]: 0 : CubitStatus result = engine->translate( geom, delta );
5692 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
5693 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::translate failed.\n");
[ # # ][ # # ]
5694 : 0 : return;
5695 : : }
5696 : : }
5697 : : }
5698 : : }
5699 : :
5700 : : RefFace *tmp_face;
5701 : : RefEdge *tmp_curve;
5702 : : RefVertex *tmp_vertex;
5703 : 0 : CubitStatus result = CUBIT_SUCCESS;
5704 : :
5705 [ # # ][ # # ]: 0 : DLIList<Body*> bodies_to_translate;
[ # # ][ # # ]
5706 [ # # ][ # # ]: 0 : DLIList<BasicTopologyEntity*> ents_to_translate;
5707 [ # # ][ # # ]: 0 : CAST_LIST( entities_to_transform, bodies_to_translate, Body);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5708 : :
5709 [ # # ][ # # ]: 0 : if( bodies_to_translate.size() != entities_to_transform.size() )
[ # # ]
5710 : : {
5711 [ # # ][ # # ]: 0 : for( int k=0; k<entities_to_transform.size(); k++ )
5712 : : {
5713 [ # # ]: 0 : RefEntity *ent = entities_to_transform[k];
5714 : :
5715 [ # # ][ # # ]: 0 : if( ( tmp_face = CAST_TO( ent, RefFace ) ) != NULL )
5716 [ # # ]: 0 : ents_to_translate.append( tmp_face );
5717 [ # # ][ # # ]: 0 : else if( (tmp_curve = CAST_TO( ent, RefEdge ) ) != NULL )
5718 [ # # ]: 0 : ents_to_translate.append( tmp_curve );
5719 [ # # ][ # # ]: 0 : else if( (tmp_vertex = CAST_TO( ent, RefVertex ) ) != NULL )
5720 [ # # ]: 0 : ents_to_translate.append( tmp_vertex );
5721 : : }
5722 : : }
5723 : :
5724 : :
5725 [ # # ][ # # ]: 0 : if( bodies_to_translate.size() )
5726 : : {
5727 [ # # ]: 0 : DLIList<Body*> bodies_translated;
5728 : : result = translate( bodies_to_translate,
5729 : : CubitVector(x,y,z),
5730 : : &bodies_translated,
5731 : : check_before_transforming,
5732 [ # # ][ # # ]: 0 : preview );
5733 : :
5734 [ # # ]: 0 : if( result )
5735 : : {
5736 [ # # ][ # # ]: 0 : for( int k=0; k<bodies_translated.size(); k++ )
5737 [ # # ][ # # ]: 0 : entities_transformed.append( bodies_translated[k] );
[ # # ]
5738 [ # # ]: 0 : }
5739 : : }
5740 : :
5741 [ # # ][ # # ]: 0 : if( ents_to_translate.size() )
5742 : : {
5743 [ # # ]: 0 : DLIList<BasicTopologyEntity*> btes_translated;
5744 : : result = translate( ents_to_translate,
5745 : : CubitVector(x,y,z),
5746 : : &btes_translated,
5747 : : check_before_transforming,
5748 [ # # ][ # # ]: 0 : preview );
5749 : :
5750 [ # # ]: 0 : if( result )
5751 : : {
5752 [ # # ][ # # ]: 0 : for( int k=0; k<btes_translated.size(); k++ )
5753 [ # # ][ # # ]: 0 : entities_transformed.append( btes_translated[k] );
[ # # ]
5754 [ # # ]: 0 : }
5755 : 0 : }
5756 : : }
5757 : :
5758 : :
5759 : 367 : CubitStatus GeometryQueryTool::translate( DLIList<Body*> &bodies,
5760 : : const CubitVector& delta,
5761 : : DLIList<Body*> *bodies_translated,
5762 : : bool check_to_transform,
5763 : : bool preview )
5764 : : {
5765 [ + - ]: 367 : CubitTransformMatrix xform;
5766 [ + - ]: 367 : xform.translate( delta );
5767 : :
5768 [ + - ][ + - ]: 734 : DLIList<RefEntity*> ents_transformed;
5769 : :
5770 [ + - ][ + + ]: 734 : for( int k=0; k<bodies.size(); k++ )
5771 : : {
5772 [ + - ]: 367 : Body *body = bodies[k];
5773 : :
5774 [ + - ]: 367 : if( check_to_transform )
5775 [ + - ][ - + ]: 367 : if (!okay_to_transform( body ))
5776 : 0 : continue;
5777 : :
5778 [ - + ]: 367 : if (preview)
5779 : : {
5780 [ # # ]: 0 : DLIList<RefEdge*> edges;
5781 [ # # ]: 0 : body->ref_edges(edges);
5782 [ # # ][ # # ]: 0 : if( edges.size() )
5783 : : {
5784 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
5785 : : {
5786 [ # # ]: 0 : GMem poly;
5787 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
5788 : : {
5789 [ # # ]: 0 : poly.transform(xform);
5790 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
5791 : : }
5792 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
5793 : : {
5794 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
5795 [ # # ][ # # ]: 0 : tmp_pt = xform*tmp_pt;
5796 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
5797 : : }
5798 [ # # ]: 0 : }
5799 : : }
5800 : : else
5801 : : {
5802 : : //just draw the surfaces
5803 [ # # ]: 0 : DLIList<RefFace*> faces;
5804 [ # # ]: 0 : body->ref_faces( faces );
5805 [ # # ][ # # ]: 0 : for( int i=0; i<faces.size(); i-- )
5806 : : {
5807 [ # # ]: 0 : GMem poly;
5808 [ # # ][ # # ]: 0 : faces.get_and_step()->get_graphics( poly );
5809 [ # # ]: 0 : poly.transform(xform);
5810 : :
5811 [ # # ]: 0 : int* facet_list = poly.facet_list();
5812 [ # # ]: 0 : GPoint* plist = poly.point_list();
5813 : :
5814 : : GPoint p[3];
5815 [ # # ]: 0 : for (i = 0; i < poly.fListCount; )
5816 : : {
5817 : 0 : int sides = facet_list[i++];
5818 [ # # ]: 0 : if (sides != 3)
5819 : : {
5820 : 0 : i += sides;
5821 : 0 : continue;
5822 : : }
5823 : : else
5824 : : {
5825 : 0 : p[0] = plist[facet_list[i++]];
5826 : 0 : p[1] = plist[facet_list[i++]];
5827 : 0 : p[2] = plist[facet_list[i++]];
5828 [ # # ]: 0 : GfxPreview::draw_polygon(p, 3, CUBIT_BLUE_INDEX, CUBIT_BLUE_INDEX, false);
5829 : : }
5830 : : }
5831 [ # # ][ # # ]: 0 : }
5832 : : }
5833 [ # # ]: 0 : GfxPreview::flush();
5834 [ # # ]: 0 : continue;
5835 : : }
5836 : :
5837 [ + - ]: 367 : BodySM* bodysm = body->get_body_sm_ptr();
5838 [ + - ]: 367 : GeometryQueryEngine* engine = bodysm->get_geometry_query_engine();
5839 [ + - ]: 367 : CubitStatus result = engine->translate( bodysm, delta );
5840 [ + - ]: 367 : if (result)
5841 : : {
5842 [ + - ]: 367 : notify_intermediate_of_transform( body, xform );
5843 : :
5844 [ - + ]: 367 : if( bodies_translated )
5845 [ # # ]: 0 : bodies_translated->append( body );
5846 [ + - ][ + - ]: 367 : ents_transformed.append( body );
5847 : : }
5848 : : else
5849 [ # # ][ # # ]: 367 : PRINT_ERROR("Translate of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
5850 [ # # ]: 0 : body->entity_name().c_str(), body->class_name(), body->id() );
5851 : : }
5852 : :
5853 [ + - ][ + - ]: 367 : if( ents_transformed.size() )
5854 : : {
5855 [ + - ]: 367 : notify_observers_of_transform( ents_transformed, &xform );
5856 : 367 : return CUBIT_SUCCESS;
5857 : : }
5858 [ # # ]: 0 : else if( preview )
5859 : 0 : return CUBIT_SUCCESS;
5860 : : else
5861 [ + - ]: 367 : return CUBIT_FAILURE;
5862 : : }
5863 : :
5864 : 0 : CubitStatus GeometryQueryTool::rotate( DLIList<RefEntity*> &entities_to_transform,
5865 : : const CubitVector& point,
5866 : : const CubitVector& direction,
5867 : : double angle,
5868 : : bool check_before_transforming,
5869 : : DLIList<RefEntity*> &entities_transformed,
5870 : : bool preview /*= false*/)
5871 : : {
5872 : : //rotate free, merged-away entities first
5873 [ # # ]: 0 : DLIList<TopologyBridge*> free_ents;
5874 [ # # ]: 0 : get_merged_away_free_entities( entities_to_transform, free_ents );
5875 : :
5876 : : int i;
5877 [ # # ]: 0 : if (!preview)
5878 : : {
5879 [ # # ][ # # ]: 0 : for( i=free_ents.size(); i--; )
5880 : : {
5881 [ # # ]: 0 : TopologyBridge *bridge = free_ents.get_and_step();
5882 [ # # ]: 0 : Curve *curve= CAST_TO( bridge, Curve );
5883 [ # # ]: 0 : TBPoint *tmp_point = CAST_TO( bridge, TBPoint );
5884 : :
5885 [ # # ][ # # ]: 0 : if( curve || tmp_point )
5886 : : {
5887 [ # # ]: 0 : GeometryEntity *geom = CAST_TO( bridge, GeometryEntity );
5888 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
5889 [ # # ][ # # ]: 0 : CubitStatus result = engine->translate( geom, -point );
5890 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
5891 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::translate failed.\n");
[ # # ][ # # ]
5892 : 0 : return result;
5893 : : }
5894 [ # # ]: 0 : result = engine->rotate( geom, direction, angle );
5895 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
5896 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::rotate failed.\n");
[ # # ][ # # ]
5897 : 0 : return result;
5898 : : }
5899 [ # # ]: 0 : result = engine->translate( geom, point );
5900 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
5901 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::translate failed.\n");
[ # # ][ # # ]
5902 : 0 : return result;
5903 : : }
5904 : : }
5905 : : }
5906 : : }
5907 : :
5908 : : RefFace *tmp_face;
5909 : : RefEdge *tmp_curve;
5910 : : RefVertex *tmp_vertex;
5911 : 0 : CubitStatus result = CUBIT_SUCCESS;
5912 : :
5913 [ # # ][ # # ]: 0 : DLIList<Body*> bodies_to_rotate;
5914 [ # # ][ # # ]: 0 : DLIList<BasicTopologyEntity*> ents_to_rotate;
5915 [ # # ][ # # ]: 0 : CAST_LIST( entities_to_transform, bodies_to_rotate, Body);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
5916 : :
5917 [ # # ][ # # ]: 0 : if( bodies_to_rotate.size() != entities_to_transform.size() )
[ # # ]
5918 : : {
5919 [ # # ][ # # ]: 0 : for( int k=0; k<entities_to_transform.size(); k++ )
5920 : : {
5921 [ # # ]: 0 : RefEntity *ent = entities_to_transform[k];
5922 : :
5923 [ # # ][ # # ]: 0 : if( ( tmp_face = CAST_TO( ent, RefFace ) ) != NULL )
5924 [ # # ]: 0 : ents_to_rotate.append( tmp_face );
5925 [ # # ][ # # ]: 0 : else if( (tmp_curve = CAST_TO( ent, RefEdge ) ) != NULL )
5926 [ # # ]: 0 : ents_to_rotate.append( tmp_curve );
5927 [ # # ][ # # ]: 0 : else if( (tmp_vertex = CAST_TO( ent, RefVertex ) ) != NULL )
5928 [ # # ]: 0 : ents_to_rotate.append( tmp_vertex );
5929 : : }
5930 : : }
5931 : :
5932 : :
5933 [ # # ][ # # ]: 0 : if( bodies_to_rotate.size() )
5934 : : {
5935 [ # # ]: 0 : DLIList<Body*> bodies_rotated;
5936 : :
5937 : : result = rotate( bodies_to_rotate,
5938 : : point, direction, angle,
5939 : : &bodies_rotated,
5940 [ # # ]: 0 : check_before_transforming, preview);
5941 : :
5942 [ # # ]: 0 : if( result )
5943 : : {
5944 [ # # ][ # # ]: 0 : for( int k=0; k<bodies_rotated.size(); k++ )
5945 [ # # ][ # # ]: 0 : entities_transformed.append( bodies_rotated[k] );
[ # # ]
5946 [ # # ]: 0 : }
5947 : : }
5948 : :
5949 [ # # ][ # # ]: 0 : if( ents_to_rotate.size() )
5950 : : {
5951 [ # # ]: 0 : DLIList<BasicTopologyEntity*> btes_rotated;
5952 : :
5953 : : result = rotate( ents_to_rotate,
5954 : : point,
5955 : : direction,
5956 : : angle,
5957 : : &btes_rotated,
5958 : : check_before_transforming,
5959 [ # # ]: 0 : preview );
5960 : :
5961 [ # # ]: 0 : if( result )
5962 : : {
5963 [ # # ][ # # ]: 0 : for( int k=0; k<btes_rotated.size(); k++ )
5964 [ # # ][ # # ]: 0 : entities_transformed.append( btes_rotated[k] );
[ # # ]
5965 [ # # ]: 0 : }
5966 : : }
5967 : :
5968 [ # # ][ # # ]: 0 : if( entities_transformed.size() )
5969 : 0 : return CUBIT_SUCCESS;
5970 : : else
5971 [ # # ]: 0 : return CUBIT_FAILURE;
5972 : : }
5973 : :
5974 : 11 : CubitStatus GeometryQueryTool::rotate( DLIList<Body*> &bodies,
5975 : : const CubitVector& axis,
5976 : : double angle,
5977 : : DLIList<Body*> *bodies_rotated,
5978 : : bool check_to_transform,
5979 : : bool preview )
5980 : : {
5981 [ + - ]: 11 : CubitTransformMatrix xform;
5982 [ + - ]: 11 : xform.rotate( angle, axis );
5983 : :
5984 [ + - ][ + - ]: 22 : DLIList<RefEntity*> ents_transformed;
5985 : :
5986 [ + - ][ + + ]: 22 : for( int k=0; k<bodies.size(); k++ )
5987 : : {
5988 [ + - ]: 11 : Body *body = bodies[k];
5989 : :
5990 [ + - ]: 11 : if( check_to_transform )
5991 [ + - ][ - + ]: 11 : if (!okay_to_transform( body ))
5992 : 0 : continue;
5993 : :
5994 [ - + ]: 11 : if (preview)
5995 : : {
5996 [ # # ]: 0 : DLIList<RefEdge*> edges;
5997 [ # # ]: 0 : body->ref_edges(edges);
5998 [ # # ][ # # ]: 0 : if( edges.size() )
5999 : : {
6000 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
6001 : : {
6002 [ # # ]: 0 : GMem poly;
6003 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
6004 : : {
6005 [ # # ]: 0 : poly.transform(xform);
6006 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
6007 : : }
6008 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
6009 : : {
6010 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
6011 [ # # ][ # # ]: 0 : tmp_pt = xform*tmp_pt;
6012 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
6013 : : }
6014 [ # # ]: 0 : }
6015 : : }
6016 : : else
6017 : : {
6018 : : //just draw the surfaces
6019 [ # # ]: 0 : DLIList<RefFace*> faces;
6020 [ # # ]: 0 : body->ref_faces( faces );
6021 [ # # ][ # # ]: 0 : for( int i=0; i<faces.size(); i-- )
6022 : : {
6023 [ # # ]: 0 : GMem poly;
6024 [ # # ][ # # ]: 0 : faces.get_and_step()->get_graphics( poly );
6025 [ # # ]: 0 : poly.transform(xform);
6026 : :
6027 [ # # ]: 0 : int* facet_list = poly.facet_list();
6028 [ # # ]: 0 : GPoint* plist = poly.point_list();
6029 : :
6030 : : GPoint p[3];
6031 [ # # ]: 0 : for (i = 0; i < poly.fListCount; )
6032 : : {
6033 : 0 : int sides = facet_list[i++];
6034 [ # # ]: 0 : if (sides != 3)
6035 : : {
6036 : 0 : i += sides;
6037 : 0 : continue;
6038 : : }
6039 : : else
6040 : : {
6041 : 0 : p[0] = plist[facet_list[i++]];
6042 : 0 : p[1] = plist[facet_list[i++]];
6043 : 0 : p[2] = plist[facet_list[i++]];
6044 [ # # ]: 0 : GfxPreview::draw_polygon(p, 3, CUBIT_BLUE_INDEX, CUBIT_BLUE_INDEX, false);
6045 : : }
6046 : : }
6047 [ # # ][ # # ]: 0 : }
6048 : : }
6049 [ # # ]: 0 : GfxPreview::flush();
6050 [ # # ]: 0 : continue;
6051 : : }
6052 : :
6053 [ + - ]: 11 : BodySM* bodysm = body->get_body_sm_ptr();
6054 [ + - ]: 11 : GeometryQueryEngine* engine = bodysm->get_geometry_query_engine();
6055 [ + - ]: 11 : CubitStatus result = engine->rotate( bodysm, axis, angle );
6056 : :
6057 [ + - ]: 11 : if (result)
6058 : : {
6059 [ + - ]: 11 : notify_intermediate_of_transform( body, xform );
6060 : :
6061 [ - + ]: 11 : if( bodies_rotated )
6062 [ # # ]: 0 : bodies_rotated->append( body );
6063 [ + - ][ + - ]: 11 : ents_transformed.append( body );
6064 : : }
6065 : : else
6066 [ # # ][ # # ]: 11 : PRINT_ERROR("Rotate of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6067 [ # # ]: 0 : body->entity_name().c_str(), body->class_name(), body->id() );
6068 : : }
6069 : :
6070 [ + - ][ + - ]: 11 : if( ents_transformed.size() )
6071 : : {
6072 [ + - ]: 11 : notify_observers_of_transform( ents_transformed, &xform );
6073 : 11 : return CUBIT_SUCCESS;
6074 : : }
6075 [ # # ]: 0 : else if( preview )
6076 : 0 : return CUBIT_SUCCESS;
6077 : : else
6078 [ + - ]: 11 : return CUBIT_FAILURE;
6079 : : }
6080 : :
6081 : 0 : CubitStatus GeometryQueryTool::rotate( DLIList<Body*> &bodies,
6082 : : const CubitVector& point,
6083 : : const CubitVector& direction,
6084 : : double degrees,
6085 : : DLIList<Body*> *bodies_rotated,
6086 : : bool check_to_transform,
6087 : : bool preview /*=false*/)
6088 : : {
6089 [ # # ]: 0 : CubitTransformMatrix prev_xform;
6090 [ # # ][ # # ]: 0 : prev_xform.translate(-point);
6091 : :
6092 [ # # ][ # # ]: 0 : CubitTransformMatrix rot_mat;
6093 [ # # ]: 0 : rot_mat.rotate( degrees, direction );
6094 : :
6095 [ # # ][ # # ]: 0 : CubitTransformMatrix mov_mat;
6096 [ # # ]: 0 : mov_mat.translate( point );
6097 : :
6098 [ # # ][ # # ]: 0 : CubitTransformMatrix total_transform;
6099 [ # # ][ # # ]: 0 : total_transform = mov_mat*rot_mat*prev_xform;
[ # # ][ # # ]
[ # # ]
6100 : :
6101 [ # # ][ # # ]: 0 : DLIList<RefEntity*> ents_transformed;
6102 : :
6103 [ # # ][ # # ]: 0 : for( int k=0; k<bodies.size(); k++ )
6104 : : {
6105 [ # # ]: 0 : Body *body = bodies[k];
6106 : :
6107 [ # # ]: 0 : if( check_to_transform )
6108 [ # # ][ # # ]: 0 : if (!okay_to_transform( body ))
6109 : 0 : continue;
6110 : :
6111 [ # # ]: 0 : if (preview)
6112 : : {
6113 [ # # ]: 0 : DLIList<RefEdge*> edges;
6114 [ # # ]: 0 : body->ref_edges(edges);
6115 [ # # ][ # # ]: 0 : if( edges.size() )
6116 : : {
6117 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
6118 : : {
6119 [ # # ]: 0 : GMem poly;
6120 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
6121 : : {
6122 [ # # ]: 0 : poly.transform( total_transform );
6123 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
6124 : : }
6125 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
6126 : : {
6127 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
6128 [ # # ][ # # ]: 0 : tmp_pt = total_transform*tmp_pt;
6129 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
6130 : : }
6131 [ # # ]: 0 : }
6132 : : }
6133 : : else
6134 : : {
6135 : : //just draw the surfaces
6136 [ # # ]: 0 : DLIList<RefFace*> faces;
6137 [ # # ]: 0 : body->ref_faces( faces );
6138 [ # # ][ # # ]: 0 : for( int i=0; i<faces.size(); i-- )
6139 : : {
6140 [ # # ]: 0 : GMem poly;
6141 [ # # ][ # # ]: 0 : faces.get_and_step()->get_graphics( poly );
6142 [ # # ]: 0 : poly.transform( total_transform );
6143 : :
6144 [ # # ]: 0 : int* facet_list = poly.facet_list();
6145 [ # # ]: 0 : GPoint* plist = poly.point_list();
6146 : :
6147 : : GPoint p[3];
6148 [ # # ]: 0 : for (i = 0; i < poly.fListCount; )
6149 : : {
6150 : 0 : int sides = facet_list[i++];
6151 [ # # ]: 0 : if (sides != 3)
6152 : : {
6153 : 0 : i += sides;
6154 : 0 : continue;
6155 : : }
6156 : : else
6157 : : {
6158 : 0 : p[0] = plist[facet_list[i++]];
6159 : 0 : p[1] = plist[facet_list[i++]];
6160 : 0 : p[2] = plist[facet_list[i++]];
6161 [ # # ]: 0 : GfxPreview::draw_polygon(p, 3, CUBIT_BLUE_INDEX, CUBIT_BLUE_INDEX, false);
6162 : : }
6163 : : }
6164 [ # # ][ # # ]: 0 : }
6165 : : }
6166 [ # # ]: 0 : GfxPreview::flush();
6167 [ # # ]: 0 : continue;
6168 : : }
6169 : :
6170 [ # # ]: 0 : BodySM* bodysm = body->get_body_sm_ptr();
6171 [ # # ]: 0 : GeometryQueryEngine* engine = bodysm->get_geometry_query_engine();
6172 : 0 : CubitStatus result = CUBIT_FAILURE;
6173 : :
6174 : : // Move to origin
6175 [ # # ][ # # ]: 0 : result = engine->translate( bodysm, -point );
6176 : :
6177 [ # # ]: 0 : if (result)
6178 : : {
6179 [ # # ]: 0 : CubitTransformMatrix xform;
6180 [ # # ][ # # ]: 0 : xform.translate( -point );
6181 [ # # ][ # # ]: 0 : notify_intermediate_of_transform( body, xform );
6182 : : }
6183 : : else
6184 : : {
6185 : 0 : continue;
6186 : : }
6187 : :
6188 : : // Rotate about direction vector
6189 [ # # ]: 0 : result = engine->rotate( bodysm, direction, degrees );
6190 [ # # ]: 0 : if (result)
6191 : : {
6192 [ # # ]: 0 : CubitTransformMatrix rot_mat;
6193 [ # # ]: 0 : rot_mat.rotate( degrees, direction );
6194 [ # # ][ # # ]: 0 : notify_intermediate_of_transform( body, rot_mat );
6195 : : }
6196 : : else
6197 : : {
6198 : 0 : continue;
6199 : : }
6200 : :
6201 [ # # ]: 0 : result= engine->translate( bodysm, point );
6202 [ # # ]: 0 : if (result)
6203 : : {
6204 [ # # ]: 0 : CubitTransformMatrix xform;
6205 [ # # ]: 0 : xform.translate( point );
6206 [ # # ]: 0 : notify_intermediate_of_transform( body, xform );
6207 : :
6208 [ # # ]: 0 : if( bodies_rotated )
6209 [ # # ]: 0 : bodies_rotated->append( body );
6210 [ # # ][ # # ]: 0 : ents_transformed.append( body );
[ # # ]
6211 : : }
6212 : : else
6213 : : {
6214 : 0 : continue;
6215 : : }
6216 : : }
6217 : :
6218 [ # # ][ # # ]: 0 : if( ents_transformed.size() )
6219 : : {
6220 [ # # ]: 0 : notify_observers_of_transform( ents_transformed, &total_transform );
6221 : 0 : return CUBIT_SUCCESS;
6222 : : }
6223 [ # # ]: 0 : else if( preview )
6224 : 0 : return CUBIT_SUCCESS;
6225 : : else
6226 [ # # ]: 0 : return CUBIT_FAILURE;
6227 : : }
6228 : :
6229 : 0 : void GeometryQueryTool::scale( DLIList<RefEntity*> &entities_to_transform,
6230 : : const CubitVector& point,
6231 : : double scale_x, double scale_y, double scale_z,
6232 : : bool check_before_transforming,
6233 : : DLIList<RefEntity*> &entities_scaled,
6234 : : bool preview /*= false*/)
6235 : : {
6236 [ # # ]: 0 : CubitVector factors(scale_x, scale_y, scale_z);
6237 : :
6238 : : //scale free, merged-away entities first
6239 [ # # ]: 0 : DLIList<TopologyBridge*> free_ents;
6240 [ # # ]: 0 : get_merged_away_free_entities( entities_to_transform, free_ents );
6241 : : int i;
6242 [ # # ]: 0 : if (!preview)
6243 : : {
6244 [ # # ][ # # ]: 0 : for( i=free_ents.size(); i--; )
6245 : : {
6246 [ # # ]: 0 : TopologyBridge *bridge = free_ents.get_and_step();
6247 [ # # ]: 0 : Curve *curve= CAST_TO( bridge, Curve );
6248 [ # # ]: 0 : TBPoint *tbpoint = CAST_TO( bridge, TBPoint );
6249 : :
6250 [ # # ][ # # ]: 0 : if( curve || tbpoint )
6251 : : {
6252 [ # # ]: 0 : GeometryEntity *geom = CAST_TO( bridge, GeometryEntity );
6253 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
6254 [ # # ][ # # ]: 0 : CubitStatus result = engine->translate( geom, -point );
6255 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
6256 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::translate failed.\n");
[ # # ][ # # ]
6257 : 0 : return;
6258 : : }
6259 [ # # ]: 0 : result = engine->scale( geom, factors );
6260 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
6261 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::scale failed.\n");
[ # # ][ # # ]
6262 : 0 : return;
6263 : : }
6264 [ # # ]: 0 : result = engine->translate( geom, point );
6265 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
6266 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::translate failed.\n");
[ # # ][ # # ]
6267 : 0 : return;
6268 : : }
6269 : : }
6270 : : }
6271 : : }
6272 : :
6273 : :
6274 : 0 : CubitStatus result = CUBIT_SUCCESS;
6275 [ # # ][ # # ]: 0 : for(i=entities_to_transform.size(); i--; )
[ # # ][ # # ]
6276 : : {
6277 [ # # ]: 0 : RefEntity *tmp_ent = entities_to_transform.get_and_step();
6278 : : Body *tmp_body;
6279 : : RefFace* tmp_face;
6280 : : RefEdge *tmp_curve;
6281 : : RefVertex *tmp_vertex;
6282 [ # # ][ # # ]: 0 : if( ( tmp_body = CAST_TO( tmp_ent, Body ) ) != NULL )
6283 : : {
6284 : : //non-uniform scaling
6285 [ # # ][ # # ]: 0 : if( scale_x != scale_y ||
6286 [ # # ]: 0 : scale_x != scale_z ||
6287 : : scale_y != scale_z )
6288 : : {
6289 : : // use GMT version for non-uniform scaling b/c it updates topology if it changes
6290 : :
6291 : : result = GeometryModifyTool::instance()->scale(tmp_body,point, factors,
6292 [ # # ][ # # ]: 0 : check_before_transforming, preview,false);
6293 [ # # ]: 0 : tmp_ent = tmp_body;
6294 : : }
6295 : : else
6296 : : result = scale( tmp_body,point, CubitVector(scale_x, scale_y, scale_z),
6297 [ # # ][ # # ]: 0 : check_before_transforming, preview);
6298 : : }
6299 [ # # ][ # # ]: 0 : else if( ( tmp_face = CAST_TO( tmp_ent, RefFace ) ) != NULL )
6300 : : {
6301 : : // only allow scaling of RefFaces if preview is on
6302 [ # # ]: 0 : if (!preview)
6303 : 0 : continue;
6304 : : result = scale( tmp_face,point, CubitVector(scale_x, scale_y, scale_z),
6305 [ # # ][ # # ]: 0 : check_before_transforming, preview);
6306 : : }
6307 [ # # ][ # # ]: 0 : else if( ( tmp_curve = CAST_TO( tmp_ent, RefEdge ) ) != NULL )
6308 : : {
6309 : : result = scale( tmp_curve,point, CubitVector(scale_x, scale_y, scale_z),
6310 [ # # ][ # # ]: 0 : check_before_transforming, preview);
6311 : : }
6312 [ # # ][ # # ]: 0 : else if( ( tmp_vertex = CAST_TO( tmp_ent, RefVertex ) ) != NULL )
6313 : : {
6314 : : result = scale( tmp_vertex,point, CubitVector(scale_x, scale_y, scale_z),
6315 [ # # ][ # # ]: 0 : check_before_transforming, preview);
6316 : : }
6317 [ # # ]: 0 : if(result)
6318 [ # # ]: 0 : entities_scaled.append( tmp_ent );
6319 : 0 : }
6320 : :
6321 : : }
6322 : :
6323 : :
6324 : 0 : CubitStatus GeometryQueryTool::scale( Body* body,const CubitVector& point, double factor, bool check_to_transform, bool preview )
6325 : : {
6326 [ # # ]: 0 : if( check_to_transform )
6327 [ # # ][ # # ]: 0 : if (!okay_to_transform( body ))
6328 : 0 : return CUBIT_FAILURE;
6329 : :
6330 [ # # ]: 0 : CubitTransformMatrix pre_form;
6331 [ # # ][ # # ]: 0 : pre_form.translate( -point );
6332 : :
6333 [ # # ][ # # ]: 0 : CubitTransformMatrix xform;
6334 [ # # ]: 0 : xform.scale_about_origin( factor );
6335 : :
6336 [ # # ][ # # ]: 0 : CubitTransformMatrix post_form;
6337 [ # # ]: 0 : post_form.translate( point );
6338 : :
6339 [ # # ]: 0 : if (preview)
6340 : : {
6341 [ # # ]: 0 : DLIList<RefEdge*> edges;
6342 [ # # ]: 0 : body->ref_edges(edges);
6343 [ # # ][ # # ]: 0 : if( edges.size() )
6344 : : {
6345 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
6346 : : {
6347 [ # # ]: 0 : GMem poly;
6348 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
6349 : : {
6350 [ # # ]: 0 : poly.transform(pre_form);
6351 [ # # ]: 0 : poly.transform(xform);
6352 [ # # ]: 0 : poly.transform(post_form);
6353 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
6354 : : }
6355 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
6356 : : {
6357 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
6358 [ # # ][ # # ]: 0 : tmp_pt = pre_form*tmp_pt;
6359 [ # # ][ # # ]: 0 : tmp_pt = xform*tmp_pt;
6360 [ # # ][ # # ]: 0 : tmp_pt = post_form*tmp_pt;
6361 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
6362 : : }
6363 [ # # ]: 0 : }
6364 : : }
6365 : : else
6366 : : {
6367 : : //just draw the surfaces
6368 [ # # ]: 0 : DLIList<RefFace*> faces;
6369 [ # # ]: 0 : body->ref_faces( faces );
6370 [ # # ][ # # ]: 0 : for( int i=0; i<faces.size(); i-- )
6371 : : {
6372 [ # # ]: 0 : GMem poly;
6373 [ # # ][ # # ]: 0 : faces.get_and_step()->get_graphics( poly );
6374 [ # # ]: 0 : poly.transform(pre_form);
6375 [ # # ]: 0 : poly.transform(xform);
6376 [ # # ]: 0 : poly.transform(post_form);
6377 : :
6378 [ # # ]: 0 : int* facet_list = poly.facet_list();
6379 [ # # ]: 0 : GPoint* plist = poly.point_list();
6380 : :
6381 : : GPoint p[3];
6382 [ # # ]: 0 : for (i = 0; i < poly.fListCount; )
6383 : : {
6384 : 0 : int sides = facet_list[i++];
6385 [ # # ]: 0 : if (sides != 3)
6386 : : {
6387 : 0 : i += sides;
6388 : 0 : continue;
6389 : : }
6390 : : else
6391 : : {
6392 : 0 : p[0] = plist[facet_list[i++]];
6393 : 0 : p[1] = plist[facet_list[i++]];
6394 : 0 : p[2] = plist[facet_list[i++]];
6395 [ # # ]: 0 : GfxPreview::draw_polygon(p, 3, CUBIT_BLUE_INDEX, CUBIT_BLUE_INDEX, false);
6396 : : }
6397 : : }
6398 [ # # ][ # # ]: 0 : }
6399 : : }
6400 [ # # ]: 0 : GfxPreview::flush();
6401 [ # # ]: 0 : return CUBIT_SUCCESS;
6402 : : }
6403 : :
6404 : :
6405 : :
6406 : : //if (preview)
6407 : : //{
6408 : : // DLIList<RefEdge*> edges;
6409 : : // body->ref_edges(edges);
6410 : : // for (int i = 0; i < edges.size(); i++)
6411 : : // {
6412 : : // GMem poly;
6413 : : // edges[i]->get_graphics(poly);
6414 : : // poly.transform(pre_form);
6415 : : // poly.transform(xform);
6416 : : // poly.transform(post_form);
6417 : : // GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
6418 : : // }
6419 : : // GfxPreview::flush();
6420 : : // return CUBIT_SUCCESS;
6421 : : //}
6422 : :
6423 [ # # ]: 0 : BodySM* bodysm = body->get_body_sm_ptr();
6424 [ # # ]: 0 : GeometryQueryEngine* engine = bodysm->get_geometry_query_engine();
6425 [ # # ][ # # ]: 0 : CubitStatus result = engine->translate( bodysm, -point );
6426 [ # # ]: 0 : if (result)
6427 : : {
6428 [ # # ]: 0 : notify_intermediate_of_transform( body, pre_form );
6429 : : }
6430 : : else
6431 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6432 [ # # ]: 0 : body->entity_name().c_str(), body->class_name(), body->id() );
6433 : :
6434 : :
6435 [ # # ]: 0 : result = engine->scale( bodysm, factor );
6436 [ # # ]: 0 : if (result)
6437 : : {
6438 [ # # ]: 0 : notify_intermediate_of_transform( body, xform );
6439 : : }
6440 : : else
6441 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6442 [ # # ]: 0 : body->entity_name().c_str(), body->class_name(), body->id() );
6443 : :
6444 [ # # ]: 0 : result = engine->translate( bodysm, point );
6445 [ # # ]: 0 : if (result)
6446 : : {
6447 [ # # ]: 0 : notify_intermediate_of_transform( body, post_form );
6448 : : }
6449 : : else
6450 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6451 [ # # ]: 0 : body->entity_name().c_str(), body->class_name(), body->id() );
6452 : :
6453 [ # # ][ # # ]: 0 : notify_observers_of_transform( body );
6454 : :
6455 [ # # ]: 0 : return result;
6456 : : }
6457 : :
6458 : 0 : CubitStatus GeometryQueryTool::scale( Body *body,
6459 : : const CubitVector& point,
6460 : : const CubitVector& factors,
6461 : : bool check_to_transform,
6462 : : bool preview )
6463 : : {
6464 [ # # ]: 0 : if( check_to_transform )
6465 [ # # ][ # # ]: 0 : if (!okay_to_transform( body ))
6466 : 0 : return CUBIT_FAILURE;
6467 : :
6468 [ # # ]: 0 : CubitTransformMatrix pre_form;
6469 [ # # ][ # # ]: 0 : pre_form.translate( -point );
6470 : :
6471 [ # # ][ # # ]: 0 : CubitTransformMatrix xform;
6472 [ # # ]: 0 : xform.scale_about_origin( factors );
6473 : :
6474 [ # # ][ # # ]: 0 : CubitTransformMatrix post_form;
6475 [ # # ]: 0 : post_form.translate( point );
6476 : :
6477 [ # # ]: 0 : if (preview)
6478 : : {
6479 [ # # ]: 0 : DLIList<RefEdge*> edges;
6480 [ # # ]: 0 : body->ref_edges(edges);
6481 [ # # ][ # # ]: 0 : if( edges.size() )
6482 : : {
6483 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
6484 : : {
6485 [ # # ]: 0 : GMem poly;
6486 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
6487 : : {
6488 [ # # ]: 0 : poly.transform(pre_form);
6489 [ # # ]: 0 : poly.transform(xform);
6490 [ # # ]: 0 : poly.transform(post_form);
6491 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
6492 : : }
6493 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
6494 : : {
6495 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
6496 [ # # ][ # # ]: 0 : tmp_pt = pre_form*tmp_pt;
6497 [ # # ][ # # ]: 0 : tmp_pt = xform*tmp_pt;
6498 [ # # ][ # # ]: 0 : tmp_pt = post_form*tmp_pt;
6499 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
6500 : : }
6501 [ # # ]: 0 : }
6502 : : }
6503 : : else
6504 : : {
6505 : : //just draw the surfaces
6506 [ # # ]: 0 : DLIList<RefFace*> faces;
6507 [ # # ]: 0 : body->ref_faces( faces );
6508 [ # # ][ # # ]: 0 : for( int i=0; i<faces.size(); i-- )
6509 : : {
6510 [ # # ]: 0 : GMem poly;
6511 [ # # ][ # # ]: 0 : faces.get_and_step()->get_graphics( poly );
6512 [ # # ]: 0 : poly.transform(pre_form);
6513 [ # # ]: 0 : poly.transform(xform);
6514 [ # # ]: 0 : poly.transform(post_form);
6515 : :
6516 [ # # ]: 0 : int* facet_list = poly.facet_list();
6517 [ # # ]: 0 : GPoint* plist = poly.point_list();
6518 : :
6519 : : GPoint p[3];
6520 [ # # ]: 0 : for (i = 0; i < poly.fListCount; )
6521 : : {
6522 : 0 : int sides = facet_list[i++];
6523 [ # # ]: 0 : if (sides != 3)
6524 : : {
6525 : 0 : i += sides;
6526 : 0 : continue;
6527 : : }
6528 : : else
6529 : : {
6530 : 0 : p[0] = plist[facet_list[i++]];
6531 : 0 : p[1] = plist[facet_list[i++]];
6532 : 0 : p[2] = plist[facet_list[i++]];
6533 [ # # ]: 0 : GfxPreview::draw_polygon(p, 3, CUBIT_BLUE_INDEX, CUBIT_BLUE_INDEX, false);
6534 : : }
6535 : : }
6536 [ # # ][ # # ]: 0 : }
6537 : : }
6538 : :
6539 [ # # ]: 0 : GfxPreview::flush();
6540 [ # # ]: 0 : return CUBIT_SUCCESS;
6541 : : }
6542 : :
6543 [ # # ]: 0 : BodySM* bodysm = body->get_body_sm_ptr();
6544 [ # # ]: 0 : GeometryQueryEngine* engine = bodysm->get_geometry_query_engine();
6545 : :
6546 [ # # ][ # # ]: 0 : CubitStatus result = engine->translate( bodysm, -point );
6547 [ # # ]: 0 : if (result)
6548 : : {
6549 [ # # ]: 0 : notify_intermediate_of_transform( body, pre_form );
6550 : : }
6551 : : else
6552 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6553 [ # # ]: 0 : body->entity_name().c_str(), body->class_name(), body->id() );
6554 : :
6555 : :
6556 [ # # ]: 0 : result = engine->scale( bodysm, factors );
6557 [ # # ]: 0 : if (result)
6558 : : {
6559 [ # # ]: 0 : notify_intermediate_of_transform( body, xform );
6560 : : }
6561 : : else
6562 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6563 [ # # ]: 0 : body->entity_name().c_str(), body->class_name(), body->id() );
6564 : :
6565 [ # # ]: 0 : result = engine->translate( bodysm, point );
6566 [ # # ]: 0 : if (result)
6567 : : {
6568 [ # # ]: 0 : notify_intermediate_of_transform( body, post_form );
6569 : : }
6570 : : else
6571 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6572 [ # # ]: 0 : body->entity_name().c_str(), body->class_name(), body->id() );
6573 : :
6574 [ # # ][ # # ]: 0 : notify_observers_of_transform( body );
6575 : :
6576 [ # # ]: 0 : return result;
6577 : : }
6578 : :
6579 : 0 : void GeometryQueryTool::reflect( DLIList<RefEntity*> &entities_to_reflect,
6580 : : const CubitVector& point,
6581 : : const CubitVector& normal,
6582 : : bool check_before_transforming,
6583 : : DLIList<RefEntity*> &entities_transformed,
6584 : : bool preview /*= false*/)
6585 : : {
6586 : : //reflect free, merged-away entities
6587 [ # # ]: 0 : DLIList<TopologyBridge*> free_ents;
6588 [ # # ]: 0 : get_merged_away_free_entities( entities_to_reflect, free_ents );
6589 : :
6590 : : int i;
6591 [ # # ]: 0 : if (!preview)
6592 : : {
6593 [ # # ][ # # ]: 0 : for( i=free_ents.size(); i--; )
6594 : : {
6595 [ # # ]: 0 : TopologyBridge *bridge = free_ents.get_and_step();
6596 [ # # ]: 0 : Curve *curve= CAST_TO( bridge, Curve );
6597 [ # # ]: 0 : TBPoint *tmp_point = CAST_TO( bridge, TBPoint );
6598 : :
6599 [ # # ][ # # ]: 0 : if( curve || tmp_point )
6600 : : {
6601 [ # # ]: 0 : GeometryEntity *geom = CAST_TO( bridge, GeometryEntity );
6602 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
6603 [ # # ][ # # ]: 0 : CubitStatus result = engine->translate( geom, -point );
6604 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
6605 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::translate failed.\n");
[ # # ][ # # ]
6606 : 0 : return;
6607 : : }
6608 [ # # ]: 0 : result = engine->reflect( geom, normal );
6609 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
6610 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::reflect failed.\n");
[ # # ][ # # ]
6611 : 0 : return;
6612 : : }
6613 [ # # ]: 0 : result = engine->translate( geom, point );
6614 [ # # ]: 0 : if (CUBIT_SUCCESS != result) {
6615 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::translate failed.\n");
[ # # ][ # # ]
6616 : 0 : return;
6617 : : }
6618 : : }
6619 : : }
6620 : : }
6621 : :
6622 : : RefFace *tmp_face;
6623 : : RefEdge *tmp_curve;
6624 : : RefVertex *tmp_vertex;
6625 : : CubitStatus result;
6626 : :
6627 [ # # ][ # # ]: 0 : DLIList<Body*> bodies_to_reflect;
[ # # ][ # # ]
6628 [ # # ][ # # ]: 0 : DLIList<BasicTopologyEntity*> ents_to_reflect;
6629 [ # # ][ # # ]: 0 : CAST_LIST( entities_to_reflect, bodies_to_reflect, Body);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
6630 : :
6631 [ # # ][ # # ]: 0 : if( bodies_to_reflect.size() != entities_to_reflect.size() )
[ # # ]
6632 : : {
6633 [ # # ][ # # ]: 0 : for( int k=0; k<entities_to_reflect.size(); k++ )
6634 : : {
6635 [ # # ]: 0 : RefEntity *ent = entities_to_reflect[k];
6636 : :
6637 [ # # ][ # # ]: 0 : if( ( tmp_face = CAST_TO( ent, RefFace ) ) != NULL )
6638 [ # # ]: 0 : ents_to_reflect.append( tmp_face );
6639 [ # # ][ # # ]: 0 : else if( (tmp_curve = CAST_TO( ent, RefEdge ) ) != NULL )
6640 [ # # ]: 0 : ents_to_reflect.append( tmp_curve );
6641 [ # # ][ # # ]: 0 : else if( (tmp_vertex = CAST_TO( ent, RefVertex ) ) != NULL )
6642 [ # # ]: 0 : ents_to_reflect.append( tmp_vertex );
6643 : : }
6644 : : }
6645 : :
6646 [ # # ][ # # ]: 0 : if( bodies_to_reflect.size() )
6647 : : {
6648 [ # # ]: 0 : DLIList<Body*> bodies_reflected;
6649 : : result = reflect( bodies_to_reflect,
6650 : : point, normal,
6651 : : &bodies_reflected,
6652 [ # # ]: 0 : preview );
6653 : :
6654 [ # # ]: 0 : if( result )
6655 : : {
6656 [ # # ][ # # ]: 0 : for( int k=0; k<bodies_reflected.size(); k++ )
6657 [ # # ][ # # ]: 0 : entities_transformed.append( bodies_reflected[k] );
[ # # ]
6658 [ # # ]: 0 : }
6659 : : }
6660 : :
6661 [ # # ][ # # ]: 0 : if( ents_to_reflect.size() )
6662 : : {
6663 [ # # ]: 0 : DLIList<BasicTopologyEntity*> btes_reflected;
6664 : : result = reflect( ents_to_reflect,
6665 : : point,
6666 : : normal,
6667 : : &btes_reflected,
6668 : : check_before_transforming,
6669 [ # # ]: 0 : preview );
6670 : :
6671 [ # # ]: 0 : if( result )
6672 : : {
6673 [ # # ][ # # ]: 0 : for( int k=0; k<btes_reflected.size(); k++ )
6674 [ # # ][ # # ]: 0 : entities_transformed.append( btes_reflected[k] );
[ # # ]
6675 [ # # ]: 0 : }
6676 : 0 : }
6677 : : }
6678 : :
6679 : 11 : CubitStatus GeometryQueryTool::reflect( DLIList<Body*> &bodies,
6680 : : const CubitVector& point,
6681 : : const CubitVector& normal,
6682 : : DLIList<Body*> *bodies_reflected,
6683 : : bool preview)
6684 : : {
6685 : : Body *tmp_body;
6686 : 11 : CubitStatus result = CUBIT_FAILURE;
6687 : :
6688 [ + - ]: 11 : CubitTransformMatrix prev_xform;
6689 [ + - ][ + - ]: 11 : prev_xform.translate(-point);
6690 : :
6691 [ + - ][ + - ]: 22 : CubitTransformMatrix ref_mat;
6692 [ + - ]: 11 : ref_mat.reflect(normal );
6693 : :
6694 [ + - ][ + - ]: 22 : CubitTransformMatrix mov_mat;
6695 [ + - ]: 11 : mov_mat.translate( point );
6696 : :
6697 [ + - ][ + - ]: 22 : CubitTransformMatrix total_transform;
6698 [ + - ][ + - ]: 11 : total_transform = mov_mat*ref_mat*prev_xform;
[ + - ][ + - ]
[ + - ]
6699 : :
6700 [ + - ][ + - ]: 22 : DLIList<RefEntity*> ents_transformed;
6701 : :
6702 [ - + ]: 11 : if (preview)
6703 : : {
6704 [ # # ][ # # ]: 0 : for (int i = 0; i < bodies.size(); i++)
6705 : : {
6706 [ # # ]: 0 : DLIList<RefEdge*> edges;
6707 [ # # ][ # # ]: 0 : bodies[i]->ref_edges(edges);
6708 [ # # ][ # # ]: 0 : if( edges.size() )
6709 : : {
6710 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
6711 : : {
6712 [ # # ]: 0 : GMem poly;
6713 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
6714 : : {
6715 [ # # ]: 0 : poly.transform( total_transform );
6716 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
6717 : : }
6718 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
6719 : : {
6720 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
6721 [ # # ][ # # ]: 0 : tmp_pt = total_transform*tmp_pt;
6722 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
6723 : : }
6724 [ # # ]: 0 : }
6725 : : }
6726 : : else
6727 : : {
6728 : : //just draw the surfaces
6729 [ # # ]: 0 : DLIList<RefFace*> faces;
6730 [ # # ][ # # ]: 0 : bodies[i]->ref_faces( faces );
6731 [ # # ][ # # ]: 0 : for( int i=0; i<faces.size(); i-- )
6732 : : {
6733 [ # # ]: 0 : GMem poly;
6734 [ # # ][ # # ]: 0 : faces.get_and_step()->get_graphics( poly );
6735 [ # # ]: 0 : poly.transform( total_transform );
6736 : :
6737 [ # # ]: 0 : int* facet_list = poly.facet_list();
6738 [ # # ]: 0 : GPoint* plist = poly.point_list();
6739 : :
6740 : : GPoint p[3];
6741 [ # # ]: 0 : for (i = 0; i < poly.fListCount; )
6742 : : {
6743 : 0 : int sides = facet_list[i++];
6744 [ # # ]: 0 : if (sides != 3)
6745 : : {
6746 : 0 : i += sides;
6747 : 0 : continue;
6748 : : }
6749 : : else
6750 : : {
6751 : 0 : p[0] = plist[facet_list[i++]];
6752 : 0 : p[1] = plist[facet_list[i++]];
6753 : 0 : p[2] = plist[facet_list[i++]];
6754 [ # # ]: 0 : GfxPreview::draw_polygon(p, 3, CUBIT_BLUE_INDEX, CUBIT_BLUE_INDEX, false);
6755 : : }
6756 : : }
6757 [ # # ][ # # ]: 0 : }
6758 : : }
6759 [ # # ]: 0 : GfxPreview::flush();
6760 [ # # ]: 0 : }
6761 : 0 : return CUBIT_SUCCESS;
6762 : : }
6763 : : //first, reflect the underlying geometry
6764 : : int i;
6765 [ + - ][ + + ]: 22 : for( i=bodies.size(); i--;)
6766 : : {
6767 [ + - ]: 11 : tmp_body = bodies.get_and_step();
6768 [ + - ]: 11 : BodySM* bodysm = tmp_body->get_body_sm_ptr();
6769 [ + - ]: 11 : GeometryQueryEngine* engine = bodysm->get_geometry_query_engine();
6770 : :
6771 : : // Move to origin
6772 [ + - ][ + - ]: 11 : result = engine->translate( bodysm, -point );
6773 [ + - ]: 11 : if (result)
6774 : : {
6775 [ + - ]: 11 : CubitTransformMatrix xform;
6776 [ + - ][ + - ]: 11 : xform.translate( -point );
6777 [ + - ][ + - ]: 11 : notify_intermediate_of_transform( tmp_body, xform );
6778 : : }
6779 : : else
6780 : : {
6781 [ # # ][ # # ]: 0 : PRINT_ERROR("Reflect of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6782 [ # # ]: 0 : tmp_body->entity_name().c_str(), tmp_body->class_name(), tmp_body->id() );
6783 : 0 : return result;
6784 : : }
6785 : :
6786 [ + - ]: 11 : result = engine->reflect( bodysm, normal );
6787 [ + - ]: 11 : if (result)
6788 : : {
6789 [ + - ]: 11 : CubitTransformMatrix xform;
6790 [ + - ]: 11 : xform.reflect( normal);
6791 [ + - ][ + - ]: 11 : notify_intermediate_of_transform( tmp_body, xform );
6792 : : }
6793 : : else
6794 : : {
6795 [ # # ][ # # ]: 0 : PRINT_ERROR("Reflect of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6796 [ # # ]: 0 : tmp_body->entity_name().c_str(), tmp_body->class_name(), tmp_body->id() );
6797 : 0 : return result;
6798 : : }
6799 : :
6800 [ + - ]: 11 : result = engine->translate( bodysm, point );
6801 [ + - ]: 11 : if (result)
6802 : : {
6803 [ + - ]: 11 : CubitTransformMatrix xform;
6804 [ + - ]: 11 : xform.translate( point );
6805 [ + - ]: 11 : notify_intermediate_of_transform( tmp_body, xform );
6806 : :
6807 [ - + ]: 11 : if( bodies_reflected )
6808 [ # # ]: 0 : bodies_reflected->append( tmp_body );
6809 [ + - ][ + - ]: 11 : ents_transformed.append( tmp_body );
[ + - ]
6810 : : }
6811 : : else
6812 : : {
6813 [ # # ][ # # ]: 0 : PRINT_ERROR("Reflect of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6814 [ # # ]: 0 : tmp_body->entity_name().c_str(), tmp_body->class_name(), tmp_body->id() );
6815 : 0 : return result;
6816 : : }
6817 : : }
6818 : :
6819 [ + - ][ + + ]: 22 : for( i=0; i<ents_transformed.size(); i++)
6820 : : {
6821 [ + - ][ + - ]: 11 : tmp_body = (Body*)ents_transformed[i];
6822 [ + - ][ + - ]: 11 : tmp_body = make_Body( tmp_body->get_body_sm_ptr() );
6823 [ + - ][ + - ]: 11 : if( tmp_body != ents_transformed[i] )
[ - + ]
6824 [ # # ][ # # ]: 0 : ents_transformed[i] = tmp_body;
6825 : : }
6826 : :
6827 [ + - ][ + - ]: 11 : if( ents_transformed.size() )
6828 : : {
6829 [ + - ]: 11 : notify_observers_of_transform( ents_transformed, &total_transform );
6830 : 11 : return CUBIT_SUCCESS;
6831 : : }
6832 [ # # ]: 0 : else if( preview )
6833 : 0 : return CUBIT_SUCCESS;
6834 : : else
6835 [ + - ]: 11 : return CUBIT_FAILURE;
6836 : : }
6837 : :
6838 : 444 : CubitStatus GeometryQueryTool::notify_intermediate_of_transform(
6839 : : TopologyEntity* entity,
6840 : : const CubitTransformMatrix& xform ) const
6841 : : {
6842 [ + - ][ + - ]: 1332 : for (IGESet::const_iterator iter = igeSet.begin(); iter != igeSet.end(); ++iter)
[ + - ][ + - ]
[ + + ]
6843 [ + - ][ + - ]: 888 : (*iter)->notify_transform( entity->bridge_manager()->topology_bridge(), xform );
[ + - ][ + - ]
6844 : 444 : return CUBIT_SUCCESS;
6845 : : }
6846 : :
6847 : 389 : void GeometryQueryTool::notify_observers_of_transform(
6848 : : DLIList<RefEntity*> &ref_ents,
6849 : : const CubitTransformMatrix *xform ) const
6850 : : {
6851 [ + - ]: 389 : if( xform )
6852 : : {
6853 : : //gather all the children
6854 [ + - ]: 389 : DLIList<RefEntity*> all_ref_ents;
6855 [ + - ]: 389 : RefEntity::get_all_child_ref_entities( ref_ents, all_ref_ents );
6856 [ + - ]: 389 : all_ref_ents.uniquify_ordered();
6857 : :
6858 [ + - ]: 389 : all_ref_ents += ref_ents;
6859 : :
6860 [ + - ][ + + ]: 8369 : for(int i=0; i<all_ref_ents.size(); i++)
6861 : : {
6862 [ + - ][ + - ]: 7980 : GeometryEvent evt(GeometryEvent::GEOMETRY_TRANSFORMED, all_ref_ents[i]);
6863 [ + - ][ + - ]: 7980 : all_ref_ents[i]->notify_observers(&evt);
6864 [ + - ]: 7980 : }
6865 : :
6866 [ + - ][ + - ]: 389 : AppUtil::instance()->send_event(TransformEvent(*xform, all_ref_ents.as_vector() ));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
6867 : : }
6868 : : else
6869 : : {
6870 [ # # ]: 0 : for( int i=0; i<ref_ents.size(); i++ )
6871 : : {
6872 : 0 : RefEntity *ent = ref_ents[i];
6873 [ # # ]: 0 : ent->notify_sub_all_observers( GeometryEvent::GEOMETRY_MODIFIED );
6874 : : }
6875 : : }
6876 : 389 : }
6877 : :
6878 : 11 : void GeometryQueryTool::notify_observers_of_transform(
6879 : : RefEntity* ref_entity,
6880 : : const CubitTransformMatrix *xform ) const
6881 : : {
6882 [ + - ]: 11 : ref_entity->notify_sub_all_observers( GeometryEvent::GEOMETRY_MODIFIED );
6883 : :
6884 : : //CGMHistory::Event evt(CGMHistory::GEOMETRY_TRANSFORMED, ref_entity);
6885 : : //const_cast<CGMHistory&>(mHistory).add_event(evt);
6886 : 11 : }
6887 : :
6888 : 0 : CubitBoolean GeometryQueryTool::okay_to_transform( BasicTopologyEntity* bte ) const
6889 : : {
6890 [ # # ][ # # ]: 0 : if (bte->get_parents() > 0)
6891 : : {
6892 [ # # ][ # # ]: 0 : PRINT_ERROR("Cannot transform %s (%s %d) : not a free %s\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
6893 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id(), bte->class_name() );
6894 : 0 : return CUBIT_FALSE;
6895 : : }
6896 : :
6897 [ # # ]: 0 : DLIList<RefEntity*> list(1);
6898 [ # # ][ # # ]: 0 : list.append( bte );
6899 [ # # ][ # # ]: 0 : if (MergeTool::instance()->contains_merged_entities( list ))
[ # # ]
6900 : : {
6901 [ # # ][ # # ]: 0 : PRINT_ERROR("Cannot tranmform %s (%s %d) : "
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
6902 : : "%s is merged or contains merged geomtry.\n",
6903 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id(), bte->class_name() );
6904 : 0 : return CUBIT_FALSE;
6905 : : }
6906 : :
6907 [ # # ]: 0 : return CUBIT_TRUE;
6908 : : }
6909 : :
6910 : 0 : CubitStatus GeometryQueryTool::translate( DLIList<BasicTopologyEntity*> &btes,
6911 : : const CubitVector& delta,
6912 : : DLIList<BasicTopologyEntity*> *btes_translated,
6913 : : bool check_to_transform,
6914 : : bool preview )
6915 : : {
6916 [ # # ]: 0 : CubitTransformMatrix xform;
6917 [ # # ]: 0 : xform.translate(delta);
6918 : :
6919 [ # # ][ # # ]: 0 : DLIList<RefEntity*> transformed_ents;
6920 : :
6921 [ # # ][ # # ]: 0 : for( int k=0; k<btes.size(); k++ )
6922 : : {
6923 [ # # ]: 0 : BasicTopologyEntity *bte = btes[k];
6924 : :
6925 [ # # ]: 0 : if( check_to_transform )
6926 [ # # ][ # # ]: 0 : if (!okay_to_transform( bte ))
6927 : 0 : continue;
6928 : :
6929 [ # # ]: 0 : if (preview)
6930 : : {
6931 [ # # ][ # # ]: 0 : if(bte->dimension()==0)
6932 : : {
6933 [ # # ]: 0 : DLIList<RefVertex*> points;
6934 [ # # ]: 0 : bte->ref_vertices(points);
6935 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
6936 : : {
6937 [ # # ][ # # ]: 0 : CubitVector temp(points[i]->center_point());
6938 [ # # ][ # # ]: 0 : temp = xform*temp;
6939 [ # # ]: 0 : GfxPreview::draw_point(temp, CUBIT_BLUE_INDEX);
6940 [ # # ]: 0 : }
6941 : : }
6942 : : else
6943 : : {
6944 [ # # ]: 0 : DLIList<RefEdge*> edges;
6945 [ # # ]: 0 : bte->ref_edges(edges);
6946 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
6947 : : {
6948 [ # # ]: 0 : GMem poly;
6949 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
6950 : : {
6951 [ # # ]: 0 : poly.transform(xform);
6952 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
6953 : : }
6954 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
6955 : : {
6956 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
6957 [ # # ][ # # ]: 0 : tmp_pt = xform*tmp_pt;
6958 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
6959 : : }
6960 [ # # ]: 0 : }
6961 [ # # ][ # # ]: 0 : if (edges.size() == 0)
6962 : : {
6963 [ # # ]: 0 : DLIList<RefVertex*> points;
6964 [ # # ]: 0 : bte->ref_vertices(points);
6965 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
6966 : : {
6967 [ # # ][ # # ]: 0 : CubitVector temp(points[i]->center_point());
6968 [ # # ][ # # ]: 0 : temp=xform*temp;
6969 [ # # ]: 0 : GfxPreview::draw_point(temp, CUBIT_BLUE_INDEX);
6970 [ # # ]: 0 : }
6971 [ # # ]: 0 : }
6972 : : }
6973 [ # # ]: 0 : GfxPreview::flush();
6974 : 0 : continue;
6975 : : }
6976 : :
6977 [ # # ]: 0 : GeometryEntity* geom = bte->get_geometry_entity_ptr();
6978 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
6979 [ # # ]: 0 : CubitStatus result = engine->translate( geom, delta );
6980 [ # # ]: 0 : if (result)
6981 : : {
6982 [ # # ]: 0 : notify_intermediate_of_transform( bte, xform );
6983 : :
6984 [ # # ]: 0 : if( btes_translated )
6985 [ # # ]: 0 : btes_translated->append( bte );
6986 [ # # ][ # # ]: 0 : transformed_ents.append( bte );
6987 : : }
6988 : : else
6989 [ # # ][ # # ]: 0 : PRINT_ERROR("Translate of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
6990 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
6991 : : }
6992 : :
6993 [ # # ][ # # ]: 0 : if( transformed_ents.size() )
6994 : : {
6995 [ # # ]: 0 : notify_observers_of_transform( transformed_ents, &xform );
6996 : 0 : return CUBIT_SUCCESS;
6997 : : }
6998 [ # # ]: 0 : else if( preview )
6999 : 0 : return CUBIT_SUCCESS;
7000 : : else
7001 [ # # ]: 0 : return CUBIT_FAILURE;
7002 : : }
7003 : :
7004 : 0 : CubitStatus GeometryQueryTool::rotate( DLIList<BasicTopologyEntity*> &btes,
7005 : : const CubitVector& point,
7006 : : const CubitVector& direction,
7007 : : double angle,
7008 : : DLIList<BasicTopologyEntity*> *btes_rotated,
7009 : : bool check_to_transform,
7010 : : bool preview )
7011 : : {
7012 [ # # ]: 0 : CubitTransformMatrix prev_xform;
7013 [ # # ][ # # ]: 0 : prev_xform.translate(-point);
7014 : :
7015 [ # # ][ # # ]: 0 : CubitTransformMatrix rot_mat;
7016 [ # # ]: 0 : rot_mat.rotate( angle, direction );
7017 : :
7018 [ # # ][ # # ]: 0 : CubitTransformMatrix mov_mat;
7019 [ # # ]: 0 : mov_mat.translate( point );
7020 : :
7021 [ # # ][ # # ]: 0 : CubitTransformMatrix total_transform;
7022 [ # # ][ # # ]: 0 : total_transform = mov_mat*rot_mat*prev_xform;
[ # # ][ # # ]
[ # # ]
7023 : :
7024 [ # # ][ # # ]: 0 : DLIList<RefEntity*> ents_transformed;
7025 : :
7026 [ # # ][ # # ]: 0 : for( int k=0; k<btes.size(); k++ )
7027 : : {
7028 [ # # ]: 0 : BasicTopologyEntity *bte = btes[k];
7029 : :
7030 [ # # ]: 0 : if( check_to_transform )
7031 [ # # ][ # # ]: 0 : if (!okay_to_transform( bte ))
7032 : 0 : continue;
7033 : :
7034 [ # # ]: 0 : if (preview)
7035 : : {
7036 [ # # ][ # # ]: 0 : if(bte->dimension()==0)
7037 : : {
7038 [ # # ]: 0 : DLIList<RefVertex*> points;
7039 [ # # ]: 0 : bte->ref_vertices(points);
7040 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
7041 : : {
7042 [ # # ][ # # ]: 0 : CubitVector temp(points[i]->center_point());
7043 [ # # ][ # # ]: 0 : temp = total_transform*temp;
7044 [ # # ]: 0 : GfxPreview::draw_point(temp, CUBIT_BLUE_INDEX);
7045 [ # # ]: 0 : }
7046 : : }
7047 : : else
7048 : : {
7049 : :
7050 [ # # ]: 0 : DLIList<RefEdge*> edges;
7051 [ # # ]: 0 : bte->ref_edges(edges);
7052 : :
7053 [ # # ][ # # ]: 0 : for (int j = 0; j < edges.size(); j++)
7054 : : {
7055 [ # # ]: 0 : GMem poly;
7056 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[j]->get_graphics(poly) )
[ # # ]
7057 : : {
7058 [ # # ]: 0 : poly.transform(total_transform);
7059 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
7060 : : }
7061 [ # # ][ # # ]: 0 : else if( edges[j]->start_vertex() == edges[j]->end_vertex() )
[ # # ][ # # ]
[ # # ]
7062 : : {
7063 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[j]->start_vertex()->coordinates();
[ # # ]
7064 [ # # ][ # # ]: 0 : tmp_pt = total_transform*tmp_pt;
7065 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
7066 : : }
7067 [ # # ]: 0 : }
7068 [ # # ][ # # ]: 0 : if (edges.size() == 0)
7069 : : {
7070 [ # # ]: 0 : DLIList<RefVertex*> points;
7071 [ # # ]: 0 : bte->ref_vertices(points);
7072 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
7073 : : {
7074 [ # # ][ # # ]: 0 : CubitVector p(points[i]->center_point());
7075 [ # # ][ # # ]: 0 : p = total_transform*p;
7076 [ # # ]: 0 : GfxPreview::draw_point(p, CUBIT_BLUE_INDEX);
7077 [ # # ]: 0 : }
7078 [ # # ]: 0 : }
7079 : : }
7080 : :
7081 [ # # ]: 0 : GfxPreview::flush();
7082 : 0 : continue;
7083 : : }
7084 : :
7085 [ # # ]: 0 : GeometryEntity* geom = bte->get_geometry_entity_ptr();
7086 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
7087 : : CubitStatus result;
7088 : : // Move to origin
7089 [ # # ][ # # ]: 0 : result = engine->translate( geom, -point );
7090 [ # # ]: 0 : if (result)
7091 : : {
7092 [ # # ]: 0 : CubitTransformMatrix xform;
7093 [ # # ][ # # ]: 0 : xform.translate( -point );
7094 [ # # ][ # # ]: 0 : notify_intermediate_of_transform( bte, xform );
7095 : : }
7096 : : else
7097 : : {
7098 [ # # ][ # # ]: 0 : PRINT_ERROR("Rotate of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7099 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7100 : 0 : continue;
7101 : : }
7102 : :
7103 [ # # ]: 0 : result = engine->rotate( geom, direction, angle );
7104 [ # # ]: 0 : if (result)
7105 : : {
7106 [ # # ]: 0 : CubitTransformMatrix rot_mat;
7107 [ # # ]: 0 : rot_mat.rotate( angle, direction );
7108 [ # # ][ # # ]: 0 : notify_intermediate_of_transform( bte, rot_mat );
7109 : : }
7110 : : else
7111 : : {
7112 [ # # ][ # # ]: 0 : PRINT_ERROR("Rotate of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7113 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7114 : 0 : continue;
7115 : : }
7116 [ # # ]: 0 : result=engine->translate( geom, point );
7117 : :
7118 [ # # ]: 0 : if (result)
7119 : : {
7120 [ # # ]: 0 : CubitTransformMatrix mov_mat;
7121 [ # # ]: 0 : mov_mat.translate( point );
7122 [ # # ]: 0 : notify_intermediate_of_transform( bte, mov_mat );
7123 : :
7124 [ # # ]: 0 : if( btes_rotated )
7125 [ # # ]: 0 : btes_rotated->append( bte );
7126 [ # # ][ # # ]: 0 : ents_transformed.append( bte );
[ # # ]
7127 : : }
7128 : : else
7129 : : {
7130 [ # # ][ # # ]: 0 : PRINT_ERROR("Rotate of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7131 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7132 : 0 : continue;
7133 : : }
7134 : : }
7135 : :
7136 [ # # ][ # # ]: 0 : if( ents_transformed.size() )
7137 : : {
7138 [ # # ]: 0 : notify_observers_of_transform( ents_transformed, &total_transform );
7139 : 0 : return CUBIT_SUCCESS;
7140 : : }
7141 [ # # ]: 0 : else if( preview )
7142 : 0 : return CUBIT_SUCCESS;
7143 : : else
7144 [ # # ]: 0 : return CUBIT_FAILURE;
7145 : : }
7146 : :
7147 : 0 : CubitStatus GeometryQueryTool::rotate( DLIList<BasicTopologyEntity*> &btes,
7148 : : const CubitVector& axis,
7149 : : double angle,
7150 : : DLIList<BasicTopologyEntity*> *btes_rotated,
7151 : : bool check_to_transform,
7152 : : bool preview )
7153 : : {
7154 [ # # ]: 0 : CubitTransformMatrix xform;
7155 [ # # ]: 0 : xform.rotate( angle, axis );
7156 : :
7157 [ # # ][ # # ]: 0 : DLIList<RefEntity*> ents_transformed;
7158 : :
7159 [ # # ][ # # ]: 0 : for( int k=0; k<btes.size(); k++ )
7160 : : {
7161 [ # # ]: 0 : BasicTopologyEntity *bte = btes[k];
7162 : :
7163 [ # # ]: 0 : if( check_to_transform )
7164 [ # # ][ # # ]: 0 : if (!okay_to_transform( bte ))
7165 : 0 : continue;
7166 : :
7167 [ # # ]: 0 : if (preview)
7168 : : {
7169 [ # # ][ # # ]: 0 : if(bte->dimension()==0)
7170 : : {
7171 [ # # ]: 0 : DLIList<RefVertex*> points;
7172 [ # # ]: 0 : bte->ref_vertices(points);
7173 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
7174 : : {
7175 [ # # ][ # # ]: 0 : CubitVector temp(points[i]->center_point());
7176 [ # # ][ # # ]: 0 : temp = xform*temp;
7177 [ # # ]: 0 : GfxPreview::draw_point(temp, CUBIT_BLUE_INDEX);
7178 [ # # ]: 0 : }
7179 : : }
7180 : : else
7181 : : {
7182 [ # # ]: 0 : DLIList<RefEdge*> edges;
7183 [ # # ]: 0 : bte->ref_edges(edges);
7184 : :
7185 [ # # ][ # # ]: 0 : for (int j = 0; j < edges.size(); j++)
7186 : : {
7187 [ # # ]: 0 : GMem poly;
7188 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[j]->get_graphics(poly) )
[ # # ]
7189 : : {
7190 [ # # ]: 0 : poly.transform(xform);
7191 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
7192 : : }
7193 [ # # ][ # # ]: 0 : else if( edges[j]->start_vertex() == edges[j]->end_vertex() )
[ # # ][ # # ]
[ # # ]
7194 : : {
7195 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[j]->start_vertex()->coordinates();
[ # # ]
7196 [ # # ][ # # ]: 0 : tmp_pt = xform*tmp_pt;
7197 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
7198 : : }
7199 [ # # ]: 0 : }
7200 [ # # ][ # # ]: 0 : if (edges.size() == 0)
7201 : : {
7202 [ # # ]: 0 : DLIList<RefVertex*> points;
7203 [ # # ]: 0 : bte->ref_vertices(points);
7204 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
7205 : : {
7206 [ # # ][ # # ]: 0 : CubitVector p(points[i]->center_point());
7207 [ # # ]: 0 : CubitVector q =xform*p;
7208 [ # # ]: 0 : GfxPreview::draw_point(q, CUBIT_BLUE_INDEX);
7209 [ # # ]: 0 : }
7210 [ # # ]: 0 : }
7211 : : }
7212 : :
7213 [ # # ]: 0 : GfxPreview::flush();
7214 : 0 : continue;
7215 : : }
7216 : :
7217 [ # # ]: 0 : GeometryEntity* geom = bte->get_geometry_entity_ptr();
7218 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
7219 [ # # ]: 0 : CubitStatus result = engine->rotate( geom, axis, angle );
7220 [ # # ]: 0 : if (result)
7221 : : {
7222 [ # # ]: 0 : notify_intermediate_of_transform( bte, xform );
7223 : :
7224 [ # # ]: 0 : if( btes_rotated )
7225 [ # # ]: 0 : btes_rotated->append( bte );
7226 [ # # ][ # # ]: 0 : ents_transformed.append( bte );
7227 : : }
7228 : : else
7229 [ # # ][ # # ]: 0 : PRINT_ERROR("Rotate of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7230 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7231 : : }
7232 : :
7233 [ # # ][ # # ]: 0 : if( ents_transformed.size() )
7234 : : {
7235 [ # # ]: 0 : notify_observers_of_transform( ents_transformed, &xform );
7236 : 0 : return CUBIT_SUCCESS;
7237 : : }
7238 [ # # ]: 0 : else if( preview )
7239 : 0 : return CUBIT_SUCCESS;
7240 : : else
7241 [ # # ]: 0 : return CUBIT_FAILURE;
7242 : : }
7243 : :
7244 : 0 : CubitStatus GeometryQueryTool::scale( BasicTopologyEntity* bte,const CubitVector& point, double factor,
7245 : : bool check_to_transform, bool preview )
7246 : : {
7247 [ # # ]: 0 : if( check_to_transform )
7248 [ # # ][ # # ]: 0 : if (!okay_to_transform( bte ))
7249 : 0 : return CUBIT_FAILURE;
7250 : :
7251 [ # # ]: 0 : CubitTransformMatrix prev_xform;
7252 [ # # ][ # # ]: 0 : prev_xform.translate(-point);
7253 : :
7254 [ # # ][ # # ]: 0 : CubitTransformMatrix xform;
7255 [ # # ]: 0 : xform.scale_about_origin( factor );
7256 : :
7257 [ # # ][ # # ]: 0 : CubitTransformMatrix mov_mat;
7258 [ # # ]: 0 : mov_mat.translate( point );
7259 : :
7260 : :
7261 [ # # ]: 0 : if (preview)
7262 : : {
7263 : :
7264 [ # # ][ # # ]: 0 : if(bte->dimension()==0)
7265 : : {
7266 [ # # ]: 0 : DLIList<RefVertex*> points;
7267 [ # # ]: 0 : bte->ref_vertices(points);
7268 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
7269 : : {
7270 [ # # ][ # # ]: 0 : CubitVector temp(points[i]->center_point());
7271 [ # # ][ # # ]: 0 : temp = prev_xform*temp;
7272 [ # # ][ # # ]: 0 : temp = xform*temp;
7273 [ # # ][ # # ]: 0 : temp = mov_mat*temp;
7274 [ # # ]: 0 : GfxPreview::draw_point(temp, CUBIT_BLUE_INDEX);
7275 [ # # ]: 0 : }
7276 : : }
7277 : : else
7278 : : {
7279 : :
7280 [ # # ]: 0 : DLIList<RefEdge*> edges;
7281 [ # # ]: 0 : bte->ref_edges(edges);
7282 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
7283 : : {
7284 [ # # ]: 0 : GMem poly;
7285 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
7286 : : {
7287 [ # # ]: 0 : poly.transform(prev_xform);
7288 [ # # ]: 0 : poly.transform(xform);
7289 [ # # ]: 0 : poly.transform(mov_mat);
7290 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
7291 : : }
7292 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
7293 : : {
7294 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
7295 [ # # ][ # # ]: 0 : tmp_pt = prev_xform*tmp_pt;
7296 [ # # ][ # # ]: 0 : tmp_pt = xform*tmp_pt;
7297 [ # # ][ # # ]: 0 : tmp_pt = mov_mat*tmp_pt;
7298 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
7299 : : }
7300 [ # # ][ # # ]: 0 : }
7301 : : }
7302 [ # # ]: 0 : GfxPreview::flush();
7303 : 0 : return CUBIT_SUCCESS;
7304 : : }
7305 : :
7306 [ # # ]: 0 : GeometryEntity* geom = bte->get_geometry_entity_ptr();
7307 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
7308 [ # # ][ # # ]: 0 : CubitStatus result = engine->translate( geom, -point );
7309 [ # # ]: 0 : if (result)
7310 : : {
7311 [ # # ]: 0 : CubitTransformMatrix prev_xform;
7312 [ # # ][ # # ]: 0 : prev_xform.translate(-point);
7313 [ # # ][ # # ]: 0 : notify_intermediate_of_transform( bte, prev_xform );
7314 : : }
7315 : : else
7316 : : {
7317 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7318 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7319 : 0 : return result;
7320 : : }
7321 : :
7322 [ # # ]: 0 : result = engine->scale( geom, factor );
7323 [ # # ]: 0 : if (result)
7324 : : {
7325 [ # # ]: 0 : CubitTransformMatrix xform;
7326 [ # # ]: 0 : xform.scale_about_origin( factor );
7327 [ # # ][ # # ]: 0 : notify_intermediate_of_transform( bte, xform );
7328 : : }
7329 : : else
7330 : : {
7331 [ # # ][ # # ]: 0 : PRINT_ERROR("Scvale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7332 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7333 : 0 : return result;
7334 : : }
7335 [ # # ]: 0 : result = engine->translate( geom, point );
7336 [ # # ]: 0 : if (result)
7337 : : {
7338 [ # # ]: 0 : CubitTransformMatrix mov_mat;
7339 [ # # ]: 0 : mov_mat.translate( point );
7340 : :
7341 [ # # ]: 0 : notify_intermediate_of_transform( bte, prev_xform );
7342 [ # # ][ # # ]: 0 : notify_observers_of_transform( bte );
[ # # ]
7343 : : }
7344 : : else
7345 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7346 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7347 [ # # ]: 0 : return result;
7348 : : }
7349 : :
7350 : :
7351 : 0 : CubitStatus GeometryQueryTool::scale( BasicTopologyEntity* bte,
7352 : : const CubitVector& point,
7353 : : const CubitVector& factors,
7354 : : bool check_to_transform,
7355 : : bool preview )
7356 : : {
7357 [ # # ]: 0 : if( check_to_transform )
7358 [ # # ][ # # ]: 0 : if (!okay_to_transform( bte ))
7359 : 0 : return CUBIT_FAILURE;
7360 : :
7361 [ # # ]: 0 : CubitTransformMatrix prev_xform;
7362 [ # # ][ # # ]: 0 : prev_xform.translate(-point);
7363 : :
7364 [ # # ][ # # ]: 0 : CubitTransformMatrix xform;
7365 [ # # ]: 0 : xform.scale_about_origin( factors );
7366 : :
7367 [ # # ][ # # ]: 0 : CubitTransformMatrix mov_mat;
7368 [ # # ]: 0 : mov_mat.translate( point );
7369 : :
7370 : :
7371 [ # # ]: 0 : if (preview)
7372 : : {
7373 [ # # ][ # # ]: 0 : if(bte->dimension()==0)
7374 : : {
7375 [ # # ]: 0 : DLIList<RefVertex*> points;
7376 [ # # ]: 0 : bte->ref_vertices(points);
7377 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
7378 : : {
7379 [ # # ][ # # ]: 0 : CubitVector temp(points[i]->center_point());
7380 [ # # ][ # # ]: 0 : temp = prev_xform*temp;
7381 [ # # ][ # # ]: 0 : temp = xform*temp;
7382 [ # # ][ # # ]: 0 : temp = mov_mat*temp;
7383 [ # # ]: 0 : GfxPreview::draw_point(temp, CUBIT_BLUE_INDEX);
7384 [ # # ]: 0 : }
7385 : : }
7386 : : else
7387 : : {
7388 : :
7389 [ # # ]: 0 : DLIList<RefEdge*> edges;
7390 [ # # ]: 0 : bte->ref_edges(edges);
7391 [ # # ][ # # ]: 0 : for (int i = 0; i < edges.size(); i++)
7392 : : {
7393 [ # # ]: 0 : GMem poly;
7394 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
[ # # ]
7395 : : {
7396 [ # # ]: 0 : poly.transform(prev_xform);
7397 [ # # ]: 0 : poly.transform(xform);
7398 [ # # ]: 0 : poly.transform(mov_mat);
7399 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
7400 : : }
7401 [ # # ][ # # ]: 0 : else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
[ # # ][ # # ]
[ # # ]
7402 : : {
7403 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
[ # # ]
7404 [ # # ][ # # ]: 0 : tmp_pt = prev_xform*tmp_pt;
7405 [ # # ][ # # ]: 0 : tmp_pt = xform*tmp_pt;
7406 [ # # ][ # # ]: 0 : tmp_pt = mov_mat*tmp_pt;
7407 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
7408 : : }
7409 [ # # ][ # # ]: 0 : }
7410 : : }
7411 [ # # ]: 0 : GfxPreview::flush();
7412 : 0 : return CUBIT_SUCCESS;
7413 : : }
7414 : :
7415 [ # # ]: 0 : GeometryEntity* geom = bte->get_geometry_entity_ptr();
7416 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
7417 [ # # ][ # # ]: 0 : CubitStatus result = engine->translate( geom, -point );
7418 [ # # ]: 0 : if (result)
7419 : : {
7420 [ # # ]: 0 : notify_intermediate_of_transform( bte, prev_xform );
7421 : : }
7422 : : else
7423 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7424 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7425 : :
7426 [ # # ]: 0 : result = engine->scale( geom, factors );
7427 [ # # ]: 0 : if (result)
7428 : : {
7429 [ # # ]: 0 : notify_intermediate_of_transform( bte, xform );
7430 : : }
7431 : : else
7432 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7433 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7434 : :
7435 : :
7436 [ # # ]: 0 : result = engine->translate( geom, point );
7437 [ # # ]: 0 : if (result)
7438 : : {
7439 [ # # ]: 0 : notify_intermediate_of_transform( bte, mov_mat );
7440 [ # # ][ # # ]: 0 : notify_observers_of_transform( bte );
7441 : : }
7442 : : else
7443 [ # # ][ # # ]: 0 : PRINT_ERROR("Scale of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7444 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7445 : :
7446 : :
7447 : :
7448 [ # # ]: 0 : return result;
7449 : : }
7450 : :
7451 : 0 : CubitStatus GeometryQueryTool::reflect( DLIList<BasicTopologyEntity*> &btes,
7452 : : const CubitVector& point,
7453 : : const CubitVector& normal,
7454 : : DLIList<BasicTopologyEntity*> *btes_reflected,
7455 : : bool check_to_transform,
7456 : : bool preview )
7457 : : {
7458 [ # # ]: 0 : CubitTransformMatrix prev_xform;
7459 [ # # ][ # # ]: 0 : prev_xform.translate(-point);
7460 : :
7461 [ # # ][ # # ]: 0 : CubitTransformMatrix ref_mat;
7462 [ # # ]: 0 : ref_mat.reflect(normal );
7463 : :
7464 [ # # ][ # # ]: 0 : CubitTransformMatrix mov_mat;
7465 [ # # ]: 0 : mov_mat.translate( point );
7466 : :
7467 [ # # ][ # # ]: 0 : CubitTransformMatrix total_transform;
7468 [ # # ][ # # ]: 0 : total_transform = mov_mat*ref_mat*prev_xform;
[ # # ][ # # ]
[ # # ]
7469 : :
7470 [ # # ][ # # ]: 0 : DLIList<RefEntity*> transformed_ents;
7471 : :
7472 [ # # ][ # # ]: 0 : for( int k=0; k<btes.size(); k++ )
7473 : : {
7474 [ # # ]: 0 : BasicTopologyEntity *bte = btes[k];
7475 : :
7476 [ # # ]: 0 : if( check_to_transform )
7477 [ # # ][ # # ]: 0 : if (!okay_to_transform( bte ))
7478 : 0 : return CUBIT_FAILURE;
7479 : :
7480 [ # # ]: 0 : if (preview)
7481 : : {
7482 [ # # ][ # # ]: 0 : if(bte->dimension()==0)
7483 : : {
7484 [ # # ]: 0 : DLIList<RefVertex*> points;
7485 [ # # ]: 0 : bte->ref_vertices(points);
7486 [ # # ][ # # ]: 0 : for (int i = 0; i < points.size(); i++)
7487 : : {
7488 [ # # ][ # # ]: 0 : CubitVector temp(points[i]->center_point());
7489 [ # # ][ # # ]: 0 : temp = total_transform*temp;
7490 [ # # ]: 0 : GfxPreview::draw_point(temp, CUBIT_BLUE_INDEX);
7491 [ # # ]: 0 : }
7492 : : }
7493 : : else
7494 : : {
7495 : :
7496 [ # # ]: 0 : DLIList<RefEdge*> edges;
7497 [ # # ]: 0 : bte->ref_edges(edges);
7498 [ # # ][ # # ]: 0 : for (int j = 0; j < edges.size(); j++)
7499 : : {
7500 [ # # ]: 0 : GMem poly;
7501 [ # # ][ # # ]: 0 : if( CUBIT_SUCCESS == edges[j]->get_graphics(poly) )
[ # # ]
7502 : : {
7503 [ # # ]: 0 : poly.transform( total_transform );
7504 [ # # ][ # # ]: 0 : GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
[ # # ]
7505 : : }
7506 [ # # ][ # # ]: 0 : else if( edges[j]->start_vertex() == edges[j]->end_vertex() )
[ # # ][ # # ]
[ # # ]
7507 : : {
7508 [ # # ][ # # ]: 0 : CubitVector tmp_pt = edges[j]->start_vertex()->coordinates();
[ # # ]
7509 [ # # ][ # # ]: 0 : tmp_pt = total_transform*tmp_pt;
7510 [ # # ]: 0 : GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
7511 : : }
7512 [ # # ][ # # ]: 0 : }
7513 : : }
7514 [ # # ]: 0 : GfxPreview::flush();
7515 : 0 : continue;
7516 : : }
7517 : :
7518 [ # # ]: 0 : GeometryEntity* geom = bte->get_geometry_entity_ptr();
7519 [ # # ]: 0 : GeometryQueryEngine* engine = geom->get_geometry_query_engine();
7520 : : CubitStatus result;
7521 : :
7522 : : // Move to origin
7523 [ # # ][ # # ]: 0 : result = engine->translate( geom, -point );
7524 [ # # ]: 0 : if (result)
7525 : : {
7526 [ # # ]: 0 : CubitTransformMatrix xform;
7527 [ # # ][ # # ]: 0 : xform.translate( -point );
7528 [ # # ][ # # ]: 0 : notify_intermediate_of_transform( bte, xform );
7529 : : }
7530 : : else
7531 : : {
7532 [ # # ][ # # ]: 0 : PRINT_ERROR("Reflect of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7533 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7534 : 0 : return result;
7535 : : }
7536 : :
7537 [ # # ]: 0 : result = engine->reflect( geom, normal );
7538 [ # # ]: 0 : if (result)
7539 : : {
7540 [ # # ]: 0 : CubitTransformMatrix xform;
7541 [ # # ]: 0 : xform.reflect( normal);
7542 [ # # ][ # # ]: 0 : notify_intermediate_of_transform( bte, xform );
7543 : : }
7544 : : else
7545 : : {
7546 [ # # ][ # # ]: 0 : PRINT_ERROR("Reflect of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7547 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7548 : 0 : return result;
7549 : : }
7550 : :
7551 [ # # ]: 0 : result = engine->translate( geom, point );
7552 [ # # ]: 0 : if (result)
7553 : : {
7554 [ # # ]: 0 : CubitTransformMatrix xform;
7555 [ # # ]: 0 : xform.translate( point );
7556 [ # # ]: 0 : notify_intermediate_of_transform( bte, xform );
7557 : :
7558 [ # # ]: 0 : if( btes_reflected )
7559 [ # # ]: 0 : btes_reflected->append( bte );
7560 [ # # ][ # # ]: 0 : transformed_ents.append( bte );
[ # # ]
7561 : : }
7562 : : else
7563 : : {
7564 [ # # ][ # # ]: 0 : PRINT_ERROR("Reflect of %s (%s %d) failed.\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
7565 [ # # ]: 0 : bte->entity_name().c_str(), bte->class_name(), bte->id() );
7566 : 0 : return result;
7567 : : }
7568 : : }
7569 : :
7570 [ # # ][ # # ]: 0 : if( transformed_ents.size() )
7571 : : {
7572 [ # # ]: 0 : notify_observers_of_transform( transformed_ents, &total_transform );
7573 : 0 : return CUBIT_SUCCESS;
7574 : : }
7575 [ # # ]: 0 : else if( preview )
7576 : 0 : return CUBIT_SUCCESS;
7577 : : else
7578 [ # # ]: 0 : return CUBIT_FAILURE;
7579 : : }
7580 : :
7581 : 120 : void GeometryQueryTool::ige_remove_modified(DLIList<Surface*> &all_surfs,
7582 : : DLIList<Curve*> &all_curves,
7583 : : DLIList<TBPoint*> &all_points)
7584 : : {
7585 [ + - ]: 120 : IGESet::iterator itor;
7586 : :
7587 [ + - ][ + - ]: 360 : for (itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ + - ][ + - ]
[ + + ]
7588 [ + - ][ + - ]: 240 : (*itor)->remove_modified(all_surfs, all_curves, all_points);
7589 : :
7590 [ + - ][ + - ]: 360 : for (itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ + - ][ + - ]
[ + + ]
7591 [ + - ][ + - ]: 240 : (*itor)->clean_out_deactivated_geometry();
7592 : 120 : }
7593 : :
7594 : 0 : CubitBoolean GeometryQueryTool::bodies_overlap( Body *body_ptr_1,
7595 : : Body *body_ptr_2 )
7596 : : {
7597 : 0 : BodySM *body1 = body_ptr_1->get_body_sm_ptr();
7598 : 0 : BodySM *body2 = body_ptr_2->get_body_sm_ptr();
7599 : :
7600 [ # # ][ # # ]: 0 : if( is_intermediate_geometry( body_ptr_1 ) )
7601 : 0 : return body_ptr_1->get_geometry_query_engine()->bodies_overlap( body1, body2 );
7602 [ # # ][ # # ]: 0 : else if( is_intermediate_geometry( body_ptr_2 ) )
7603 : 0 : return body_ptr_2->get_geometry_query_engine()->bodies_overlap( body2, body1 );
7604 [ # # ]: 0 : else if( body_ptr_1->get_geometry_query_engine() !=
7605 : 0 : body_ptr_2->get_geometry_query_engine() )
7606 : : {
7607 [ # # ]: 0 : PRINT_ERROR("Volumes must be of the same type ( SolidWorks, etc) to\n"
7608 [ # # ]: 0 : "find if they overlap.\n");
7609 : 0 : return CUBIT_FALSE;
7610 : : }
7611 : : else
7612 : 0 : return body_ptr_1->get_geometry_query_engine()->bodies_overlap( body1, body2 );
7613 : : }
7614 : :
7615 : 0 : CubitBoolean GeometryQueryTool::volumes_overlap( RefVolume *volume_1,
7616 : : RefVolume *volume_2 )
7617 : : {
7618 : 0 : Lump *lump1 = volume_1->get_lump_ptr();
7619 : 0 : Lump *lump2 = volume_2->get_lump_ptr();
7620 : :
7621 [ # # ][ # # ]: 0 : if( is_intermediate_geometry( volume_1 ) )
7622 : 0 : return volume_1->get_geometry_query_engine()->volumes_overlap( lump1, lump2 );
7623 [ # # ][ # # ]: 0 : else if( is_intermediate_geometry( volume_2 ) )
7624 : 0 : return volume_2->get_geometry_query_engine()->volumes_overlap( lump2, lump1 );
7625 [ # # ]: 0 : else if( volume_1->get_geometry_query_engine() !=
7626 : 0 : volume_2->get_geometry_query_engine() )
7627 : : {
7628 [ # # ]: 0 : PRINT_ERROR("Volumes must be of the same type (SolidWorks, etc) to\n"
7629 [ # # ]: 0 : "find if they overlap.\n");
7630 : 0 : return CUBIT_FALSE;
7631 : : }
7632 : : else
7633 : 0 : return volume_1->get_geometry_query_engine()->volumes_overlap( lump1, lump2 );
7634 : : }
7635 : :
7636 : 0 : void GeometryQueryTool::find_nonmanifold_curves(DLIList<RefVolume*> &vol_list,
7637 : : DLIList<RefEdge*> &curve_list)
7638 : : {
7639 : : int i;
7640 [ # # ]: 0 : for(i=vol_list.size(); i>0; i--)
7641 : : {
7642 [ # # ]: 0 : RefVolume *vol = vol_list.get_and_step();
7643 [ # # ]: 0 : DLIList<RefEdge*> vol_curves;
7644 [ # # ]: 0 : vol->ref_edges(vol_curves);
7645 : : int j;
7646 [ # # ][ # # ]: 0 : for(j=vol_curves.size(); j>0; j--)
7647 : : {
7648 [ # # ]: 0 : RefEdge *cur_curve = vol_curves.get_and_step();
7649 [ # # ][ # # ]: 0 : if(cur_curve->is_merged())
7650 : : {
7651 [ # # ]: 0 : DLIList<RefFace*> curve_faces;
7652 [ # # ]: 0 : cur_curve->ref_faces(curve_faces);
7653 : 0 : bool merged_face_exists = false;
7654 [ # # ][ # # ]: 0 : while(curve_faces.size() && !merged_face_exists)
[ # # ][ # # ]
7655 : : {
7656 [ # # ]: 0 : RefFace *cur_face = curve_faces.pop();
7657 [ # # ][ # # ]: 0 : if(cur_face->is_merged())
7658 : 0 : merged_face_exists = true;
7659 : : }
7660 [ # # ]: 0 : if(!merged_face_exists)
7661 [ # # ][ # # ]: 0 : curve_list.append(cur_curve);
7662 : : }
7663 : : }
7664 [ # # ]: 0 : }
7665 : 0 : curve_list.uniquify_ordered();
7666 : 0 : }
7667 : :
7668 : 0 : double GeometryQueryTool::estimate_merge_tolerance(DLIList<RefVolume*> &vol_list,
7669 : : bool accurate_in,
7670 : : bool report_in,
7671 : : double lo_val_in,
7672 : : double hi_val_in,
7673 : : int num_calculations_in,
7674 : : bool return_calculations_in,
7675 : : DLIList<double> *merge_tols,
7676 : : DLIList<int> *num_proximities)
7677 : : {
7678 : 0 : double return_merge_tol = -1.0; // return value of < 0.0 will mean failure
7679 : : // to find a merge tolerance
7680 : :
7681 [ # # ]: 0 : DLIList<double> local_merge_tols;
7682 [ # # ][ # # ]: 0 : DLIList<int> local_num_proximities;
7683 : 0 : bool report = report_in;
7684 : 0 : double lo_val = 0.0;
7685 [ # # ]: 0 : double hi_val = get_geometry_factor()*GEOMETRY_RESABS*10.0; // 10 * merge tol -- arbitrary
7686 : 0 : int num_calculations = num_calculations_in;
7687 : :
7688 [ # # ]: 0 : if(lo_val_in != -1.0)
7689 : 0 : lo_val = lo_val_in;
7690 [ # # ]: 0 : if(hi_val_in != -1.0)
7691 : 0 : hi_val = hi_val_in;
7692 : :
7693 [ # # ]: 0 : if(hi_val > lo_val)
7694 : : {
7695 : 0 : double cur_val = lo_val;
7696 : 0 : double step = (hi_val - lo_val)/(double)num_calculations;
7697 : : int i;
7698 [ # # ]: 0 : if(report)
7699 : : {
7700 [ # # ][ # # ]: 0 : PRINT_INFO("\n\nLooking for merge toleance...\n\n");
[ # # ][ # # ]
7701 [ # # ][ # # ]: 0 : PRINT_INFO(" Possible range: %f, %f\n", lo_val, hi_val);
[ # # ][ # # ]
7702 [ # # ][ # # ]: 0 : PRINT_INFO(" Number of steps: %d\n\n", num_calculations+1);
[ # # ][ # # ]
7703 : : }
7704 : :
7705 [ # # ]: 0 : std::map <RefVertex*, DLIList<dist_vert_struct*>*> vert_dist_map;
7706 [ # # ]: 0 : GeomMeasureTool::find_near_coincident_vertices_unique(vol_list, hi_val, vert_dist_map);
7707 : :
7708 : 0 : int total_num_proximities = 0;
7709 [ # # ]: 0 : for(i=0; i<=num_calculations; i++)
7710 : : {
7711 : 0 : int cur_num_proximities = 0;
7712 [ # # ]: 0 : local_merge_tols.append(cur_val);
7713 : :
7714 [ # # ]: 0 : std::map <RefVertex*, DLIList<dist_vert_struct*>*>::iterator iter;
7715 [ # # ][ # # ]: 0 : for(iter=vert_dist_map.begin(); iter != vert_dist_map.end(); iter++ )
[ # # ][ # # ]
[ # # ]
7716 : : {
7717 : : //RefVertex *vert = iter->first;
7718 [ # # ]: 0 : DLIList<dist_vert_struct*> *struct_list = iter->second;
7719 : : int m;
7720 [ # # ][ # # ]: 0 : for(m=struct_list->size(); m>0; m--)
7721 : : {
7722 [ # # ]: 0 : dist_vert_struct *dvs = struct_list->get();
7723 [ # # ]: 0 : if(dvs->dist <= cur_val)
7724 : : {
7725 : : // PRINT_INFO("Vertices %d and %d, distance: %.10lf\n", vert->id(), dvs->v2->id(), dvs->dist);
7726 [ # # ]: 0 : struct_list->change_to(NULL);
7727 : 0 : delete dvs;
7728 : 0 : cur_num_proximities++;
7729 : : }
7730 [ # # ]: 0 : struct_list->step();
7731 : : }
7732 [ # # ]: 0 : struct_list->remove_all_with_value(NULL);
7733 : : }
7734 : :
7735 : 0 : total_num_proximities += cur_num_proximities;
7736 [ # # ]: 0 : local_num_proximities.append(total_num_proximities);
7737 : :
7738 [ # # ]: 0 : if(report)
7739 : : {
7740 [ # # ][ # # ]: 0 : PRINT_INFO(" At merge tolerance = %f number of proximities = %d.\n", cur_val, total_num_proximities);
[ # # ][ # # ]
7741 : : }
7742 : :
7743 : 0 : cur_val += step;
7744 : : }
7745 : :
7746 [ # # ]: 0 : std::map <RefVertex*, DLIList<dist_vert_struct*>*>::iterator iter;
7747 [ # # ][ # # ]: 0 : for(iter=vert_dist_map.begin(); iter != vert_dist_map.end(); iter++ )
[ # # ][ # # ]
[ # # ]
7748 : : {
7749 [ # # ]: 0 : DLIList<dist_vert_struct*> *struct_list = iter->second;
7750 : : // I think all of the items in the lists should be gone
7751 : : // by now but just in case...
7752 [ # # ][ # # ]: 0 : while(struct_list->size())
7753 [ # # ]: 0 : delete struct_list->pop();
7754 [ # # ][ # # ]: 0 : delete struct_list;
7755 : : }
7756 : :
7757 [ # # ]: 0 : local_num_proximities.reset();
7758 [ # # ]: 0 : local_merge_tols.reset();
7759 [ # # ]: 0 : int num_total = local_merge_tols.size();
7760 [ # # ]: 0 : if(num_total > 2)
7761 : : {
7762 : 0 : int num_triplets = num_total - 2;
7763 : : int h, min_index, min_diff;
7764 [ # # ]: 0 : DLIList<int> diffs;
7765 [ # # ]: 0 : for(h=0; h<num_triplets; h++)
7766 : : {
7767 [ # # ]: 0 : int num_begin = local_num_proximities.get();
7768 [ # # ]: 0 : local_num_proximities.step(2);
7769 [ # # ]: 0 : int num_end = local_num_proximities.get();
7770 [ # # ]: 0 : local_num_proximities.back();
7771 : 0 : int cur_diff = num_end - num_begin;
7772 [ # # ]: 0 : if(h==0)
7773 : : {
7774 : 0 : min_index = h;
7775 : 0 : min_diff = cur_diff;
7776 : : }
7777 : : else
7778 : : {
7779 [ # # ]: 0 : if(cur_diff < min_diff)
7780 : : {
7781 : 0 : min_diff = cur_diff;
7782 : 0 : min_index = h;
7783 : : }
7784 : : }
7785 : : }
7786 [ # # ]: 0 : local_merge_tols.step(min_index+1);
7787 [ # # ][ # # ]: 0 : return_merge_tol = local_merge_tols.get();
7788 : : }
7789 : : else
7790 [ # # ][ # # ]: 0 : PRINT_ERROR("Unable to estimate merge tolerance.\n");
[ # # ][ # # ]
7791 : :
7792 : : /*
7793 : : // Pick off a merge tolerance.
7794 : : local_num_proximities.reset();
7795 : : local_merge_tols.reset();
7796 : : DLIList<int> unique_num_proximities;
7797 : : DLIList<int> unique_counts;
7798 : : DLIList<double> tmp_merge_tol_list;
7799 : : int tmp_num_proximities;
7800 : : double tmp_merge_tol;
7801 : :
7802 : : double cur_merge_tol = local_merge_tols.get_and_step();
7803 : : int cur_num_prox = local_num_proximities.get_and_step();
7804 : : int cur_unique_counts = 1;
7805 : : // Loop over the whole size even though we have processed the
7806 : : // first entry because we need to record the results after the
7807 : : // last entry.
7808 : : for(i=local_num_proximities.size(); i>0; i--)
7809 : : {
7810 : : if(i>1)
7811 : : {
7812 : : tmp_num_proximities = local_num_proximities.get_and_step();
7813 : : tmp_merge_tol = local_merge_tols.get_and_step();
7814 : : }
7815 : : else
7816 : : {
7817 : : // On the last time in just give it a dummy value so we
7818 : : // can record the results from the last real entry.
7819 : : tmp_num_proximities = -1;
7820 : : }
7821 : : if(cur_num_prox == tmp_num_proximities)
7822 : : {
7823 : : cur_unique_counts++;
7824 : : }
7825 : : else
7826 : : {
7827 : : tmp_merge_tol_list.append(cur_merge_tol);
7828 : : unique_counts.append(cur_unique_counts);
7829 : : unique_num_proximities.append(cur_num_prox);
7830 : : cur_unique_counts = 1;
7831 : : cur_num_prox = tmp_num_proximities;
7832 : : cur_merge_tol = tmp_merge_tol;
7833 : : }
7834 : : }
7835 : :
7836 : : int max_index = -1;
7837 : : int cur_max_num_counts = 0;
7838 : : unique_counts.reset();
7839 : : unique_num_proximities.reset();
7840 : : tmp_merge_tol_list.reset();
7841 : : for(i=unique_counts.size(); i>0; i--)
7842 : : {
7843 : : int cur_num_counts = unique_counts.get();
7844 : : if(cur_num_counts > cur_max_num_counts)
7845 : : {
7846 : : cur_max_num_counts = cur_num_counts;
7847 : : max_index = unique_counts.get_index();
7848 : : }
7849 : : unique_counts.step();
7850 : : }
7851 : :
7852 : : if(max_index > -1)
7853 : : {
7854 : : tmp_merge_tol_list.step(max_index);
7855 : : return_merge_tol = tmp_merge_tol_list.get();
7856 : : }
7857 : : else
7858 : : {
7859 : : PRINT_ERROR("Unable to estimate merge tolerance.\n");
7860 : : }
7861 : : */
7862 : :
7863 [ # # ]: 0 : if(report)
7864 [ # # ][ # # ]: 0 : PRINT_INFO("\nEstimated merge tolerance: %f\n", return_merge_tol);
[ # # ][ # # ]
[ # # ]
7865 : : }
7866 : : else
7867 [ # # ][ # # ]: 0 : PRINT_ERROR("Range low value is larger than range high value.\n");
[ # # ][ # # ]
7868 : :
7869 [ # # ]: 0 : return return_merge_tol;
7870 : : }
7871 : :
7872 : 0 : void GeometryQueryTool::find_floating_volumes(DLIList<RefVolume*> &vol_list,
7873 : : DLIList<RefVolume*> &floating_list)
7874 : : {
7875 : : int i;
7876 [ # # ]: 0 : for(i=vol_list.size(); i>0; i--)
7877 : : {
7878 : 0 : bool floating = true;
7879 [ # # ]: 0 : RefVolume *vol = vol_list.get_and_step();
7880 [ # # ]: 0 : DLIList<RefEdge*> vol_curves;
7881 [ # # ][ # # ]: 0 : DLIList<RefVertex*> vol_verts;
7882 [ # # ][ # # ]: 0 : DLIList<RefFace*> vol_surfs;
7883 [ # # ]: 0 : vol->ref_edges(vol_curves);
7884 [ # # ]: 0 : vol->ref_faces(vol_surfs);
7885 [ # # ]: 0 : vol->ref_vertices(vol_verts);
7886 : : int j;
7887 [ # # ][ # # ]: 0 : for(j=vol_surfs.size(); j>0 && floating; j--)
[ # # ]
7888 : : {
7889 [ # # ]: 0 : RefFace *cur_surf = vol_surfs.get_and_step();
7890 [ # # ][ # # ]: 0 : if(cur_surf->is_merged())
7891 : 0 : floating = false;
7892 : : }
7893 [ # # ][ # # ]: 0 : for(j=vol_curves.size(); j>0 && floating; j--)
[ # # ]
7894 : : {
7895 [ # # ]: 0 : RefEdge *cur_curve = vol_curves.get_and_step();
7896 [ # # ][ # # ]: 0 : if(cur_curve->is_merged())
7897 : 0 : floating = false;
7898 : : }
7899 [ # # ][ # # ]: 0 : for(j=vol_verts.size(); j>0 && floating; j--)
[ # # ]
7900 : : {
7901 [ # # ]: 0 : RefVertex *cur_vert = vol_verts.get_and_step();
7902 [ # # ][ # # ]: 0 : if(cur_vert->is_merged())
7903 : 0 : floating = false;
7904 : : }
7905 [ # # ]: 0 : if(floating)
7906 [ # # ]: 0 : floating_list.append(vol);
7907 [ # # ]: 0 : }
7908 : 0 : floating_list.uniquify_ordered();
7909 : 0 : }
7910 : :
7911 : 0 : void GeometryQueryTool::find_nonmanifold_vertices(DLIList<RefVolume*> &vol_list,
7912 : : DLIList<RefVertex*> &vertex_list)
7913 : : {
7914 : : int i;
7915 [ # # ]: 0 : for(i=vol_list.size(); i>0; i--)
7916 : : {
7917 [ # # ]: 0 : RefVolume *vol = vol_list.get_and_step();
7918 [ # # ]: 0 : DLIList<RefVertex*> vol_verts;
7919 [ # # ]: 0 : vol->ref_vertices(vol_verts);
7920 : : int j;
7921 [ # # ][ # # ]: 0 : for(j=vol_verts.size(); j>0; j--)
7922 : : {
7923 [ # # ]: 0 : RefVertex *cur_vert = vol_verts.get_and_step();
7924 [ # # ][ # # ]: 0 : if(cur_vert->is_merged())
7925 : : {
7926 [ # # ]: 0 : DLIList<RefEdge*> vert_edges;
7927 [ # # ]: 0 : cur_vert->ref_edges(vert_edges);
7928 : 0 : bool merged_edge_exists = false;
7929 [ # # ][ # # ]: 0 : while(vert_edges.size() && !merged_edge_exists)
[ # # ][ # # ]
7930 : : {
7931 [ # # ]: 0 : RefEdge *cur_edge = vert_edges.pop();
7932 [ # # ][ # # ]: 0 : if(cur_edge->is_merged())
7933 : 0 : merged_edge_exists = true;
7934 : : }
7935 [ # # ]: 0 : if(!merged_edge_exists)
7936 [ # # ][ # # ]: 0 : vertex_list.append(cur_vert);
7937 : : }
7938 : : }
7939 [ # # ]: 0 : }
7940 : 0 : vertex_list.uniquify_ordered();
7941 : 0 : }
7942 : :
7943 : 133669 : CGMHistory& GeometryQueryTool::history()
7944 : : {
7945 : 133669 : return mHistory;
7946 : : }
7947 : :
7948 : 0 : void GeometryQueryTool::get_merged_away_free_entities( DLIList<RefEntity*> &ref_ents,
7949 : : DLIList<TopologyBridge*> &free_ents )
7950 : : {
7951 : : //determine if you have any free entities that were merged away
7952 [ # # ]: 0 : DLIList<RefEntity*> merged_ref_ents;
7953 [ # # ][ # # ]: 0 : MergeTool::instance()->contains_merged_entities( ref_ents, &merged_ref_ents );
7954 : : int i;
7955 [ # # ][ # # ]: 0 : for( i=merged_ref_ents.size(); i--; )
7956 : : {
7957 [ # # ]: 0 : RefEntity *tmp_ent = merged_ref_ents.get_and_step();
7958 [ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
7959 [ # # ]: 0 : TopologyEntity *te = CAST_TO(tmp_ent, TopologyEntity );
7960 [ # # ][ # # ]: 0 : te->bridge_manager()->get_bridge_list( bridge_list );
7961 : : //bridge_list.reset();
7962 : : //bridge_list.step(); //don't want to first bridge...that's the real thing
7963 : :
7964 : : //check for free entities...
7965 : : int j;
7966 [ # # ][ # # ]: 0 : for( j=0; j<bridge_list.size(); j++ )
7967 : : {
7968 [ # # ]: 0 : TopologyBridge *tmp_bridge = bridge_list.get_and_step();
7969 : :
7970 : : //ignore the representation bridge if it's a free vertex
7971 [ # # ]: 0 : if( j==0 )
7972 [ # # ][ # # ]: 0 : if( tmp_ent->num_parent_ref_entities() == 0 )
7973 : 0 : continue;
7974 : :
7975 [ # # ]: 0 : DLIList<TopologyBridge*> parents;
7976 [ # # ]: 0 : tmp_bridge->get_parents( parents );
7977 [ # # ][ # # ]: 0 : if( parents.size() == 0 )
7978 [ # # ]: 0 : free_ents.append( tmp_bridge );
7979 [ # # ]: 0 : }
7980 [ # # ][ # # ]: 0 : }
7981 : 0 : }
7982 : :
7983 : :
7984 : 0 : CubitStatus GeometryQueryTool::get_graphics( RefFace *ref_face,
7985 : : GMem *gmem,
7986 : : std::vector<RefEntity*> &facet_point_ownership_vector,
7987 : : std::vector<std::pair< RefEntity*, std::pair<int,int> > > &facetedges_on_refedges,
7988 : : unsigned short normal_tolerance,
7989 : : double distance_tolerance,
7990 : : double max_edge_length )
7991 : : {
7992 [ # # ]: 0 : Surface* surf_ptr = ref_face->get_surface_ptr();
7993 [ # # ]: 0 : if (!surf_ptr)
7994 : : {
7995 [ # # ][ # # ]: 0 : PRINT_ERROR("RefFace %d is invalid -- no attached Surface.\n",ref_face->id());
[ # # ][ # # ]
[ # # ]
7996 : 0 : return CUBIT_FAILURE;
7997 : : }
7998 : :
7999 [ # # ]: 0 : std::vector<TopologyBridge*> vertex_edge_to_point_vector;
8000 [ # # ][ # # ]: 0 : std::vector<std::pair<TopologyBridge*, std::pair<int,int> > > facetedges_on_curve;
8001 : :
8002 [ # # ]: 0 : CubitStatus rv = surf_ptr->get_geometry_query_engine()->
8003 : : get_graphics(surf_ptr, gmem, vertex_edge_to_point_vector, facetedges_on_curve,
8004 [ # # ]: 0 : normal_tolerance, distance_tolerance, max_edge_length );
8005 [ # # ]: 0 : if (CUBIT_SUCCESS != rv) {
8006 [ # # ][ # # ]: 0 : PRINT_ERROR("GeometryQueryEngine::get_graphics failed.\n");
[ # # ][ # # ]
8007 : 0 : return rv;
8008 : : }
8009 : :
8010 [ # # ][ # # ]: 0 : facet_point_ownership_vector.resize( vertex_edge_to_point_vector.size(), NULL );
8011 : 0 : RefEntity *ref_ent = NULL;
8012 [ # # ][ # # ]: 0 : for( unsigned int i = 0; i < vertex_edge_to_point_vector.size(); i++ )
8013 : : {
8014 [ # # ]: 0 : TopologyBridge *tb = vertex_edge_to_point_vector[i];
8015 [ # # ]: 0 : if( NULL == tb )
8016 : 0 : continue;
8017 : :
8018 [ # # ][ # # ]: 0 : if( tb->topology_entity() )
8019 : : {
8020 [ # # ][ # # ]: 0 : ref_ent = CAST_TO( tb->topology_entity(), RefEntity );
8021 [ # # ]: 0 : facet_point_ownership_vector[i] = ref_ent;
8022 : : }
8023 : : else
8024 : 0 : assert(0);
8025 : : }
8026 : :
8027 [ # # ][ # # ]: 0 : for( unsigned int i = 0; i < facetedges_on_curve.size(); i++ )
8028 : : {
8029 [ # # ]: 0 : std::pair<TopologyBridge*, std::pair<int,int> > tmp_pair = facetedges_on_curve[i];
8030 : 0 : TopologyBridge *tb = tmp_pair.first;
8031 : :
8032 [ # # ][ # # ]: 0 : if( tb->topology_entity() )
8033 : : {
8034 [ # # ][ # # ]: 0 : ref_ent = CAST_TO( tb->topology_entity(), RefEntity );
8035 [ # # ][ # # ]: 0 : facetedges_on_refedges.push_back( std::make_pair( ref_ent, tmp_pair.second ) );
8036 : : }
8037 : : else
8038 : : {
8039 : 0 : assert(0);
8040 : : }
8041 : : }
8042 : :
8043 : :
8044 : 0 : bool debug = false;
8045 : :
8046 [ # # ]: 0 : if( debug )
8047 : : {
8048 : : //GfxDebug::clear();
8049 : : //GPoint *pt_list = gmem->point_list();
8050 [ # # ][ # # ]: 0 : for( unsigned int i = 0; i < facet_point_ownership_vector.size(); i++ )
8051 : : {
8052 : : //RefEntity *ref_ent = facet_point_ownership_vector[i];
8053 : :
8054 : : //int color = 3;
8055 : : //if( ref_ent->dimension() == 1 )
8056 : : //color = 4;
8057 : : //else if( ref_ent->dimension() == 2 )
8058 : : //color = 5;
8059 : : }
8060 : :
8061 [ # # ]: 0 : GfxDebug::flush();
8062 [ # # ]: 0 : GfxDebug::mouse_xforms();
8063 : :
8064 : :
8065 [ # # ]: 0 : GfxDebug::clear();
8066 : : //draw the curves
8067 [ # # ][ # # ]: 0 : for( unsigned int i=0; i<facetedges_on_refedges.size(); i++ )
8068 : : {
8069 [ # # ]: 0 : std::pair<RefEntity*, std::pair<int,int> > tmp_pair;
8070 [ # # ]: 0 : tmp_pair = facetedges_on_refedges[i];
8071 : :
8072 : 0 : RefEntity* ref_ent = tmp_pair.first;
8073 : 0 : std::pair<int,int> int_pair = tmp_pair.second;
8074 : :
8075 [ # # ]: 0 : CubitVector pt0( gmem->point_list()[int_pair.first].x,
8076 [ # # ]: 0 : gmem->point_list()[int_pair.first].y,
8077 [ # # ][ # # ]: 0 : gmem->point_list()[int_pair.first].z );
8078 : :
8079 [ # # ]: 0 : CubitVector pt1( gmem->point_list()[int_pair.second].x,
8080 [ # # ]: 0 : gmem->point_list()[int_pair.second].y,
8081 [ # # ][ # # ]: 0 : gmem->point_list()[int_pair.second].z );
8082 : :
8083 [ # # ][ # # ]: 0 : GfxDebug::draw_point(pt0, (ref_ent->id()%10) + 3 );
8084 [ # # ][ # # ]: 0 : GfxDebug::draw_point(pt1, (ref_ent->id()%10) + 3 );
8085 [ # # ][ # # ]: 0 : GfxDebug::draw_line( pt0, pt1, (ref_ent->id()%10) + 3 );
8086 : : }
8087 [ # # ]: 0 : GfxDebug::flush();
8088 [ # # ]: 0 : GfxDebug::mouse_xforms();
8089 : :
8090 : 0 : int index = 0;
8091 [ # # ]: 0 : GfxDebug::clear();
8092 [ # # ]: 0 : for( int i=0; i<gmem->fListCount; i++ )
8093 : : {
8094 [ # # ]: 0 : int step = gmem->facet_list()[index++];
8095 : : //create pts
8096 [ # # ][ # # ]: 0 : CubitVector pt0( gmem->point_list()[ gmem->facet_list()[index] ].x,
8097 [ # # ][ # # ]: 0 : gmem->point_list()[ gmem->facet_list()[index] ].y,
8098 [ # # ][ # # ]: 0 : gmem->point_list()[ gmem->facet_list()[index] ].z );
[ # # ]
8099 : 0 : index++;
8100 : :
8101 [ # # ][ # # ]: 0 : CubitVector pt1( gmem->point_list()[ gmem->facet_list()[index] ].x,
8102 [ # # ][ # # ]: 0 : gmem->point_list()[ gmem->facet_list()[index] ].y,
8103 [ # # ][ # # ]: 0 : gmem->point_list()[ gmem->facet_list()[index] ].z );
[ # # ]
8104 : 0 : index++;
8105 : :
8106 [ # # ][ # # ]: 0 : CubitVector pt2( gmem->point_list()[ gmem->facet_list()[index] ].x,
8107 [ # # ][ # # ]: 0 : gmem->point_list()[ gmem->facet_list()[index] ].y,
8108 [ # # ][ # # ]: 0 : gmem->point_list()[ gmem->facet_list()[index] ].z );
[ # # ]
8109 : 0 : index++;
8110 : :
8111 : : //draw lines
8112 : : GPoint three_pts[3];
8113 [ # # ]: 0 : three_pts[0].x = pt0.x();
8114 [ # # ]: 0 : three_pts[0].y = pt0.y();
8115 [ # # ]: 0 : three_pts[0].z = pt0.z();
8116 : :
8117 [ # # ]: 0 : three_pts[1].x = pt1.x();
8118 [ # # ]: 0 : three_pts[1].y = pt1.y();
8119 [ # # ]: 0 : three_pts[1].z = pt1.z();
8120 : :
8121 [ # # ]: 0 : three_pts[2].x = pt2.x();
8122 [ # # ]: 0 : three_pts[2].y = pt2.y();
8123 [ # # ]: 0 : three_pts[2].z = pt2.z();
8124 : :
8125 [ # # ]: 0 : GfxDebug::draw_polygon( three_pts, 3, i%20, i%20, true );
8126 [ # # ]: 0 : GfxDebug::draw_line( pt0, pt1, i%20 );
8127 [ # # ]: 0 : GfxDebug::draw_line( pt1, pt2, i%20 );
8128 [ # # ]: 0 : GfxDebug::draw_line( pt0, pt2, i%20 );
8129 : 0 : i+=step;
8130 : : }
8131 [ # # ]: 0 : GfxDebug::flush();
8132 [ # # ]: 0 : GfxDebug::mouse_xforms();
8133 : : }
8134 : :
8135 : :
8136 : :
8137 : :
8138 [ # # ]: 0 : return CUBIT_SUCCESS;
8139 : : }
8140 : :
8141 : :
8142 : 0 : CubitStatus GeometryQueryTool::get_graphics( Body *body,
8143 : : GMem *g_mem,
8144 : : std::vector<RefFace*> &ref_face_to_facet_vector,
8145 : : std::vector<RefEntity*> &facet_point_ownership_vector,
8146 : : std::vector<std::pair< RefEntity*, std::pair<int,int> > > &facetedges_on_refedges,
8147 : : unsigned short normal_tolerance,
8148 : : double distance_tolerance,
8149 : : double max_edge_length )
8150 : : {
8151 : : //get all the RefFaces from
8152 [ # # ]: 0 : DLIList<RefFace*> all_ref_faces;
8153 [ # # ]: 0 : body->ref_faces( all_ref_faces );
8154 : :
8155 : 0 : BodySM *body_sm = NULL;
8156 : :
8157 : : //get the underlying body in partition bodies
8158 [ # # ][ # # ]: 0 : if( GeometryQueryTool::instance()->is_intermediate_geometry( body ) )
[ # # ][ # # ]
8159 : : {
8160 [ # # ]: 0 : DLIList<TopologyBridge*> partition_body(1);
8161 [ # # ][ # # ]: 0 : body->get_body_sm_ptr()->get_geometry_query_engine()->get_underlying_bridges( body->get_body_sm_ptr(), partition_body );
[ # # ][ # # ]
8162 [ # # ][ # # ]: 0 : if( partition_body.size() == 1 )
8163 [ # # ][ # # ]: 0 : body_sm = static_cast<BodySM*>(partition_body.get());
8164 : : }
8165 : : else
8166 [ # # ]: 0 : body_sm = body->get_body_sm_ptr();
8167 : :
8168 : : //make sure everything belongs to the same GQE
8169 [ # # ]: 0 : GeometryQueryEngine* gqe = body_sm->get_geometry_query_engine();
8170 : :
8171 : : //get the graphics
8172 [ # # ][ # # ]: 0 : std::vector<Surface*> surfaces_to_facet_vector;
8173 [ # # ][ # # ]: 0 : std::vector<TopologyBridge*> tmp_facet_point_ownership_vector;
8174 [ # # ][ # # ]: 0 : std::vector<std::pair<TopologyBridge*, std::pair<int,int> > > facetedges_on_curve;
8175 : : CubitStatus stat = gqe->get_graphics( body_sm, g_mem, surfaces_to_facet_vector, tmp_facet_point_ownership_vector,
8176 [ # # ]: 0 : facetedges_on_curve, normal_tolerance, distance_tolerance, max_edge_length );
8177 : :
8178 [ # # ]: 0 : if( CUBIT_FAILURE == stat )
8179 : 0 : return CUBIT_FAILURE;
8180 : :
8181 : : //map Surfaces to MRefFaces
8182 : 0 : Surface *current_surf = NULL;
8183 : 0 : RefFace *current_ref_face = NULL;
8184 : 0 : bool ignore_facets = false;
8185 : :
8186 : : unsigned int i;
8187 [ # # ][ # # ]: 0 : for( i=0; i<surfaces_to_facet_vector.size(); i++ )
8188 : : {
8189 [ # # ]: 0 : Surface *tmp_surf = surfaces_to_facet_vector[i];
8190 : :
8191 [ # # ]: 0 : if( tmp_surf != current_surf )
8192 : : {
8193 : 0 : ignore_facets = false;
8194 : 0 : current_surf = tmp_surf;
8195 : :
8196 [ # # ][ # # ]: 0 : if( tmp_surf->topology_entity() )
8197 : : {
8198 [ # # ][ # # ]: 0 : current_ref_face = CAST_TO( tmp_surf->topology_entity(), RefFace );
8199 [ # # ]: 0 : if( current_ref_face )
8200 [ # # ]: 0 : ref_face_to_facet_vector.push_back( current_ref_face );
8201 : : }
8202 : : else
8203 : : {
8204 : 0 : int times_through = 0;
8205 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
8206 : : {
8207 : 0 : times_through++;
8208 [ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
8209 [ # # ][ # # ]: 0 : (*itor)->get_tbs_with_bridge_manager_as_owner(tmp_surf, bridge_list);
8210 [ # # ][ # # ]: 0 : if( bridge_list.size() == 0 )
8211 : : {
8212 [ # # ]: 0 : if( times_through == 2 )
8213 : 0 : assert(0);
8214 : 0 : continue;
8215 : : }
8216 : :
8217 [ # # ][ # # ]: 0 : if( bridge_list.size() == 1 )
8218 : : {
8219 [ # # ][ # # ]: 0 : current_ref_face = CAST_TO( bridge_list.get()->topology_entity(), RefFace );
[ # # ]
8220 [ # # ]: 0 : if( current_ref_face )
8221 [ # # ]: 0 : ref_face_to_facet_vector.push_back( current_ref_face );
8222 : : else
8223 : : {
8224 [ # # ][ # # ]: 0 : PRINT_INFO("Having trouble finding the top-level RefFace\n");
[ # # ][ # # ]
8225 : 0 : assert(0);
8226 : : }
8227 : 0 : break;
8228 : : }
8229 [ # # ][ # # ]: 0 : else if( bridge_list.size() > 1 ) // it is a partition...we'll ignore the facets
8230 : : {
8231 [ # # ]: 0 : ref_face_to_facet_vector.push_back( NULL );
8232 : 0 : ignore_facets = true;
8233 [ # # ]: 0 : break;
[ # # # ]
8234 : : }
8235 : 0 : }
8236 : : }
8237 : : }
8238 : : else
8239 : : {
8240 [ # # ]: 0 : if( ignore_facets )
8241 [ # # ]: 0 : ref_face_to_facet_vector.push_back( NULL );
8242 : : else
8243 [ # # ]: 0 : ref_face_to_facet_vector.push_back( current_ref_face );
8244 : : }
8245 : : }
8246 : :
8247 [ # # ][ # # ]: 0 : facet_point_ownership_vector.resize( tmp_facet_point_ownership_vector.size(), NULL );
8248 : 0 : RefEntity *ref_ent = NULL;
8249 [ # # ][ # # ]: 0 : for( i=0; i<tmp_facet_point_ownership_vector.size(); i++ )
8250 : : {
8251 [ # # ]: 0 : TopologyBridge *tb = tmp_facet_point_ownership_vector[i];
8252 [ # # ]: 0 : if( NULL == tb )
8253 : 0 : continue;
8254 : :
8255 [ # # ][ # # ]: 0 : if( tb->topology_entity() )
8256 : : {
8257 [ # # ][ # # ]: 0 : ref_ent = CAST_TO( tb->topology_entity(), RefEntity );
8258 [ # # ]: 0 : facet_point_ownership_vector[i] = ref_ent;
8259 : : }
8260 : : else
8261 : : {
8262 : 0 : int times_through = 0;
8263 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
8264 : : {
8265 : 0 : times_through++;
8266 [ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
8267 [ # # ][ # # ]: 0 : (*itor)->get_tbs_with_bridge_manager_as_owner(tb, bridge_list);
8268 [ # # ][ # # ]: 0 : if( bridge_list.size() == 0 )
8269 : : {
8270 [ # # ]: 0 : if( times_through == 2 )
8271 : 0 : assert(0);
8272 : 0 : continue;
8273 : : }
8274 : :
8275 : : //composites
8276 [ # # ][ # # ]: 0 : if( bridge_list.size() == 1 )
8277 : : {
8278 [ # # ][ # # ]: 0 : ref_ent = CAST_TO( bridge_list.get()->topology_entity(), RefEntity );
[ # # ]
8279 [ # # ]: 0 : if( ref_ent )
8280 [ # # ]: 0 : facet_point_ownership_vector[i] = ref_ent;
8281 : : else
8282 : : {
8283 [ # # ][ # # ]: 0 : PRINT_INFO("Having trouble finding the top-level RefEdge or RefVertex\n");
[ # # ][ # # ]
8284 : 0 : assert(0);
8285 : : }
8286 : 0 : break;
8287 : : }
8288 [ # # ][ # # ]: 0 : else if( bridge_list.size() > 1 ) // it is a partition...we'll ignore the facets
8289 : : {
8290 [ # # ]: 0 : facet_point_ownership_vector[i] = NULL;
8291 : 0 : ignore_facets = true;
8292 [ # # ]: 0 : break;
[ # # # ]
8293 : : }
8294 : 0 : }
8295 : : }
8296 : : }
8297 : :
8298 [ # # ][ # # ]: 0 : for( i=0; i<facetedges_on_curve.size(); i++ )
8299 : : {
8300 [ # # ]: 0 : std::pair<TopologyBridge*, std::pair<int,int> > tmp_pair = facetedges_on_curve[i];
8301 : 0 : TopologyBridge *tb = tmp_pair.first;
8302 : :
8303 [ # # ][ # # ]: 0 : if( tb->topology_entity() )
8304 : : {
8305 [ # # ][ # # ]: 0 : ref_ent = CAST_TO( tb->topology_entity(), RefEntity );
8306 [ # # ][ # # ]: 0 : facetedges_on_refedges.push_back( std::make_pair( ref_ent, tmp_pair.second ) );
8307 : : }
8308 : : else
8309 : : {
8310 : 0 : int times_through = 0;
8311 [ # # ][ # # ]: 0 : for (IGESet::iterator itor = igeSet.begin(); itor != igeSet.end(); ++itor)
[ # # ][ # # ]
[ # # ]
8312 : : {
8313 : 0 : times_through++;
8314 [ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
8315 [ # # ][ # # ]: 0 : (*itor)->get_tbs_with_bridge_manager_as_owner(tb, bridge_list);
8316 [ # # ][ # # ]: 0 : if( bridge_list.size() == 0 )
8317 : : {
8318 : : //if( times_through == 2 )
8319 : : // assert(0);
8320 : 0 : continue;
8321 : : }
8322 : :
8323 : : //composites
8324 [ # # ][ # # ]: 0 : if( bridge_list.size() == 1 )
8325 : : {
8326 [ # # ][ # # ]: 0 : ref_ent = CAST_TO( bridge_list.get()->topology_entity(), RefEntity );
[ # # ]
8327 [ # # ]: 0 : if( ref_ent )
8328 [ # # ][ # # ]: 0 : facetedges_on_refedges.push_back( std::make_pair( ref_ent, tmp_pair.second ) );
8329 : : else
8330 : : {
8331 [ # # ][ # # ]: 0 : PRINT_INFO("Having trouble finding the top-level RefEdge or RefVertex\n");
[ # # ][ # # ]
8332 : 0 : assert(0);
8333 : : }
8334 : 0 : break;
8335 : : }
8336 [ # # ][ # # ]: 0 : else if( bridge_list.size() > 1 ) // it is a partition...we'll ignore the facets
8337 : : {
8338 [ # # ]: 0 : break;
[ # # # ]
8339 : : }
8340 : 0 : }
8341 : : }
8342 : : }
8343 : :
8344 : :
8345 : 0 : bool debug = false;
8346 : :
8347 [ # # ]: 0 : if( debug )
8348 : : {
8349 : : //GfxDebug::clear();
8350 [ # # ]: 0 : GPoint *pt_list = g_mem->point_list();
8351 [ # # ][ # # ]: 0 : for( unsigned int i = 0; i < facet_point_ownership_vector.size(); i++ )
8352 : : {
8353 [ # # ]: 0 : RefEntity *ref_ent = facet_point_ownership_vector[i];
8354 : :
8355 : 0 : int color = 3;
8356 [ # # ][ # # ]: 0 : if( ref_ent->dimension() == 1 )
8357 : 0 : color = 4;
8358 [ # # ][ # # ]: 0 : else if( ref_ent->dimension() == 2 )
8359 : 0 : color = 5;
8360 : :
8361 [ # # ]: 0 : GfxDebug::draw_point( pt_list[i].x, pt_list[i].y, pt_list[i].z, color );
8362 : : }
8363 : :
8364 [ # # ]: 0 : GfxDebug::flush();
8365 [ # # ]: 0 : GfxDebug::mouse_xforms();
8366 : : /*
8367 : : GfxDebug::clear();
8368 : : //draw the curves
8369 : : for( int i=0; i<facetedges_on_refedges.size(); i++ )
8370 : : {
8371 : : std::pair<RefEntity*, std::pair<int,int> > tmp_pair;
8372 : : tmp_pair = facetedges_on_refedges[i];
8373 : :
8374 : : RefEntity* ref_ent = tmp_pair.first;
8375 : : std::pair<int,int> int_pair = tmp_pair.second;
8376 : :
8377 : : CubitVector pt0( g_mem->point_list()[int_pair.first].x,
8378 : : g_mem->point_list()[int_pair.first].y,
8379 : : g_mem->point_list()[int_pair.first].z );
8380 : :
8381 : : CubitVector pt1( g_mem->point_list()[int_pair.second].x,
8382 : : g_mem->point_list()[int_pair.second].y,
8383 : : g_mem->point_list()[int_pair.second].z );
8384 : :
8385 : : GfxDebug::draw_point(pt0, (ref_ent->id()%10) + 3 );
8386 : : GfxDebug::draw_point(pt1, (ref_ent->id()%10) + 3 );
8387 : : GfxDebug::draw_line( pt0, pt1, (ref_ent->id()%10) + 3 );
8388 : : }
8389 : : GfxDebug::flush();
8390 : : GfxDebug::mouse_xforms();
8391 : :
8392 : : int index = 0;
8393 : : int color;
8394 : :
8395 : : index = 0;
8396 : : GfxDebug::clear();
8397 : : for( int i=0; i<g_mem->fListCount; i++ )
8398 : : {
8399 : : int step = g_mem->facet_list()[index++];
8400 : : //create pts
8401 : : RefEntity *ref_ent = facet_point_ownership_vector[ g_mem->facet_list()[index] ];
8402 : : if( ref_ent->dimension() == 2 )
8403 : : color = ref_ent->id() + 3 ;
8404 : : CubitVector pt0( g_mem->point_list()[ g_mem->facet_list()[index] ].x,
8405 : : g_mem->point_list()[ g_mem->facet_list()[index] ].y,
8406 : : g_mem->point_list()[ g_mem->facet_list()[index] ].z );
8407 : : index++;
8408 : :
8409 : : ref_ent = facet_point_ownership_vector[ g_mem->facet_list()[index] ];
8410 : : if( ref_ent->dimension() == 2 )
8411 : : color = ref_ent->id() + 3 ;
8412 : : CubitVector pt1( g_mem->point_list()[ g_mem->facet_list()[index] ].x,
8413 : : g_mem->point_list()[ g_mem->facet_list()[index] ].y,
8414 : : g_mem->point_list()[ g_mem->facet_list()[index] ].z );
8415 : : index++;
8416 : :
8417 : : ref_ent = facet_point_ownership_vector[ g_mem->facet_list()[index] ];
8418 : : if( ref_ent->dimension() == 2 )
8419 : : color = ref_ent->id() + 3 ;
8420 : : CubitVector pt2( g_mem->point_list()[ g_mem->facet_list()[index] ].x,
8421 : : g_mem->point_list()[ g_mem->facet_list()[index] ].y,
8422 : : g_mem->point_list()[ g_mem->facet_list()[index] ].z );
8423 : : index++;
8424 : :
8425 : : //draw lines
8426 : :
8427 : : GPoint three_pts[3];
8428 : : three_pts[0].x = pt0.x();
8429 : : three_pts[0].y = pt0.y();
8430 : : three_pts[0].z = pt0.z();
8431 : :
8432 : : three_pts[1].x = pt1.x();
8433 : : three_pts[1].y = pt1.y();
8434 : : three_pts[1].z = pt1.z();
8435 : :
8436 : : three_pts[2].x = pt2.x();
8437 : : three_pts[2].y = pt2.y();
8438 : : three_pts[2].z = pt2.z();
8439 : :
8440 : : GfxDebug::draw_polygon( three_pts, 3, i%20, i%20, true );
8441 : : GfxDebug::draw_line( pt0, pt1, color );
8442 : : GfxDebug::draw_line( pt1, pt2, color );
8443 : : GfxDebug::draw_line( pt0, pt2, color );
8444 : : i+=step;
8445 : : }
8446 : : GfxDebug::flush();
8447 : : GfxDebug::mouse_xforms();
8448 : : */
8449 : : }
8450 : :
8451 [ # # ]: 0 : return CUBIT_SUCCESS;
8452 : : }
8453 : :
8454 : :
8455 : 0 : CubitStatus GeometryQueryTool::get_point_containment( DLIList<Body*> &body_list,
8456 : : DLIList<CubitVector> &point_list,
8457 : : double tolerance,
8458 : : bool allow_pts_in_multiple_bodies,
8459 : : std::vector< std::pair<Body*, std::vector<int> > > &body_to_pt_indices )
8460 : : {
8461 [ # # ][ # # ]: 0 : DLIList<TopologyEntity*> entity_list( body_list.size() );
8462 [ # # ][ # # ]: 0 : for( int i=body_list.size(); i--; )
8463 [ # # ][ # # ]: 0 : entity_list.append( body_list.get_and_step() );
8464 : :
8465 [ # # ][ # # ]: 0 : DLIList<TopologyBridge*> bridge_list;
8466 [ # # ]: 0 : GeometryQueryEngine* gqe = common_query_engine( entity_list, bridge_list );
8467 : :
8468 : : //map for associating PartitionBody back to Body
8469 [ # # ][ # # ]: 0 : std::map<BodySM*, Body*> partition_body_map;
8470 : :
8471 : : //there is a slim chance that all bodies are ParititonBodies. If so,
8472 : : //the gqe will be non-NULL...let's check if the first one is
8473 [ # # ][ # # ]: 0 : if( gqe && GeometryModifyTool::instance()->contains_partitions( body_list ) )
[ # # ][ # # ]
[ # # ]
8474 : 0 : gqe = NULL;
8475 : :
8476 : : //if the engine is still NULL, we could just have a partition body in there...
8477 [ # # ]: 0 : if( gqe == NULL )
8478 : : {
8479 [ # # ]: 0 : bridge_list.clean_out();
8480 : :
8481 [ # # ][ # # ]: 0 : for( int k=0; k<body_list.size(); k++ )
8482 : : {
8483 [ # # ]: 0 : DLIList<TopologyBridge*> underlying_body;
8484 : :
8485 : : //if it is virtual
8486 [ # # ][ # # ]: 0 : if( body_list[k]->get_geometry_query_engine()->is_intermediate_engine() )
[ # # ][ # # ]
8487 : : {
8488 : : //get the underlying Body...in PartitionBody case, it should be a Body
8489 [ # # ][ # # ]: 0 : underlying_body.append( body_list[k]->bridge_manager()->topology_bridge() );
[ # # ][ # # ]
8490 [ # # ]: 0 : IGESet::reverse_iterator itor;
8491 [ # # ][ # # ]: 0 : for (itor = igeSet.rbegin(); itor != igeSet.rend(); ++itor)
[ # # ][ # # ]
[ # # ]
8492 [ # # ][ # # ]: 0 : (*itor)->export_geometry(underlying_body);
8493 : :
8494 : : //if it is different than the original Body TopologyBridge, we found it
8495 [ # # ][ # # ]: 0 : if( underlying_body.size() && body_list[k]->bridge_manager()->topology_bridge() != underlying_body.get() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
8496 : : {
8497 [ # # ][ # # ]: 0 : partition_body_map.insert( std::make_pair( (BodySM*)underlying_body.get(), body_list[k] ) );
[ # # ][ # # ]
[ # # ]
8498 [ # # ][ # # ]: 0 : bridge_list.append( underlying_body.get() );
8499 : : }
8500 : : }
8501 : : else
8502 [ # # ][ # # ]: 0 : bridge_list.append( body_list[k]->bridge_manager()->topology_bridge() );
[ # # ][ # # ]
8503 [ # # ]: 0 : }
8504 : :
8505 [ # # ]: 0 : bridge_list.reset();
8506 [ # # ][ # # ]: 0 : gqe = bridge_list.get_and_step()->get_geometry_query_engine();
8507 : :
8508 [ # # ][ # # ]: 0 : for( int i=1; i<bridge_list.size(); i++ )
8509 : : {
8510 [ # # ]: 0 : TopologyBridge *tmp_bridge = bridge_list.get_and_step();
8511 [ # # ][ # # ]: 0 : if( gqe != tmp_bridge->get_geometry_query_engine() )
8512 : : {
8513 : 0 : gqe = NULL;
8514 : 0 : break;
8515 : : }
8516 : : }
8517 : : }
8518 : :
8519 [ # # ]: 0 : if( gqe == NULL )
8520 : : {
8521 [ # # ][ # # ]: 0 : PRINT_ERROR("Input geometry does not have the same geometry engine.\n");
[ # # ][ # # ]
8522 : 0 : return CUBIT_FAILURE;
8523 : : }
8524 : :
8525 [ # # ][ # # ]: 0 : DLIList<BodySM*> body_sm_list;
8526 [ # # ][ # # ]: 0 : CAST_LIST(bridge_list, body_sm_list, BodySM);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
8527 : :
8528 [ # # ][ # # ]: 0 : std::vector< std::pair<BodySM*, std::vector<int> > > bodysm_to_pt_indices;
8529 [ # # ]: 0 : gqe->get_point_containment( body_sm_list, point_list, tolerance, allow_pts_in_multiple_bodies, bodysm_to_pt_indices );
8530 : :
8531 : : //convert the BodySMs back to BODYs
8532 [ # # ][ # # ]: 0 : for( unsigned int i=0; i<bodysm_to_pt_indices.size(); i++ )
8533 : : {
8534 [ # # ][ # # ]: 0 : std::pair<BodySM*, std::vector<int> > tmp_pair = bodysm_to_pt_indices[i];
8535 : 0 : BodySM *body_sm = tmp_pair.first;
8536 [ # # ][ # # ]: 0 : Body *tmp_body = dynamic_cast<Body*>( body_sm->topology_entity() );
8537 [ # # ]: 0 : if( !tmp_body )
8538 : : {
8539 : : //PartitionBody case...look it up in the map
8540 [ # # ]: 0 : std::map<BodySM*, Body*>::iterator tmp_iter = partition_body_map.find( body_sm );
8541 [ # # ][ # # ]: 0 : if( partition_body_map.end() != tmp_iter )
[ # # ]
8542 : : {
8543 [ # # ][ # # ]: 0 : body_to_pt_indices.push_back( std::make_pair( tmp_iter->second, tmp_pair.second) );
[ # # ][ # # ]
[ # # ][ # # ]
8544 : : }
8545 : : }
8546 : : else
8547 [ # # ][ # # ]: 0 : body_to_pt_indices.push_back( std::make_pair( tmp_body, tmp_pair.second) );
[ # # ][ # # ]
[ # # ]
8548 [ # # ]: 0 : }
8549 : :
8550 [ # # ]: 0 : return CUBIT_SUCCESS;
8551 : : }
8552 : :
8553 : 0 : void GeometryQueryTool::validate_geometry_database()
8554 : : {
8555 [ # # ]: 0 : DLIList<GeometryQueryEngine*> gqe_list;
8556 [ # # ]: 0 : this->get_gqe_list(gqe_list);
8557 [ # # ][ # # ]: 0 : for(int i=0; i<gqe_list.size(); i++)
8558 : : {
8559 [ # # ]: 0 : GeometryQueryEngine *gqe = gqe_list[i];
8560 [ # # ]: 0 : gqe->validate_geometry_database();
8561 [ # # ]: 0 : }
8562 [ + - ][ + - ]: 6540 : }
8563 : :
8564 : :
|