cgma
FacetboolInterface.cpp
Go to the documentation of this file.
00001 #include "FacetboolInterface.hpp"
00002 #include "FacetDataUtil.hpp"
00003 #include "FBDataUtil.hpp"
00004 #include "FBIntersect.hpp"
00005 #include "IntegerHash.hpp"
00006 #include "FacetBody.hpp"
00007 #include "BodySM.hpp"
00008 #include "Body.hpp"
00009 #include "FacetSurface.hpp"
00010 #include "FBDataUtil.hpp"
00011 #include "CubitPoint.hpp"
00012 #include "CubitPointData.hpp"
00013 #include "CubitFacetData.hpp"
00014 #include "FacetModifyEngine.hpp"
00015 #include "FacetQueryEngine.hpp"
00016 #include "FacetCurve.hpp"
00017 #include "CubitFacetEdge.hpp"
00018 #include "TDFacetboolData.hpp"
00019 #include "CurveFacetEvalTool.hpp"
00020 #include "FacetPoint.hpp"
00021 #include "FacetLump.hpp"
00022 #include "FacetShell.hpp"
00023 #include "CubitBox.hpp"
00024 #include "FBImprint.hpp"
00025 #include "GfxDebug.hpp"
00026 #include "ChollaEngine.hpp"
00027 
00028 FacetboolInterface::FacetboolInterface()
00029 {
00030 
00031 }
00032 
00033 FacetboolInterface::~FacetboolInterface()
00034 {
00035 
00036 }
00037 
00038 //===============================================================================
00039 // Function   : webcut_FB
00040 // Member Type: PUBLIC
00041 // Description: webcut a FacetBody with a FacetBool cutter
00042 // Author     : John Fowler
00043 // Date       : 02/04
00044 //===============================================================================
00045 CubitStatus FacetboolInterface::webcut_FB(BodySM *bodysm_ptr,
00046                                          std::vector<double>& cutter_verts,
00047                                          std::vector<int>& cutter_connections,
00048                                          bool cutter_is_plane,
00049                                          CubitBoolean delete_bodies,
00050                                          CubitBoolean &intersects,
00051                                          DLIList<BodySM*>& results_list)
00052                                          
00053 {
00054   intersects = CUBIT_TRUE;
00055   DLIList<FacetSurface*> facet_surf_list;
00056   std::vector<double> body_verts;
00057   std::vector<int> body_connections, newbodyfacets;
00058   std::vector<int> newcutterfacets;
00059   std::vector<int> f_c_indices1;
00060   std::vector<FacetSurface *> fsurfarray;
00061   std::vector<FacetCurve *> fcurvearray;
00062   CubitStatus status;
00063   int mydebug = 0;
00064     FacetModifyEngine *fme = FacetModifyEngine::instance();
00065     FacetBody *facet_body_ptr = CAST_TO(bodysm_ptr, FacetBody);
00066 
00067     facet_body_ptr->get_surfaces(facet_surf_list);
00068 
00069     status = facetbody_to_facetbool(facet_surf_list,body_verts,
00070                          body_connections,&f_c_indices1,
00071                          fsurfarray,fcurvearray);
00072     if( status == CUBIT_FAILURE )
00073       return status;
00074 
00075     FBIntersect intersector;
00076     intersector.set_classify_flag(true);
00077     if ( cutter_is_plane == true ) intersector.set_body2_planar();
00078 
00079     status = intersector.intersect(body_verts,body_connections,
00080                                     cutter_verts,cutter_connections,
00081                                     newbodyfacets,newcutterfacets,
00082                                     &f_c_indices1,
00083                                     0);
00084     if( status == CUBIT_FAILURE )
00085       return status;
00086 
00087     bool *surfs_in_intersection, *surfs_in_subtraction;
00088     bool *curves_in_intersection, *curves_in_subtraction;
00089     
00090     surfs_in_intersection = new bool[1+fsurfarray.size()];
00091     surfs_in_subtraction = new bool[1+fsurfarray.size()];
00092     curves_in_intersection = new bool[1+fcurvearray.size()];
00093     curves_in_subtraction = new bool[1+fcurvearray.size()];
00094     unsigned int k;
00095     for ( k = 1; k < 1 + fsurfarray.size(); k++ ) 
00096         surfs_in_subtraction[k] = surfs_in_intersection[k] = false;
00097     for ( k = 1; k < 1 + fcurvearray.size(); k++ ) 
00098         curves_in_subtraction[k] = curves_in_intersection[k] = false;
00099 
00100     status = intersector.get_persistent_entity_info(surfs_in_intersection,
00101                                  curves_in_intersection,surfs_in_subtraction,
00102                                  curves_in_subtraction,CUBIT_FB_INTERSECTION,1);
00103     if( status == CUBIT_FAILURE )
00104       return status;
00105 
00106     facet_surf_list.reset();
00107 
00108     std::vector<int> surfindex, surfindex2;  
00109     std::vector<int> curveindex, curveindex2;  
00110     std::vector<double> vertsout, vertsout2;
00111     std::vector<int> coordsout, coordsout2;
00112     
00113     status = intersector.gather_by_boolean(vertsout,coordsout,
00114                                      &surfindex,&curveindex,0,
00115                                      CUBIT_FB_INTERSECTION);  
00116     if( status == CUBIT_FAILURE )
00117       return status;
00118     status = intersector.gather_by_boolean(vertsout2,coordsout2,
00119                                      &surfindex2,&curveindex2,0,
00120                                      CUBIT_FB_SUBTRACTION);
00121     if( status == CUBIT_FAILURE )
00122       return status;
00123 
00124     //  If there were no intersections
00125     if ( (vertsout.size()  == 0) || (coordsout.size() == 0) ||
00126          (vertsout2.size() == 0) || (coordsout2.size() == 0) )
00127     {
00128         intersects = CUBIT_FALSE;
00129         delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
00130         delete [] curves_in_intersection; delete [] curves_in_subtraction;
00131         return CUBIT_SUCCESS;
00132     }
00133 
00134     CubitPoint *new_point;
00135     std::vector<CubitPoint *> points;
00136 
00137     for ( k = 0; k < vertsout.size(); k += 3 ) {
00138       new_point = (CubitPoint *) new CubitPointData( vertsout[k],
00139                                                      vertsout[k+1],
00140                                                      vertsout[k+2] );
00141       points.push_back(new_point);
00142     } 
00143 
00144     DLIList <CubitFacet *>facet_list;
00145     DLIList <CubitPoint *>point_list;
00146     CubitFacet *facet_ptr;
00147     if(mydebug)
00148       GfxDebug::clear();
00149     for ( k = 0; k < coordsout.size(); k += 3 ) 
00150     {    
00151       facet_ptr = new CubitFacetData( points[coordsout[k]],
00152                                       points[coordsout[k+1]],
00153                                       points[coordsout[k+2]] ); 
00154       int cptr[3];
00155       cptr[0] = curveindex[k];
00156       cptr[1] = curveindex[k+1];
00157       cptr[2] = curveindex[k+2];
00158       TDFacetboolData::add_facetbool_facet( facet_ptr );
00159       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
00160       td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],false,
00161               facet_ptr->is_backwards());
00162       if(mydebug){
00163         facet_ptr->debug_draw(CUBIT_YELLOW_INDEX);
00164         CubitVector tmp1 = points[coordsout[k]]->coordinates();
00165         CubitVector tmp2 = points[coordsout[k+1]]->coordinates();
00166         CubitVector tmp3 = points[coordsout[k+2]]->coordinates();
00167         
00168         if(cptr[0]){
00169           GfxDebug::draw_line(tmp1, tmp2, CUBIT_WHITE_INDEX);
00170         }
00171         if(cptr[1]){
00172           GfxDebug::draw_line(tmp2, tmp3, CUBIT_GREEN_INDEX);
00173         }
00174         if(cptr[2]){
00175           GfxDebug::draw_line(tmp3, tmp1, CUBIT_BLUE_INDEX);
00176         }
00177       }
00178       facet_list.append( facet_ptr );     
00179     }
00180     if(mydebug){
00181       GfxDebug::mouse_xforms();
00182     }
00183     points.clear(); //  clear out the points vector since we are through with it.
00184 
00185     double feature_angle;
00186     int interp_order;
00187     CubitBoolean smooth_non_manifold, split_surfaces;
00188     BodySM *body_ptr, *body_ptr2;
00189       //determine if original body is a sheet body
00190     Body *tmp_body = CAST_TO(bodysm_ptr->topology_entity(), Body);
00191     bool is_sheet_body = false;
00192     if( tmp_body->is_sheet_body() ) 
00193       is_sheet_body = true;
00194 
00195       //mbrewer:  This is not the best solution.  For now, we are using
00196       // a no feature angle unless we are working with a sheet-body.  For
00197       // sheet-bodies, however, we are not marking the vertices that
00198       // bound curves.  Therefore, if we do not use a feature angle, curves
00199       // are not split correctly.  The correct fix would be to mark
00200       // the vertices and maintain them through the webcut.
00201     if( is_sheet_body ) 
00202       feature_angle = 135.0;
00203     else
00204       feature_angle = 0.0;
00205     interp_order = 0;
00206     smooth_non_manifold = CUBIT_TRUE;
00207     split_surfaces = CUBIT_FALSE;
00208 
00209     {
00210         ChollaEngine *cholla_ptr = NULL;
00211 
00212         status = fme->build_cholla_surfaces( facet_list,
00213                                              point_list,
00214                                              feature_angle,
00215                                              interp_order,
00216                                              smooth_non_manifold,
00217                                              split_surfaces,
00218                                              cholla_ptr );
00219         if( status == CUBIT_FAILURE )
00220           return status;
00221 
00222         status = fme->finish_facet_Body( cholla_ptr,
00223                                          NULL,
00224                                          feature_angle, interp_order,
00225                                          body_ptr);
00226         if( status == CUBIT_FAILURE )
00227           return status;
00228 
00229         if ( cholla_ptr )
00230         {
00231             cholla_ptr->delete_me();
00232             delete cholla_ptr;
00233         }
00234     }
00235     DLIList<BodySM*> new_bodies;
00236 
00237     status = separate_shells_into_bodies( body_ptr, is_sheet_body, new_bodies );
00238     if( status == CUBIT_FAILURE )
00239       return status;
00240     for(k=new_bodies.size(); k--;)
00241       results_list.append( new_bodies.get_and_step() );  
00242       
00243     vertsout.clear();
00244     coordsout.clear();                                 
00245 
00246     facet_list.clean_out();    
00247     for ( k = 0; k < vertsout2.size(); k += 3 ) {
00248       new_point = (CubitPoint *) new CubitPointData( vertsout2[k],
00249                                                    vertsout2[k+1],
00250                                                    vertsout2[k+2] );
00251       points.push_back(new_point);
00252     }  
00253     for ( k = 0; k < coordsout2.size(); k += 3 ) {    
00254       facet_ptr = new CubitFacetData( points[coordsout2[k]],
00255                                       points[coordsout2[k+1]],
00256                                       points[coordsout2[k+2]] );
00257       int cptr[3];
00258       cptr[0] = curveindex2[k];
00259       cptr[1] = curveindex2[k+1];
00260       cptr[2] = curveindex2[k+2];
00261       TDFacetboolData::add_facetbool_facet( facet_ptr );
00262       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
00263       td->set(surfindex2[k/3],cptr[0],cptr[1],cptr[2],false,
00264               facet_ptr->is_backwards());
00265       if(mydebug){
00266         CubitVector tmp1 = points[coordsout2[k]]->coordinates();
00267         CubitVector tmp2 = points[coordsout2[k+1]]->coordinates();
00268         CubitVector tmp3 = points[coordsout2[k+2]]->coordinates();
00269         if(cptr[0]){
00270           GfxDebug::draw_line(tmp1, tmp2, CUBIT_WHITE_INDEX);
00271         }
00272         if(cptr[1]){
00273           GfxDebug::draw_line(tmp2, tmp3, CUBIT_GREEN_INDEX);
00274         }
00275         if(cptr[2]){
00276           GfxDebug::draw_line(tmp3, tmp1, CUBIT_BLUE_INDEX);
00277         }
00278       }
00279       facet_list.append( facet_ptr );     
00280     }
00281     points.clear(); //  clear out the points vector since we are through with it.
00282 
00283     {
00284         ChollaEngine *cholla_ptr = NULL;
00285 
00286         status = fme->build_cholla_surfaces( facet_list,
00287                                              point_list,
00288                                              feature_angle,
00289                                              interp_order,
00290                                              smooth_non_manifold,
00291                                              split_surfaces,
00292                                              cholla_ptr );
00293         if( status == CUBIT_FAILURE )
00294           return status;
00295 
00296         status = fme->finish_facet_Body( cholla_ptr,
00297                                          NULL,
00298                                          feature_angle, interp_order,
00299                                          body_ptr2);
00300         if( status == CUBIT_FAILURE )
00301           return status;
00302         if ( cholla_ptr )
00303         {
00304             cholla_ptr->delete_me();
00305             delete cholla_ptr;
00306         }
00307     }
00308     new_bodies.clean_out();
00309     status = separate_shells_into_bodies( body_ptr2, is_sheet_body, new_bodies );
00310     if( status == CUBIT_FAILURE )
00311       return status;
00312     for(k=new_bodies.size(); k--;)
00313       results_list.append( new_bodies.get_and_step() );  
00314                                
00315     if ( delete_bodies == CUBIT_TRUE )
00316       make_persistents_webcut(bodysm_ptr,body_ptr,body_ptr2,fsurfarray,fcurvearray,
00317                        surfs_in_intersection,surfs_in_subtraction,
00318                        curves_in_intersection,curves_in_subtraction);
00319 
00320     vertsout2.clear();
00321     coordsout2.clear();                                 
00322                               
00323     delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
00324     delete [] curves_in_intersection; delete [] curves_in_subtraction;
00325       
00326     return CUBIT_SUCCESS;
00327 }
00328 
00329 CubitStatus FacetboolInterface::separate_lumps( BodySM *body_ptr, 
00330                                                 bool is_sheet_body)
00331 {
00332     //get all the shells in 'body_ptr'
00333     DLIList<FacetShell*> facet_shells;
00334     FacetBody *facet_body = CAST_TO( body_ptr, FacetBody );
00335     facet_body->get_shells( facet_shells );
00336 
00337     // some shells here might contain more than one connected
00338     // patch of surfaces...which is illegal.  Separate them into their own shells.
00339     bool created_shells = false;
00340     int k,i;
00341     for( k=facet_shells.size(); k--; )
00342     {
00343       FacetShell *facet_shell = facet_shells.get_and_step();
00344       DLIList<FacetSurface*> facet_surfs;
00345       facet_shell->get_surfaces( facet_surfs );
00346       DLIList<FacetSurface*> connected_patch;
00347       int max_num_passes = facet_surfs.size();
00348       int num_passes=0;  //prevents infinite loop
00349       while( facet_surfs.size() && num_passes < max_num_passes )
00350       {
00351         connected_patch.clean_out();
00352         FacetQueryEngine::instance()->get_connected_patch( facet_surfs, connected_patch );
00353 
00354         if( num_passes == 0 ) 
00355         {
00356           int kk;
00357           for( kk=connected_patch.size(); kk--; )
00358           {
00359             FacetSurface *f_surf = connected_patch.get_and_step();
00360             if( is_sheet_body ) 
00361               f_surf->set_shell_sense( facet_shell, CUBIT_UNKNOWN );
00362             else
00363               f_surf->set_shell_sense( facet_shell, CUBIT_FORWARD );
00364           }
00365         }
00366         else //extract surfaces out of current shell and make them into their own shell
00367         {
00368 
00369           facet_shell->disconnect_surfaces( connected_patch ); 
00370          
00371           DLIList<Surface*> tmp_surfs;
00372           CAST_LIST( connected_patch, tmp_surfs, Surface ); 
00373           ShellSM *shellsm_ptr;
00374           FacetModifyEngine::instance()->make_facet_shell(tmp_surfs, shellsm_ptr);
00375           if ( shellsm_ptr == NULL )
00376           {
00377             PRINT_ERROR("Problems building facet based shell entity.\n");
00378           }
00379           else
00380           {
00381             FacetShell *tmp_shell = static_cast<FacetShell*>(shellsm_ptr);
00382 
00383             int kk;
00384             //now for each surface, add sense wrt this new shell
00385             for( kk=tmp_surfs.size(); kk--;)
00386             {
00387               FacetSurface *tmp_facet_surf = CAST_TO(tmp_surfs.get_and_step(), FacetSurface); 
00388               
00389               //if it's not a sheet body, tag the surfs wrt the shell, FORWARD
00390               if( is_sheet_body ) 
00391                 tmp_facet_surf->set_shell_sense( tmp_shell, CUBIT_UNKNOWN );
00392               else
00393                 tmp_facet_surf->set_shell_sense( tmp_shell, CUBIT_FORWARD );
00394             }
00395 
00396             created_shells = true;
00397             FacetLump *facet_lump = static_cast<FacetLump*>( facet_shell->get_lump() ); 
00398             facet_lump->add_shell( tmp_shell ); 
00399           }
00400         }
00401         num_passes++;
00402       }
00403     }
00404   
00405     bool created_lumps = false;
00406     DLIList<FacetShell*> void_shells; 
00407     int number_regions = 0;
00408     if( created_shells )
00409     {
00410       //determine which shells are regions and which are voids
00411       //get a point we know is outside the body
00412       CubitBox bbox;
00413       CubitVector centroid;
00414       double vol;
00415       facet_body->mass_properties( centroid, vol );
00416       FacetQueryEngine::instance()->create_facet_bounding_box( facet_body, bbox );
00417       CubitVector point_outside = 2*(bbox.maximum() - centroid);  
00418       point_outside = centroid + point_outside;
00419       
00420       facet_shells.clean_out();
00421       facet_body->get_shells( facet_shells );
00422       for( k=facet_shells.size(); k--; )
00423       {
00424         FacetShell *facet_shell = facet_shells.get_and_step();
00425         CubitPointContainment point_cont;
00426         point_cont = facet_shell->point_containment( point_outside );
00427 
00428         if( point_cont == CUBIT_PNT_OUTSIDE )
00429           number_regions++;
00430         else if( point_cont == CUBIT_PNT_INSIDE )
00431           void_shells.append( facet_shell ); 
00432 
00433         //is a region...if it is the second found region, should be 
00434         //in its own lump
00435         if( number_regions>1 && point_cont == CUBIT_PNT_OUTSIDE ) 
00436         {
00437           created_lumps = true;
00438         
00439           //remove this shell from its current Lump
00440           FacetLump *tmp_lump = static_cast<FacetLump*>(facet_shell->get_lump());
00441           tmp_lump->remove_shell( facet_shell ); 
00442 
00443           //make a new lump containing this shell
00444           Lump *new_lump;
00445           DLIList<ShellSM*> sm_shells;
00446           sm_shells.append( static_cast<ShellSM*>(facet_shell) );
00447           FacetModifyEngine::instance()->make_facet_lump( sm_shells, new_lump );
00448 
00449           //add lump to body
00450           facet_body->add_lump( static_cast<FacetLump*>(new_lump) );
00451         }
00452       }
00453     }
00454 
00455     if( void_shells.size() && created_lumps )
00456     {
00457       //the void shells are still in the original lump.  We need to pair each 
00458       //up with the region that encloses it 
00459       
00460       //make a list of all the region (non-void) shells in the body
00461       DLIList<FacetShell*> region_shells; 
00462       facet_body->get_shells( region_shells );
00463       for(k=void_shells.size(); k--;)
00464       {
00465         if( region_shells.move_to( void_shells.get_and_step() ) )
00466           region_shells.change_to( NULL );
00467       }
00468       region_shells.remove_all_with_value( NULL );
00469     
00470       //for each void lump...find the region that contains it
00471       for( k=void_shells.size(); k--; )
00472       {
00473         FacetShell *void_shell = void_shells.get_and_step();
00474 
00475         //get a point on the void
00476         DLIList<FacetSurface*> tmp_surfs;
00477         void_shell->get_surfaces( tmp_surfs );
00478         CubitVector point_on_shell;
00479         
00480         DLIList<CubitFacet*> facet_list;
00481         tmp_surfs.get()->tris( facet_list );
00482         
00483         point_on_shell = facet_list.get()->center();
00484 
00485         //get the region that contains that point
00486         for( i=region_shells.size(); i--; )
00487         {
00488           FacetShell *region_shell = region_shells.get_and_step();
00489 
00490           tmp_surfs.clean_out();
00491           region_shell->get_surfaces( tmp_surfs );
00492 
00493           if( region_shell->point_containment( point_on_shell ) 
00494                                                         == CUBIT_PNT_INSIDE )
00495           {
00496             //remove the void shell from it's lump
00497             FacetLump *tmp_lump = static_cast<FacetLump*>(void_shell->get_lump());
00498             tmp_lump->remove_shell( void_shell ); 
00499 
00500             //add the void shell to the region's lump
00501             tmp_lump = static_cast<FacetLump*>(region_shell->get_lump());
00502             tmp_lump->add_shell( void_shell ); 
00503             break;
00504           }
00505         }
00506       }
00507     }
00508     return CUBIT_SUCCESS;
00509 }
00510 
00511 CubitStatus FacetboolInterface::separate_shells_into_bodies(BodySM *body_ptr,
00512                                                             bool is_sheet_body,
00513                                                  DLIList<BodySM*> &new_bodies)
00514 {
00515     //first separate the body into its lumps
00516   if(!separate_lumps(body_ptr,is_sheet_body))
00517     return CUBIT_FAILURE;
00518   
00519     //split out each lump into it's own body
00520   DLIList<BodySM*> split_bodies;
00521   FacetModifyEngine::instance()->split_body( body_ptr, split_bodies);
00522   new_bodies += split_bodies;
00523   
00524   return CUBIT_SUCCESS;
00525 }    
00526 
00527 CubitStatus FacetboolInterface::facetbody_to_facetbool(
00528                                DLIList<FacetSurface*> &facet_surf_list,
00529                                std::vector<double> &body_verts,
00530                                std::vector<int> &body_connections,
00531                                std::vector<int> *f_c_indices,
00532                                std::vector<FacetSurface *>& fsurfarray,
00533                                std::vector<FacetCurve *>& fcurvearray
00534                                )
00535 {
00536   CubitStatus status;
00537   int mydebug = 0;
00538   
00539   if(mydebug){
00540     GfxDebug::clear();
00541   }
00542   int i, j, k, m, n, vtx[3], hashvalue, *hasharrayptr, hasharraysize, ifoundit;
00543   IntegerHash *hashobj;
00544   double xx, yy, zz, xval, yval, zval;
00545   FacetSurface *facet_surface; 
00546   DLIList<CubitFacet*> facetlist; 
00547   DLIList<CubitFacetEdge*> c_edgelist, f_edgelist;
00548   DLIList<FacetCurve *> curve_list;
00549   CubitPoint *point;
00550   CubitFacet *facet;
00551   FacetCurve *curve;
00552   CubitFacetEdge *c_edge, *edge;
00553   int numhashbins, c_index;
00554 
00555   numhashbins = 101;
00556   status = CUBIT_SUCCESS;
00557   hashobj = new IntegerHash(numhashbins,20);
00558                                           
00559   for ( i = 0; i < facet_surf_list.size(); i++ ) {
00560     facet_surface = facet_surf_list.get_and_step();
00561     fsurfarray.push_back(facet_surface); 
00562     facet_surface->get_my_facetedges(f_edgelist);
00563     for ( m = f_edgelist.size(); m > 0; m-- ) {
00564       edge = f_edgelist.get_and_step();
00565       edge->set_flag(0); //  Initialize edge flags.
00566       if(mydebug)
00567         edge->debug_draw(CUBIT_PINK_INDEX);
00568     }
00569     //  Assume that each facet surf occurs only once, so there won't be
00570     //  duplicates on fsarray.
00571     facetlist.clean_out();
00572     facet_surface->tris(facetlist);
00573     curve_list.clean_out();
00574     facet_surface->get_curves(curve_list);
00575     for ( m = 0; m < curve_list.size(); m++ ) {    
00576       curve = curve_list.get_and_step();
00577       c_index = findcurve(curve,fcurvearray);
00578       c_edgelist.clean_out();
00579       curve->get_facets(c_edgelist);
00580       for ( n = c_edgelist.size(); n > 0; n-- ) {
00581         c_edge = c_edgelist.get_and_step();
00582         c_edge->set_flag(c_index+1);
00583         if(mydebug)
00584           c_edge->debug_draw(CUBIT_RED_INDEX);
00585         
00586       }
00587     }
00588     int efindex[3];
00589     for ( j = facetlist.size(); j > 0; j-- ) {
00590       facet = facetlist.get_and_step();
00591       for ( k = 0; k < 3; k++ ) {
00592         point = facet->point(k);
00593         edge = facet->edge(k);
00594         if(mydebug){
00595           if(edge->get_flag()){
00596             edge->debug_draw(CUBIT_WHITE_INDEX);
00597           }
00598         }
00599         efindex[k] = edge->get_flag();
00600         xx = point->x(); 
00601         yy = point->y();
00602         zz = point->z();
00603         //  Get a vertex number.
00604         hashvalue = FBDataUtil::makeahashvaluefrom_coord(xx,yy,zz,numhashbins);
00605         hasharrayptr = hashobj->getHashBin(hashvalue,&hasharraysize);
00606         ifoundit = -1;
00607         for ( m = 0; m < hasharraysize; m++ ) {
00608           n = hasharrayptr[m];
00609           xval = body_verts[3*n];
00610           yval = body_verts[3*n+1];
00611           zval = body_verts[3*n+2];
00612           if ( ( fabs(xval-xx) < 1.e-6 ) && 
00613           ( fabs(yval-yy) < 1.e-6 ) &&
00614           ( fabs(zval-zz) < 1.e-6 ) ) {
00615             ifoundit = n;
00616             break;
00617           }
00618         }
00619         if ( ifoundit == -1 ) {
00620           ifoundit = body_verts.size()/3;
00621           body_verts.push_back(xx);
00622           body_verts.push_back(yy);
00623           body_verts.push_back(zz);
00624           hashobj->addtoHashList(hashvalue,ifoundit);
00625         }
00626         vtx[k] = ifoundit;
00627       }
00628       body_connections.push_back(vtx[0]);
00629       body_connections.push_back(vtx[1]);
00630       body_connections.push_back(vtx[2]);
00631       f_c_indices->push_back(i+1); //  put the surface index for the facet
00632       f_c_indices->push_back(efindex[2]); //  edge indices for the facet
00633       f_c_indices->push_back(efindex[0]);
00634       f_c_indices->push_back(efindex[1]);            
00635     }    
00636   }
00637   if(mydebug)
00638     GfxDebug::mouse_xforms();
00639   delete hashobj;   
00640   return status;
00641   
00642 }
00643 
00644 //===============================================================================
00645 // Function   : dofacetboolean
00646 // Member Type: PUBLIC
00647 // Description: do facetboolean operations on a list of bodies.
00648 // Author     : John Fowler
00649 // Date       : 02/04
00650 //===============================================================================
00651 CubitStatus FacetboolInterface::dofacetboolean(DLIList<BodySM*>& body_list, 
00652                              BodySM*& newBody,
00653                              bool keep_old,
00654                              const CubitFacetboolOp op)
00655 {
00656   int k;
00657   BodySM *body_sm1, *body_sm2, *body_out;
00658   CubitStatus status = CUBIT_FAILURE;
00659   bool intersection_found = false;
00660 
00661   body_sm1 = body_list.get_and_step();
00662 
00663   for ( k = body_list.size() - 1; k > 0; k-- ) {
00664     body_out =0;
00665     if(!body_sm1)
00666       body_sm1=body_list.get_and_step();
00667     else{
00668       body_sm2 = body_list.get_and_step();  
00669       status = dofacetboolean_2bodies(body_sm1,body_sm2,body_out,keep_old,
00670                                       intersection_found,op);
00671       if ( keep_old == false){
00672           //if there was an intersection, we want to delete the two
00673           //original bodies if we are not keeping old.
00674           //Also, if we we were performing an INTERSECTION we
00675           //want to delete the two original bodies even if there was
00676           //no intersection between the two bodies (again if we
00677           //are not keeping originals).
00678         if(intersection_found == true || op == CUBIT_FB_INTERSECTION)  { 
00679           FacetQueryEngine::instance()->
00680             delete_solid_model_entities(body_sm2);
00681           FacetQueryEngine::instance()->
00682             delete_solid_model_entities(body_sm1);
00683           body_sm2=NULL;
00684           body_sm1=NULL;
00685         }
00686           //if we are not keeping old, we want to delete the second
00687           //body even if there was no intersection between the two
00688           //bodies (for a subtration).
00689         else if(op == CUBIT_FB_SUBTRACTION)  { 
00690           FacetQueryEngine::instance()->
00691             delete_solid_model_entities(body_sm2);
00692           body_sm2=NULL;
00693         }
00694       }
00695         
00696       if ( body_out ) body_sm1 = body_out;
00697     }
00698   }  
00699   newBody = body_sm1;
00700   
00701   return status;  
00702 }
00703 
00704 //===============================================================================
00705 // Function   : dofacetboolean_subtract
00706 // Member Type: PUBLIC
00707 // Description: do facetboolean subtract operations on a list of bodies.
00708 // Author     : John Fowler
00709 // Date       : 02/04
00710 //===============================================================================
00711 CubitStatus FacetboolInterface::dofacetboolean_subtract(BodySM*& tool_body, 
00712                                       DLIList<BodySM*>& from_bodies,
00713                                       DLIList<BodySM*>& new_bodies,
00714                                       bool keep_old,
00715                                       bool* to_be_deleted,
00716                                       const CubitFacetboolOp op)
00717 {
00718   int k;
00719   BodySM *body_sm2, *body_out;
00720   CubitStatus status = CUBIT_FAILURE;
00721   bool intersection_found = false;
00722 
00723   for ( k = 0; k < from_bodies.size(); k++ ) {
00724     body_out = 0;  
00725     body_sm2 = from_bodies.get_and_step();  
00726     status = dofacetboolean_2bodies(body_sm2,tool_body,body_out,keep_old,
00727                             intersection_found,op);
00728     if ( (keep_old == false) && (intersection_found == true) ) { 
00729       to_be_deleted[k] = true;
00730     }
00731 
00732     if ( (status == CUBIT_SUCCESS) && (body_out) ) new_bodies.append(body_out);
00733   }  
00734  
00735   return status;  
00736 }
00737 
00738 CubitStatus FacetboolInterface::dofacetboolean_2bodies(BodySM*& body_in1, 
00739                              BodySM*& body_in2,
00740                              BodySM*& body_out,
00741                              bool keep_old,
00742                              bool& intersection_found,
00743                              const CubitFacetboolOp op)
00744 {
00745 
00746 CubitStatus status;
00747 std::vector<double> body_verts;
00748 std::vector<double> body2_verts;
00749 std::vector<int> body_connections, newbodyfacets;
00750 std::vector<int>  body2_connections, newbody2facets;
00751 std::vector<double> vertsout;
00752 std::vector<int> coordsout;
00753 std::vector<int> f_c_indices1;
00754 std::vector<int> f_c_indices2;
00755 std::vector<FacetSurface *> fsurfarray1, fsurfarray2;
00756 std::vector<FacetCurve *> fcurvearray1, fcurvearray2;
00757 std::vector<int> surfindex;  
00758 std::vector<int> curveindex;
00759  
00760  
00761     DLIList <CubitFacet *>facet_list;
00762     DLIList <CubitPoint *>point_list;
00763     CubitPoint *new_point;
00764     CubitFacet *facet_ptr;
00765     std::vector<CubitPoint *> points;
00766     bool *surfs_in_intersection, *surfs_in_subtraction;
00767     bool *curves_in_intersection, *curves_in_subtraction;
00768     bool *surfs_in_intersection2, *surfs_in_subtraction2;
00769     bool *curves_in_intersection2, *curves_in_subtraction2;
00770 
00771   status = CUBIT_SUCCESS;
00772   intersection_found = true;
00773   bool is_sheet_body = false;
00774   Body *tmp_body_1 = CAST_TO(body_in1->topology_entity(), Body);
00775   Body *tmp_body_2 = CAST_TO(body_in2->topology_entity(), Body);
00776     //try to figure out if we are using sheet bodies
00777     //if it is ambiguous, print a warning.
00778   if(tmp_body_1 && tmp_body_1->is_sheet_body()){
00779     is_sheet_body = true;
00780   }
00781   else if(tmp_body_2 && tmp_body_2->is_sheet_body()){
00782     is_sheet_body = true;
00783   }
00784   if(tmp_body_1 && tmp_body_2 &&
00785      tmp_body_1->is_sheet_body() != tmp_body_2->is_sheet_body())
00786   {
00787     PRINT_WARNING("Geometric boolean requested for a sheet body and a non-sheet body.\n");
00788   }
00789   FacetBody *fbody_ptr;
00790   fbody_ptr = dynamic_cast<FacetBody *>(body_in1);
00791   DLIList<FacetSurface*> facet_surf_list;
00792   fbody_ptr->get_surfaces(facet_surf_list);
00793   
00794   status = facetbody_to_facetbool(facet_surf_list,body_verts,
00795                                 body_connections,&f_c_indices1,
00796                                 fsurfarray1,fcurvearray1);
00797   facet_surf_list.clean_out();                                            
00798 
00799     fbody_ptr = dynamic_cast<FacetBody *>(body_in2);
00800     fbody_ptr->get_surfaces(facet_surf_list);
00801     status = facetbody_to_facetbool(facet_surf_list,body2_verts,
00802                                   body2_connections,&f_c_indices2,
00803                                   fsurfarray2,fcurvearray2);
00804     facet_surf_list.clean_out();                                    
00805 
00806     FBIntersect intersector;
00807     intersector.set_classify_flag(true);
00808     
00809     status = intersector.intersect(body_verts,body_connections,
00810                                     body2_verts,body2_connections,
00811                                     newbodyfacets,newbody2facets,
00812                                     &f_c_indices1,
00813                                     &f_c_indices2);
00814 
00815     std::vector<bool> is_body_1;
00816     status = intersector.gather_by_boolean(vertsout,coordsout,
00817                                      &surfindex,&curveindex,&is_body_1,op);      
00818 
00819      //  If there were no intersections
00820     if ( (vertsout.size() == 0) || (coordsout.size() == 0)) {
00821       intersection_found = false;
00822       return CUBIT_SUCCESS;
00823     }  
00824     //  If there was no body_out, we are just checking if there was any
00825     //  intersection.  If we got this far, there was -- so return.
00826     if ( &body_out == 0 ) return CUBIT_SUCCESS;
00827       
00828     surfs_in_intersection = new bool[1+fsurfarray1.size()];
00829     surfs_in_subtraction = new bool[1+fsurfarray1.size()];
00830     curves_in_intersection = new bool[1+fcurvearray1.size()];
00831     curves_in_subtraction = new bool[1+fcurvearray1.size()];
00832     surfs_in_intersection2 = new bool[1+fsurfarray2.size()];
00833     surfs_in_subtraction2 = new bool[1+fsurfarray2.size()];
00834     curves_in_intersection2 = new bool[1+fcurvearray2.size()];
00835     curves_in_subtraction2 = new bool[1+fcurvearray2.size()];
00836 
00837     unsigned int k;
00838     for ( k = 1; k < 1 + fsurfarray1.size(); k++ ) {
00839         surfs_in_subtraction[k] = surfs_in_intersection[k] = false;
00840     }
00841     for ( k = 1; k < 1 + fcurvearray1.size(); k++ ) {
00842         curves_in_subtraction[k] = curves_in_intersection[k] = false;
00843     }
00844     
00845     for ( k = 1; k < 1 + fsurfarray2.size(); k++ ) {
00846         surfs_in_subtraction2[k] = surfs_in_intersection2[k] = false;
00847     }
00848     for ( k = 1; k < 1 + fcurvearray2.size(); k++ ) {
00849         curves_in_subtraction2[k] = curves_in_intersection2[k] = false;
00850     }
00851      
00852     status = intersector.get_persistent_entity_info(surfs_in_intersection,
00853                                  curves_in_intersection,surfs_in_subtraction,
00854                                  curves_in_subtraction,op,1);
00855      //  If op == unite, the curves ans surfs that are undamaged are those
00856      //  for which xxx_in_intereseciton = 0 false and xxx_in_subtraction == true
00857 
00858     status = intersector.get_persistent_entity_info(surfs_in_intersection2,
00859                                  curves_in_intersection2,surfs_in_subtraction2,
00860                                  curves_in_subtraction2,op,2);
00861 
00862 
00863     for ( k = 0; k < vertsout.size(); k += 3 ) {
00864       new_point = (CubitPoint *) new CubitPointData( vertsout[k],
00865                                                      vertsout[k+1],
00866                                                      vertsout[k+2] );
00867       points.push_back(new_point);
00868     }  
00869     for ( k = 0; k < coordsout.size(); k += 3 ) {    
00870       facet_ptr = new CubitFacetData( points[coordsout[k]],
00871                                       points[coordsout[k+1]],
00872                                       points[coordsout[k+2]] );
00873       int cptr[3];
00874       cptr[0] = curveindex[k];
00875       cptr[1] = curveindex[k+1];
00876       cptr[2] = curveindex[k+2];
00877       TDFacetboolData::add_facetbool_facet( facet_ptr );
00878       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
00879       td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],is_body_1[k/3],
00880               facet_ptr->is_backwards());                                
00881 
00882       facet_list.append( facet_ptr );     
00883     }
00884     points.clear(); //  clear out the points vector since we are through with it.
00885 
00886     FacetModifyEngine *fme = FacetModifyEngine::instance();
00887     int interp_order;
00888     CubitBoolean smooth_non_manifold, split_surfaces;
00889     BodySM *body_ptr;
00890     interp_order = 0;
00891     smooth_non_manifold = CUBIT_TRUE;
00892     split_surfaces = CUBIT_FALSE;
00893       
00894     {
00895         ChollaEngine *cholla_ptr = NULL;
00896 
00897         status = fme->build_cholla_surfaces( facet_list,
00898                                              point_list,
00899                                              -1.0,
00900                                              interp_order,
00901                                              smooth_non_manifold,
00902                                              split_surfaces,
00903                                              cholla_ptr );
00904         if( status == CUBIT_FAILURE )
00905           return status;
00906 
00907         status = fme->finish_facet_Body( cholla_ptr,
00908                                          NULL,
00909                                          -1.0, interp_order,
00910                                          body_ptr);
00911         if( status == CUBIT_FAILURE )
00912           return status;
00913         if ( cholla_ptr )
00914         {
00915             cholla_ptr->delete_me();
00916             delete cholla_ptr;
00917         }
00918     }
00919 
00920     if ( keep_old == false ) {
00921       make_persistents_boolean(body_in2,body_ptr,fsurfarray2,fcurvearray2,
00922                        surfs_in_intersection2,surfs_in_subtraction2,
00923                        curves_in_intersection2,curves_in_subtraction2,op,false);
00924       make_persistents_boolean(body_in1,body_ptr,fsurfarray1,fcurvearray1,
00925                        surfs_in_intersection,surfs_in_subtraction,
00926                        curves_in_intersection,curves_in_subtraction,op,true);
00927 
00928     }
00929 
00930     body_out = body_ptr;
00931       //separate the lumps in the "body_out", these will be converted to
00932       //separate volumes later in the code.
00933     status=separate_lumps(body_out,is_sheet_body);
00934     vertsout.clear();
00935     coordsout.clear();                 
00936     delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
00937     delete [] curves_in_intersection; delete [] curves_in_subtraction;
00938     delete [] surfs_in_intersection2; delete [] surfs_in_subtraction2;
00939     delete [] curves_in_intersection2; delete [] curves_in_subtraction2;
00940                                   
00941   return status; 
00942 
00943 }
00944                            
00945 int FacetboolInterface::findcurve(FacetCurve *curve, 
00946                                   std::vector<FacetCurve *>& fcurvearray)
00947 {
00948 unsigned int i;
00949 
00950   for ( i = 0; i < fcurvearray.size(); i++ ) {
00951     if ( fcurvearray[i] == curve ) {
00952       return i;
00953     }
00954   }
00955   fcurvearray.push_back(curve);
00956   
00957   return fcurvearray.size() - 1;
00958 }
00959 
00960 void FacetboolInterface::make_persistents_webcut(BodySM *body_in, 
00961                                           BodySM *body_out1, 
00962                                           BodySM *body_out2,
00963                                           std::vector<FacetSurface *>& fsurfarray,
00964                                           std::vector<FacetCurve *>& fcurvearray,
00965                                           bool *surfs_in_intersection,
00966                                           bool *surfs_in_subtraction,
00967                                           bool *curves_in_intersection,
00968                                           bool  *curves_in_subtraction
00969                                          )
00970 {
00971 unsigned int k, n;
00972 DLIList<CubitSimpleAttrib> csa_list;
00973 FacetBody *facet_body_in = CAST_TO(body_in, FacetBody);
00974 FacetBody *facet_body_out1;
00975 FacetBody *facet_body_out2;                               
00976 
00977   facet_body_out1 = CAST_TO(body_out1, FacetBody);
00978   facet_body_out2 = CAST_TO(body_out2, FacetBody);                               
00979 
00980 //  Fix the curves.                      
00981 DLIList<FacetCurve*> fcurvelist, fcurvelist2; 
00982 
00983     facet_body_out1->get_curves(fcurvelist);
00984     facet_body_out2->get_curves(fcurvelist2);
00985 
00986   for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
00987     if ( (curves_in_intersection[n] == true) && (curves_in_subtraction[n] == false) ) {
00988       make_persistent_curves(fcurvelist,fcurvearray,n);
00989     } else if ( (curves_in_intersection[n] == false) && 
00990                 (curves_in_subtraction[n] == true) ) {
00991       make_persistent_curves(fcurvelist2,fcurvearray,n);
00992     }
00993   }
00994 
00995 
00996 //  Fix the surfaces
00997 DLIList<FacetSurface*> fsurfaceslist, fsurfaceslist2;
00998     facet_body_out1->get_surfaces(fsurfaceslist);
00999     facet_body_out2->get_surfaces(fsurfaceslist2);
01000 
01001   for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
01002     if ( (surfs_in_intersection[n] == true) && (surfs_in_subtraction[n] == false) ) {
01003       make_persistent_surfaces(fsurfaceslist,fsurfarray,n);                          
01004     } else if ( (surfs_in_intersection[n] == false) && 
01005                 (surfs_in_subtraction[n] == true) ) {
01006       make_persistent_surfaces(fsurfaceslist2,fsurfarray,n);                
01007     }
01008   }
01009 
01010 //  Fix the lumps.
01011 FacetLump *florig, *fl2;
01012 DLIList<FacetLump*> flumplist, flumplist2;
01013     facet_body_in->get_lumps(flumplist);
01014       facet_body_out1->get_lumps(flumplist2);
01015       florig = flumplist.get();
01016       fl2 = flumplist2.get();
01017       if ( florig->owner() ) {
01018         florig->owner()->swap_bridge(florig,fl2,false);
01019         florig->get_simple_attribute(csa_list);
01020         for ( k = csa_list.size(); k > 0; k-- ) {
01021           const CubitSimpleAttrib& csa = csa_list.get_and_step();
01022           fl2->append_simple_attribute_virt(csa);                               
01023         }
01024       }
01025 //  Fix the bodies.
01026     if ( facet_body_in->owner() ) {
01027       facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
01028       facet_body_in->get_simple_attribute(csa_list);
01029       for ( k = csa_list.size(); k > 0; k-- ) {
01030         const CubitSimpleAttrib& csa = csa_list.get_and_step();
01031         facet_body_out1->append_simple_attribute_virt(csa);                               
01032       } 
01033     } 
01034   
01035 }
01036 
01037 void FacetboolInterface::make_persistents_imprint(BodySM *body_in, 
01038                                           BodySM *body_out1, 
01039                                           std::vector<FacetSurface *>& fsurfarray,
01040                                           std::vector<FacetCurve *>& fcurvearray
01041                                          )
01042 {
01043 DLIList<CubitSimpleAttrib> csa_list;
01044 FacetBody *facet_body_in = CAST_TO(body_in, FacetBody);
01045 FacetBody *facet_body_out1 = CAST_TO(body_out1, FacetBody);                                    
01046 unsigned int n;
01047 
01048 //  Fix the curves.                      
01049     DLIList<FacetCurve*> fcurvelist; 
01050     facet_body_out1->get_curves(fcurvelist);
01051 
01052   for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
01053       make_persistent_curves(fcurvelist,fcurvearray,n,0);
01054   }
01055 
01056 
01057 //  Fix the surfaces
01058     DLIList<FacetSurface*> fsurfaceslist;
01059     facet_body_out1->get_surfaces(fsurfaceslist);
01060 
01061   for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
01062       make_persistent_surfaces(fsurfaceslist,fsurfarray,n,0);                          
01063   }
01064  
01065 //  Fix the lumps.
01066 FacetLump *florig, *fl2;
01067 DLIList<FacetLump*> flumplist, flumplist2;
01068 int k;
01069 
01070     facet_body_in->get_lumps(flumplist);
01071       facet_body_out1->get_lumps(flumplist2);
01072       florig = flumplist.get();
01073       fl2 = flumplist2.get();
01074       if ( florig->owner() ) {
01075         florig->owner()->swap_bridge(florig,fl2,false);
01076         florig->get_simple_attribute(csa_list);
01077         for ( k = csa_list.size(); k > 0; k-- ) {
01078           const CubitSimpleAttrib& csa = csa_list.get_and_step();
01079           fl2->append_simple_attribute_virt(csa);                               
01080         }
01081       }
01082 
01083 //  Fix the bodies.
01084     if ( facet_body_in->owner() ) {
01085       facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
01086       facet_body_in->get_simple_attribute(csa_list);
01087       for ( k = csa_list.size(); k > 0; k-- ) {
01088         const CubitSimpleAttrib& csa = csa_list.get_and_step();
01089         facet_body_out1->append_simple_attribute_virt(csa);                               
01090       }
01091     }    
01092 
01093 }
01094 
01095 void FacetboolInterface::make_persistents_boolean(BodySM *body_in, 
01096                                           BodySM *body_out1, 
01097                                           std::vector<FacetSurface *>& fsurfarray,
01098                                           std::vector<FacetCurve *>& fcurvearray,
01099                                           bool *surfs_in_intersection,
01100                                           bool *surfs_in_subtraction,
01101                                           bool *curves_in_intersection,
01102                                           bool  *curves_in_subtraction,
01103                                           const CubitFacetboolOp op,
01104                                           bool body_1
01105                                          )
01106 {
01107   unsigned int n;
01108   DLIList<CubitSimpleAttrib> csa_list;
01109   FacetBody *facet_body_in = CAST_TO(body_in, FacetBody);
01110   FacetBody *facet_body_out1 = CAST_TO(body_out1, FacetBody);
01111   int which_parent;
01112   bool bvalue1 = false, bvalue2 = false;
01113 
01114   if ( body_1 == true ) which_parent = 1;
01115   else which_parent = 2;
01116 
01117   switch (op) {
01118   
01119     case CUBIT_FB_UNION:
01120       bvalue1 = false;
01121       bvalue2 = true;
01122       break;
01123     case CUBIT_FB_INTERSECTION:
01124       bvalue2 = false;
01125       bvalue1 = true;
01126       break;
01127     case CUBIT_FB_SUBTRACTION:
01128       if ( body_1 == true ) {
01129         bvalue2 = false;
01130         bvalue1 = true;
01131       } else {
01132         bvalue1 = false;
01133         bvalue2 = true;
01134       }      
01135       break;      
01136   }      
01137 //  Fix the curves.                      
01138     DLIList<FacetCurve*> fcurvelist; 
01139     facet_body_out1->get_curves(fcurvelist);
01140 
01141   for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
01142     if ( (curves_in_intersection[n] == bvalue1) && 
01143          (curves_in_subtraction[n] == bvalue2) ) {
01144       make_persistent_curves(fcurvelist,fcurvearray,n,which_parent);
01145     }
01146   }
01147 
01148 
01149 //  Fix the surfaces
01150     DLIList<FacetSurface*> fsurfaceslist;
01151     facet_body_out1->get_surfaces(fsurfaceslist);
01152 
01153   for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
01154     if ( (surfs_in_intersection[n] == bvalue1) && 
01155          (surfs_in_subtraction[n] == bvalue2) ) {
01156       make_persistent_surfaces(fsurfaceslist,fsurfarray,n,which_parent);                          
01157     }
01158   }
01159  
01160   if ( body_1 == true ) {
01161 //  Fix the lumps.
01162 FacetLump *florig, *fl2;
01163 DLIList<FacetLump*> flumplist, flumplist2;
01164 int k;
01165 
01166     facet_body_in->get_lumps(flumplist);
01167       facet_body_out1->get_lumps(flumplist2);
01168       florig = flumplist.get();
01169       fl2 = flumplist2.get();
01170       if ( florig->owner() ) {
01171         florig->owner()->swap_bridge(florig,fl2,false);
01172         florig->get_simple_attribute(csa_list);
01173         for ( k = csa_list.size(); k > 0; k-- ) {
01174           const CubitSimpleAttrib& csa = csa_list.get_and_step();
01175           fl2->append_simple_attribute_virt(csa);                               
01176         }
01177       }
01178 
01179 //  Fix the bodies.
01180     if ( facet_body_in->owner() ) {
01181       facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
01182       facet_body_in->get_simple_attribute(csa_list);
01183       for ( k = csa_list.size(); k > 0; k-- ) {
01184         const CubitSimpleAttrib& csa = csa_list.get_and_step();
01185         facet_body_out1->append_simple_attribute_virt(csa);                               
01186       }
01187     }    
01188   }
01189    
01190 }
01191 
01192 void FacetboolInterface::make_persistent_curves(DLIList<FacetCurve*> fcurvelist,
01193                                        std::vector<FacetCurve *>& fcurvearray,
01194                                        int n,
01195                                        int which_parent)
01196 {
01197 int k, m, jj;
01198 FacetCurve *fcurveorig, *fcurve2;
01199 int *marked3, index;
01200 bool ifoundit;
01201 FacetPoint *fpointorig, *fpoint2; 
01202 DLIList<FacetPoint*> fpointlist, fpointlist2; 
01203 CubitFacet *cfac;
01204 DLIList<CubitSimpleAttrib> csa_list;
01205 bool is_from_1, error;
01206 TDFacetboolData* tdf;
01207  
01208   fcurveorig = fcurvearray[n-1];
01209   ifoundit = false;
01210   for ( k = fcurvelist.size(); k > 0; k-- ) {
01211     fcurve2 = fcurvelist.get_and_step();
01212     if ( fcurve2->owner() ) continue;  //  If owner is already set, skip it.
01213     CurveFacetEvalTool *evaltool = fcurve2->get_eval_tool();
01214     DLIList<CubitFacetEdge*> edgelist;
01215     CubitFacetEdge *cfedge;
01216     evaltool->get_facets(edgelist);
01217     cfedge = edgelist.get();
01218     cfac = cfedge->adj_facet(0);
01219     index = cfac->edge_index(cfedge);
01220     tdf = TDFacetboolData::get(cfac);
01221     if ( which_parent ) {
01222       is_from_1 = tdf->parent_is_body_1();
01223       if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
01224            ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
01225     } 
01226     marked3 = tdf->get_edge_indices(cfac->is_backwards());
01227     if ( marked3[(index+1)%3] == n ) ifoundit = true;
01228     else {
01229       cfac = cfedge->adj_facet(1);
01230       if (cfac) {
01231         index = cfac->edge_index(cfedge);
01232         tdf = TDFacetboolData::get(cfac);
01233         if ( which_parent ) {
01234           is_from_1 = tdf->parent_is_body_1();
01235           if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
01236                ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
01237         }         
01238         marked3 = tdf->get_edge_indices(cfac->is_backwards());
01239         if ( marked3[(index+1)%3] == n ) ifoundit = true; 
01240       }
01241     }
01242     if ( ifoundit == true ) {
01243       fpointlist.clean_out();
01244       fpointlist2.clean_out();
01245       fcurveorig->get_points(fpointlist);
01246       fcurve2->get_points(fpointlist2);
01247       for ( jj = fpointlist.size(); jj > 0; jj-- ) {
01248         error = false;
01249         fpointorig = fpointlist.get_and_step();
01250         fpoint2 = fpointlist2.get_and_step();
01251         while ( fpoint2->coordinates() != fpointorig->coordinates() ) {
01252           if ( fpointlist2.is_at_beginning() == CUBIT_TRUE ) {
01253 //            PRINT_WARNING("Unable to make point on curve persistent.\n");
01254             error = true;
01255             break;
01256           } 
01257           fpoint2 = fpointlist2.get_and_step();
01258         }
01259         if ( error == true ) continue;
01260         if ( fpointorig->owner() && !(fpoint2->owner()) ) {
01261           fpointorig->owner()->swap_bridge(fpointorig,fpoint2,false); 
01262           fpointorig->get_simple_attribute(csa_list);
01263           for ( m = csa_list.size(); m > 0; m-- ) {
01264             const CubitSimpleAttrib& csa = csa_list.get_and_step();
01265             fpoint2->append_simple_attribute_virt(csa);                                     
01266           } 
01267         }             
01268       }
01269       if ( fcurveorig->owner() != 0 ) 
01270         fcurveorig->owner()->swap_bridge(fcurveorig,fcurve2,false); 
01271       fcurveorig->get_simple_attribute(csa_list);
01272       for ( m = csa_list.size(); m > 0; m-- ) {
01273         const CubitSimpleAttrib& csa = csa_list.get_and_step();
01274         fcurve2->append_simple_attribute_virt(csa);                                     
01275       }    
01276       break;
01277     }
01278   }
01279 }
01280 
01281 void FacetboolInterface::make_persistent_surfaces(DLIList<FacetSurface*> fsurfaceslist,
01282                             std::vector<FacetSurface *>& fsurfarray,
01283                             int n,
01284                             int which_parent)
01285 {
01286 DLIList<CubitSimpleAttrib> csa_list;
01287 int k, m;
01288 FacetSurface *fsorig, *fsurf2;
01289 bool is_from_1;
01290 
01291   fsorig = fsurfarray[n-1];
01292   for ( k = fsurfaceslist.size(); k > 0; k-- ) {
01293     fsurf2 = fsurfaceslist.get_and_step();
01294     DLIList<CubitFacet*> facet_list2;
01295     fsurf2->tris(facet_list2);
01296     CubitFacet* facet2 = facet_list2.get();
01297     TDFacetboolData* tdf = TDFacetboolData::get(facet2);
01298     if ( which_parent ) {
01299       is_from_1 = tdf->parent_is_body_1();
01300       if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
01301            ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
01302     }
01303     int marked2 = tdf->get_surf_index(); 
01304     if ( marked2 == n ) {
01305       if ( fsorig->owner() != 0 )
01306         fsorig->owner()->swap_bridge(fsorig,fsurf2,false); 
01307       fsorig->get_simple_attribute(csa_list);
01308       for ( m = csa_list.size(); m > 0; m-- ) {
01309         const CubitSimpleAttrib& csa = csa_list.get_and_step();
01310         fsurf2->append_simple_attribute_virt(csa);                               
01311       }    
01312       break;
01313     }
01314   }    
01315 }
01316 
01317 CubitStatus FacetboolInterface::FB_imprint_with_curves(BodySM*& body_in,
01318                              BodySM*& body_out,                             
01319                              bool keep_old)
01320 {
01321 CubitStatus status;
01322 
01323   FacetModifyEngine *fme = FacetModifyEngine::instance();
01324 
01325   FacetBody *fbody_ptr;
01326   fbody_ptr = dynamic_cast<FacetBody *>(body_in);
01327   DLIList<FacetSurface*> facet_surf_list;
01328   fbody_ptr->get_surfaces(facet_surf_list);
01329 std::vector<double> body_verts;
01330 std::vector<int> body_connections, newbodyfacets;
01331 std::vector<int> f_c_indices;
01332 std::vector<FacetSurface *> fsurfarray;
01333 std::vector<FacetCurve *> fcurvearray;
01334 std::vector<double> vertsout;
01335 std::vector<int> coordsout;
01336 std::vector<int> surfindex;  
01337 std::vector<int> curveindex;  
01338   
01339   status = facetbody_to_facetbool(facet_surf_list,body_verts,
01340                                 body_connections,&f_c_indices,
01341                                 fsurfarray,fcurvearray);
01342   facet_surf_list.clean_out();                                            
01343 
01344   FBImprint imprinter;
01345  
01346   status = imprinter.imprint_body_curve(body_verts,body_connections,
01347                                 FB_imprint_edge_coords,FB_imprint_edges,
01348                                 FB_imprint_edge_bboxes,&f_c_indices);            
01349 
01350   status = imprinter.update_surfs_and_curves(vertsout,coordsout,
01351                                           &surfindex,&curveindex);
01352     DLIList <CubitFacet *>facet_list;
01353     DLIList <CubitPoint *>point_list;
01354     CubitPoint *new_point;
01355     CubitFacet *facet_ptr;
01356     std::vector<CubitPoint *> points;
01357 
01358 unsigned int k;
01359     for ( k = 0; k < vertsout.size(); k += 3 ) {
01360       new_point = (CubitPoint *) new CubitPointData( vertsout[k],
01361                                                      vertsout[k+1],
01362                                                      vertsout[k+2] );
01363       points.push_back(new_point);
01364     }  
01365     for ( k = 0; k < coordsout.size(); k += 3 ) {        
01366       facet_ptr = new CubitFacetData( points[coordsout[k]],
01367                                       points[coordsout[k+1]],
01368                                       points[coordsout[k+2]] );
01369       int cptr[3];
01370       cptr[0] = curveindex[k];
01371       cptr[1] = curveindex[k+1];
01372       cptr[2] = curveindex[k+2];
01373       TDFacetboolData::add_facetbool_facet( facet_ptr );
01374       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
01375       td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],false,
01376               facet_ptr->is_backwards());                                
01377 
01378       facet_list.append( facet_ptr );     
01379     }
01380     points.clear(); //  clear out the points vector since we are through with it.
01381       
01382     double feature_angle;
01383     int interp_order;
01384     CubitBoolean smooth_non_manifold, split_surfaces;
01385     feature_angle = 135.0;
01386     interp_order = 0;
01387     smooth_non_manifold = CUBIT_TRUE;
01388     split_surfaces = CUBIT_TRUE;
01389   
01390     {
01391         ChollaEngine *cholla_ptr = NULL;
01392 
01393         status = fme->build_cholla_surfaces( facet_list,
01394                                              point_list,
01395                                              feature_angle,
01396                                              interp_order,
01397                                              smooth_non_manifold,
01398                                              split_surfaces,
01399                                              cholla_ptr );
01400         if( status == CUBIT_FAILURE )
01401           return status;
01402 
01403         status = fme->finish_facet_Body( cholla_ptr,
01404                                          NULL,
01405                                          feature_angle, interp_order,
01406                                          body_out);
01407         if( status == CUBIT_FAILURE )
01408           return status;
01409         if ( cholla_ptr )
01410         {
01411             cholla_ptr->delete_me();
01412             delete cholla_ptr;
01413         }
01414     }
01415 
01416     vertsout.clear();
01417     coordsout.clear();                                 
01418     if ( keep_old == false ) {
01419       make_persistents_imprint(body_in,body_out,fsurfarray,fcurvearray);
01420     }
01421   
01422   return status;
01423 
01424 }
01425 
01426 CubitStatus FacetboolInterface::dofacetboolean_2bodies_imprint(BodySM*& body_in1, 
01427                              BodySM*& body_in2,
01428                              BodySM*& body_out1,
01429                              BodySM*& body_out2,                             
01430                              bool keep_old)
01431 {
01432 CubitStatus status;
01433 std::vector<double> body_verts;
01434 std::vector<double> body2_verts;
01435 std::vector<int> body_connections, newbodyfacets;
01436 std::vector<int>  body2_connections, newbody2facets;
01437 std::vector<double> vertsout1, vertsout2;
01438 std::vector<int> coordsout1, coordsout2;
01439 std::vector<int> f_c_indices1;
01440 std::vector<int> f_c_indices2;
01441 std::vector<FacetSurface *> fsurfarray1, fsurfarray2;
01442 std::vector<FacetCurve *> fcurvearray1, fcurvearray2;
01443 std::vector<int> surfindex1, surfindex2;  
01444 std::vector<int> curveindex1, curveindex2;  
01445  
01446     DLIList <CubitFacet *>facet_list;
01447     DLIList <CubitPoint *>point_list;
01448     CubitPoint *new_point;
01449     CubitFacet *facet_ptr;
01450     std::vector<CubitPoint *> points;
01451 
01452   FacetModifyEngine *fme = FacetModifyEngine::instance();
01453   bool is_sheet_body = false;
01454   Body *tmp_body_1 = CAST_TO(body_in1->topology_entity(), Body);
01455   Body *tmp_body_2 = CAST_TO(body_in2->topology_entity(), Body);
01456   if(tmp_body_1 && tmp_body_1->is_sheet_body()){
01457     is_sheet_body = true;
01458   }
01459   else if(tmp_body_2 && tmp_body_2->is_sheet_body()){
01460     is_sheet_body = true;
01461   }
01462   if(tmp_body_1->is_sheet_body() != tmp_body_2->is_sheet_body())
01463   {
01464     PRINT_WARNING("Geometric boolean requested for a sheet body and a non-sheet body.\n");
01465   }
01466   FacetBody *fbody_ptr;
01467   fbody_ptr = dynamic_cast<FacetBody *>(body_in1);
01468   DLIList<FacetSurface*> facet_surf_list;
01469   fbody_ptr->get_surfaces(facet_surf_list);
01470   
01471   status = facetbody_to_facetbool(facet_surf_list,body_verts,
01472                                 body_connections,&f_c_indices1,
01473                                 fsurfarray1,fcurvearray1);
01474   facet_surf_list.clean_out();                                            
01475 
01476     fbody_ptr = dynamic_cast<FacetBody *>(body_in2);
01477     fbody_ptr->get_surfaces(facet_surf_list);
01478     status = facetbody_to_facetbool(facet_surf_list,body2_verts,
01479                                   body2_connections,&f_c_indices2,
01480                                   fsurfarray2,fcurvearray2);
01481     facet_surf_list.clean_out();                                    
01482 
01483     FBIntersect intersector;
01484     intersector.set_imprint();
01485     status = intersector.intersect(body_verts,body_connections,
01486                                     body2_verts,body2_connections,
01487                                     newbodyfacets,newbody2facets,
01488                                     &f_c_indices1,
01489                                     &f_c_indices2);
01490     status = intersector.update_surfs_and_curves(vertsout1,coordsout1,
01491                                           &surfindex1,&curveindex1,1);
01492     status = intersector.update_surfs_and_curves(vertsout2,coordsout2,
01493                                           &surfindex2,&curveindex2,2);
01494 unsigned int k;
01495     for ( k = 0; k < vertsout1.size(); k += 3 ) {
01496       new_point = (CubitPoint *) new CubitPointData( vertsout1[k],
01497                                                      vertsout1[k+1],
01498                                                      vertsout1[k+2] );
01499       points.push_back(new_point);
01500     }  
01501     for ( k = 0; k < coordsout1.size(); k += 3 ) {        
01502       facet_ptr = new CubitFacetData( points[coordsout1[k]],
01503                                       points[coordsout1[k+1]],
01504                                       points[coordsout1[k+2]] );
01505       int cptr[3];
01506       cptr[0] = curveindex1[k];
01507       cptr[1] = curveindex1[k+1];
01508       cptr[2] = curveindex1[k+2];
01509       TDFacetboolData::add_facetbool_facet( facet_ptr );
01510       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
01511       td->set(surfindex1[k/3],cptr[0],cptr[1],cptr[2],false,
01512               facet_ptr->is_backwards());                                
01513 
01514       facet_list.append( facet_ptr );     
01515     }
01516     points.clear(); //  clear out the points vector since we are through with it.
01517       
01518     double feature_angle;
01519     int interp_order;
01520     CubitBoolean smooth_non_manifold, split_surfaces;
01521     feature_angle = 135.0;
01522     interp_order = 0;
01523     smooth_non_manifold = CUBIT_TRUE;
01524     split_surfaces = CUBIT_FALSE;
01525   
01526     {
01527         ChollaEngine *cholla_ptr = NULL;
01528 
01529         status = fme->build_cholla_surfaces( facet_list,
01530                                              point_list,
01531                                              feature_angle,
01532                                              interp_order,
01533                                              smooth_non_manifold,
01534                                              split_surfaces,
01535                                              cholla_ptr );
01536         if( status == CUBIT_FAILURE )
01537           return status;
01538 
01539         status = fme->finish_facet_Body( cholla_ptr,
01540                                          NULL,
01541                                          feature_angle, interp_order,
01542                                          body_out1);
01543         if( status == CUBIT_FAILURE )
01544           return status;
01545         if ( cholla_ptr )
01546         {
01547             cholla_ptr->delete_me();
01548             delete cholla_ptr;
01549         }
01550     }
01551     vertsout1.clear();
01552     coordsout1.clear();                                 
01553 
01554     facet_list.clean_out();    
01555     for ( k = 0; k < vertsout2.size(); k += 3 ) {
01556       new_point = (CubitPoint *) new CubitPointData( vertsout2[k],
01557                                                    vertsout2[k+1],
01558                                                    vertsout2[k+2] );
01559       points.push_back(new_point);
01560     }  
01561     for ( k = 0; k < coordsout2.size(); k += 3 ) {    
01562       facet_ptr = new CubitFacetData( points[coordsout2[k]],
01563                                       points[coordsout2[k+1]],
01564                                       points[coordsout2[k+2]] );
01565       int cptr[3];
01566       cptr[0] = curveindex2[k];
01567       cptr[1] = curveindex2[k+1];
01568       cptr[2] = curveindex2[k+2];
01569       TDFacetboolData::add_facetbool_facet( facet_ptr );
01570       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
01571       td->set(surfindex2[k/3],cptr[0],cptr[1],cptr[2],false,
01572               facet_ptr->is_backwards());                              
01573       facet_list.append( facet_ptr );     
01574     }
01575     points.clear(); //  clear out the points vector since we are through with it.
01576   
01577     {
01578         ChollaEngine *cholla_ptr = NULL;
01579 
01580         status = fme->build_cholla_surfaces( facet_list,
01581                                              point_list,
01582                                              feature_angle,
01583                                              interp_order,
01584                                              smooth_non_manifold,
01585                                              split_surfaces,
01586                                              cholla_ptr );
01587         if( status == CUBIT_FAILURE )
01588           return status;
01589 
01590         status = fme->finish_facet_Body( cholla_ptr,
01591                                          NULL,
01592                                          feature_angle, interp_order,
01593                                          body_out2);
01594         if( status == CUBIT_FAILURE )
01595           return status;
01596         if ( cholla_ptr )
01597         {
01598             cholla_ptr->delete_me();
01599             delete cholla_ptr;
01600         }
01601     }
01602                                
01603     if ( keep_old == false ) {
01604       make_persistents_imprint(body_in1,body_out1,fsurfarray1,fcurvearray1);
01605       make_persistents_imprint(body_in2,body_out2,fsurfarray2,fcurvearray2);
01606     }
01607     
01608       //separate the lumps in the "body_out1" and "body_out2", these will
01609       //be converted to separate volumes later in the code.
01610     status=separate_lumps(body_out1, is_sheet_body);
01611     status=separate_lumps(body_out2, is_sheet_body);
01612     vertsout2.clear();
01613     coordsout2.clear();                                      
01614 
01615   return status;
01616 }
01617 
01618 CubitStatus FacetboolInterface::make_FB_edge_list(DLIList<Curve*> &ref_edge_list)
01619 {
01620 CubitStatus success = CUBIT_SUCCESS;
01621 Curve *ref_edge_ptr;
01622 FacetCurve *cfcurve;
01623 CubitPoint  *cfpoint;
01624 DLIList<CubitPoint *> cfpointlist;
01625 int i, j, lastvert, nextvert;
01626 CubitVector coords;
01627 
01628    ref_edge_list.reset();
01629    for( i = ref_edge_list.size(); i > 0; i-- )
01630    {
01631       ref_edge_ptr = ref_edge_list.get_and_step();
01632       cfcurve = CAST_TO( ref_edge_ptr, FacetCurve);
01633       cfpointlist.clean_out();
01634       cfcurve->get_points(cfpointlist);
01635       cfpoint = cfpointlist.get_and_step();
01636       coords = cfpoint->coordinates();
01637       lastvert = find_coord(coords.x(),coords.y(),coords.z());
01638       for ( j = cfpointlist.size()-1; j > 0; j-- ) {
01639         cfpoint = cfpointlist.get_and_step();
01640         coords = cfpoint->coordinates();
01641         nextvert = find_coord(coords.x(),coords.y(),coords.z());
01642 
01643           FB_Edge *FBedge = new FB_Edge(lastvert,nextvert,0,0,false);
01644           FSBoundingBox *bb = make_edge_bounding_box(lastvert,nextvert); 
01645           lastvert = nextvert;         
01646           FB_imprint_edges.push_back(FBedge);
01647           FB_imprint_edge_bboxes.push_back(bb);
01648       }
01649    }
01650 
01651   return success;  
01652 }
01653 
01654 int FacetboolInterface::find_coord(double xx, double yy, double zz)
01655 {
01656 int value;
01657 unsigned int i;
01658 
01659   value = -1;
01660   for ( i = 0; i < FB_imprint_edge_coords.size(); i++ ) {
01661     if ( (fabs(FB_imprint_edge_coords[i]->coord[0] - xx) < GEOMETRY_RESABS) &&
01662          (fabs(FB_imprint_edge_coords[i]->coord[1] - yy) < GEOMETRY_RESABS) &&
01663          (fabs(FB_imprint_edge_coords[i]->coord[2] - zz) < GEOMETRY_RESABS) ) {
01664       value = (int)i;
01665       break;
01666     }
01667   }  
01668   if ( value == -1 ) {
01669     value = FB_imprint_edge_coords.size();
01670     FB_Coord *FBcoord = new FB_Coord(xx,yy,zz);
01671     FB_imprint_edge_coords.push_back(FBcoord);
01672   }
01673       
01674   return value;
01675 }
01676 
01677 FSBoundingBox* FacetboolInterface::make_edge_bounding_box(int v0, int v1)
01678 {
01679 FSBoundingBox *bb;
01680 double xmin, ymin, zmin, xmax, ymax, zmax;
01681 
01682   
01683   xmin = ( FB_imprint_edge_coords[v0]->coord[0] < FB_imprint_edge_coords[v1]->coord[0] ) ?
01684            FB_imprint_edge_coords[v0]->coord[0] : FB_imprint_edge_coords[v1]->coord[0];
01685   ymin = ( FB_imprint_edge_coords[v0]->coord[1] < FB_imprint_edge_coords[v1]->coord[1] ) ?
01686            FB_imprint_edge_coords[v0]->coord[1] : FB_imprint_edge_coords[v1]->coord[1];
01687   zmin = ( FB_imprint_edge_coords[v0]->coord[2] < FB_imprint_edge_coords[v1]->coord[2] ) ?
01688            FB_imprint_edge_coords[v0]->coord[2] : FB_imprint_edge_coords[v1]->coord[2];
01689   xmax = ( FB_imprint_edge_coords[v0]->coord[0] > FB_imprint_edge_coords[v1]->coord[0] ) ?
01690            FB_imprint_edge_coords[v0]->coord[0] : FB_imprint_edge_coords[v1]->coord[0];
01691   ymax = ( FB_imprint_edge_coords[v0]->coord[1] > FB_imprint_edge_coords[v1]->coord[1] ) ?
01692            FB_imprint_edge_coords[v0]->coord[1] : FB_imprint_edge_coords[v1]->coord[1];
01693   zmax = ( FB_imprint_edge_coords[v0]->coord[2] > FB_imprint_edge_coords[v1]->coord[2] ) ?
01694            FB_imprint_edge_coords[v0]->coord[2] : FB_imprint_edge_coords[v1]->coord[2];
01695   if ( (xmax - xmin) < 2.0*GEOMETRY_RESABS ) {
01696     xmin -= GEOMETRY_RESABS;
01697     xmax += GEOMETRY_RESABS;
01698   }
01699   if ( (ymax - ymin) < 2.0*GEOMETRY_RESABS ) {
01700     ymin -= GEOMETRY_RESABS;
01701     ymax += GEOMETRY_RESABS;
01702   }              
01703   if ( (zmax - zmin) < 2.0*GEOMETRY_RESABS ) {
01704     zmin -= GEOMETRY_RESABS;
01705     zmax += GEOMETRY_RESABS;
01706   }
01707   
01708   bb = new FSBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax);
01709 
01710   return bb;
01711 
01712 }
01713 
01714 void FacetboolInterface::get_edge_list_bbox(CubitBox& edge_list_bbox)
01715 {
01716 unsigned int i;
01717 double min[3],max[3];
01718 
01719   min[0] = min[1] = min[2] = CUBIT_DBL_MAX - 1.0;
01720   max[0] = max[1] = max[2] = -CUBIT_DBL_MAX;  
01721 
01722   for ( i = 0; i < FB_imprint_edge_coords.size(); i++ ) {
01723     min[0] = ( min[0] < FB_imprint_edge_coords[i]->coord[0] ) ? min[0] : 
01724                     FB_imprint_edge_coords[i]->coord[0];
01725     min[1] = ( min[1] < FB_imprint_edge_coords[i]->coord[1] ) ? min[1] : 
01726                     FB_imprint_edge_coords[i]->coord[1];
01727     min[2] = ( min[2] < FB_imprint_edge_coords[i]->coord[2] ) ? min[2] : 
01728                     FB_imprint_edge_coords[i]->coord[2];                     
01729     max[0] = ( max[0] > FB_imprint_edge_coords[i]->coord[0] ) ? max[0] : 
01730                     FB_imprint_edge_coords[i]->coord[0];
01731     max[1] = ( max[1] > FB_imprint_edge_coords[i]->coord[1] ) ? max[1] : 
01732                     FB_imprint_edge_coords[i]->coord[1];
01733     max[2] = ( max[2] > FB_imprint_edge_coords[i]->coord[2] ) ? max[2] : 
01734                     FB_imprint_edge_coords[i]->coord[2];
01735   }
01736   if ( (max[0] - min[0]) < 2.0*GEOMETRY_RESABS ) {
01737     min[0] -= GEOMETRY_RESABS;
01738     max[0] += GEOMETRY_RESABS;
01739   }
01740   if ( (max[1] - min[1]) < 2.0*GEOMETRY_RESABS ) {
01741     min[1] -= GEOMETRY_RESABS;
01742     max[1] += GEOMETRY_RESABS;
01743   }              
01744   if ( (max[2] - min[2]) < 2.0*GEOMETRY_RESABS ) {
01745     min[2] -= GEOMETRY_RESABS;
01746     max[2] += GEOMETRY_RESABS;
01747   }   
01748   CubitBox box(min,max);
01749   edge_list_bbox = box; 
01750 
01751 }
01752 
01753 
01754 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines