cgma
|
00001 //------------------------------------------------------------------------- 00002 // Filename : FacetorTool.cpp 00003 // 00004 // Purpose : 2D Delaunay mesher, template that can use both mesh and geom entities, not yet tested with geometric 00005 // entities 00006 // 00007 // Creator : Christopher Hynes 00008 // 00009 // Creation Date : 5/31/2002 00010 // 00011 // Owner : Steve Owen 00012 //------------------------------------------------------------------------- 00013 00014 #ifdef INLINE_TEMPLATES 00015 #define MY_INLINE inline 00016 #else 00017 #define MY_INLINE 00018 #endif 00019 00020 #include "FacetorTool.hpp" 00021 #include "FacetorUtil.hpp" 00022 #include "TDDelaunay.hpp" 00023 #include "BoundaryConstrainTool.hpp" 00024 #include "CubitPoint.hpp" 00025 #include "CubitPointData.hpp" 00026 #include "CubitFacet.hpp" 00027 #include "CubitFacetData.hpp" 00028 #include "FacetEvalTool.hpp" 00029 #include "ParamTool.hpp" 00030 #include "CubitMessage.hpp" 00031 00032 #define DETERM(p1,q1,p2,q2,p3,q3)\ 00033 ((q3)*((p2)-(p1)) + (q2)*((p1)-(p3)) + (q1)*((p3)-(p2))) 00034 #define SQR(x) ((x) * (x)) 00035 #define FT_INSIDE_TOL 1.0e-6 00036 #define QUALITY_ANGLE 0.361283155162 /* 20.7 degrees */ 00037 #define ALPHA 0.70228615 00038 00039 //------------------------------------------------------------------------- 00040 // Function: FacetorTool 00041 // Description: constructor 00042 // Author: chynes 00043 // Date: 6/5/2002 00044 //------------------------------------------------------------------------- 00045 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00046 FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>:: 00047 FacetorTool( SURF *ref_face_ptr, 00048 DLIList<NODE *> &bounding_nodes, 00049 NODE **boundary_edge_start_nodes, 00050 NODE **boundary_edge_end_nodes, 00051 int num_boundary_edges, 00052 SIZEFUNC *sizing_function, 00053 ParamTool *p_tool ) 00054 { 00055 //update private variables 00056 pTool = p_tool; 00057 refFacePtr = ref_face_ptr; 00058 boundingNodes = &bounding_nodes; 00059 boundaryEdgeStartNodes = boundary_edge_start_nodes; 00060 boundaryEdgeEndNodes = boundary_edge_end_nodes; 00061 numBoundaryEdges = num_boundary_edges; 00062 sizingFunction = sizing_function; 00063 00064 curVisitFlag = INT_MIN+1; 00065 boxNodes[0] = boxNodes[1] = boxNodes[2] = boxNodes[3] = NULL; 00066 } 00067 00068 00069 //------------------------------------------------------------------------- 00070 // Function: ~FacetorTool 00071 // Description: destructor 00072 // Author: chynes 00073 // Date: 5/31/2002 00074 //------------------------------------------------------------------------- 00075 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00076 FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::~FacetorTool() 00077 { 00078 numBoundaryEdges = 0; 00079 } 00080 00081 00082 //------------------------------------------------------------------------- 00083 // Function: mesh_surf 00084 // Description: mesh the surface 00085 // Author: chynes 00086 // Date: 5/31/2002 00087 //------------------------------------------------------------------------- 00088 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00089 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::mesh_surf(DLIList<TRI *> &facet_list) 00090 { 00091 CubitStatus ret_value = CUBIT_SUCCESS; 00092 00093 // update private variables 00094 facetList = &facet_list; 00095 00096 // create two initial bounding triangles 00097 00098 if (ret_value == CUBIT_SUCCESS) 00099 { 00100 ret_value = init_box(); 00101 } 00102 00103 // insert the boundary nodes 00104 00105 if (ret_value == CUBIT_SUCCESS) 00106 { 00107 //PRINT_INFO("Inserting boundary nodes \n"); 00108 ret_value = insert_nodes( boundingNodes ); 00109 } 00110 00111 // constrain the boundary 00112 00113 if (ret_value == CUBIT_SUCCESS) 00114 { 00115 //PRINT_INFO("Constraining the mesh to the boundary\n"); 00116 ret_value = constrain_boundary(); 00117 } 00118 00119 // delete the triangles on the outside of the boundary 00120 00121 if (ret_value == CUBIT_SUCCESS) 00122 { 00123 //PRINT_INFO("Deleting the exterior entities\n"); 00124 ret_value = delete_exterior(); 00125 } 00126 00127 // insert the hards 00128 00129 // insert interior points 00130 00131 if (ret_value == CUBIT_SUCCESS) { 00132 //PRINT_INFO("Refining the interior mesh\n"); 00133 ret_value = refine_interior(*facetList); 00134 } 00135 00136 // clean up 00137 //PRINT_INFO("Cleaning up some data\n"); 00138 clean_up_data(); 00139 00140 00141 return ret_value; 00142 } 00143 00144 //------------------------------------------------------------------------- 00145 // Function: mesh_surfwoIP 00146 // Description: mesh the surface w/o interior point refinement 00147 // Author: chynes 00148 // Date: 6/20/2002 00149 //------------------------------------------------------------------------- 00150 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00151 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::mesh_surfwoIP(DLIList<TRI *> &facet_list) 00152 { 00153 CubitStatus ret_value = CUBIT_SUCCESS; 00154 00155 //update private variables 00156 facetList = &facet_list; 00157 00158 // create two initial bounding triangles 00159 00160 if (ret_value == CUBIT_SUCCESS) 00161 { 00162 ret_value = init_box(); 00163 } 00164 00165 // insert the boundary nodes 00166 00167 if (ret_value == CUBIT_SUCCESS) 00168 { 00169 ret_value = insert_nodes( boundingNodes ); 00170 } 00171 00172 // constrain the boundary 00173 00174 if (ret_value == CUBIT_SUCCESS) 00175 { 00176 ret_value = constrain_boundary(); 00177 } 00178 00179 // delete the triangles on the outside of the boundary 00180 00181 if (ret_value == CUBIT_SUCCESS) 00182 { 00183 ret_value = delete_exterior(); 00184 } 00185 00186 // insert the hard points 00187 00188 // clean up 00189 00190 clean_up_data(); 00191 00192 return ret_value; 00193 } 00194 00195 //------------------------------------------------------------------------- 00196 // Function: mesh_surfwoIPBC 00197 // Description: mesh the surface w/o interior point refinement 00198 // Author: chynes 00199 // Date: 6/20/2002 00200 //------------------------------------------------------------------------- 00201 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00202 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::mesh_surfwoIPBC(DLIList<TRI *> &facet_list) 00203 { 00204 CubitStatus ret_value = CUBIT_SUCCESS; 00205 00206 // update private variables 00207 00208 facetList = &facet_list; 00209 00210 // create two initial bounding triangles 00211 00212 if (ret_value == CUBIT_SUCCESS) 00213 { 00214 ret_value = init_box(); 00215 } 00216 00217 // insert the boundary nodes 00218 00219 if (ret_value == CUBIT_SUCCESS) 00220 { 00221 ret_value = insert_nodes( boundingNodes ); 00222 } 00223 00224 // delete the triangles on the outside of the boundary 00225 00226 if (ret_value == CUBIT_SUCCESS){ 00227 ret_value = delete_exterior(); 00228 } 00229 00230 // insert the hard points 00231 00232 // clean up 00233 00234 clean_up_data(); 00235 00236 return ret_value; 00237 } 00238 00239 //------------------------------------------------------------------------- 00240 // Function: init_box 00241 // Description: create two initial bounding triangles 00242 // Author: chynes 00243 // Date: 5/31/2002 00244 //------------------------------------------------------------------------- 00245 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00246 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::init_box(void) 00247 { 00248 // find the bounding box 00249 00250 int ii; 00251 CubitVector min_box, max_box; 00252 min_box.x( CUBIT_DBL_MAX );min_box.y( CUBIT_DBL_MAX ); 00253 max_box.x( -CUBIT_DBL_MAX );max_box.y( -CUBIT_DBL_MAX ); 00254 00255 NODE *node_ptr; 00256 CubitVector node_loc; 00257 for (ii=0; ii<boundingNodes->size(); ii++) 00258 { 00259 node_ptr = boundingNodes->get_and_step(); 00260 node_loc = node_ptr->coordinates(); 00261 if (node_loc.x() < min_box.x()) min_box.x( node_loc.x() ); 00262 if (node_loc.y() < min_box.y()) min_box.y( node_loc.y() ); 00263 if (node_loc.x() > max_box.x()) max_box.x( node_loc.x() ); 00264 if (node_loc.y() > max_box.y()) max_box.y( node_loc.y() ); 00265 } 00266 00267 // expand the box by 10% 00268 00269 double dx = max_box.x() - min_box.x(); 00270 double dy = max_box.y() - min_box.y(); 00271 double expand; 00272 if (dx > dy) 00273 expand = 0.1 * dx; 00274 else 00275 expand = 0.1 * dy; 00276 00277 min_box.x( min_box.x() - expand ); 00278 min_box.y( min_box.y() - expand ); 00279 max_box.x( max_box.x() + expand ); 00280 max_box.y( max_box.y() + expand ); 00281 00282 00283 // create four new nodes 00284 00285 boxNodes[0] = (NODE *) new NODECHILD(min_box.x(), min_box.y(), 0.0, refFacePtr); 00286 boxNodes[1] = (NODE *) new NODECHILD(max_box.x(), min_box.y(), 0.0, refFacePtr); 00287 boxNodes[2] = (NODE *) new NODECHILD(max_box.x(), max_box.y(), 0.0, refFacePtr); 00288 boxNodes[3] = (NODE *) new NODECHILD(min_box.x(), max_box.y(), 0.0, refFacePtr); 00289 00290 00291 // create the two triangles 00292 00293 TRI *new_facet1 = (TRI *) new TRICHILD( boxNodes[0], boxNodes[1], 00294 boxNodes[3], refFacePtr ); 00295 TRI *new_facet2 = (TRI *) new TRICHILD( boxNodes[1], boxNodes[2], 00296 boxNodes[3], refFacePtr ); 00297 00298 facetList->append(new_facet1); 00299 facetList->append(new_facet2); 00300 00301 return CUBIT_SUCCESS; 00302 } 00303 00304 00305 //------------------------------------------------------------------------- 00306 // Function: insert_nodes 00307 // Description: insert nodes into Delaunay mesh 00308 // Author: chynes 00309 // Date: 6/3/2002 00310 //------------------------------------------------------------------------- 00311 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00312 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>:: 00313 insert_nodes(DLIList<NODE *> *&bounding_nodes) 00314 { 00315 CubitStatus rv = CUBIT_SUCCESS; 00316 int ii; 00317 NODE *point_ptr; 00318 TRI* start_tri = NULL; 00319 for (ii=0; ii<bounding_nodes->size() && rv == CUBIT_SUCCESS; ii++){ 00320 point_ptr = bounding_nodes->get_and_step(); 00321 rv = FacetorUtil<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::insert_node( 00322 point_ptr, *facetList, 00323 refFacePtr, curVisitFlag, 00324 start_tri); 00325 } 00326 00327 00328 return rv; 00329 } 00330 00331 00332 //------------------------------------------------------------------------- 00333 // Function: constrain_boundary 00334 // Description: recover the boundary edges from the mesh 00335 // Author: chynes 00336 // Date: 6/3/2002 00337 //------------------------------------------------------------------------- 00338 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00339 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::constrain_boundary(void) 00340 { 00341 CubitStatus rv = CUBIT_SUCCESS; 00342 00343 BoundaryConstrainTool<SURF,TRI,EDGE,NODE,TRICHILD> bctool( refFacePtr ); 00344 EDGE *edge_ptr = NULL; 00345 int ii; 00346 for (ii=0; ii<numBoundaryEdges && rv == CUBIT_SUCCESS; ii++) 00347 { 00348 rv = bctool.recover_edge( boundaryEdgeStartNodes[ii], 00349 boundaryEdgeEndNodes[ii], 00350 edge_ptr, 00351 facetList); 00352 //assert(edge_ptr != NULL); 00353 if (edge_ptr == NULL) 00354 { 00355 PRINT_ERROR("Could not recover a boundary in Delaunay facetor.\n" 00356 "Indicates potential problems with input loop geometry\n"); 00357 rv = CUBIT_FAILURE; 00358 } 00359 } 00360 return rv; 00361 } 00362 00363 00364 //------------------------------------------------------------------------- 00365 // Function: delete_exterior 00366 // Description: delete the triangles on the outside of the boundary and on 00367 // the interior of holes 00368 // Author: chynes 00369 // Date: 6/3/2002 00370 //------------------------------------------------------------------------- 00371 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00372 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::delete_exterior(void) 00373 { 00374 CubitStatus rv = CUBIT_SUCCESS; 00375 00376 // mark edges at the boundary 00377 00378 EDGE *edge_ptr; 00379 int ii; 00380 for (ii=0; ii<numBoundaryEdges; ii++) 00381 { 00382 edge_ptr = boundaryEdgeStartNodes[ii]->shared_edge( boundaryEdgeEndNodes[ii] ); 00383 if(!edge_ptr){ 00384 PRINT_ERROR("Boundary edges were not successfully recovered.\n"); 00385 return CUBIT_FAILURE; 00386 } 00387 edge_ptr->marked( CUBIT_TRUE ); 00388 } 00389 00390 // get a tri adjacent to a bounding box node 00391 00392 DLIList<TRI*> adjtris; 00393 boxNodes[0]->tris( adjtris ); 00394 TRI *tri_ptr = adjtris.get(); 00395 00396 // mark the tris on the outside starting from this triangle 00397 00398 int num_edges_found=0; 00399 rv = mark_tris( tri_ptr, num_edges_found ); 00400 if (rv != CUBIT_SUCCESS) 00401 return rv; 00402 00403 // delete the exterior triangles 00404 00405 int marked_flag = 1; 00406 rv = delete_tris( *facetList, marked_flag ); 00407 00408 // check to see if we've found all the edges 00409 //PRINT_INFO("num_edges_found = %i, numBoundaryEdges = %i\n",num_edges_found,numBoundaryEdges); 00410 00411 if (num_edges_found != numBoundaryEdges) 00412 { 00413 00414 // if not, then there are interior loops(holes) that need to have their 00415 // triangles removed 00416 00417 // find a triangle at the boundary 00418 00419 TRI *adjtri; 00420 int jj; 00421 CubitBoolean found = CUBIT_FALSE; 00422 if(!facetList->size()){ 00423 PRINT_ERROR("Problem marking exterior facets.\n"); 00424 return CUBIT_FAILURE; 00425 } 00426 00427 for (ii=0; ii<facetList->size() && !found; ii++) 00428 { 00429 tri_ptr = facetList->get_and_step(); 00430 for (jj=0; jj<3 && !found; jj++) 00431 { 00432 int kk = jj; 00433 adjtri = tri_ptr->adjacent( kk, refFacePtr ); 00434 if (adjtri == NULL) 00435 { 00436 found = CUBIT_TRUE; 00437 } 00438 } 00439 } 00440 00441 // mark all the tris we want to keep 00442 if(!found){ 00443 PRINT_WARNING("Possible problem. No boundary edge found.\n"); 00444 } 00445 00446 rv = mark_tris( tri_ptr, num_edges_found ); 00447 00448 // delete all the rest 00449 00450 marked_flag = 0; 00451 rv = delete_tris( *facetList, marked_flag ); 00452 } 00453 00454 return rv; 00455 } 00456 00457 00458 //------------------------------------------------------------------------- 00459 // Function: delete_tris 00460 // Description: delete triangles in the list with the specified marked flag 00461 // Author: chynes 00462 // Date: 6/3/2002 00463 //------------------------------------------------------------------------- 00464 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00465 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::delete_tris(DLIList<TRI *> &tri_list, int marked_flag) 00466 { 00467 CubitStatus rv = CUBIT_SUCCESS; 00468 00469 int ii, jj; 00470 EDGE *edge_ptr; 00471 TRI *tri_ptr; 00472 DLIList<EDGE *> edge_list; 00473 DLIList<TRI *> new_list; 00474 int ntri = tri_list.size(); 00475 for(ii=0; ii<ntri; ii++) 00476 { 00477 tri_ptr = tri_list.pop(); 00478 if (tri_ptr->marked() == marked_flag) 00479 { 00480 edge_list.clean_out(); 00481 tri_ptr->edges( edge_list ); 00482 delete tri_ptr; 00483 for(jj=0; jj<3; jj++) 00484 { 00485 edge_ptr = edge_list.get_and_step(); 00486 if(edge_ptr->number_tris() == 0 && edge_ptr->number_faces() == 0) 00487 delete edge_ptr; 00488 } 00489 } 00490 else 00491 new_list.append(tri_ptr); 00492 } 00493 tri_list+=new_list; 00494 return rv; 00495 } 00496 00497 00498 //------------------------------------------------------------------------- 00499 // Function: mark_tris 00500 // Description: recursive function to mark all the triangles we want to keep 00501 // Author: chynes 00502 // Date: 6/3/2002 00503 //------------------------------------------------------------------------- 00504 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00505 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::mark_tris(TRI *tri_ptr, 00506 int &num_edges_found) 00507 { 00508 CubitStatus rv = CUBIT_SUCCESS; 00509 tri_ptr->marked( CUBIT_TRUE ); 00510 int ii; 00511 EDGE *edge_ptr; 00512 TRI *adjtri; 00513 for (ii=0; ii<3 && rv == CUBIT_SUCCESS; ii++) 00514 { 00515 int jj = ii; 00516 adjtri = tri_ptr->adjacent( jj, refFacePtr ); 00517 edge_ptr = tri_ptr->edge( jj ); 00518 if(edge_ptr->marked()) { 00519 num_edges_found++; 00520 } 00521 else { 00522 if (adjtri != NULL && !adjtri->marked()) 00523 rv = mark_tris( adjtri, num_edges_found ); 00524 } 00525 } 00526 return rv; 00527 } 00528 00529 00530 //------------------------------------------------------------------------- 00531 // Function: refine_interior 00532 // Description: generate nodes on the interior of the tiangulation to 00533 // improve quality 00534 // Notes: this inserts nodes at the circumcenters of triangles roughly 00535 // based on the algorithm by Jonathon Shewchuk 00536 // Author: chynes 00537 // Date: 6/3/2002 00538 //------------------------------------------------------------------------- 00539 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00540 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::refine_interior(DLIList<TRI *> &tri_list) 00541 { 00542 CubitStatus rv = CUBIT_SUCCESS; 00543 00544 // classify the triangles based on their minimum angle 00545 00546 //rv = 00547 const int num_lists = 64; 00548 const double interval = QUALITY_ANGLE / double( num_lists - 1 ); 00549 DLIList<TRI*>* tri_sort_array = new DLIList<TRI *> [num_lists]; 00550 classify_triangles(tri_list, tri_sort_array, num_lists, interval ); 00551 00552 // process each of the triangles until done 00553 00554 TRI *tri_ptr; 00555 TRI* start_tri = NULL; 00556 while ((tri_ptr = next_triangle(tri_sort_array, num_lists)) != NULL && rv == CUBIT_SUCCESS) 00557 { 00558 rv = FacetorUtil<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::insert_at_circumcenter(tri_ptr, 00559 *facetList, 00560 start_tri, 00561 curVisitFlag, 00562 refFacePtr, 00563 tri_sort_array, 00564 num_lists, 00565 interval, 00566 QUALITY_ANGLE, 00567 sizingFunction, 00568 pTool); 00569 } 00570 00571 delete [] tri_sort_array; 00572 tri_sort_array = NULL; 00573 00574 return rv; 00575 } 00576 00577 //------------------------------------------------------------------------- 00578 // Function: classify_triangles 00579 // Description: order the triangles in the current mesh by their worst angle 00580 // Author: chynes 00581 // Date: 6/3/2002 00582 //------------------------------------------------------------------------- 00583 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00584 CubitStatus FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::classify_triangles(DLIList<TRI *> &tri_list, 00585 DLIList<TRI*>* sorted_lists, 00586 const int num_lists, 00587 const double interval) 00588 { 00589 CubitStatus rv = CUBIT_SUCCESS; 00590 00591 // Create an array of lists that will hold triangles as they are 00592 // created (and deleted). Each list will hold triangles whose angles 00593 // fall within a specified interval. Triangles will be processed 00594 // from smallest angle to best angle 00595 00596 // classify each trriangle and place into sort lists 00597 00598 TRI *tri_ptr; 00599 int ii; 00600 for(ii=0; ii<tri_list.size() && rv == CUBIT_SUCCESS; ii++) 00601 { 00602 tri_ptr = tri_list.get_and_step(); 00603 //rv = 00604 FacetorUtil<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::classify_tri_by_angle( 00605 tri_ptr, sorted_lists, num_lists, interval, QUALITY_ANGLE); 00606 } 00607 00608 return rv; 00609 } 00610 00611 00612 //------------------------------------------------------------------------- 00613 // Function: next_triangle 00614 // Description: get the next triangle to process 00615 // Author: chynes 00616 // Date: 6/3/2002 00617 //------------------------------------------------------------------------- 00618 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00619 TRI *FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::next_triangle(DLIList<TRI*>* sorted_lists, 00620 const int num_lists) 00621 { 00622 TRI *tri_ptr = NULL; 00623 int ii; 00624 for( ii = 1; ii < num_lists && tri_ptr == NULL; ii++) 00625 { 00626 if (sorted_lists[ii].size() > 0) 00627 tri_ptr = sorted_lists[ii].remove(); 00628 } 00629 if (tri_ptr == NULL) 00630 { 00631 if (sorted_lists[0].size() > 0) 00632 tri_ptr = sorted_lists[0].remove(); 00633 } 00634 return tri_ptr; 00635 } 00636 00637 //------------------------------------------------------------------------- 00638 // Function: clean_up_data 00639 // Description: clean up any data we've allocated 00640 // Author: chynes 00641 // Date: 6/3/2002 00642 //------------------------------------------------------------------------- 00643 template<class SURF, class TRI, class EDGE, class NODE, class TRICHILD, class NODECHILD, class SIZEFUNC> MY_INLINE 00644 void FacetorTool<SURF, TRI, EDGE, NODE, TRICHILD, NODECHILD, SIZEFUNC>::clean_up_data(void) 00645 { 00646 00647 EDGE *del_edge_ptr; 00648 DLIList<EDGE *> del_edge_list; 00649 TRI *tri_ptr; 00650 DLIList<TRI *> tri_list; 00651 00652 00653 int ii, jj, kk; 00654 00655 //loop over facets and remove marks 00656 for(ii=0; ii<facetList->size(); ii++) 00657 { 00658 tri_ptr = facetList->get_and_step(); 00659 tri_ptr->marked(CUBIT_FALSE); 00660 ToolData *td = tri_ptr->remove_TD( TDDelaunay< TRI, NODE >::is_delaunay ); 00661 if (td != NULL) 00662 { 00663 TDDelaunay< TRI, NODE > *td_del = dynamic_cast<TDDelaunay< TRI, NODE >*> (td); 00664 delete td_del; 00665 } 00666 } 00667 00668 //loop over the box ndes 00669 //if meshing was successful, some of the below is unnecessary 00670 for(ii=0; ii<4; ii++) 00671 { 00672 if (boxNodes[ii] != NULL){ 00673 tri_list.clean_out(); 00674 //if there are tris attached, delete them. 00675 boxNodes[ii]->tris(tri_list); 00676 for (jj=0; jj<tri_list.size(); jj++) 00677 { 00678 tri_ptr = tri_list.get_and_step(); 00679 del_edge_list.clean_out(); 00680 tri_ptr->edges( del_edge_list ); 00681 delete tri_ptr; 00682 00683 // also deltet the attached, unused edges 00684 for (kk=0; kk<del_edge_list.size(); kk++) 00685 { 00686 del_edge_ptr = del_edge_list.get_and_step(); 00687 if (del_edge_ptr->number_tris() == 0) 00688 delete del_edge_ptr; 00689 } 00690 } 00691 } 00692 //finally delete the nodes 00693 delete boxNodes[ii]; 00694 } 00695 00696 // clean off the edge marks 00697 00698 EDGE *edge_ptr; 00699 for (ii=0; ii<numBoundaryEdges; ii++) 00700 { 00701 edge_ptr = boundaryEdgeStartNodes[ii]->shared_edge( boundaryEdgeEndNodes[ii] ); 00702 if (edge_ptr) 00703 edge_ptr->marked( CUBIT_FALSE ); 00704 } 00705 } 00706 00707 // EOF 00708