cgma
|
00001 #include "CubitOctreeGeneratorVolumes.hpp" 00002 #include "CubitOctree.hpp" 00003 #include "RefFace.hpp" 00004 #include "TDOctreeRefFace.hpp" 00005 #include "CubitFacet.hpp" 00006 #include "CubitOctreeNode.hpp" 00007 #include "CubitOctreeCell.hpp" 00008 #include "CubitPoint.hpp" 00009 #include "CubitFacetEdge.hpp" 00010 #include "RefEdge.hpp" 00011 #include "CpuTimer.hpp" 00012 #include "FacetDataUtil.hpp" 00013 #include "RefEdge.hpp" 00014 #include "TDOctreeRefEdge.hpp" 00015 #include "GeometryQueryEngine.hpp" 00016 #include "FacetSurface.hpp" 00017 #include "CubitOctreeConstants.hpp" 00018 #include "ChollaEngine.hpp" 00019 #include "ProgressTool.hpp" 00020 #include "AppUtil.hpp" 00021 #include "OctreeFacetPointData.hpp" 00022 #include "Body.hpp" 00023 00024 // Constructor for CubitOctree 00025 CubitOctreeGeneratorVolumes::CubitOctreeGeneratorVolumes( DLIList<RefEntity*> &entity_list) 00026 :CubitOctreeGenerator( ), entityList(entity_list){ 00027 00028 entityList = entity_list; 00029 cubitOctree = new CubitOctree( this); 00030 } 00031 00032 void CubitOctreeGeneratorVolumes::get_bounding_box( CubitVector &min, CubitVector &max ){ 00033 RefEntity *volume; 00034 int index; 00035 CubitBox bound_box; 00036 00037 min.x( CUBIT_DBL_MAX ); 00038 min.y( CUBIT_DBL_MAX ); 00039 min.z( CUBIT_DBL_MAX ); 00040 00041 max.x( -CUBIT_DBL_MAX ); 00042 max.y( -CUBIT_DBL_MAX ); 00043 max.z( -CUBIT_DBL_MAX ); 00044 00045 for( index = 0; index < entityList.size(); index++ ){ 00046 volume = entityList.get_and_step(); 00047 00048 bound_box = volume->bounding_box(); 00049 00050 if( bound_box.minimum().x() < min.x() ) 00051 min.x( bound_box.minimum().x()); 00052 if( bound_box.minimum().y() < min.y() ) 00053 min.y( bound_box.minimum().y()); 00054 if( bound_box.minimum().z() < min.z() ) 00055 min.z( bound_box.minimum().z()); 00056 00057 if( bound_box.maximum().x() > max.x() ) 00058 max.x( bound_box.maximum().x()); 00059 if( bound_box.maximum().y() > max.y() ) 00060 max.y( bound_box.maximum().y()); 00061 if( bound_box.maximum().z() > max.z() ) 00062 max.z( bound_box.maximum().z()); 00063 } 00064 00065 } 00066 00067 // CubitOctree is generated based on facets of the FACE. 00068 // Therefore small features are captured. 00069 // First the CubitOctree grid is generated without any intersection 00070 // calculation. The nodes are linked using 6 pointers to the adjacent nodes 00071 // The cells are stored using CubitOctree data structure. As the boundary points are need 00072 // for MAT generation, intersection between the CubitOctree edges and facets are computed and 00073 // normals are also stored. 00074 CubitBoolean CubitOctreeGeneratorVolumes::generate_lattice( void ){ 00075 00076 // initialize CubitOctree root 00077 cubitOctree->initialize_octree_generation(); 00078 00079 // Builds the tree fully till the level min_depthibcbtghs.lib 00080 cubitOctree->build_octree_till_min_depth( cubitOctree->get_root() ); 00081 00082 // Builds the tree based on facets' points, centroid, dimension ... 00083 // Note that the points on the curves belong to more than one face 00084 // Therefore the CubitOctree is subdivided till the maxDepth 00085 build_octree_till_skl_max_depth_based_on_facets(); 00086 00087 // Adjacents cells can be found by visiting the adjacent cells of every node 00088 // Cells are split till the difference in the levels of adjacent cells is 1. 00089 // At every node find the maximum and minimum cell. Split the maximum cell if 00090 // it deffers by 2 or more in depth. 00091 00092 00093 //PRINT_DEBUG_157(" Number of nodes = %d", gridNodeVector.size() ); 00094 return CUBIT_TRUE; 00095 } 00096 00097 00098 CubitBoolean CubitOctreeGeneratorVolumes::build_octree_till_skl_max_depth_based_on_facets( void ){ 00099 00100 DLIList< RefFace *> vol_ref_faces; 00101 DLIList<CubitFacet *> *facet_list; 00102 DLIList<CubitPoint*> *point_list; 00103 DLIList<CubitFacetEdge *> *ptr_facet_edge_list; 00104 DLIList<OctreeFacetPointData *> facet_point_data_list; //, vfacet_point_data_list; 00105 DLIList<CubitOctreeCell*> refine_cell_list; 00106 00107 // DLIList<CubitFacet*> global_facet_list; 00108 00109 00110 int index; 00111 int i, j, k, l; 00112 CubitPoint *ptr_point; 00113 CubitFacet *ptr_facet, *ptr_adj_facet0, *ptr_adj_facet1; 00114 CubitFacetEdge *ptr_edge; 00115 RefFace *ptr_ref_face; 00116 OctreeFacetPointData *facet_point_data; 00117 CubitVector normal0, normal1; 00118 double internal_angle; 00119 Body *volume; 00120 TDOctreeRefFace *td_ref_face; 00121 00122 // PR-CubitOctree has the property that the cell size depends on the density of the facet points 00123 // Higher the density the finer will be the facet cell size. 00124 // Step 1: The CubitOctree is built only till MaxDepth based on facet information 00125 // 1. Small features that have smaller curve length are detected using facet density 00126 // 2. Surface/Curve curvature are detected based on di-hedral angle between the adj facets. 00127 // Also the aspect ratio of facets are used because it is found that when the surface has curvature on only one directio 00128 // the facet aspect ratio will be very high. 00129 for( index = 0; index < entityList.size(); index++ ){ 00130 volume = CAST_TO( entityList.get_and_step(), Body ); 00131 vol_ref_faces.clean_out(); 00132 volume->ref_faces( vol_ref_faces ); 00133 vol_ref_faces.reset(); 00134 00135 // get volume facets and insert points from those facets 00136 00137 for( i = 0; i < vol_ref_faces.size(); i++ ){ 00138 ptr_ref_face = vol_ref_faces.get_and_step(); 00139 td_ref_face = TDOctreeRefFace::get_td( ptr_ref_face ); 00140 00141 if( td_ref_face->get_visit() == CUBIT_FALSE ){ 00142 td_ref_face->set_visit( CUBIT_TRUE ); 00143 00144 // grab facets here if stitching 00145 00146 // add to global list for facet point insertion 00147 00148 /*int num_parents = CAST_TO(ptr_ref_face,RefFace)->num_parent_ref_entities(); 00149 if (num_parents == 1) 00150 { 00151 global_facet_list += *facet_list; 00152 } 00153 00154 else 00155 {*/ 00156 00157 // Generated OctreeFacetPointData based on facet vertices 00158 point_list = td_ref_face->get_ptr_cubit_point_list(); 00159 for( j = 0; j < point_list->size(); j++ ){ 00160 ptr_point = point_list->get_and_step(); 00161 facet_point_data = new OctreeFacetPointData( ptr_point->coordinates(), ptr_point ); 00162 facet_point_data_list.push( facet_point_data ); 00163 } 00164 // point_list.clean_out(); 00165 00166 //} 00167 00168 00169 // Generate OctreeFacetPointData based on facet centroid 00170 00171 facet_list = td_ref_face->get_ptr_cubit_facet_list(); 00172 for( j = 0; j < facet_list->size(); j++ ){ 00173 ptr_facet = facet_list->get_and_step(); 00174 facet_point_data = new OctreeFacetPointData( ptr_facet->center(), ptr_facet ); 00175 facet_point_data_list.push( facet_point_data ); 00176 } 00177 00178 /* Generate OctreeFacetPointData based on aspect ratio of facet 00179 for( j = 0; j < facet_list->size(); j++ ){ 00180 ptr_facet = facet_list->get_and_step(); 00181 OctreeFacetPointData::generate_facet_point_data_at_slender_facet( ptr_facet, facet_point_data_list ); 00182 } 00183 */ 00184 00185 // Generate OctreeFacetPointData based on surface curvature 00186 ptr_facet_edge_list = td_ref_face->get_ptr_cubit_facet_edge_list(); 00187 for( j = 0; j < ptr_facet_edge_list->size(); j++ ){ 00188 ptr_edge = ptr_facet_edge_list->get_and_step(); 00189 if( ptr_edge->num_adj_facets() == 2 ){ 00190 // mark adjacent facets 00191 ptr_adj_facet0 = ptr_edge->adj_facet(0); 00192 ptr_adj_facet1 = ptr_edge->adj_facet(1); 00193 normal0 = ptr_adj_facet0->normal(); 00194 normal1 = ptr_adj_facet1->normal(); 00195 00196 if (normal0.length_squared() > 0.0 && normal1.length_squared() > 0.0) 00197 { 00198 internal_angle = normal0.interior_angle(normal1); 00199 } 00200 else 00201 { 00202 internal_angle = 0.0; 00203 } 00204 //PRINT_INFO("%f ", internal_angle ); 00205 if( internal_angle > ANGLE_BETWEEN_FACETS_NORMAL_FOR_OCTREE_BASED_ON_SURF_CURVATURE_FACTOR * ANG_FACET_EXTRACT[OCTREE_TIME_ACCURACY_LEVEL] ){ 00206 OctreeFacetPointData::generate_facet_point_data_based_on_curvature( ptr_edge, /*internal_angle,*/ facet_point_data_list ); 00207 } 00208 } 00209 } 00210 00211 // now check for pairs of adjacents with dihedral angles along their shared edge 00212 // the CubitOctree should be refined in these regions so we have enough grid nodes to generate 3dmat points 00213 // disabling for now :( because there is a problem in FacetDataUtil's facet stitching code 00214 if (0) 00215 { 00216 DLIList<DLIList<RefEdge*> > edge_loops; 00217 ptr_ref_face->ref_edge_loops(edge_loops); 00218 for (i=0; i < edge_loops.size(); ++i) 00219 { 00220 DLIList<RefEdge*>& edge_loop = edge_loops.get_and_step(); 00221 for (j=0; j < edge_loop.size(); ++j) 00222 { 00223 DLIList<RefEntity*> parents; 00224 RefEdge *edge = edge_loop.get_and_step(); 00225 TDOctreeRefEdge *td_ref_edge = TDOctreeRefEdge::get_td(edge); 00226 00227 if( td_ref_edge->get_visit() == CUBIT_FALSE ) 00228 { 00229 td_ref_edge->set_visit( CUBIT_TRUE ); 00230 edge->get_parent_ref_entities(parents); 00231 00232 // check Refface's for bad facets in case it hasn't been done 00233 // already 00234 for (k=0; k < parents.size(); ++k) 00235 { 00236 RefFace *parent = CAST_TO(parents.get_and_step(), RefFace); 00237 if (parent == NULL) {continue;} 00238 TDOctreeRefFace *td_parent = TDOctreeRefFace::get_td(parent); 00239 if (td_parent == NULL) {continue;} 00240 if (td_parent->get_create_2dmat()) 00241 { 00242 td_parent->check_valid_facets(CUBIT_TRUE); 00243 } 00244 } 00245 00246 for (k=0; k < parents.size(); ++k) 00247 { 00248 for (l=k+1; l < parents.size(); ++l) 00249 { 00250 // SVDrawTool::clear_non_retained(); 00251 DLIList<CubitFacet*> crease_facets; 00252 DLIList<CubitFacetEdge*> crease_edges; 00253 cubitOctree->find_cells_based_on_surface_angle(refine_cell_list, crease_edges, crease_facets, 00254 CAST_TO(parents[k],RefFace), CAST_TO(parents[l],RefFace), 00255 CUBIT_FALSE, 2.0*CUBIT_PI/3.0); 00256 // will need to store crease_edges and facets 00257 00258 // SVDrawTool::mouse_xforms(); 00259 } 00260 00261 } 00262 } 00263 00264 } 00265 00266 } 00267 } 00268 00269 } 00270 } 00271 } 00272 00273 00274 /* 00275 DLIList<DLIList<CubitFacet*>*> shells; 00276 shells.append(&global_facet_list); 00277 CubitBoolean dummy; 00278 FacetDataUtil::stitch_facets(shells, OCTREE_EPSILON, dummy); 00279 if (shells.size() == 1) 00280 { 00281 FacetDataUtil::get_points(global_facet_list, point_list); 00282 for( j = 0; j < point_list.size(); j++ ) 00283 { 00284 ptr_point = point_list.get_and_step(); 00285 facet_point_data = new OctreeFacetPointData( ptr_point->coordinates(), ptr_point ); 00286 facet_point_data_list.push( facet_point_data ); 00287 } 00288 } 00289 else 00290 { 00291 PRINT_INFO("Stitch resulted in multiple shells!!!!!!!!!!\n"); 00292 00293 } 00294 */ 00295 00296 00297 00298 // Reset the visit to CUBIT_FALSE 00299 reset_td_octree_ref_face_visit( CUBIT_FALSE ); 00300 reset_td_octree_ref_edge_visit( CUBIT_FALSE ); 00301 00302 facet_point_data_list.reset(); 00303 for( i = 0; i < facet_point_data_list.size(); i++ ){ 00304 facet_point_data = facet_point_data_list.get_and_step(); 00305 //SkeletonDebug::draw_point( facet_point_data->coordinates(), CUBIT_MAGENTA_INDEX ); 00306 cubitOctree->subdivide_octree_based_on_facet_point( facet_point_data, cubitOctree->get_max_depth() ); 00307 } 00308 00309 // refine the cells on edges with large enough dihedral angles 00310 // disabling for now 00311 //int target_depth = skeletonProxy->get_source_entity_max_depth(); 00312 //cubitOctree->refine_cells_to_target_depth(refine_cell_list, target_depth); 00313 00314 return CUBIT_TRUE; 00315 } 00316 00317 00318 00319 CubitBoolean CubitOctreeGeneratorVolumes::find_intersection_between_octree_and_facets( DLIList<CubitOctreeNode *> &queue_for_mat_generation ){ 00320 DLIList< RefFace *> vol_ref_faces; 00321 RefFace *ptr_ref_face; 00322 TDOctreeRefFace *td_ref_face; 00323 DLIList< CubitFacet *> *facet_list; 00324 CubitFacet *ptr_facet; 00325 DLIList<CubitOctreeCell *> CubitOctree_cell_list; 00326 DLIList< CubitOctreeNode *> CubitOctree_grid_node_list; 00327 DLIList<CubitOctreeNode*> all_grid_nodes; 00328 00329 //CubitVector facet_normal; 00330 //DLIList< CubitPoint *> *point_list; 00331 int i, j, k; 00332 int index; 00333 Body *volume; 00334 00335 // CpuTimer total_idata_time; 00336 00337 for( index = 0; index < entityList.size(); index++ ){ 00338 volume = CAST_TO( entityList.get_and_back(), Body ); 00339 vol_ref_faces.clean_out(); 00340 volume->ref_faces( vol_ref_faces ); 00341 //vol_ref_faces.reset(); 00342 //int cell_count = 0; 00343 //CubitBox facet_bbox; 00344 //PRINT_INFO(" \nRef Volume = %d ", volume->id()); 00345 00346 for( i = 0; i < vol_ref_faces.size(); i++ ){ 00347 ptr_ref_face = vol_ref_faces.get_and_step(); 00348 td_ref_face = TDOctreeRefFace::get_td( ptr_ref_face ); 00349 00350 if(td_ref_face->get_visit() == CUBIT_FALSE){ 00351 td_ref_face->set_visit( CUBIT_TRUE ); 00352 00353 //PRINT_INFO(" \nRef Face = %d ", ptr_ref_face->id()); 00354 00355 RefFace *current_ref_face = CAST_TO(ptr_ref_face, RefFace); 00356 /*if (current_ref_face->sense(CAST_TO(volume,Body)) == CUBIT_REVERSED) 00357 { 00358 temp_facet_normal *= -1.0; 00359 }*/ 00360 00361 // PRINT_INFO("Number of parent ref Entities for face %d: %d\n", current_ref_face->id(), current_ref_face->num_parent_ref_entities()); 00362 00363 // get the sense so we know which way to propagate the 3DMAT front inwards 00364 CubitSense ref_face_sense = CUBIT_FORWARD; //current_ref_face->sense(volume); 00365 00366 // in the case of a merged face, figure out if two parent vols share the same 00367 // sizing function. If so, propagate in both directions 00368 if (current_ref_face->is_merged() /*&& current_ref_face->num_parent_ref_entities() == 2*/) 00369 { 00370 DLIList<RefEntity*> parent_ents; 00371 current_ref_face->get_parent_ref_entities(parent_ents); 00372 if (parent_ents.size() == 2) 00373 { 00374 Body *other_parent_vol = CAST_TO(parent_ents.get_and_step(),Body); 00375 if (other_parent_vol == volume) {other_parent_vol = CAST_TO(parent_ents.get(),Body);} 00376 if (other_parent_vol != NULL) 00377 { 00378 00379 // if the other parent volume has the same sizing function, 00380 // pass CUBIT_UNKNOWN to CubitOctreeCell::set_color_and_idatas 00381 // It will then set up the front normals to propagate in both directions 00382 ref_face_sense = CUBIT_UNKNOWN; 00383 00384 } 00385 } 00386 } 00387 00388 facet_list = td_ref_face->get_ptr_cubit_facet_list(); 00389 //PRINT_INFO("Surface %d: facets: %d\n", ptr_ref_face->id(), facet_list->size()); 00390 00391 for( j = 0; j < facet_list->size(); j++ ){ 00392 ptr_facet = facet_list->get_and_step(); 00393 00394 //CubitVector temp_facet_normal = ptr_facet->normal(); 00395 00396 00397 //SVDrawTool::draw_vector(ptr_facet->center(), ptr_facet->center()+temp_facet_normal, (i%8)+1); 00398 00399 00400 //#ifndef NDEBUG 00401 // SkeletonDebug::draw_facet( ptr_facet, CUBIT_BLUE_INDEX ); 00402 //#endif 00403 //facet_bbox = ptr_facet->bounding_box(); 00404 //draw_box( facet_bbox ); 00405 //facet_normal = ptr_facet->normal(); 00406 //if( ptr_facet->is_backwards() ){ 00407 // facet_normal = facet_normal * -1; 00408 //} 00409 //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 ); 00410 CubitOctree_cell_list.clean_out(); 00411 CubitOctree_grid_node_list.clean_out(); 00412 //PRINT_INFO(" Before find_octree_cells_contatined \n"); 00413 cubitOctree->find_octree_cells_contained_inside_bbox( ptr_facet, CubitOctree_cell_list ); 00414 //PRINT_INFO(" Before mark_positive_and_negative_grid_nodes \n"); 00415 cubitOctree->mark_positive_and_negative_octree_grid_nodes( ptr_facet, CubitOctree_cell_list, CubitOctree_grid_node_list ); 00416 //PRINT_INFO(" Before find_intersection_between_grid_edge_facet \n"); 00417 00418 if ( OCTREE_DEFAULT_INTERSECTION_METHOD[OCTREE_TIME_ACCURACY_LEVEL] == SAT_INTERSECT){ 00419 //PRINT_INFO("%d cells in bbox\n", CubitOctree_cell_list.size()); 00420 00421 for (k=0; k < CubitOctree_cell_list.size(); ++k) 00422 { 00423 CubitOctreeCell *current_cell = CubitOctree_cell_list.get_and_step(); 00424 // if (current_cell->get_mark() == CUBIT_FALSE) {continue;} 00425 //current_cell->set_mark(CUBIT_FALSE); 00426 00427 if (current_cell->does_facet_intersect_octreecell(ptr_facet)) 00428 { 00429 /* double corners[3]; 00430 double half_edge_length = current_cell->get_dimension()/2.0; 00431 CubitVector center = current_cell->get_center(); 00432 center.get_xyz(corners); 00433 float box[6] = {corners[0]-half_edge_length, corners[1]-half_edge_length, corners[2]-half_edge_length, 00434 corners[0]+half_edge_length, corners[1]+half_edge_length, corners[2]+half_edge_length}; 00435 SVDrawTool::draw_cube(box, CUBIT_GREEN_INDEX, SVDrawTool::WIRE);*/ 00436 00437 current_cell->set_color_and_intersection_datas(ptr_facet, ptr_ref_face, 00438 #ifdef USE_octree_BGMESH 00439 cubitOctree->get_greycelllist(), 00440 #endif 00441 ref_face_sense); 00442 00443 //cubitOctree->get_greycelllist()->append(current_cell); 00444 } 00445 /*if (ref_face_sense) { 00446 // SVDrawTool::mouse_xforms(); 00447 }*/ 00448 00449 } 00450 00451 for( k = 0; k < CubitOctree_grid_node_list.size(); k++ ) 00452 { 00453 CubitOctreeNode *ptr_grid_node = CubitOctree_grid_node_list.get_and_step(); 00454 if (ptr_grid_node->get_visit() == CUBIT_FALSE) 00455 { 00456 all_grid_nodes.append(ptr_grid_node); 00457 ptr_grid_node->set_visit(CUBIT_TRUE); 00458 } 00459 00460 ptr_grid_node->set_mark( CUBIT_FALSE ); 00461 if( ptr_grid_node->get_halfspace_direction() == OCTREE_POSITIVE ) 00462 { 00463 ptr_grid_node->set_halfspace_direction( OCTREE_NEGATIVE ); 00464 } 00465 } 00466 } 00467 00468 if (OCTREE_DEFAULT_INTERSECTION_METHOD[OCTREE_TIME_ACCURACY_LEVEL] == GRID_EDGE_INT) 00469 { 00470 cubitOctree->find_intersection_between_grid_edges_and_facet( CUBIT_OCTREE_VOLUME, ptr_ref_face, ptr_facet, CubitOctree_grid_node_list ); 00471 } 00472 00473 00474 00475 } 00476 00477 } 00478 } 00479 } 00480 00481 // Reset the visit to CUBIT_FALSE 00482 reset_td_octree_ref_face_visit( CUBIT_FALSE ); 00483 //SVDrawTool::mouse_xforms(); 00484 // PRINT_INFO("profiling: time for intersecting and making idatas: %f\n", total_idata_time.cpu_secs()); 00485 00486 if (OCTREE_DEFAULT_INTERSECTION_METHOD[OCTREE_TIME_ACCURACY_LEVEL] == SAT_INTERSECT) 00487 { 00488 //CpuTimer front_color_time; 00489 for (i=0; i < all_grid_nodes.size(); ++i) 00490 { 00491 CubitOctreeNode *grid_node = all_grid_nodes.get_and_step(); 00492 DLIList<OctreeIntersectionData*> *idata_list = grid_node->get_idata_list(); 00493 //idata_list->uniquify_unordered(); 00494 00495 00496 if (idata_list->size() > 0) 00497 { 00498 DLIList<OctreeIntersectionData*> closest_ones; 00499 //OctreeIntersectionData *closest = NULL; 00500 double min_list_dist = CUBIT_DBL_MAX; 00501 for (k=0; k < idata_list->size(); ++k) 00502 { 00503 if (idata_list->get()->is_merged()) {idata_list->step();} 00504 00505 double temp_dist = idata_list->get()->get_length(); 00506 if (temp_dist < min_list_dist - OCTREE_EPSILON) 00507 { 00508 closest_ones.clean_out(); 00509 // closest = idata_list->get(); 00510 closest_ones.append(idata_list->get()); 00511 min_list_dist = temp_dist; 00512 } 00513 else if (fabs(temp_dist - min_list_dist) <= OCTREE_EPSILON) 00514 { 00515 closest_ones.append(idata_list->get()); 00516 } 00517 idata_list->step(); 00518 } 00519 00520 bool white = false; 00521 00522 for (j=0; j < closest_ones.size(); ++j) 00523 { 00524 if (closest_ones.get_and_step()->get_halfspace()) 00525 { 00526 white = true; 00527 break; 00528 } 00529 } 00530 00531 //closest = closest_ones.get(); 00532 // if (!white) {SVDrawTool::draw_vector(grid_node->get_coord(), closest->get_int_point(), CUBIT_RED_INDEX);} 00533 00534 // this is the closest facet encountered by the current grid node so far 00535 // update color of node based on this facet 00536 if (white) 00537 { 00538 grid_node->set_color(CUBIT_WHITE_INDEX); 00539 cubitOctree->get_whitenodelist()->append(grid_node); 00540 00541 } 00542 else if (!white) 00543 { 00544 // if ( (grid_node->get_coord()-closest->get_facet_ptr()->center()) % (closest->get_normal()) < 0) 00545 // { 00546 // PRINT_INFO("Adding a white node to queue !!!!!!!!!!!!\n"); 00547 // } 00548 00549 // uncomment this 00550 // for (j=0; j < grid_node->get_idata_list()->size(); ++j) 00551 // { 00552 // OctreeIntersectionData *idata = grid_node->get_idata_list()->get_and_step(); 00553 // double proj_length = fabs((grid_node->get_coord() - idata->get_int_point())%idata->get_facet_normal()); 00554 // idata->set_length(proj_length); 00555 // } 00556 00557 // SVDrawTool::draw_vector(grid_node->get_coord(), closest->get_int_point(), CUBIT_RED_INDEX); 00558 00559 grid_node->set_color(CUBIT_BLACK_INDEX); 00560 queue_for_mat_generation.append(grid_node); 00561 } 00562 else 00563 { 00564 //PRINT_INFO("Couldn't pick halfspace to color node!\n"); 00565 } 00566 } 00567 grid_node->set_visit(CUBIT_FALSE); 00568 } 00569 00570 for (i=0; i < cubitOctree->get_whitenodelist()->size(); ++i) 00571 { 00572 CubitOctreeNode *ptr_grid_node = cubitOctree->get_whitenodelist()->get_and_step(); 00573 DLIList<OctreeIntersectionData*> *idata_list = ptr_grid_node->get_idata_list(); 00574 for (k=0; k < idata_list->size(); ++k) 00575 { 00576 OctreeIntersectionData *idata = idata_list->get_and_step(); 00577 if (idata != NULL) {delete idata;} 00578 } 00579 idata_list->clean_out(); 00580 CubitOctreeNode *adj_node = NULL; 00581 for (k=0; k < 6; ++k) 00582 { 00583 adj_node = ptr_grid_node->get_adj_node(k); 00584 if (adj_node != NULL) 00585 { 00586 if (adj_node->get_color() != CUBIT_BLACK_INDEX && adj_node->get_color() != CUBIT_WHITE_INDEX) 00587 { 00588 adj_node->set_color(CUBIT_YELLOW_INDEX); 00589 } 00590 //SVDrawTool::draw_point(adj_node->get_coord(), adj_node->get_color()); 00591 } 00592 } 00593 } 00594 // PRINT_INFO("profiling: time to color front nodes: %f\n", front_color_time.cpu_secs()); 00595 00596 } 00597 00598 00599 00600 00601 00602 // PRINT_INFO("Testing: Cell Count = %d", cell_count ); 00603 if (OCTREE_DEFAULT_INTERSECTION_METHOD[OCTREE_TIME_ACCURACY_LEVEL] == SAT_INTERSECT) 00604 { 00605 00606 // CpuTimer front_init; 00607 00608 for( i = 0; i < queue_for_mat_generation.size(); i++ ){ 00609 queue_for_mat_generation.get_and_step()->SAT_find_face_distance_average_normal( /*skeletonSizingFunction, queue_for_mat_generation*/ ); 00610 } 00611 //PRINT_INFO("profiling: time to init front: %f\n", front_init.cpu_secs()); 00612 00613 } 00614 00615 00616 return CUBIT_TRUE; 00617 } 00618 00619 00620 00621 void CubitOctreeGeneratorVolumes::find_optimal_min_and_max_depth( RefEntity*entity, int &local_min_depth, int &local_max_depth ) 00622 { 00623 Body *volume = dynamic_cast<Body *> (entity); 00624 if( NULL == volume) 00625 return; 00626 00627 CubitBox bbox = volume->bounding_box(); 00628 00629 // calculate min_depth by comparing min_range with max_range in log scale 00630 double max_range = std::max( std::max( bbox.x_range(), bbox.y_range()), bbox.z_range() ); 00631 double min_range = std::min( std::min( bbox.x_range(), bbox.y_range()), bbox.z_range() ); 00632 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 00633 00634 if( local_min_depth < MIN_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL] ) 00635 local_min_depth = MIN_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL]; 00636 if( local_min_depth > MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL] ) 00637 local_min_depth = MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL]; 00638 00639 // calculate max_depth by comparing the min curve length with max_range in log scale 00640 DLIList< RefEdge *> list_edges; 00641 volume->ref_edges( list_edges ); 00642 00643 int i; 00644 RefEdge *ptr_edge; 00645 double min_edge_len = DBL_MAX; 00646 double len; 00647 CubitVector start_pt, mid_pt, end_pt; 00648 for( i = 0; i < list_edges.size(); i++ ) 00649 { 00650 ptr_edge = list_edges.get_and_step(); 00651 //len = ptr_edge->length_from_u( ptr_edge->start_param(), ptr_edge->end_param() ); 00652 start_pt = ptr_edge->start_coordinates(); 00653 end_pt = ptr_edge->end_coordinates(); 00654 ptr_edge->mid_point(mid_pt); 00655 len = (mid_pt - start_pt).length() + (end_pt - mid_pt).length(); 00656 if( len < min_edge_len ) 00657 { 00658 min_edge_len = len; 00659 } 00660 } 00661 local_max_depth = (int)(log( max_range / min_edge_len) / log(2.0) ) + 1; 00662 00663 /* 00664 // calculate max_depth by comparing the min mesh size with max_range in log scale 00665 double min_mesh_size = max_range; 00666 double mesh_size; 00667 for( i = 0; i < list_edges.size(); i++ ) 00668 { 00669 ptr_edge = list_edges.get_and_step(); 00670 00671 mesh_size = max_range; 00672 MeshToolProxy* mesh_tool_ptr = MeshToolProxy::mesh_tool(ptr_edge); 00673 SizeIntervalType hardness; 00674 double tmp_size = mesh_tool_ptr->requested_interval_size(hardness); 00675 if (hardness > CALCULATED) 00676 { 00677 mesh_size = tmp_size/ 2.0; 00678 } 00679 if( mesh_size < min_mesh_size ) 00680 { 00681 min_mesh_size = mesh_size; 00682 } 00683 } 00684 local_max_depth = std::max( local_max_depth, (int)(log( max_range / min_mesh_size) / log(2.0) ) + 1 ); 00685 */ 00686 /* 00687 // calculate max_depth by comparing the min mesh size with max_range in log scale 00688 DLIList< RefFace *> list_faces; 00689 volume->ref_faces( list_faces ); 00690 min_mesh_size = max_range; 00691 RefFace *ptr_face; 00692 for( i = 0; i < list_faces.size(); i++ ) 00693 { 00694 ptr_face = list_faces.get_and_step(); 00695 00696 mesh_size = max_range; 00697 MeshToolProxy* mesh_tool_ptr = MeshToolProxy::mesh_tool(ptr_face); 00698 SizeIntervalType hardness; 00699 double tmp_size = mesh_tool_ptr->requested_interval_size(hardness); 00700 if (hardness > CALCULATED) 00701 { 00702 mesh_size = tmp_size/2.0; 00703 } 00704 if( mesh_size < min_mesh_size ) 00705 { 00706 min_mesh_size = mesh_size; 00707 } 00708 } 00709 local_max_depth = std::max( local_max_depth, (int)(log( max_range / min_mesh_size) / log(2.0) ) + 1 ); 00710 */ 00711 00712 if( local_max_depth > MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL] ) 00713 local_max_depth = MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL]; 00714 00715 // make sure local_max_depth is atleast one depth higher than local_min_depth 00716 if( local_max_depth <= local_min_depth ) 00717 local_max_depth = local_min_depth + 1; 00718 00719 00720 00721 } 00722 00723 // finds the optimal min and max depths of CubitOctree 00724 void CubitOctreeGeneratorVolumes::find_optimal_min_and_max_octree_depths( DLIList< RefEntity *> &entity_list, int &min_depth, int &max_depth ) 00725 { 00726 DLIList< int > list_min_depth; 00727 DLIList< int > list_max_depth; 00728 00729 // traverse through the list of volumes and find optimal depth 00730 Body*volume; 00731 int index; 00732 int local_min_depth, local_max_depth; 00733 for( index = 0; index < entity_list.size(); index++ ) 00734 { 00735 volume = CAST_TO( entity_list.get_and_step(), Body ); 00736 if( volume ) 00737 { 00738 CubitOctreeGeneratorVolumes::find_optimal_min_and_max_depth( volume, local_min_depth, local_max_depth ); 00739 list_min_depth.append( local_min_depth ); 00740 list_max_depth.append( local_max_depth ); 00741 } 00742 } 00743 00744 // find resultant min_depth and max_depth 00745 // for now let us take the floor of the average depth 00746 int avg_min_depth = 0; 00747 int avg_max_depth = 0; 00748 for( index = 0; index < list_min_depth.size(); index++ ) 00749 { 00750 avg_min_depth += list_min_depth[index]; 00751 avg_max_depth += list_max_depth[index]; 00752 } 00753 avg_min_depth /= list_min_depth.size(); 00754 avg_max_depth /= list_max_depth.size(); 00755 00756 // assign min of initial value and avg depths as final answer 00757 min_depth = std::min( min_depth, avg_min_depth ); 00758 max_depth = std::min( max_depth, avg_max_depth ); 00759 00760 } 00761 00762 void CubitOctreeGeneratorVolumes::reset_td_octree_ref_face_visit( const CubitBoolean type ){ 00763 int index, i; 00764 Body *volume; 00765 DLIList<RefFace *> vol_ref_faces; 00766 00767 for( index = 0; index < entityList.size(); index++ ){ 00768 volume = CAST_TO( entityList.get_and_step(), Body ); 00769 vol_ref_faces.clean_out(); 00770 volume->ref_faces( vol_ref_faces ); 00771 for( i = 0; i < vol_ref_faces.size(); i++ ){ 00772 TDOctreeRefFace::get_td( vol_ref_faces.get_and_step() )->set_visit( type ); 00773 } 00774 } 00775 00776 return; 00777 } 00778 00779 00780 void CubitOctreeGeneratorVolumes::reset_td_octree_ref_edge_visit( const CubitBoolean type ){ 00781 int index, i; 00782 Body *volume; 00783 DLIList<RefEdge *> vol_ref_edges; 00784 00785 for( index = 0; index < entityList.size(); index++ ){ 00786 volume = CAST_TO( entityList.get_and_step(), Body ); 00787 vol_ref_edges.clean_out(); 00788 volume->ref_edges( vol_ref_edges ); 00789 for( i = 0; i < vol_ref_edges.size(); i++ ){ 00790 TDOctreeRefEdge::get_td( vol_ref_edges.get_and_step() )->set_visit( type ); 00791 } 00792 } 00793 00794 return; 00795 } 00796 00797 CubitBoolean CubitOctreeGeneratorVolumes::build_td_mref_faces( void ){ 00798 DLIList< RefFace *> vol_ref_faces; 00799 RefFace *ptr_ref_face; 00800 TDOctreeRefFace *td_mref_face; 00801 DLIList<CubitFacet *> *facet_list; 00802 DLIList<CubitFacetEdge *> *facet_edge_list; 00803 DLIList<CubitPoint*> *point_list; 00804 int i; 00805 int index; 00806 Body *volume; 00807 00808 CubitBoolean identified_engine = CUBIT_FALSE; 00809 CubitBoolean is_facet_geom = CUBIT_FALSE; 00810 00811 for( index = 0; index < entityList.size(); index++ ){ 00812 volume = CAST_TO( entityList.get_and_step(), Body ); 00813 vol_ref_faces.clean_out(); 00814 volume->ref_faces( vol_ref_faces ); 00815 identified_engine = CUBIT_FALSE; 00816 for( i = 0; i < vol_ref_faces.size(); i++ ){ 00817 ptr_ref_face = vol_ref_faces.get_and_step(); 00818 if( ptr_ref_face->marked() == CUBIT_FALSE ){ 00819 if (identified_engine == CUBIT_FALSE) 00820 { 00821 if (ptr_ref_face->get_geometry_query_engine()->get_engine_version_string().find("Facet") != CubitString::npos) 00822 { 00823 is_facet_geom = CUBIT_TRUE; 00824 } 00825 identified_engine = CUBIT_TRUE; 00826 } 00827 00828 00829 ptr_ref_face->marked( CUBIT_TRUE ); 00830 00831 // Add TD for MRefFace 00832 TDOctreeRefFace::add_td(ptr_ref_face); 00833 facet_list = new DLIList<CubitFacet *>; 00834 facet_edge_list = new DLIList<CubitFacetEdge *>; 00835 point_list = new DLIList<CubitPoint*>; 00836 00837 //PRINT_DEBUG_157(" \n\nRef Face = %d \n ", ptr_ref_face->id()); 00838 //facet_list->clean_out(); 00839 //point_list->clean_out(); 00840 //facet_edge_list->clean_out(); 00841 00842 if (is_facet_geom) 00843 { 00844 DLIList<CubitFacet*> facets; 00845 DLIList<CubitPoint*> points; 00846 00847 FacetSurface *facet_surf_ptr = CAST_TO(ptr_ref_face->get_surface_ptr(),FacetSurface); 00848 if (facet_surf_ptr != NULL) 00849 { 00850 facet_surf_ptr->get_my_facets(facets,points); 00851 } 00852 FacetDataUtil::copy_facets(facets,*facet_list,*point_list,*facet_edge_list); 00853 /*PRINT_INFO("Grabbed %d facets from surface %d\n", facet_list->size(),ptr_ref_face); 00854 PRINT_INFO("Grabbed %d facet edges from surface %d\n", facet_edge_list->size(),ptr_ref_face); 00855 PRINT_INFO("Grabbed %d facet points from surface %d\n", point_list->size(),ptr_ref_face);*/ 00856 } 00857 else 00858 { 00859 GMem gmem; 00860 //Surface* surf_ptr = ptr_ref_face->get_surface_ptr(); 00861 //surf_ptr->get_geometry_query_engine()->get_graphics(surf_ptr, &gmem); 00862 int angle = 15; 00863 float distance = 0; 00864 //SVDrawTool::get_facet_tolerance(angle, distance); 00865 angle = static_cast<int>(ANG_FACET_EXTRACT[OCTREE_TIME_ACCURACY_LEVEL]); 00866 //PRINT_INFO("\n Facets extracted with angle %d and distance %f \n", angle, distance ); 00867 ptr_ref_face->get_graphics( gmem, angle, distance, 0 ); 00868 ChollaEngine::get_facets(gmem, *facet_list, *point_list); 00869 00870 /* 00871 // delete point_list; 00872 // point_list = new DLIList<CubitPoint*>; 00873 point_list->clean_out(); 00874 00875 DLIList<DLIList<CubitFacet *> *> shell_list; 00876 00877 CubitBoolean dummy2; 00878 double tol = SKL_EPSILON; 00879 DLIList <CubitQuadFacet *> qfacet_list; 00880 FacetDataUtil::split_into_shells(*facet_list, qfacet_list,shell_list, dummy2); 00881 00882 FacetDataUtil::stitch_facets(shell_list,tol,dummy2,false); 00883 //int nv,ne; 00884 //DLIList<CubitPoint*> un; 00885 00886 //FacetDataUtil::merge_coincident_vertices(shell_list,tol,nv,ne,un); 00887 facet_list = shell_list.get(); 00888 PRINT_INFO("skl: number of shells = %d\n", shell_list.size()); 00889 00890 FacetDataUtil::get_edges( *facet_list, *facet_edge_list ); 00891 FacetDataUtil::get_points(*facet_list,*point_list); 00892 SVDrawTool::draw_facets(*facet_list,CUBIT_GREEN_INDEX); 00893 */ 00894 00895 FacetDataUtil::get_edges( *facet_list, *facet_edge_list ); 00896 /* 00897 // checks for problems with gfx facets 00898 // debug use only 00899 int v; 00900 for (v=0; v < facet_edge_list->size(); ++v) 00901 { 00902 CubitFacetEdge *temp_edge = facet_edge_list->get_and_step(); 00903 if (temp_edge->num_adj_facets() != 2 && temp_edge->num_adj_facets() != 1) 00904 { 00905 PRINT_INFO("Skeleton sizing function, copying gfx facets: edge has %d adj facets!\n", temp_edge->num_adj_facets()); 00906 SVDrawTool::draw_vector(temp_edge->point(0)->coordinates(), temp_edge->point(1)->coordinates(), CUBIT_RED_INDEX); 00907 SVDrawTool::mouse_xforms(); 00908 } 00909 } 00910 int w; 00911 for (v=0; v < facet_list->size(); ++v) 00912 { 00913 CubitFacet *first = (*facet_list)[v]; 00914 for (w=v+1; w < facet_list->size(); ++w) 00915 { 00916 CubitFacet *second = (*facet_list)[w]; 00917 if (first == second) 00918 { 00919 PRINT_INFO("Skeleton Sizing Function: gfx facet list contains a duplicate, ids are %d,%d\n", first->id(), second->id()); 00920 } 00921 } 00922 } 00923 */ 00924 } 00925 00926 td_mref_face = TDOctreeRefFace::get_td(ptr_ref_face); 00927 00928 /* 00929 td_mref_face->set_ptr_cubit_facet_list(facet_list); 00930 td_mref_face->set_ptr_cubit_facet_edge_list(facet_edge_list); 00931 td_mref_face->set_ptr_cubit_point_list(point_list); 00932 */ 00933 if( td_mref_face->get_ptr_cubit_facet_list() ) 00934 { 00935 delete td_mref_face->get_ptr_cubit_facet_list(); 00936 td_mref_face->set_ptr_cubit_facet_list(facet_list); 00937 00938 } 00939 else 00940 { 00941 td_mref_face->set_ptr_cubit_facet_list(facet_list); 00942 } 00943 00944 if( td_mref_face->get_ptr_cubit_facet_edge_list() ) 00945 { 00946 delete td_mref_face->get_ptr_cubit_facet_edge_list(); 00947 td_mref_face->set_ptr_cubit_facet_edge_list(facet_edge_list); 00948 00949 } 00950 else 00951 { 00952 td_mref_face->set_ptr_cubit_facet_edge_list(facet_edge_list); 00953 } 00954 00955 if( td_mref_face->get_ptr_cubit_point_list() ) 00956 { 00957 delete td_mref_face->get_ptr_cubit_point_list(); 00958 td_mref_face->set_ptr_cubit_point_list(point_list); 00959 } 00960 else 00961 { 00962 td_mref_face->set_ptr_cubit_point_list(point_list); 00963 } 00964 00965 // check for bad facets and disable 2dmat if necessary 00966 td_mref_face->check_valid_facets(CUBIT_TRUE); 00967 //if (!create_2dmat) {td_mref_face->set_create_2dmat(CUBIT_FALSE);} 00968 } 00969 } 00970 } 00971 00972 // Reset the marker of faces 00973 for( index = 0; index < entityList.size(); index++ ){ 00974 volume = CAST_TO( entityList.get_and_step(), Body ); 00975 vol_ref_faces.clean_out(); 00976 volume->ref_faces( vol_ref_faces ); 00977 for( i = 0; i < vol_ref_faces.size(); i++ ){ 00978 vol_ref_faces.get_and_step()->marked( CUBIT_FALSE ); 00979 } 00980 } 00981 00982 return CUBIT_TRUE; 00983 } 00984 00985 00986 CubitBoolean CubitOctreeGeneratorVolumes::build_td_mref_edges( void ) 00987 { 00988 DLIList< RefEdge *> vol_mref_edges; 00989 RefEdge *ptr_mref_edge; 00990 TDOctreeRefEdge *td_mref_edge; 00991 int i; 00992 int index; 00993 Body *volume; 00994 00995 // Reset the marker of edges 00996 for( index = 0; index < entityList.size(); index++ ){ 00997 volume = CAST_TO( entityList.get_and_step(), Body ); 00998 vol_mref_edges.clean_out(); 00999 volume->ref_edges( vol_mref_edges ); 01000 for( i = 0; i < vol_mref_edges.size(); i++ ){ 01001 ptr_mref_edge = vol_mref_edges.get_and_step(); 01002 if( ptr_mref_edge->marked() == CUBIT_FALSE ){ 01003 ptr_mref_edge->marked( CUBIT_TRUE ); 01004 // Add TD for MRefEdge 01005 TDOctreeRefEdge::add_td(ptr_mref_edge); 01006 td_mref_edge = TDOctreeRefEdge::get_td(ptr_mref_edge); 01007 td_mref_edge->generate_gpoint_list(ANG_FACET_EXTRACT[OCTREE_TIME_ACCURACY_LEVEL] * OCTREE_TOLERANCE_FOR_CURVE_DECIMATION_FACTOR ); 01008 } 01009 } 01010 } 01011 01012 // Reset the marker of edges 01013 for( index = 0; index < entityList.size(); index++ ){ 01014 volume = CAST_TO( entityList.get_and_step(), Body ); 01015 vol_mref_edges.clean_out(); 01016 volume->ref_edges( vol_mref_edges ); 01017 for( i = 0; i < vol_mref_edges.size();i++ ){ 01018 vol_mref_edges.get_and_step()->marked( CUBIT_FALSE ); 01019 } 01020 } 01021 01022 return CUBIT_TRUE; 01023 } 01024 01025 01026 01027 void CubitOctreeGeneratorVolumes::color_octreenode_via_grassfire( DLIList<CubitOctreeNode *> &queue_for_mat_generation ) 01028 { 01029 01030 PriorityQueue<CubitOctreeNode *> heap( CubitOctreeNode::compare_function); 01031 CubitOctreeNode *ptr_grid_node; 01032 01033 // ************************* For Testing Purpose *************************** 01034 // int i; 01035 //for( i = 0; i < queue_for_mat_generation.size(); i++ ){ 01036 //ptr_grid_node = queue_for_mat_generation.get_and_step(); 01037 01038 //PRINT_DEBUG_157(" boundary node distance = %f \n",ptr_grid_node->get_distance() ); 01039 //PRINT_DEBUG_157(" boundary node visit = %d \n",ptr_grid_node->get_visit() ); 01040 01041 //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() ); 01042 //GfxDebug::draw_point( ptr_grid_node->get_coord().x(), ptr_grid_node->get_coord().y(), ptr_grid_node->get_coord().z(), CUBIT_YELLOW_INDEX ); 01043 //ptr_grid_node->display( this, DISTANCE ); 01044 //} 01045 // ************************* For Testing Purpose *************************** 01046 01047 //PRINT_DEBUG_157(" Num of initial points for mat generation = %d \n", queue_for_mat_generation.size() ); 01048 01049 // Initialize the heap 01050 while( queue_for_mat_generation.size() > 0 ){ 01051 heap.push( queue_for_mat_generation.pop() ); 01052 } 01053 01054 // distance by default is CUBIT_DBL_MAX, and the white boundary nodes's distance is set to -1. 01055 //PRINT_DEBUG_157(" heap size = %d", heap.size() ); 01056 //int draw_count = 1; 01057 01058 01059 while( heap.size() > 0 ){ 01060 // PRINT_INFO( " manhattan in process before opo() = %d \n",queue.size() ); 01061 ptr_grid_node = heap.top(); 01062 heap.pop(); 01063 01064 01065 ptr_grid_node->find_distance_at_adj_node( &heap ); 01066 01067 // PRINT_INFO( " manhattan in process after NumberAdjNode() = %d \n", queue.size() ); 01068 } 01069 01070 } 01071 01072 CubitStatus CubitOctreeGeneratorVolumes::generate_full_octree( void ) 01073 { 01074 // all the functions of skeleton sizing function are called here 01075 CpuTimer octgentime; 01076 double time_octree_generation; 01077 01078 //ProgressTool *progressToolPtr = AppUtil::instance()->progress_tool(); 01079 //assert(progressToolPtr != NULL ); 01080 //char title[42]="Octree Generation in Progress ..."; 01081 //progressToolPtr->start(0, 100, title, NULL, CUBIT_TRUE, CUBIT_TRUE); 01082 01083 //PRINT_DEBUG_157("\nENTER: Octree Generation \n"); 01084 01085 01086 CpuTimer preproctime; 01087 01088 build_td_mref_faces(); 01089 build_td_mref_edges(); 01090 01091 01092 // this is used to store size and also used in 3D MAT generation 01093 CpuTimer gen_latt; 01094 01095 int min_depth = MIN_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL]; 01096 int max_depth = MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL]; 01097 CubitOctreeGeneratorVolumes::find_optimal_min_and_max_octree_depths( entityList, min_depth, max_depth ); 01098 get_octree_lattice()->set_max_depth(std::min( get_octree_lattice()->get_max_depth(), max_depth) ); 01099 get_octree_lattice()->set_min_depth(std::max( get_octree_lattice()->get_min_depth(), min_depth) ); 01100 //PRINT_INFO("\nOctree min_depth = %d, max_depth = %d\n", min_depth, max_depth); 01101 01102 generate_lattice(); 01103 //PRINT_INFO("profiling: time in generate_lattice: %f\n", gen_latt.cpu_secs()); 01104 01105 // PRINT_DEBUG_157("AFTER: octree lattice generation\n"); 01106 01107 01108 //PRINT_DEBUG_157("BEFORE smooth transiton number of nodes = %d\n",gridNodeVector.size() ); 01109 CpuTimer time_to_balance; 01110 get_octree_lattice()->establish_smooth_transition_of_cells( max_depth ); //OCTREE_MAX_DEPTH_OCTREE[OCTREE_TIME_ACCURACY_LEVEL] ); 01111 // PRINT_INFO("profiling: time to balance octree: %f\n", time_to_balance.cpu_secs()); 01112 01113 // PRINT_DEBUG_157("AFTER smooth transiton \n" ); 01114 01115 // Finds the intersection between the facets and the octree 01116 CpuTimer intersection_time; 01117 DLIList<CubitOctreeNode *> queue_for_3Dmat_generation; 01118 find_intersection_between_octree_and_facets( queue_for_3Dmat_generation ); 01119 //PRINT_INFO("profiling: intersection time: %f\n", intersection_time.cpu_secs()); 01120 01121 //PRINT_DEBUG_157("AFTER intersection between facets and octree \n" ); 01122 01123 01124 //PRINT_DEBUG_157("\nDONE: Octree Generation \n" ); 01125 //progressToolPtr->percent(1.0); 01126 01127 if( AppUtil::instance()->interrupt() ){ 01128 //CubitBoolean interruptStatus; 01129 PRINT_WARNING("\n Killed octree generation...\n"); 01130 //interruptStatus = CUBIT_TRUE; 01131 //progressToolPtr->end(); 01132 return CUBIT_FAILURE; 01133 } 01134 01135 color_octreenode_via_grassfire( queue_for_3Dmat_generation ); 01136 01137 color_lattice_cell(); 01138 01139 01140 time_octree_generation = octgentime.cpu_secs(); 01141 01142 01143 01144 01145 PRINT_INFO("Total time for octree generation: %f\n", time_octree_generation); 01146 01147 return CUBIT_SUCCESS; 01148 } 01149 01150 01151 // OPTIMIZE: priorityqueue -> dlist/queue 01152 // EOF 01153