Branch data Line data Source code
1 : : #include "CubitOctreeGeneratorVolumes.hpp"
2 : : #include "CubitOctree.hpp"
3 : : #include "RefFace.hpp"
4 : : #include "TDOctreeRefFace.hpp"
5 : : #include "CubitFacet.hpp"
6 : : #include "CubitOctreeNode.hpp"
7 : : #include "CubitOctreeCell.hpp"
8 : : #include "CubitPoint.hpp"
9 : : #include "CubitFacetEdge.hpp"
10 : : #include "RefEdge.hpp"
11 : : #include "CpuTimer.hpp"
12 : : #include "FacetDataUtil.hpp"
13 : : #include "RefEdge.hpp"
14 : : #include "TDOctreeRefEdge.hpp"
15 : : #include "GeometryQueryEngine.hpp"
16 : : #include "FacetSurface.hpp"
17 : : #include "CubitOctreeConstants.hpp"
18 : : #include "ChollaEngine.hpp"
19 : : #include "ProgressTool.hpp"
20 : : #include "AppUtil.hpp"
21 : : #include "OctreeFacetPointData.hpp"
22 : : #include "Body.hpp"
23 : :
24 : : // Constructor for CubitOctree
25 : 0 : CubitOctreeGeneratorVolumes::CubitOctreeGeneratorVolumes( DLIList<RefEntity*> &entity_list)
26 : 0 : :CubitOctreeGenerator( ), entityList(entity_list){
27 : :
28 [ # # ]: 0 : entityList = entity_list;
29 [ # # ][ # # ]: 0 : cubitOctree = new CubitOctree( this);
30 : 0 : }
31 : :
32 : 0 : void CubitOctreeGeneratorVolumes::get_bounding_box( CubitVector &min, CubitVector &max ){
33 : : RefEntity *volume;
34 : : int index;
35 [ # # ]: 0 : CubitBox bound_box;
36 : :
37 [ # # ]: 0 : min.x( CUBIT_DBL_MAX );
38 [ # # ]: 0 : min.y( CUBIT_DBL_MAX );
39 [ # # ]: 0 : min.z( CUBIT_DBL_MAX );
40 : :
41 [ # # ]: 0 : max.x( -CUBIT_DBL_MAX );
42 [ # # ]: 0 : max.y( -CUBIT_DBL_MAX );
43 [ # # ]: 0 : max.z( -CUBIT_DBL_MAX );
44 : :
45 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
46 [ # # ]: 0 : volume = entityList.get_and_step();
47 : :
48 [ # # ][ # # ]: 0 : bound_box = volume->bounding_box();
[ # # ]
49 : :
50 [ # # ][ # # ]: 0 : if( bound_box.minimum().x() < min.x() )
[ # # ][ # # ]
51 [ # # ][ # # ]: 0 : min.x( bound_box.minimum().x());
[ # # ]
52 [ # # ][ # # ]: 0 : if( bound_box.minimum().y() < min.y() )
[ # # ][ # # ]
53 [ # # ][ # # ]: 0 : min.y( bound_box.minimum().y());
[ # # ]
54 [ # # ][ # # ]: 0 : if( bound_box.minimum().z() < min.z() )
[ # # ][ # # ]
55 [ # # ][ # # ]: 0 : min.z( bound_box.minimum().z());
[ # # ]
56 : :
57 [ # # ][ # # ]: 0 : if( bound_box.maximum().x() > max.x() )
[ # # ][ # # ]
58 [ # # ][ # # ]: 0 : max.x( bound_box.maximum().x());
[ # # ]
59 [ # # ][ # # ]: 0 : if( bound_box.maximum().y() > max.y() )
[ # # ][ # # ]
60 [ # # ][ # # ]: 0 : max.y( bound_box.maximum().y());
[ # # ]
61 [ # # ][ # # ]: 0 : if( bound_box.maximum().z() > max.z() )
[ # # ][ # # ]
62 [ # # ][ # # ]: 0 : max.z( bound_box.maximum().z());
[ # # ]
63 [ # # ]: 0 : }
64 : :
65 : 0 : }
66 : :
67 : : // CubitOctree is generated based on facets of the FACE.
68 : : // Therefore small features are captured.
69 : : // First the CubitOctree grid is generated without any intersection
70 : : // calculation. The nodes are linked using 6 pointers to the adjacent nodes
71 : : // The cells are stored using CubitOctree data structure. As the boundary points are need
72 : : // for MAT generation, intersection between the CubitOctree edges and facets are computed and
73 : : // normals are also stored.
74 : 0 : CubitBoolean CubitOctreeGeneratorVolumes::generate_lattice( void ){
75 : :
76 : : // initialize CubitOctree root
77 : 0 : cubitOctree->initialize_octree_generation();
78 : :
79 : : // Builds the tree fully till the level min_depthibcbtghs.lib
80 : 0 : cubitOctree->build_octree_till_min_depth( cubitOctree->get_root() );
81 : :
82 : : // Builds the tree based on facets' points, centroid, dimension ...
83 : : // Note that the points on the curves belong to more than one face
84 : : // Therefore the CubitOctree is subdivided till the maxDepth
85 : 0 : build_octree_till_skl_max_depth_based_on_facets();
86 : :
87 : : // Adjacents cells can be found by visiting the adjacent cells of every node
88 : : // Cells are split till the difference in the levels of adjacent cells is 1.
89 : : // At every node find the maximum and minimum cell. Split the maximum cell if
90 : : // it deffers by 2 or more in depth.
91 : :
92 : :
93 : : //PRINT_DEBUG_157(" Number of nodes = %d", gridNodeVector.size() );
94 : 0 : return CUBIT_TRUE;
95 : : }
96 : :
97 : :
98 : 0 : CubitBoolean CubitOctreeGeneratorVolumes::build_octree_till_skl_max_depth_based_on_facets( void ){
99 : :
100 [ # # ]: 0 : DLIList< RefFace *> vol_ref_faces;
101 : : DLIList<CubitFacet *> *facet_list;
102 : : DLIList<CubitPoint*> *point_list;
103 : : DLIList<CubitFacetEdge *> *ptr_facet_edge_list;
104 [ # # ][ # # ]: 0 : DLIList<OctreeFacetPointData *> facet_point_data_list; //, vfacet_point_data_list;
105 [ # # ][ # # ]: 0 : DLIList<CubitOctreeCell*> refine_cell_list;
106 : :
107 : : // DLIList<CubitFacet*> global_facet_list;
108 : :
109 : :
110 : : int index;
111 : : int i, j, k, l;
112 : : CubitPoint *ptr_point;
113 : : CubitFacet *ptr_facet, *ptr_adj_facet0, *ptr_adj_facet1;
114 : : CubitFacetEdge *ptr_edge;
115 : : RefFace *ptr_ref_face;
116 : : OctreeFacetPointData *facet_point_data;
117 [ # # ][ # # ]: 0 : CubitVector normal0, normal1;
118 : : double internal_angle;
119 : : Body *volume;
120 : : TDOctreeRefFace *td_ref_face;
121 : :
122 : : // PR-CubitOctree has the property that the cell size depends on the density of the facet points
123 : : // Higher the density the finer will be the facet cell size.
124 : : // Step 1: The CubitOctree is built only till MaxDepth based on facet information
125 : : // 1. Small features that have smaller curve length are detected using facet density
126 : : // 2. Surface/Curve curvature are detected based on di-hedral angle between the adj facets.
127 : : // Also the aspect ratio of facets are used because it is found that when the surface has curvature on only one directio
128 : : // the facet aspect ratio will be very high.
129 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
130 [ # # ][ # # ]: 0 : volume = CAST_TO( entityList.get_and_step(), Body );
131 [ # # ]: 0 : vol_ref_faces.clean_out();
132 [ # # ]: 0 : volume->ref_faces( vol_ref_faces );
133 [ # # ]: 0 : vol_ref_faces.reset();
134 : :
135 : : // get volume facets and insert points from those facets
136 : :
137 [ # # ][ # # ]: 0 : for( i = 0; i < vol_ref_faces.size(); i++ ){
138 [ # # ]: 0 : ptr_ref_face = vol_ref_faces.get_and_step();
139 [ # # ]: 0 : td_ref_face = TDOctreeRefFace::get_td( ptr_ref_face );
140 : :
141 [ # # ][ # # ]: 0 : if( td_ref_face->get_visit() == CUBIT_FALSE ){
142 [ # # ]: 0 : td_ref_face->set_visit( CUBIT_TRUE );
143 : :
144 : : // grab facets here if stitching
145 : :
146 : : // add to global list for facet point insertion
147 : :
148 : : /*int num_parents = CAST_TO(ptr_ref_face,RefFace)->num_parent_ref_entities();
149 : : if (num_parents == 1)
150 : : {
151 : : global_facet_list += *facet_list;
152 : : }
153 : :
154 : : else
155 : : {*/
156 : :
157 : : // Generated OctreeFacetPointData based on facet vertices
158 [ # # ]: 0 : point_list = td_ref_face->get_ptr_cubit_point_list();
159 [ # # ][ # # ]: 0 : for( j = 0; j < point_list->size(); j++ ){
160 [ # # ]: 0 : ptr_point = point_list->get_and_step();
161 [ # # ][ # # ]: 0 : facet_point_data = new OctreeFacetPointData( ptr_point->coordinates(), ptr_point );
[ # # ]
162 [ # # ]: 0 : facet_point_data_list.push( facet_point_data );
163 : : }
164 : : // point_list.clean_out();
165 : :
166 : : //}
167 : :
168 : :
169 : : // Generate OctreeFacetPointData based on facet centroid
170 : :
171 [ # # ]: 0 : facet_list = td_ref_face->get_ptr_cubit_facet_list();
172 [ # # ][ # # ]: 0 : for( j = 0; j < facet_list->size(); j++ ){
173 [ # # ]: 0 : ptr_facet = facet_list->get_and_step();
174 [ # # ][ # # ]: 0 : facet_point_data = new OctreeFacetPointData( ptr_facet->center(), ptr_facet );
[ # # ]
175 [ # # ]: 0 : facet_point_data_list.push( facet_point_data );
176 : : }
177 : :
178 : : /* Generate OctreeFacetPointData based on aspect ratio of facet
179 : : for( j = 0; j < facet_list->size(); j++ ){
180 : : ptr_facet = facet_list->get_and_step();
181 : : OctreeFacetPointData::generate_facet_point_data_at_slender_facet( ptr_facet, facet_point_data_list );
182 : : }
183 : : */
184 : :
185 : : // Generate OctreeFacetPointData based on surface curvature
186 [ # # ]: 0 : ptr_facet_edge_list = td_ref_face->get_ptr_cubit_facet_edge_list();
187 [ # # ][ # # ]: 0 : for( j = 0; j < ptr_facet_edge_list->size(); j++ ){
188 [ # # ]: 0 : ptr_edge = ptr_facet_edge_list->get_and_step();
189 [ # # ][ # # ]: 0 : if( ptr_edge->num_adj_facets() == 2 ){
190 : : // mark adjacent facets
191 [ # # ]: 0 : ptr_adj_facet0 = ptr_edge->adj_facet(0);
192 [ # # ]: 0 : ptr_adj_facet1 = ptr_edge->adj_facet(1);
193 [ # # ][ # # ]: 0 : normal0 = ptr_adj_facet0->normal();
194 [ # # ][ # # ]: 0 : normal1 = ptr_adj_facet1->normal();
195 : :
196 [ # # ][ # # ]: 0 : if (normal0.length_squared() > 0.0 && normal1.length_squared() > 0.0)
[ # # ][ # # ]
[ # # ]
197 : : {
198 [ # # ]: 0 : internal_angle = normal0.interior_angle(normal1);
199 : : }
200 : : else
201 : : {
202 : 0 : internal_angle = 0.0;
203 : : }
204 : : //PRINT_INFO("%f ", internal_angle );
205 [ # # ]: 0 : if( internal_angle > ANGLE_BETWEEN_FACETS_NORMAL_FOR_OCTREE_BASED_ON_SURF_CURVATURE_FACTOR * ANG_FACET_EXTRACT[OCTREE_TIME_ACCURACY_LEVEL] ){
206 [ # # ]: 0 : OctreeFacetPointData::generate_facet_point_data_based_on_curvature( ptr_edge, /*internal_angle,*/ facet_point_data_list );
207 : : }
208 : : }
209 : : }
210 : :
211 : : // now check for pairs of adjacents with dihedral angles along their shared edge
212 : : // the CubitOctree should be refined in these regions so we have enough grid nodes to generate 3dmat points
213 : : // disabling for now :( because there is a problem in FacetDataUtil's facet stitching code
214 : : if (0)
215 : : {
216 : : DLIList<DLIList<RefEdge*> > edge_loops;
217 : : ptr_ref_face->ref_edge_loops(edge_loops);
218 : : for (i=0; i < edge_loops.size(); ++i)
219 : : {
220 : : DLIList<RefEdge*>& edge_loop = edge_loops.get_and_step();
221 : : for (j=0; j < edge_loop.size(); ++j)
222 : : {
223 : : DLIList<RefEntity*> parents;
224 : : RefEdge *edge = edge_loop.get_and_step();
225 : : TDOctreeRefEdge *td_ref_edge = TDOctreeRefEdge::get_td(edge);
226 : :
227 : : if( td_ref_edge->get_visit() == CUBIT_FALSE )
228 : : {
229 : : td_ref_edge->set_visit( CUBIT_TRUE );
230 : : edge->get_parent_ref_entities(parents);
231 : :
232 : : // check Refface's for bad facets in case it hasn't been done
233 : : // already
234 : : for (k=0; k < parents.size(); ++k)
235 : : {
236 : : RefFace *parent = CAST_TO(parents.get_and_step(), RefFace);
237 : : if (parent == NULL) {continue;}
238 : : TDOctreeRefFace *td_parent = TDOctreeRefFace::get_td(parent);
239 : : if (td_parent == NULL) {continue;}
240 : : if (td_parent->get_create_2dmat())
241 : : {
242 : : td_parent->check_valid_facets(CUBIT_TRUE);
243 : : }
244 : : }
245 : :
246 : : for (k=0; k < parents.size(); ++k)
247 : : {
248 : : for (l=k+1; l < parents.size(); ++l)
249 : : {
250 : : // SVDrawTool::clear_non_retained();
251 : : DLIList<CubitFacet*> crease_facets;
252 : : DLIList<CubitFacetEdge*> crease_edges;
253 : : cubitOctree->find_cells_based_on_surface_angle(refine_cell_list, crease_edges, crease_facets,
254 : : CAST_TO(parents[k],RefFace), CAST_TO(parents[l],RefFace),
255 : : CUBIT_FALSE, 2.0*CUBIT_PI/3.0);
256 : : // will need to store crease_edges and facets
257 : :
258 : : // SVDrawTool::mouse_xforms();
259 : : }
260 : :
261 : : }
262 : : }
263 : :
264 : : }
265 : :
266 : : }
267 : : }
268 : :
269 : : }
270 : : }
271 : : }
272 : :
273 : :
274 : : /*
275 : : DLIList<DLIList<CubitFacet*>*> shells;
276 : : shells.append(&global_facet_list);
277 : : CubitBoolean dummy;
278 : : FacetDataUtil::stitch_facets(shells, OCTREE_EPSILON, dummy);
279 : : if (shells.size() == 1)
280 : : {
281 : : FacetDataUtil::get_points(global_facet_list, point_list);
282 : : for( j = 0; j < point_list.size(); j++ )
283 : : {
284 : : ptr_point = point_list.get_and_step();
285 : : facet_point_data = new OctreeFacetPointData( ptr_point->coordinates(), ptr_point );
286 : : facet_point_data_list.push( facet_point_data );
287 : : }
288 : : }
289 : : else
290 : : {
291 : : PRINT_INFO("Stitch resulted in multiple shells!!!!!!!!!!\n");
292 : :
293 : : }
294 : : */
295 : :
296 : :
297 : :
298 : : // Reset the visit to CUBIT_FALSE
299 [ # # ]: 0 : reset_td_octree_ref_face_visit( CUBIT_FALSE );
300 [ # # ]: 0 : reset_td_octree_ref_edge_visit( CUBIT_FALSE );
301 : :
302 [ # # ]: 0 : facet_point_data_list.reset();
303 [ # # ][ # # ]: 0 : for( i = 0; i < facet_point_data_list.size(); i++ ){
304 [ # # ]: 0 : facet_point_data = facet_point_data_list.get_and_step();
305 : : //SkeletonDebug::draw_point( facet_point_data->coordinates(), CUBIT_MAGENTA_INDEX );
306 [ # # ][ # # ]: 0 : cubitOctree->subdivide_octree_based_on_facet_point( facet_point_data, cubitOctree->get_max_depth() );
307 : : }
308 : :
309 : : // refine the cells on edges with large enough dihedral angles
310 : : // disabling for now
311 : : //int target_depth = skeletonProxy->get_source_entity_max_depth();
312 : : //cubitOctree->refine_cells_to_target_depth(refine_cell_list, target_depth);
313 : :
314 [ # # ]: 0 : return CUBIT_TRUE;
315 : : }
316 : :
317 : :
318 : :
319 : 0 : CubitBoolean CubitOctreeGeneratorVolumes::find_intersection_between_octree_and_facets( DLIList<CubitOctreeNode *> &queue_for_mat_generation ){
320 [ # # ]: 0 : DLIList< RefFace *> vol_ref_faces;
321 : : RefFace *ptr_ref_face;
322 : : TDOctreeRefFace *td_ref_face;
323 : : DLIList< CubitFacet *> *facet_list;
324 : : CubitFacet *ptr_facet;
325 [ # # ][ # # ]: 0 : DLIList<CubitOctreeCell *> CubitOctree_cell_list;
326 [ # # ][ # # ]: 0 : DLIList< CubitOctreeNode *> CubitOctree_grid_node_list;
327 [ # # ][ # # ]: 0 : DLIList<CubitOctreeNode*> all_grid_nodes;
328 : :
329 : : //CubitVector facet_normal;
330 : : //DLIList< CubitPoint *> *point_list;
331 : : int i, j, k;
332 : : int index;
333 : : Body *volume;
334 : :
335 : : // CpuTimer total_idata_time;
336 : :
337 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
338 [ # # ][ # # ]: 0 : volume = CAST_TO( entityList.get_and_back(), Body );
339 [ # # ]: 0 : vol_ref_faces.clean_out();
340 [ # # ]: 0 : volume->ref_faces( vol_ref_faces );
341 : : //vol_ref_faces.reset();
342 : : //int cell_count = 0;
343 : : //CubitBox facet_bbox;
344 : : //PRINT_INFO(" \nRef Volume = %d ", volume->id());
345 : :
346 [ # # ][ # # ]: 0 : for( i = 0; i < vol_ref_faces.size(); i++ ){
347 [ # # ]: 0 : ptr_ref_face = vol_ref_faces.get_and_step();
348 [ # # ]: 0 : td_ref_face = TDOctreeRefFace::get_td( ptr_ref_face );
349 : :
350 [ # # ][ # # ]: 0 : if(td_ref_face->get_visit() == CUBIT_FALSE){
351 [ # # ]: 0 : td_ref_face->set_visit( CUBIT_TRUE );
352 : :
353 : : //PRINT_INFO(" \nRef Face = %d ", ptr_ref_face->id());
354 : :
355 : 0 : RefFace *current_ref_face = CAST_TO(ptr_ref_face, RefFace);
356 : : /*if (current_ref_face->sense(CAST_TO(volume,Body)) == CUBIT_REVERSED)
357 : : {
358 : : temp_facet_normal *= -1.0;
359 : : }*/
360 : :
361 : : // PRINT_INFO("Number of parent ref Entities for face %d: %d\n", current_ref_face->id(), current_ref_face->num_parent_ref_entities());
362 : :
363 : : // get the sense so we know which way to propagate the 3DMAT front inwards
364 : 0 : CubitSense ref_face_sense = CUBIT_FORWARD; //current_ref_face->sense(volume);
365 : :
366 : : // in the case of a merged face, figure out if two parent vols share the same
367 : : // sizing function. If so, propagate in both directions
368 [ # # ][ # # ]: 0 : if (current_ref_face->is_merged() /*&& current_ref_face->num_parent_ref_entities() == 2*/)
369 : : {
370 [ # # ]: 0 : DLIList<RefEntity*> parent_ents;
371 [ # # ]: 0 : current_ref_face->get_parent_ref_entities(parent_ents);
372 [ # # ][ # # ]: 0 : if (parent_ents.size() == 2)
373 : : {
374 [ # # ][ # # ]: 0 : Body *other_parent_vol = CAST_TO(parent_ents.get_and_step(),Body);
375 [ # # ][ # # ]: 0 : if (other_parent_vol == volume) {other_parent_vol = CAST_TO(parent_ents.get(),Body);}
[ # # ]
376 [ # # ]: 0 : if (other_parent_vol != NULL)
377 : : {
378 : :
379 : : // if the other parent volume has the same sizing function,
380 : : // pass CUBIT_UNKNOWN to CubitOctreeCell::set_color_and_idatas
381 : : // It will then set up the front normals to propagate in both directions
382 : 0 : ref_face_sense = CUBIT_UNKNOWN;
383 : :
384 : : }
385 [ # # ]: 0 : }
386 : : }
387 : :
388 [ # # ]: 0 : facet_list = td_ref_face->get_ptr_cubit_facet_list();
389 : : //PRINT_INFO("Surface %d: facets: %d\n", ptr_ref_face->id(), facet_list->size());
390 : :
391 [ # # ][ # # ]: 0 : for( j = 0; j < facet_list->size(); j++ ){
392 [ # # ]: 0 : ptr_facet = facet_list->get_and_step();
393 : :
394 : : //CubitVector temp_facet_normal = ptr_facet->normal();
395 : :
396 : :
397 : : //SVDrawTool::draw_vector(ptr_facet->center(), ptr_facet->center()+temp_facet_normal, (i%8)+1);
398 : :
399 : :
400 : : //#ifndef NDEBUG
401 : : // SkeletonDebug::draw_facet( ptr_facet, CUBIT_BLUE_INDEX );
402 : : //#endif
403 : : //facet_bbox = ptr_facet->bounding_box();
404 : : //draw_box( facet_bbox );
405 : : //facet_normal = ptr_facet->normal();
406 : : //if( ptr_facet->is_backwards() ){
407 : : // facet_normal = facet_normal * -1;
408 : : //}
409 : : //GfxDebug::draw_line( ptr_facet->center().x(), ptr_facet->center().y(), ptr_facet->center().z(), ptr_facet->center().x()+facet_normal.x(), ptr_facet->center().y()+facet_normal.y(), ptr_facet->center().z()+facet_normal.z(), CUBIT_WHITE_INDEX );
410 [ # # ]: 0 : CubitOctree_cell_list.clean_out();
411 [ # # ]: 0 : CubitOctree_grid_node_list.clean_out();
412 : : //PRINT_INFO(" Before find_octree_cells_contatined \n");
413 [ # # ]: 0 : cubitOctree->find_octree_cells_contained_inside_bbox( ptr_facet, CubitOctree_cell_list );
414 : : //PRINT_INFO(" Before mark_positive_and_negative_grid_nodes \n");
415 [ # # ]: 0 : cubitOctree->mark_positive_and_negative_octree_grid_nodes( ptr_facet, CubitOctree_cell_list, CubitOctree_grid_node_list );
416 : : //PRINT_INFO(" Before find_intersection_between_grid_edge_facet \n");
417 : :
418 [ # # ]: 0 : if ( OCTREE_DEFAULT_INTERSECTION_METHOD[OCTREE_TIME_ACCURACY_LEVEL] == SAT_INTERSECT){
419 : : //PRINT_INFO("%d cells in bbox\n", CubitOctree_cell_list.size());
420 : :
421 [ # # ][ # # ]: 0 : for (k=0; k < CubitOctree_cell_list.size(); ++k)
422 : : {
423 [ # # ]: 0 : CubitOctreeCell *current_cell = CubitOctree_cell_list.get_and_step();
424 : : // if (current_cell->get_mark() == CUBIT_FALSE) {continue;}
425 : : //current_cell->set_mark(CUBIT_FALSE);
426 : :
427 [ # # ][ # # ]: 0 : if (current_cell->does_facet_intersect_octreecell(ptr_facet))
428 : : {
429 : : /* double corners[3];
430 : : double half_edge_length = current_cell->get_dimension()/2.0;
431 : : CubitVector center = current_cell->get_center();
432 : : center.get_xyz(corners);
433 : : float box[6] = {corners[0]-half_edge_length, corners[1]-half_edge_length, corners[2]-half_edge_length,
434 : : corners[0]+half_edge_length, corners[1]+half_edge_length, corners[2]+half_edge_length};
435 : : SVDrawTool::draw_cube(box, CUBIT_GREEN_INDEX, SVDrawTool::WIRE);*/
436 : :
437 : : current_cell->set_color_and_intersection_datas(ptr_facet, ptr_ref_face,
438 : : #ifdef USE_octree_BGMESH
439 : : cubitOctree->get_greycelllist(),
440 : : #endif
441 [ # # ]: 0 : ref_face_sense);
442 : :
443 : : //cubitOctree->get_greycelllist()->append(current_cell);
444 : : }
445 : : /*if (ref_face_sense) {
446 : : // SVDrawTool::mouse_xforms();
447 : : }*/
448 : :
449 : : }
450 : :
451 [ # # ][ # # ]: 0 : for( k = 0; k < CubitOctree_grid_node_list.size(); k++ )
452 : : {
453 [ # # ]: 0 : CubitOctreeNode *ptr_grid_node = CubitOctree_grid_node_list.get_and_step();
454 [ # # ][ # # ]: 0 : if (ptr_grid_node->get_visit() == CUBIT_FALSE)
455 : : {
456 [ # # ]: 0 : all_grid_nodes.append(ptr_grid_node);
457 [ # # ]: 0 : ptr_grid_node->set_visit(CUBIT_TRUE);
458 : : }
459 : :
460 [ # # ]: 0 : ptr_grid_node->set_mark( CUBIT_FALSE );
461 [ # # ][ # # ]: 0 : if( ptr_grid_node->get_halfspace_direction() == OCTREE_POSITIVE )
462 : : {
463 [ # # ]: 0 : ptr_grid_node->set_halfspace_direction( OCTREE_NEGATIVE );
464 : : }
465 : : }
466 : : }
467 : :
468 [ # # ]: 0 : if (OCTREE_DEFAULT_INTERSECTION_METHOD[OCTREE_TIME_ACCURACY_LEVEL] == GRID_EDGE_INT)
469 : : {
470 [ # # ]: 0 : cubitOctree->find_intersection_between_grid_edges_and_facet( CUBIT_OCTREE_VOLUME, ptr_ref_face, ptr_facet, CubitOctree_grid_node_list );
471 : : }
472 : :
473 : :
474 : :
475 : : }
476 : :
477 : : }
478 : : }
479 : : }
480 : :
481 : : // Reset the visit to CUBIT_FALSE
482 [ # # ]: 0 : reset_td_octree_ref_face_visit( CUBIT_FALSE );
483 : : //SVDrawTool::mouse_xforms();
484 : : // PRINT_INFO("profiling: time for intersecting and making idatas: %f\n", total_idata_time.cpu_secs());
485 : :
486 [ # # ]: 0 : if (OCTREE_DEFAULT_INTERSECTION_METHOD[OCTREE_TIME_ACCURACY_LEVEL] == SAT_INTERSECT)
487 : : {
488 : : //CpuTimer front_color_time;
489 [ # # ][ # # ]: 0 : for (i=0; i < all_grid_nodes.size(); ++i)
490 : : {
491 [ # # ]: 0 : CubitOctreeNode *grid_node = all_grid_nodes.get_and_step();
492 [ # # ]: 0 : DLIList<OctreeIntersectionData*> *idata_list = grid_node->get_idata_list();
493 : : //idata_list->uniquify_unordered();
494 : :
495 : :
496 [ # # ][ # # ]: 0 : if (idata_list->size() > 0)
497 : : {
498 [ # # ]: 0 : DLIList<OctreeIntersectionData*> closest_ones;
499 : : //OctreeIntersectionData *closest = NULL;
500 : 0 : double min_list_dist = CUBIT_DBL_MAX;
501 [ # # ][ # # ]: 0 : for (k=0; k < idata_list->size(); ++k)
502 : : {
503 [ # # ][ # # ]: 0 : if (idata_list->get()->is_merged()) {idata_list->step();}
[ # # ][ # # ]
504 : :
505 [ # # ][ # # ]: 0 : double temp_dist = idata_list->get()->get_length();
506 [ # # ]: 0 : if (temp_dist < min_list_dist - OCTREE_EPSILON)
507 : : {
508 [ # # ]: 0 : closest_ones.clean_out();
509 : : // closest = idata_list->get();
510 [ # # ][ # # ]: 0 : closest_ones.append(idata_list->get());
511 : 0 : min_list_dist = temp_dist;
512 : : }
513 [ # # ]: 0 : else if (fabs(temp_dist - min_list_dist) <= OCTREE_EPSILON)
514 : : {
515 [ # # ][ # # ]: 0 : closest_ones.append(idata_list->get());
516 : : }
517 [ # # ]: 0 : idata_list->step();
518 : : }
519 : :
520 : 0 : bool white = false;
521 : :
522 [ # # ][ # # ]: 0 : for (j=0; j < closest_ones.size(); ++j)
523 : : {
524 [ # # ][ # # ]: 0 : if (closest_ones.get_and_step()->get_halfspace())
[ # # ]
525 : : {
526 : 0 : white = true;
527 : 0 : break;
528 : : }
529 : : }
530 : :
531 : : //closest = closest_ones.get();
532 : : // if (!white) {SVDrawTool::draw_vector(grid_node->get_coord(), closest->get_int_point(), CUBIT_RED_INDEX);}
533 : :
534 : : // this is the closest facet encountered by the current grid node so far
535 : : // update color of node based on this facet
536 [ # # ]: 0 : if (white)
537 : : {
538 [ # # ]: 0 : grid_node->set_color(CUBIT_WHITE_INDEX);
539 [ # # ][ # # ]: 0 : cubitOctree->get_whitenodelist()->append(grid_node);
540 : :
541 : : }
542 [ # # ]: 0 : else if (!white)
543 : : {
544 : : // if ( (grid_node->get_coord()-closest->get_facet_ptr()->center()) % (closest->get_normal()) < 0)
545 : : // {
546 : : // PRINT_INFO("Adding a white node to queue !!!!!!!!!!!!\n");
547 : : // }
548 : :
549 : : // uncomment this
550 : : // for (j=0; j < grid_node->get_idata_list()->size(); ++j)
551 : : // {
552 : : // OctreeIntersectionData *idata = grid_node->get_idata_list()->get_and_step();
553 : : // double proj_length = fabs((grid_node->get_coord() - idata->get_int_point())%idata->get_facet_normal());
554 : : // idata->set_length(proj_length);
555 : : // }
556 : :
557 : : // SVDrawTool::draw_vector(grid_node->get_coord(), closest->get_int_point(), CUBIT_RED_INDEX);
558 : :
559 [ # # ]: 0 : grid_node->set_color(CUBIT_BLACK_INDEX);
560 [ # # ]: 0 : queue_for_mat_generation.append(grid_node);
561 : : }
562 : : else
563 : : {
564 : : //PRINT_INFO("Couldn't pick halfspace to color node!\n");
565 [ # # ]: 0 : }
566 : : }
567 [ # # ]: 0 : grid_node->set_visit(CUBIT_FALSE);
568 : : }
569 : :
570 [ # # ][ # # ]: 0 : for (i=0; i < cubitOctree->get_whitenodelist()->size(); ++i)
[ # # ]
571 : : {
572 [ # # ][ # # ]: 0 : CubitOctreeNode *ptr_grid_node = cubitOctree->get_whitenodelist()->get_and_step();
573 [ # # ]: 0 : DLIList<OctreeIntersectionData*> *idata_list = ptr_grid_node->get_idata_list();
574 [ # # ][ # # ]: 0 : for (k=0; k < idata_list->size(); ++k)
575 : : {
576 [ # # ]: 0 : OctreeIntersectionData *idata = idata_list->get_and_step();
577 [ # # ][ # # ]: 0 : if (idata != NULL) {delete idata;}
[ # # ]
578 : : }
579 [ # # ]: 0 : idata_list->clean_out();
580 : 0 : CubitOctreeNode *adj_node = NULL;
581 [ # # ]: 0 : for (k=0; k < 6; ++k)
582 : : {
583 [ # # ]: 0 : adj_node = ptr_grid_node->get_adj_node(k);
584 [ # # ]: 0 : if (adj_node != NULL)
585 : : {
586 [ # # ][ # # ]: 0 : if (adj_node->get_color() != CUBIT_BLACK_INDEX && adj_node->get_color() != CUBIT_WHITE_INDEX)
[ # # ][ # # ]
[ # # ]
587 : : {
588 [ # # ]: 0 : adj_node->set_color(CUBIT_YELLOW_INDEX);
589 : : }
590 : : //SVDrawTool::draw_point(adj_node->get_coord(), adj_node->get_color());
591 : : }
592 : : }
593 : : }
594 : : // PRINT_INFO("profiling: time to color front nodes: %f\n", front_color_time.cpu_secs());
595 : :
596 : : }
597 : :
598 : :
599 : :
600 : :
601 : :
602 : : // PRINT_INFO("Testing: Cell Count = %d", cell_count );
603 [ # # ]: 0 : if (OCTREE_DEFAULT_INTERSECTION_METHOD[OCTREE_TIME_ACCURACY_LEVEL] == SAT_INTERSECT)
604 : : {
605 : :
606 : : // CpuTimer front_init;
607 : :
608 [ # # ][ # # ]: 0 : for( i = 0; i < queue_for_mat_generation.size(); i++ ){
609 [ # # ][ # # ]: 0 : queue_for_mat_generation.get_and_step()->SAT_find_face_distance_average_normal( /*skeletonSizingFunction, queue_for_mat_generation*/ );
610 : : }
611 : : //PRINT_INFO("profiling: time to init front: %f\n", front_init.cpu_secs());
612 : :
613 : : }
614 : :
615 : :
616 [ # # ]: 0 : return CUBIT_TRUE;
617 : : }
618 : :
619 : :
620 : :
621 : 0 : void CubitOctreeGeneratorVolumes::find_optimal_min_and_max_depth( RefEntity*entity, int &local_min_depth, int &local_max_depth )
622 : : {
623 [ # # ]: 0 : Body *volume = dynamic_cast<Body *> (entity);
624 [ # # ]: 0 : if( NULL == volume)
625 : 0 : return;
626 : :
627 [ # # ]: 0 : CubitBox bbox = volume->bounding_box();
628 : :
629 : : // calculate min_depth by comparing min_range with max_range in log scale
630 [ # # ][ # # ]: 0 : double max_range = std::max( std::max( bbox.x_range(), bbox.y_range()), bbox.z_range() );
[ # # ][ # # ]
[ # # ]
631 [ # # ][ # # ]: 0 : double min_range = std::min( std::min( bbox.x_range(), bbox.y_range()), bbox.z_range() );
[ # # ][ # # ]
[ # # ]
632 : 0 : local_min_depth = (int)(log( max_range / min_range ) / log(2.0)) + 1; // add plus 1 just to give enough one extra level of depth
633 : :
634 [ # # ]: 0 : if( local_min_depth < MIN_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL] )
635 : 0 : local_min_depth = MIN_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL];
636 [ # # ]: 0 : if( local_min_depth > MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL] )
637 : 0 : local_min_depth = MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL];
638 : :
639 : : // calculate max_depth by comparing the min curve length with max_range in log scale
640 [ # # ][ # # ]: 0 : DLIList< RefEdge *> list_edges;
641 [ # # ]: 0 : volume->ref_edges( list_edges );
642 : :
643 : : int i;
644 : : RefEdge *ptr_edge;
645 : 0 : double min_edge_len = DBL_MAX;
646 : : double len;
647 [ # # ][ # # ]: 0 : CubitVector start_pt, mid_pt, end_pt;
[ # # ]
648 [ # # ][ # # ]: 0 : for( i = 0; i < list_edges.size(); i++ )
649 : : {
650 [ # # ]: 0 : ptr_edge = list_edges.get_and_step();
651 : : //len = ptr_edge->length_from_u( ptr_edge->start_param(), ptr_edge->end_param() );
652 [ # # ][ # # ]: 0 : start_pt = ptr_edge->start_coordinates();
653 [ # # ][ # # ]: 0 : end_pt = ptr_edge->end_coordinates();
654 [ # # ]: 0 : ptr_edge->mid_point(mid_pt);
655 [ # # ][ # # ]: 0 : len = (mid_pt - start_pt).length() + (end_pt - mid_pt).length();
[ # # ][ # # ]
656 [ # # ]: 0 : if( len < min_edge_len )
657 : : {
658 : 0 : min_edge_len = len;
659 : : }
660 : : }
661 : 0 : local_max_depth = (int)(log( max_range / min_edge_len) / log(2.0) ) + 1;
662 : :
663 : : /*
664 : : // calculate max_depth by comparing the min mesh size with max_range in log scale
665 : : double min_mesh_size = max_range;
666 : : double mesh_size;
667 : : for( i = 0; i < list_edges.size(); i++ )
668 : : {
669 : : ptr_edge = list_edges.get_and_step();
670 : :
671 : : mesh_size = max_range;
672 : : MeshToolProxy* mesh_tool_ptr = MeshToolProxy::mesh_tool(ptr_edge);
673 : : SizeIntervalType hardness;
674 : : double tmp_size = mesh_tool_ptr->requested_interval_size(hardness);
675 : : if (hardness > CALCULATED)
676 : : {
677 : : mesh_size = tmp_size/ 2.0;
678 : : }
679 : : if( mesh_size < min_mesh_size )
680 : : {
681 : : min_mesh_size = mesh_size;
682 : : }
683 : : }
684 : : local_max_depth = std::max( local_max_depth, (int)(log( max_range / min_mesh_size) / log(2.0) ) + 1 );
685 : : */
686 : : /*
687 : : // calculate max_depth by comparing the min mesh size with max_range in log scale
688 : : DLIList< RefFace *> list_faces;
689 : : volume->ref_faces( list_faces );
690 : : min_mesh_size = max_range;
691 : : RefFace *ptr_face;
692 : : for( i = 0; i < list_faces.size(); i++ )
693 : : {
694 : : ptr_face = list_faces.get_and_step();
695 : :
696 : : mesh_size = max_range;
697 : : MeshToolProxy* mesh_tool_ptr = MeshToolProxy::mesh_tool(ptr_face);
698 : : SizeIntervalType hardness;
699 : : double tmp_size = mesh_tool_ptr->requested_interval_size(hardness);
700 : : if (hardness > CALCULATED)
701 : : {
702 : : mesh_size = tmp_size/2.0;
703 : : }
704 : : if( mesh_size < min_mesh_size )
705 : : {
706 : : min_mesh_size = mesh_size;
707 : : }
708 : : }
709 : : local_max_depth = std::max( local_max_depth, (int)(log( max_range / min_mesh_size) / log(2.0) ) + 1 );
710 : : */
711 : :
712 [ # # ]: 0 : if( local_max_depth > MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL] )
713 : 0 : local_max_depth = MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL];
714 : :
715 : : // make sure local_max_depth is atleast one depth higher than local_min_depth
716 [ # # ]: 0 : if( local_max_depth <= local_min_depth )
717 [ # # ]: 0 : local_max_depth = local_min_depth + 1;
718 : :
719 : :
720 : :
721 : : }
722 : :
723 : : // finds the optimal min and max depths of CubitOctree
724 : 0 : void CubitOctreeGeneratorVolumes::find_optimal_min_and_max_octree_depths( DLIList< RefEntity *> &entity_list, int &min_depth, int &max_depth )
725 : : {
726 [ # # ]: 0 : DLIList< int > list_min_depth;
727 [ # # ][ # # ]: 0 : DLIList< int > list_max_depth;
728 : :
729 : : // traverse through the list of volumes and find optimal depth
730 : : Body*volume;
731 : : int index;
732 : : int local_min_depth, local_max_depth;
733 [ # # ][ # # ]: 0 : for( index = 0; index < entity_list.size(); index++ )
734 : : {
735 [ # # ][ # # ]: 0 : volume = CAST_TO( entity_list.get_and_step(), Body );
736 [ # # ]: 0 : if( volume )
737 : : {
738 [ # # ][ # # ]: 0 : CubitOctreeGeneratorVolumes::find_optimal_min_and_max_depth( volume, local_min_depth, local_max_depth );
739 [ # # ]: 0 : list_min_depth.append( local_min_depth );
740 [ # # ]: 0 : list_max_depth.append( local_max_depth );
741 : : }
742 : : }
743 : :
744 : : // find resultant min_depth and max_depth
745 : : // for now let us take the floor of the average depth
746 : 0 : int avg_min_depth = 0;
747 : 0 : int avg_max_depth = 0;
748 [ # # ][ # # ]: 0 : for( index = 0; index < list_min_depth.size(); index++ )
749 : : {
750 [ # # ]: 0 : avg_min_depth += list_min_depth[index];
751 [ # # ]: 0 : avg_max_depth += list_max_depth[index];
752 : : }
753 [ # # ]: 0 : avg_min_depth /= list_min_depth.size();
754 [ # # ]: 0 : avg_max_depth /= list_max_depth.size();
755 : :
756 : : // assign min of initial value and avg depths as final answer
757 [ # # ]: 0 : min_depth = std::min( min_depth, avg_min_depth );
758 [ # # ][ # # ]: 0 : max_depth = std::min( max_depth, avg_max_depth );
759 : :
760 : 0 : }
761 : :
762 : 0 : void CubitOctreeGeneratorVolumes::reset_td_octree_ref_face_visit( const CubitBoolean type ){
763 : : int index, i;
764 : : Body *volume;
765 [ # # ]: 0 : DLIList<RefFace *> vol_ref_faces;
766 : :
767 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
768 [ # # ][ # # ]: 0 : volume = CAST_TO( entityList.get_and_step(), Body );
769 [ # # ]: 0 : vol_ref_faces.clean_out();
770 [ # # ]: 0 : volume->ref_faces( vol_ref_faces );
771 [ # # ][ # # ]: 0 : for( i = 0; i < vol_ref_faces.size(); i++ ){
772 [ # # ][ # # ]: 0 : TDOctreeRefFace::get_td( vol_ref_faces.get_and_step() )->set_visit( type );
[ # # ]
773 : : }
774 : : }
775 : :
776 [ # # ]: 0 : return;
777 : : }
778 : :
779 : :
780 : 0 : void CubitOctreeGeneratorVolumes::reset_td_octree_ref_edge_visit( const CubitBoolean type ){
781 : : int index, i;
782 : : Body *volume;
783 [ # # ]: 0 : DLIList<RefEdge *> vol_ref_edges;
784 : :
785 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
786 [ # # ][ # # ]: 0 : volume = CAST_TO( entityList.get_and_step(), Body );
787 [ # # ]: 0 : vol_ref_edges.clean_out();
788 [ # # ]: 0 : volume->ref_edges( vol_ref_edges );
789 [ # # ][ # # ]: 0 : for( i = 0; i < vol_ref_edges.size(); i++ ){
790 [ # # ][ # # ]: 0 : TDOctreeRefEdge::get_td( vol_ref_edges.get_and_step() )->set_visit( type );
[ # # ]
791 : : }
792 : : }
793 : :
794 [ # # ]: 0 : return;
795 : : }
796 : :
797 : 0 : CubitBoolean CubitOctreeGeneratorVolumes::build_td_mref_faces( void ){
798 [ # # ]: 0 : DLIList< RefFace *> vol_ref_faces;
799 : : RefFace *ptr_ref_face;
800 : : TDOctreeRefFace *td_mref_face;
801 : : DLIList<CubitFacet *> *facet_list;
802 : : DLIList<CubitFacetEdge *> *facet_edge_list;
803 : : DLIList<CubitPoint*> *point_list;
804 : : int i;
805 : : int index;
806 : : Body *volume;
807 : :
808 : 0 : CubitBoolean identified_engine = CUBIT_FALSE;
809 : 0 : CubitBoolean is_facet_geom = CUBIT_FALSE;
810 : :
811 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
812 [ # # ][ # # ]: 0 : volume = CAST_TO( entityList.get_and_step(), Body );
813 [ # # ]: 0 : vol_ref_faces.clean_out();
814 [ # # ]: 0 : volume->ref_faces( vol_ref_faces );
815 : 0 : identified_engine = CUBIT_FALSE;
816 [ # # ][ # # ]: 0 : for( i = 0; i < vol_ref_faces.size(); i++ ){
817 [ # # ]: 0 : ptr_ref_face = vol_ref_faces.get_and_step();
818 [ # # ][ # # ]: 0 : if( ptr_ref_face->marked() == CUBIT_FALSE ){
819 [ # # ]: 0 : if (identified_engine == CUBIT_FALSE)
820 : : {
821 [ # # ][ # # ]: 0 : if (ptr_ref_face->get_geometry_query_engine()->get_engine_version_string().find("Facet") != CubitString::npos)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
822 : : {
823 : 0 : is_facet_geom = CUBIT_TRUE;
824 : : }
825 : 0 : identified_engine = CUBIT_TRUE;
826 : : }
827 : :
828 : :
829 [ # # ]: 0 : ptr_ref_face->marked( CUBIT_TRUE );
830 : :
831 : : // Add TD for MRefFace
832 [ # # ]: 0 : TDOctreeRefFace::add_td(ptr_ref_face);
833 [ # # ][ # # ]: 0 : facet_list = new DLIList<CubitFacet *>;
834 [ # # ][ # # ]: 0 : facet_edge_list = new DLIList<CubitFacetEdge *>;
835 [ # # ][ # # ]: 0 : point_list = new DLIList<CubitPoint*>;
836 : :
837 : : //PRINT_DEBUG_157(" \n\nRef Face = %d \n ", ptr_ref_face->id());
838 : : //facet_list->clean_out();
839 : : //point_list->clean_out();
840 : : //facet_edge_list->clean_out();
841 : :
842 [ # # ]: 0 : if (is_facet_geom)
843 : : {
844 [ # # ]: 0 : DLIList<CubitFacet*> facets;
845 [ # # ][ # # ]: 0 : DLIList<CubitPoint*> points;
846 : :
847 [ # # ][ # # ]: 0 : FacetSurface *facet_surf_ptr = CAST_TO(ptr_ref_face->get_surface_ptr(),FacetSurface);
848 [ # # ]: 0 : if (facet_surf_ptr != NULL)
849 : : {
850 [ # # ]: 0 : facet_surf_ptr->get_my_facets(facets,points);
851 : : }
852 [ # # ][ # # ]: 0 : FacetDataUtil::copy_facets(facets,*facet_list,*point_list,*facet_edge_list);
853 : : /*PRINT_INFO("Grabbed %d facets from surface %d\n", facet_list->size(),ptr_ref_face);
854 : : PRINT_INFO("Grabbed %d facet edges from surface %d\n", facet_edge_list->size(),ptr_ref_face);
855 : : PRINT_INFO("Grabbed %d facet points from surface %d\n", point_list->size(),ptr_ref_face);*/
856 : : }
857 : : else
858 : : {
859 [ # # ]: 0 : GMem gmem;
860 : : //Surface* surf_ptr = ptr_ref_face->get_surface_ptr();
861 : : //surf_ptr->get_geometry_query_engine()->get_graphics(surf_ptr, &gmem);
862 : 0 : int angle = 15;
863 : 0 : float distance = 0;
864 : : //SVDrawTool::get_facet_tolerance(angle, distance);
865 : 0 : angle = static_cast<int>(ANG_FACET_EXTRACT[OCTREE_TIME_ACCURACY_LEVEL]);
866 : : //PRINT_INFO("\n Facets extracted with angle %d and distance %f \n", angle, distance );
867 [ # # ]: 0 : ptr_ref_face->get_graphics( gmem, angle, distance, 0 );
868 [ # # ]: 0 : ChollaEngine::get_facets(gmem, *facet_list, *point_list);
869 : :
870 : : /*
871 : : // delete point_list;
872 : : // point_list = new DLIList<CubitPoint*>;
873 : : point_list->clean_out();
874 : :
875 : : DLIList<DLIList<CubitFacet *> *> shell_list;
876 : :
877 : : CubitBoolean dummy2;
878 : : double tol = SKL_EPSILON;
879 : : DLIList <CubitQuadFacet *> qfacet_list;
880 : : FacetDataUtil::split_into_shells(*facet_list, qfacet_list,shell_list, dummy2);
881 : :
882 : : FacetDataUtil::stitch_facets(shell_list,tol,dummy2,false);
883 : : //int nv,ne;
884 : : //DLIList<CubitPoint*> un;
885 : :
886 : : //FacetDataUtil::merge_coincident_vertices(shell_list,tol,nv,ne,un);
887 : : facet_list = shell_list.get();
888 : : PRINT_INFO("skl: number of shells = %d\n", shell_list.size());
889 : :
890 : : FacetDataUtil::get_edges( *facet_list, *facet_edge_list );
891 : : FacetDataUtil::get_points(*facet_list,*point_list);
892 : : SVDrawTool::draw_facets(*facet_list,CUBIT_GREEN_INDEX);
893 : : */
894 : :
895 [ # # ][ # # ]: 0 : FacetDataUtil::get_edges( *facet_list, *facet_edge_list );
896 : : /*
897 : : // checks for problems with gfx facets
898 : : // debug use only
899 : : int v;
900 : : for (v=0; v < facet_edge_list->size(); ++v)
901 : : {
902 : : CubitFacetEdge *temp_edge = facet_edge_list->get_and_step();
903 : : if (temp_edge->num_adj_facets() != 2 && temp_edge->num_adj_facets() != 1)
904 : : {
905 : : PRINT_INFO("Skeleton sizing function, copying gfx facets: edge has %d adj facets!\n", temp_edge->num_adj_facets());
906 : : SVDrawTool::draw_vector(temp_edge->point(0)->coordinates(), temp_edge->point(1)->coordinates(), CUBIT_RED_INDEX);
907 : : SVDrawTool::mouse_xforms();
908 : : }
909 : : }
910 : : int w;
911 : : for (v=0; v < facet_list->size(); ++v)
912 : : {
913 : : CubitFacet *first = (*facet_list)[v];
914 : : for (w=v+1; w < facet_list->size(); ++w)
915 : : {
916 : : CubitFacet *second = (*facet_list)[w];
917 : : if (first == second)
918 : : {
919 : : PRINT_INFO("Skeleton Sizing Function: gfx facet list contains a duplicate, ids are %d,%d\n", first->id(), second->id());
920 : : }
921 : : }
922 : : }
923 : : */
924 : : }
925 : :
926 [ # # ]: 0 : td_mref_face = TDOctreeRefFace::get_td(ptr_ref_face);
927 : :
928 : : /*
929 : : td_mref_face->set_ptr_cubit_facet_list(facet_list);
930 : : td_mref_face->set_ptr_cubit_facet_edge_list(facet_edge_list);
931 : : td_mref_face->set_ptr_cubit_point_list(point_list);
932 : : */
933 [ # # ][ # # ]: 0 : if( td_mref_face->get_ptr_cubit_facet_list() )
934 : : {
935 [ # # ][ # # ]: 0 : delete td_mref_face->get_ptr_cubit_facet_list();
[ # # ]
936 [ # # ]: 0 : td_mref_face->set_ptr_cubit_facet_list(facet_list);
937 : :
938 : : }
939 : : else
940 : : {
941 [ # # ]: 0 : td_mref_face->set_ptr_cubit_facet_list(facet_list);
942 : : }
943 : :
944 [ # # ][ # # ]: 0 : if( td_mref_face->get_ptr_cubit_facet_edge_list() )
945 : : {
946 [ # # ][ # # ]: 0 : delete td_mref_face->get_ptr_cubit_facet_edge_list();
[ # # ]
947 [ # # ]: 0 : td_mref_face->set_ptr_cubit_facet_edge_list(facet_edge_list);
948 : :
949 : : }
950 : : else
951 : : {
952 [ # # ]: 0 : td_mref_face->set_ptr_cubit_facet_edge_list(facet_edge_list);
953 : : }
954 : :
955 [ # # ][ # # ]: 0 : if( td_mref_face->get_ptr_cubit_point_list() )
956 : : {
957 [ # # ][ # # ]: 0 : delete td_mref_face->get_ptr_cubit_point_list();
[ # # ]
958 [ # # ]: 0 : td_mref_face->set_ptr_cubit_point_list(point_list);
959 : : }
960 : : else
961 : : {
962 [ # # ]: 0 : td_mref_face->set_ptr_cubit_point_list(point_list);
963 : : }
964 : :
965 : : // check for bad facets and disable 2dmat if necessary
966 [ # # ]: 0 : td_mref_face->check_valid_facets(CUBIT_TRUE);
967 : : //if (!create_2dmat) {td_mref_face->set_create_2dmat(CUBIT_FALSE);}
968 : : }
969 : : }
970 : : }
971 : :
972 : : // Reset the marker of faces
973 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
974 [ # # ][ # # ]: 0 : volume = CAST_TO( entityList.get_and_step(), Body );
975 [ # # ]: 0 : vol_ref_faces.clean_out();
976 [ # # ]: 0 : volume->ref_faces( vol_ref_faces );
977 [ # # ][ # # ]: 0 : for( i = 0; i < vol_ref_faces.size(); i++ ){
978 [ # # ][ # # ]: 0 : vol_ref_faces.get_and_step()->marked( CUBIT_FALSE );
979 : : }
980 : : }
981 : :
982 [ # # ]: 0 : return CUBIT_TRUE;
983 : : }
984 : :
985 : :
986 : 0 : CubitBoolean CubitOctreeGeneratorVolumes::build_td_mref_edges( void )
987 : : {
988 [ # # ]: 0 : DLIList< RefEdge *> vol_mref_edges;
989 : : RefEdge *ptr_mref_edge;
990 : : TDOctreeRefEdge *td_mref_edge;
991 : : int i;
992 : : int index;
993 : : Body *volume;
994 : :
995 : : // Reset the marker of edges
996 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
997 [ # # ][ # # ]: 0 : volume = CAST_TO( entityList.get_and_step(), Body );
998 [ # # ]: 0 : vol_mref_edges.clean_out();
999 [ # # ]: 0 : volume->ref_edges( vol_mref_edges );
1000 [ # # ][ # # ]: 0 : for( i = 0; i < vol_mref_edges.size(); i++ ){
1001 [ # # ]: 0 : ptr_mref_edge = vol_mref_edges.get_and_step();
1002 [ # # ][ # # ]: 0 : if( ptr_mref_edge->marked() == CUBIT_FALSE ){
1003 [ # # ]: 0 : ptr_mref_edge->marked( CUBIT_TRUE );
1004 : : // Add TD for MRefEdge
1005 [ # # ]: 0 : TDOctreeRefEdge::add_td(ptr_mref_edge);
1006 [ # # ]: 0 : td_mref_edge = TDOctreeRefEdge::get_td(ptr_mref_edge);
1007 [ # # ]: 0 : td_mref_edge->generate_gpoint_list(ANG_FACET_EXTRACT[OCTREE_TIME_ACCURACY_LEVEL] * OCTREE_TOLERANCE_FOR_CURVE_DECIMATION_FACTOR );
1008 : : }
1009 : : }
1010 : : }
1011 : :
1012 : : // Reset the marker of edges
1013 [ # # ][ # # ]: 0 : for( index = 0; index < entityList.size(); index++ ){
1014 [ # # ][ # # ]: 0 : volume = CAST_TO( entityList.get_and_step(), Body );
1015 [ # # ]: 0 : vol_mref_edges.clean_out();
1016 [ # # ]: 0 : volume->ref_edges( vol_mref_edges );
1017 [ # # ][ # # ]: 0 : for( i = 0; i < vol_mref_edges.size();i++ ){
1018 [ # # ][ # # ]: 0 : vol_mref_edges.get_and_step()->marked( CUBIT_FALSE );
1019 : : }
1020 : : }
1021 : :
1022 [ # # ]: 0 : return CUBIT_TRUE;
1023 : : }
1024 : :
1025 : :
1026 : :
1027 : 0 : void CubitOctreeGeneratorVolumes::color_octreenode_via_grassfire( DLIList<CubitOctreeNode *> &queue_for_mat_generation )
1028 : : {
1029 : :
1030 [ # # ]: 0 : PriorityQueue<CubitOctreeNode *> heap( CubitOctreeNode::compare_function);
1031 : : CubitOctreeNode *ptr_grid_node;
1032 : :
1033 : : // ************************* For Testing Purpose ***************************
1034 : : // int i;
1035 : : //for( i = 0; i < queue_for_mat_generation.size(); i++ ){
1036 : : //ptr_grid_node = queue_for_mat_generation.get_and_step();
1037 : :
1038 : : //PRINT_DEBUG_157(" boundary node distance = %f \n",ptr_grid_node->get_distance() );
1039 : : //PRINT_DEBUG_157(" boundary node visit = %d \n",ptr_grid_node->get_visit() );
1040 : :
1041 : : //PRINT_DEBUG_157(" mat initial grid = %f %f %f %f \n", ptr_grid_node->get_distance(), ptr_grid_node->get_coord().x(), ptr_grid_node->get_coord().y(), ptr_grid_node->get_coord().z() );
1042 : : //GfxDebug::draw_point( ptr_grid_node->get_coord().x(), ptr_grid_node->get_coord().y(), ptr_grid_node->get_coord().z(), CUBIT_YELLOW_INDEX );
1043 : : //ptr_grid_node->display( this, DISTANCE );
1044 : : //}
1045 : : // ************************* For Testing Purpose ***************************
1046 : :
1047 : : //PRINT_DEBUG_157(" Num of initial points for mat generation = %d \n", queue_for_mat_generation.size() );
1048 : :
1049 : : // Initialize the heap
1050 [ # # ][ # # ]: 0 : while( queue_for_mat_generation.size() > 0 ){
1051 [ # # ][ # # ]: 0 : heap.push( queue_for_mat_generation.pop() );
1052 : : }
1053 : :
1054 : : // distance by default is CUBIT_DBL_MAX, and the white boundary nodes's distance is set to -1.
1055 : : //PRINT_DEBUG_157(" heap size = %d", heap.size() );
1056 : : //int draw_count = 1;
1057 : :
1058 : :
1059 [ # # ][ # # ]: 0 : while( heap.size() > 0 ){
1060 : : // PRINT_INFO( " manhattan in process before opo() = %d \n",queue.size() );
1061 [ # # ]: 0 : ptr_grid_node = heap.top();
1062 [ # # ]: 0 : heap.pop();
1063 : :
1064 : :
1065 [ # # ]: 0 : ptr_grid_node->find_distance_at_adj_node( &heap );
1066 : :
1067 : : // PRINT_INFO( " manhattan in process after NumberAdjNode() = %d \n", queue.size() );
1068 [ # # ]: 0 : }
1069 : :
1070 : 0 : }
1071 : :
1072 : 0 : CubitStatus CubitOctreeGeneratorVolumes::generate_full_octree( void )
1073 : : {
1074 : : // all the functions of skeleton sizing function are called here
1075 [ # # ]: 0 : CpuTimer octgentime;
1076 : : double time_octree_generation;
1077 : :
1078 : : //ProgressTool *progressToolPtr = AppUtil::instance()->progress_tool();
1079 : : //assert(progressToolPtr != NULL );
1080 : : //char title[42]="Octree Generation in Progress ...";
1081 : : //progressToolPtr->start(0, 100, title, NULL, CUBIT_TRUE, CUBIT_TRUE);
1082 : :
1083 : : //PRINT_DEBUG_157("\nENTER: Octree Generation \n");
1084 : :
1085 : :
1086 [ # # ]: 0 : CpuTimer preproctime;
1087 : :
1088 [ # # ]: 0 : build_td_mref_faces();
1089 [ # # ]: 0 : build_td_mref_edges();
1090 : :
1091 : :
1092 : : // this is used to store size and also used in 3D MAT generation
1093 [ # # ]: 0 : CpuTimer gen_latt;
1094 : :
1095 : 0 : int min_depth = MIN_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL];
1096 : 0 : int max_depth = MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL];
1097 [ # # ]: 0 : CubitOctreeGeneratorVolumes::find_optimal_min_and_max_octree_depths( entityList, min_depth, max_depth );
1098 [ # # ][ # # ]: 0 : get_octree_lattice()->set_max_depth(std::min( get_octree_lattice()->get_max_depth(), max_depth) );
[ # # ][ # # ]
[ # # ]
1099 [ # # ][ # # ]: 0 : get_octree_lattice()->set_min_depth(std::max( get_octree_lattice()->get_min_depth(), min_depth) );
[ # # ][ # # ]
[ # # ]
1100 : : //PRINT_INFO("\nOctree min_depth = %d, max_depth = %d\n", min_depth, max_depth);
1101 : :
1102 [ # # ]: 0 : generate_lattice();
1103 : : //PRINT_INFO("profiling: time in generate_lattice: %f\n", gen_latt.cpu_secs());
1104 : :
1105 : : // PRINT_DEBUG_157("AFTER: octree lattice generation\n");
1106 : :
1107 : :
1108 : : //PRINT_DEBUG_157("BEFORE smooth transiton number of nodes = %d\n",gridNodeVector.size() );
1109 [ # # ]: 0 : CpuTimer time_to_balance;
1110 [ # # ][ # # ]: 0 : get_octree_lattice()->establish_smooth_transition_of_cells( max_depth ); //OCTREE_MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL] );
1111 : : // PRINT_INFO("profiling: time to balance octree: %f\n", time_to_balance.cpu_secs());
1112 : :
1113 : : // PRINT_DEBUG_157("AFTER smooth transiton \n" );
1114 : :
1115 : : // Finds the intersection between the facets and the octree
1116 [ # # ]: 0 : CpuTimer intersection_time;
1117 [ # # ]: 0 : DLIList<CubitOctreeNode *> queue_for_3Dmat_generation;
1118 [ # # ]: 0 : find_intersection_between_octree_and_facets( queue_for_3Dmat_generation );
1119 : : //PRINT_INFO("profiling: intersection time: %f\n", intersection_time.cpu_secs());
1120 : :
1121 : : //PRINT_DEBUG_157("AFTER intersection between facets and octree \n" );
1122 : :
1123 : :
1124 : : //PRINT_DEBUG_157("\nDONE: Octree Generation \n" );
1125 : : //progressToolPtr->percent(1.0);
1126 : :
1127 [ # # ][ # # ]: 0 : if( AppUtil::instance()->interrupt() ){
[ # # ]
1128 : : //CubitBoolean interruptStatus;
1129 [ # # ][ # # ]: 0 : PRINT_WARNING("\n Killed octree generation...\n");
[ # # ][ # # ]
1130 : : //interruptStatus = CUBIT_TRUE;
1131 : : //progressToolPtr->end();
1132 : 0 : return CUBIT_FAILURE;
1133 : : }
1134 : :
1135 [ # # ]: 0 : color_octreenode_via_grassfire( queue_for_3Dmat_generation );
1136 : :
1137 [ # # ]: 0 : color_lattice_cell();
1138 : :
1139 : :
1140 [ # # ]: 0 : time_octree_generation = octgentime.cpu_secs();
1141 : :
1142 : :
1143 : :
1144 : :
1145 [ # # ][ # # ]: 0 : PRINT_INFO("Total time for octree generation: %f\n", time_octree_generation);
[ # # ][ # # ]
1146 : :
1147 [ # # ]: 0 : return CUBIT_SUCCESS;
1148 [ + - ][ + - ]: 6540 : }
1149 : :
1150 : :
1151 : : // OPTIMIZE: priorityqueue -> dlist/queue
1152 : : // EOF
1153 : :
|