LCOV - code coverage report
Current view: top level - geom/facet - FacetboolInterface.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 1 966 0.1 %
Date: 2020-06-30 00:58:45 Functions: 2 23 8.7 %
Branches: 2 2500 0.1 %

           Branch data     Line data    Source code
       1                 :            : #include "FacetboolInterface.hpp"
       2                 :            : #include "FacetDataUtil.hpp"
       3                 :            : #include "FBDataUtil.hpp"
       4                 :            : #include "FBIntersect.hpp"
       5                 :            : #include "IntegerHash.hpp"
       6                 :            : #include "FacetBody.hpp"
       7                 :            : #include "BodySM.hpp"
       8                 :            : #include "Body.hpp"
       9                 :            : #include "FacetSurface.hpp"
      10                 :            : #include "FBDataUtil.hpp"
      11                 :            : #include "CubitPoint.hpp"
      12                 :            : #include "CubitPointData.hpp"
      13                 :            : #include "CubitFacetData.hpp"
      14                 :            : #include "FacetModifyEngine.hpp"
      15                 :            : #include "FacetQueryEngine.hpp"
      16                 :            : #include "FacetCurve.hpp"
      17                 :            : #include "CubitFacetEdge.hpp"
      18                 :            : #include "TDFacetboolData.hpp"
      19                 :            : #include "CurveFacetEvalTool.hpp"
      20                 :            : #include "FacetPoint.hpp"
      21                 :            : #include "FacetLump.hpp"
      22                 :            : #include "FacetShell.hpp"
      23                 :            : #include "CubitBox.hpp"
      24                 :            : #include "FBImprint.hpp"
      25                 :            : #include "GfxDebug.hpp"
      26                 :            : #include "ChollaEngine.hpp"
      27                 :            : 
      28 [ #  # ][ #  # ]:          0 : FacetboolInterface::FacetboolInterface()
      29                 :            : {
      30                 :            : 
      31                 :          0 : }
      32                 :            : 
      33 [ #  # ][ #  # ]:          0 : FacetboolInterface::~FacetboolInterface()
      34                 :            : {
      35                 :            : 
      36                 :          0 : }
      37                 :            : 
      38                 :            : //===============================================================================
      39                 :            : // Function   : webcut_FB
      40                 :            : // Member Type: PUBLIC
      41                 :            : // Description: webcut a FacetBody with a FacetBool cutter
      42                 :            : // Author     : John Fowler
      43                 :            : // Date       : 02/04
      44                 :            : //===============================================================================
      45                 :          0 : CubitStatus FacetboolInterface::webcut_FB(BodySM *bodysm_ptr,
      46                 :            :                                          std::vector<double>& cutter_verts,
      47                 :            :                                          std::vector<int>& cutter_connections,
      48                 :            :                                          bool cutter_is_plane,
      49                 :            :                                          CubitBoolean delete_bodies,
      50                 :            :                                          CubitBoolean &intersects,
      51                 :            :                                          DLIList<BodySM*>& results_list)
      52                 :            :                                          
      53                 :            : {
      54                 :          0 :   intersects = CUBIT_TRUE;
      55         [ #  # ]:          0 :   DLIList<FacetSurface*> facet_surf_list;
      56 [ #  # ][ #  # ]:          0 :   std::vector<double> body_verts;
      57 [ #  # ][ #  # ]:          0 :   std::vector<int> body_connections, newbodyfacets;
         [ #  # ][ #  # ]
      58 [ #  # ][ #  # ]:          0 :   std::vector<int> newcutterfacets;
      59 [ #  # ][ #  # ]:          0 :   std::vector<int> f_c_indices1;
      60 [ #  # ][ #  # ]:          0 :   std::vector<FacetSurface *> fsurfarray;
      61 [ #  # ][ #  # ]:          0 :   std::vector<FacetCurve *> fcurvearray;
      62                 :            :   CubitStatus status;
      63                 :          0 :   int mydebug = 0;
      64         [ #  # ]:          0 :     FacetModifyEngine *fme = FacetModifyEngine::instance();
      65         [ #  # ]:          0 :     FacetBody *facet_body_ptr = CAST_TO(bodysm_ptr, FacetBody);
      66                 :            : 
      67         [ #  # ]:          0 :     facet_body_ptr->get_surfaces(facet_surf_list);
      68                 :            : 
      69                 :            :     status = facetbody_to_facetbool(facet_surf_list,body_verts,
      70                 :            :                          body_connections,&f_c_indices1,
      71         [ #  # ]:          0 :                          fsurfarray,fcurvearray);
      72         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
      73                 :          0 :       return status;
      74                 :            : 
      75 [ #  # ][ #  # ]:          0 :     FBIntersect intersector;
      76         [ #  # ]:          0 :     intersector.set_classify_flag(true);
      77 [ #  # ][ #  # ]:          0 :     if ( cutter_is_plane == true ) intersector.set_body2_planar();
      78                 :            : 
      79                 :            :     status = intersector.intersect(body_verts,body_connections,
      80                 :            :                                     cutter_verts,cutter_connections,
      81                 :            :                                     newbodyfacets,newcutterfacets,
      82                 :            :                                     &f_c_indices1,
      83         [ #  # ]:          0 :                                     0);
      84         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
      85                 :          0 :       return status;
      86                 :            : 
      87                 :            :     bool *surfs_in_intersection, *surfs_in_subtraction;
      88                 :            :     bool *curves_in_intersection, *curves_in_subtraction;
      89                 :            :     
      90 [ #  # ][ #  # ]:          0 :     surfs_in_intersection = new bool[1+fsurfarray.size()];
      91 [ #  # ][ #  # ]:          0 :     surfs_in_subtraction = new bool[1+fsurfarray.size()];
      92 [ #  # ][ #  # ]:          0 :     curves_in_intersection = new bool[1+fcurvearray.size()];
      93 [ #  # ][ #  # ]:          0 :     curves_in_subtraction = new bool[1+fcurvearray.size()];
      94                 :            :     unsigned int k;
      95 [ #  # ][ #  # ]:          0 :     for ( k = 1; k < 1 + fsurfarray.size(); k++ ) 
      96                 :          0 :         surfs_in_subtraction[k] = surfs_in_intersection[k] = false;
      97 [ #  # ][ #  # ]:          0 :     for ( k = 1; k < 1 + fcurvearray.size(); k++ ) 
      98                 :          0 :         curves_in_subtraction[k] = curves_in_intersection[k] = false;
      99                 :            : 
     100                 :            :     status = intersector.get_persistent_entity_info(surfs_in_intersection,
     101                 :            :                                  curves_in_intersection,surfs_in_subtraction,
     102         [ #  # ]:          0 :                                  curves_in_subtraction,CUBIT_FB_INTERSECTION,1);
     103         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
     104                 :          0 :       return status;
     105                 :            : 
     106         [ #  # ]:          0 :     facet_surf_list.reset();
     107                 :            : 
     108 [ #  # ][ #  # ]:          0 :     std::vector<int> surfindex, surfindex2;  
         [ #  # ][ #  # ]
     109 [ #  # ][ #  # ]:          0 :     std::vector<int> curveindex, curveindex2;  
         [ #  # ][ #  # ]
     110 [ #  # ][ #  # ]:          0 :     std::vector<double> vertsout, vertsout2;
         [ #  # ][ #  # ]
     111 [ #  # ][ #  # ]:          0 :     std::vector<int> coordsout, coordsout2;
         [ #  # ][ #  # ]
     112                 :            :     
     113                 :            :     status = intersector.gather_by_boolean(vertsout,coordsout,
     114                 :            :                                      &surfindex,&curveindex,0,
     115         [ #  # ]:          0 :                                      CUBIT_FB_INTERSECTION);  
     116         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
     117                 :          0 :       return status;
     118                 :            :     status = intersector.gather_by_boolean(vertsout2,coordsout2,
     119                 :            :                                      &surfindex2,&curveindex2,0,
     120         [ #  # ]:          0 :                                      CUBIT_FB_SUBTRACTION);
     121         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
     122                 :          0 :       return status;
     123                 :            : 
     124                 :            :     //  If there were no intersections
     125 [ #  # ][ #  # ]:          0 :     if ( (vertsout.size()  == 0) || (coordsout.size() == 0) ||
         [ #  # ][ #  # ]
                 [ #  # ]
     126 [ #  # ][ #  # ]:          0 :          (vertsout2.size() == 0) || (coordsout2.size() == 0) )
         [ #  # ][ #  # ]
     127                 :            :     {
     128                 :          0 :         intersects = CUBIT_FALSE;
     129 [ #  # ][ #  # ]:          0 :         delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
     130 [ #  # ][ #  # ]:          0 :         delete [] curves_in_intersection; delete [] curves_in_subtraction;
     131                 :          0 :         return CUBIT_SUCCESS;
     132                 :            :     }
     133                 :            : 
     134                 :            :     CubitPoint *new_point;
     135 [ #  # ][ #  # ]:          0 :     std::vector<CubitPoint *> points;
     136                 :            : 
     137 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < vertsout.size(); k += 3 ) {
     138         [ #  # ]:          0 :       new_point = (CubitPoint *) new CubitPointData( vertsout[k],
     139         [ #  # ]:          0 :                                                      vertsout[k+1],
     140 [ #  # ][ #  # ]:          0 :                                                      vertsout[k+2] );
                 [ #  # ]
     141         [ #  # ]:          0 :       points.push_back(new_point);
     142                 :            :     } 
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 :     DLIList <CubitFacet *>facet_list;
     145 [ #  # ][ #  # ]:          0 :     DLIList <CubitPoint *>point_list;
     146                 :            :     CubitFacet *facet_ptr;
     147         [ #  # ]:          0 :     if(mydebug)
     148         [ #  # ]:          0 :       GfxDebug::clear();
     149 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < coordsout.size(); k += 3 ) 
     150                 :            :     {    
     151 [ #  # ][ #  # ]:          0 :       facet_ptr = new CubitFacetData( points[coordsout[k]],
     152 [ #  # ][ #  # ]:          0 :                                       points[coordsout[k+1]],
     153 [ #  # ][ #  # ]:          0 :                                       points[coordsout[k+2]] ); 
         [ #  # ][ #  # ]
     154                 :            :       int cptr[3];
     155         [ #  # ]:          0 :       cptr[0] = curveindex[k];
     156         [ #  # ]:          0 :       cptr[1] = curveindex[k+1];
     157         [ #  # ]:          0 :       cptr[2] = curveindex[k+2];
     158         [ #  # ]:          0 :       TDFacetboolData::add_facetbool_facet( facet_ptr );
     159         [ #  # ]:          0 :       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
     160         [ #  # ]:          0 :       td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],false,
     161 [ #  # ][ #  # ]:          0 :               facet_ptr->is_backwards());
     162         [ #  # ]:          0 :       if(mydebug){
     163         [ #  # ]:          0 :         facet_ptr->debug_draw(CUBIT_YELLOW_INDEX);
     164 [ #  # ][ #  # ]:          0 :         CubitVector tmp1 = points[coordsout[k]]->coordinates();
                 [ #  # ]
     165 [ #  # ][ #  # ]:          0 :         CubitVector tmp2 = points[coordsout[k+1]]->coordinates();
                 [ #  # ]
     166 [ #  # ][ #  # ]:          0 :         CubitVector tmp3 = points[coordsout[k+2]]->coordinates();
                 [ #  # ]
     167                 :            :         
     168         [ #  # ]:          0 :         if(cptr[0]){
     169         [ #  # ]:          0 :           GfxDebug::draw_line(tmp1, tmp2, CUBIT_WHITE_INDEX);
     170                 :            :         }
     171         [ #  # ]:          0 :         if(cptr[1]){
     172         [ #  # ]:          0 :           GfxDebug::draw_line(tmp2, tmp3, CUBIT_GREEN_INDEX);
     173                 :            :         }
     174         [ #  # ]:          0 :         if(cptr[2]){
     175         [ #  # ]:          0 :           GfxDebug::draw_line(tmp3, tmp1, CUBIT_BLUE_INDEX);
     176                 :            :         }
     177                 :            :       }
     178         [ #  # ]:          0 :       facet_list.append( facet_ptr );     
     179                 :            :     }
     180         [ #  # ]:          0 :     if(mydebug){
     181         [ #  # ]:          0 :       GfxDebug::mouse_xforms();
     182                 :            :     }
     183         [ #  # ]:          0 :     points.clear(); //  clear out the points vector since we are through with it.
     184                 :            : 
     185                 :            :     double feature_angle;
     186                 :            :     int interp_order;
     187                 :            :     CubitBoolean smooth_non_manifold, split_surfaces;
     188                 :            :     BodySM *body_ptr, *body_ptr2;
     189                 :            :       //determine if original body is a sheet body
     190 [ #  # ][ #  # ]:          0 :     Body *tmp_body = CAST_TO(bodysm_ptr->topology_entity(), Body);
     191                 :          0 :     bool is_sheet_body = false;
     192 [ #  # ][ #  # ]:          0 :     if( tmp_body->is_sheet_body() ) 
     193                 :          0 :       is_sheet_body = true;
     194                 :            : 
     195                 :            :       //mbrewer:  This is not the best solution.  For now, we are using
     196                 :            :       // a no feature angle unless we are working with a sheet-body.  For
     197                 :            :       // sheet-bodies, however, we are not marking the vertices that
     198                 :            :       // bound curves.  Therefore, if we do not use a feature angle, curves
     199                 :            :       // are not split correctly.  The correct fix would be to mark
     200                 :            :       // the vertices and maintain them through the webcut.
     201         [ #  # ]:          0 :     if( is_sheet_body ) 
     202                 :          0 :       feature_angle = 135.0;
     203                 :            :     else
     204                 :          0 :       feature_angle = 0.0;
     205                 :          0 :     interp_order = 0;
     206                 :          0 :     smooth_non_manifold = CUBIT_TRUE;
     207                 :          0 :     split_surfaces = CUBIT_FALSE;
     208                 :            : 
     209                 :            :     {
     210                 :          0 :         ChollaEngine *cholla_ptr = NULL;
     211                 :            : 
     212                 :            :         status = fme->build_cholla_surfaces( facet_list,
     213                 :            :                                              point_list,
     214                 :            :                                              feature_angle,
     215                 :            :                                              interp_order,
     216                 :            :                                              smooth_non_manifold,
     217                 :            :                                              split_surfaces,
     218 [ #  # ][ #  # ]:          0 :                                              cholla_ptr );
         [ #  # ][ #  # ]
                 [ #  # ]
     219         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
     220                 :          0 :           return status;
     221                 :            : 
     222                 :            :         status = fme->finish_facet_Body( cholla_ptr,
     223                 :            :                                          NULL,
     224                 :            :                                          feature_angle, interp_order,
     225         [ #  # ]:          0 :                                          body_ptr);
     226         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
     227                 :          0 :           return status;
     228                 :            : 
     229         [ #  # ]:          0 :         if ( cholla_ptr )
     230                 :            :         {
     231         [ #  # ]:          0 :             cholla_ptr->delete_me();
     232 [ #  # ][ #  # ]:          0 :             delete cholla_ptr;
     233                 :            :         }
     234                 :            :     }
     235 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> new_bodies;
     236                 :            : 
     237         [ #  # ]:          0 :     status = separate_shells_into_bodies( body_ptr, is_sheet_body, new_bodies );
     238         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
     239                 :          0 :       return status;
     240 [ #  # ][ #  # ]:          0 :     for(k=new_bodies.size(); k--;)
     241 [ #  # ][ #  # ]:          0 :       results_list.append( new_bodies.get_and_step() );  
     242                 :            :       
     243         [ #  # ]:          0 :     vertsout.clear();
     244         [ #  # ]:          0 :     coordsout.clear();                                 
     245                 :            : 
     246         [ #  # ]:          0 :     facet_list.clean_out();    
     247 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < vertsout2.size(); k += 3 ) {
     248         [ #  # ]:          0 :       new_point = (CubitPoint *) new CubitPointData( vertsout2[k],
     249         [ #  # ]:          0 :                                                    vertsout2[k+1],
     250 [ #  # ][ #  # ]:          0 :                                                    vertsout2[k+2] );
                 [ #  # ]
     251         [ #  # ]:          0 :       points.push_back(new_point);
     252                 :            :     }  
     253 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < coordsout2.size(); k += 3 ) {    
     254 [ #  # ][ #  # ]:          0 :       facet_ptr = new CubitFacetData( points[coordsout2[k]],
     255 [ #  # ][ #  # ]:          0 :                                       points[coordsout2[k+1]],
     256 [ #  # ][ #  # ]:          0 :                                       points[coordsout2[k+2]] );
         [ #  # ][ #  # ]
     257                 :            :       int cptr[3];
     258         [ #  # ]:          0 :       cptr[0] = curveindex2[k];
     259         [ #  # ]:          0 :       cptr[1] = curveindex2[k+1];
     260         [ #  # ]:          0 :       cptr[2] = curveindex2[k+2];
     261         [ #  # ]:          0 :       TDFacetboolData::add_facetbool_facet( facet_ptr );
     262         [ #  # ]:          0 :       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
     263         [ #  # ]:          0 :       td->set(surfindex2[k/3],cptr[0],cptr[1],cptr[2],false,
     264 [ #  # ][ #  # ]:          0 :               facet_ptr->is_backwards());
     265         [ #  # ]:          0 :       if(mydebug){
     266 [ #  # ][ #  # ]:          0 :         CubitVector tmp1 = points[coordsout2[k]]->coordinates();
                 [ #  # ]
     267 [ #  # ][ #  # ]:          0 :         CubitVector tmp2 = points[coordsout2[k+1]]->coordinates();
                 [ #  # ]
     268 [ #  # ][ #  # ]:          0 :         CubitVector tmp3 = points[coordsout2[k+2]]->coordinates();
                 [ #  # ]
     269         [ #  # ]:          0 :         if(cptr[0]){
     270         [ #  # ]:          0 :           GfxDebug::draw_line(tmp1, tmp2, CUBIT_WHITE_INDEX);
     271                 :            :         }
     272         [ #  # ]:          0 :         if(cptr[1]){
     273         [ #  # ]:          0 :           GfxDebug::draw_line(tmp2, tmp3, CUBIT_GREEN_INDEX);
     274                 :            :         }
     275         [ #  # ]:          0 :         if(cptr[2]){
     276         [ #  # ]:          0 :           GfxDebug::draw_line(tmp3, tmp1, CUBIT_BLUE_INDEX);
     277                 :            :         }
     278                 :            :       }
     279         [ #  # ]:          0 :       facet_list.append( facet_ptr );     
     280                 :            :     }
     281         [ #  # ]:          0 :     points.clear(); //  clear out the points vector since we are through with it.
     282                 :            : 
     283                 :            :     {
     284                 :          0 :         ChollaEngine *cholla_ptr = NULL;
     285                 :            : 
     286                 :            :         status = fme->build_cholla_surfaces( facet_list,
     287                 :            :                                              point_list,
     288                 :            :                                              feature_angle,
     289                 :            :                                              interp_order,
     290                 :            :                                              smooth_non_manifold,
     291                 :            :                                              split_surfaces,
     292 [ #  # ][ #  # ]:          0 :                                              cholla_ptr );
         [ #  # ][ #  # ]
                 [ #  # ]
     293         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
     294                 :          0 :           return status;
     295                 :            : 
     296                 :            :         status = fme->finish_facet_Body( cholla_ptr,
     297                 :            :                                          NULL,
     298                 :            :                                          feature_angle, interp_order,
     299         [ #  # ]:          0 :                                          body_ptr2);
     300         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
     301                 :          0 :           return status;
     302         [ #  # ]:          0 :         if ( cholla_ptr )
     303                 :            :         {
     304         [ #  # ]:          0 :             cholla_ptr->delete_me();
     305 [ #  # ][ #  # ]:          0 :             delete cholla_ptr;
     306                 :            :         }
     307                 :            :     }
     308         [ #  # ]:          0 :     new_bodies.clean_out();
     309         [ #  # ]:          0 :     status = separate_shells_into_bodies( body_ptr2, is_sheet_body, new_bodies );
     310         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
     311                 :          0 :       return status;
     312 [ #  # ][ #  # ]:          0 :     for(k=new_bodies.size(); k--;)
     313 [ #  # ][ #  # ]:          0 :       results_list.append( new_bodies.get_and_step() );  
     314                 :            :                                
     315         [ #  # ]:          0 :     if ( delete_bodies == CUBIT_TRUE )
     316                 :            :       make_persistents_webcut(bodysm_ptr,body_ptr,body_ptr2,fsurfarray,fcurvearray,
     317                 :            :                        surfs_in_intersection,surfs_in_subtraction,
     318         [ #  # ]:          0 :                        curves_in_intersection,curves_in_subtraction);
     319                 :            : 
     320         [ #  # ]:          0 :     vertsout2.clear();
     321         [ #  # ]:          0 :     coordsout2.clear();                                 
     322                 :            :                               
     323 [ #  # ][ #  # ]:          0 :     delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
     324 [ #  # ][ #  # ]:          0 :     delete [] curves_in_intersection; delete [] curves_in_subtraction;
     325                 :            :       
     326         [ #  # ]:          0 :     return CUBIT_SUCCESS;
     327                 :            : }
     328                 :            : 
     329                 :          0 : CubitStatus FacetboolInterface::separate_lumps( BodySM *body_ptr, 
     330                 :            :                                                 bool is_sheet_body)
     331                 :            : {
     332                 :            :     //get all the shells in 'body_ptr'
     333         [ #  # ]:          0 :     DLIList<FacetShell*> facet_shells;
     334         [ #  # ]:          0 :     FacetBody *facet_body = CAST_TO( body_ptr, FacetBody );
     335         [ #  # ]:          0 :     facet_body->get_shells( facet_shells );
     336                 :            : 
     337                 :            :     // some shells here might contain more than one connected
     338                 :            :     // patch of surfaces...which is illegal.  Separate them into their own shells.
     339                 :          0 :     bool created_shells = false;
     340                 :            :     int k,i;
     341 [ #  # ][ #  # ]:          0 :     for( k=facet_shells.size(); k--; )
     342                 :            :     {
     343         [ #  # ]:          0 :       FacetShell *facet_shell = facet_shells.get_and_step();
     344         [ #  # ]:          0 :       DLIList<FacetSurface*> facet_surfs;
     345         [ #  # ]:          0 :       facet_shell->get_surfaces( facet_surfs );
     346 [ #  # ][ #  # ]:          0 :       DLIList<FacetSurface*> connected_patch;
     347         [ #  # ]:          0 :       int max_num_passes = facet_surfs.size();
     348                 :          0 :       int num_passes=0;  //prevents infinite loop
     349 [ #  # ][ #  # ]:          0 :       while( facet_surfs.size() && num_passes < max_num_passes )
         [ #  # ][ #  # ]
     350                 :            :       {
     351         [ #  # ]:          0 :         connected_patch.clean_out();
     352 [ #  # ][ #  # ]:          0 :         FacetQueryEngine::instance()->get_connected_patch( facet_surfs, connected_patch );
     353                 :            : 
     354         [ #  # ]:          0 :         if( num_passes == 0 ) 
     355                 :            :         {
     356                 :            :           int kk;
     357 [ #  # ][ #  # ]:          0 :           for( kk=connected_patch.size(); kk--; )
     358                 :            :           {
     359         [ #  # ]:          0 :             FacetSurface *f_surf = connected_patch.get_and_step();
     360         [ #  # ]:          0 :             if( is_sheet_body ) 
     361         [ #  # ]:          0 :               f_surf->set_shell_sense( facet_shell, CUBIT_UNKNOWN );
     362                 :            :             else
     363         [ #  # ]:          0 :               f_surf->set_shell_sense( facet_shell, CUBIT_FORWARD );
     364                 :            :           }
     365                 :            :         }
     366                 :            :         else //extract surfaces out of current shell and make them into their own shell
     367                 :            :         {
     368                 :            : 
     369         [ #  # ]:          0 :           facet_shell->disconnect_surfaces( connected_patch ); 
     370                 :            :          
     371         [ #  # ]:          0 :           DLIList<Surface*> tmp_surfs;
     372 [ #  # ][ #  # ]:          0 :           CAST_LIST( connected_patch, tmp_surfs, Surface ); 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     373                 :            :           ShellSM *shellsm_ptr;
     374 [ #  # ][ #  # ]:          0 :           FacetModifyEngine::instance()->make_facet_shell(tmp_surfs, shellsm_ptr);
     375         [ #  # ]:          0 :           if ( shellsm_ptr == NULL )
     376                 :            :           {
     377 [ #  # ][ #  # ]:          0 :             PRINT_ERROR("Problems building facet based shell entity.\n");
         [ #  # ][ #  # ]
     378                 :            :           }
     379                 :            :           else
     380                 :            :           {
     381                 :          0 :             FacetShell *tmp_shell = static_cast<FacetShell*>(shellsm_ptr);
     382                 :            : 
     383                 :            :             int kk;
     384                 :            :             //now for each surface, add sense wrt this new shell
     385 [ #  # ][ #  # ]:          0 :             for( kk=tmp_surfs.size(); kk--;)
     386                 :            :             {
     387 [ #  # ][ #  # ]:          0 :               FacetSurface *tmp_facet_surf = CAST_TO(tmp_surfs.get_and_step(), FacetSurface); 
     388                 :            :               
     389                 :            :               //if it's not a sheet body, tag the surfs wrt the shell, FORWARD
     390         [ #  # ]:          0 :               if( is_sheet_body ) 
     391         [ #  # ]:          0 :                 tmp_facet_surf->set_shell_sense( tmp_shell, CUBIT_UNKNOWN );
     392                 :            :               else
     393         [ #  # ]:          0 :                 tmp_facet_surf->set_shell_sense( tmp_shell, CUBIT_FORWARD );
     394                 :            :             }
     395                 :            : 
     396                 :          0 :             created_shells = true;
     397         [ #  # ]:          0 :             FacetLump *facet_lump = static_cast<FacetLump*>( facet_shell->get_lump() ); 
     398         [ #  # ]:          0 :             facet_lump->add_shell( tmp_shell ); 
     399         [ #  # ]:          0 :           }
     400                 :            :         }
     401                 :          0 :         num_passes++;
     402                 :            :       }
     403         [ #  # ]:          0 :     }
     404                 :            :   
     405                 :          0 :     bool created_lumps = false;
     406 [ #  # ][ #  # ]:          0 :     DLIList<FacetShell*> void_shells; 
     407                 :          0 :     int number_regions = 0;
     408         [ #  # ]:          0 :     if( created_shells )
     409                 :            :     {
     410                 :            :       //determine which shells are regions and which are voids
     411                 :            :       //get a point we know is outside the body
     412         [ #  # ]:          0 :       CubitBox bbox;
     413         [ #  # ]:          0 :       CubitVector centroid;
     414                 :            :       double vol;
     415         [ #  # ]:          0 :       facet_body->mass_properties( centroid, vol );
     416 [ #  # ][ #  # ]:          0 :       FacetQueryEngine::instance()->create_facet_bounding_box( facet_body, bbox );
     417 [ #  # ][ #  # ]:          0 :       CubitVector point_outside = 2*(bbox.maximum() - centroid);  
                 [ #  # ]
     418 [ #  # ][ #  # ]:          0 :       point_outside = centroid + point_outside;
     419                 :            :       
     420         [ #  # ]:          0 :       facet_shells.clean_out();
     421         [ #  # ]:          0 :       facet_body->get_shells( facet_shells );
     422 [ #  # ][ #  # ]:          0 :       for( k=facet_shells.size(); k--; )
     423                 :            :       {
     424         [ #  # ]:          0 :         FacetShell *facet_shell = facet_shells.get_and_step();
     425                 :            :         CubitPointContainment point_cont;
     426         [ #  # ]:          0 :         point_cont = facet_shell->point_containment( point_outside );
     427                 :            : 
     428         [ #  # ]:          0 :         if( point_cont == CUBIT_PNT_OUTSIDE )
     429                 :          0 :           number_regions++;
     430         [ #  # ]:          0 :         else if( point_cont == CUBIT_PNT_INSIDE )
     431         [ #  # ]:          0 :           void_shells.append( facet_shell ); 
     432                 :            : 
     433                 :            :         //is a region...if it is the second found region, should be 
     434                 :            :         //in its own lump
     435 [ #  # ][ #  # ]:          0 :         if( number_regions>1 && point_cont == CUBIT_PNT_OUTSIDE ) 
     436                 :            :         {
     437                 :          0 :           created_lumps = true;
     438                 :            :         
     439                 :            :           //remove this shell from its current Lump
     440         [ #  # ]:          0 :           FacetLump *tmp_lump = static_cast<FacetLump*>(facet_shell->get_lump());
     441         [ #  # ]:          0 :           tmp_lump->remove_shell( facet_shell ); 
     442                 :            : 
     443                 :            :           //make a new lump containing this shell
     444                 :            :           Lump *new_lump;
     445         [ #  # ]:          0 :           DLIList<ShellSM*> sm_shells;
     446         [ #  # ]:          0 :           sm_shells.append( static_cast<ShellSM*>(facet_shell) );
     447 [ #  # ][ #  # ]:          0 :           FacetModifyEngine::instance()->make_facet_lump( sm_shells, new_lump );
     448                 :            : 
     449                 :            :           //add lump to body
     450 [ #  # ][ #  # ]:          0 :           facet_body->add_lump( static_cast<FacetLump*>(new_lump) );
     451                 :            :         }
     452         [ #  # ]:          0 :       }
     453                 :            :     }
     454                 :            : 
     455 [ #  # ][ #  # ]:          0 :     if( void_shells.size() && created_lumps )
         [ #  # ][ #  # ]
     456                 :            :     {
     457                 :            :       //the void shells are still in the original lump.  We need to pair each 
     458                 :            :       //up with the region that encloses it 
     459                 :            :       
     460                 :            :       //make a list of all the region (non-void) shells in the body
     461         [ #  # ]:          0 :       DLIList<FacetShell*> region_shells; 
     462         [ #  # ]:          0 :       facet_body->get_shells( region_shells );
     463 [ #  # ][ #  # ]:          0 :       for(k=void_shells.size(); k--;)
     464                 :            :       {
     465 [ #  # ][ #  # ]:          0 :         if( region_shells.move_to( void_shells.get_and_step() ) )
                 [ #  # ]
     466         [ #  # ]:          0 :           region_shells.change_to( NULL );
     467                 :            :       }
     468         [ #  # ]:          0 :       region_shells.remove_all_with_value( NULL );
     469                 :            :     
     470                 :            :       //for each void lump...find the region that contains it
     471 [ #  # ][ #  # ]:          0 :       for( k=void_shells.size(); k--; )
     472                 :            :       {
     473         [ #  # ]:          0 :         FacetShell *void_shell = void_shells.get_and_step();
     474                 :            : 
     475                 :            :         //get a point on the void
     476         [ #  # ]:          0 :         DLIList<FacetSurface*> tmp_surfs;
     477         [ #  # ]:          0 :         void_shell->get_surfaces( tmp_surfs );
     478         [ #  # ]:          0 :         CubitVector point_on_shell;
     479                 :            :         
     480 [ #  # ][ #  # ]:          0 :         DLIList<CubitFacet*> facet_list;
     481 [ #  # ][ #  # ]:          0 :         tmp_surfs.get()->tris( facet_list );
     482                 :            :         
     483 [ #  # ][ #  # ]:          0 :         point_on_shell = facet_list.get()->center();
                 [ #  # ]
     484                 :            : 
     485                 :            :         //get the region that contains that point
     486 [ #  # ][ #  # ]:          0 :         for( i=region_shells.size(); i--; )
     487                 :            :         {
     488         [ #  # ]:          0 :           FacetShell *region_shell = region_shells.get_and_step();
     489                 :            : 
     490         [ #  # ]:          0 :           tmp_surfs.clean_out();
     491         [ #  # ]:          0 :           region_shell->get_surfaces( tmp_surfs );
     492                 :            : 
     493 [ #  # ][ #  # ]:          0 :           if( region_shell->point_containment( point_on_shell ) 
     494                 :            :                                                         == CUBIT_PNT_INSIDE )
     495                 :            :           {
     496                 :            :             //remove the void shell from it's lump
     497         [ #  # ]:          0 :             FacetLump *tmp_lump = static_cast<FacetLump*>(void_shell->get_lump());
     498         [ #  # ]:          0 :             tmp_lump->remove_shell( void_shell ); 
     499                 :            : 
     500                 :            :             //add the void shell to the region's lump
     501         [ #  # ]:          0 :             tmp_lump = static_cast<FacetLump*>(region_shell->get_lump());
     502         [ #  # ]:          0 :             tmp_lump->add_shell( void_shell ); 
     503                 :          0 :             break;
     504                 :            :           }
     505                 :            :         }
     506 [ #  # ][ #  # ]:          0 :       }
     507                 :            :     }
     508         [ #  # ]:          0 :     return CUBIT_SUCCESS;
     509                 :            : }
     510                 :            : 
     511                 :          0 : CubitStatus FacetboolInterface::separate_shells_into_bodies(BodySM *body_ptr,
     512                 :            :                                                             bool is_sheet_body,
     513                 :            :                                                  DLIList<BodySM*> &new_bodies)
     514                 :            : {
     515                 :            :     //first separate the body into its lumps
     516 [ #  # ][ #  # ]:          0 :   if(!separate_lumps(body_ptr,is_sheet_body))
     517                 :          0 :     return CUBIT_FAILURE;
     518                 :            :   
     519                 :            :     //split out each lump into it's own body
     520         [ #  # ]:          0 :   DLIList<BodySM*> split_bodies;
     521 [ #  # ][ #  # ]:          0 :   FacetModifyEngine::instance()->split_body( body_ptr, split_bodies);
     522         [ #  # ]:          0 :   new_bodies += split_bodies;
     523                 :            :   
     524         [ #  # ]:          0 :   return CUBIT_SUCCESS;
     525                 :            : }    
     526                 :            : 
     527                 :          0 : CubitStatus FacetboolInterface::facetbody_to_facetbool(
     528                 :            :                                DLIList<FacetSurface*> &facet_surf_list,
     529                 :            :                                std::vector<double> &body_verts,
     530                 :            :                                std::vector<int> &body_connections,
     531                 :            :                                std::vector<int> *f_c_indices,
     532                 :            :                                std::vector<FacetSurface *>& fsurfarray,
     533                 :            :                                std::vector<FacetCurve *>& fcurvearray
     534                 :            :                                )
     535                 :            : {
     536                 :            :   CubitStatus status;
     537                 :          0 :   int mydebug = 0;
     538                 :            :   
     539         [ #  # ]:          0 :   if(mydebug){
     540         [ #  # ]:          0 :     GfxDebug::clear();
     541                 :            :   }
     542                 :            :   int i, j, k, m, n, vtx[3], hashvalue, *hasharrayptr, hasharraysize, ifoundit;
     543                 :            :   IntegerHash *hashobj;
     544                 :            :   double xx, yy, zz, xval, yval, zval;
     545                 :            :   FacetSurface *facet_surface; 
     546         [ #  # ]:          0 :   DLIList<CubitFacet*> facetlist; 
     547 [ #  # ][ #  # ]:          0 :   DLIList<CubitFacetEdge*> c_edgelist, f_edgelist;
         [ #  # ][ #  # ]
     548 [ #  # ][ #  # ]:          0 :   DLIList<FacetCurve *> curve_list;
     549                 :            :   CubitPoint *point;
     550                 :            :   CubitFacet *facet;
     551                 :            :   FacetCurve *curve;
     552                 :            :   CubitFacetEdge *c_edge, *edge;
     553                 :            :   int numhashbins, c_index;
     554                 :            : 
     555                 :          0 :   numhashbins = 101;
     556                 :          0 :   status = CUBIT_SUCCESS;
     557 [ #  # ][ #  # ]:          0 :   hashobj = new IntegerHash(numhashbins,20);
     558                 :            :                                           
     559 [ #  # ][ #  # ]:          0 :   for ( i = 0; i < facet_surf_list.size(); i++ ) {
     560         [ #  # ]:          0 :     facet_surface = facet_surf_list.get_and_step();
     561         [ #  # ]:          0 :     fsurfarray.push_back(facet_surface); 
     562         [ #  # ]:          0 :     facet_surface->get_my_facetedges(f_edgelist);
     563 [ #  # ][ #  # ]:          0 :     for ( m = f_edgelist.size(); m > 0; m-- ) {
     564         [ #  # ]:          0 :       edge = f_edgelist.get_and_step();
     565         [ #  # ]:          0 :       edge->set_flag(0); //  Initialize edge flags.
     566         [ #  # ]:          0 :       if(mydebug)
     567         [ #  # ]:          0 :         edge->debug_draw(CUBIT_PINK_INDEX);
     568                 :            :     }
     569                 :            :     //  Assume that each facet surf occurs only once, so there won't be
     570                 :            :     //  duplicates on fsarray.
     571         [ #  # ]:          0 :     facetlist.clean_out();
     572         [ #  # ]:          0 :     facet_surface->tris(facetlist);
     573         [ #  # ]:          0 :     curve_list.clean_out();
     574         [ #  # ]:          0 :     facet_surface->get_curves(curve_list);
     575 [ #  # ][ #  # ]:          0 :     for ( m = 0; m < curve_list.size(); m++ ) {    
     576         [ #  # ]:          0 :       curve = curve_list.get_and_step();
     577         [ #  # ]:          0 :       c_index = findcurve(curve,fcurvearray);
     578         [ #  # ]:          0 :       c_edgelist.clean_out();
     579         [ #  # ]:          0 :       curve->get_facets(c_edgelist);
     580 [ #  # ][ #  # ]:          0 :       for ( n = c_edgelist.size(); n > 0; n-- ) {
     581         [ #  # ]:          0 :         c_edge = c_edgelist.get_and_step();
     582         [ #  # ]:          0 :         c_edge->set_flag(c_index+1);
     583         [ #  # ]:          0 :         if(mydebug)
     584         [ #  # ]:          0 :           c_edge->debug_draw(CUBIT_RED_INDEX);
     585                 :            :         
     586                 :            :       }
     587                 :            :     }
     588                 :            :     int efindex[3];
     589 [ #  # ][ #  # ]:          0 :     for ( j = facetlist.size(); j > 0; j-- ) {
     590         [ #  # ]:          0 :       facet = facetlist.get_and_step();
     591         [ #  # ]:          0 :       for ( k = 0; k < 3; k++ ) {
     592         [ #  # ]:          0 :         point = facet->point(k);
     593         [ #  # ]:          0 :         edge = facet->edge(k);
     594         [ #  # ]:          0 :         if(mydebug){
     595 [ #  # ][ #  # ]:          0 :           if(edge->get_flag()){
     596         [ #  # ]:          0 :             edge->debug_draw(CUBIT_WHITE_INDEX);
     597                 :            :           }
     598                 :            :         }
     599         [ #  # ]:          0 :         efindex[k] = edge->get_flag();
     600         [ #  # ]:          0 :         xx = point->x(); 
     601         [ #  # ]:          0 :         yy = point->y();
     602         [ #  # ]:          0 :         zz = point->z();
     603                 :            :         //  Get a vertex number.
     604         [ #  # ]:          0 :         hashvalue = FBDataUtil::makeahashvaluefrom_coord(xx,yy,zz,numhashbins);
     605         [ #  # ]:          0 :         hasharrayptr = hashobj->getHashBin(hashvalue,&hasharraysize);
     606                 :          0 :         ifoundit = -1;
     607         [ #  # ]:          0 :         for ( m = 0; m < hasharraysize; m++ ) {
     608                 :          0 :           n = hasharrayptr[m];
     609         [ #  # ]:          0 :           xval = body_verts[3*n];
     610         [ #  # ]:          0 :           yval = body_verts[3*n+1];
     611         [ #  # ]:          0 :           zval = body_verts[3*n+2];
     612 [ #  # ][ #  # ]:          0 :           if ( ( fabs(xval-xx) < 1.e-6 ) && 
     613         [ #  # ]:          0 :           ( fabs(yval-yy) < 1.e-6 ) &&
     614                 :          0 :           ( fabs(zval-zz) < 1.e-6 ) ) {
     615                 :          0 :             ifoundit = n;
     616                 :          0 :             break;
     617                 :            :           }
     618                 :            :         }
     619         [ #  # ]:          0 :         if ( ifoundit == -1 ) {
     620         [ #  # ]:          0 :           ifoundit = body_verts.size()/3;
     621         [ #  # ]:          0 :           body_verts.push_back(xx);
     622         [ #  # ]:          0 :           body_verts.push_back(yy);
     623         [ #  # ]:          0 :           body_verts.push_back(zz);
     624         [ #  # ]:          0 :           hashobj->addtoHashList(hashvalue,ifoundit);
     625                 :            :         }
     626                 :          0 :         vtx[k] = ifoundit;
     627                 :            :       }
     628         [ #  # ]:          0 :       body_connections.push_back(vtx[0]);
     629         [ #  # ]:          0 :       body_connections.push_back(vtx[1]);
     630         [ #  # ]:          0 :       body_connections.push_back(vtx[2]);
     631         [ #  # ]:          0 :       f_c_indices->push_back(i+1); //  put the surface index for the facet
     632         [ #  # ]:          0 :       f_c_indices->push_back(efindex[2]); //  edge indices for the facet
     633         [ #  # ]:          0 :       f_c_indices->push_back(efindex[0]);
     634         [ #  # ]:          0 :       f_c_indices->push_back(efindex[1]);            
     635                 :            :     }    
     636                 :            :   }
     637         [ #  # ]:          0 :   if(mydebug)
     638         [ #  # ]:          0 :     GfxDebug::mouse_xforms();
     639 [ #  # ][ #  # ]:          0 :   delete hashobj;   
     640         [ #  # ]:          0 :   return status;
     641                 :            :   
     642                 :            : }
     643                 :            : 
     644                 :            : //===============================================================================
     645                 :            : // Function   : dofacetboolean
     646                 :            : // Member Type: PUBLIC
     647                 :            : // Description: do facetboolean operations on a list of bodies.
     648                 :            : // Author     : John Fowler
     649                 :            : // Date       : 02/04
     650                 :            : //===============================================================================
     651                 :          0 : CubitStatus FacetboolInterface::dofacetboolean(DLIList<BodySM*>& body_list, 
     652                 :            :                              BodySM*& newBody,
     653                 :            :                              bool keep_old,
     654                 :            :                              const CubitFacetboolOp op)
     655                 :            : {
     656                 :            :   int k;
     657                 :            :   BodySM *body_sm1, *body_sm2, *body_out;
     658                 :          0 :   CubitStatus status = CUBIT_FAILURE;
     659                 :          0 :   bool intersection_found = false;
     660                 :            : 
     661         [ #  # ]:          0 :   body_sm1 = body_list.get_and_step();
     662                 :            : 
     663 [ #  # ][ #  # ]:          0 :   for ( k = body_list.size() - 1; k > 0; k-- ) {
     664                 :          0 :     body_out =0;
     665         [ #  # ]:          0 :     if(!body_sm1)
     666         [ #  # ]:          0 :       body_sm1=body_list.get_and_step();
     667                 :            :     else{
     668         [ #  # ]:          0 :       body_sm2 = body_list.get_and_step();  
     669                 :            :       status = dofacetboolean_2bodies(body_sm1,body_sm2,body_out,keep_old,
     670         [ #  # ]:          0 :                                       intersection_found,op);
     671         [ #  # ]:          0 :       if ( keep_old == false){
     672                 :            :           //if there was an intersection, we want to delete the two
     673                 :            :           //original bodies if we are not keeping old.
     674                 :            :           //Also, if we we were performing an INTERSECTION we
     675                 :            :           //want to delete the two original bodies even if there was
     676                 :            :           //no intersection between the two bodies (again if we
     677                 :            :           //are not keeping originals).
     678 [ #  # ][ #  # ]:          0 :         if(intersection_found == true || op == CUBIT_FB_INTERSECTION)  { 
     679         [ #  # ]:          0 :           FacetQueryEngine::instance()->
     680         [ #  # ]:          0 :             delete_solid_model_entities(body_sm2);
     681         [ #  # ]:          0 :           FacetQueryEngine::instance()->
     682         [ #  # ]:          0 :             delete_solid_model_entities(body_sm1);
     683                 :          0 :           body_sm2=NULL;
     684                 :          0 :           body_sm1=NULL;
     685                 :            :         }
     686                 :            :           //if we are not keeping old, we want to delete the second
     687                 :            :           //body even if there was no intersection between the two
     688                 :            :           //bodies (for a subtration).
     689         [ #  # ]:          0 :         else if(op == CUBIT_FB_SUBTRACTION)  { 
     690         [ #  # ]:          0 :           FacetQueryEngine::instance()->
     691         [ #  # ]:          0 :             delete_solid_model_entities(body_sm2);
     692                 :          0 :           body_sm2=NULL;
     693                 :            :         }
     694                 :            :       }
     695                 :            :         
     696         [ #  # ]:          0 :       if ( body_out ) body_sm1 = body_out;
     697                 :            :     }
     698                 :            :   }  
     699                 :          0 :   newBody = body_sm1;
     700                 :            :   
     701                 :          0 :   return status;  
     702                 :            : }
     703                 :            : 
     704                 :            : //===============================================================================
     705                 :            : // Function   : dofacetboolean_subtract
     706                 :            : // Member Type: PUBLIC
     707                 :            : // Description: do facetboolean subtract operations on a list of bodies.
     708                 :            : // Author     : John Fowler
     709                 :            : // Date       : 02/04
     710                 :            : //===============================================================================
     711                 :          0 : CubitStatus FacetboolInterface::dofacetboolean_subtract(BodySM*& tool_body, 
     712                 :            :                                       DLIList<BodySM*>& from_bodies,
     713                 :            :                                       DLIList<BodySM*>& new_bodies,
     714                 :            :                                       bool keep_old,
     715                 :            :                                       bool* to_be_deleted,
     716                 :            :                                       const CubitFacetboolOp op)
     717                 :            : {
     718                 :            :   int k;
     719                 :            :   BodySM *body_sm2, *body_out;
     720                 :          0 :   CubitStatus status = CUBIT_FAILURE;
     721                 :          0 :   bool intersection_found = false;
     722                 :            : 
     723 [ #  # ][ #  # ]:          0 :   for ( k = 0; k < from_bodies.size(); k++ ) {
     724                 :          0 :     body_out = 0;  
     725         [ #  # ]:          0 :     body_sm2 = from_bodies.get_and_step();  
     726                 :            :     status = dofacetboolean_2bodies(body_sm2,tool_body,body_out,keep_old,
     727         [ #  # ]:          0 :                             intersection_found,op);
     728 [ #  # ][ #  # ]:          0 :     if ( (keep_old == false) && (intersection_found == true) ) { 
     729                 :          0 :       to_be_deleted[k] = true;
     730                 :            :     }
     731                 :            : 
     732 [ #  # ][ #  # ]:          0 :     if ( (status == CUBIT_SUCCESS) && (body_out) ) new_bodies.append(body_out);
                 [ #  # ]
     733                 :            :   }  
     734                 :            :  
     735                 :          0 :   return status;  
     736                 :            : }
     737                 :            : 
     738                 :          0 : CubitStatus FacetboolInterface::dofacetboolean_2bodies(BodySM*& body_in1, 
     739                 :            :                              BodySM*& body_in2,
     740                 :            :                              BodySM*& body_out,
     741                 :            :                              bool keep_old,
     742                 :            :                              bool& intersection_found,
     743                 :            :                              const CubitFacetboolOp op)
     744                 :            : {
     745                 :            : 
     746                 :            : CubitStatus status;
     747         [ #  # ]:          0 : std::vector<double> body_verts;
     748 [ #  # ][ #  # ]:          0 : std::vector<double> body2_verts;
     749 [ #  # ][ #  # ]:          0 : std::vector<int> body_connections, newbodyfacets;
         [ #  # ][ #  # ]
     750 [ #  # ][ #  # ]:          0 : std::vector<int>  body2_connections, newbody2facets;
         [ #  # ][ #  # ]
     751 [ #  # ][ #  # ]:          0 : std::vector<double> vertsout;
     752 [ #  # ][ #  # ]:          0 : std::vector<int> coordsout;
     753 [ #  # ][ #  # ]:          0 : std::vector<int> f_c_indices1;
     754 [ #  # ][ #  # ]:          0 : std::vector<int> f_c_indices2;
     755 [ #  # ][ #  # ]:          0 : std::vector<FacetSurface *> fsurfarray1, fsurfarray2;
         [ #  # ][ #  # ]
     756 [ #  # ][ #  # ]:          0 : std::vector<FacetCurve *> fcurvearray1, fcurvearray2;
         [ #  # ][ #  # ]
     757 [ #  # ][ #  # ]:          0 : std::vector<int> surfindex;  
     758 [ #  # ][ #  # ]:          0 : std::vector<int> curveindex;
     759                 :            :  
     760                 :            :  
     761 [ #  # ][ #  # ]:          0 :     DLIList <CubitFacet *>facet_list;
     762 [ #  # ][ #  # ]:          0 :     DLIList <CubitPoint *>point_list;
     763                 :            :     CubitPoint *new_point;
     764                 :            :     CubitFacet *facet_ptr;
     765 [ #  # ][ #  # ]:          0 :     std::vector<CubitPoint *> points;
     766                 :            :     bool *surfs_in_intersection, *surfs_in_subtraction;
     767                 :            :     bool *curves_in_intersection, *curves_in_subtraction;
     768                 :            :     bool *surfs_in_intersection2, *surfs_in_subtraction2;
     769                 :            :     bool *curves_in_intersection2, *curves_in_subtraction2;
     770                 :            : 
     771                 :          0 :   status = CUBIT_SUCCESS;
     772                 :          0 :   intersection_found = true;
     773                 :          0 :   bool is_sheet_body = false;
     774 [ #  # ][ #  # ]:          0 :   Body *tmp_body_1 = CAST_TO(body_in1->topology_entity(), Body);
     775 [ #  # ][ #  # ]:          0 :   Body *tmp_body_2 = CAST_TO(body_in2->topology_entity(), Body);
     776                 :            :     //try to figure out if we are using sheet bodies
     777                 :            :     //if it is ambiguous, print a warning.
     778 [ #  # ][ #  # ]:          0 :   if(tmp_body_1 && tmp_body_1->is_sheet_body()){
         [ #  # ][ #  # ]
     779                 :          0 :     is_sheet_body = true;
     780                 :            :   }
     781 [ #  # ][ #  # ]:          0 :   else if(tmp_body_2 && tmp_body_2->is_sheet_body()){
         [ #  # ][ #  # ]
     782                 :          0 :     is_sheet_body = true;
     783                 :            :   }
     784 [ #  # ][ #  # ]:          0 :   if(tmp_body_1 && tmp_body_2 &&
         [ #  # ][ #  # ]
     785 [ #  # ][ #  # ]:          0 :      tmp_body_1->is_sheet_body() != tmp_body_2->is_sheet_body())
     786                 :            :   {
     787 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("Geometric boolean requested for a sheet body and a non-sheet body.\n");
         [ #  # ][ #  # ]
     788                 :            :   }
     789                 :            :   FacetBody *fbody_ptr;
     790         [ #  # ]:          0 :   fbody_ptr = dynamic_cast<FacetBody *>(body_in1);
     791 [ #  # ][ #  # ]:          0 :   DLIList<FacetSurface*> facet_surf_list;
     792         [ #  # ]:          0 :   fbody_ptr->get_surfaces(facet_surf_list);
     793                 :            :   
     794                 :            :   status = facetbody_to_facetbool(facet_surf_list,body_verts,
     795                 :            :                                 body_connections,&f_c_indices1,
     796         [ #  # ]:          0 :                                 fsurfarray1,fcurvearray1);
     797         [ #  # ]:          0 :   facet_surf_list.clean_out();                                            
     798                 :            : 
     799         [ #  # ]:          0 :     fbody_ptr = dynamic_cast<FacetBody *>(body_in2);
     800         [ #  # ]:          0 :     fbody_ptr->get_surfaces(facet_surf_list);
     801                 :            :     status = facetbody_to_facetbool(facet_surf_list,body2_verts,
     802                 :            :                                   body2_connections,&f_c_indices2,
     803         [ #  # ]:          0 :                                   fsurfarray2,fcurvearray2);
     804         [ #  # ]:          0 :     facet_surf_list.clean_out();                                    
     805                 :            : 
     806 [ #  # ][ #  # ]:          0 :     FBIntersect intersector;
     807         [ #  # ]:          0 :     intersector.set_classify_flag(true);
     808                 :            :     
     809                 :            :     status = intersector.intersect(body_verts,body_connections,
     810                 :            :                                     body2_verts,body2_connections,
     811                 :            :                                     newbodyfacets,newbody2facets,
     812                 :            :                                     &f_c_indices1,
     813         [ #  # ]:          0 :                                     &f_c_indices2);
     814                 :            : 
     815 [ #  # ][ #  # ]:          0 :     std::vector<bool> is_body_1;
     816                 :            :     status = intersector.gather_by_boolean(vertsout,coordsout,
     817         [ #  # ]:          0 :                                      &surfindex,&curveindex,&is_body_1,op);      
     818                 :            : 
     819                 :            :      //  If there were no intersections
     820 [ #  # ][ #  # ]:          0 :     if ( (vertsout.size() == 0) || (coordsout.size() == 0)) {
         [ #  # ][ #  # ]
                 [ #  # ]
     821                 :          0 :       intersection_found = false;
     822                 :          0 :       return CUBIT_SUCCESS;
     823                 :            :     }  
     824                 :            :     //  If there was no body_out, we are just checking if there was any
     825                 :            :     //  intersection.  If we got this far, there was -- so return.
     826         [ #  # ]:          0 :     if ( &body_out == 0 ) return CUBIT_SUCCESS;
     827                 :            :       
     828 [ #  # ][ #  # ]:          0 :     surfs_in_intersection = new bool[1+fsurfarray1.size()];
     829 [ #  # ][ #  # ]:          0 :     surfs_in_subtraction = new bool[1+fsurfarray1.size()];
     830 [ #  # ][ #  # ]:          0 :     curves_in_intersection = new bool[1+fcurvearray1.size()];
     831 [ #  # ][ #  # ]:          0 :     curves_in_subtraction = new bool[1+fcurvearray1.size()];
     832 [ #  # ][ #  # ]:          0 :     surfs_in_intersection2 = new bool[1+fsurfarray2.size()];
     833 [ #  # ][ #  # ]:          0 :     surfs_in_subtraction2 = new bool[1+fsurfarray2.size()];
     834 [ #  # ][ #  # ]:          0 :     curves_in_intersection2 = new bool[1+fcurvearray2.size()];
     835 [ #  # ][ #  # ]:          0 :     curves_in_subtraction2 = new bool[1+fcurvearray2.size()];
     836                 :            : 
     837                 :            :     unsigned int k;
     838 [ #  # ][ #  # ]:          0 :     for ( k = 1; k < 1 + fsurfarray1.size(); k++ ) {
     839                 :          0 :         surfs_in_subtraction[k] = surfs_in_intersection[k] = false;
     840                 :            :     }
     841 [ #  # ][ #  # ]:          0 :     for ( k = 1; k < 1 + fcurvearray1.size(); k++ ) {
     842                 :          0 :         curves_in_subtraction[k] = curves_in_intersection[k] = false;
     843                 :            :     }
     844                 :            :     
     845 [ #  # ][ #  # ]:          0 :     for ( k = 1; k < 1 + fsurfarray2.size(); k++ ) {
     846                 :          0 :         surfs_in_subtraction2[k] = surfs_in_intersection2[k] = false;
     847                 :            :     }
     848 [ #  # ][ #  # ]:          0 :     for ( k = 1; k < 1 + fcurvearray2.size(); k++ ) {
     849                 :          0 :         curves_in_subtraction2[k] = curves_in_intersection2[k] = false;
     850                 :            :     }
     851                 :            :      
     852                 :            :     status = intersector.get_persistent_entity_info(surfs_in_intersection,
     853                 :            :                                  curves_in_intersection,surfs_in_subtraction,
     854         [ #  # ]:          0 :                                  curves_in_subtraction,op,1);
     855                 :            :      //  If op == unite, the curves ans surfs that are undamaged are those
     856                 :            :      //  for which xxx_in_intereseciton = 0 false and xxx_in_subtraction == true
     857                 :            : 
     858                 :            :     status = intersector.get_persistent_entity_info(surfs_in_intersection2,
     859                 :            :                                  curves_in_intersection2,surfs_in_subtraction2,
     860         [ #  # ]:          0 :                                  curves_in_subtraction2,op,2);
     861                 :            : 
     862                 :            : 
     863 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < vertsout.size(); k += 3 ) {
     864         [ #  # ]:          0 :       new_point = (CubitPoint *) new CubitPointData( vertsout[k],
     865         [ #  # ]:          0 :                                                      vertsout[k+1],
     866 [ #  # ][ #  # ]:          0 :                                                      vertsout[k+2] );
                 [ #  # ]
     867         [ #  # ]:          0 :       points.push_back(new_point);
     868                 :            :     }  
     869 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < coordsout.size(); k += 3 ) {    
     870 [ #  # ][ #  # ]:          0 :       facet_ptr = new CubitFacetData( points[coordsout[k]],
     871 [ #  # ][ #  # ]:          0 :                                       points[coordsout[k+1]],
     872 [ #  # ][ #  # ]:          0 :                                       points[coordsout[k+2]] );
         [ #  # ][ #  # ]
     873                 :            :       int cptr[3];
     874         [ #  # ]:          0 :       cptr[0] = curveindex[k];
     875         [ #  # ]:          0 :       cptr[1] = curveindex[k+1];
     876         [ #  # ]:          0 :       cptr[2] = curveindex[k+2];
     877         [ #  # ]:          0 :       TDFacetboolData::add_facetbool_facet( facet_ptr );
     878         [ #  # ]:          0 :       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
     879         [ #  # ]:          0 :       td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],is_body_1[k/3],
     880 [ #  # ][ #  # ]:          0 :               facet_ptr->is_backwards());                                
         [ #  # ][ #  # ]
     881                 :            : 
     882         [ #  # ]:          0 :       facet_list.append( facet_ptr );     
     883                 :            :     }
     884         [ #  # ]:          0 :     points.clear(); //  clear out the points vector since we are through with it.
     885                 :            : 
     886         [ #  # ]:          0 :     FacetModifyEngine *fme = FacetModifyEngine::instance();
     887                 :            :     int interp_order;
     888                 :            :     CubitBoolean smooth_non_manifold, split_surfaces;
     889                 :            :     BodySM *body_ptr;
     890                 :          0 :     interp_order = 0;
     891                 :          0 :     smooth_non_manifold = CUBIT_TRUE;
     892                 :          0 :     split_surfaces = CUBIT_FALSE;
     893                 :            :       
     894                 :            :     {
     895                 :          0 :         ChollaEngine *cholla_ptr = NULL;
     896                 :            : 
     897                 :            :         status = fme->build_cholla_surfaces( facet_list,
     898                 :            :                                              point_list,
     899                 :            :                                              -1.0,
     900                 :            :                                              interp_order,
     901                 :            :                                              smooth_non_manifold,
     902                 :            :                                              split_surfaces,
     903 [ #  # ][ #  # ]:          0 :                                              cholla_ptr );
         [ #  # ][ #  # ]
                 [ #  # ]
     904         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
     905                 :          0 :           return status;
     906                 :            : 
     907                 :            :         status = fme->finish_facet_Body( cholla_ptr,
     908                 :            :                                          NULL,
     909                 :            :                                          -1.0, interp_order,
     910         [ #  # ]:          0 :                                          body_ptr);
     911         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
     912                 :          0 :           return status;
     913         [ #  # ]:          0 :         if ( cholla_ptr )
     914                 :            :         {
     915         [ #  # ]:          0 :             cholla_ptr->delete_me();
     916 [ #  # ][ #  # ]:          0 :             delete cholla_ptr;
     917                 :            :         }
     918                 :            :     }
     919                 :            : 
     920         [ #  # ]:          0 :     if ( keep_old == false ) {
     921                 :            :       make_persistents_boolean(body_in2,body_ptr,fsurfarray2,fcurvearray2,
     922                 :            :                        surfs_in_intersection2,surfs_in_subtraction2,
     923         [ #  # ]:          0 :                        curves_in_intersection2,curves_in_subtraction2,op,false);
     924                 :            :       make_persistents_boolean(body_in1,body_ptr,fsurfarray1,fcurvearray1,
     925                 :            :                        surfs_in_intersection,surfs_in_subtraction,
     926         [ #  # ]:          0 :                        curves_in_intersection,curves_in_subtraction,op,true);
     927                 :            : 
     928                 :            :     }
     929                 :            : 
     930                 :          0 :     body_out = body_ptr;
     931                 :            :       //separate the lumps in the "body_out", these will be converted to
     932                 :            :       //separate volumes later in the code.
     933         [ #  # ]:          0 :     status=separate_lumps(body_out,is_sheet_body);
     934         [ #  # ]:          0 :     vertsout.clear();
     935         [ #  # ]:          0 :     coordsout.clear();                 
     936 [ #  # ][ #  # ]:          0 :     delete [] surfs_in_intersection; delete [] surfs_in_subtraction;
     937 [ #  # ][ #  # ]:          0 :     delete [] curves_in_intersection; delete [] curves_in_subtraction;
     938 [ #  # ][ #  # ]:          0 :     delete [] surfs_in_intersection2; delete [] surfs_in_subtraction2;
     939 [ #  # ][ #  # ]:          0 :     delete [] curves_in_intersection2; delete [] curves_in_subtraction2;
     940                 :            :                                   
     941         [ #  # ]:          0 :   return status; 
     942                 :            : 
     943                 :            : }
     944                 :            :                            
     945                 :          0 : int FacetboolInterface::findcurve(FacetCurve *curve, 
     946                 :            :                                   std::vector<FacetCurve *>& fcurvearray)
     947                 :            : {
     948                 :            : unsigned int i;
     949                 :            : 
     950         [ #  # ]:          0 :   for ( i = 0; i < fcurvearray.size(); i++ ) {
     951         [ #  # ]:          0 :     if ( fcurvearray[i] == curve ) {
     952                 :          0 :       return i;
     953                 :            :     }
     954                 :            :   }
     955                 :          0 :   fcurvearray.push_back(curve);
     956                 :            :   
     957                 :          0 :   return fcurvearray.size() - 1;
     958                 :            : }
     959                 :            : 
     960                 :          0 : void FacetboolInterface::make_persistents_webcut(BodySM *body_in, 
     961                 :            :                                           BodySM *body_out1, 
     962                 :            :                                           BodySM *body_out2,
     963                 :            :                                           std::vector<FacetSurface *>& fsurfarray,
     964                 :            :                                           std::vector<FacetCurve *>& fcurvearray,
     965                 :            :                                           bool *surfs_in_intersection,
     966                 :            :                                           bool *surfs_in_subtraction,
     967                 :            :                                           bool *curves_in_intersection,
     968                 :            :                                           bool  *curves_in_subtraction
     969                 :            :                                          )
     970                 :            : {
     971                 :            : unsigned int k, n;
     972         [ #  # ]:          0 : DLIList<CubitSimpleAttrib> csa_list;
     973         [ #  # ]:          0 : FacetBody *facet_body_in = CAST_TO(body_in, FacetBody);
     974                 :            : FacetBody *facet_body_out1;
     975                 :            : FacetBody *facet_body_out2;                               
     976                 :            : 
     977         [ #  # ]:          0 :   facet_body_out1 = CAST_TO(body_out1, FacetBody);
     978         [ #  # ]:          0 :   facet_body_out2 = CAST_TO(body_out2, FacetBody);                               
     979                 :            : 
     980                 :            : //  Fix the curves.                      
     981 [ #  # ][ #  # ]:          0 : DLIList<FacetCurve*> fcurvelist, fcurvelist2; 
         [ #  # ][ #  # ]
     982                 :            : 
     983         [ #  # ]:          0 :     facet_body_out1->get_curves(fcurvelist);
     984         [ #  # ]:          0 :     facet_body_out2->get_curves(fcurvelist2);
     985                 :            : 
     986 [ #  # ][ #  # ]:          0 :   for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
     987 [ #  # ][ #  # ]:          0 :     if ( (curves_in_intersection[n] == true) && (curves_in_subtraction[n] == false) ) {
     988 [ #  # ][ #  # ]:          0 :       make_persistent_curves(fcurvelist,fcurvearray,n);
                 [ #  # ]
     989 [ #  # ][ #  # ]:          0 :     } else if ( (curves_in_intersection[n] == false) && 
     990                 :          0 :                 (curves_in_subtraction[n] == true) ) {
     991 [ #  # ][ #  # ]:          0 :       make_persistent_curves(fcurvelist2,fcurvearray,n);
                 [ #  # ]
     992                 :            :     }
     993                 :            :   }
     994                 :            : 
     995                 :            : 
     996                 :            : //  Fix the surfaces
     997 [ #  # ][ #  # ]:          0 : DLIList<FacetSurface*> fsurfaceslist, fsurfaceslist2;
         [ #  # ][ #  # ]
     998         [ #  # ]:          0 :     facet_body_out1->get_surfaces(fsurfaceslist);
     999         [ #  # ]:          0 :     facet_body_out2->get_surfaces(fsurfaceslist2);
    1000                 :            : 
    1001 [ #  # ][ #  # ]:          0 :   for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
    1002 [ #  # ][ #  # ]:          0 :     if ( (surfs_in_intersection[n] == true) && (surfs_in_subtraction[n] == false) ) {
    1003 [ #  # ][ #  # ]:          0 :       make_persistent_surfaces(fsurfaceslist,fsurfarray,n);                          
                 [ #  # ]
    1004 [ #  # ][ #  # ]:          0 :     } else if ( (surfs_in_intersection[n] == false) && 
    1005                 :          0 :                 (surfs_in_subtraction[n] == true) ) {
    1006 [ #  # ][ #  # ]:          0 :       make_persistent_surfaces(fsurfaceslist2,fsurfarray,n);                
                 [ #  # ]
    1007                 :            :     }
    1008                 :            :   }
    1009                 :            : 
    1010                 :            : //  Fix the lumps.
    1011                 :            : FacetLump *florig, *fl2;
    1012 [ #  # ][ #  # ]:          0 : DLIList<FacetLump*> flumplist, flumplist2;
         [ #  # ][ #  # ]
    1013         [ #  # ]:          0 :     facet_body_in->get_lumps(flumplist);
    1014         [ #  # ]:          0 :       facet_body_out1->get_lumps(flumplist2);
    1015         [ #  # ]:          0 :       florig = flumplist.get();
    1016         [ #  # ]:          0 :       fl2 = flumplist2.get();
    1017 [ #  # ][ #  # ]:          0 :       if ( florig->owner() ) {
    1018 [ #  # ][ #  # ]:          0 :         florig->owner()->swap_bridge(florig,fl2,false);
    1019         [ #  # ]:          0 :         florig->get_simple_attribute(csa_list);
    1020 [ #  # ][ #  # ]:          0 :         for ( k = csa_list.size(); k > 0; k-- ) {
    1021         [ #  # ]:          0 :           const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1022         [ #  # ]:          0 :           fl2->append_simple_attribute_virt(csa);                               
    1023                 :            :         }
    1024                 :            :       }
    1025                 :            : //  Fix the bodies.
    1026 [ #  # ][ #  # ]:          0 :     if ( facet_body_in->owner() ) {
    1027 [ #  # ][ #  # ]:          0 :       facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
    1028         [ #  # ]:          0 :       facet_body_in->get_simple_attribute(csa_list);
    1029 [ #  # ][ #  # ]:          0 :       for ( k = csa_list.size(); k > 0; k-- ) {
    1030         [ #  # ]:          0 :         const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1031         [ #  # ]:          0 :         facet_body_out1->append_simple_attribute_virt(csa);                               
    1032                 :            :       } 
    1033         [ #  # ]:          0 :     } 
    1034                 :            :   
    1035                 :          0 : }
    1036                 :            : 
    1037                 :          0 : void FacetboolInterface::make_persistents_imprint(BodySM *body_in, 
    1038                 :            :                                           BodySM *body_out1, 
    1039                 :            :                                           std::vector<FacetSurface *>& fsurfarray,
    1040                 :            :                                           std::vector<FacetCurve *>& fcurvearray
    1041                 :            :                                          )
    1042                 :            : {
    1043         [ #  # ]:          0 : DLIList<CubitSimpleAttrib> csa_list;
    1044         [ #  # ]:          0 : FacetBody *facet_body_in = CAST_TO(body_in, FacetBody);
    1045         [ #  # ]:          0 : FacetBody *facet_body_out1 = CAST_TO(body_out1, FacetBody);                                    
    1046                 :            : unsigned int n;
    1047                 :            : 
    1048                 :            : //  Fix the curves.                      
    1049 [ #  # ][ #  # ]:          0 :     DLIList<FacetCurve*> fcurvelist; 
    1050         [ #  # ]:          0 :     facet_body_out1->get_curves(fcurvelist);
    1051                 :            : 
    1052 [ #  # ][ #  # ]:          0 :   for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
    1053 [ #  # ][ #  # ]:          0 :       make_persistent_curves(fcurvelist,fcurvearray,n,0);
                 [ #  # ]
    1054                 :            :   }
    1055                 :            : 
    1056                 :            : 
    1057                 :            : //  Fix the surfaces
    1058 [ #  # ][ #  # ]:          0 :     DLIList<FacetSurface*> fsurfaceslist;
    1059         [ #  # ]:          0 :     facet_body_out1->get_surfaces(fsurfaceslist);
    1060                 :            : 
    1061 [ #  # ][ #  # ]:          0 :   for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
    1062 [ #  # ][ #  # ]:          0 :       make_persistent_surfaces(fsurfaceslist,fsurfarray,n,0);                          
                 [ #  # ]
    1063                 :            :   }
    1064                 :            :  
    1065                 :            : //  Fix the lumps.
    1066                 :            : FacetLump *florig, *fl2;
    1067 [ #  # ][ #  # ]:          0 : DLIList<FacetLump*> flumplist, flumplist2;
         [ #  # ][ #  # ]
    1068                 :            : int k;
    1069                 :            : 
    1070         [ #  # ]:          0 :     facet_body_in->get_lumps(flumplist);
    1071         [ #  # ]:          0 :       facet_body_out1->get_lumps(flumplist2);
    1072         [ #  # ]:          0 :       florig = flumplist.get();
    1073         [ #  # ]:          0 :       fl2 = flumplist2.get();
    1074 [ #  # ][ #  # ]:          0 :       if ( florig->owner() ) {
    1075 [ #  # ][ #  # ]:          0 :         florig->owner()->swap_bridge(florig,fl2,false);
    1076         [ #  # ]:          0 :         florig->get_simple_attribute(csa_list);
    1077 [ #  # ][ #  # ]:          0 :         for ( k = csa_list.size(); k > 0; k-- ) {
    1078         [ #  # ]:          0 :           const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1079         [ #  # ]:          0 :           fl2->append_simple_attribute_virt(csa);                               
    1080                 :            :         }
    1081                 :            :       }
    1082                 :            : 
    1083                 :            : //  Fix the bodies.
    1084 [ #  # ][ #  # ]:          0 :     if ( facet_body_in->owner() ) {
    1085 [ #  # ][ #  # ]:          0 :       facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
    1086         [ #  # ]:          0 :       facet_body_in->get_simple_attribute(csa_list);
    1087 [ #  # ][ #  # ]:          0 :       for ( k = csa_list.size(); k > 0; k-- ) {
    1088         [ #  # ]:          0 :         const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1089         [ #  # ]:          0 :         facet_body_out1->append_simple_attribute_virt(csa);                               
    1090                 :            :       }
    1091         [ #  # ]:          0 :     }    
    1092                 :            : 
    1093                 :          0 : }
    1094                 :            : 
    1095                 :          0 : void FacetboolInterface::make_persistents_boolean(BodySM *body_in, 
    1096                 :            :                                           BodySM *body_out1, 
    1097                 :            :                                           std::vector<FacetSurface *>& fsurfarray,
    1098                 :            :                                           std::vector<FacetCurve *>& fcurvearray,
    1099                 :            :                                           bool *surfs_in_intersection,
    1100                 :            :                                           bool *surfs_in_subtraction,
    1101                 :            :                                           bool *curves_in_intersection,
    1102                 :            :                                           bool  *curves_in_subtraction,
    1103                 :            :                                           const CubitFacetboolOp op,
    1104                 :            :                                           bool body_1
    1105                 :            :                                          )
    1106                 :            : {
    1107                 :            :   unsigned int n;
    1108         [ #  # ]:          0 :   DLIList<CubitSimpleAttrib> csa_list;
    1109         [ #  # ]:          0 :   FacetBody *facet_body_in = CAST_TO(body_in, FacetBody);
    1110         [ #  # ]:          0 :   FacetBody *facet_body_out1 = CAST_TO(body_out1, FacetBody);
    1111                 :            :   int which_parent;
    1112                 :          0 :   bool bvalue1 = false, bvalue2 = false;
    1113                 :            : 
    1114         [ #  # ]:          0 :   if ( body_1 == true ) which_parent = 1;
    1115                 :          0 :   else which_parent = 2;
    1116                 :            : 
    1117   [ #  #  #  # ]:          0 :   switch (op) {
    1118                 :            :   
    1119                 :            :     case CUBIT_FB_UNION:
    1120                 :          0 :       bvalue1 = false;
    1121                 :          0 :       bvalue2 = true;
    1122                 :          0 :       break;
    1123                 :            :     case CUBIT_FB_INTERSECTION:
    1124                 :          0 :       bvalue2 = false;
    1125                 :          0 :       bvalue1 = true;
    1126                 :          0 :       break;
    1127                 :            :     case CUBIT_FB_SUBTRACTION:
    1128         [ #  # ]:          0 :       if ( body_1 == true ) {
    1129                 :          0 :         bvalue2 = false;
    1130                 :          0 :         bvalue1 = true;
    1131                 :            :       } else {
    1132                 :          0 :         bvalue1 = false;
    1133                 :          0 :         bvalue2 = true;
    1134                 :            :       }      
    1135                 :          0 :       break;      
    1136                 :            :   }      
    1137                 :            : //  Fix the curves.                      
    1138         [ #  # ]:          0 :     DLIList<FacetCurve*> fcurvelist; 
    1139         [ #  # ]:          0 :     facet_body_out1->get_curves(fcurvelist);
    1140                 :            : 
    1141 [ #  # ][ #  # ]:          0 :   for ( n = 1; n < 1 + fcurvearray.size(); n++ ) {
    1142 [ #  # ][ #  # ]:          0 :     if ( (curves_in_intersection[n] == bvalue1) && 
    1143                 :          0 :          (curves_in_subtraction[n] == bvalue2) ) {
    1144 [ #  # ][ #  # ]:          0 :       make_persistent_curves(fcurvelist,fcurvearray,n,which_parent);
                 [ #  # ]
    1145                 :            :     }
    1146                 :            :   }
    1147                 :            : 
    1148                 :            : 
    1149                 :            : //  Fix the surfaces
    1150 [ #  # ][ #  # ]:          0 :     DLIList<FacetSurface*> fsurfaceslist;
    1151         [ #  # ]:          0 :     facet_body_out1->get_surfaces(fsurfaceslist);
    1152                 :            : 
    1153 [ #  # ][ #  # ]:          0 :   for ( n = 1; n < 1 + fsurfarray.size(); n++ ) {
    1154 [ #  # ][ #  # ]:          0 :     if ( (surfs_in_intersection[n] == bvalue1) && 
    1155                 :          0 :          (surfs_in_subtraction[n] == bvalue2) ) {
    1156 [ #  # ][ #  # ]:          0 :       make_persistent_surfaces(fsurfaceslist,fsurfarray,n,which_parent);                          
                 [ #  # ]
    1157                 :            :     }
    1158                 :            :   }
    1159                 :            :  
    1160         [ #  # ]:          0 :   if ( body_1 == true ) {
    1161                 :            : //  Fix the lumps.
    1162                 :            : FacetLump *florig, *fl2;
    1163 [ #  # ][ #  # ]:          0 : DLIList<FacetLump*> flumplist, flumplist2;
                 [ #  # ]
    1164                 :            : int k;
    1165                 :            : 
    1166         [ #  # ]:          0 :     facet_body_in->get_lumps(flumplist);
    1167         [ #  # ]:          0 :       facet_body_out1->get_lumps(flumplist2);
    1168         [ #  # ]:          0 :       florig = flumplist.get();
    1169         [ #  # ]:          0 :       fl2 = flumplist2.get();
    1170 [ #  # ][ #  # ]:          0 :       if ( florig->owner() ) {
    1171 [ #  # ][ #  # ]:          0 :         florig->owner()->swap_bridge(florig,fl2,false);
    1172         [ #  # ]:          0 :         florig->get_simple_attribute(csa_list);
    1173 [ #  # ][ #  # ]:          0 :         for ( k = csa_list.size(); k > 0; k-- ) {
    1174         [ #  # ]:          0 :           const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1175         [ #  # ]:          0 :           fl2->append_simple_attribute_virt(csa);                               
    1176                 :            :         }
    1177                 :            :       }
    1178                 :            : 
    1179                 :            : //  Fix the bodies.
    1180 [ #  # ][ #  # ]:          0 :     if ( facet_body_in->owner() ) {
    1181 [ #  # ][ #  # ]:          0 :       facet_body_in->owner()->swap_bridge(facet_body_in,facet_body_out1,false);
    1182         [ #  # ]:          0 :       facet_body_in->get_simple_attribute(csa_list);
    1183 [ #  # ][ #  # ]:          0 :       for ( k = csa_list.size(); k > 0; k-- ) {
    1184         [ #  # ]:          0 :         const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1185         [ #  # ]:          0 :         facet_body_out1->append_simple_attribute_virt(csa);                               
    1186                 :            :       }
    1187         [ #  # ]:          0 :     }    
    1188 [ #  # ][ #  # ]:          0 :   }
    1189                 :            :    
    1190                 :          0 : }
    1191                 :            : 
    1192                 :          0 : void FacetboolInterface::make_persistent_curves(DLIList<FacetCurve*> fcurvelist,
    1193                 :            :                                        std::vector<FacetCurve *>& fcurvearray,
    1194                 :            :                                        int n,
    1195                 :            :                                        int which_parent)
    1196                 :            : {
    1197                 :            : int k, m, jj;
    1198                 :            : FacetCurve *fcurveorig, *fcurve2;
    1199                 :            : int *marked3, index;
    1200                 :            : bool ifoundit;
    1201                 :            : FacetPoint *fpointorig, *fpoint2; 
    1202 [ #  # ][ #  # ]:          0 : DLIList<FacetPoint*> fpointlist, fpointlist2; 
                 [ #  # ]
    1203                 :            : CubitFacet *cfac;
    1204 [ #  # ][ #  # ]:          0 : DLIList<CubitSimpleAttrib> csa_list;
    1205                 :            : bool is_from_1, error;
    1206                 :            : TDFacetboolData* tdf;
    1207                 :            :  
    1208         [ #  # ]:          0 :   fcurveorig = fcurvearray[n-1];
    1209                 :          0 :   ifoundit = false;
    1210 [ #  # ][ #  # ]:          0 :   for ( k = fcurvelist.size(); k > 0; k-- ) {
    1211         [ #  # ]:          0 :     fcurve2 = fcurvelist.get_and_step();
    1212 [ #  # ][ #  # ]:          0 :     if ( fcurve2->owner() ) continue;  //  If owner is already set, skip it.
    1213         [ #  # ]:          0 :     CurveFacetEvalTool *evaltool = fcurve2->get_eval_tool();
    1214         [ #  # ]:          0 :     DLIList<CubitFacetEdge*> edgelist;
    1215                 :            :     CubitFacetEdge *cfedge;
    1216         [ #  # ]:          0 :     evaltool->get_facets(edgelist);
    1217         [ #  # ]:          0 :     cfedge = edgelist.get();
    1218         [ #  # ]:          0 :     cfac = cfedge->adj_facet(0);
    1219         [ #  # ]:          0 :     index = cfac->edge_index(cfedge);
    1220         [ #  # ]:          0 :     tdf = TDFacetboolData::get(cfac);
    1221         [ #  # ]:          0 :     if ( which_parent ) {
    1222         [ #  # ]:          0 :       is_from_1 = tdf->parent_is_body_1();
    1223 [ #  # ][ #  # ]:          0 :       if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
                 [ #  # ]
    1224         [ #  # ]:          0 :            ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
    1225                 :            :     } 
    1226 [ #  # ][ #  # ]:          0 :     marked3 = tdf->get_edge_indices(cfac->is_backwards());
    1227         [ #  # ]:          0 :     if ( marked3[(index+1)%3] == n ) ifoundit = true;
    1228                 :            :     else {
    1229         [ #  # ]:          0 :       cfac = cfedge->adj_facet(1);
    1230         [ #  # ]:          0 :       if (cfac) {
    1231         [ #  # ]:          0 :         index = cfac->edge_index(cfedge);
    1232         [ #  # ]:          0 :         tdf = TDFacetboolData::get(cfac);
    1233         [ #  # ]:          0 :         if ( which_parent ) {
    1234         [ #  # ]:          0 :           is_from_1 = tdf->parent_is_body_1();
    1235 [ #  # ][ #  # ]:          0 :           if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
                 [ #  # ]
    1236         [ #  # ]:          0 :                ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
    1237                 :            :         }         
    1238 [ #  # ][ #  # ]:          0 :         marked3 = tdf->get_edge_indices(cfac->is_backwards());
    1239         [ #  # ]:          0 :         if ( marked3[(index+1)%3] == n ) ifoundit = true; 
    1240                 :            :       }
    1241                 :            :     }
    1242         [ #  # ]:          0 :     if ( ifoundit == true ) {
    1243         [ #  # ]:          0 :       fpointlist.clean_out();
    1244         [ #  # ]:          0 :       fpointlist2.clean_out();
    1245         [ #  # ]:          0 :       fcurveorig->get_points(fpointlist);
    1246         [ #  # ]:          0 :       fcurve2->get_points(fpointlist2);
    1247 [ #  # ][ #  # ]:          0 :       for ( jj = fpointlist.size(); jj > 0; jj-- ) {
    1248                 :          0 :         error = false;
    1249         [ #  # ]:          0 :         fpointorig = fpointlist.get_and_step();
    1250         [ #  # ]:          0 :         fpoint2 = fpointlist2.get_and_step();
    1251 [ #  # ][ #  # ]:          0 :         while ( fpoint2->coordinates() != fpointorig->coordinates() ) {
         [ #  # ][ #  # ]
    1252 [ #  # ][ #  # ]:          0 :           if ( fpointlist2.is_at_beginning() == CUBIT_TRUE ) {
    1253                 :            : //            PRINT_WARNING("Unable to make point on curve persistent.\n");
    1254                 :          0 :             error = true;
    1255                 :          0 :             break;
    1256                 :            :           } 
    1257         [ #  # ]:          0 :           fpoint2 = fpointlist2.get_and_step();
    1258                 :            :         }
    1259         [ #  # ]:          0 :         if ( error == true ) continue;
    1260 [ #  # ][ #  # ]:          0 :         if ( fpointorig->owner() && !(fpoint2->owner()) ) {
         [ #  # ][ #  # ]
                 [ #  # ]
    1261 [ #  # ][ #  # ]:          0 :           fpointorig->owner()->swap_bridge(fpointorig,fpoint2,false); 
    1262         [ #  # ]:          0 :           fpointorig->get_simple_attribute(csa_list);
    1263 [ #  # ][ #  # ]:          0 :           for ( m = csa_list.size(); m > 0; m-- ) {
    1264         [ #  # ]:          0 :             const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1265         [ #  # ]:          0 :             fpoint2->append_simple_attribute_virt(csa);                                     
    1266                 :            :           } 
    1267                 :            :         }             
    1268                 :            :       }
    1269 [ #  # ][ #  # ]:          0 :       if ( fcurveorig->owner() != 0 ) 
    1270 [ #  # ][ #  # ]:          0 :         fcurveorig->owner()->swap_bridge(fcurveorig,fcurve2,false); 
    1271         [ #  # ]:          0 :       fcurveorig->get_simple_attribute(csa_list);
    1272 [ #  # ][ #  # ]:          0 :       for ( m = csa_list.size(); m > 0; m-- ) {
    1273         [ #  # ]:          0 :         const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1274         [ #  # ]:          0 :         fcurve2->append_simple_attribute_virt(csa);                                     
    1275                 :            :       }    
    1276         [ #  # ]:          0 :       break;
              [ #  #  # ]
    1277                 :            :     }
    1278         [ #  # ]:          0 :   }
    1279                 :          0 : }
    1280                 :            : 
    1281                 :          0 : void FacetboolInterface::make_persistent_surfaces(DLIList<FacetSurface*> fsurfaceslist,
    1282                 :            :                             std::vector<FacetSurface *>& fsurfarray,
    1283                 :            :                             int n,
    1284                 :            :                             int which_parent)
    1285                 :            : {
    1286         [ #  # ]:          0 : DLIList<CubitSimpleAttrib> csa_list;
    1287                 :            : int k, m;
    1288                 :            : FacetSurface *fsorig, *fsurf2;
    1289                 :            : bool is_from_1;
    1290                 :            : 
    1291         [ #  # ]:          0 :   fsorig = fsurfarray[n-1];
    1292 [ #  # ][ #  # ]:          0 :   for ( k = fsurfaceslist.size(); k > 0; k-- ) {
    1293         [ #  # ]:          0 :     fsurf2 = fsurfaceslist.get_and_step();
    1294         [ #  # ]:          0 :     DLIList<CubitFacet*> facet_list2;
    1295         [ #  # ]:          0 :     fsurf2->tris(facet_list2);
    1296         [ #  # ]:          0 :     CubitFacet* facet2 = facet_list2.get();
    1297         [ #  # ]:          0 :     TDFacetboolData* tdf = TDFacetboolData::get(facet2);
    1298         [ #  # ]:          0 :     if ( which_parent ) {
    1299         [ #  # ]:          0 :       is_from_1 = tdf->parent_is_body_1();
    1300 [ #  # ][ #  # ]:          0 :       if ( ( (is_from_1 == true) && (which_parent == 2) ) ||
                 [ #  # ]
    1301         [ #  # ]:          0 :            ( (is_from_1 == false) && (which_parent == 1) ) ) continue;
    1302                 :            :     }
    1303         [ #  # ]:          0 :     int marked2 = tdf->get_surf_index(); 
    1304         [ #  # ]:          0 :     if ( marked2 == n ) {
    1305 [ #  # ][ #  # ]:          0 :       if ( fsorig->owner() != 0 )
    1306 [ #  # ][ #  # ]:          0 :         fsorig->owner()->swap_bridge(fsorig,fsurf2,false); 
    1307         [ #  # ]:          0 :       fsorig->get_simple_attribute(csa_list);
    1308 [ #  # ][ #  # ]:          0 :       for ( m = csa_list.size(); m > 0; m-- ) {
    1309         [ #  # ]:          0 :         const CubitSimpleAttrib& csa = csa_list.get_and_step();
    1310         [ #  # ]:          0 :         fsurf2->append_simple_attribute_virt(csa);                               
    1311                 :            :       }    
    1312         [ #  # ]:          0 :       break;
              [ #  #  # ]
    1313                 :            :     }
    1314         [ #  # ]:          0 :   }    
    1315                 :          0 : }
    1316                 :            : 
    1317                 :          0 : CubitStatus FacetboolInterface::FB_imprint_with_curves(BodySM*& body_in,
    1318                 :            :                              BodySM*& body_out,                             
    1319                 :            :                              bool keep_old)
    1320                 :            : {
    1321                 :            : CubitStatus status;
    1322                 :            : 
    1323         [ #  # ]:          0 :   FacetModifyEngine *fme = FacetModifyEngine::instance();
    1324                 :            : 
    1325                 :            :   FacetBody *fbody_ptr;
    1326         [ #  # ]:          0 :   fbody_ptr = dynamic_cast<FacetBody *>(body_in);
    1327         [ #  # ]:          0 :   DLIList<FacetSurface*> facet_surf_list;
    1328         [ #  # ]:          0 :   fbody_ptr->get_surfaces(facet_surf_list);
    1329 [ #  # ][ #  # ]:          0 : std::vector<double> body_verts;
    1330 [ #  # ][ #  # ]:          0 : std::vector<int> body_connections, newbodyfacets;
         [ #  # ][ #  # ]
    1331 [ #  # ][ #  # ]:          0 : std::vector<int> f_c_indices;
    1332 [ #  # ][ #  # ]:          0 : std::vector<FacetSurface *> fsurfarray;
    1333 [ #  # ][ #  # ]:          0 : std::vector<FacetCurve *> fcurvearray;
    1334 [ #  # ][ #  # ]:          0 : std::vector<double> vertsout;
    1335 [ #  # ][ #  # ]:          0 : std::vector<int> coordsout;
    1336 [ #  # ][ #  # ]:          0 : std::vector<int> surfindex;  
    1337 [ #  # ][ #  # ]:          0 : std::vector<int> curveindex;  
    1338                 :            :   
    1339                 :            :   status = facetbody_to_facetbool(facet_surf_list,body_verts,
    1340                 :            :                                 body_connections,&f_c_indices,
    1341         [ #  # ]:          0 :                                 fsurfarray,fcurvearray);
    1342         [ #  # ]:          0 :   facet_surf_list.clean_out();                                            
    1343                 :            : 
    1344 [ #  # ][ #  # ]:          0 :   FBImprint imprinter;
    1345                 :            :  
    1346                 :            :   status = imprinter.imprint_body_curve(body_verts,body_connections,
    1347                 :            :                                 FB_imprint_edge_coords,FB_imprint_edges,
    1348         [ #  # ]:          0 :                                 FB_imprint_edge_bboxes,&f_c_indices);            
    1349                 :            : 
    1350                 :            :   status = imprinter.update_surfs_and_curves(vertsout,coordsout,
    1351         [ #  # ]:          0 :                                           &surfindex,&curveindex);
    1352 [ #  # ][ #  # ]:          0 :     DLIList <CubitFacet *>facet_list;
    1353 [ #  # ][ #  # ]:          0 :     DLIList <CubitPoint *>point_list;
    1354                 :            :     CubitPoint *new_point;
    1355                 :            :     CubitFacet *facet_ptr;
    1356 [ #  # ][ #  # ]:          0 :     std::vector<CubitPoint *> points;
    1357                 :            : 
    1358                 :            : unsigned int k;
    1359 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < vertsout.size(); k += 3 ) {
    1360         [ #  # ]:          0 :       new_point = (CubitPoint *) new CubitPointData( vertsout[k],
    1361         [ #  # ]:          0 :                                                      vertsout[k+1],
    1362 [ #  # ][ #  # ]:          0 :                                                      vertsout[k+2] );
                 [ #  # ]
    1363         [ #  # ]:          0 :       points.push_back(new_point);
    1364                 :            :     }  
    1365 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < coordsout.size(); k += 3 ) {        
    1366 [ #  # ][ #  # ]:          0 :       facet_ptr = new CubitFacetData( points[coordsout[k]],
    1367 [ #  # ][ #  # ]:          0 :                                       points[coordsout[k+1]],
    1368 [ #  # ][ #  # ]:          0 :                                       points[coordsout[k+2]] );
         [ #  # ][ #  # ]
    1369                 :            :       int cptr[3];
    1370         [ #  # ]:          0 :       cptr[0] = curveindex[k];
    1371         [ #  # ]:          0 :       cptr[1] = curveindex[k+1];
    1372         [ #  # ]:          0 :       cptr[2] = curveindex[k+2];
    1373         [ #  # ]:          0 :       TDFacetboolData::add_facetbool_facet( facet_ptr );
    1374         [ #  # ]:          0 :       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
    1375         [ #  # ]:          0 :       td->set(surfindex[k/3],cptr[0],cptr[1],cptr[2],false,
    1376 [ #  # ][ #  # ]:          0 :               facet_ptr->is_backwards());                                
    1377                 :            : 
    1378         [ #  # ]:          0 :       facet_list.append( facet_ptr );     
    1379                 :            :     }
    1380         [ #  # ]:          0 :     points.clear(); //  clear out the points vector since we are through with it.
    1381                 :            :       
    1382                 :            :     double feature_angle;
    1383                 :            :     int interp_order;
    1384                 :            :     CubitBoolean smooth_non_manifold, split_surfaces;
    1385                 :          0 :     feature_angle = 135.0;
    1386                 :          0 :     interp_order = 0;
    1387                 :          0 :     smooth_non_manifold = CUBIT_TRUE;
    1388                 :          0 :     split_surfaces = CUBIT_TRUE;
    1389                 :            :   
    1390                 :            :     {
    1391                 :          0 :         ChollaEngine *cholla_ptr = NULL;
    1392                 :            : 
    1393                 :            :         status = fme->build_cholla_surfaces( facet_list,
    1394                 :            :                                              point_list,
    1395                 :            :                                              feature_angle,
    1396                 :            :                                              interp_order,
    1397                 :            :                                              smooth_non_manifold,
    1398                 :            :                                              split_surfaces,
    1399 [ #  # ][ #  # ]:          0 :                                              cholla_ptr );
         [ #  # ][ #  # ]
                 [ #  # ]
    1400         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
    1401                 :          0 :           return status;
    1402                 :            : 
    1403                 :            :         status = fme->finish_facet_Body( cholla_ptr,
    1404                 :            :                                          NULL,
    1405                 :            :                                          feature_angle, interp_order,
    1406         [ #  # ]:          0 :                                          body_out);
    1407         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
    1408                 :          0 :           return status;
    1409         [ #  # ]:          0 :         if ( cholla_ptr )
    1410                 :            :         {
    1411         [ #  # ]:          0 :             cholla_ptr->delete_me();
    1412 [ #  # ][ #  # ]:          0 :             delete cholla_ptr;
    1413                 :            :         }
    1414                 :            :     }
    1415                 :            : 
    1416         [ #  # ]:          0 :     vertsout.clear();
    1417         [ #  # ]:          0 :     coordsout.clear();                                 
    1418         [ #  # ]:          0 :     if ( keep_old == false ) {
    1419         [ #  # ]:          0 :       make_persistents_imprint(body_in,body_out,fsurfarray,fcurvearray);
    1420                 :            :     }
    1421                 :            :   
    1422         [ #  # ]:          0 :   return status;
    1423                 :            : 
    1424                 :            : }
    1425                 :            : 
    1426                 :          0 : CubitStatus FacetboolInterface::dofacetboolean_2bodies_imprint(BodySM*& body_in1, 
    1427                 :            :                              BodySM*& body_in2,
    1428                 :            :                              BodySM*& body_out1,
    1429                 :            :                              BodySM*& body_out2,                             
    1430                 :            :                              bool keep_old)
    1431                 :            : {
    1432                 :            : CubitStatus status;
    1433         [ #  # ]:          0 : std::vector<double> body_verts;
    1434 [ #  # ][ #  # ]:          0 : std::vector<double> body2_verts;
    1435 [ #  # ][ #  # ]:          0 : std::vector<int> body_connections, newbodyfacets;
         [ #  # ][ #  # ]
    1436 [ #  # ][ #  # ]:          0 : std::vector<int>  body2_connections, newbody2facets;
         [ #  # ][ #  # ]
    1437 [ #  # ][ #  # ]:          0 : std::vector<double> vertsout1, vertsout2;
         [ #  # ][ #  # ]
    1438 [ #  # ][ #  # ]:          0 : std::vector<int> coordsout1, coordsout2;
         [ #  # ][ #  # ]
    1439 [ #  # ][ #  # ]:          0 : std::vector<int> f_c_indices1;
    1440 [ #  # ][ #  # ]:          0 : std::vector<int> f_c_indices2;
    1441 [ #  # ][ #  # ]:          0 : std::vector<FacetSurface *> fsurfarray1, fsurfarray2;
         [ #  # ][ #  # ]
    1442 [ #  # ][ #  # ]:          0 : std::vector<FacetCurve *> fcurvearray1, fcurvearray2;
         [ #  # ][ #  # ]
    1443 [ #  # ][ #  # ]:          0 : std::vector<int> surfindex1, surfindex2;  
         [ #  # ][ #  # ]
    1444 [ #  # ][ #  # ]:          0 : std::vector<int> curveindex1, curveindex2;  
         [ #  # ][ #  # ]
    1445                 :            :  
    1446 [ #  # ][ #  # ]:          0 :     DLIList <CubitFacet *>facet_list;
    1447 [ #  # ][ #  # ]:          0 :     DLIList <CubitPoint *>point_list;
    1448                 :            :     CubitPoint *new_point;
    1449                 :            :     CubitFacet *facet_ptr;
    1450 [ #  # ][ #  # ]:          0 :     std::vector<CubitPoint *> points;
    1451                 :            : 
    1452         [ #  # ]:          0 :   FacetModifyEngine *fme = FacetModifyEngine::instance();
    1453                 :          0 :   bool is_sheet_body = false;
    1454 [ #  # ][ #  # ]:          0 :   Body *tmp_body_1 = CAST_TO(body_in1->topology_entity(), Body);
    1455 [ #  # ][ #  # ]:          0 :   Body *tmp_body_2 = CAST_TO(body_in2->topology_entity(), Body);
    1456 [ #  # ][ #  # ]:          0 :   if(tmp_body_1 && tmp_body_1->is_sheet_body()){
         [ #  # ][ #  # ]
    1457                 :          0 :     is_sheet_body = true;
    1458                 :            :   }
    1459 [ #  # ][ #  # ]:          0 :   else if(tmp_body_2 && tmp_body_2->is_sheet_body()){
         [ #  # ][ #  # ]
    1460                 :          0 :     is_sheet_body = true;
    1461                 :            :   }
    1462 [ #  # ][ #  # ]:          0 :   if(tmp_body_1->is_sheet_body() != tmp_body_2->is_sheet_body())
                 [ #  # ]
    1463                 :            :   {
    1464 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("Geometric boolean requested for a sheet body and a non-sheet body.\n");
         [ #  # ][ #  # ]
    1465                 :            :   }
    1466                 :            :   FacetBody *fbody_ptr;
    1467         [ #  # ]:          0 :   fbody_ptr = dynamic_cast<FacetBody *>(body_in1);
    1468 [ #  # ][ #  # ]:          0 :   DLIList<FacetSurface*> facet_surf_list;
    1469         [ #  # ]:          0 :   fbody_ptr->get_surfaces(facet_surf_list);
    1470                 :            :   
    1471                 :            :   status = facetbody_to_facetbool(facet_surf_list,body_verts,
    1472                 :            :                                 body_connections,&f_c_indices1,
    1473         [ #  # ]:          0 :                                 fsurfarray1,fcurvearray1);
    1474         [ #  # ]:          0 :   facet_surf_list.clean_out();                                            
    1475                 :            : 
    1476         [ #  # ]:          0 :     fbody_ptr = dynamic_cast<FacetBody *>(body_in2);
    1477         [ #  # ]:          0 :     fbody_ptr->get_surfaces(facet_surf_list);
    1478                 :            :     status = facetbody_to_facetbool(facet_surf_list,body2_verts,
    1479                 :            :                                   body2_connections,&f_c_indices2,
    1480         [ #  # ]:          0 :                                   fsurfarray2,fcurvearray2);
    1481         [ #  # ]:          0 :     facet_surf_list.clean_out();                                    
    1482                 :            : 
    1483 [ #  # ][ #  # ]:          0 :     FBIntersect intersector;
    1484         [ #  # ]:          0 :     intersector.set_imprint();
    1485                 :            :     status = intersector.intersect(body_verts,body_connections,
    1486                 :            :                                     body2_verts,body2_connections,
    1487                 :            :                                     newbodyfacets,newbody2facets,
    1488                 :            :                                     &f_c_indices1,
    1489         [ #  # ]:          0 :                                     &f_c_indices2);
    1490                 :            :     status = intersector.update_surfs_and_curves(vertsout1,coordsout1,
    1491         [ #  # ]:          0 :                                           &surfindex1,&curveindex1,1);
    1492                 :            :     status = intersector.update_surfs_and_curves(vertsout2,coordsout2,
    1493         [ #  # ]:          0 :                                           &surfindex2,&curveindex2,2);
    1494                 :            : unsigned int k;
    1495 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < vertsout1.size(); k += 3 ) {
    1496         [ #  # ]:          0 :       new_point = (CubitPoint *) new CubitPointData( vertsout1[k],
    1497         [ #  # ]:          0 :                                                      vertsout1[k+1],
    1498 [ #  # ][ #  # ]:          0 :                                                      vertsout1[k+2] );
                 [ #  # ]
    1499         [ #  # ]:          0 :       points.push_back(new_point);
    1500                 :            :     }  
    1501 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < coordsout1.size(); k += 3 ) {        
    1502 [ #  # ][ #  # ]:          0 :       facet_ptr = new CubitFacetData( points[coordsout1[k]],
    1503 [ #  # ][ #  # ]:          0 :                                       points[coordsout1[k+1]],
    1504 [ #  # ][ #  # ]:          0 :                                       points[coordsout1[k+2]] );
         [ #  # ][ #  # ]
    1505                 :            :       int cptr[3];
    1506         [ #  # ]:          0 :       cptr[0] = curveindex1[k];
    1507         [ #  # ]:          0 :       cptr[1] = curveindex1[k+1];
    1508         [ #  # ]:          0 :       cptr[2] = curveindex1[k+2];
    1509         [ #  # ]:          0 :       TDFacetboolData::add_facetbool_facet( facet_ptr );
    1510         [ #  # ]:          0 :       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
    1511         [ #  # ]:          0 :       td->set(surfindex1[k/3],cptr[0],cptr[1],cptr[2],false,
    1512 [ #  # ][ #  # ]:          0 :               facet_ptr->is_backwards());                                
    1513                 :            : 
    1514         [ #  # ]:          0 :       facet_list.append( facet_ptr );     
    1515                 :            :     }
    1516         [ #  # ]:          0 :     points.clear(); //  clear out the points vector since we are through with it.
    1517                 :            :       
    1518                 :            :     double feature_angle;
    1519                 :            :     int interp_order;
    1520                 :            :     CubitBoolean smooth_non_manifold, split_surfaces;
    1521                 :          0 :     feature_angle = 135.0;
    1522                 :          0 :     interp_order = 0;
    1523                 :          0 :     smooth_non_manifold = CUBIT_TRUE;
    1524                 :          0 :     split_surfaces = CUBIT_FALSE;
    1525                 :            :   
    1526                 :            :     {
    1527                 :          0 :         ChollaEngine *cholla_ptr = NULL;
    1528                 :            : 
    1529                 :            :         status = fme->build_cholla_surfaces( facet_list,
    1530                 :            :                                              point_list,
    1531                 :            :                                              feature_angle,
    1532                 :            :                                              interp_order,
    1533                 :            :                                              smooth_non_manifold,
    1534                 :            :                                              split_surfaces,
    1535 [ #  # ][ #  # ]:          0 :                                              cholla_ptr );
         [ #  # ][ #  # ]
                 [ #  # ]
    1536         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
    1537                 :          0 :           return status;
    1538                 :            : 
    1539                 :            :         status = fme->finish_facet_Body( cholla_ptr,
    1540                 :            :                                          NULL,
    1541                 :            :                                          feature_angle, interp_order,
    1542         [ #  # ]:          0 :                                          body_out1);
    1543         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
    1544                 :          0 :           return status;
    1545         [ #  # ]:          0 :         if ( cholla_ptr )
    1546                 :            :         {
    1547         [ #  # ]:          0 :             cholla_ptr->delete_me();
    1548 [ #  # ][ #  # ]:          0 :             delete cholla_ptr;
    1549                 :            :         }
    1550                 :            :     }
    1551         [ #  # ]:          0 :     vertsout1.clear();
    1552         [ #  # ]:          0 :     coordsout1.clear();                                 
    1553                 :            : 
    1554         [ #  # ]:          0 :     facet_list.clean_out();    
    1555 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < vertsout2.size(); k += 3 ) {
    1556         [ #  # ]:          0 :       new_point = (CubitPoint *) new CubitPointData( vertsout2[k],
    1557         [ #  # ]:          0 :                                                    vertsout2[k+1],
    1558 [ #  # ][ #  # ]:          0 :                                                    vertsout2[k+2] );
                 [ #  # ]
    1559         [ #  # ]:          0 :       points.push_back(new_point);
    1560                 :            :     }  
    1561 [ #  # ][ #  # ]:          0 :     for ( k = 0; k < coordsout2.size(); k += 3 ) {    
    1562 [ #  # ][ #  # ]:          0 :       facet_ptr = new CubitFacetData( points[coordsout2[k]],
    1563 [ #  # ][ #  # ]:          0 :                                       points[coordsout2[k+1]],
    1564 [ #  # ][ #  # ]:          0 :                                       points[coordsout2[k+2]] );
         [ #  # ][ #  # ]
    1565                 :            :       int cptr[3];
    1566         [ #  # ]:          0 :       cptr[0] = curveindex2[k];
    1567         [ #  # ]:          0 :       cptr[1] = curveindex2[k+1];
    1568         [ #  # ]:          0 :       cptr[2] = curveindex2[k+2];
    1569         [ #  # ]:          0 :       TDFacetboolData::add_facetbool_facet( facet_ptr );
    1570         [ #  # ]:          0 :       TDFacetboolData* td = TDFacetboolData::get(facet_ptr);
    1571         [ #  # ]:          0 :       td->set(surfindex2[k/3],cptr[0],cptr[1],cptr[2],false,
    1572 [ #  # ][ #  # ]:          0 :               facet_ptr->is_backwards());                              
    1573         [ #  # ]:          0 :       facet_list.append( facet_ptr );     
    1574                 :            :     }
    1575         [ #  # ]:          0 :     points.clear(); //  clear out the points vector since we are through with it.
    1576                 :            :   
    1577                 :            :     {
    1578                 :          0 :         ChollaEngine *cholla_ptr = NULL;
    1579                 :            : 
    1580                 :            :         status = fme->build_cholla_surfaces( facet_list,
    1581                 :            :                                              point_list,
    1582                 :            :                                              feature_angle,
    1583                 :            :                                              interp_order,
    1584                 :            :                                              smooth_non_manifold,
    1585                 :            :                                              split_surfaces,
    1586 [ #  # ][ #  # ]:          0 :                                              cholla_ptr );
         [ #  # ][ #  # ]
                 [ #  # ]
    1587         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
    1588                 :          0 :           return status;
    1589                 :            : 
    1590                 :            :         status = fme->finish_facet_Body( cholla_ptr,
    1591                 :            :                                          NULL,
    1592                 :            :                                          feature_angle, interp_order,
    1593         [ #  # ]:          0 :                                          body_out2);
    1594         [ #  # ]:          0 :         if( status == CUBIT_FAILURE )
    1595                 :          0 :           return status;
    1596         [ #  # ]:          0 :         if ( cholla_ptr )
    1597                 :            :         {
    1598         [ #  # ]:          0 :             cholla_ptr->delete_me();
    1599 [ #  # ][ #  # ]:          0 :             delete cholla_ptr;
    1600                 :            :         }
    1601                 :            :     }
    1602                 :            :                                
    1603         [ #  # ]:          0 :     if ( keep_old == false ) {
    1604         [ #  # ]:          0 :       make_persistents_imprint(body_in1,body_out1,fsurfarray1,fcurvearray1);
    1605         [ #  # ]:          0 :       make_persistents_imprint(body_in2,body_out2,fsurfarray2,fcurvearray2);
    1606                 :            :     }
    1607                 :            :     
    1608                 :            :       //separate the lumps in the "body_out1" and "body_out2", these will
    1609                 :            :       //be converted to separate volumes later in the code.
    1610         [ #  # ]:          0 :     status=separate_lumps(body_out1, is_sheet_body);
    1611         [ #  # ]:          0 :     status=separate_lumps(body_out2, is_sheet_body);
    1612         [ #  # ]:          0 :     vertsout2.clear();
    1613         [ #  # ]:          0 :     coordsout2.clear();                                      
    1614                 :            : 
    1615         [ #  # ]:          0 :   return status;
    1616                 :            : }
    1617                 :            : 
    1618                 :          0 : CubitStatus FacetboolInterface::make_FB_edge_list(DLIList<Curve*> &ref_edge_list)
    1619                 :            : {
    1620                 :          0 : CubitStatus success = CUBIT_SUCCESS;
    1621                 :            : Curve *ref_edge_ptr;
    1622                 :            : FacetCurve *cfcurve;
    1623                 :            : CubitPoint  *cfpoint;
    1624         [ #  # ]:          0 : DLIList<CubitPoint *> cfpointlist;
    1625                 :            : int i, j, lastvert, nextvert;
    1626         [ #  # ]:          0 : CubitVector coords;
    1627                 :            : 
    1628         [ #  # ]:          0 :    ref_edge_list.reset();
    1629 [ #  # ][ #  # ]:          0 :    for( i = ref_edge_list.size(); i > 0; i-- )
    1630                 :            :    {
    1631         [ #  # ]:          0 :       ref_edge_ptr = ref_edge_list.get_and_step();
    1632         [ #  # ]:          0 :       cfcurve = CAST_TO( ref_edge_ptr, FacetCurve);
    1633         [ #  # ]:          0 :       cfpointlist.clean_out();
    1634         [ #  # ]:          0 :       cfcurve->get_points(cfpointlist);
    1635         [ #  # ]:          0 :       cfpoint = cfpointlist.get_and_step();
    1636 [ #  # ][ #  # ]:          0 :       coords = cfpoint->coordinates();
    1637 [ #  # ][ #  # ]:          0 :       lastvert = find_coord(coords.x(),coords.y(),coords.z());
         [ #  # ][ #  # ]
    1638 [ #  # ][ #  # ]:          0 :       for ( j = cfpointlist.size()-1; j > 0; j-- ) {
    1639         [ #  # ]:          0 :         cfpoint = cfpointlist.get_and_step();
    1640 [ #  # ][ #  # ]:          0 :         coords = cfpoint->coordinates();
    1641 [ #  # ][ #  # ]:          0 :         nextvert = find_coord(coords.x(),coords.y(),coords.z());
         [ #  # ][ #  # ]
    1642                 :            : 
    1643 [ #  # ][ #  # ]:          0 :           FB_Edge *FBedge = new FB_Edge(lastvert,nextvert,0,0,false);
    1644         [ #  # ]:          0 :           FSBoundingBox *bb = make_edge_bounding_box(lastvert,nextvert); 
    1645                 :          0 :           lastvert = nextvert;         
    1646         [ #  # ]:          0 :           FB_imprint_edges.push_back(FBedge);
    1647         [ #  # ]:          0 :           FB_imprint_edge_bboxes.push_back(bb);
    1648                 :            :       }
    1649                 :            :    }
    1650                 :            : 
    1651         [ #  # ]:          0 :   return success;  
    1652                 :            : }
    1653                 :            : 
    1654                 :          0 : int FacetboolInterface::find_coord(double xx, double yy, double zz)
    1655                 :            : {
    1656                 :            : int value;
    1657                 :            : unsigned int i;
    1658                 :            : 
    1659                 :          0 :   value = -1;
    1660         [ #  # ]:          0 :   for ( i = 0; i < FB_imprint_edge_coords.size(); i++ ) {
    1661 [ #  # ][ #  # ]:          0 :     if ( (fabs(FB_imprint_edge_coords[i]->coord[0] - xx) < GEOMETRY_RESABS) &&
    1662 [ #  # ][ #  # ]:          0 :          (fabs(FB_imprint_edge_coords[i]->coord[1] - yy) < GEOMETRY_RESABS) &&
    1663                 :          0 :          (fabs(FB_imprint_edge_coords[i]->coord[2] - zz) < GEOMETRY_RESABS) ) {
    1664                 :          0 :       value = (int)i;
    1665                 :          0 :       break;
    1666                 :            :     }
    1667                 :            :   }  
    1668         [ #  # ]:          0 :   if ( value == -1 ) {
    1669         [ #  # ]:          0 :     value = FB_imprint_edge_coords.size();
    1670 [ #  # ][ #  # ]:          0 :     FB_Coord *FBcoord = new FB_Coord(xx,yy,zz);
    1671         [ #  # ]:          0 :     FB_imprint_edge_coords.push_back(FBcoord);
    1672                 :            :   }
    1673                 :            :       
    1674                 :          0 :   return value;
    1675                 :            : }
    1676                 :            : 
    1677                 :          0 : FSBoundingBox* FacetboolInterface::make_edge_bounding_box(int v0, int v1)
    1678                 :            : {
    1679                 :            : FSBoundingBox *bb;
    1680                 :            : double xmin, ymin, zmin, xmax, ymax, zmax;
    1681                 :            : 
    1682                 :            :   
    1683                 :          0 :   xmin = ( FB_imprint_edge_coords[v0]->coord[0] < FB_imprint_edge_coords[v1]->coord[0] ) ?
    1684         [ #  # ]:          0 :            FB_imprint_edge_coords[v0]->coord[0] : FB_imprint_edge_coords[v1]->coord[0];
    1685                 :          0 :   ymin = ( FB_imprint_edge_coords[v0]->coord[1] < FB_imprint_edge_coords[v1]->coord[1] ) ?
    1686         [ #  # ]:          0 :            FB_imprint_edge_coords[v0]->coord[1] : FB_imprint_edge_coords[v1]->coord[1];
    1687                 :          0 :   zmin = ( FB_imprint_edge_coords[v0]->coord[2] < FB_imprint_edge_coords[v1]->coord[2] ) ?
    1688         [ #  # ]:          0 :            FB_imprint_edge_coords[v0]->coord[2] : FB_imprint_edge_coords[v1]->coord[2];
    1689                 :          0 :   xmax = ( FB_imprint_edge_coords[v0]->coord[0] > FB_imprint_edge_coords[v1]->coord[0] ) ?
    1690         [ #  # ]:          0 :            FB_imprint_edge_coords[v0]->coord[0] : FB_imprint_edge_coords[v1]->coord[0];
    1691                 :          0 :   ymax = ( FB_imprint_edge_coords[v0]->coord[1] > FB_imprint_edge_coords[v1]->coord[1] ) ?
    1692         [ #  # ]:          0 :            FB_imprint_edge_coords[v0]->coord[1] : FB_imprint_edge_coords[v1]->coord[1];
    1693                 :          0 :   zmax = ( FB_imprint_edge_coords[v0]->coord[2] > FB_imprint_edge_coords[v1]->coord[2] ) ?
    1694         [ #  # ]:          0 :            FB_imprint_edge_coords[v0]->coord[2] : FB_imprint_edge_coords[v1]->coord[2];
    1695         [ #  # ]:          0 :   if ( (xmax - xmin) < 2.0*GEOMETRY_RESABS ) {
    1696                 :          0 :     xmin -= GEOMETRY_RESABS;
    1697                 :          0 :     xmax += GEOMETRY_RESABS;
    1698                 :            :   }
    1699         [ #  # ]:          0 :   if ( (ymax - ymin) < 2.0*GEOMETRY_RESABS ) {
    1700                 :          0 :     ymin -= GEOMETRY_RESABS;
    1701                 :          0 :     ymax += GEOMETRY_RESABS;
    1702                 :            :   }              
    1703         [ #  # ]:          0 :   if ( (zmax - zmin) < 2.0*GEOMETRY_RESABS ) {
    1704                 :          0 :     zmin -= GEOMETRY_RESABS;
    1705                 :          0 :     zmax += GEOMETRY_RESABS;
    1706                 :            :   }
    1707                 :            :   
    1708         [ #  # ]:          0 :   bb = new FSBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax);
    1709                 :            : 
    1710                 :          0 :   return bb;
    1711                 :            : 
    1712                 :            : }
    1713                 :            : 
    1714                 :          0 : void FacetboolInterface::get_edge_list_bbox(CubitBox& edge_list_bbox)
    1715                 :            : {
    1716                 :            : unsigned int i;
    1717                 :            : double min[3],max[3];
    1718                 :            : 
    1719                 :          0 :   min[0] = min[1] = min[2] = CUBIT_DBL_MAX - 1.0;
    1720                 :          0 :   max[0] = max[1] = max[2] = -CUBIT_DBL_MAX;  
    1721                 :            : 
    1722 [ #  # ][ #  # ]:          0 :   for ( i = 0; i < FB_imprint_edge_coords.size(); i++ ) {
    1723         [ #  # ]:          0 :     min[0] = ( min[0] < FB_imprint_edge_coords[i]->coord[0] ) ? min[0] : 
    1724 [ #  # ][ #  # ]:          0 :                     FB_imprint_edge_coords[i]->coord[0];
    1725         [ #  # ]:          0 :     min[1] = ( min[1] < FB_imprint_edge_coords[i]->coord[1] ) ? min[1] : 
    1726 [ #  # ][ #  # ]:          0 :                     FB_imprint_edge_coords[i]->coord[1];
    1727         [ #  # ]:          0 :     min[2] = ( min[2] < FB_imprint_edge_coords[i]->coord[2] ) ? min[2] : 
    1728 [ #  # ][ #  # ]:          0 :                     FB_imprint_edge_coords[i]->coord[2];                     
    1729         [ #  # ]:          0 :     max[0] = ( max[0] > FB_imprint_edge_coords[i]->coord[0] ) ? max[0] : 
    1730 [ #  # ][ #  # ]:          0 :                     FB_imprint_edge_coords[i]->coord[0];
    1731         [ #  # ]:          0 :     max[1] = ( max[1] > FB_imprint_edge_coords[i]->coord[1] ) ? max[1] : 
    1732 [ #  # ][ #  # ]:          0 :                     FB_imprint_edge_coords[i]->coord[1];
    1733         [ #  # ]:          0 :     max[2] = ( max[2] > FB_imprint_edge_coords[i]->coord[2] ) ? max[2] : 
    1734 [ #  # ][ #  # ]:          0 :                     FB_imprint_edge_coords[i]->coord[2];
    1735                 :            :   }
    1736         [ #  # ]:          0 :   if ( (max[0] - min[0]) < 2.0*GEOMETRY_RESABS ) {
    1737                 :          0 :     min[0] -= GEOMETRY_RESABS;
    1738                 :          0 :     max[0] += GEOMETRY_RESABS;
    1739                 :            :   }
    1740         [ #  # ]:          0 :   if ( (max[1] - min[1]) < 2.0*GEOMETRY_RESABS ) {
    1741                 :          0 :     min[1] -= GEOMETRY_RESABS;
    1742                 :          0 :     max[1] += GEOMETRY_RESABS;
    1743                 :            :   }              
    1744         [ #  # ]:          0 :   if ( (max[2] - min[2]) < 2.0*GEOMETRY_RESABS ) {
    1745                 :          0 :     min[2] -= GEOMETRY_RESABS;
    1746                 :          0 :     max[2] += GEOMETRY_RESABS;
    1747                 :            :   }   
    1748         [ #  # ]:          0 :   CubitBox box(min,max);
    1749 [ #  # ][ #  # ]:          0 :   edge_list_bbox = box; 
    1750                 :            : 
    1751 [ +  - ][ +  - ]:       6540 : }
    1752                 :            : 
    1753                 :            : 
    1754                 :            : 

Generated by: LCOV version 1.11