LCOV - code coverage report
Current view: top level - geom/Cholla - ChollaEngine.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 573 2083 27.5 %
Date: 2020-06-30 00:58:45 Functions: 32 83 38.6 %
Branches: 652 4546 14.3 %

           Branch data     Line data    Source code
       1                 :            : //- Class:       ChollaEngine
       2                 :            : //- Description: Creates the topology for a given geometry described by facets.
       3                 :            : //- Owner:       Steven J. Owen
       4                 :            : //- Checked by:
       5                 :            : //- Version:
       6                 :            : //#include <list>
       7                 :            : #include <set>
       8                 :            : #include <map>
       9                 :            : #include <vector>
      10                 :            : #include "CubitDefines.h"
      11                 :            : #include "ChollaEngine.hpp"
      12                 :            : #include "DLIList.hpp"
      13                 :            : #include "TDGeomFacet.hpp"
      14                 :            : #include "CastTo.hpp"
      15                 :            : #include "ChollaSkinTool.hpp"
      16                 :            : #include "ChollaVolume.hpp"
      17                 :            : #include "ChollaSurface.hpp"
      18                 :            : #include "ChollaCurve.hpp"
      19                 :            : #include "ChollaPoint.hpp"
      20                 :            : #include "CubitFacet.hpp"
      21                 :            : #include "CubitFacetData.hpp"
      22                 :            : #include "CubitFacetEdge.hpp"
      23                 :            : #include "CubitFacetEdgeData.hpp"
      24                 :            : #include "CubitPoint.hpp"
      25                 :            : #include "CubitPointData.hpp"
      26                 :            : #include "FacetEntity.hpp"
      27                 :            : #include "FacetEvalTool.hpp"
      28                 :            : #include "FacetDataUtil.hpp"
      29                 :            : #include "ChollaDebug.hpp"
      30                 :            : #include "TDFacetBoundaryEdge.hpp"
      31                 :            : #include "TDFacetBoundaryPoint.hpp"
      32                 :            : #include "CurveFacetEvalTool.hpp"
      33                 :            : #include "Cholla.h"
      34                 :            : #include "GfxDebug.hpp"
      35                 :            : #include "TDFacetboolData.hpp"
      36                 :            : #include "GMem.hpp"
      37                 :            : 
      38                 :            : //============================================================================
      39                 :            : //Function:  ChollaEngine (PUBLIC) (constructor)
      40                 :            : //============================================================================
      41 [ #  # ][ #  # ]:          0 : ChollaEngine::ChollaEngine()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      42                 :            : {
      43                 :          0 :   hashCurveArray = NULL;
      44                 :          0 :   hashCurveSize = 0;
      45                 :          0 :   hashPointArray = NULL;
      46                 :          0 :   hashPointSize = 0;
      47                 :          0 : }
      48                 :            : 
      49                 :            : //============================================================================
      50                 :            : //Function:  ChollaEngine (PUBLIC) (constructor)
      51                 :            : //============================================================================
      52                 :         88 : ChollaEngine::ChollaEngine(DLIList<FacetEntity*> &face_list,
      53                 :            :                            DLIList<FacetEntity*> &edge_list,
      54 [ +  - ][ +  - ]:         88 :                            DLIList<FacetEntity*> &point_list )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      55                 :            : {
      56         [ +  - ]:         88 :   faceList = face_list;
      57         [ +  - ]:         88 :   edgeList = edge_list;
      58         [ +  - ]:         88 :   pointList = point_list;
      59         [ +  - ]:         88 :   set_up_tool_datas();
      60                 :         88 :   hashCurveArray = NULL;
      61                 :         88 :   hashCurveSize = 0;
      62                 :         88 :   hashPointArray = NULL;
      63                 :         88 :   hashPointSize = 0;
      64                 :         88 :   doFlip = CUBIT_FALSE;
      65                 :         88 : }
      66                 :            : 
      67                 :            : //============================================================================
      68                 :            : //Function:  ChollaEngine (PUBLIC) (constructor)
      69                 :            : //============================================================================
      70                 :          0 : ChollaEngine::ChollaEngine(DLIList<CubitFacet*>     &facet_list,
      71                 :            :                            DLIList<CubitFacetEdge*> &edge_list,
      72 [ #  # ][ #  # ]:          0 :                            DLIList<CubitPoint*>     &point_list )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      73                 :            : {
      74 [ #  # ][ #  # ]:          0 :   CAST_LIST(facet_list, faceList, FacetEntity);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      75 [ #  # ][ #  # ]:          0 :   CAST_LIST(edge_list, edgeList, FacetEntity);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      76 [ #  # ][ #  # ]:          0 :   CAST_LIST(point_list, pointList, FacetEntity);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      77         [ #  # ]:          0 :   set_up_tool_datas();
      78                 :          0 :   hashCurveArray = NULL;
      79                 :          0 :   hashCurveSize = 0;
      80                 :          0 :   hashPointArray = NULL;
      81                 :          0 :   hashPointSize = 0;
      82                 :          0 :   doFlip = CUBIT_FALSE;
      83                 :          0 : }
      84                 :            : 
      85                 :            : //============================================================================
      86                 :            : //Function:  ChollaEngine (PUBLIC) (constructor)
      87                 :            : //Notes: This case is used only when the cholla entities have been generated 
      88                 :            : //       directly rather than using create_geometry
      89                 :            : //       Does not use the TDGeomFacet Tooldatas
      90                 :            : //============================================================================
      91                 :          0 : ChollaEngine::ChollaEngine(DLIList<CubitFacet*>     &facet_list,
      92                 :            :                            DLIList<CubitFacetEdge*> &edge_list,
      93                 :            :                            DLIList<CubitPoint*>     &point_list,
      94                 :            :                            DLIList<ChollaVolume *>  &cholla_volumes,
      95                 :            :                            DLIList<ChollaSurface *> &cholla_surfaces,
      96                 :            :                            DLIList<ChollaCurve *>   &cholla_curves,
      97 [ #  # ][ #  # ]:          0 :                            DLIList<ChollaPoint *>   &cholla_points )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      98                 :            : {
      99 [ #  # ][ #  # ]:          0 :   CAST_LIST(facet_list, faceList, FacetEntity);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     100 [ #  # ][ #  # ]:          0 :   CAST_LIST(edge_list, edgeList, FacetEntity);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     101 [ #  # ][ #  # ]:          0 :   CAST_LIST(point_list, pointList, FacetEntity);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     102                 :            :   //set_up_tool_datas();  TDGeomFacet tooldatas should have already been added
     103                 :            : 
     104                 :          0 :   hashCurveArray = NULL;
     105                 :          0 :   hashCurveSize = 0;
     106                 :          0 :   hashPointArray = NULL;
     107                 :          0 :   hashPointSize = 0;
     108                 :          0 :   doFlip = CUBIT_FALSE;
     109                 :            :   
     110         [ #  # ]:          0 :   chollaVolumeList = cholla_volumes;
     111         [ #  # ]:          0 :   chollaSurfaceList = cholla_surfaces;
     112         [ #  # ]:          0 :   chollaCurveList = cholla_curves;
     113         [ #  # ]:          0 :   chollaPointList = cholla_points;
     114                 :          0 : }
     115                 :            :                           
     116                 :            : 
     117                 :            : //============================================================================
     118                 :            : //Function:  set_up_tool_datas
     119                 :            : //============================================================================
     120                 :         88 : void ChollaEngine::set_up_tool_datas( )
     121                 :            : {
     122                 :            :   int ii;
     123                 :            :   FacetEntity *fe_ptr;
     124         [ +  + ]:       1144 :   for (ii=0; ii<faceList.size(); ii++)
     125                 :            :   {
     126                 :       1056 :     fe_ptr = faceList.get_and_step();
     127                 :       1056 :     TDGeomFacet::add_geom_facet( fe_ptr, -1 );
     128                 :            :   }
     129         [ +  + ]:        902 :   for (ii=0; ii<pointList.size(); ii++)
     130                 :            :   {
     131                 :        814 :     fe_ptr = pointList.get_and_step();
     132                 :        814 :     TDGeomFacet::add_geom_facet( fe_ptr, -1 );
     133                 :            :   }
     134                 :         88 : }
     135                 :            : 
     136                 :          0 : CubitStatus ChollaEngine::build_eval_tools()
     137                 :            : {
     138                 :          0 :   CubitBoolean use_feature_angle = CUBIT_FALSE; 
     139                 :          0 :   double min_dot = 0.0;                    
     140                 :          0 :   int interp_order = 0;                 
     141                 :          0 :   CubitBoolean smooth_non_manifold = CUBIT_FALSE;
     142                 :          0 :   CubitBoolean split_surfaces = CUBIT_FALSE;
     143                 :            : 
     144                 :            :   return build_eval_tools( chollaSurfaceList,
     145                 :            :                            chollaCurveList,
     146                 :            :                            interp_order, use_feature_angle, 
     147                 :            :                            min_dot, smooth_non_manifold,
     148                 :          0 :                            split_surfaces );
     149                 :            : }
     150                 :            : 
     151                 :            : //============================================================================
     152                 :            : //Function:  delete_tool_datas
     153                 :            : //============================================================================
     154                 :         88 : void ChollaEngine::delete_tool_datas( )
     155                 :            : {
     156                 :            :   int ii;
     157                 :            :   FacetEntity *fe_ptr;
     158         [ +  + ]:       1144 :   for (ii=0; ii<faceList.size(); ii++)
     159                 :            :   {
     160                 :       1056 :     fe_ptr = faceList.get_and_step();
     161                 :       1056 :     fe_ptr->delete_TD( &TDGeomFacet::is_geom_facet );
     162                 :            :   }
     163         [ +  + ]:       1782 :   for (ii=0; ii<edgeList.size(); ii++)
     164                 :            :   {
     165                 :       1694 :     fe_ptr = edgeList.get_and_step();
     166                 :       1694 :     fe_ptr->delete_TD( &TDGeomFacet::is_geom_facet );
     167                 :            :   }
     168         [ +  + ]:        902 :   for (ii=0; ii<pointList.size(); ii++)
     169                 :            :   {
     170                 :        814 :     fe_ptr = pointList.get_and_step();
     171                 :        814 :     fe_ptr->delete_TD( &TDGeomFacet::is_geom_facet );
     172                 :            :   }
     173                 :         88 : }
     174                 :            : 
     175                 :            : //============================================================================
     176                 :            : //Function:  delete_eval_tools
     177                 :            : //============================================================================
     178                 :          0 : void ChollaEngine::delete_eval_tools()
     179                 :            : {
     180                 :            : 
     181                 :          0 :   delete_tool_datas();
     182                 :            :   int ii;
     183                 :          0 :   ChollaSurface *cs_ptr = NULL;
     184                 :            :   FacetEvalTool *fe_tool_ptr;
     185         [ #  # ]:          0 :   for (ii = chollaSurfaceList.size(); ii > 0; ii-- )
     186                 :            :   {
     187                 :          0 :     cs_ptr = chollaSurfaceList.get_and_step();
     188                 :          0 :     fe_tool_ptr = cs_ptr->get_eval_tool();
     189         [ #  # ]:          0 :     if (fe_tool_ptr)
     190         [ #  # ]:          0 :       delete fe_tool_ptr;
     191                 :            :   }
     192                 :          0 :   ChollaCurve *cc_ptr = NULL;
     193                 :            :   CurveFacetEvalTool *ce_tool_ptr;
     194         [ #  # ]:          0 :   for (ii = chollaCurveList.size(); ii > 0; ii-- )
     195                 :            :   {
     196                 :          0 :     cc_ptr = chollaCurveList.get_and_step();
     197                 :          0 :     ce_tool_ptr = cc_ptr->get_eval_tool();
     198         [ #  # ]:          0 :     if (ce_tool_ptr)
     199         [ #  # ]:          0 :       delete ce_tool_ptr;
     200                 :            :   }
     201                 :          0 :   faceList.clean_out();
     202                 :          0 :   edgeList.clean_out();
     203                 :          0 :   pointList.clean_out();
     204                 :          0 : }
     205                 :            : 
     206                 :            : //============================================================================
     207                 :            : //Function:  delete_eval_tools_but_not_facets
     208                 :            : //============================================================================
     209                 :          0 : void ChollaEngine::delete_eval_tools_but_not_facets()
     210                 :            : {
     211                 :            : 
     212                 :          0 :   delete_tool_datas();
     213                 :            :   int ii;
     214                 :          0 :   ChollaSurface *cs_ptr = NULL;
     215                 :            :   FacetEvalTool *fe_tool_ptr;
     216         [ #  # ]:          0 :   for (ii = chollaSurfaceList.size(); ii > 0; ii-- )
     217                 :            :   {
     218                 :          0 :     cs_ptr = chollaSurfaceList.get_and_step();
     219                 :          0 :     fe_tool_ptr = cs_ptr->get_eval_tool();
     220         [ #  # ]:          0 :     if (fe_tool_ptr)
     221                 :            :     {
     222         [ #  # ]:          0 :       DLIList<CubitFacet *>facets;
     223         [ #  # ]:          0 :       fe_tool_ptr->remove_facets(facets);
     224 [ #  # ][ #  # ]:          0 :       delete fe_tool_ptr;
                 [ #  # ]
     225                 :            :     }
     226                 :            :   }
     227                 :          0 :   ChollaCurve *cc_ptr = NULL;
     228                 :            :   CurveFacetEvalTool *ce_tool_ptr;
     229         [ #  # ]:          0 :   for (ii = chollaCurveList.size(); ii > 0; ii-- )
     230                 :            :   {
     231                 :          0 :     cc_ptr = chollaCurveList.get_and_step();
     232                 :          0 :     ce_tool_ptr = cc_ptr->get_eval_tool();
     233         [ #  # ]:          0 :     if (ce_tool_ptr)
     234                 :            :     {
     235         [ #  # ]:          0 :       delete ce_tool_ptr;
     236                 :            :     }
     237                 :            :   }
     238                 :          0 :   faceList.clean_out();
     239                 :          0 :   edgeList.clean_out();
     240                 :          0 :   pointList.clean_out();
     241                 :          0 : }
     242                 :            : 
     243                 :            : //============================================================================
     244                 :            : //Function:  ~ChollaEngine (PUBLIC) (destructor)
     245                 :            : //============================================================================
     246 [ +  - ][ +  - ]:        176 : ChollaEngine::~ChollaEngine()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     247                 :            : {
     248                 :         88 : }
     249                 :            : 
     250                 :            : //============================================================================
     251                 :            : //Function:  delete (PUBLIC)
     252                 :            : //Description: removes all cholla entities stored with the cholla engine
     253                 :            : //             usually called before destructor
     254                 :            : //============================================================================
     255                 :         88 : void ChollaEngine::delete_me()
     256                 :            : {
     257                 :         88 :   delete_tool_datas();
     258                 :            :   int ii;
     259                 :            :     //clean up any data remaining.
     260         [ +  + ]:        506 :   for (ii = chollaPointList.size(); ii > 0; ii-- )
     261         [ +  - ]:        418 :     delete chollaPointList.remove();
     262         [ +  + ]:        682 :   for (ii = chollaCurveList.size(); ii > 0; ii-- )
     263         [ +  - ]:        594 :     delete chollaCurveList.remove();
     264         [ +  + ]:        429 :   for (ii = chollaSurfaceList.size(); ii > 0; ii-- )
     265         [ +  - ]:        341 :     delete chollaSurfaceList.remove();
     266                 :            :   
     267                 :         88 : }
     268                 :            : 
     269                 :            : //==================================================================================
     270                 :            : //Function:  create_geometry (PUBLIC)
     271                 :            : //Description:  Interface function to acutally create the topology
     272                 :            : //              for the given mesh.
     273                 :            : //==================================================================================
     274                 :        176 : CubitStatus ChollaEngine::create_geometry(
     275                 :            :   CubitBoolean use_feature_angle,   // use an angle to define where to break surfaces
     276                 :            :   double angle,                     // the feature angle
     277                 :            :   int interp_order,                 // 0=linear, 4=b-spline patches
     278                 :            :   CubitBoolean smooth_non_manifold, // check for continuity accross >2 valence edges
     279                 :            :   CubitBoolean split_surfaces)      // create new FacetEntities to split surfaces at
     280                 :            :                                     // at features.  Otherwise - don't mess with the
     281                 :            :                                     // FacetEntities. (creates TDs instead)
     282                 :            : 
     283                 :            : {
     284                 :            :   if (0)
     285                 :            :   {
     286                 :            :     dump("cyl.cholla", angle);
     287                 :            :   }
     288                 :            : 
     289                 :            :   //- convert feature angle to a dot product
     290                 :            : 
     291                 :         88 :   double min_dot = 0.0;
     292         [ +  + ]:         88 :   if (use_feature_angle)
     293                 :            :   {
     294         [ -  + ]:         44 :     if (angle > 180.0) angle = 180.0;
     295         [ -  + ]:         44 :     if (angle < 0.0) angle = 0.0;
     296                 :         44 :     double rad_angle = (180.0 - angle) * CUBIT_PI / 180.0;
     297                 :         44 :     min_dot = cos( rad_angle );
     298                 :            :   }
     299                 :            : 
     300                 :            :   //- create one facet surface to start with
     301                 :            : 
     302         [ +  - ]:         88 :   ChollaSkinTool c_skin_tool;
     303                 :         88 :   ChollaSurface *cholla_surface_ptr = NULL;
     304         [ +  - ]:         88 :   CubitStatus stat = c_skin_tool.skin_2d(faceList, cholla_surface_ptr);
     305         [ -  + ]:         88 :   if ( stat != CUBIT_SUCCESS )
     306                 :          0 :     return stat;
     307         [ +  - ]:         88 :   if ( cholla_surface_ptr )
     308         [ +  - ]:         88 :     chollaSurfaceList.append(cholla_surface_ptr);
     309                 :            : 
     310                 :            :   // before building the surfaces, orient the facets so they are consistent
     311                 :            :   
     312 [ +  - ][ +  - ]:        176 :   DLIList<CubitFacet *>total_facet_list;
     313 [ +  - ][ +  - ]:       1144 :   CAST_LIST( faceList, total_facet_list, CubitFacet );
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
     314                 :            :   //stat = check_all_facet_orientations( total_facet_list, doFlip );
     315         [ -  + ]:         88 :   if (stat!=CUBIT_SUCCESS)
     316                 :          0 :     return stat;
     317                 :            :   
     318                 :            :   // generate the topology from the facets
     319                 :            : 
     320                 :            :   stat = create_volume_boundaries( chollaSurfaceList,
     321                 :            :                                    use_feature_angle, min_dot, 
     322         [ +  - ]:         88 :                                    split_surfaces );
     323         [ -  + ]:         88 :   if ( stat == CUBIT_FAILURE )
     324                 :          0 :     return stat;
     325                 :            : 
     326                 :            :   stat = create_surface_boundaries( chollaSurfaceList, chollaCurveList,
     327         [ +  - ]:         88 :                                     use_feature_angle, min_dot );
     328         [ -  + ]:         88 :   if ( stat == CUBIT_FAILURE )
     329                 :          0 :     return stat;
     330                 :            : 
     331         [ +  - ]:         88 :   stat = create_curve_boundaries( chollaCurveList, chollaPointList );
     332         [ -  + ]:         88 :   if ( stat == CUBIT_FAILURE )
     333                 :          0 :     return stat;
     334                 :            : 
     335                 :            :     // Okay.  Now we are ready to actually build the geometry.
     336                 :         88 :   int mydebug = 0;
     337         [ -  + ]:         88 :   if (mydebug)
     338         [ #  # ]:          0 :     print_me();
     339                 :            : 
     340                 :            :   stat = build_eval_tools( chollaSurfaceList,
     341                 :            :                            chollaCurveList,
     342                 :            :                            interp_order, use_feature_angle, 
     343                 :            :                            min_dot, smooth_non_manifold,
     344         [ +  - ]:         88 :                            split_surfaces );
     345                 :            : 
     346         [ +  - ]:        176 :   return stat;
     347                 :            : }
     348                 :            : 
     349                 :            : //=============================================================================
     350                 :            : //Function:  create_volume_boundaries (PRIVATE)
     351                 :            : //Description: creates the surfaces based on the sideset and element block
     352                 :            : //             information
     353                 :            : //Author: sjowen
     354                 :            : //Date: 10/17/00
     355                 :            : //=============================================================================
     356                 :         88 : CubitStatus ChollaEngine::create_volume_boundaries( 
     357                 :            :   DLIList<ChollaSurface*> &cholla_surface_sheets,  // output global list of surfaces
     358                 :            :   CubitBoolean use_feature_angle,   // define surfaces based on feature angle
     359                 :            :   double min_dot,      // minimum dot product between face normals
     360                 :            :   CubitBoolean split_surfaces )  // create new FacetEntities to split surfaces at
     361                 :            :                                  // at features.  Otherwise - don't mess with the
     362                 :            :                                  // FacetEntities. (creates TDs instead)
     363                 :            : {
     364                 :         88 :   CubitStatus rv = CUBIT_SUCCESS;
     365                 :            : 
     366                 :            :   // Split these surfaces so that there is only one set of continuous
     367                 :            :   // faces per surface 
     368                 :            : 
     369                 :            :   int ii;
     370                 :         88 :   int num_surfaces = cholla_surface_sheets.size();
     371                 :         88 :   cholla_surface_sheets.reset();
     372         [ +  + ]:        176 :   for ( ii = num_surfaces; ii > 0; ii-- )
     373                 :            :   {
     374                 :            : 
     375         [ +  - ]:         88 :     ChollaSurface *chsurf_ptr = cholla_surface_sheets.get_and_step();
     376                 :            : 
     377         [ +  - ]:         88 :     DLIList<FacetEntity*> surf_facet_list;
     378                 :            :     FacetEntity *sfacet;    
     379         [ +  - ]:         88 :     chsurf_ptr->get_facets(surf_facet_list);
     380 [ +  - ][ +  - ]:        176 :     DLIList<CubitFacet*> facet_list;
                 [ +  - ]
     381                 :            :     CubitFacet *facet;
     382                 :            :     CubitFacetEdge *fedge;
     383                 :            :     int kk, mm;
     384                 :         88 :     int mydebug = 0;
     385         [ -  + ]:         88 :     if(mydebug){
     386         [ #  # ]:          0 :       GfxDebug::clear();
     387                 :            :     }
     388 [ +  - ][ +  - ]:        176 :     DLIList<CubitFacetEdge *> feature_edge_list;
                 [ +  - ]
     389 [ +  - ][ +  + ]:       1144 :     for ( kk = surf_facet_list.size(); kk > 0; kk-- ) {
     390         [ +  - ]:       1056 :       sfacet = surf_facet_list.get_and_step();
     391         [ +  - ]:       1056 :       facet_list.clean_out();
     392         [ +  - ]:       1056 :       sfacet->facets(facet_list);
     393         [ +  - ]:       1056 :       facet = facet_list.get();
     394         [ +  - ]:       1056 :       TDFacetboolData* tdf = TDFacetboolData::get(facet);
     395         [ -  + ]:       1056 :       if ( tdf ) {
     396                 :            :         int *cptr;
     397 [ #  # ][ #  # ]:          0 :         cptr = tdf->get_edge_indices( (bool) facet->is_backwards());
     398         [ #  # ]:          0 :         for ( mm = 0; mm < 3; mm++ ) {
     399         [ #  # ]:          0 :           if ( cptr[mm] != 0 ) {
     400         [ #  # ]:          0 :             fedge = facet->edge((2+mm)%3);
     401         [ #  # ]:          0 :             if(mydebug){
     402 [ #  # ][ #  # ]:          0 :               if(facet->is_backwards()){
     403 [ #  # ][ #  # ]:          0 :                 facet->edge((1+mm)%3)->debug_draw(CUBIT_GREEN_INDEX);
     404 [ #  # ][ #  # ]:          0 :                 facet->edge((mm)%3)->debug_draw(CUBIT_RED_INDEX);
     405                 :            :               
     406         [ #  # ]:          0 :                 fedge->debug_draw(CUBIT_BLUE_INDEX);
     407                 :            :               }
     408                 :            :               else
     409         [ #  # ]:          0 :                 fedge->debug_draw(CUBIT_WHITE_INDEX);
     410                 :            :             }
     411                 :            :             
     412         [ #  # ]:          0 :             TDGeomFacet::add_geom_facet(fedge, -1);
     413         [ #  # ]:          0 :             fedge->set_as_feature();
     414         [ #  # ]:          0 :             feature_edge_list.append( fedge );
     415                 :            :           }            
     416                 :            :         }
     417                 :            :       }
     418                 :            :     }
     419         [ -  + ]:         88 :     if(mydebug){
     420         [ #  # ]:          0 :       GfxDebug::mouse_xforms();
     421                 :            :     }
     422                 :            :     // make a list of feature edges
     423                 :            : 
     424         [ +  - ]:         88 :     rv = chsurf_ptr->add_preexisting_feature_edges( feature_edge_list );
     425         [ -  + ]:         88 :                 if (rv != CUBIT_SUCCESS)
     426                 :          0 :                         return rv;
     427                 :            :                 
     428         [ +  + ]:         88 :     if (use_feature_angle)
     429                 :            :     {
     430         [ +  - ]:         44 :       rv = chsurf_ptr->feature_angle( min_dot, feature_edge_list );
     431                 :            :     }
     432                 :            :     else
     433                 :            :     {
     434         [ +  - ]:         44 :       rv = chsurf_ptr->non_manifold_edges( feature_edge_list );
     435                 :            :     }
     436         [ -  + ]:         88 :     if (rv != CUBIT_SUCCESS)
     437                 :          0 :       return rv;
     438                 :            : 
     439                 :            :      // crack the surface at the feature edges.  create new edges and
     440                 :            :      // points so the facet representation is discontinuous.
     441                 :            : 
     442         [ +  - ]:         88 :     rv = make_features( feature_edge_list, split_surfaces );
     443         [ -  + ]:         88 :     if (rv != CUBIT_SUCCESS)
     444                 :          0 :        return rv;
     445                 :            : 
     446                 :            :     // split up the surface
     447                 :            : 
     448         [ +  - ]:         88 :     rv = chsurf_ptr->split_surface( cholla_surface_sheets );
     449         [ -  + ]:         88 :     if (rv != CUBIT_SUCCESS)
     450 [ +  - ][ +  - ]:         88 :        return rv;
     451                 :         88 :   }
     452                 :            : 
     453                 :            :   // Clean up any edges that do not form complete loops as a result of 
     454                 :            :   // feature angle.  For this implementation we will allow features to exist
     455                 :            :   // within the surface without defining a complete loop. -- so the next
     456                 :            :   // piece of code is never executed.
     457                 :            : 
     458                 :         88 :   CubitBoolean use_complete_loops_only = CUBIT_FALSE;
     459 [ +  + ][ -  + ]:         88 :   if (use_feature_angle && use_complete_loops_only)
     460                 :            :   {
     461         [ #  # ]:          0 :     for ( ii = cholla_surface_sheets.size(); ii > 0; ii-- )
     462                 :            :     {
     463                 :          0 :       ChollaSurface *chsurf_ptr = cholla_surface_sheets.get_and_step();
     464                 :          0 :       chsurf_ptr->clean_features();
     465                 :            :     }
     466                 :            :   }
     467                 :            : 
     468                 :            :   // Now that we've broken everything into surfaces, update the surface IDs
     469                 :            :   // on the boundary facet tool data
     470                 :            : 
     471         [ +  - ]:         88 :   if (!split_surfaces)
     472                 :            :   {
     473         [ +  + ]:        429 :     for ( ii = cholla_surface_sheets.size(); ii > 0; ii-- )
     474                 :            :     {
     475                 :        341 :       ChollaSurface *chsurf_ptr = cholla_surface_sheets.get_and_step();
     476                 :        341 :       chsurf_ptr->update_boundary_tool_data();
     477                 :            :     }
     478                 :            :   }
     479                 :         88 :   return rv;
     480                 :            : }
     481                 :            : 
     482                 :            : 
     483                 :            : //=============================================================================
     484                 :            : //Function:  create_surface_boundaries (PRIVATE)
     485                 :            : //Description: creates the curves based on the facet surface information
     486                 :            : //Author: sjowen
     487                 :            : //Date: 12/3/00
     488                 :            : //=============================================================================
     489                 :         88 : CubitStatus ChollaEngine::create_surface_boundaries(
     490                 :            :   DLIList<ChollaSurface*> &cholla_surface_list, // global list of surfaces
     491                 :            :   DLIList<ChollaCurve*> &cholla_curve_list,     // output global list of curves
     492                 :            :   CubitBoolean use_feature_angle,
     493                 :            :   double min_dot )
     494                 :            : {
     495                 :         88 :   CubitStatus stat = CUBIT_SUCCESS;
     496                 :            : 
     497                 :            :     // determine the boundaries for each surface.  One curve per surface
     498                 :            : 
     499                 :            :   int ii;
     500         [ +  + ]:        429 :   for ( ii = cholla_surface_list.size(); ii > 0; ii-- )
     501                 :            :   {
     502         [ +  - ]:        341 :     ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
     503         [ +  - ]:        341 :     DLIList<ChollaCurve*> chcurve_list;
     504         [ +  - ]:        341 :     chsurf_ptr->get_curves( chcurve_list );
     505 [ +  - ][ +  + ]:        341 :     if (chcurve_list.size() == 0)
     506                 :            :     {
     507         [ +  - ]:        308 :       DLIList<FacetEntity*> facet_list;
     508         [ +  - ]:        308 :       chsurf_ptr->get_facets(facet_list);
     509 [ +  - ][ +  - ]:        616 :       ChollaSkinTool c_skin_tool;
                 [ +  - ]
     510         [ +  - ]:        308 :       stat = c_skin_tool.skin_2d(facet_list, chsurf_ptr);
     511         [ -  + ]:        308 :       if ( stat != CUBIT_SUCCESS )
     512 [ +  - ][ +  - ]:        649 :         return stat;
         [ +  - ][ +  - ]
     513                 :            :     }
     514                 :        341 :   }
     515                 :            : 
     516                 :            :   // create a hash list of curves - to speed up classification
     517                 :            : 
     518                 :         88 :   stat = init_hash_curves();
     519         [ -  + ]:         88 :   if (stat != CUBIT_SUCCESS)
     520                 :            :   {
     521                 :          0 :     delete_hash_curves();
     522                 :          0 :     return stat;
     523                 :            :   }
     524                 :            : 
     525                 :            :   // loop through each of the edges on the surfaces
     526                 :            :   // Determine which curve it is a part of.
     527                 :            :   // Create a new ChollaCurve for each curve
     528                 :            :   // Curves are created wherever there is a unique set of associated
     529                 :            :   // surfaces 
     530                 :            : 
     531                 :            :   int jj, kk;
     532         [ +  + ]:        429 :   for ( ii = cholla_surface_list.size(); ii > 0; ii-- )
     533                 :            :   {
     534                 :            : 
     535         [ +  - ]:        341 :     ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
     536         [ +  - ]:        341 :     DLIList<ChollaCurve*> chcurve_list;
     537         [ +  - ]:        341 :     chsurf_ptr->get_curves( chcurve_list );
     538                 :            : 
     539                 :            :     // curently there should only be one curve list per surface
     540                 :            : 
     541 [ +  - ][ +  + ]:        682 :     for (jj=chcurve_list.size(); jj>0; jj--)
         [ +  - ][ +  - ]
     542                 :            :     {
     543         [ +  - ]:        341 :       ChollaCurve *chcurv_ptr = chcurve_list.get_and_step();
     544 [ +  - ][ +  - ]:        341 :       DLIList<FacetEntity*> facet_list =  chcurv_ptr->get_facet_list();
     545                 :            :       FacetEntity *edge_ptr;
     546 [ +  - ][ +  + ]:       1617 :       for ( kk = 0; kk < facet_list.size(); kk++)
     547                 :            :       {
     548         [ +  - ]:       1276 :         edge_ptr = facet_list.get_and_step();
     549         [ +  - ]:       1276 :         stat = classify_edge( edge_ptr, cholla_curve_list, chsurf_ptr );
     550         [ -  + ]:       1276 :         if (stat != CUBIT_SUCCESS) 
     551                 :          0 :           return stat;
     552                 :            :       }
     553                 :            : 
     554                 :            :       // delete this ChollaCurve - it should have been replaced by one
     555                 :            :       // or more curves bounding this surface
     556                 :            : 
     557         [ +  - ]:        341 :       chsurf_ptr->remove_curve( chcurv_ptr );
     558 [ +  - ][ +  - ]:        341 :       delete chcurv_ptr;
         [ +  - ][ +  - ]
     559                 :        341 :     }
     560                 :        341 :   }
     561                 :         88 :   delete_hash_curves();
     562                 :            : 
     563                 :            :   // Split these curves so that there is only one string of continuous
     564                 :            :   // edges per curve (it will also order the edges and set the start
     565                 :            :   // and end nodes for each curve) 
     566                 :            : 
     567                 :         88 :   int num_curves = cholla_curve_list.size();
     568                 :            : 
     569                 :         88 :   cholla_curve_list.reset();
     570 [ +  + ][ +  - ]:        682 :   for ( ii = num_curves; ii > 0 && stat == CUBIT_SUCCESS; ii-- )
     571                 :            :   {
     572                 :        594 :     ChollaCurve *chcurv_ptr = cholla_curve_list.get();
     573                 :            : 
     574                 :            :     // if necessary mark nodes that will serve as feature breaks (vertices 
     575                 :            :     // will be generatedat them)
     576                 :            : 
     577         [ +  + ]:        594 :     if (use_feature_angle)
     578                 :            :     {
     579                 :        528 :       stat = chcurv_ptr->feature_angle( min_dot );
     580         [ -  + ]:        528 :       if (stat != CUBIT_SUCCESS)
     581                 :          0 :          return stat;
     582                 :            :     }
     583                 :            : 
     584                 :            :     // split the curve based on various criteria
     585                 :            : 
     586                 :        594 :     stat = chcurv_ptr->split_curve( cholla_curve_list );
     587                 :            : 
     588                 :            :     // delete this curve (new curves were created in split_curve)
     589                 :            : 
     590         [ +  - ]:        594 :     delete chcurv_ptr;
     591                 :        594 :     cholla_curve_list.change_to(NULL);
     592                 :        594 :     cholla_curve_list.step();
     593                 :            :   }
     594         [ +  - ]:         88 :   cholla_curve_list.remove_all_with_value(NULL);
     595                 :            : 
     596                 :            :   // update the point->curve associativity
     597                 :            : 
     598         [ +  + ]:        682 :   for (ii=0; ii<cholla_curve_list.size(); ii++)
     599                 :            :   {
     600         [ +  - ]:        594 :     ChollaCurve *chcurv_ptr = cholla_curve_list.get_and_step();
     601                 :            :     CubitPoint *start_ptr, *end_ptr;
     602         [ +  - ]:        594 :     chcurv_ptr->get_ends( start_ptr, end_ptr );
     603         [ +  - ]:        594 :     TDGeomFacet *td = TDGeomFacet::get_geom_facet( start_ptr );
     604         [ +  - ]:        594 :     td->add_cholla_curve( chcurv_ptr );
     605         [ +  - ]:        594 :     td = TDGeomFacet::get_geom_facet( end_ptr );
     606         [ +  - ]:        594 :     td->add_cholla_curve( chcurv_ptr );
     607                 :            :   }
     608                 :            : 
     609                 :         88 :   return stat;
     610                 :            : }
     611                 :            : 
     612                 :            : //=============================================================================
     613                 :            : //Function:  init_hash_curves (PRIVATE)
     614                 :            : //Description: create a hash array of all curves.  They are hashed based on the
     615                 :            : //             smallest id of any surface attached to the curve 
     616                 :            : //Author: sjowen
     617                 :            : //Date: 3/7/01
     618                 :            : //=============================================================================
     619                 :         88 : CubitStatus ChollaEngine::init_hash_curves( )
     620                 :            : {
     621                 :            :   /* === find the next highest prime number */
     622                 :            : 
     623         [ +  - ]:         88 :   int num_surfs = chollaSurfaceList.size();
     624                 :            :   int i;
     625                 :         88 :   hashCurveSize = num_surfs;
     626         [ +  - ]:         88 :   if (num_surfs < 30) hashCurveSize = 31;
     627                 :            :   else 
     628                 :            :   {
     629                 :          0 :     i=2;
     630         [ #  # ]:          0 :     while (i<hashCurveSize*0.5 + 1) {
     631         [ #  # ]:          0 :       if (hashCurveSize % i == 0) {
     632                 :          0 :         i=2;
     633                 :          0 :         hashCurveSize++;
     634                 :            :       }
     635                 :            :       else {
     636                 :          0 :         i++;
     637                 :            :       }
     638                 :            :     }
     639                 :            :   }
     640 [ +  - ][ +  - ]:       2816 :   hashCurveArray = new DLIList<ChollaCurve*>[hashCurveSize];
                 [ +  - ]
           [ +  +  #  # ]
     641                 :            : 
     642                 :         88 :   int key = 0;
     643                 :            :   ChollaCurve *chcurv_ptr;
     644                 :            :   DLIList<ChollaSurface*> *fsm_list_ptr; 
     645 [ +  - ][ -  + ]:         88 :   for (i=0; i<chollaCurveList.size(); i++)
     646                 :            :   {
     647         [ #  # ]:          0 :     chcurv_ptr = chollaCurveList.get_and_step();
     648         [ #  # ]:          0 :     fsm_list_ptr = chcurv_ptr->get_surface_list_ptr();
     649         [ #  # ]:          0 :     key = get_curve_hash_key( fsm_list_ptr );
     650         [ #  # ]:          0 :     hashCurveArray[key].append( chcurv_ptr );   
     651                 :            :   }
     652         [ #  # ]:         88 :   return CUBIT_SUCCESS;
     653                 :            : }
     654                 :            : 
     655                 :            : //=============================================================================
     656                 :            : //Function:  delete_hash_curves (PRIVATE)
     657                 :            : //Description: delete the hash curve stuff
     658                 :            : //Author: sjowen
     659                 :            : //Date: 3/7/01
     660                 :            : //=============================================================================
     661                 :         88 : void ChollaEngine::delete_hash_curves( )
     662                 :            : {
     663         [ +  - ]:         88 :   if (hashCurveArray)
     664 [ +  - ][ +  + ]:       2816 :    delete [] hashCurveArray;
     665                 :         88 :   hashCurveArray = NULL;
     666                 :         88 :   hashCurveSize = 0;
     667                 :         88 : }
     668                 :            : 
     669                 :            : //=============================================================================
     670                 :            : //Function:  get_curve_hash_key (PRIVATE)
     671                 :            : //Description: 
     672                 :            : //Author: sjowen
     673                 :            : //Date: 3/7/01
     674                 :            : //=============================================================================
     675                 :        748 : int ChollaEngine::get_curve_hash_key(
     676                 :            :   DLIList<ChollaSurface*> *fsm_list_ptr )
     677                 :            : {
     678                 :            :   int key, j;
     679                 :            :   ChollaSurface *chsurf_ptr;
     680         [ -  + ]:        748 :   if (fsm_list_ptr->size() == 0)
     681                 :            :   {
     682                 :          0 :     key = 0;
     683                 :            :   }
     684                 :            :   else
     685                 :            :   {
     686                 :        748 :     key = INT_MAX;
     687         [ +  + ]:       2024 :     for (j=0; j<fsm_list_ptr->size(); j++)
     688                 :            :     {
     689                 :       1276 :       chsurf_ptr = fsm_list_ptr->get_and_step();
     690         [ +  + ]:       1276 :       if (chsurf_ptr->get_id() < key)
     691                 :        748 :         key = chsurf_ptr->get_id();
     692                 :            :     }
     693                 :            :   }
     694                 :        748 :   key = key % hashCurveSize;
     695                 :        748 :   return key;
     696                 :            : }
     697                 :            : 
     698                 :            : 
     699                 :            : //=============================================================================
     700                 :            : //Function:  classify_edge (PRIVATE)
     701                 :            : //Description: sorts a edge into its correct curve based on its associated
     702                 :            : //             surfaces and sidesets/nodesets.  Creates a new block curve if 
     703                 :            : //             necessary.
     704                 :            : //Author: sjowen
     705                 :            : //Date: 12/3/00
     706                 :            : //=============================================================================
     707                 :       1276 : CubitStatus ChollaEngine::classify_edge(
     708                 :            :   FacetEntity *edge_ptr,       // the edge we are classifying
     709                 :            :   DLIList<ChollaCurve*> &cholla_curve_list,  // add to one of these
     710                 :            :   ChollaSurface *cholla_surf_mesh_ptr )   // the current surface
     711                 :            : {
     712                 :       1276 :   CubitStatus rv = CUBIT_SUCCESS;
     713                 :            : 
     714                 :            :   // see if we have already classified this edge (from another surface)
     715                 :            : 
     716         [ +  - ]:       1276 :   TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
     717 [ +  - ][ +  + ]:       1276 :   if (td_gm_edge->get_hit_flag() != 0)
     718                 :        528 :     return rv;
     719         [ +  - ]:        748 :   td_gm_edge->set_hit_flag(1);
     720                 :            : 
     721                 :            :   // get the surfaces adjacent to this edge
     722                 :            : 
     723         [ +  - ]:        748 :   DLIList<ChollaSurface*> this_chsurf_list;
     724         [ +  - ]:        748 :   td_gm_edge->get_cholla_surfs( this_chsurf_list );
     725         [ +  - ]:        748 :   int this_num_adj = this_chsurf_list.size();
     726                 :            :    
     727                 :            :   // see if the surfaces defined on this face match any 
     728                 :            :   // of the existing block curves
     729                 :            : 
     730                 :            :   DLIList<ChollaSurface*> *chsurf_list_ptr;
     731                 :        748 :   ChollaCurve *chcurv_ptr = NULL;
     732                 :        748 :   int found = 0;
     733         [ +  - ]:        748 :   int key = get_curve_hash_key( &this_chsurf_list );
     734                 :            :   int ii;
     735 [ +  - ][ +  + ]:       1419 :   for (ii=0; ii<hashCurveArray[key].size() && !found; ii++)
         [ +  - ][ +  + ]
     736                 :            :   {
     737         [ +  - ]:        671 :     chcurv_ptr = hashCurveArray[key].get();
     738                 :            :     // the first one checked should be the same as the last one checked (don't
     739                 :            :     // use get_and_step here)  This should speed things up
     740                 :            : 
     741                 :            :     // check if surfaces are the same
     742                 :            : 
     743         [ +  - ]:        671 :     chsurf_list_ptr = chcurv_ptr->get_surface_list_ptr( );
     744         [ +  - ]:        671 :     int num_adj = chsurf_list_ptr->size();
     745         [ +  - ]:        671 :     if (num_adj == this_num_adj)
     746                 :            :     {
     747                 :        671 :       found = 1;
     748                 :            :       int jj, kk;
     749 [ +  - ][ +  + ]:       1694 :       for (jj=chsurf_list_ptr->size(); jj>0 && found; jj--)
                 [ +  + ]
     750                 :            :       {
     751                 :       1023 :         int same_surf = 0;
     752         [ +  - ]:       1023 :         ChollaSurface *chsurf_ptr = chsurf_list_ptr->get_and_step();
     753 [ +  - ][ +  + ]:       2607 :         for(kk=this_chsurf_list.size(); kk>0 && !same_surf; kk--)
                 [ +  + ]
     754                 :            :         {
     755         [ +  - ]:       1584 :           ChollaSurface *this_chsurf_ptr = this_chsurf_list.get_and_step();
     756         [ +  + ]:       1584 :           if (this_chsurf_ptr == chsurf_ptr)
     757                 :            :           {
     758                 :        506 :             same_surf = 1;
     759                 :            :           }
     760                 :            :         }
     761         [ +  + ]:       1023 :         if (!same_surf)
     762                 :        517 :           found = 0;
     763                 :            :       }
     764                 :            :     }
     765         [ +  + ]:        671 :     if (!found)
     766         [ +  - ]:        517 :       hashCurveArray[key].step();
     767                 :            :   }
     768                 :            : 
     769                 :            :   // if the unique set of surfaces that this edge is associated 
     770                 :            :   // with was found to already exist for a facet curve -- add the
     771                 :            :   // edge to the block curve
     772                 :            : 
     773         [ +  + ]:        748 :   if (found)
     774                 :            :   {
     775                 :            : 
     776                 :            :     // add the edge to the block curve mesh (make sure it is only added once)
     777                 :            : 
     778                 :            :     //int was_added = 
     779         [ +  - ]:        154 :     chcurv_ptr->add_facet_unique( edge_ptr );
     780                 :            : 
     781                 :            :     // add the curve to the surface (if needed)
     782                 :            : 
     783         [ +  - ]:        154 :     cholla_surf_mesh_ptr->add_curve_unique( chcurv_ptr );
     784                 :            : 
     785                 :            :     // add the curve to the edge
     786                 :            :   
     787         [ +  - ]:        154 :     td_gm_edge->add_cholla_curve( chcurv_ptr );
     788                 :            :   }
     789                 :            : 
     790                 :            :   // if the unique set of surfaces that this edge is associated
     791                 :            :   // with is not found, then create a new facet curve and add the edge to it
     792                 :            : 
     793                 :            :   else
     794                 :            :   {
     795                 :            : 
     796                 :            :     // create it and update surface and nodeset info
     797                 :            : 
     798         [ +  - ]:        594 :     int block_id = td_gm_edge->get_block_id();
     799 [ +  - ][ +  - ]:        594 :     ChollaCurve *new_chcurv_ptr = new ChollaCurve( block_id ); 
     800         [ +  + ]:       1716 :     for (int mm=0; mm<this_num_adj; mm++)
     801                 :            :     {
     802 [ +  - ][ +  - ]:       1122 :       new_chcurv_ptr->add_surface( this_chsurf_list.get_and_step() );
     803                 :            :     }
     804                 :            : 
     805                 :            :     // add the edge
     806                 :            : 
     807         [ +  - ]:        594 :     new_chcurv_ptr->add_facet( edge_ptr );
     808                 :            : 
     809                 :            :     // update the surface with this new curve
     810                 :            : 
     811         [ +  - ]:        594 :     cholla_surf_mesh_ptr->add_curve( new_chcurv_ptr );
     812                 :            : 
     813                 :            :     // add the new curve to the global list
     814                 :            : 
     815         [ +  - ]:        594 :     cholla_curve_list.append( new_chcurv_ptr ); 
     816                 :            : 
     817                 :            :     // add the curve to the edge
     818                 :            :   
     819         [ +  - ]:        594 :     td_gm_edge->add_cholla_curve( new_chcurv_ptr );
     820                 :            : 
     821                 :            :     // add the new curve to the hash table
     822                 :            : 
     823         [ +  - ]:        594 :     hashCurveArray[key].append( new_chcurv_ptr );
     824                 :            :   }
     825         [ +  - ]:       1276 :   return rv;
     826                 :            : }
     827                 :            : 
     828                 :            : //=============================================================================
     829                 :            : //Function:  create_curve_boundaries (PRIVATE)
     830                 :            : //Description: creates the points based on the nodeset and curve information
     831                 :            : //Author: sjowen
     832                 :            : //Date: 12/6/00
     833                 :            : //=============================================================================
     834                 :         88 : CubitStatus ChollaEngine::create_curve_boundaries(
     835                 :            :   DLIList<ChollaCurve*> &cholla_curve_list,   // global list of curves
     836                 :            :   DLIList<ChollaPoint*> &cholla_point_list )  // output global list of points
     837                 :            : {
     838                 :            : 
     839                 :         88 :   CubitStatus stat = CUBIT_SUCCESS;
     840                 :            : 
     841                 :            :   // hash the points for speed
     842                 :            : 
     843                 :         88 :   stat = init_hash_points();
     844         [ -  + ]:         88 :   if (stat != CUBIT_SUCCESS)
     845                 :            :   {
     846                 :          0 :     delete_hash_points();
     847                 :          0 :     return stat;
     848                 :            :   }
     849                 :            : 
     850                 :            :   // loop through each of the end nodes on the curves
     851                 :            :   // Determine which point it is a part of.
     852                 :            :   // Create a new ChollaPoint for each point
     853                 :            : 
     854                 :            :   //int mydebug = 0;
     855                 :            :   int ii, kk;
     856         [ +  + ]:        682 :   for ( ii = cholla_curve_list.size(); ii > 0; ii-- )
     857                 :            :   {
     858         [ +  - ]:        594 :     ChollaCurve *chcurv_ptr = cholla_curve_list.get_and_step();
     859                 :            :     CubitPoint *point_ptr[2];
     860         [ +  - ]:        594 :     chcurv_ptr->get_ends( point_ptr[0], point_ptr[1] );
     861         [ +  + ]:       1782 :     for ( kk = 0; kk < 2; kk++)
     862                 :            :     {
     863         [ +  - ]:       1188 :       stat = classify_point( point_ptr[kk], cholla_point_list, chcurv_ptr );
     864         [ -  + ]:       1188 :       if (stat != CUBIT_SUCCESS)
     865                 :            :       {
     866         [ #  # ]:          0 :         delete_hash_points();
     867                 :          0 :         return stat;
     868                 :            :       }
     869                 :            :     }
     870                 :            :   }
     871                 :         88 :   delete_hash_points();
     872                 :         88 :   return stat;
     873                 :            : }
     874                 :            : 
     875                 :            : //=============================================================================
     876                 :            : //Function:  classify_point (PRIVATE)
     877                 :            : //Description: sorts a point into its correct point based on its associated
     878                 :            : //             curve.  Creates a new block point if necessary
     879                 :            : //Author: sjowen
     880                 :            : //Date: 12/6/00
     881                 :            : //=============================================================================
     882                 :       1188 : CubitStatus ChollaEngine::classify_point(
     883                 :            :   CubitPoint *point_ptr,                     // the node to classify
     884                 :            :   DLIList<ChollaPoint*> &cholla_point_list,   // global list of points
     885                 :            :   ChollaCurve *chcurv_ptr )                 // curve that the end point is on
     886                 :            : {
     887                 :            :   int ii;
     888                 :       1188 :   int found = 0;
     889         [ +  - ]:       1188 :   TDGeomFacet *td_node = TDGeomFacet::get_geom_facet( point_ptr );
     890                 :       1188 :   ChollaPoint *chpnt_ptr = NULL;
     891         [ +  - ]:       1188 :   DLIList<ChollaCurve*> fcm_list;
     892         [ +  - ]:       1188 :   td_node->get_cholla_curves(fcm_list);
     893         [ +  - ]:       1188 :   int key = get_point_hash_key( &fcm_list );
     894 [ +  - ][ +  + ]:       2123 :   for (ii = 0; ii < hashPointArray[key].size() && !found; ii++)
         [ +  + ][ +  + ]
     895                 :            :   {
     896         [ +  - ]:        935 :     chpnt_ptr = hashPointArray[key].get();
     897         [ +  - ]:        935 :     FacetEntity *this_point_ptr = chpnt_ptr->get_facets();
     898         [ +  + ]:        935 :     if (this_point_ptr == point_ptr)
     899                 :            :     {
     900                 :        770 :       found = 1;
     901                 :            :     }
     902                 :            :     else
     903                 :            :     {
     904         [ +  - ]:        165 :       hashPointArray[key].step();
     905                 :            :     }
     906                 :            :   } 
     907                 :            : 
     908         [ +  + ]:       1188 :   if (found)
     909                 :            :   {
     910         [ +  - ]:        770 :     chpnt_ptr->add_curve( chcurv_ptr );
     911         [ +  - ]:        770 :     chcurv_ptr->add_point( chpnt_ptr );
     912                 :            :   }
     913                 :            :   else
     914                 :            :   {
     915 [ +  - ][ +  - ]:        418 :     ChollaPoint *new_chpnt_ptr = new ChollaPoint(); 
     916         [ +  - ]:        418 :     new_chpnt_ptr->add_facet( point_ptr );
     917         [ +  - ]:        418 :     new_chpnt_ptr->add_curve( chcurv_ptr );
     918         [ +  - ]:        418 :     chcurv_ptr->add_point( new_chpnt_ptr );
     919         [ +  - ]:        418 :     cholla_point_list.append( new_chpnt_ptr );
     920         [ +  - ]:        418 :     hashPointArray[key].append( new_chpnt_ptr );
     921                 :            :   }
     922         [ +  - ]:       1188 :   return CUBIT_SUCCESS;
     923                 :            : }
     924                 :            : 
     925                 :            : //=============================================================================
     926                 :            : //Function:  init_hash_points (PRIVATE)
     927                 :            : //Description: create a hash array of all points.  They are hashed based on the
     928                 :            : //             smallest id of any curve attached to the curve 
     929                 :            : //Author: sjowen
     930                 :            : //Date: 3/7/01
     931                 :            : //=============================================================================
     932                 :         88 : CubitStatus ChollaEngine::init_hash_points( )
     933                 :            : {
     934                 :            :   /* === find the next highest prime number */
     935                 :            : 
     936         [ +  - ]:         88 :   int num_curves = chollaCurveList.size();
     937                 :            :   int i;
     938                 :         88 :   hashPointSize = num_curves;
     939         [ +  - ]:         88 :   if (num_curves < 30) hashPointSize = 31;
     940                 :            :   else 
     941                 :            :   {
     942                 :          0 :     i=2;
     943         [ #  # ]:          0 :     while (i<hashPointSize*0.5 + 1) {
     944         [ #  # ]:          0 :       if (hashPointSize % i == 0) {
     945                 :          0 :         i=2;
     946                 :          0 :         hashPointSize++;
     947                 :            :       }
     948                 :            :       else {
     949                 :          0 :         i++;
     950                 :            :       }
     951                 :            :     }
     952                 :            :   }
     953 [ +  - ][ +  - ]:       2816 :   hashPointArray = new DLIList<ChollaPoint*>[hashPointSize];
                 [ +  - ]
           [ +  +  #  # ]
     954                 :            : 
     955                 :         88 :   int key = 0;
     956                 :            :   ChollaPoint *chpnt_ptr;
     957                 :            :   DLIList<ChollaCurve*> *fcm_list_ptr; 
     958 [ +  - ][ -  + ]:         88 :   for (i=0; i<chollaPointList.size(); i++)
     959                 :            :   {
     960         [ #  # ]:          0 :     chpnt_ptr = chollaPointList.get_and_step();
     961         [ #  # ]:          0 :     fcm_list_ptr = chpnt_ptr->get_curve_list_ptr();
     962         [ #  # ]:          0 :     key = get_point_hash_key( fcm_list_ptr );
     963         [ #  # ]:          0 :     hashPointArray[key].append( chpnt_ptr );   
     964                 :            :   }
     965         [ #  # ]:         88 :   return CUBIT_SUCCESS;
     966                 :            : }
     967                 :            : 
     968                 :            : //=============================================================================
     969                 :            : //Function:  delete_hash_points (PRIVATE)
     970                 :            : //Description: delete the hash point stuff
     971                 :            : //Author: sjowen
     972                 :            : //Date: 3/7/01
     973                 :            : //=============================================================================
     974                 :         88 : void ChollaEngine::delete_hash_points( )
     975                 :            : {
     976         [ +  - ]:         88 :   if (hashPointArray)
     977 [ +  - ][ +  + ]:       2816 :    delete [] hashPointArray;
     978                 :         88 :   hashPointArray = NULL;
     979                 :         88 :   hashPointSize = 0;
     980                 :         88 : }
     981                 :            : 
     982                 :            : //=============================================================================
     983                 :            : //Function:  get_point_hash_key (PRIVATE)
     984                 :            : //Description: 
     985                 :            : //Author: sjowen
     986                 :            : //Date: 3/7/01
     987                 :            : //=============================================================================
     988                 :       1188 : int ChollaEngine::get_point_hash_key(
     989                 :            :   DLIList<ChollaCurve*> *fcm_list_ptr )
     990                 :            : {
     991                 :            :   int key, j;
     992                 :            :   ChollaCurve *chcurv_ptr;
     993         [ -  + ]:       1188 :   if (fcm_list_ptr->size() == 0)
     994                 :            :   {
     995                 :          0 :     key = 0;
     996                 :            :   }
     997                 :            :   else
     998                 :            :   {
     999                 :       1188 :     key = INT_MAX;
    1000         [ +  + ]:       4488 :     for (j=0; j<fcm_list_ptr->size(); j++)
    1001                 :            :     {
    1002                 :       3300 :       chcurv_ptr = fcm_list_ptr->get_and_step();
    1003         [ +  + ]:       3300 :       if (chcurv_ptr->get_id() < key)
    1004                 :       1188 :         key = chcurv_ptr->get_id();
    1005                 :            :     }
    1006                 :            :   }
    1007                 :       1188 :   key = key % hashPointSize;
    1008                 :       1188 :   return key;
    1009                 :            : }
    1010                 :            : 
    1011                 :            : //=============================================================================
    1012                 :            : //Function:  facet_dimension (PRIVATE)
    1013                 :            : //Description: returns the dimension of a mesh entity.
    1014                 :            : //=============================================================================
    1015                 :          0 : int ChollaEngine::facet_dimension(FacetEntity *facet_ptr)
    1016                 :            : {
    1017 [ #  # ][ #  # ]:          0 :   if (CAST_TO(facet_ptr, CubitFacet) != NULL)
                 [ #  # ]
    1018                 :          0 :     return 2;
    1019 [ #  # ][ #  # ]:          0 :   if (CAST_TO(facet_ptr, CubitFacetEdge) != NULL)
                 [ #  # ]
    1020                 :          0 :     return 1;
    1021 [ #  # ][ #  # ]:          0 :   if (CAST_TO(facet_ptr, CubitPoint) != NULL)
                 [ #  # ]
    1022                 :          0 :     return 0;
    1023                 :          0 :   return -1;
    1024                 :            : }
    1025                 :            : 
    1026                 :            : 
    1027                 :            : //===============================================================================
    1028                 :            : //Function:  build_eval_tools (PRIVATE)
    1029                 :            : //Description:  build the CUBIT geometry based on the Facet entity class lists
    1030                 :            : //===============================================================================
    1031                 :         88 : CubitStatus ChollaEngine::build_eval_tools(
    1032                 :            :   DLIList<ChollaSurface*> &cholla_surface_list,
    1033                 :            :   DLIList<ChollaCurve*> &cholla_curve_list,
    1034                 :            :   int interp_order,
    1035                 :            :   CubitBoolean use_feature_angle,
    1036                 :            :   double min_dot,
    1037                 :            :   CubitBoolean smooth_non_manifold,
    1038                 :            :   CubitBoolean split_surfaces )
    1039                 :            : {
    1040                 :         88 :   CubitStatus stat = CUBIT_SUCCESS;  
    1041                 :            : 
    1042         [ +  - ]:         88 :   if (stat == CUBIT_SUCCESS)
    1043                 :            :     stat = build_surface_and_curve_eval_tools( cholla_surface_list,
    1044                 :         88 :                                    interp_order, min_dot );  
    1045         [ +  - ]:         88 :   if (stat == CUBIT_SUCCESS)
    1046                 :         88 :     stat = build_curve_eval_tools( cholla_curve_list, interp_order );
    1047                 :            : 
    1048         [ +  - ]:         88 :   if (stat == CUBIT_SUCCESS)
    1049         [ +  + ]:         88 :     if (interp_order == 4)
    1050                 :            :       stat = clean_geometry( smooth_non_manifold, split_surfaces,
    1051                 :         11 :                            use_feature_angle, min_dot, cholla_curve_list );
    1052                 :         88 :   return stat;
    1053                 :            : }
    1054                 :            : 
    1055                 :            : 
    1056                 :            : //===============================================================================
    1057                 :            : //Function:  build_curve_eval_tools (PRIVATE)
    1058                 :            : //Description:  From the cholla curve list, create CurveFacetEvalTools
    1059                 :            : //===============================================================================
    1060                 :         88 : CubitStatus ChollaEngine::build_curve_eval_tools(
    1061                 :            :   DLIList<ChollaCurve*> &cholla_curve_list,
    1062                 :            :   int /* interp_order */)
    1063                 :            : {
    1064                 :         88 :   CubitStatus stat = CUBIT_SUCCESS;
    1065                 :            :   int kk;
    1066         [ +  + ]:        682 :   for ( kk = cholla_curve_list.size(); kk > 0; kk-- )
    1067                 :            :   {
    1068                 :        594 :     ChollaCurve *chcurv_ptr = cholla_curve_list.get_and_step();
    1069                 :        594 :     CurveFacetEvalTool *curv_eval_tool_ptr = chcurv_ptr->get_eval_tool();
    1070         [ -  + ]:        594 :     if (curv_eval_tool_ptr == NULL)
    1071                 :            :     {
    1072                 :            :       CubitPoint *start_point, *end_point;
    1073         [ #  # ]:          0 :       chcurv_ptr->get_ends( start_point, end_point );
    1074                 :            :       
    1075                 :            :       // if this is a curve without a parent surface then handle it 
    1076                 :            :       // differently.  (Curves with parents use the surface to evaluate to
    1077                 :            :       // With only a curve, it must evaluate to the curve)
    1078                 :            :       // Note the CurveFacetEvalTool for curves that have parent surfaces
    1079                 :            :       // are computed in build_surface_eval_tools
    1080                 :            :       
    1081 [ #  # ][ #  # ]:          0 :       DLIList<ChollaSurface*> chsurf_list = chcurv_ptr->get_surfaces();
    1082 [ #  # ][ #  # ]:          0 :       if (chsurf_list.size() == 0)
    1083                 :            :       {
    1084         [ #  # ]:          0 :         DLIList<FacetEntity*> facet_list;
    1085 [ #  # ][ #  # ]:          0 :         DLIList<CubitPoint*> point_list;  // needs to be filled in
                 [ #  # ]
    1086 [ #  # ][ #  # ]:          0 :         facet_list = chcurv_ptr->get_facet_list();
    1087 [ #  # ][ #  # ]:          0 :         DLIList<CubitFacetEdge*> edge_list;
                 [ #  # ]
    1088 [ #  # ][ #  # ]:          0 :         CAST_LIST( facet_list, edge_list, CubitFacetEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1089         [ #  # ]:          0 :         if (stat != CUBIT_SUCCESS)
    1090                 :          0 :           return stat;     
    1091                 :            : 
    1092 [ #  # ][ #  # ]:          0 :         curv_eval_tool_ptr = new CurveFacetEvalTool;
    1093         [ #  # ]:          0 :         stat = curv_eval_tool_ptr->initialize( edge_list, point_list );
    1094                 :            : 
    1095         [ #  # ]:          0 :         if ( stat != CUBIT_SUCCESS )
    1096                 :            :         {
    1097                 :          0 :             return stat;
    1098                 :            :         }
    1099 [ #  # ][ #  # ]:          0 :         chcurv_ptr->assign_eval_tool(curv_eval_tool_ptr);
                 [ #  # ]
    1100                 :            :       }
    1101                 :            :       else
    1102                 :            :       {       
    1103                 :            :         //fix up the orientation of the Cholla curve
    1104         [ #  # ]:          0 :         stat = chcurv_ptr->order_edges();
    1105         [ #  # ]:          0 :         if ( stat != CUBIT_SUCCESS )
    1106                 :            :         {         
    1107 [ #  # ][ #  # ]:          0 :           return stat;
    1108                 :            :         }
    1109                 :            :         
    1110         [ #  # ]:          0 :         DLIList<FacetEntity*> facet_ents;
    1111 [ #  # ][ #  # ]:          0 :         facet_ents = chcurv_ptr->get_facet_list();
    1112 [ #  # ][ #  # ]:          0 :         DLIList<CubitFacetEdge*> edge_facets;
                 [ #  # ]
    1113 [ #  # ][ #  # ]:          0 :         CAST_LIST(facet_ents, edge_facets, CubitFacetEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1114 [ #  # ][ #  # ]:          0 :         DLIList<CubitPoint*> ordered_points;
                 [ #  # ]
    1115                 :            :         
    1116 [ #  # ][ #  # ]:          0 :         for( int k=0; k<edge_facets.size(); k++ )
    1117                 :            :         {
    1118         [ #  # ]:          0 :           CubitFacetEdge *tmp_edge = edge_facets.get_and_step();          
    1119         [ #  # ]:          0 :           if( k==0 )
    1120                 :            :           {
    1121 [ #  # ][ #  # ]:          0 :             ordered_points.append( tmp_edge->point(0) );            
    1122 [ #  # ][ #  # ]:          0 :             ordered_points.append( tmp_edge->point(1) );            
    1123                 :            :           }
    1124                 :            :           else        
    1125 [ #  # ][ #  # ]:          0 :             ordered_points.append( tmp_edge->point(1) );                      
    1126                 :            :         }     
    1127                 :            : 
    1128 [ #  # ][ #  # ]:          0 :         FacetEvalTool *surf_eval_tool = chsurf_list.get()->get_eval_tool();
    1129 [ #  # ][ #  # ]:          0 :         CurveFacetEvalTool *curv_eval_tool_ptr = new CurveFacetEvalTool;       
    1130         [ #  # ]:          0 :         edge_facets.reset();        
    1131         [ #  # ]:          0 :         stat = curv_eval_tool_ptr->initialize( edge_facets, ordered_points, surf_eval_tool );          
    1132                 :            : 
    1133         [ #  # ]:          0 :         if ( stat != CUBIT_SUCCESS )
    1134                 :            :         {
    1135                 :          0 :           return stat;
    1136                 :            :         }
    1137 [ #  # ][ #  # ]:          0 :         chcurv_ptr->assign_eval_tool( curv_eval_tool_ptr );           
                 [ #  # ]
    1138                 :          0 :       }
    1139                 :            :     }   
    1140                 :            :   }
    1141                 :         88 :   return stat;
    1142                 :            : }
    1143                 :            : 
    1144                 :            : //===============================================================================
    1145                 :            : //Function:  build_surface_eval_tools (PRIVATE)
    1146                 :            : //Description:  From the facet surface list, create the FacetEvalTools
    1147                 :            : //===============================================================================
    1148                 :         88 : CubitStatus ChollaEngine::build_surface_and_curve_eval_tools(
    1149                 :            :   DLIList<ChollaSurface*> &cholla_surface_list,
    1150                 :            :   int interp_order,
    1151                 :            :   double min_dot)
    1152                 :            : {
    1153                 :         88 :   CubitStatus stat = CUBIT_SUCCESS;
    1154                 :            :   int ii, kk;
    1155                 :            : 
    1156                 :            :   // make sure the facet flags have been reset
    1157                 :            : 
    1158         [ +  + ]:        429 :   for ( kk = cholla_surface_list.size(); kk > 0; kk-- )
    1159                 :            :   {
    1160                 :        341 :     ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
    1161                 :        341 :     chsurf_ptr->reset_facet_flags();
    1162                 :            :   }
    1163                 :            : 
    1164                 :            :   // now loop through surfaces and create them
    1165                 :            : 
    1166         [ +  + ]:        429 :   for ( kk = cholla_surface_list.size(); kk > 0; kk-- )
    1167                 :            :   {
    1168         [ +  - ]:        341 :     ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
    1169         [ +  - ]:        341 :     DLIList<FacetEntity*> facet_entity_list;    
    1170 [ +  - ][ +  - ]:        682 :     DLIList<CubitPoint*> point_list;
                 [ +  - ]
    1171         [ +  - ]:        341 :     chsurf_ptr->get_points(point_list);
    1172         [ +  - ]:        341 :     chsurf_ptr->get_facets(facet_entity_list);
    1173 [ +  - ][ +  - ]:        682 :     DLIList<CubitFacet*> facet_list;
                 [ +  - ]
    1174 [ +  - ][ +  - ]:       1397 :     CAST_LIST( facet_entity_list, facet_list, CubitFacet );
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
    1175                 :            : 
    1176 [ +  - ][ +  - ]:        341 :     FacetEvalTool *eval_tool_ptr = new FacetEvalTool();
    1177         [ +  - ]:        341 :     eval_tool_ptr->initialize(facet_list, point_list, interp_order, min_dot);
    1178                 :            : 
    1179         [ +  - ]:        341 :     chsurf_ptr->assign_eval_tool(eval_tool_ptr);
    1180                 :            : 
    1181                 :            :     // go through each of this surface's curves and create CurveFacetEvalTools
    1182                 :            : 
    1183 [ +  - ][ +  - ]:        682 :     DLIList<ChollaCurve *> chcurv_list;
                 [ +  - ]
    1184         [ +  - ]:        341 :     chsurf_ptr->get_curves( chcurv_list );
    1185 [ +  - ][ +  + ]:       1463 :     for (ii=0; ii<chcurv_list.size(); ii++)
         [ +  - ][ +  - ]
    1186                 :            :     {
    1187         [ +  - ]:       1122 :       ChollaCurve *chcurv_ptr = chcurv_list.get_and_step();   
    1188                 :            : 
    1189 [ +  - ][ +  + ]:       1122 :       if (chcurv_ptr->get_eval_tool() == NULL)
    1190                 :            :       {
    1191                 :            :         //fix up the orientation of the Cholla curve
    1192         [ +  - ]:        594 :         stat = chcurv_ptr->order_edges();
    1193         [ -  + ]:        594 :         if ( stat != CUBIT_SUCCESS )
    1194                 :            :         {         
    1195 [ #  # ][ #  # ]:          0 :           PRINT_ERROR("Problems ordering edges!!!!!\n");          
         [ #  # ][ #  # ]
    1196                 :          0 :           return stat;
    1197                 :            :         }        
    1198                 :            :         
    1199         [ +  - ]:        594 :         DLIList<FacetEntity*> facet_ents;
    1200 [ +  - ][ +  - ]:        594 :         facet_ents = chcurv_ptr->get_facet_list();
    1201 [ +  - ][ +  - ]:       1188 :         DLIList<CubitFacetEdge*> edge_facets;
                 [ +  - ]
    1202 [ +  - ][ +  - ]:       1342 :         CAST_LIST(facet_ents, edge_facets, CubitFacetEdge );
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
    1203 [ +  - ][ +  - ]:       1188 :         DLIList<CubitPoint*> ordered_points;
                 [ +  - ]
    1204                 :            :         
    1205 [ +  - ][ +  + ]:       1342 :         for( int k=0; k<edge_facets.size(); k++ )
    1206                 :            :         {
    1207         [ +  - ]:        748 :           CubitFacetEdge *tmp_edge = edge_facets.get_and_step();          
    1208         [ +  + ]:        748 :           if( k==0 )
    1209                 :            :           {
    1210 [ +  - ][ +  - ]:        594 :             ordered_points.append( tmp_edge->point(0) );            
    1211 [ +  - ][ +  - ]:        594 :             ordered_points.append( tmp_edge->point(1) );            
    1212                 :            :           }
    1213                 :            :           else        
    1214 [ +  - ][ +  - ]:        154 :             ordered_points.append( tmp_edge->point(1) );                      
    1215                 :            :         }     
    1216                 :            : 
    1217 [ +  - ][ +  - ]:        594 :         CurveFacetEvalTool *curv_eval_tool_ptr = new CurveFacetEvalTool;       
    1218         [ +  - ]:        594 :         edge_facets.reset();        
    1219         [ +  - ]:        594 :         stat = curv_eval_tool_ptr->initialize( edge_facets, ordered_points, eval_tool_ptr );          
    1220                 :            : 
    1221         [ -  + ]:        594 :         if ( stat != CUBIT_SUCCESS )
    1222                 :            :         {
    1223                 :          0 :           return stat;
    1224                 :            :         }
    1225 [ +  - ][ +  - ]:       1188 :         chcurv_ptr->assign_eval_tool( curv_eval_tool_ptr );     
                 [ +  - ]
    1226                 :            :       }
    1227                 :            :     }
    1228                 :        341 :   }
    1229                 :         88 :   return stat;
    1230                 :            : }
    1231                 :            : 
    1232                 :          0 : CubitStatus ChollaEngine::rebuild_surface_and_curve_eval_tools(
    1233                 :            :   DLIList<ChollaSurface*> &cholla_surface_list,
    1234                 :            :   int interp_order,
    1235                 :            :   double min_dot )
    1236                 :            : {
    1237                 :          0 :   CubitStatus stat = CUBIT_SUCCESS;
    1238                 :            :   int ii, kk;
    1239                 :            : 
    1240                 :            :   // make sure the facet flags have been reset
    1241 [ #  # ][ #  # ]:          0 :   for ( kk = cholla_surface_list.size(); kk > 0; kk-- )
    1242                 :            :   {
    1243         [ #  # ]:          0 :     ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
    1244         [ #  # ]:          0 :     chsurf_ptr->reset_facet_flags();    
    1245                 :            :   }
    1246                 :            : 
    1247                 :            :   // get unique list of curves
    1248         [ #  # ]:          0 :   DLIList<ChollaCurve *> all_chcurves;
    1249 [ #  # ][ #  # ]:          0 :   for ( kk = cholla_surface_list.size(); kk > 0; kk-- )
    1250                 :            :   {
    1251         [ #  # ]:          0 :     ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
    1252         [ #  # ]:          0 :     DLIList<ChollaCurve *> chcurv_list;
    1253         [ #  # ]:          0 :     chsurf_ptr->get_curves( chcurv_list );
    1254         [ #  # ]:          0 :     all_chcurves += chcurv_list;    
    1255         [ #  # ]:          0 :   }
    1256         [ #  # ]:          0 :   all_chcurves.uniquify_ordered();
    1257                 :            : 
    1258                 :            :   // now loop through surfaces and create them
    1259                 :            : 
    1260 [ #  # ][ #  # ]:          0 :   for ( kk = cholla_surface_list.size(); kk > 0; kk-- )
    1261                 :            :   {
    1262         [ #  # ]:          0 :     ChollaSurface *chsurf_ptr = cholla_surface_list.get_and_step();
    1263         [ #  # ]:          0 :     DLIList<FacetEntity*> facet_entity_list;
    1264 [ #  # ][ #  # ]:          0 :     DLIList<CubitPoint*> point_list;
                 [ #  # ]
    1265         [ #  # ]:          0 :     chsurf_ptr->get_points(point_list);
    1266         [ #  # ]:          0 :     chsurf_ptr->get_facets(facet_entity_list);
    1267 [ #  # ][ #  # ]:          0 :     DLIList<CubitFacet*> facet_list;
                 [ #  # ]
    1268 [ #  # ][ #  # ]:          0 :     CAST_LIST( facet_entity_list, facet_list, CubitFacet );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1269                 :            : 
    1270         [ #  # ]:          0 :     FacetEvalTool *eval_tool_ptr = chsurf_ptr->get_eval_tool();
    1271         [ #  # ]:          0 :     if (NULL != eval_tool_ptr)
    1272                 :            :     {
    1273         [ #  # ]:          0 :       DLIList<CubitFacet*> facets;
    1274         [ #  # ]:          0 :       eval_tool_ptr->remove_facets(facets);
    1275 [ #  # ][ #  # ]:          0 :       delete eval_tool_ptr;
                 [ #  # ]
    1276                 :            :     }
    1277                 :            : 
    1278 [ #  # ][ #  # ]:          0 :     eval_tool_ptr = new FacetEvalTool();
    1279 [ #  # ][ #  # ]:          0 :     if ( CUBIT_SUCCESS != eval_tool_ptr->initialize(facet_list, point_list, interp_order, min_dot) )
    1280                 :            :     {
    1281                 :          0 :       return CUBIT_FAILURE;
    1282                 :            :     }
    1283                 :            : 
    1284                 :            :     //eval_tool_ptr = new FacetEvalTool();
    1285                 :            :     //eval_tool_ptr->replace_facets(facet_list);
    1286                 :            : 
    1287 [ #  # ][ #  # ]:          0 :     chsurf_ptr->assign_eval_tool(eval_tool_ptr);
                 [ #  # ]
    1288                 :          0 :   }
    1289                 :            : 
    1290                 :            :   // go through each of the curves and create CurveFacetEvalTools
    1291 [ #  # ][ #  # ]:          0 :   for (ii=0; ii<all_chcurves.size(); ii++)
    1292                 :            :   {
    1293         [ #  # ]:          0 :     ChollaCurve *chcurv_ptr = all_chcurves.get_and_step();    
    1294                 :            : 
    1295         [ #  # ]:          0 :     CubitStatus rv = chcurv_ptr->order_edges();
    1296         [ #  # ]:          0 :     if (CUBIT_SUCCESS != rv) {
    1297 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Failed to order edges.\n");
         [ #  # ][ #  # ]
    1298                 :          0 :       return rv;
    1299                 :            :     }
    1300                 :            : 
    1301         [ #  # ]:          0 :     CurveFacetEvalTool* curve_eval = chcurv_ptr->get_eval_tool();
    1302         [ #  # ]:          0 :     if (NULL != curve_eval)
    1303                 :            :     {
    1304         [ #  # ]:          0 :       DLIList<CubitFacetEdge*> eval_facets;
    1305         [ #  # ]:          0 :       curve_eval->remove_facets(eval_facets);
    1306 [ #  # ][ #  # ]:          0 :       delete curve_eval;
                 [ #  # ]
    1307                 :            :     }
    1308                 :            : 
    1309         [ #  # ]:          0 :     DLIList<FacetEntity*> facet_ents;
    1310 [ #  # ][ #  # ]:          0 :     facet_ents = chcurv_ptr->get_facet_list();
    1311 [ #  # ][ #  # ]:          0 :     DLIList<CubitFacetEdge*> edge_facets;
                 [ #  # ]
    1312 [ #  # ][ #  # ]:          0 :     CAST_LIST(facet_ents, edge_facets, CubitFacetEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1313 [ #  # ][ #  # ]:          0 :     DLIList<CubitPoint*> ordered_points;
                 [ #  # ]
    1314                 :            : 
    1315 [ #  # ][ #  # ]:          0 :     for( int k=0; k<edge_facets.size(); k++ )
    1316                 :            :     {
    1317         [ #  # ]:          0 :       CubitFacetEdge *tmp_edge = edge_facets.get_and_step();          
    1318         [ #  # ]:          0 :       if( k==0 )
    1319                 :            :       {
    1320 [ #  # ][ #  # ]:          0 :         ordered_points.append( tmp_edge->point(0) );            
    1321 [ #  # ][ #  # ]:          0 :         ordered_points.append( tmp_edge->point(1) );            
    1322                 :            :       }
    1323                 :            :       else        
    1324 [ #  # ][ #  # ]:          0 :         ordered_points.append( tmp_edge->point(1) );                      
    1325                 :            :     }     
    1326                 :            : 
    1327 [ #  # ][ #  # ]:          0 :     CurveFacetEvalTool *curv_eval_tool_ptr = new CurveFacetEvalTool;       
    1328         [ #  # ]:          0 :     edge_facets.reset();
    1329         [ #  # ]:          0 :     ordered_points.reset();
    1330         [ #  # ]:          0 :     stat = curv_eval_tool_ptr->initialize( edge_facets, ordered_points);          
    1331                 :            : 
    1332         [ #  # ]:          0 :     if ( stat != CUBIT_SUCCESS )
    1333                 :            :     {
    1334                 :          0 :       return stat;
    1335                 :            :     }
    1336 [ #  # ][ #  # ]:          0 :     chcurv_ptr->assign_eval_tool( curv_eval_tool_ptr );       
                 [ #  # ]
    1337                 :          0 :   }
    1338                 :            : 
    1339         [ #  # ]:          0 :   return stat; 
    1340                 :            : }
    1341                 :            : 
    1342                 :            : //===============================================================================
    1343                 :            : //Function:  determine_curve_orientation (static PUBLIC)
    1344                 :            : //Description:  Determine orientation of the curve with respect to the surface
    1345                 :            : //===============================================================================
    1346                 :       1122 : CubitStatus ChollaEngine::determine_curve_orientation( 
    1347                 :            :   ChollaSurface *chsurf_ptr,
    1348                 :            :   ChollaCurve *chcurv_ptr,
    1349                 :            :   CubitSense & orientation )
    1350                 :            : {
    1351                 :            :   // get the first mesh edge on the curve. use it to determine the 
    1352                 :            :   // orientation of the curve with respect to the surface
    1353                 :            : 
    1354 [ +  - ][ +  - ]:       1122 :   DLIList<FacetEntity*> facet_list = chcurv_ptr->get_facet_list();
    1355         [ +  - ]:       1122 :   facet_list.reset();
    1356         [ +  - ]:       1122 :   FacetEntity *facet_ptr = facet_list.get();
    1357         [ -  + ]:       1122 :   CubitFacetEdge *edge_ptr = CAST_TO( facet_ptr, CubitFacetEdge );
    1358         [ -  + ]:       1122 :   if (!edge_ptr)
    1359                 :          0 :     return CUBIT_FAILURE; // facet edges are not on the list - we shouldn't be here
    1360                 :            : 
    1361                 :            :   // get the adjacent face on this surface
    1362                 :            : 
    1363 [ +  - ][ +  - ]:       2244 :   DLIList<FacetEntity*> adj_face_list;
    1364         [ +  - ]:       1122 :   edge_ptr->get_parents( adj_face_list );
    1365                 :            : 
    1366 [ +  - ][ +  - ]:       2244 :   DLIList<FacetEntity*> face_ptrs;
    1367                 :            :   int jj;
    1368 [ +  - ][ +  + ]:       3300 :   for ( jj = 0; jj < adj_face_list.size(); jj++ )
    1369                 :            :   {
    1370         [ +  - ]:       2178 :     FacetEntity* face_ptr = adj_face_list.get_and_step();    
    1371         [ +  - ]:       2178 :     TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(face_ptr); 
    1372         [ +  - ]:       2178 :     DLIList<ChollaSurface*> chsurf_list;
    1373         [ +  - ]:       2178 :     if(td_gm_face)
    1374                 :            :     {
    1375         [ +  - ]:       2178 :       td_gm_face->get_cholla_surfs( chsurf_list );
    1376 [ +  - ][ +  - ]:       2178 :       if (chsurf_list.size())
    1377                 :            :       {
    1378         [ +  - ]:       2178 :         ChollaSurface *face_chsurf_ptr = chsurf_list.get();
    1379         [ +  + ]:       2178 :         if(face_chsurf_ptr == chsurf_ptr)
    1380                 :            :         {
    1381         [ +  - ]:       2178 :           face_ptrs.append(face_ptr);
    1382                 :            :         }
    1383                 :            :       }
    1384                 :            :     }
    1385         [ +  - ]:       2178 :   }
    1386 [ +  - ][ -  + ]:       1122 :   if(!face_ptrs.size())
    1387                 :          0 :     return CUBIT_FAILURE;  // didn't find an adj face on the surface ???
    1388                 :            :     
    1389                 :            : 
    1390                 :            :   // if there are two, we'll just say the orientation is unknown
    1391                 :            :   // this happens when there is a non-manifold, callers are responsible for dealing with those
    1392 [ +  - ][ -  + ]:       1122 :   if(face_ptrs.size() >= 2)
    1393                 :            :   {
    1394                 :          0 :     orientation = CUBIT_UNKNOWN;
    1395                 :          0 :     return CUBIT_SUCCESS;
    1396                 :            :   }
    1397                 :            : 
    1398         [ +  - ]:       1122 :   FacetEntity* face_ptr = face_ptrs[0];
    1399                 :            : 
    1400                 :            :   // determine orientation of nodes on this mesh face
    1401                 :            : 
    1402                 :            :   CubitPoint *start_ptr, *end_ptr;
    1403         [ +  - ]:       1122 :   chcurv_ptr->get_ends( start_ptr, end_ptr );
    1404         [ +  - ]:       1122 :   end_ptr = edge_ptr->other_point( start_ptr );
    1405         [ -  + ]:       1122 :   if (end_ptr == NULL)    
    1406                 :            :   {  
    1407                 :          0 :     return CUBIT_FAILURE;  // the edge list may not be ordered correctly??
    1408                 :            :   }
    1409                 :            :   CubitPoint *points[3];
    1410         [ -  + ]:       1122 :   CubitFacet *tri_ptr = CAST_TO( face_ptr, CubitFacet );
    1411         [ +  - ]:       1122 :   tri_ptr->points( points[0], points[1], points[2] );
    1412                 :            :   
    1413                 :       1122 :   int found = 0;
    1414 [ +  + ][ +  + ]:       2959 :   for ( jj = 0; jj < 3 && !found; jj++ )
    1415                 :            :   {
    1416         [ +  + ]:       1837 :     if (points[jj] == start_ptr)
    1417                 :            :     {
    1418                 :       1122 :       int next_jj = (jj + 1)%3;
    1419                 :       1122 :       int prev_jj = (jj + 2)%3;
    1420         [ +  + ]:       1122 :       if(points[next_jj] == end_ptr)
    1421                 :            :       {
    1422                 :        583 :         found = 1;
    1423                 :        583 :         orientation = CUBIT_FORWARD;
    1424                 :            :       }
    1425         [ +  - ]:        539 :       else if(points[prev_jj] == end_ptr)
    1426                 :            :       {
    1427                 :        539 :         found = 1;
    1428                 :       1122 :         orientation = CUBIT_REVERSED;
    1429                 :            :       }
    1430                 :            :     } 
    1431                 :            :   } 
    1432         [ -  + ]:       1122 :   if (!found)
    1433                 :          0 :     return CUBIT_FAILURE;  // couldn't determine the orientation
    1434                 :            : 
    1435         [ +  - ]:       2244 :   return CUBIT_SUCCESS;
    1436                 :            : }
    1437                 :            : 
    1438                 :            : //===============================================================================
    1439                 :            : //Function:  clean_geometry (PRIVATE)
    1440                 :            : //Description:  fix the edge control points and the normals so they are conforming
    1441                 :            : //              (or non-conforming) accross curves
    1442                 :            : //===============================================================================
    1443                 :         11 : CubitStatus ChollaEngine::clean_geometry( 
    1444                 :            :   CubitBoolean smooth_non_manifold,
    1445                 :            :   CubitBoolean split_surfaces,
    1446                 :            :   CubitBoolean use_feature_angle,
    1447                 :            :   double mindot,
    1448                 :            :   DLIList <ChollaCurve *> &cholla_curve_list )
    1449                 :            : {
    1450                 :            :   int iedge;
    1451                 :            :   ChollaCurve *chcurv_ptr;
    1452                 :            :   FacetEntity *fedge_ptr;
    1453                 :            :   CubitFacetEdge *edge_ptr;
    1454         [ +  - ]:         11 :   DLIList <FacetEntity *> facet_list; 
    1455 [ +  - ][ +  - ]:         22 :   DLIList<CubitFacetEdge *> feature_edge_list;
    1456                 :            :   int icurve;
    1457 [ +  - ][ +  + ]:        143 :   for (icurve=0; icurve<cholla_curve_list.size(); icurve++)
    1458                 :            :   {
    1459         [ +  - ]:        132 :     chcurv_ptr = cholla_curve_list.get_and_step();
    1460         [ +  - ]:        132 :     facet_list.clean_out();
    1461 [ +  - ][ +  - ]:        132 :     facet_list = chcurv_ptr->get_facet_list( );
    1462 [ +  - ][ +  + ]:        264 :     for (iedge=0; iedge<facet_list.size(); iedge++)
    1463                 :            :     {
    1464         [ +  - ]:        132 :       fedge_ptr = facet_list.get_and_step();
    1465         [ -  + ]:        132 :       edge_ptr = CAST_TO( fedge_ptr, CubitFacetEdge );
    1466         [ +  - ]:        132 :       feature_edge_list.append( edge_ptr );
    1467                 :            :     }
    1468                 :            :   }
    1469                 :            : 
    1470                 :            :   return fix_geometry( smooth_non_manifold,split_surfaces, 
    1471 [ +  - ][ +  - ]:         22 :                        use_feature_angle,mindot, feature_edge_list );
    1472                 :            : }
    1473                 :            : 
    1474                 :            : //=============================================================================
    1475                 :            : //Function:  check_all_facet_orientations (PUBLIC)
    1476                 :            : //Description: check for consistent orientation of the facets and set the 
    1477                 :            : //             isBackwards flag on the facets if necessary  
    1478                 :            : //Author: sjowen
    1479                 :            : //Date: 8/14/01
    1480                 :            : //=============================================================================
    1481                 :         11 : CubitStatus ChollaEngine::check_all_facet_orientations(
    1482                 :            :   DLIList<CubitFacet*> &facet_list,
    1483                 :            :   CubitBoolean do_flip)
    1484                 :            : {
    1485                 :         11 :   CubitStatus stat = CUBIT_SUCCESS;
    1486                 :            :   //return CUBIT_SUCCESS;
    1487                 :            :   // mark facets
    1488                 :            : 
    1489                 :            :   int ii;
    1490 [ +  - ][ +  + ]:        143 :   for (ii=0; ii<facet_list.size(); ii++)
    1491 [ +  - ][ +  - ]:        132 :     facet_list.get_and_step()->marked(1);
    1492                 :            : 
    1493                 :         11 :   int mydebug = 0;
    1494         [ -  + ]:         11 :   if (mydebug)
    1495                 :            :   {
    1496         [ #  # ]:          0 :     dcolor(CUBIT_YELLOW_INDEX);
    1497         [ #  # ]:          0 :     dfldraw(facet_list);
    1498         [ #  # ]:          0 :     dview();
    1499                 :            :   }
    1500                 :            : 
    1501                 :            :   // recursively loop through all facets making sure we are oriented the same
    1502                 :         11 :   int nfacets = 0;
    1503                 :            :   CubitFacet *facet_ptr;
    1504 [ +  - ][ +  + ]:         22 :   while ( nfacets < facet_list.size() )
    1505                 :            :   {
    1506         [ +  - ]:         11 :     facet_ptr = facet_list.get_and_step();
    1507 [ +  - ][ +  - ]:         11 :     if (facet_ptr->marked() == 1)
    1508                 :            :     {
    1509         [ +  - ]:         11 :       stat = check_facet_orientation( facet_ptr, do_flip, nfacets, mydebug );
    1510         [ -  + ]:         11 :       if (stat!= CUBIT_SUCCESS)
    1511                 :          0 :         return stat;
    1512                 :            :     }
    1513                 :            :   }
    1514                 :         11 :   return stat;
    1515                 :            : }
    1516                 :            : 
    1517                 :            : 
    1518                 :            : //=============================================================================
    1519                 :            : //Function:  check_facet_orientation (PUBLIC)
    1520                 :            : //Description: check for consistent orientation of the facets and change
    1521                 :            : //             orientation if necessary  (is NOT recursive function)
    1522                 :            : //Notes:  If do_flip is CUBIT_TRUE, then the facet topology is actually
    1523                 :            : //        changed.  Otherwise the is_backwards flag is set
    1524                 :            : //Author: sjowen
    1525                 :            : //Date: 6/3/01
    1526                 :            : //=============================================================================
    1527                 :         11 : CubitStatus ChollaEngine::check_facet_orientation(
    1528                 :            :   CubitFacet *start_facet, 
    1529                 :            :   CubitBoolean do_flip,
    1530                 :            :   int &nfacets, int mydebug )
    1531                 :            : {
    1532                 :            : 
    1533                 :            :   int jj;
    1534                 :            :   CubitFacet *adjfacet, *facet;
    1535                 :            :   CubitPoint *cpt0, *cpt1, *adjpt;
    1536         [ +  - ]:         11 :   DLIList<CubitFacet *>temp_flist;
    1537 [ +  - ][ +  - ]:         22 :   DLIList<CubitFacet *>adj_facet_list;
    1538         [ +  - ]:         11 :   temp_flist.append(start_facet);
    1539         [ -  + ]:         11 :   if (mydebug)
    1540                 :            :   {
    1541         [ #  # ]:          0 :     dcolor(CUBIT_RED_INDEX);
    1542         [ #  # ]:          0 :     dfdraw(start_facet);
    1543                 :            :   }
    1544                 :         11 :   nfacets++;
    1545         [ +  - ]:         11 :   start_facet->marked( 0 );
    1546                 :            :   int adjidx; 
    1547 [ +  - ][ +  + ]:        143 :   while(temp_flist.size())
    1548                 :            :   {
    1549         [ +  - ]:        132 :     facet = temp_flist.pop();
    1550 [ +  - ][ +  - ]:        132 :     if (facet->marked() == 0)
    1551                 :            :     {
    1552         [ +  + ]:        528 :       for (jj=0; jj<3; jj++)
    1553                 :            :       {
    1554         [ +  - ]:        396 :         cpt0 = facet->point(jj);
    1555         [ +  - ]:        396 :         cpt1 = facet->point((jj+1)%3);
    1556         [ +  - ]:        396 :         adj_facet_list.clean_out();
    1557         [ +  - ]:        396 :         facet->shared_facets(cpt0, cpt1, adj_facet_list);
    1558 [ +  - ][ +  - ]:        396 :         if(adj_facet_list.size()==1)
    1559                 :            :         {
    1560         [ +  - ]:        396 :           adjfacet = adj_facet_list.get();
    1561 [ +  - ][ +  + ]:        396 :           if (adjfacet->marked() == 1)
    1562                 :            :           {
    1563         [ +  - ]:        121 :             adjidx = adjfacet->point_index( cpt1 ); 
    1564         [ -  + ]:        121 :             if (adjidx == -1)
    1565                 :            :             {
    1566                 :          0 :               return CUBIT_FAILURE;
    1567                 :            :             }
    1568         [ +  - ]:        121 :             adjpt = adjfacet->point((adjidx+1)%3);
    1569         [ -  + ]:        121 :             if (adjpt != cpt0)
    1570                 :            :             {        
    1571                 :            :               // the orientation is not consistent -- flip the orientation of the 
    1572                 :            :               // adjacent facet
    1573                 :            : 
    1574                 :            :               // an assertion here means that the facets really don't share an
    1575                 :            :               // edge.  Should not happen!
    1576                 :            :               
    1577 [ #  # ][ #  # ]:          0 :               if (adjfacet->point((adjidx+2)%3) != cpt0)
    1578                 :            :               {
    1579                 :          0 :                 return CUBIT_FAILURE;
    1580                 :            :               }
    1581                 :            :        
    1582         [ #  # ]:          0 :               if (do_flip)
    1583                 :            :               {
    1584         [ #  # ]:          0 :                 adjfacet->flip();
    1585                 :            :               }
    1586                 :            :               else
    1587                 :            :               {
    1588 [ #  # ][ #  # ]:          0 :                 if(adjfacet->is_backwards())
    1589         [ #  # ]:          0 :                   adjfacet->is_backwards( 0 );
    1590                 :            :                 else
    1591         [ #  # ]:          0 :                   adjfacet->is_backwards( 1 );
    1592                 :            :               }
    1593         [ #  # ]:          0 :               if(mydebug){
    1594         [ #  # ]:          0 :                 adjfacet->debug_draw(CUBIT_WHITE_INDEX);
    1595                 :            :               }
    1596                 :            :             }
    1597                 :            : 
    1598                 :            :             // put its neighbor on the list to be processed later
    1599                 :            : 
    1600 [ +  - ][ +  - ]:        121 :             if (adjfacet->marked() == 1)
    1601                 :            :             {
    1602         [ +  - ]:        121 :               temp_flist.append( adjfacet );
    1603         [ +  - ]:        121 :               adjfacet->marked( 0 );
    1604         [ -  + ]:        121 :               if(mydebug)
    1605                 :            :               {
    1606         [ #  # ]:          0 :                 dfdraw(adjfacet);
    1607                 :            :               }
    1608                 :        121 :               nfacets++;
    1609                 :            :             }
    1610                 :            :           }
    1611                 :            :         }
    1612                 :            :       }
    1613                 :            :     }
    1614                 :            :   }
    1615         [ -  + ]:         11 :   if(mydebug)
    1616         [ #  # ]:          0 :     GfxDebug::mouse_xforms();
    1617         [ +  - ]:         22 :   return CUBIT_SUCCESS;
    1618                 :            : }
    1619                 :            : 
    1620                 :            : 
    1621                 :            : #ifdef ALPHA_CABLE
    1622                 :            : //=============================================================================
    1623                 :            : //Function:  split_surface_at_edges (PUBLIC)
    1624                 :            : //Description: Given a list of edges that divides a surface into two, this
    1625                 :            : // function splits the surface and modifies the engine to represent the
    1626                 :            : // new geometry.
    1627                 :            : //Author: mbrewer
    1628                 :            : //Date: 4/22/2004
    1629                 :            : //=============================================================================
    1630                 :            : CubitStatus ChollaEngine::split_surface_at_edges(
    1631                 :            :   ChollaSurface* owning_surface,
    1632                 :            :   DLIList<CubitFacetEdge *> &feature_edge_list,
    1633                 :            :   DLIList<ChollaCurve*> &cholla_curves,
    1634                 :            :   DLIList<ChollaSurface*> &cholla_surfaces)
    1635                 :            : {
    1636                 :            :   int i=0;
    1637                 :            :   DLIList<ChollaSurface*> original_surfaces = chollaSurfaceList;
    1638                 :            :   DLIList<ChollaCurve*> original_curves = chollaCurveList;
    1639                 :            :   //mark edges as feature
    1640                 :            :   CubitFacetEdge* edge_ptr=NULL;
    1641                 :            :   for(i=0;i<feature_edge_list.size();++i){
    1642                 :            :     edge_ptr=feature_edge_list.get_and_step();
    1643                 :            :     TDGeomFacet::add_geom_facet(edge_ptr, -1); 
    1644                 :            :     TDGeomFacet* td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
    1645                 :            :     edge_ptr->set_as_feature();
    1646                 :            :   }
    1647                 :            :    //Michael temp
    1648                 :            :   DLIList<FacetEntity*> *surf_facet_list=owning_surface->get_facet_list_ptr();
    1649                 :            :   int surface_id = owning_surface->get_id();
    1650                 :            :   for(i=0;i<surf_facet_list->size();++i){
    1651                 :            :     FacetEntity* face_ptr = surf_facet_list->get_and_step();
    1652                 :            :     TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(face_ptr);
    1653                 :            :     td_gm_face->set_hit_flag(surface_id);
    1654                 :            :   }
    1655                 :            :   
    1656                 :            :   CubitStatus rv = make_features( feature_edge_list, CUBIT_FALSE );
    1657                 :            :   if (rv != CUBIT_SUCCESS)
    1658                 :            :     return rv;
    1659                 :            :   
    1660                 :            :     // split up the surface
    1661                 :            :   rv = owning_surface->split_surface( cholla_surfaces );
    1662                 :            :   if (rv != CUBIT_SUCCESS)
    1663                 :            :     return rv;
    1664                 :            : 
    1665                 :            :   for ( i = cholla_surfaces.size(); i > 0; i-- )
    1666                 :            :   {
    1667                 :            :     ChollaSurface *chsurf_ptr = cholla_surfaces.get_and_step();
    1668                 :            :     chsurf_ptr->update_boundary_tool_data();
    1669                 :            :     if(chsurf_ptr != owning_surface){
    1670                 :            :       chollaSurfaceList.append(chsurf_ptr);
    1671                 :            :      
    1672                 :            :     }
    1673                 :            :   }
    1674                 :            :   rv = create_surface_boundaries( chollaSurfaceList, chollaCurveList,
    1675                 :            :                                   CUBIT_FALSE, 0.0);
    1676                 :            :   if ( !rv )
    1677                 :            :     return rv;
    1678                 :            : 
    1679                 :            :   rv = create_curve_boundaries( chollaCurveList, chollaPointList );
    1680                 :            :   if ( !rv )
    1681                 :            :     return rv;
    1682                 :            : 
    1683                 :            :   rv = build_eval_tools( chollaSurfaceList,
    1684                 :            :                          chollaCurveList,
    1685                 :            :                          0, CUBIT_FALSE, 
    1686                 :            :                          0, CUBIT_FALSE, CUBIT_FALSE);
    1687                 :            :   
    1688                 :            :   
    1689                 :            :   cholla_surfaces = chollaSurfaceList;
    1690                 :            :   cholla_curves = chollaCurveList;
    1691                 :            : 
    1692                 :            :   cholla_surfaces -= original_surfaces;
    1693                 :            :   cholla_curves -= original_curves;
    1694                 :            :   
    1695                 :            :   return rv;
    1696                 :            : }
    1697                 :            : #endif//cable
    1698                 :            : 
    1699                 :            : //=============================================================================
    1700                 :            : //Function:  make_features (PRIVATE)
    1701                 :            : //Description: add additional edges and points where feature angle requires
    1702                 :            : //             a break in the surface
    1703                 :            : //Author: sjowen
    1704                 :            : //Date:  4/31/01
    1705                 :            : //=============================================================================
    1706                 :         88 : CubitStatus ChollaEngine::make_features(
    1707                 :            :   DLIList<CubitFacetEdge *> &feature_edge_list,
    1708                 :            :   CubitBoolean split_surfaces )
    1709                 :            : {
    1710                 :         88 :   CubitStatus rv = CUBIT_SUCCESS;
    1711                 :            :   int ii, jj;
    1712                 :            :   CubitFacetEdge *edge_ptr;
    1713                 :            :   CubitPoint *point_ptr;
    1714                 :         88 :   int mydebug = 0;
    1715         [ -  + ]:         88 :   if(mydebug)
    1716                 :          0 :     GfxDebug::clear();
    1717         [ +  + ]:        836 :   for (ii=0; ii<feature_edge_list.size(); ii++)
    1718                 :            :   {
    1719                 :        748 :     edge_ptr = feature_edge_list.get_and_step();
    1720         [ -  + ]:        748 :     if(mydebug)
    1721                 :          0 :       edge_ptr->debug_draw(CUBIT_YELLOW_INDEX);
    1722         [ +  + ]:       2244 :     for (jj=0; jj<2; jj++)
    1723                 :            :     {
    1724                 :       1496 :       point_ptr = edge_ptr->point( jj );
    1725                 :       1496 :       point_ptr->marked( 0 );
    1726                 :            :     }
    1727                 :        748 :     edge_ptr->set_flag( 1 );  // mark edges as being feature edges
    1728                 :            :   }
    1729                 :            : 
    1730         [ -  + ]:         88 :   if (mydebug)
    1731                 :            :   {
    1732                 :          0 :     GfxDebug::mouse_xforms();
    1733                 :          0 :     dcolor(CUBIT_WHITE_INDEX);
    1734                 :          0 :     deldraw(feature_edge_list);
    1735                 :          0 :     dview();
    1736                 :            :   }
    1737                 :            : 
    1738         [ +  + ]:        836 :   for (ii=0; ii<feature_edge_list.size(); ii++)
    1739                 :            :   {
    1740                 :        748 :     edge_ptr = feature_edge_list.get_and_step();
    1741         [ +  + ]:       2244 :     for (jj=0; jj<2; jj++)
    1742                 :            :     {
    1743                 :       1496 :       point_ptr = edge_ptr->point( jj );
    1744         [ +  + ]:       1496 :       if (0 == point_ptr->marked())
    1745                 :            :       {
    1746                 :        572 :         point_ptr->marked(1);
    1747         [ -  + ]:        572 :         if (split_surfaces)
    1748                 :          0 :           rv = crack_open_point( point_ptr, mydebug );
    1749                 :            :         else
    1750                 :        572 :           rv = insert_discontinuity_at_point( point_ptr );
    1751         [ -  + ]:        572 :         if (rv != CUBIT_SUCCESS)
    1752                 :          0 :           return rv;
    1753                 :            :       }
    1754                 :            :     }
    1755                 :            :   }
    1756                 :            : 
    1757         [ +  + ]:        836 :   for (ii=0; ii<feature_edge_list.size(); ii++)
    1758                 :            :   {
    1759                 :        748 :     feature_edge_list.get_and_step()->set_flag( 0 );
    1760                 :            :   }
    1761                 :         88 :   return rv;
    1762                 :            : }
    1763                 :            : 
    1764                 :            : //=============================================================================
    1765                 :            : //Function:  crack_open_point (PRIVATE)
    1766                 :            : //Description: split the surface facets at a point if required.  Create
    1767                 :            : //             new points and edges as needed
    1768                 :            : //Author: sjowen
    1769                 :            : //Date:  4/31/01
    1770                 :            : //=============================================================================
    1771                 :          0 : CubitStatus ChollaEngine::crack_open_point(
    1772                 :            :   CubitPoint *point_ptr,  
    1773                 :            :   int mydebug )
    1774                 :            : {
    1775                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;
    1776                 :            : 
    1777                 :            :   // get facets at this point and mark them all ready for recursion function
    1778                 :            :   // get_facets_at_point
    1779                 :            : 
    1780                 :            :   int ii, jj;
    1781         [ #  # ]:          0 :   DLIList<CubitFacet *> facet_list;
    1782         [ #  # ]:          0 :   point_ptr->facets( facet_list );
    1783                 :            :   CubitFacet *facet_ptr, *adj_facet_ptr;
    1784 [ #  # ][ #  # ]:          0 :   for (ii=0; ii<facet_list.size(); ii++)
    1785                 :            :   {
    1786         [ #  # ]:          0 :     facet_ptr = facet_list.get_and_step();
    1787         [ #  # ]:          0 :     facet_ptr->marked( 0 );
    1788                 :            :   }
    1789                 :            : 
    1790                 :            :   // go through and find groups of adjacent facets that will form part of
    1791                 :            :   // new surfaces
    1792                 :            : 
    1793         [ #  # ]:          0 :   int totfacets = facet_list.size();
    1794                 :          0 :   int numfacets = 0;
    1795         [ #  # ]:          0 :   while(numfacets < totfacets)
    1796                 :            :   {
    1797         [ #  # ]:          0 :     facet_list.clean_out();
    1798         [ #  # ]:          0 :     point_ptr->facets( facet_list );
    1799         [ #  # ]:          0 :     facet_ptr = facet_list.get();
    1800         [ #  # ]:          0 :     DLIList<CubitFacet *> adj_facet_list;
    1801 [ #  # ][ #  # ]:          0 :     DLIList<CubitFacetEdge *>feature_edge_list;
                 [ #  # ]
    1802                 :            : 
    1803                 :            :     // make a list of all facets adjacet this point that are bounded
    1804                 :            :     // by feature edges.  Start with facet_ptr and recurse until
    1805                 :            :     // we bump into feature edges at the point.
    1806                 :            : 
    1807                 :            :     rv = get_facets_at_point( point_ptr, facet_ptr, adj_facet_list, 
    1808         [ #  # ]:          0 :                               feature_edge_list );
    1809         [ #  # ]:          0 :     numfacets += adj_facet_list.size();
    1810                 :            : 
    1811                 :            :     // if the number of facets for this feature are the same as the number of
    1812                 :            :     // facets at this point, then we are done with this point.  Otherwise
    1813                 :            :     // create new point and edges 
    1814                 :            : 
    1815         [ #  # ]:          0 :     if (numfacets < totfacets)
    1816                 :            :     {
    1817                 :            :       // create a new point and update the facets
    1818                 :            : 
    1819                 :            :       CubitPoint *new_point_ptr = 
    1820 [ #  # ][ #  # ]:          0 :          new CubitPointData( point_ptr->coordinates() );
                 [ #  # ]
    1821         [ #  # ]:          0 :       TDGeomFacet::add_geom_facet( new_point_ptr , -1);
    1822 [ #  # ][ #  # ]:          0 :       for (ii=0; ii<adj_facet_list.size(); ii++)
    1823                 :            :       {
    1824         [ #  # ]:          0 :         adj_facet_ptr = adj_facet_list.get_and_step();
    1825                 :            : 
    1826                 :            :         // facet modifications can only occur with native CUBIT facet data
    1827                 :            :         // if we are using someone else's data (ie. Sierra) then fail.
    1828                 :            :         // (Should not be using split_surfaces = TRUE)
    1829                 :            : 
    1830         [ #  # ]:          0 :         CubitFacetData *cfd_ptr = CAST_TO( adj_facet_ptr, CubitFacetData );
    1831         [ #  # ]:          0 :         if (!cfd_ptr)
    1832 [ #  # ][ #  # ]:          0 :           return CUBIT_FAILURE;
    1833         [ #  # ]:          0 :         new_point_ptr->add_facet( adj_facet_ptr );
    1834         [ #  # ]:          0 :         point_ptr->remove_facet( adj_facet_ptr );
    1835         [ #  # ]:          0 :         int pidx = adj_facet_ptr->point_index( point_ptr );
    1836         [ #  # ]:          0 :         cfd_ptr->set_point( new_point_ptr, pidx );
    1837                 :            :       }
    1838                 :            : 
    1839                 :            :       // The existing and the new points in some cases have to maintain 
    1840                 :            :       // the same normal...  so they need to keep track of
    1841                 :            :       // each other.  They will likely wind up on different surfaces
    1842                 :            :       // and we don't want to go search for them later
    1843                 :            : 
    1844         [ #  # ]:          0 :       TDGeomFacet *td_existing_point = TDGeomFacet::get_geom_facet( point_ptr );
    1845         [ #  # ]:          0 :       TDGeomFacet *td_new_point = TDGeomFacet::get_geom_facet( new_point_ptr );
    1846         [ #  # ]:          0 :       DLIList<CubitPoint *> partner_point_list;
    1847                 :            : 
    1848                 :            :       // add the existing point's partner list to the new point
    1849                 :            : 
    1850                 :            :       CubitPoint *partner_point_ptr;
    1851                 :            :       TDGeomFacet *td_partner;
    1852         [ #  # ]:          0 :       td_existing_point->get_partner_points( partner_point_list );
    1853 [ #  # ][ #  # ]:          0 :       for (ii=0; ii<partner_point_list.size(); ii++)
    1854                 :            :       {
    1855         [ #  # ]:          0 :         partner_point_ptr = partner_point_list.get_and_step();
    1856         [ #  # ]:          0 :         td_partner = TDGeomFacet::get_geom_facet( partner_point_ptr );
    1857                 :            :           //added mbrewer:  the check for a pointer here shouldn't
    1858                 :            :           // be necessary, but I have a case where it fails.  I don't
    1859                 :            :           // see where the logic is wrong.
    1860         [ #  # ]:          0 :         if(!td_partner){
    1861         [ #  # ]:          0 :           TDGeomFacet::add_geom_facet( partner_point_ptr , -1);
    1862         [ #  # ]:          0 :           td_partner = TDGeomFacet::get_geom_facet( partner_point_ptr );
    1863                 :            :         }
    1864         [ #  # ]:          0 :         td_partner->add_partner_point( new_point_ptr );
    1865         [ #  # ]:          0 :         td_new_point->add_partner_point( partner_point_ptr );
    1866                 :            :       }
    1867                 :            : 
    1868                 :            :       // Add each other as a partner
    1869                 :            : 
    1870         [ #  # ]:          0 :       td_existing_point->add_partner_point( new_point_ptr );
    1871         [ #  # ]:          0 :       td_new_point->add_partner_point( point_ptr );
    1872                 :            : 
    1873                 :            :       // create new edges at the point
    1874                 :            : 
    1875                 :            :       CubitFacetEdgeData *cfed_ptr;
    1876 [ #  # ][ #  # ]:          0 :       for (ii=0; ii<feature_edge_list.size(); ii++)
    1877                 :            :       {
    1878         [ #  # ]:          0 :         CubitFacetEdge *edge_ptr = feature_edge_list.get_and_step();
    1879         [ #  # ]:          0 :         cfed_ptr = CAST_TO( edge_ptr, CubitFacetEdgeData );
    1880         [ #  # ]:          0 :         if (!cfed_ptr)
    1881                 :          0 :           return CUBIT_FAILURE;
    1882                 :          0 :         rv = CUBIT_FAILURE;
    1883 [ #  # ][ #  # ]:          0 :         for (jj=0; jj<adj_facet_list.size() && rv == CUBIT_FAILURE; jj++)
         [ #  # ][ #  # ]
    1884                 :            :         {
    1885 [ #  # ][ #  # ]:          0 :           rv = cfed_ptr->remove_facet( adj_facet_list.get_and_step() );
    1886                 :            :         }
    1887         [ #  # ]:          0 :         if (rv != CUBIT_SUCCESS)
    1888                 :          0 :           return rv;
    1889         [ #  # ]:          0 :         CubitPoint *p1 = edge_ptr->other_point( point_ptr );
    1890                 :            : 
    1891                 :            :         // create a new edge - the edge constructor will update
    1892                 :            :         // the facet and its edge use.
    1893                 :            : 
    1894                 :            :         CubitFacetEdge *new_edge_ptr =
    1895 [ #  # ][ #  # ]:          0 :           new CubitFacetEdgeData( new_point_ptr, p1 );
    1896         [ #  # ]:          0 :         TDGeomFacet::add_geom_facet( new_edge_ptr, -1 );
    1897         [ #  # ]:          0 :         new_edge_ptr->set_as_feature();
    1898         [ #  # ]:          0 :         if (mydebug)
    1899                 :            :         {
    1900         [ #  # ]:          0 :           dcolor(CUBIT_RED_INDEX);
    1901         [ #  # ]:          0 :           dedraw(new_edge_ptr);
    1902                 :            :         }
    1903                 :            : 
    1904                 :            :         // The existing and the new edges have to maintain the same 
    1905                 :            :         // control point locations, so they need to keep track of
    1906                 :            :         // each other.  They will likely wind up on different surfaces
    1907                 :            :         // and we don't want to go search for them later
    1908                 :            : 
    1909         [ #  # ]:          0 :         TDGeomFacet *td_existing_edge = TDGeomFacet::get_geom_facet( edge_ptr );
    1910         [ #  # ]:          0 :         TDGeomFacet *td_new_edge = TDGeomFacet::get_geom_facet( new_edge_ptr );
    1911         [ #  # ]:          0 :         DLIList<CubitFacetEdge *> partner_edge_list;
    1912                 :            : 
    1913                 :            :         // add the existing edge's partner list to the new edge
    1914                 :            : 
    1915                 :            :         CubitFacetEdge *partner_edge_ptr;
    1916         [ #  # ]:          0 :         td_existing_edge->get_partner_edges( partner_edge_list );
    1917 [ #  # ][ #  # ]:          0 :         for (jj=0; jj<partner_edge_list.size(); jj++)
    1918                 :            :         {
    1919         [ #  # ]:          0 :           partner_edge_ptr = partner_edge_list.get_and_step();
    1920         [ #  # ]:          0 :           td_partner = TDGeomFacet::get_geom_facet( partner_edge_ptr );
    1921         [ #  # ]:          0 :           td_partner->add_partner_edge( new_edge_ptr );
    1922         [ #  # ]:          0 :           td_new_edge->add_partner_edge( partner_edge_ptr );
    1923                 :            :         }
    1924                 :            : 
    1925                 :            :         // Add each other as a partner
    1926                 :            : 
    1927         [ #  # ]:          0 :         td_existing_edge->add_partner_edge( new_edge_ptr );
    1928         [ #  # ]:          0 :         td_new_edge->add_partner_edge( edge_ptr );
    1929         [ #  # ]:          0 :       }
    1930                 :            : 
    1931                 :            :       // update the other edges with the new point
    1932                 :            : 
    1933 [ #  # ][ #  # ]:          0 :       for (ii=0; ii<adj_facet_list.size(); ii++)
         [ #  # ][ #  # ]
    1934                 :            :       {
    1935         [ #  # ]:          0 :         adj_facet_ptr = adj_facet_list.get_and_step();
    1936         [ #  # ]:          0 :         for (jj=0; jj<3; jj++)
    1937                 :            :         {
    1938         [ #  # ]:          0 :           CubitFacetEdge *edge_ptr = adj_facet_ptr->edge( jj );
    1939         [ #  # ]:          0 :           cfed_ptr = CAST_TO( edge_ptr, CubitFacetEdgeData );
    1940         [ #  # ]:          0 :           if (!cfed_ptr)
    1941                 :          0 :             return CUBIT_FAILURE;
    1942 [ #  # ][ #  # ]:          0 :           if (cfed_ptr->point( 0 ) == point_ptr)
    1943         [ #  # ]:          0 :             cfed_ptr->set_point( new_point_ptr, 0 );
    1944 [ #  # ][ #  # ]:          0 :           if (cfed_ptr->point( 1 ) == point_ptr)
    1945         [ #  # ]:          0 :             cfed_ptr->set_point( new_point_ptr, 1 );
    1946                 :            :         }
    1947                 :          0 :       }
    1948                 :            :     }
    1949                 :          0 :   }
    1950                 :            : 
    1951         [ #  # ]:          0 :   return rv;
    1952                 :            : }
    1953                 :            : 
    1954                 :            : //=============================================================================
    1955                 :            : //Function:  insert_discontinuity_at_point (PRIVATE)
    1956                 :            : //Description: does the same as crack_open_point, but does not create new 
    1957                 :            : //             facet entities at surface boundaries.  Instead, it creates 
    1958                 :            : //             facet boundary tooldatas to hold the additional control point 
    1959                 :            : //             and normal data
    1960                 :            : //Author: sjowen
    1961                 :            : //Date:  4/31/01
    1962                 :            : //=============================================================================
    1963                 :        572 : CubitStatus ChollaEngine::insert_discontinuity_at_point(
    1964                 :            :   CubitPoint *point_ptr )
    1965                 :            : {
    1966                 :        572 :   CubitStatus rv = CUBIT_SUCCESS;
    1967                 :            : 
    1968                 :            :   // get facets at this point and mark them all ready for recursion function
    1969                 :            :   // get_facets_at_point
    1970                 :            : 
    1971                 :            :   int ii;
    1972         [ +  - ]:        572 :   DLIList<CubitFacet *> facet_list;
    1973         [ +  - ]:        572 :   point_ptr->facets( facet_list );
    1974                 :        572 :   CubitFacet *facet_ptr = NULL;
    1975 [ +  - ][ +  + ]:       2816 :   for (ii=0; ii<facet_list.size(); ii++)
    1976                 :            :   {
    1977         [ +  - ]:       2244 :     facet_ptr = facet_list.get_and_step();
    1978         [ +  - ]:       2244 :     facet_ptr->marked( 0 );
    1979                 :            :   }
    1980                 :            : 
    1981                 :        572 :   int mydebug = 0;
    1982         [ -  + ]:        572 :   if (mydebug) {
    1983         [ #  # ]:          0 :     dfldraw(facet_list);
    1984         [ #  # ]:          0 :     dview();
    1985                 :            :   }
    1986                 :            : 
    1987                 :            :   // go through and find groups of adjacent facets that will form part of
    1988                 :            :   // new surfaces
    1989                 :            : 
    1990                 :            :   TDFacetBoundaryPoint *td_fbp = 
    1991         [ +  - ]:        572 :     TDFacetBoundaryPoint::get_facet_boundary_point( point_ptr );
    1992         [ +  - ]:        572 :   int totfacets = facet_list.size();
    1993                 :        572 :   int numfacets = 0;
    1994         [ +  + ]:       1848 :   while(numfacets < totfacets)
    1995                 :            :   {
    1996                 :       1276 :     ii = 0;
    1997                 :       1276 :     int found = 0;
    1998 [ +  + ][ +  - ]:       3256 :     while(!found && ii < totfacets )
    1999                 :            :     {
    2000                 :       1980 :       ii++;
    2001         [ +  - ]:       1980 :       facet_ptr = facet_list.get_and_step();
    2002         [ +  + ]:       1980 :       if (facet_ptr != NULL)
    2003                 :       1276 :         found = 1;
    2004                 :            :     }
    2005         [ -  + ]:       1276 :     assert(found);
    2006         [ +  - ]:       1276 :     DLIList<CubitFacet *> adj_facet_list;
    2007 [ +  - ][ +  - ]:       2552 :     DLIList<CubitFacetEdge *>feature_edge_list;
                 [ +  - ]
    2008                 :            : 
    2009                 :            :     // make a list of all facets adjacet this point that are bounded
    2010                 :            :     // by feature edges.  Start with facet_ptr and recurse until
    2011                 :            :     // we bump into feature edges at the point.
    2012                 :            : 
    2013                 :            :     rv = get_facets_at_point( point_ptr, facet_ptr, adj_facet_list, 
    2014         [ +  - ]:       1276 :                               feature_edge_list );
    2015                 :            : 
    2016         [ -  + ]:       1276 :     if (rv != CUBIT_SUCCESS)
    2017                 :          0 :       return rv;
    2018         [ +  - ]:       1276 :     numfacets += adj_facet_list.size();
    2019 [ +  - ][ +  + ]:       3520 :     for (ii=0; ii<adj_facet_list.size(); ii++)
    2020                 :            :     {
    2021 [ +  - ][ +  - ]:       2244 :       facet_list.move_to( adj_facet_list.get_and_step() );
    2022         [ +  - ]:       2244 :       facet_list.change_to( NULL );
    2023                 :            :     }
    2024                 :            : 
    2025                 :            :     // create a new boundary point tooldata if needed and add the facets
    2026                 :            :     // associated with this surface
    2027                 :            : 
    2028         [ +  + ]:       1276 :     if (td_fbp == NULL)
    2029                 :            :     {
    2030         [ +  - ]:        572 :       TDFacetBoundaryPoint::add_facet_boundary_point( point_ptr );
    2031         [ +  - ]:        572 :       td_fbp = TDFacetBoundaryPoint::get_facet_boundary_point( point_ptr );
    2032                 :            :     }
    2033 [ +  - ][ +  - ]:       1276 :     td_fbp->add_surf_facets( adj_facet_list );
                 [ +  - ]
    2034                 :            : 
    2035                 :            :     // create new boundary edge tooldatas at the point
    2036 [ +  - ][ +  + ]:       3388 :     for (ii=0; ii<feature_edge_list.size(); ii++)
         [ +  - ][ +  - ]
    2037                 :            :     {
    2038         [ +  - ]:       2112 :       CubitFacetEdge *edge_ptr = feature_edge_list.get_and_step();
    2039                 :            : 
    2040                 :            :       TDFacetBoundaryEdge *td_fbe = 
    2041         [ +  - ]:       2112 :         TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
    2042         [ +  + ]:       2112 :       if (td_fbe == NULL)
    2043                 :            :       {
    2044         [ +  - ]:        528 :         TDFacetBoundaryEdge::add_facet_boundary_edge( edge_ptr );
    2045         [ +  - ]:        528 :         td_fbe = TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
    2046                 :            :       }
    2047         [ +  - ]:       2112 :       td_fbe->add_surf_facet( adj_facet_list );
    2048                 :            :     }
    2049                 :       1276 :   }
    2050                 :            : 
    2051         [ +  - ]:        572 :   return rv;
    2052                 :            : }
    2053                 :            : 
    2054                 :            : //=============================================================================
    2055                 :            : //Function:  get_facets_at_point (PRIVATE)
    2056                 :            : //Description: make a list of all faces adjacent to a single point that are 
    2057                 :            : //             bounded by feature edges - recursive function
    2058                 :            : //Author: sjowen
    2059                 :            : //Date:  5/2/01
    2060                 :            : //=============================================================================
    2061                 :       2244 : CubitStatus ChollaEngine::get_facets_at_point(
    2062                 :            :   CubitPoint *point_ptr,
    2063                 :            :   CubitFacet *facet_ptr,
    2064                 :            :   DLIList<CubitFacet *> &facet_list,
    2065                 :            :   DLIList<CubitFacetEdge *> &feature_edge_list)
    2066                 :            : {
    2067                 :       2244 :   CubitStatus rv = CUBIT_SUCCESS;
    2068                 :            :   CubitFacetEdge *edge_ptr;
    2069                 :            :   CubitFacet *adj_facet;
    2070         [ +  - ]:       2244 :   facet_list.append(facet_ptr);
    2071         [ +  - ]:       2244 :   facet_ptr->marked( 1 );
    2072                 :            : 
    2073         [ +  + ]:       8976 :   for (int ii=0; ii<3; ii++)
    2074                 :            :   {
    2075         [ +  - ]:       6732 :     edge_ptr = facet_ptr->edge( ii );
    2076 [ +  - ][ +  + ]:       6732 :     if (edge_ptr->contains( point_ptr ))
    2077                 :            :     {
    2078 [ +  - ][ +  + ]:       4488 :       if (!edge_ptr->is_feature())
    2079                 :            :       {
    2080 [ +  - ][ -  + ]:       1936 :         if (edge_ptr->num_adj_facets() >2)
    2081                 :          0 :           return CUBIT_FAILURE;
    2082         [ +  - ]:       1936 :         adj_facet = edge_ptr->other_facet( facet_ptr );
    2083         [ -  + ]:       1936 :         if (adj_facet == NULL)
    2084                 :          0 :           return CUBIT_FAILURE;
    2085 [ +  - ][ +  + ]:       1936 :         if (adj_facet->marked() == 0)
    2086                 :            :         {
    2087                 :            :           rv = get_facets_at_point( point_ptr, adj_facet, 
    2088         [ +  - ]:        968 :                                     facet_list, feature_edge_list );
    2089         [ -  + ]:        968 :           if (rv != CUBIT_SUCCESS)
    2090                 :          0 :             return rv;
    2091                 :            :         }
    2092                 :            :       }
    2093                 :            :       else
    2094                 :            :       {
    2095 [ +  - ][ +  + ]:       2552 :         if (edge_ptr->num_adj_facets() > 1)
    2096                 :            :         {
    2097         [ +  - ]:       2112 :           feature_edge_list.append_unique( edge_ptr );
    2098                 :            :         }
    2099                 :            :       }
    2100                 :            :     }
    2101                 :            :   }
    2102                 :       2244 :   return rv;
    2103                 :            : }
    2104                 :            : 
    2105                 :            : //===============================================================================
    2106                 :            : //Function:  fix_geometry (PUBLIC)
    2107                 :            : //Description:  fix the edge control points and the normals so they are conforming
    2108                 :            : //              (or non-conforming) accross curves
    2109                 :            : //===============================================================================
    2110                 :         11 : CubitStatus ChollaEngine::fix_geometry(
    2111                 :            :   CubitBoolean smooth_non_manifold,
    2112                 :            :   CubitBoolean split_surfaces,
    2113                 :            :   CubitBoolean /* use_feature_angle */,
    2114                 :            :   double mindot,
    2115                 :            :   DLIList <CubitFacetEdge *> &feature_edge_list )
    2116                 :            : {
    2117                 :         11 :   CubitStatus stat = CUBIT_SUCCESS;
    2118                 :            : 
    2119                 :            :   // unmark all the edges and points
    2120                 :            : 
    2121                 :            :   CubitFacetEdge *edge_ptr; 
    2122                 :            :   int iedge;
    2123         [ +  - ]:         11 :   int flag = (smooth_non_manifold) ? 0 : 1;
    2124 [ +  - ][ +  + ]:        143 :   for (iedge = 0; iedge < feature_edge_list.size(); iedge++)
    2125                 :            :   {
    2126         [ +  - ]:        132 :     edge_ptr = feature_edge_list.get_and_step();
    2127         [ +  - ]:        132 :     edge_ptr->set_flag( flag );
    2128 [ +  - ][ +  - ]:        132 :     edge_ptr->point( 0 )->marked( flag );
    2129 [ +  - ][ +  - ]:        132 :     edge_ptr->point( 1 )->marked( flag );
    2130                 :            :   }
    2131                 :            : 
    2132                 :            :   // for non-manifold edges, find sets of adjacent facets that 
    2133                 :            :   // we can smooth across.  If adjacent facets do not satisfy the
    2134                 :            :   // feature angle criteria, then they should have C1 continuity
    2135                 :            :   // across the edge.  To do this, the normals at the edge's
    2136                 :            :   // points on partner edges will need to be the same.  This next
    2137                 :            :   // piece of code potentially alters the point normals.  As a result
    2138                 :            :   // edge and facet control points will need to be updated.
    2139                 :            : 
    2140         [ +  - ]:         11 :   DLIList<CubitFacet *>update_facet_list;
    2141         [ +  - ]:         11 :   if (smooth_non_manifold)
    2142                 :            :   {
    2143         [ +  - ]:         11 :     DLIList <CubitPoint *> changed_points;
    2144 [ +  - ][ +  + ]:        143 :     for (iedge = 0; iedge < feature_edge_list.size(); iedge++)
    2145                 :            :     {
    2146         [ +  - ]:        132 :       edge_ptr = feature_edge_list.get_and_step();
    2147 [ +  - ][ -  + ]:        132 :       if (edge_ptr->get_flag() == 1)
    2148                 :          0 :         continue;
    2149         [ +  - ]:        132 :       edge_ptr->set_flag( 1 );
    2150         [ -  + ]:        132 :       if (split_surfaces)
    2151                 :            :         stat = fix_split_non_manifold_edge( edge_ptr, mindot, 
    2152         [ #  # ]:          0 :                                             changed_points );
    2153                 :            :       else
    2154                 :            :         stat = fix_non_manifold_edge( edge_ptr, mindot, 
    2155         [ +  - ]:        132 :                                       changed_points );
    2156         [ -  + ]:        132 :       if (stat != CUBIT_SUCCESS)
    2157                 :          0 :         return stat;
    2158                 :            :     }
    2159 [ +  - ][ -  + ]:         11 :     if (changed_points.size() > 0)
    2160                 :            :       stat = update_edges_at_points( split_surfaces,
    2161                 :            :                                      changed_points, 
    2162                 :            :                                      update_facet_list,
    2163         [ #  # ]:          0 :                                      mindot );
    2164         [ -  + ]:         11 :     if (stat != CUBIT_SUCCESS)
    2165 [ +  - ][ +  - ]:         11 :       return stat;
    2166                 :            :   }
    2167                 :            : 
    2168                 :            :   // For all cases we need to ensure that partner edges share the same
    2169                 :            :   // control, point locations.  This piece of code goes through and
    2170                 :            :   // computes an average location for control points on partner edges
    2171                 :            :   // and sets them back on the edge
    2172                 :            : 
    2173 [ +  - ][ +  + ]:        143 :   for (iedge = 0; iedge < feature_edge_list.size(); iedge++)
    2174                 :            :   {
    2175         [ +  - ]:        132 :     edge_ptr = feature_edge_list.get_and_step();
    2176 [ +  - ][ -  + ]:        132 :     if (edge_ptr->get_flag() == 2)
    2177                 :          0 :       continue;
    2178         [ +  - ]:        132 :     edge_ptr->set_flag( 2 );
    2179         [ -  + ]:        132 :     if (split_surfaces)
    2180         [ #  # ]:          0 :       stat = fix_split_edge( edge_ptr, update_facet_list );
    2181                 :            :     else
    2182         [ +  - ]:        132 :       stat = fix_edge( edge_ptr, update_facet_list );
    2183         [ -  + ]:        132 :     if (stat != CUBIT_SUCCESS)
    2184                 :          0 :       return stat;
    2185                 :            :   }
    2186                 :            : 
    2187                 :            :   // since we have potentially modified the point normals and edge 
    2188                 :            :   // control points, we need to fix the facet control points (interior
    2189                 :            :   // to the facet) The update_facet_list contains a non-unique list of
    2190                 :            :   // facets that will need to be recomputed.
    2191                 :            : 
    2192                 :            :   int ii;
    2193                 :            :   CubitFacet *facet_ptr;
    2194 [ +  - ][ +  + ]:        275 :   for (ii=0; ii<update_facet_list.size(); ii++)
    2195 [ +  - ][ +  - ]:        264 :     update_facet_list.get_and_step()->marked( 0 );
    2196                 :            : 
    2197 [ +  - ][ +  + ]:        275 :   for (ii=0; ii<update_facet_list.size(); ii++)
    2198                 :            :   {
    2199         [ +  - ]:        264 :     facet_ptr = update_facet_list.get_and_step();
    2200 [ +  - ][ +  + ]:        264 :     if (facet_ptr->marked() == 0)
    2201                 :            :     {
    2202         [ +  - ]:        132 :       facet_ptr->marked( 1 );
    2203         [ +  - ]:        132 :       stat = FacetEvalTool::init_bezier_facet( facet_ptr );
    2204         [ -  + ]:        132 :       if (stat != CUBIT_SUCCESS)
    2205                 :          0 :         return stat;
    2206                 :            :     }
    2207                 :            :   }
    2208                 :            : 
    2209 [ +  - ][ +  + ]:        275 :   for (ii=0; ii<update_facet_list.size(); ii++)
    2210 [ +  - ][ +  - ]:        264 :     update_facet_list.get_and_step()->marked( 0 );
    2211                 :            : 
    2212         [ +  - ]:         11 :   return stat;
    2213                 :            : }
    2214                 :            : 
    2215                 :            : //===============================================================================
    2216                 :            : //Function:  update_edges_at_points (PRIVATE)
    2217                 :            : //Description: recompute the edge control points at all facets sharing
    2218                 :            : //             points in the list
    2219                 :            : //Date: 05/01
    2220                 :            : //===============================================================================
    2221                 :          0 : CubitStatus ChollaEngine::update_edges_at_points(
    2222                 :            :   CubitBoolean /* split_surfaces */,        // we are splitting facets to create geometry
    2223                 :            :   DLIList<CubitPoint *> &point_list,  // points whose edges will be updated
    2224                 :            :   DLIList<CubitFacet *> &facet_update_list,  // append facets adjacent edges that
    2225                 :            :                                              // will be updated later
    2226                 :            :   double mindot )
    2227                 :            : {
    2228                 :          0 :   CubitStatus stat = CUBIT_SUCCESS;
    2229                 :            :   CubitPoint *point_ptr;
    2230                 :            :   CubitFacetEdge *edge_ptr;
    2231         [ #  # ]:          0 :   DLIList <CubitFacetEdge *> edge_list;
    2232                 :            :   int ii;
    2233 [ #  # ][ #  # ]:          0 :   for (ii=0; ii<point_list.size(); ii++)
    2234                 :            :   {
    2235         [ #  # ]:          0 :     point_ptr = point_list.get_and_step();
    2236         [ #  # ]:          0 :     point_ptr->edges( edge_list );
    2237         [ #  # ]:          0 :     point_ptr->facets( facet_update_list );
    2238                 :            :   }
    2239 [ #  # ][ #  # ]:          0 :   for (ii=0; ii<edge_list.size(); ii++)
    2240                 :            :   {
    2241         [ #  # ]:          0 :     edge_ptr = edge_list.get_and_step();
    2242         [ #  # ]:          0 :     edge_ptr->set_flag( 0 );
    2243                 :            :   }
    2244 [ #  # ][ #  # ]:          0 :   for (ii=0; ii<edge_list.size(); ii++)
    2245                 :            :   {
    2246         [ #  # ]:          0 :     edge_ptr = edge_list.get_and_step();
    2247 [ #  # ][ #  # ]:          0 :     if (edge_ptr->get_flag() == 0)
    2248                 :            :     {
    2249         [ #  # ]:          0 :       edge_ptr->set_flag( 1 );
    2250         [ #  # ]:          0 :       stat = FacetEvalTool::init_bezier_edge( edge_ptr, mindot );
    2251                 :            :     }
    2252                 :            :   }
    2253         [ #  # ]:          0 :   return stat;
    2254                 :            : }
    2255                 :            : 
    2256                 :            : //===============================================================================
    2257                 :            : //Function:  fix_edge (PRIVATE)
    2258                 :            : //Description: Enforce the condition where all partner edges to this edge
    2259                 :            : //             share the same control points.  Compute the average of the
    2260                 :            : //             partner control points and set on the edge
    2261                 :            : //Date: 05/01
    2262                 :            : //===============================================================================
    2263                 :        132 : CubitStatus ChollaEngine::fix_edge( CubitFacetEdge *edge_ptr,
    2264                 :            :                                    DLIList<CubitFacet *> &update_facet_list)
    2265                 :            : {
    2266         [ -  + ]:        132 :   if (edge_ptr->num_adj_facets() == 1)
    2267                 :          0 :     return CUBIT_SUCCESS;
    2268                 :            :   TDFacetBoundaryEdge *td_fbe =
    2269                 :        132 :     TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
    2270         [ -  + ]:        132 :   if (!td_fbe)
    2271                 :          0 :     return CUBIT_FAILURE;
    2272                 :            : 
    2273                 :        132 :   edge_ptr->facets( update_facet_list );
    2274                 :        132 :   CubitStatus stat = td_fbe->merge_control_points();
    2275                 :        132 :   return stat;
    2276                 :            : }
    2277                 :            : 
    2278                 :            : //===============================================================================
    2279                 :            : //Function:  fix_split_edge (PRIVATE)
    2280                 :            : //Description: Enforce the condition where all partner edges to this edge
    2281                 :            : //             share the same control points.  Compute the average of the
    2282                 :            : //             partner control points and set on the edge
    2283                 :            : //Date: 05/01
    2284                 :            : //===============================================================================
    2285                 :          0 : CubitStatus ChollaEngine::fix_split_edge( CubitFacetEdge *edge_ptr,
    2286                 :            :                                    DLIList<CubitFacet *> &update_facet_list)
    2287                 :            : {
    2288                 :            : 
    2289                 :            :   // we only need to do this if the edge has any partners.  Otherwise return
    2290                 :            : 
    2291         [ #  # ]:          0 :   TDGeomFacet *td = TDGeomFacet::get_geom_facet( edge_ptr );
    2292 [ #  # ][ #  # ]:          0 :   if (td->num_partner_edges() == 0)
    2293                 :          0 :     return CUBIT_SUCCESS;
    2294                 :            :  
    2295                 :            :   // get the control points for this edge (oriented with
    2296                 :            :   // respect to point(0) on the edge)--- This means that
    2297                 :            :   // the rest of the partners to this edge must also
    2298                 :            :   // provide control points with respect to the same orientation
    2299                 :            : 
    2300 [ #  # ][ #  # ]:          0 :   CubitVector control_points[3];
    2301         [ #  # ]:          0 :   CubitPoint *start_ptr = edge_ptr->point(0);
    2302         [ #  # ]:          0 :   edge_ptr->get_control_points( start_ptr, control_points );
    2303                 :            : 
    2304                 :            :   // get all this edge's partners
    2305                 :            : 
    2306                 :            :   int ii;
    2307 [ #  # ][ #  # ]:          0 :   CubitVector partner_control_points[3];
    2308                 :            :   CubitFacetEdge *partner_edge_ptr;
    2309                 :            :   CubitPoint *partner_start_ptr;
    2310         [ #  # ]:          0 :   DLIList <CubitFacetEdge *> partner_edge_list;
    2311         [ #  # ]:          0 :   td->get_partner_edges( partner_edge_list );
    2312 [ #  # ][ #  # ]:          0 :   for (ii=0; ii<partner_edge_list.size(); ii++)
    2313                 :            :   {
    2314         [ #  # ]:          0 :     partner_edge_ptr = partner_edge_list.get_and_step();
    2315         [ #  # ]:          0 :     partner_edge_ptr->set_flag( 2 );
    2316                 :            : 
    2317                 :            :     // determine the same orientation as the first edge
    2318                 :            : 
    2319         [ #  # ]:          0 :     partner_start_ptr = partner_edge_ptr->point(0);
    2320         [ #  # ]:          0 :     TDGeomFacet *td_point = TDGeomFacet::get_geom_facet( partner_start_ptr );
    2321 [ #  # ][ #  # ]:          0 :     if (!td_point->is_partner( start_ptr ))
    2322                 :            :     {
    2323         [ #  # ]:          0 :       partner_start_ptr = partner_edge_ptr->point(1);
    2324         [ #  # ]:          0 :       td_point = TDGeomFacet::get_geom_facet( partner_start_ptr );
    2325 [ #  # ][ #  # ]:          0 :       if (!td_point->is_partner( start_ptr ))
    2326                 :            :       {
    2327 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Topology error generating facet geometry\n");
         [ #  # ][ #  # ]
    2328                 :          0 :         return CUBIT_FAILURE;
    2329                 :            :       }
    2330                 :            :     }
    2331                 :            : 
    2332                 :            :     // get the partner's control points and add to the current
    2333                 :            :     // totals
    2334                 :            : 
    2335                 :            :     partner_edge_ptr->get_control_points( partner_start_ptr, 
    2336         [ #  # ]:          0 :                                       partner_control_points );
    2337         [ #  # ]:          0 :     control_points[0] += partner_control_points[0];
    2338         [ #  # ]:          0 :     control_points[1] += partner_control_points[1];
    2339         [ #  # ]:          0 :     control_points[2] += partner_control_points[2];
    2340                 :            : 
    2341                 :            :     // add this edge's adjacent facets to the update facet list
    2342                 :            : 
    2343         [ #  # ]:          0 :     partner_edge_ptr->facets( update_facet_list );
    2344                 :            :   }
    2345         [ #  # ]:          0 :   edge_ptr->facets( update_facet_list );
    2346                 :            : 
    2347                 :            :   // average the control point locations
    2348                 :            : 
    2349         [ #  # ]:          0 :   int nedges = partner_edge_list.size() + 1;
    2350         [ #  # ]:          0 :   control_points[0] /= (double)nedges;
    2351         [ #  # ]:          0 :   control_points[1] /= (double)nedges;
    2352         [ #  # ]:          0 :   control_points[2] /= (double)nedges;
    2353                 :            : 
    2354                 :            :   // set the new control points back on the edges
    2355                 :            : 
    2356         [ #  # ]:          0 :   edge_ptr->set_control_points( start_ptr, control_points );
    2357                 :            : 
    2358                 :            :   TDGeomFacet *td_point;
    2359 [ #  # ][ #  # ]:          0 :   for (ii=0; ii<partner_edge_list.size(); ii++)
    2360                 :            :   {
    2361         [ #  # ]:          0 :     partner_edge_ptr = partner_edge_list.get_and_step();
    2362                 :            : 
    2363                 :            :     // determine the same orientation as the first edge
    2364                 :            : 
    2365         [ #  # ]:          0 :     partner_start_ptr = partner_edge_ptr->point(0);
    2366         [ #  # ]:          0 :     td_point = TDGeomFacet::get_geom_facet( partner_start_ptr );
    2367 [ #  # ][ #  # ]:          0 :     if (!td_point->is_partner( start_ptr ))
    2368                 :            :     {
    2369         [ #  # ]:          0 :       partner_start_ptr = partner_edge_ptr->point(1);
    2370         [ #  # ]:          0 :       td_point = TDGeomFacet::get_geom_facet( partner_start_ptr );
    2371 [ #  # ][ #  # ]:          0 :       if (!td_point->is_partner( start_ptr ))
    2372                 :            :       {
    2373 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Topology error generating facet geometry\n");
         [ #  # ][ #  # ]
    2374                 :          0 :         return CUBIT_FAILURE;
    2375                 :            :       }
    2376                 :            :     }
    2377                 :            :     partner_edge_ptr->set_control_points( partner_start_ptr,
    2378         [ #  # ]:          0 :                                            control_points );
    2379                 :            :   }
    2380         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    2381                 :            : }
    2382                 :            : 
    2383                 :            : //===============================================================================
    2384                 :            : //Function:  fix_non_split_manifold_edge (PRIVATE)
    2385                 :            : //Description: Enforce the condition where partner edges on non-manifold edges
    2386                 :            : //             with >2 adjacent facets that do not satisfy feature criteria
    2387                 :            : //             will have the same normal accross the edge
    2388                 :            : //Date: 05/01
    2389                 :            : //===============================================================================
    2390                 :          0 : CubitStatus ChollaEngine::fix_split_non_manifold_edge(
    2391                 :            :   CubitFacetEdge *edge_ptr,
    2392                 :            :   double min_dot,
    2393                 :            :   DLIList <CubitPoint *> &changed_points )
    2394                 :            : {
    2395                 :            :   // first check if this edge has 3 or more adjacent facets.  Return now if not
    2396                 :            : 
    2397                 :          0 :   CubitStatus stat = CUBIT_SUCCESS;
    2398         [ #  # ]:          0 :   TDGeomFacet *td = TDGeomFacet::get_geom_facet( edge_ptr );
    2399         [ #  # ]:          0 :   int nedges = td->num_partner_edges() + 1;
    2400         [ #  # ]:          0 :   if (nedges < 3)
    2401                 :          0 :     return stat;
    2402                 :            : 
    2403                 :            :   // make an array of partner edges
    2404                 :            : 
    2405         [ #  # ]:          0 :   std::vector<int> partner0(nedges);
    2406 [ #  # ][ #  # ]:          0 :   std::vector<int> partner1(nedges);
    2407 [ #  # ][ #  # ]:          0 :   std::vector<double> partner_dot(nedges);
    2408                 :          0 :   int num_partners = 0;
    2409 [ #  # ][ #  # ]:          0 :   std::vector<CubitFacetEdge*> edges(nedges);
    2410                 :            : 
    2411         [ #  # ]:          0 :   edges[0] = edge_ptr;
    2412 [ #  # ][ #  # ]:          0 :   DLIList<CubitFacetEdge *> partner_list;
    2413         [ #  # ]:          0 :   td->get_partner_edges( partner_list );
    2414                 :            :   int ii;
    2415 [ #  # ][ #  # ]:          0 :   for (ii=0; ii< partner_list.size(); ii++)
    2416                 :            :   {
    2417 [ #  # ][ #  # ]:          0 :     edges[ii+1] = partner_list.get_and_step();
    2418 [ #  # ][ #  # ]:          0 :     edges[ii+1]->set_flag( 1 );
    2419                 :            :   }
    2420                 :            : 
    2421                 :            :   
    2422                 :            :   // check each facet against every other facet at this edge to
    2423                 :            :   // see if we need to enforce continuity.  There may be several
    2424                 :            :   // cases where the feature angle criteria is (not) met.  Find
    2425                 :            :   // the pair that has the greatest dot product between them.
    2426                 :            :   // If more than 1 pair has the same dot product and meets criteria
    2427                 :            :   // then it arbitrarily uses the first one.
    2428                 :            : 
    2429                 :            :   int jj, kk;
    2430         [ #  # ]:          0 :   for (ii=0; ii<nedges-1; ii++)
    2431                 :            :   {
    2432 [ #  # ][ #  # ]:          0 :     CubitFacet *facet_ptr = edges[ii]->adj_facet( 0 );
    2433         [ #  # ]:          0 :     CubitVector normal = facet_ptr->normal();
    2434         [ #  # ]:          0 :     normal.normalize();
    2435                 :          0 :     double best_dot = -1.0;
    2436         [ #  # ]:          0 :     for (jj=ii+1; jj<nedges; jj++)
    2437                 :            :     {
    2438 [ #  # ][ #  # ]:          0 :       CubitFacet *afacet_ptr = edges[jj]->adj_facet( 0 );
    2439         [ #  # ]:          0 :       CubitVector anormal = afacet_ptr->normal();
    2440         [ #  # ]:          0 :       anormal.normalize();
    2441         [ #  # ]:          0 :       double dot = fabs(normal % anormal);
    2442 [ #  # ][ #  # ]:          0 :       if (dot > min_dot && dot > best_dot)
    2443                 :            :       {
    2444                 :            : 
    2445                 :            :         // check to see if this partner pair has not already
    2446                 :            :         // been used in another partnership.  If so, then check
    2447                 :            :         // to see if this match is better.  Otherwise, ignore
    2448                 :            :         // this match.
    2449                 :            : 
    2450                 :          0 :         int found = 0;
    2451         [ #  # ]:          0 :         for (kk=0; kk<num_partners; kk++)
    2452                 :            :         {
    2453 [ #  # ][ #  # ]:          0 :           if (partner0[kk] == ii || partner0[kk] == jj ||
         [ #  # ][ #  # ]
                 [ #  # ]
    2454 [ #  # ][ #  # ]:          0 :               partner1[kk] == ii || partner1[kk] == jj)
         [ #  # ][ #  # ]
    2455                 :            :           {
    2456                 :          0 :             found = 1;
    2457 [ #  # ][ #  # ]:          0 :             if (dot > partner_dot[kk])
    2458                 :            :             {
    2459         [ #  # ]:          0 :               partner_dot[kk] = dot;
    2460         [ #  # ]:          0 :               partner0[kk] = ii;
    2461         [ #  # ]:          0 :               partner1[kk] = jj;
    2462                 :            :             }
    2463                 :            :           }
    2464                 :            :         }
    2465         [ #  # ]:          0 :         if (!found)
    2466                 :            :         {
    2467         [ #  # ]:          0 :           partner_dot[num_partners] = dot;
    2468         [ #  # ]:          0 :           partner0[num_partners] = ii;
    2469         [ #  # ]:          0 :           partner1[num_partners] = jj;
    2470                 :          0 :           num_partners++;
    2471                 :            :         }
    2472                 :          0 :         best_dot = dot;
    2473                 :            :       }
    2474                 :            :     }
    2475                 :            :   }
    2476                 :            : 
    2477                 :            :   // we found a partner facet(s) that needs to have C1 continuity
    2478                 :            :   // across this facet.  Merge the normals on the edge so they
    2479                 :            :   // are the same
    2480                 :            : 
    2481         [ #  # ]:          0 :   for (ii=0; ii<num_partners; ii++)
    2482                 :            :   {
    2483 [ #  # ][ #  # ]:          0 :     CubitFacetEdge *edge0 = edges[partner0[ii]];
    2484 [ #  # ][ #  # ]:          0 :     CubitFacetEdge *edge1 = edges[partner1[ii]];
    2485         [ #  # ]:          0 :     for (jj=0; jj<2; jj++)
    2486                 :            :     {
    2487         [ #  # ]:          0 :       CubitPoint *pt0 = edge0->point(jj);
    2488                 :            : 
    2489                 :            :       // find its point partner on the partner edge
    2490                 :            : 
    2491         [ #  # ]:          0 :       CubitPoint *pt1 = edge1->point( 0 );
    2492         [ #  # ]:          0 :       td = TDGeomFacet::get_geom_facet( pt0 );
    2493 [ #  # ][ #  # ]:          0 :       if (!td->is_partner( pt1 ))
    2494                 :            :       {
    2495         [ #  # ]:          0 :         pt1 = edge1->point( 1 );
    2496 [ #  # ][ #  # ]:          0 :         if (!td->is_partner( pt1 ))
    2497                 :            :         {
    2498 [ #  # ][ #  # ]:          0 :           PRINT_ERROR("Internal error defining continuity across non-manifold edges\n");
         [ #  # ][ #  # ]
    2499                 :          0 :           return CUBIT_FAILURE;
    2500                 :            :         }
    2501                 :            :       }
    2502 [ #  # ][ #  # ]:          0 :       if (pt0->marked() == 0 || pt1->marked() == 0)
         [ #  # ][ #  # ]
                 [ #  # ]
    2503                 :            :       {
    2504         [ #  # ]:          0 :         pt0->marked( 1 );
    2505         [ #  # ]:          0 :         pt1->marked( 1 );
    2506         [ #  # ]:          0 :         changed_points.append( pt0 );
    2507         [ #  # ]:          0 :         changed_points.append( pt1 );
    2508         [ #  # ]:          0 :         stat = merge_normals( pt0, pt1 );
    2509         [ #  # ]:          0 :         if (stat != CUBIT_SUCCESS)
    2510                 :          0 :           return stat;
    2511                 :            :       }
    2512                 :            :     }
    2513                 :            :   }
    2514                 :            :   
    2515         [ #  # ]:          0 :   return stat;
    2516                 :            : }
    2517                 :            : 
    2518                 :            : //===============================================================================
    2519                 :            : //Function:  fix_non_manifold_edge (PRIVATE)
    2520                 :            : //Description: Enforce the condition where partner edges on non-manifold edges
    2521                 :            : //             with >2 adjacent facets that do not satisfy feature criteria
    2522                 :            : //             will have the same normal accross the edge
    2523                 :            : //Date: 05/01
    2524                 :            : //===============================================================================
    2525                 :        132 : CubitStatus ChollaEngine::fix_non_manifold_edge(
    2526                 :            :   CubitFacetEdge *edge_ptr,
    2527                 :            :   double min_dot,
    2528                 :            :   DLIList <CubitPoint *> &changed_points )
    2529                 :            : {
    2530                 :            :   // first check if this edge has 3 or more adjacent facets.  Return now if not
    2531                 :            : 
    2532                 :        132 :   CubitStatus stat = CUBIT_SUCCESS;
    2533         [ +  - ]:        132 :   int nfacets = edge_ptr->num_adj_facets();
    2534         [ +  - ]:        132 :   if (nfacets < 3)
    2535                 :        132 :     return stat;
    2536                 :            : 
    2537                 :            :   TDFacetBoundaryEdge *td_fbe =
    2538         [ #  # ]:          0 :     TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
    2539         [ #  # ]:          0 :   if (td_fbe == NULL)
    2540                 :            :   {
    2541                 :          0 :     return CUBIT_FAILURE;  // there is supposed to be a tool data here!
    2542                 :            :   }
    2543                 :            : 
    2544                 :            :   // make an array of partner edges
    2545                 :            : 
    2546 [ #  # ][ #  # ]:          0 :   int *partner0 = new int [nfacets];
    2547 [ #  # ][ #  # ]:          0 :   int *partner1 = new int [nfacets];
    2548 [ #  # ][ #  # ]:          0 :   double *partner_dot = new double [nfacets];
    2549                 :          0 :   int num_partners = 0;
    2550 [ #  # ][ #  # ]:          0 :   CubitFacet **facets = new CubitFacet * [nfacets];
    2551 [ #  # ][ #  # ]:          0 :   if (!facets || !partner0 || !partner1 || !partner_dot)
         [ #  # ][ #  # ]
    2552                 :          0 :     return CUBIT_FAILURE;
    2553         [ #  # ]:          0 :   DLIList <CubitFacet *>adj_facets;
    2554         [ #  # ]:          0 :   edge_ptr->facets( adj_facets );
    2555                 :            :   int ii;
    2556 [ #  # ][ #  # ]:          0 :   for (ii=0; ii< adj_facets.size(); ii++)
    2557                 :            :   {
    2558         [ #  # ]:          0 :     facets[ii] = adj_facets.get_and_step();
    2559         [ #  # ]:          0 :     facets[ii]->marked( 1 );
    2560                 :            :   }
    2561                 :            : 
    2562                 :            :   
    2563                 :            :   // check each facet against every other facet at this edge to
    2564                 :            :   // see if we need to enforce continuity.  There may be several
    2565                 :            :   // cases where the feature angle criteria is (not) met.  Find
    2566                 :            :   // the pair that has the greatest dot product between them.
    2567                 :            :   // If more than 1 pair has the same dot product and meets criteria
    2568                 :            :   // then it arbitrarily uses the first one.
    2569                 :            : 
    2570                 :            :   int jj, kk;
    2571         [ #  # ]:          0 :   for (ii=0; ii<nfacets-1; ii++)
    2572                 :            :   {
    2573                 :          0 :     CubitFacet *facet_ptr = facets[ii];
    2574         [ #  # ]:          0 :     CubitVector normal = facet_ptr->normal();
    2575         [ #  # ]:          0 :     normal.normalize();
    2576                 :          0 :     double best_dot = -1.0;
    2577         [ #  # ]:          0 :     for (jj=ii+1; jj<nfacets; jj++)
    2578                 :            :     {
    2579                 :          0 :       CubitFacet *afacet_ptr = facets[jj];
    2580         [ #  # ]:          0 :       CubitVector anormal = afacet_ptr->normal();
    2581         [ #  # ]:          0 :       anormal.normalize();
    2582         [ #  # ]:          0 :       double dot = fabs(normal % anormal);
    2583 [ #  # ][ #  # ]:          0 :       if (dot > min_dot && dot > best_dot)
    2584                 :            :       {
    2585                 :            : 
    2586                 :            :         // check to see if this partner pair has not already
    2587                 :            :         // been used in another partnership.  If so, then check
    2588                 :            :         // to see if this match is better.  Otherwise, ignore
    2589                 :            :         // this match.
    2590                 :            : 
    2591                 :          0 :         int found = 0;
    2592         [ #  # ]:          0 :         for (kk=0; kk<num_partners; kk++)
    2593                 :            :         {
    2594 [ #  # ][ #  # ]:          0 :           if (partner0[kk] == ii || partner0[kk] == jj ||
                 [ #  # ]
    2595         [ #  # ]:          0 :               partner1[kk] == ii || partner1[kk] == jj)
    2596                 :            :           {
    2597                 :          0 :             found = 1;
    2598         [ #  # ]:          0 :             if (dot > partner_dot[kk])
    2599                 :            :             {
    2600                 :          0 :               partner_dot[kk] = dot;
    2601                 :          0 :               partner0[kk] = ii;
    2602                 :          0 :               partner1[kk] = jj;
    2603                 :            :             }
    2604                 :            :           }
    2605                 :            :         }
    2606         [ #  # ]:          0 :         if (!found)
    2607                 :            :         {
    2608                 :          0 :           partner_dot[num_partners] = dot;
    2609                 :          0 :           partner0[num_partners] = ii;
    2610                 :          0 :           partner1[num_partners] = jj;
    2611                 :          0 :           num_partners++;
    2612                 :            :         }
    2613                 :          0 :         best_dot = dot;
    2614                 :            :       }
    2615                 :            :     }
    2616                 :            :   }
    2617                 :            : 
    2618                 :            :   // we found a partner facet(s) that needs to have C1 continuity
    2619                 :            :   // across this facet.  Merge the normals on the edge so they
    2620                 :            :   // are the same
    2621                 :            : 
    2622         [ #  # ]:          0 :   if (num_partners > 0)
    2623                 :            :   {
    2624         [ #  # ]:          0 :     CubitPoint *pt0 = edge_ptr->point(0);
    2625         [ #  # ]:          0 :     CubitPoint *pt1 = edge_ptr->point(1);
    2626                 :            :     TDFacetBoundaryPoint *td_fbp0 =
    2627         [ #  # ]:          0 :       TDFacetBoundaryPoint::get_facet_boundary_point( pt0 );
    2628                 :            :     TDFacetBoundaryPoint *td_fbp1 =
    2629         [ #  # ]:          0 :       TDFacetBoundaryPoint::get_facet_boundary_point( pt1 );
    2630 [ #  # ][ #  # ]:          0 :     if (!td_fbp0 || !td_fbp1) {
    2631         [ #  # ]:          0 :       delete [] facets;
    2632         [ #  # ]:          0 :       delete [] partner0;
    2633         [ #  # ]:          0 :       delete [] partner1;
    2634         [ #  # ]:          0 :       delete [] partner_dot;
    2635                 :          0 :       return CUBIT_FAILURE;
    2636                 :            :     }
    2637                 :            : 
    2638         [ #  # ]:          0 :     for (ii=0; ii<num_partners; ii++)
    2639                 :            :     {
    2640         [ #  # ]:          0 :       td_fbp0->merge_normals( facets[partner0[ii]], facets[partner1[ii]] );
    2641         [ #  # ]:          0 :       td_fbp1->merge_normals( facets[partner0[ii]], facets[partner1[ii]] );
    2642                 :            :     }
    2643         [ #  # ]:          0 :     pt0->marked( 1 );
    2644         [ #  # ]:          0 :     pt1->marked( 1 );
    2645         [ #  # ]:          0 :     changed_points.append( pt0 );
    2646         [ #  # ]:          0 :     changed_points.append( pt1 );
    2647                 :            :   }
    2648                 :            :   
    2649         [ #  # ]:          0 :   delete [] facets;
    2650         [ #  # ]:          0 :   delete [] partner0;
    2651         [ #  # ]:          0 :   delete [] partner1;
    2652         [ #  # ]:          0 :   delete [] partner_dot;
    2653                 :            : 
    2654         [ #  # ]:        132 :   return stat;
    2655                 :            : }
    2656                 :            : 
    2657                 :            : //===============================================================================
    2658                 :            : //Function:  merge_normals (PRIVATE)
    2659                 :            : //Description: Enforce continuity across facets by merging the normals at two
    2660                 :            : //             points.  Assumes the points are coincident.
    2661                 :            : //Date: 05/01
    2662                 :            : //===============================================================================
    2663                 :          0 : CubitStatus ChollaEngine::merge_normals(
    2664                 :            :   CubitPoint *pt0,
    2665                 :            :   CubitPoint *pt1)
    2666                 :            : {
    2667                 :            : 
    2668         [ #  # ]:          0 :   DLIList<CubitFacet*> adj_facet_list0;
    2669         [ #  # ]:          0 :   pt0->facets(adj_facet_list0);
    2670 [ #  # ][ #  # ]:          0 :   if (adj_facet_list0.size() == 0)
    2671                 :          0 :     return CUBIT_FAILURE;
    2672                 :            : 
    2673         [ #  # ]:          0 :   CubitVector avg_normal(0.0e0, 0.0e0, 0.0e0);
    2674                 :          0 :   double totangle = 0.0e0;
    2675                 :            :   double angle;
    2676                 :            :   CubitFacet *facet;
    2677                 :            :   int j;
    2678                 :            : 
    2679                 :            :   // weight the normal by the spanning angle at the point
    2680                 :            : 
    2681 [ #  # ][ #  # ]:          0 :   for (j = 0; j < adj_facet_list0.size(); j++)
    2682                 :            :   {
    2683         [ #  # ]:          0 :     facet = adj_facet_list0.get_and_step();
    2684         [ #  # ]:          0 :     angle = facet->angle( pt0 );
    2685         [ #  # ]:          0 :     facet->weight( angle );
    2686                 :          0 :     totangle += angle;
    2687                 :            :   }
    2688 [ #  # ][ #  # ]:          0 :   DLIList<CubitFacet*> adj_facet_list1;
    2689         [ #  # ]:          0 :   pt1->facets(adj_facet_list1);
    2690 [ #  # ][ #  # ]:          0 :   if (adj_facet_list1.size() == 0)
    2691                 :          0 :     return CUBIT_FAILURE;
    2692 [ #  # ][ #  # ]:          0 :   for (j = 0; j < adj_facet_list1.size(); j++)
    2693                 :            :   {
    2694         [ #  # ]:          0 :     facet = adj_facet_list1.get_and_step();
    2695         [ #  # ]:          0 :     angle = facet->angle( pt1 );
    2696         [ #  # ]:          0 :     facet->weight( angle );
    2697                 :          0 :     totangle += angle;
    2698                 :            :   }
    2699                 :            : 
    2700                 :            :   // computed weighted normal
    2701                 :            : 
    2702         [ #  # ]:          0 :   CubitVector normal;
    2703 [ #  # ][ #  # ]:          0 :   for (j = 0; j < adj_facet_list0.size(); j++)
    2704                 :            :   {
    2705         [ #  # ]:          0 :     facet = adj_facet_list0.get_and_step();
    2706 [ #  # ][ #  # ]:          0 :     normal = facet->normal();
    2707         [ #  # ]:          0 :     normal.normalize();
    2708 [ #  # ][ #  # ]:          0 :     avg_normal += (facet->weight() / totangle) * normal;
                 [ #  # ]
    2709                 :            :   }
    2710                 :            :   
    2711                 :            :   // orientation of facets may be opposite on opposing surfaces.
    2712                 :            :   // Check for this case and correct of necessary
    2713                 :            :   
    2714 [ #  # ][ #  # ]:          0 :   CubitVector norm0, norm1;
    2715 [ #  # ][ #  # ]:          0 :   norm0 = pt0->normal();
    2716         [ #  # ]:          0 :   norm0.normalize();
    2717 [ #  # ][ #  # ]:          0 :   norm1 = pt1->normal();
    2718         [ #  # ]:          0 :   norm1.normalize();
    2719         [ #  # ]:          0 :   double dot = norm0 % norm1;
    2720                 :          0 :   double sign = 1.0;
    2721         [ #  # ]:          0 :   if (dot < 0.0)
    2722                 :          0 :     sign = -1.0;
    2723                 :            : 
    2724 [ #  # ][ #  # ]:          0 :   for (j = 0; j < adj_facet_list1.size(); j++)
    2725                 :            :   {
    2726         [ #  # ]:          0 :     facet = adj_facet_list1.get_and_step();
    2727 [ #  # ][ #  # ]:          0 :     normal = sign * facet->normal();
                 [ #  # ]
    2728         [ #  # ]:          0 :     normal.normalize();
    2729 [ #  # ][ #  # ]:          0 :     avg_normal += (facet->weight() / totangle) * normal;
                 [ #  # ]
    2730                 :            :   }
    2731                 :            : 
    2732                 :            :   // set the new normal on both points
    2733                 :            : 
    2734         [ #  # ]:          0 :   avg_normal.normalize();
    2735         [ #  # ]:          0 :   pt0->normal(avg_normal);
    2736         [ #  # ]:          0 :   CubitVector temp_vector = sign * avg_normal;
    2737         [ #  # ]:          0 :   pt1->normal(temp_vector);
    2738 [ #  # ][ #  # ]:          0 :   double coefd = -(pt0->coordinates()%avg_normal);
    2739         [ #  # ]:          0 :   pt0->d_coef( coefd );
    2740         [ #  # ]:          0 :   pt1->d_coef( sign * coefd );
    2741                 :            : 
    2742         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    2743                 :            : }
    2744                 :            : 
    2745                 :            : //===============================================================================
    2746                 :            : //Function:  print_me (PRIVATE)
    2747                 :            : //Description: debug
    2748                 :            : //===============================================================================
    2749                 :          0 : void ChollaEngine::print_me()
    2750                 :            : {
    2751                 :          0 :   FILE *fp = fopen( "fbg.out", "w" );
    2752                 :            :   int ii, jj, kk;
    2753         [ #  # ]:          0 :   for (ii=0; ii<chollaSurfaceList.size(); ii++)
    2754                 :            :   {
    2755         [ #  # ]:          0 :     ChollaSurface *chsurf_ptr = chollaSurfaceList.get_and_step();
    2756 [ #  # ][ #  # ]:          0 :     fprintf( fp, "*********** Surface %d ***************\n", chsurf_ptr->get_id());
    2757         [ #  # ]:          0 :     DLIList<ChollaCurve *> fcm_list;
    2758         [ #  # ]:          0 :     chsurf_ptr->get_curves( fcm_list );
    2759 [ #  # ][ #  # ]:          0 :     for (jj=0; jj<fcm_list.size(); jj++)
    2760                 :            :     {
    2761         [ #  # ]:          0 :       ChollaCurve *chcurv_ptr = fcm_list.get_and_step();
    2762 [ #  # ][ #  # ]:          0 :       fprintf(fp, "   Curve %d\n", chcurv_ptr->get_id() );
    2763                 :            :       //CubitVector start, end;
    2764 [ #  # ][ #  # ]:          0 :       DLIList<ChollaPoint *> fpm_list = chcurv_ptr->get_points();
    2765 [ #  # ][ #  # ]:          0 :       for (kk=0; kk<fpm_list.size(); kk++)
    2766                 :            :       {
    2767         [ #  # ]:          0 :         ChollaPoint *chpnt_ptr = fpm_list.get_and_step();
    2768         [ #  # ]:          0 :         FacetEntity *facet_point = chpnt_ptr->get_facets();
    2769         [ #  # ]:          0 :         if (facet_point)
    2770                 :            :         {
    2771         [ #  # ]:          0 :           CubitPoint *point_ptr = CAST_TO(facet_point, CubitPoint);
    2772         [ #  # ]:          0 :           CubitVector pt = point_ptr->coordinates();
    2773                 :            :           fprintf(fp, "      (%d) x = %8.4f y = %8.4f z = %8.4f\n",
    2774 [ #  # ][ #  # ]:          0 :                   chpnt_ptr->get_id(), pt.x(), pt.y(), pt.z());
         [ #  # ][ #  # ]
                 [ #  # ]
    2775                 :            :         }
    2776                 :            :       }
    2777         [ #  # ]:          0 :     }
    2778         [ #  # ]:          0 :   }
    2779                 :          0 :   fclose(fp);
    2780                 :          0 : }
    2781                 :            : 
    2782                 :            : //===============================================================================
    2783                 :            : //Function:  dump (PUBLIC)
    2784                 :            : //Description: debug
    2785                 :            : //===============================================================================
    2786                 :          0 : void ChollaEngine::dump( const char *filename, double angle )
    2787                 :            : {
    2788                 :          0 :   int include_results = 0;
    2789         [ #  # ]:          0 :   int num_face = faceList.size();
    2790         [ #  # ]:          0 :   int num_edge = edgeList.size();
    2791         [ #  # ]:          0 :   int num_vert = pointList.size();
    2792 [ #  # ][ #  # ]:          0 :   int *face_edge = new int [3*num_face];
    2793 [ #  # ][ #  # ]:          0 :   int *edge_vert = new int [2*num_edge];
    2794 [ #  # ][ #  # ]:          0 :   double *vert = new double [3*num_vert];
    2795                 :            : 
    2796                 :            :   int ii;
    2797         [ #  # ]:          0 :   CubitVector loc;
    2798                 :            :   CubitPoint *point_ptr;
    2799         [ #  # ]:          0 :   pointList.reset();
    2800         [ #  # ]:          0 :   for (ii=0; ii<num_vert; ii++)
    2801                 :            :   {
    2802 [ #  # ][ #  # ]:          0 :     point_ptr = dynamic_cast<CubitPoint *>(pointList.get_and_step());
    2803         [ #  # ]:          0 :     point_ptr->set_id( ii );
    2804 [ #  # ][ #  # ]:          0 :     loc = point_ptr->coordinates();
    2805         [ #  # ]:          0 :     vert[ii*3] = loc.x();
    2806         [ #  # ]:          0 :     vert[ii*3+1] = loc.y();
    2807         [ #  # ]:          0 :     vert[ii*3+2] = loc.z();
    2808                 :            :   }
    2809                 :            : 
    2810                 :            :   CubitFacetEdge *edge_ptr;
    2811         [ #  # ]:          0 :   edgeList.reset();
    2812         [ #  # ]:          0 :   for (ii=0; ii<num_edge; ii++)
    2813                 :            :   {
    2814 [ #  # ][ #  # ]:          0 :     edge_ptr = dynamic_cast<CubitFacetEdge *>(edgeList.get_and_step());
    2815         [ #  # ]:          0 :     edge_ptr->set_id( ii );
    2816 [ #  # ][ #  # ]:          0 :     edge_vert[ii*2] = edge_ptr->point( 0 )->id();
    2817 [ #  # ][ #  # ]:          0 :     edge_vert[ii*2+1] = edge_ptr->point( 1 )->id();
    2818                 :            :   }
    2819                 :            : 
    2820                 :            :   CubitFacet *facet_ptr;
    2821         [ #  # ]:          0 :   faceList.reset();
    2822         [ #  # ]:          0 :   for(ii=0; ii<num_face; ii++)
    2823                 :            :   {
    2824 [ #  # ][ #  # ]:          0 :     facet_ptr = dynamic_cast<CubitFacet *>(faceList.get_and_step());
    2825 [ #  # ][ #  # ]:          0 :     face_edge[ii*3] = facet_ptr->edge( 0 )->id();
    2826 [ #  # ][ #  # ]:          0 :     face_edge[ii*3+1] = facet_ptr->edge( 1 )->id();
    2827 [ #  # ][ #  # ]:          0 :     face_edge[ii*3+2] = facet_ptr->edge( 2 )->id();
    2828                 :            :   }
    2829                 :            : 
    2830 [ #  # ][ #  # ]:          0 :   double *edge_control_points = new double [3*3*num_edge];
    2831 [ #  # ][ #  # ]:          0 :   double *tri_control_points = new double [3*6*num_face];
    2832                 :          0 :   double *quad_control_points = NULL;
    2833                 :            : 
    2834                 :            :   char mesh_filename[256];
    2835                 :          0 :   sprintf(mesh_filename, "%s.mesh", filename);
    2836                 :            :   dumpMesh(mesh_filename, include_results, angle, num_face, 0, num_edge,
    2837                 :            :            num_vert, face_edge, NULL, edge_vert, vert, edge_control_points, 
    2838         [ #  # ]:          0 :            tri_control_points, quad_control_points);
    2839                 :            : 
    2840                 :            :   constructBezier( angle, num_face, 0, num_edge, num_vert, face_edge, NULL,
    2841                 :            :                    edge_vert, vert, edge_control_points, tri_control_points,
    2842         [ #  # ]:          0 :                    quad_control_points );
    2843                 :            : 
    2844                 :            :   char result_filename[256];
    2845                 :          0 :   sprintf(result_filename, "%s.results", filename);
    2846                 :            :   dumpResults(result_filename, num_edge, num_face, 0, 
    2847         [ #  # ]:          0 :               edge_control_points, tri_control_points, quad_control_points );
    2848                 :            : 
    2849                 :          0 :   include_results = 1;
    2850                 :            :   char full_filename[256];
    2851                 :          0 :   sprintf(full_filename, "%s.full", filename);
    2852                 :            :   dumpMesh(full_filename, include_results, angle, num_face, 0, num_edge,
    2853                 :            :            num_vert, face_edge, NULL, edge_vert, vert, edge_control_points, 
    2854         [ #  # ]:          0 :            tri_control_points, quad_control_points);
    2855                 :            : 
    2856         [ #  # ]:          0 :   delete [] face_edge;
    2857         [ #  # ]:          0 :   delete [] edge_vert;
    2858         [ #  # ]:          0 :   delete [] vert;
    2859         [ #  # ]:          0 :   delete [] edge_control_points;
    2860         [ #  # ]:          0 :   delete [] tri_control_points;
    2861                 :          0 : }
    2862                 :            : 
    2863                 :            : //===============================================================================
    2864                 :            : //Function:  mark_features (PUBLIC)
    2865                 :            : //Description: Calling this before ChollaEngine create geometry / topology
    2866                 :            : // allows you to define features points. This can be used in conjunction
    2867                 :            : // with the feature angle option or exclusively (original intention).
    2868                 :            : //===============================================================================
    2869                 :          0 : void ChollaEngine::mark_features (DLIList<CubitPoint*> &feature_points)
    2870                 :            : {
    2871                 :            :   int ii;
    2872                 :          0 :   TDGeomFacet *td_gm = NULL;
    2873                 :          0 :   CubitPoint *curr_pt = NULL;
    2874                 :            : 
    2875                 :            :     // loop through supplied CubitPoint*
    2876                 :            :     // set the hit flag on each one
    2877                 :            :   
    2878         [ #  # ]:          0 :   for (ii=0; ii < feature_points.size(); ++ii)
    2879                 :            :   {
    2880                 :          0 :     curr_pt = feature_points.get_and_step();
    2881                 :          0 :     TDGeomFacet::add_geom_facet(curr_pt, -1);
    2882                 :          0 :     td_gm = TDGeomFacet::get_geom_facet(curr_pt);
    2883                 :          0 :     td_gm->set_hit_flag(1);
    2884                 :          0 :     curr_pt->set_as_feature();
    2885                 :            :   }
    2886                 :          0 : }
    2887                 :            : 
    2888                 :            : //===============================================================================
    2889                 :            : //Function:  mark_features (PUBLIC)
    2890                 :            : //Description: Calling this before ChollaEngine create geometry / topology
    2891                 :            : // allows you to define features points. This can be used in conjunction
    2892                 :            : // with the feature angle option or exclusively (original intention).
    2893                 :            : //===============================================================================
    2894                 :          0 : void ChollaEngine::mark_features (DLIList<CubitFacetEdge*> &feature_edges)
    2895                 :            : {
    2896                 :            :   int ii;
    2897                 :          0 :   CubitFacetEdge *curr_edge = NULL;
    2898                 :            :         
    2899                 :            :         // loop through supplied CubitFaceEdge*
    2900                 :            :         // set the hit flag on each one
    2901                 :            : 
    2902         [ #  # ]:          0 :   for (ii=0; ii < feature_edges.size(); ++ii)
    2903                 :            :   {
    2904                 :          0 :     curr_edge = feature_edges.get_and_step();
    2905                 :          0 :     curr_edge->set_as_feature();
    2906                 :            :   }
    2907                 :          0 : }
    2908                 :            : 
    2909                 :            :   
    2910                 :          0 : static CubitStatus create_tri_facets(int *face_list,int current_position,
    2911                 :            :                                      CubitPoint **point_list,
    2912                 :            :                                      DLIList <CubitFacet*> &facet_list)
    2913                 :            : {
    2914                 :          0 :   int step = face_list[current_position];
    2915                 :            :     //This function is hard coded to work for splitting 4, 5, and 6
    2916                 :            :     //faceted points into triangles.
    2917 [ #  # ][ #  # ]:          0 :   if ( step > 6 || step < 4 )
    2918                 :            :   {
    2919 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Trying to split facets with wrong function.\n");
         [ #  # ][ #  # ]
    2920                 :          0 :     return CUBIT_FAILURE;
    2921                 :            :   }
    2922                 :            :     //Basically get the points in a list first.
    2923                 :          0 :   int ii = current_position + 1, jj;
    2924         [ #  # ]:          0 :   DLIList <CubitPoint*> temp_points;
    2925                 :            :   
    2926         [ #  # ]:          0 :   for( jj = ii; jj < ii+step; jj++ )
    2927                 :            :   {
    2928                 :          0 :     int index_to_point = face_list[jj];
    2929         [ #  # ]:          0 :     assert(index_to_point >= 0 );
    2930         [ #  # ]:          0 :     temp_points.append(point_list[index_to_point]);
    2931                 :            :   }
    2932                 :            :     //Now cycle through the points and creat facets from them.
    2933                 :            :   CubitPoint *point_1, *point_2, *point_3;
    2934                 :            :     //This definatly could be improved to get more optimal triangles...
    2935                 :            :     //Create the first two facets in the normal way.  This is the
    2936                 :            :     //same for 4, 5 and 6 points.
    2937         [ #  # ]:          0 :   for ( jj = 0; jj < 2; jj++ )
    2938                 :            :   {
    2939         [ #  # ]:          0 :     point_1 = temp_points.get_and_step();
    2940         [ #  # ]:          0 :     point_2 = temp_points.get_and_step();
    2941         [ #  # ]:          0 :     point_3 = temp_points.get();
    2942                 :            :       //If these are colinear we are screwed...
    2943                 :            :     CubitFacet *new_facet = (CubitFacet *)
    2944 [ #  # ][ #  # ]:          0 :       new CubitFacetData(point_1, point_2, point_3);
    2945         [ #  # ]:          0 :     facet_list.append(new_facet);
    2946                 :            :   }
    2947                 :            :     //create the third facet for 5 points.
    2948         [ #  # ]:          0 :   if ( step == 5 )
    2949                 :            :   {
    2950                 :            :       //Now create the last facet with the first point, last point and
    2951                 :            :       //third point.
    2952         [ #  # ]:          0 :     temp_points.reset();
    2953         [ #  # ]:          0 :     point_1 = temp_points.prev();
    2954         [ #  # ]:          0 :     point_2 = temp_points.get();
    2955         [ #  # ]:          0 :     point_3 = temp_points.next(2);
    2956                 :            :     CubitFacet *new_facet = (CubitFacet *)
    2957 [ #  # ][ #  # ]:          0 :       new CubitFacetData(point_1, point_2, point_3);
    2958         [ #  # ]:          0 :     facet_list.append(new_facet);
    2959                 :            :   }
    2960                 :            :     //create the third and fourth for 6 points.
    2961         [ #  # ]:          0 :   else if ( step == 6 )
    2962                 :            :   {
    2963                 :            :       //get the current point (should be position 5/6)
    2964         [ #  # ]:          0 :     point_1 = temp_points.get();
    2965                 :            :       //get the next point. (should be position 6/6)
    2966         [ #  # ]:          0 :     point_2 = temp_points.next();
    2967                 :            :       //get the prev(2) point. ( should be position 3/6)
    2968         [ #  # ]:          0 :     point_3 = temp_points.prev(2);
    2969                 :            :     CubitFacet *new_facet = (CubitFacet *)
    2970 [ #  # ][ #  # ]:          0 :       new CubitFacetData(point_1, point_2, point_3);
    2971         [ #  # ]:          0 :     facet_list.append(new_facet);
    2972                 :            :       // get the next point. (should be 6/6)
    2973         [ #  # ]:          0 :     point_1 = temp_points.next();
    2974                 :            :       // get the next 2 point ( should be 1/6)
    2975         [ #  # ]:          0 :     point_2 = temp_points.next(2);
    2976                 :            :       //point3 stays the same (position 3/6).
    2977                 :            :     new_facet = (CubitFacet *)
    2978 [ #  # ][ #  # ]:          0 :       new CubitFacetData(point_1, point_2, point_3);
    2979         [ #  # ]:          0 :     facet_list.append(new_facet);
    2980                 :            :   }
    2981         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    2982                 :            : }
    2983                 :            : 
    2984                 :            : //===================================================================================
    2985                 :            : // Description: given facets in the form of a GMem data structure create new
    2986                 :            : //              CubitFacet and CubitPoint classes and return in lists
    2987                 :            : // Notes: 
    2988                 :            : // Author: 
    2989                 :            : // Date: 
    2990                 :            : //===================================================================================
    2991                 :          0 : CubitStatus ChollaEngine::get_facets(GMem& gMem, DLIList<CubitFacet*> &facet_list, 
    2992                 :            :                                      DLIList<CubitPoint*> &dl_point_list,
    2993                 :            :                                      bool insert_null_facets )
    2994                 :            : {
    2995         [ #  # ]:          0 :   if(gMem.fListCount == 0)
    2996                 :          0 :     return CUBIT_FAILURE;
    2997                 :            : 
    2998         [ #  # ]:          0 :   GPoint* plist = gMem.point_list();
    2999                 :            :   CubitPoint **point_list = (CubitPoint **)
    3000 [ #  # ][ #  # ]:          0 :     new CubitPointData *[gMem.pointListCount];
    3001                 :            :   double x, y, z;
    3002                 :            :   int i,j;
    3003         [ #  # ]:          0 :   for (i = 0; i<gMem.pointListCount; i++) 
    3004                 :            :   {
    3005                 :          0 :     x = plist[i].x;
    3006                 :          0 :     y = plist[i].y;
    3007                 :          0 :     z = plist[i].z;
    3008 [ #  # ][ #  # ]:          0 :     CubitPoint *new_point = (CubitPoint *) new CubitPointData(x, y, z);
    3009                 :          0 :     point_list[i] = new_point;
    3010         [ #  # ]:          0 :     dl_point_list.append(new_point);
    3011                 :            :   } 
    3012         [ #  # ]:          0 :   int *face_list = gMem.facet_list();
    3013                 :            :   int step;
    3014         [ #  # ]:          0 :   DLIList<CubitPoint*> temp_points;
    3015                 :            :   CubitFacet *new_facet;
    3016                 :            :   int ii, index_to_point;
    3017                 :            :   CubitStatus stat1;
    3018         [ #  # ]:          0 :   for ( i = 0; i < gMem.fListCount; i++ )
    3019                 :            :   {
    3020                 :          0 :     step = face_list[i];
    3021                 :            :       //Now get the points for this facet.
    3022      [ #  #  # ]:          0 :     switch (step)
    3023                 :            :     {
    3024                 :            :       case 3:
    3025                 :          0 :         ii = i + 1;
    3026         [ #  # ]:          0 :         temp_points.clean_out();
    3027         [ #  # ]:          0 :         for( j = ii; j < ii+step; j++ )
    3028                 :            :         {
    3029                 :          0 :           index_to_point = face_list[j];
    3030 [ #  # ][ #  # ]:          0 :           assert(index_to_point >= 0 && index_to_point <= gMem.pointListCount );
    3031         [ #  # ]:          0 :           temp_points.append(point_list[index_to_point]);
    3032                 :            :         }
    3033                 :            : 
    3034 [ #  # ][ #  # ]:          0 :         if( temp_points.get() != temp_points.next() &&
         [ #  # ][ #  # ]
    3035 [ #  # ][ #  # ]:          0 :             temp_points.get() != temp_points.next(2) &&
         [ #  # ][ #  # ]
    3036 [ #  # ][ #  # ]:          0 :             temp_points.next() != temp_points.next(2) )
    3037                 :            :         {
    3038                 :            :           new_facet = (CubitFacet *)
    3039         [ #  # ]:          0 :           new CubitFacetData(temp_points.get(), 
    3040                 :            :                              temp_points.next(),
    3041 [ #  # ][ #  # ]:          0 :                              temp_points.next(2) );
         [ #  # ][ #  # ]
    3042         [ #  # ]:          0 :           facet_list.append(new_facet);
    3043                 :            :         }
    3044                 :          0 :         i = i+step;
    3045                 :          0 :         break;
    3046                 :            :       case 4:
    3047                 :            :       case 5:
    3048                 :            :       case 6:
    3049                 :            :         stat1 = create_tri_facets(face_list,i, point_list,
    3050         [ #  # ]:          0 :                                   facet_list);
    3051         [ #  # ]:          0 :         if ( stat1 != CUBIT_SUCCESS )
    3052                 :            :         {
    3053 [ #  # ][ #  # ]:          0 :           PRINT_ERROR("Facets were not triangular and couldn't be split\n");
         [ #  # ][ #  # ]
    3054                 :          0 :           return stat1;
    3055                 :            :         }
    3056                 :          0 :         i = i+step;
    3057                 :          0 :         break;
    3058                 :            :       default:
    3059                 :            :           //We currently can't handle this...
    3060                 :            :           //Eventually we will have to split this polygon into more facets.
    3061 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Facets were not triangular, and couldn't be made so.\n");
         [ #  # ][ #  # ]
    3062 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Surface has: %d points forming a facet.\n", step);
         [ #  # ][ #  # ]
    3063         [ #  # ]:          0 :         if( insert_null_facets )
    3064         [ #  # ]:          0 :           facet_list.append( NULL );
    3065                 :          0 :         return CUBIT_FAILURE;
    3066                 :            :     }
    3067                 :            :   }
    3068         [ #  # ]:          0 :   delete [] point_list;
    3069         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    3070                 :            : }
    3071                 :            : 
    3072                 :            : //=============================================================================
    3073                 :            : //Function: collapses a given curve to a given point_to_keep
    3074                 :            : //          
    3075                 :            : //Description:
    3076                 :            : //Note: the hashing and other data structures are not updated during collapse.
    3077                 :            : //Author: william roshan quadros
    3078                 :            : //Date:  12/15/08
    3079                 :            : //=============================================================================
    3080                 :          0 : CubitStatus ChollaEngine::collapse_curve( ChollaCurve *cholla_curve, ChollaPoint *point_to_keep )
    3081                 :            : {
    3082                 :            :   // Make sure there are no underlying facet edges connected with this curve
    3083 [ #  # ][ #  # ]:          0 :   if( cholla_curve->get_facet_list().size() )
                 [ #  # ]
    3084                 :          0 :     return CUBIT_FAILURE;
    3085                 :            :   
    3086                 :            :   // Disassociate from cholla_surfaces 
    3087         [ #  # ]:          0 :   DLIList<ChollaSurface *> &ref_surfaces = cholla_curve->get_surfaces();
    3088                 :            :   int i;
    3089                 :            :   ChollaSurface *cholla_surface;
    3090 [ #  # ][ #  # ]:          0 :   for( i = 0; i < ref_surfaces.size(); i++ )
    3091                 :            :   {
    3092         [ #  # ]:          0 :     cholla_surface = ref_surfaces.get_and_step();
    3093         [ #  # ]:          0 :     cholla_surface->remove_curve( cholla_curve );
    3094                 :            :   }
    3095         [ #  # ]:          0 :   ref_surfaces.clean_out();
    3096                 :            : 
    3097                 :            :   // Disassociate from cholla point_to_delete 
    3098                 :            :   // Make sure curve has at least one point
    3099         [ #  # ]:          0 :   DLIList<ChollaPoint *> &cholla_pnts = cholla_curve->get_points();
    3100 [ #  # ][ #  # ]:          0 :   if( 0 == cholla_pnts.size()  )
    3101                 :          0 :     return CUBIT_FAILURE;
    3102                 :            : 
    3103                 :            :     // free eval tool
    3104 [ #  # ][ #  # ]:          0 :   if( cholla_curve->get_eval_tool() )
    3105                 :            :   {
    3106 [ #  # ][ #  # ]:          0 :     delete cholla_curve->get_eval_tool(); 
                 [ #  # ]
    3107                 :            :   }
    3108                 :            : 
    3109                 :            :   // find the point to delete
    3110         [ #  # ]:          0 :   ChollaPoint *first_pnt = cholla_pnts.get_and_step();
    3111         [ #  # ]:          0 :   ChollaPoint *last_pnt = cholla_pnts.get();
    3112                 :          0 :   ChollaPoint *point_to_del = NULL;
    3113         [ #  # ]:          0 :   switch( cholla_pnts.size() )
              [ #  #  # ]
    3114                 :            :   {
    3115                 :            : 
    3116                 :            :   case 2:    
    3117         [ #  # ]:          0 :     if( point_to_keep == last_pnt )
    3118                 :            :     {
    3119                 :          0 :       point_to_del = first_pnt;
    3120                 :            :     }
    3121                 :            :     else
    3122                 :            :     {
    3123         [ #  # ]:          0 :       if( point_to_keep == first_pnt )
    3124                 :            :       {
    3125                 :          0 :         point_to_del = last_pnt;
    3126                 :            :       }
    3127                 :            :     }
    3128                 :            : 
    3129                 :            :     // disassociate end points from cholla_curve
    3130         [ #  # ]:          0 :     if( point_to_del )
    3131                 :            :     {
    3132         [ #  # ]:          0 :       point_to_del->remove_curve( cholla_curve );
    3133         [ #  # ]:          0 :       cholla_pnts.remove( point_to_del );
    3134                 :            :     }
    3135         [ #  # ]:          0 :     if( point_to_keep )
    3136                 :            :     {
    3137         [ #  # ]:          0 :       point_to_keep->remove_curve( cholla_curve );
    3138         [ #  # ]:          0 :       cholla_pnts.remove( point_to_keep );
    3139                 :            :     }
    3140                 :            : 
    3141                 :            :     // Merge two points 
    3142         [ #  # ]:          0 :     merge_two_points( point_to_keep, point_to_del );
    3143                 :            : 
    3144                 :          0 :     break;
    3145                 :            : 
    3146                 :            :   case 1:
    3147                 :            :     // disassociate end points from cholla_curve
    3148                 :          0 :     point_to_del = first_pnt;
    3149         [ #  # ]:          0 :     point_to_del->remove_curve( cholla_curve );
    3150         [ #  # ]:          0 :     cholla_pnts.remove( point_to_del );
    3151                 :            :     
    3152 [ #  # ][ #  # ]:          0 :     if( 0 == point_to_del->get_curve_list_ptr()->size() )
                 [ #  # ]
    3153                 :            :     {
    3154                 :            :       // remove point_to_del from ChollaEngine
    3155         [ #  # ]:          0 :       remove_point( point_to_del );
    3156                 :            : 
    3157                 :            :       // free point_to_del
    3158 [ #  # ][ #  # ]:          0 :       delete point_to_del;
    3159                 :            :     }    
    3160                 :          0 :     break;
    3161                 :            : 
    3162                 :            :   default:
    3163                 :          0 :     return CUBIT_FAILURE;
    3164                 :            :   }
    3165                 :            : 
    3166                 :            : 
    3167                 :            :   // Disassociate curve from chollaEngine
    3168         [ #  # ]:          0 :   this->remove_curve( cholla_curve );
    3169                 :            : 
    3170                 :            :   // free the cholla_curve
    3171 [ #  # ][ #  # ]:          0 :   delete cholla_curve;
    3172                 :            : 
    3173                 :          0 :   return CUBIT_SUCCESS;
    3174                 :            : }
    3175                 :            : 
    3176                 :            :   // Merge two points 
    3177                 :          0 : CubitStatus ChollaEngine::merge_two_points( ChollaPoint *point_to_keep, ChollaPoint *point_to_del )
    3178                 :            : {
    3179                 :            :   // move cholla curves from point_to_del to point_to_keep
    3180                 :          0 :   DLIList<ChollaCurve *> &del_pnt_curves = point_to_del->get_curves();
    3181                 :            :   int i;
    3182                 :            :   ChollaCurve *cholla_curve;
    3183         [ #  # ]:          0 :   for( i = 0; i < del_pnt_curves.size(); i++ )
    3184                 :            :   {
    3185                 :          0 :     cholla_curve = del_pnt_curves.get_and_step();
    3186                 :            :     
    3187                 :          0 :     cholla_curve->remove_point( point_to_del );
    3188                 :          0 :     cholla_curve->add_point( point_to_keep );
    3189                 :          0 :     point_to_keep->add_curve( cholla_curve );
    3190                 :            :   }
    3191                 :          0 :   del_pnt_curves.clean_out();
    3192                 :            : 
    3193                 :            :   // if point_to_keep facet is null use point_to_del's facet
    3194 [ #  # ][ #  # ]:          0 :   if( NULL == point_to_keep->get_facets() && point_to_del->get_facets() )
                 [ #  # ]
    3195                 :            :   {
    3196                 :          0 :     point_to_keep->add_facet( point_to_del->get_facets() );
    3197                 :            :   }
    3198                 :            :   
    3199                 :            :   // what we should do with data member id?  should we move if point_to_keep->get_id() !=  0?
    3200                 :            : 
    3201                 :            :   // remove point_to_del from ChollaEngine
    3202                 :          0 :   remove_point( point_to_del );
    3203                 :            : 
    3204                 :            :   // free point_to_del
    3205         [ #  # ]:          0 :   delete point_to_del;
    3206                 :            : 
    3207                 :          0 :   return CUBIT_SUCCESS;
    3208                 :            : }
    3209                 :            : 
    3210                 :            : 
    3211                 :            : 
    3212                 :          0 : CubitStatus ChollaEngine::disassociate_surface( ChollaSurface *cholla_surf )
    3213                 :            : {
    3214                 :            :    // remove surface from volume
    3215         [ #  # ]:          0 :   DLIList<ChollaVolume *> cholla_volumes;
    3216         [ #  # ]:          0 :   cholla_surf->get_volumes(cholla_volumes);
    3217                 :            :   int i;
    3218                 :            :   ChollaVolume *cholla_volume;
    3219 [ #  # ][ #  # ]:          0 :   for (i=0; i<cholla_volumes.size(); i++)
    3220                 :            :   {
    3221         [ #  # ]:          0 :     cholla_volume = cholla_volumes.get_and_step();
    3222         [ #  # ]:          0 :     cholla_volume->remove_surface( cholla_surf );
    3223                 :            :   }
    3224                 :            :   
    3225                 :            :    // Disassociate curves from suface
    3226 [ #  # ][ #  # ]:          0 :   DLIList< ChollaCurve *> cholla_curves;
    3227         [ #  # ]:          0 :   cholla_surf->get_curves( cholla_curves );
    3228                 :            :   
    3229                 :            :   ChollaCurve *cholla_curve;
    3230 [ #  # ][ #  # ]:          0 :   for( i = 0; i < cholla_curves.size(); i++ )
    3231                 :            :   {
    3232         [ #  # ]:          0 :     cholla_curve = cholla_curves.get_and_step();
    3233                 :            :     
    3234         [ #  # ]:          0 :     cholla_curve->remove_surface( cholla_surf );
    3235         [ #  # ]:          0 :     cholla_surf->remove_curve( cholla_curve );
    3236                 :            :   }
    3237         [ #  # ]:          0 :   cholla_curves.clean_out();
    3238                 :            : 
    3239                 :            :   // Remove facet tool if available ?
    3240         [ #  # ]:          0 :   if( cholla_surf->get_eval_tool() )
    3241                 :            :   {
    3242                 :            : #ifdef _DEBUG
    3243                 :            :     //PRINT_INFO("WARNING: delete ch_surf->facet_eval_tool safely \n");//   
    3244                 :            : #endif
    3245                 :            :     //delete cholla_surf->get_eval_tool();
    3246                 :            :     // set eval tool to NULL
    3247                 :            :   }
    3248                 :            :   
    3249                 :            :   // remove from ChollaEngine
    3250         [ #  # ]:          0 :   remove_surface( cholla_surf );
    3251                 :            : 
    3252         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    3253                 :            : 
    3254                 :            : }
    3255                 :            : //=============================================================================
    3256                 :            : //Function: collapses a given surface 
    3257                 :            : //Description: currently it disassociates surface with its curves and ChollaEngine 
    3258                 :            : //Note: make sure there are no underlying facets and model is automatically watertight when input cholla_surf is deleted
    3259                 :            : //Author: william roshan quadros
    3260                 :            : //Date:  12/15/08
    3261                 :            : //=============================================================================
    3262                 :            : 
    3263                 :          0 : CubitStatus ChollaEngine::collapse_surface( ChollaSurface *cholla_surf )
    3264                 :            : {
    3265                 :            :   // Make sure there are no facets 
    3266         [ #  # ]:          0 :   if( cholla_surf->get_facet_list().size() )
    3267                 :          0 :      return CUBIT_FAILURE; 
    3268                 :            : 
    3269                 :          0 :   disassociate_surface( cholla_surf );
    3270                 :            :   
    3271                 :            :   // free cholla surface
    3272         [ #  # ]:          0 :   delete cholla_surf;
    3273                 :            : 
    3274                 :          0 :   return CUBIT_SUCCESS;
    3275                 :            : }
    3276                 :            : 
    3277                 :          0 : CubitStatus ChollaEngine::remove_facet_entity( CubitFacet *facet, ChollaSurface *cholla_surf )
    3278                 :            : {
    3279         [ #  # ]:          0 :   this->faceList.remove( facet );
    3280                 :            : 
    3281         [ #  # ]:          0 :   if( cholla_surf )
    3282                 :          0 :     cholla_surf->remove_facet( facet );
    3283                 :            : 
    3284                 :          0 :   return CUBIT_SUCCESS;
    3285                 :            : }
    3286                 :            :   
    3287                 :          0 : CubitStatus ChollaEngine::remove_facet_entity( CubitFacetEdge *facet_edge, ChollaCurve *cholla_curve )
    3288                 :            : {
    3289         [ #  # ]:          0 :   this->edgeList.remove( facet_edge );
    3290                 :            : 
    3291         [ #  # ]:          0 :   if( cholla_curve )
    3292                 :          0 :     cholla_curve->remove_facet( facet_edge );
    3293                 :            : 
    3294                 :          0 :   return CUBIT_SUCCESS;
    3295                 :            : }
    3296                 :            : 
    3297                 :          0 : CubitStatus ChollaEngine::remove_facet_entity( CubitPoint *facet_pnt, ChollaPoint *cholla_point )
    3298                 :            : {
    3299         [ #  # ]:          0 :   this->pointList.remove( facet_pnt );
    3300                 :            : 
    3301         [ #  # ]:          0 :   if( cholla_point )
    3302                 :          0 :     cholla_point->remove_facet(/* facet_pnt */);
    3303                 :            : 
    3304                 :          0 :   return CUBIT_SUCCESS;
    3305                 :            : }
    3306                 :            : 
    3307                 :          0 : CubitStatus ChollaEngine::remove_facet_entity( CubitFacet *facet, std::set<ChollaEntity *> &cholla_surfs )
    3308                 :            : {
    3309         [ #  # ]:          0 :   std::set<ChollaEntity *>::iterator set_it;
    3310 [ #  # ][ #  # ]:          0 :   for( set_it = cholla_surfs.begin(); set_it != cholla_surfs.end(); set_it++ )
         [ #  # ][ #  # ]
                 [ #  # ]
    3311                 :            :   {
    3312 [ #  # ][ #  # ]:          0 :     if( dynamic_cast< ChollaSurface *>(*set_it) )
         [ #  # ][ #  # ]
    3313                 :            :     {
    3314 [ #  # ][ #  # ]:          0 :       static_cast<ChollaSurface *>(*set_it)->remove_facet( facet );
    3315                 :            :     }
    3316                 :            :   }
    3317                 :            : 
    3318         [ #  # ]:          0 :   this->faceList.remove( facet );
    3319                 :            : 
    3320                 :          0 :   return CUBIT_SUCCESS;
    3321                 :            : }
    3322                 :            :   
    3323                 :          0 : CubitStatus ChollaEngine::remove_facet_entity( CubitFacetEdge *facet_edge, std::set<ChollaEntity *> &cholla_curves )
    3324                 :            : {
    3325                 :            :   
    3326         [ #  # ]:          0 :   std::set<ChollaEntity *>::iterator set_it;
    3327 [ #  # ][ #  # ]:          0 :   for( set_it = cholla_curves.begin(); set_it != cholla_curves.end(); set_it++ )
         [ #  # ][ #  # ]
                 [ #  # ]
    3328                 :            :   {
    3329 [ #  # ][ #  # ]:          0 :     if( dynamic_cast<ChollaCurve*>(*set_it) )
         [ #  # ][ #  # ]
    3330                 :            :     { 
    3331 [ #  # ][ #  # ]:          0 :       dynamic_cast<ChollaCurve*>(*set_it)->remove_facet( facet_edge );
                 [ #  # ]
    3332                 :            :     }
    3333                 :            :   }
    3334                 :            : 
    3335         [ #  # ]:          0 :   this->edgeList.remove( facet_edge );
    3336                 :            : 
    3337                 :          0 :   return CUBIT_SUCCESS;
    3338                 :            : }
    3339                 :            : 
    3340                 :          0 : CubitStatus ChollaEngine::replace_facet_entity( CubitFacetEdge *remove_edge, CubitFacetEdge *replace_edge, std::set<ChollaEntity *> cholla_curves )
    3341                 :            : {
    3342         [ #  # ]:          0 :   std::set<ChollaEntity *>::iterator set_it; 
    3343 [ #  # ][ #  # ]:          0 :   for( set_it = cholla_curves.begin(); set_it != cholla_curves.end(); set_it++ )
         [ #  # ][ #  # ]
                 [ #  # ]
    3344                 :            :   {
    3345 [ #  # ][ #  # ]:          0 :     if( dynamic_cast<ChollaCurve*>(*set_it) )
         [ #  # ][ #  # ]
    3346                 :            :     { 
    3347 [ #  # ][ #  # ]:          0 :       static_cast<ChollaCurve*>(*set_it)->replace_facet( remove_edge, replace_edge );
    3348                 :            :     }
    3349                 :            :   }
    3350                 :            : 
    3351                 :          0 :   return CUBIT_SUCCESS;
    3352                 :            : }
    3353                 :            : 
    3354                 :            : 
    3355                 :          0 : CubitStatus ChollaEngine::remove_facet_entity( CubitPoint *facet_pnt, std::set<ChollaEntity *> &cholla_points )
    3356                 :            : {
    3357         [ #  # ]:          0 :   this->pointList.remove( facet_pnt );
    3358                 :            : 
    3359         [ #  # ]:          0 :   std::set<ChollaEntity *>::iterator set_it;
    3360 [ #  # ][ #  # ]:          0 :   for( set_it = cholla_points.begin(); set_it != cholla_points.end(); set_it++ )
         [ #  # ][ #  # ]
                 [ #  # ]
    3361                 :            :   {
    3362 [ #  # ][ #  # ]:          0 :     if( dynamic_cast<ChollaPoint*>(*set_it) )
         [ #  # ][ #  # ]
    3363                 :            :     { 
    3364 [ #  # ][ #  # ]:          0 :       static_cast<ChollaPoint*>(*set_it)->remove_facet( facet_pnt );
    3365                 :            :     }
    3366                 :            :   }
    3367                 :            : 
    3368                 :          0 :   return CUBIT_SUCCESS;
    3369                 :            : }
    3370                 :            : 
    3371                 :            : /*
    3372                 :            : // disassoicate ch_entity from ch_points, ch_curve, ch_surf, and ch_engine
    3373                 :            : CubitStatus ChollaEngine::disassociate_curve( ChollaCurve *ch_curve )
    3374                 :            : {
    3375                 :            :   
    3376                 :            :   // disassociate from cholla points
    3377                 :            :   ch_curve->disassociate_from_points();
    3378                 :            :   
    3379                 :            :   // disassociate from cholla surface
    3380                 :            :   ch_curve->disassociate_from_surfaces();
    3381                 :            : 
    3382                 :            :   // disassociate from cholla engine
    3383                 :            :   remove_curve( ch_curve );
    3384                 :            : 
    3385                 :            :   return CUBIT_SUCCESS;
    3386                 :            : }
    3387                 :            : */
    3388                 :            : 
    3389                 :          0 : CubitStatus ChollaEngine::create_surface( int block_id,
    3390                 :            :                                           ChollaSurface *&new_ch_surf )
    3391                 :            : {
    3392         [ #  # ]:          0 :   new_ch_surf = new ChollaSurface( block_id );
    3393                 :            :   
    3394                 :            :   // add it to cholla engine
    3395                 :          0 :   chollaSurfaceList.append( new_ch_surf ); 
    3396                 :            : 
    3397                 :          0 :   return CUBIT_SUCCESS;
    3398                 :            : }
    3399                 :            : 
    3400                 :            :  // Create new ch_curve and associate with end ch_points.  Add ch_curve to chollaEngine
    3401                 :          0 : CubitStatus ChollaEngine::create_curve(int block_id, 
    3402                 :            :                                        ChollaPoint *new_ch_pnt0, 
    3403                 :            :                                        ChollaPoint *new_ch_pnt1, 
    3404                 :            :                                        ChollaCurve *&new_ch_curve
    3405                 :            :                                     )
    3406                 :            : {
    3407                 :            : 
    3408                 :            :   
    3409         [ #  # ]:          0 :   new_ch_curve = new ChollaCurve( block_id );
    3410                 :            : 
    3411                 :            :   // associate with cholla points
    3412                 :          0 :   new_ch_curve->add_point( new_ch_pnt0 );
    3413                 :          0 :   new_ch_pnt0->add_curve( new_ch_curve );
    3414                 :          0 :   new_ch_curve->add_point( new_ch_pnt1 );
    3415                 :          0 :   new_ch_pnt1->add_curve( new_ch_curve );
    3416                 :            : 
    3417                 :            : 
    3418                 :            :   // update start and end facet points
    3419         [ #  # ]:          0 :   new_ch_curve->set_start( CAST_TO( new_ch_pnt0->get_facets(), CubitPointData) );
    3420         [ #  # ]:          0 :   new_ch_curve->set_end( CAST_TO( new_ch_pnt1->get_facets(), CubitPointData) );
    3421                 :            : 
    3422                 :            :   // add it to cholla engine
    3423                 :          0 :   chollaCurveList.append( new_ch_curve ); 
    3424                 :            : 
    3425                 :          0 :   return CUBIT_SUCCESS;
    3426                 :            : }
    3427                 :            : 
    3428                 :          0 : CubitStatus ChollaEngine::create_point( CubitPoint *pnt, ChollaPoint * &new_ch_pnt )
    3429                 :            : {
    3430 [ #  # ][ #  # ]:          0 :   new_ch_pnt = new ChollaPoint();
    3431         [ #  # ]:          0 :   new_ch_pnt->add_facet( pnt );
    3432         [ #  # ]:          0 :   double *coordinate = new double[3];
    3433         [ #  # ]:          0 :   CubitVector coord_vect = pnt->coordinates();
    3434         [ #  # ]:          0 :   coordinate[0] = coord_vect[0];
    3435         [ #  # ]:          0 :   coordinate[1] = coord_vect[1];
    3436         [ #  # ]:          0 :   coordinate[2] = coord_vect[2];
    3437         [ #  # ]:          0 :   new_ch_pnt->assign_geometric_point( (void*) coordinate );
    3438                 :            : 
    3439                 :          0 :   return CUBIT_SUCCESS;
    3440                 :            : }
    3441                 :            : 
    3442                 :            : 
    3443                 :            : // disassoicate ch_curve from ch_points, ch_surfs, and ch_engine
    3444                 :          0 : CubitStatus ChollaEngine::disassociate_curve( ChollaCurve *ch_curve, bool disassociate_with_vert, bool disassociate_with_surf, bool disassociate_with_model )
    3445                 :            : {
    3446                 :            :   // remove ch_curve from ch_point
    3447                 :            :   int i;
    3448         [ #  # ]:          0 :   if( disassociate_with_vert )
    3449                 :            :   {
    3450         [ #  # ]:          0 :     for( i = 0; i < ch_curve->get_points().size(); i++ )
    3451                 :            :     {
    3452                 :          0 :       ch_curve->get_points().get_and_step()->remove_curve( ch_curve );
    3453                 :            :     }
    3454                 :            :     // remove ch_points
    3455                 :          0 :     ch_curve->get_points().clean_out();
    3456                 :            :   }
    3457                 :            : 
    3458         [ #  # ]:          0 :   if( disassociate_with_surf )
    3459                 :            :   {
    3460                 :            :     // remove ch_curve in ch_surface
    3461                 :            :     ChollaSurface *ptr_ch_surf;   
    3462         [ #  # ]:          0 :     for( i = 0; i < ch_curve->get_surfaces().size(); i++ )
    3463                 :            :     {
    3464                 :          0 :       ptr_ch_surf = ch_curve->get_surfaces().get_and_step();
    3465                 :          0 :       ptr_ch_surf->remove_curve( ch_curve );
    3466                 :            :     }
    3467                 :            :     // remove ch_surface
    3468                 :          0 :     ch_curve->get_surfaces().clean_out();
    3469                 :            :   }
    3470                 :            : 
    3471         [ #  # ]:          0 :   if( disassociate_with_model )
    3472                 :            :   {
    3473                 :            :     // remove from ch_engie
    3474                 :          0 :     this->remove_curve( ch_curve );
    3475                 :            :   }
    3476                 :            : 
    3477                 :          0 :   return CUBIT_SUCCESS;
    3478                 :            : }
    3479                 :            : 
    3480                 :            : //=============================================================================
    3481                 :            : //Function: detach_volumes 
    3482                 :            : //Description: Create independent manifold volumes from the non-manifold set 
    3483                 :            : //Note: 
    3484                 :            : //Author:sjowen
    3485                 :            : //Date:  09/10/09
    3486                 :            : //=============================================================================
    3487                 :          0 : CubitStatus ChollaEngine::detach_volumes()
    3488                 :            : {
    3489                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;
    3490                 :            :  
    3491                 :            :   // define maps between the original entities and their copies so we can 
    3492                 :            :   // use them for detaching the facets
    3493                 :            :   
    3494         [ #  # ]:          0 :   std::map<ChollaSurface *, ChollaSurface *> surf_map;
    3495 [ #  # ][ #  # ]:          0 :   std::multimap<ChollaCurve *, ChollaCurve *> curve_map;
    3496 [ #  # ][ #  # ]:          0 :   std::multimap<ChollaPoint *, ChollaPoint *> point_map; 
    3497                 :            :   
    3498 [ #  # ][ #  # ]:          0 :   for( int i=chollaVolumeList.size(); i--; )
    3499                 :            :   {
    3500         [ #  # ]:          0 :     ChollaVolume *chvol = chollaVolumeList.get_and_step();
    3501         [ #  # ]:          0 :     DLIList<ChollaSurface*> ch_surfaces;
    3502         [ #  # ]:          0 :     chvol->get_surfaces( ch_surfaces );    
    3503                 :            : 
    3504 [ #  # ][ #  # ]:          0 :     std::map<ChollaCurve *, ChollaCurve *> tmp_curve_map;
                 [ #  # ]
    3505 [ #  # ][ #  # ]:          0 :     std::map<ChollaPoint *, ChollaPoint *> tmp_point_map; 
                 [ #  # ]
    3506                 :            :     
    3507 [ #  # ][ #  # ]:          0 :     DLIList<ChollaSurface*> surfaces_to_detach;
                 [ #  # ]
    3508 [ #  # ][ #  # ]:          0 :     DLIList<ChollaCurve*> curves_to_detach;
                 [ #  # ]
    3509 [ #  # ][ #  # ]:          0 :     for( int j=ch_surfaces.size(); j--; )
    3510                 :            :     {
    3511         [ #  # ]:          0 :       ChollaSurface *chsurf_ptr = ch_surfaces.get_and_step();     
    3512                 :            : 
    3513                 :            :       // look for any surfaces that are associated with exactly two volumes
    3514 [ #  # ][ #  # ]:          0 :       if (chsurf_ptr->num_volumes() == 2)      
    3515         [ #  # ]:          0 :         surfaces_to_detach.append( chsurf_ptr );   
    3516                 :            :       else
    3517                 :            :       {
    3518                 :            :         //look for any curves that are attached to two volumes
    3519         [ #  # ]:          0 :         DLIList<ChollaCurve*> ch_curves;
    3520         [ #  # ]:          0 :         chsurf_ptr->get_curves( ch_curves );
    3521 [ #  # ][ #  # ]:          0 :         for( int k=ch_curves.size(); k--; )
    3522                 :            :         {
    3523         [ #  # ]:          0 :           ChollaCurve *tmp_curve = ch_curves.get_and_step();
    3524 [ #  # ][ #  # ]:          0 :           if( tmp_curve->num_volumes() > 1 )
    3525         [ #  # ]:          0 :             curves_to_detach.append( tmp_curve );
    3526         [ #  # ]:          0 :         }
    3527                 :            :       }
    3528                 :            :     }   
    3529                 :            : 
    3530                 :            :     //filter out curves that are in surfs in 'surfaces_to_detach'
    3531                 :            :     //since they will get detached when the parent surface gets detached
    3532 [ #  # ][ #  # ]:          0 :     for( int j=curves_to_detach.size(); j--; )
    3533                 :            :     {
    3534         [ #  # ]:          0 :       ChollaCurve *tmp_curve = curves_to_detach.get();
    3535 [ #  # ][ #  # ]:          0 :       DLIList<ChollaSurface*> tmp_surfs = tmp_curve->get_surfaces();
    3536                 :            : 
    3537 [ #  # ][ #  # ]:          0 :       for( int k=tmp_surfs.size(); k--; )
    3538                 :            :       {
    3539         [ #  # ]:          0 :         ChollaSurface *tmp_surf = tmp_surfs.get_and_step();
    3540 [ #  # ][ #  # ]:          0 :         if( surfaces_to_detach.is_in_list( tmp_surf ) )
    3541                 :            :         {
    3542         [ #  # ]:          0 :           curves_to_detach.change_to(NULL);
    3543                 :          0 :           break;
    3544                 :            :         }
    3545                 :            :       }
    3546         [ #  # ]:          0 :       curves_to_detach.step();    
    3547         [ #  # ]:          0 :     }  
    3548                 :            :     
    3549         [ #  # ]:          0 :     curves_to_detach.remove_all_with_value( NULL );
    3550         [ #  # ]:          0 :     curves_to_detach.uniquify_unordered();
    3551                 :            : 
    3552 [ #  # ][ #  # ]:          0 :     if( surfaces_to_detach.size() || curves_to_detach.size() )
         [ #  # ][ #  # ]
                 [ #  # ]
    3553                 :            :     {
    3554         [ #  # ]:          0 :       rv = detach_surfaces( surfaces_to_detach, curves_to_detach, chvol, surf_map, tmp_curve_map, tmp_point_map );
    3555         [ #  # ]:          0 :       if (rv != CUBIT_SUCCESS)
    3556                 :          0 :         return CUBIT_FAILURE;
    3557                 :            :       
    3558                 :            :       //for all detached surfaces, detach all the facets and create new ones for
    3559                 :            :       //the detached surfaces
    3560         [ #  # ]:          0 :       rv = detach_facets(surfaces_to_detach, curves_to_detach, chvol, surf_map, tmp_curve_map, tmp_point_map);
    3561         [ #  # ]:          0 :       if (rv != CUBIT_SUCCESS)
    3562                 :          0 :         return rv;
    3563                 :            : 
    3564                 :            :       // set the cubitpoints at the correct start/end locations on the cholla curves   
    3565         [ #  # ]:          0 :       rv = set_curve_endpoints(tmp_point_map, tmp_curve_map );
    3566         [ #  # ]:          0 :       if (rv != CUBIT_SUCCESS)
    3567                 :          0 :         return rv;
    3568                 :            :     }
    3569                 :            : 
    3570                 :            :     //append the map to the multi-map
    3571         [ #  # ]:          0 :     std::map<ChollaCurve*, ChollaCurve*>::iterator iter = tmp_curve_map.begin();
    3572 [ #  # ][ #  # ]:          0 :     for( ; iter!=tmp_curve_map.end(); iter++)
         [ #  # ][ #  # ]
    3573 [ #  # ][ #  # ]:          0 :       curve_map.insert( std::pair<ChollaCurve*,ChollaCurve*>(iter->first, iter->second) );
         [ #  # ][ #  # ]
                 [ #  # ]
    3574                 :            : 
    3575                 :            :     //append the map to the multi-map
    3576         [ #  # ]:          0 :     std::map<ChollaPoint*, ChollaPoint*>::iterator pt_iter = tmp_point_map.begin();
    3577 [ #  # ][ #  # ]:          0 :     for( ; pt_iter!=tmp_point_map.end(); pt_iter++)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3578 [ #  # ][ #  # ]:          0 :       point_map.insert( std::pair<ChollaPoint*,ChollaPoint*>(pt_iter->first, pt_iter->second) );   
         [ #  # ][ #  # ]
                 [ #  # ]
    3579                 :          0 :   } 
    3580                 :            :   
    3581                 :            :   // create the evaluation tools on the new entities
    3582                 :            :   
    3583                 :          0 :   CubitBoolean use_feature_angle = CUBIT_FALSE; 
    3584                 :          0 :   double min_dot = 0.0;                    
    3585                 :          0 :   int interp_order = 0;                 
    3586                 :          0 :   CubitBoolean smooth_non_manifold = CUBIT_FALSE;
    3587                 :          0 :   CubitBoolean split_surfaces = CUBIT_FALSE;
    3588 [ #  # ][ #  # ]:          0 :   DLIList<ChollaSurface *> cholla_surfaces;
    3589 [ #  # ][ #  # ]:          0 :   DLIList<ChollaCurve *> cholla_curves;
    3590                 :            :   
    3591                 :            :   // get lists of new surfaces and curves from the maps
    3592                 :            :   
    3593         [ #  # ]:          0 :   std::map<ChollaSurface *, ChollaSurface *>::iterator smap_it;
    3594 [ #  # ][ #  # ]:          0 :   for (smap_it=surf_map.begin(); smap_it != surf_map.end(); smap_it++)
         [ #  # ][ #  # ]
                 [ #  # ]
    3595                 :            :   {
    3596 [ #  # ][ #  # ]:          0 :     cholla_surfaces.append(smap_it->second);
    3597                 :            :   }
    3598                 :            :   
    3599         [ #  # ]:          0 :   std::multimap<ChollaCurve *, ChollaCurve *>::iterator cmap_it;
    3600 [ #  # ][ #  # ]:          0 :   for (cmap_it=curve_map.begin(); cmap_it != curve_map.end(); cmap_it++)
         [ #  # ][ #  # ]
                 [ #  # ]
    3601                 :            :   {
    3602 [ #  # ][ #  # ]:          0 :     cholla_curves.append(cmap_it->second);
    3603                 :            :   }
    3604                 :            :   
    3605                 :            :   // rebuild the new curves so the edges are oriented correctly
    3606                 :            :   
    3607 [ #  # ][ #  # ]:          0 :   for (int ii=0; ii<cholla_curves.size(); ii++)
    3608                 :            :   {
    3609         [ #  # ]:          0 :     ChollaCurve *cholla_curve = cholla_curves.get_and_step();
    3610 [ #  # ][ #  # ]:          0 :     DLIList<ChollaPoint *>  cholla_points = cholla_curve->get_points();    
    3611                 :          0 :     int periodic = 0;
    3612 [ #  # ][ #  # ]:          0 :     if (cholla_points.size() == 1)
    3613                 :          0 :       periodic = 1;
    3614                 :            :     else
    3615 [ #  # ][ #  # ]:          0 :       assert(cholla_points.size() == 2);  // assuming we have exactly two end points so far
    3616                 :            :     CubitPoint *start_point, *end_point;
    3617         [ #  # ]:          0 :     cholla_curve->get_ends(start_point, end_point);        
    3618         [ #  # ]:          0 :     int max_edges = cholla_curve->num_edges();
    3619         [ #  # ]:          0 :     cholla_curve->clean_out_edges();  // edges will be added in build_curve_from_edges 
    3620         [ #  # ]:          0 :     rv = cholla_curve->build_curve_from_edges( start_point, periodic, max_edges, NULL, cholla_curve );
    3621         [ #  # ]:          0 :     if (rv != CUBIT_SUCCESS)
    3622 [ #  # ][ #  # ]:          0 :       return rv;
    3623                 :          0 :   } 
    3624                 :            :   
    3625                 :            :   // replace the facets on the existing eval tools on the curves and surfaces bounding the interface.
    3626                 :            :   // for simplicity, just replace them on all the existing eval tools on 
    3627                 :            :   
    3628 [ #  # ][ #  # ]:          0 :   for (int icurv = 0; icurv < chollaCurveList.size(); icurv++)
    3629                 :            :   {
    3630         [ #  # ]:          0 :     ChollaCurve *chcurv_ptr = chollaCurveList.get_and_step();
    3631         [ #  # ]:          0 :     CurveFacetEvalTool *ceval = chcurv_ptr->get_eval_tool();
    3632         [ #  # ]:          0 :     if (ceval != NULL)
    3633                 :            :     {
    3634 [ #  # ][ #  # ]:          0 :       DLIList<FacetEntity *> fedges = chcurv_ptr->get_facet_list();
    3635 [ #  # ][ #  # ]:          0 :       DLIList<CubitFacetEdge *> edges;
    3636 [ #  # ][ #  # ]:          0 :       CAST_LIST( fedges, edges, CubitFacetEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3637 [ #  # ][ #  # ]:          0 :       ceval->replace_facets(edges);
    3638                 :            :     }
    3639                 :            :   }
    3640                 :            :   
    3641 [ #  # ][ #  # ]:          0 :   for (int isurf=0; isurf<chollaSurfaceList.size(); isurf++)
    3642                 :            :   {
    3643         [ #  # ]:          0 :     ChollaSurface *chsurf_ptr = chollaSurfaceList.get_and_step();
    3644         [ #  # ]:          0 :     FacetEvalTool *seval = chsurf_ptr->get_eval_tool();
    3645         [ #  # ]:          0 :     if (seval != NULL)
    3646                 :            :     {
    3647 [ #  # ][ #  # ]:          0 :       DLIList<FacetEntity *> ffacets = chsurf_ptr->get_facet_list();
    3648 [ #  # ][ #  # ]:          0 :       DLIList<CubitFacet *> facets;
    3649 [ #  # ][ #  # ]:          0 :       CAST_LIST( ffacets, facets, CubitFacet );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3650 [ #  # ][ #  # ]:          0 :       seval->replace_facets(facets);
    3651                 :            :     }
    3652                 :            :   }
    3653                 :            :  
    3654                 :            :   
    3655                 :            :   // build the eval tools
    3656                 :            :       
    3657                 :            :   rv = build_eval_tools(cholla_surfaces,
    3658                 :            :                         cholla_curves,
    3659                 :            :                         interp_order, use_feature_angle, 
    3660                 :            :                         min_dot, smooth_non_manifold,
    3661         [ #  # ]:          0 :                         split_surfaces );
    3662                 :            :     
    3663         [ #  # ]:          0 :   return rv;
    3664                 :            : }
    3665                 :            : 
    3666                 :            : //=============================================================================
    3667                 :            : //Function: detach_surface 
    3668                 :            : //Description: given a non-manifold surface in a cholla model, create a copy
    3669                 :            : //             and update child entities
    3670                 :            : //Notes:  assumes that chsurf_ptr has exactly 2 adjacent volumes
    3671                 :            : //Author:sjowen
    3672                 :            : //Date:  09/18/09
    3673                 :            : //=============================================================================
    3674                 :          0 : CubitStatus ChollaEngine::detach_surfaces(DLIList<ChollaSurface*> &chsurfs,
    3675                 :            :                                           DLIList<ChollaCurve*> &chcurves,
    3676                 :            :                                          ChollaVolume *vol_getting_new_surfs,
    3677                 :            :                                          std::map<ChollaSurface *, ChollaSurface *> &surf_map,
    3678                 :            :                                          std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    3679                 :            :                                          std::map<ChollaPoint *, ChollaPoint *> &point_map)
    3680                 :            : {
    3681                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;
    3682                 :            :   
    3683                 :            :   // detach the surface from its volumes
    3684                 :            : 
    3685         [ #  # ]:          0 :   DLIList<ChollaCurve*> all_curves_in_surfs;
    3686 [ #  # ][ #  # ]:          0 :   DLIList<ChollaPoint*> all_points_in_surfs;
    3687                 :            : 
    3688 [ #  # ][ #  # ]:          0 :   std::multimap<ChollaCurve*, ChollaSurface*> orig_curve_to_new_surf_map;
    3689                 :            :   
    3690 [ #  # ][ #  # ]:          0 :   for( int i=chsurfs.size(); i--; )
    3691                 :            :   {
    3692         [ #  # ]:          0 :     ChollaSurface *chsurf_ptr = chsurfs.get_and_step();
    3693         [ #  # ]:          0 :     DLIList<ChollaVolume *> chvol_list;
    3694         [ #  # ]:          0 :     chsurf_ptr->get_volumes(chvol_list);
    3695         [ #  # ]:          0 :     ChollaVolume *chvol1_ptr = chvol_list.get_and_step();
    3696         [ #  # ]:          0 :     ChollaVolume *chvol2_ptr = chvol_list.get();
    3697                 :            : 
    3698         [ #  # ]:          0 :     if( chvol2_ptr != vol_getting_new_surfs )      
    3699                 :            :     {
    3700                 :          0 :       chvol1_ptr = chvol2_ptr;
    3701                 :          0 :       chvol2_ptr = vol_getting_new_surfs;      
    3702                 :            :     }
    3703                 :            : 
    3704 [ #  # ][ #  # ]:          0 :     if (NULL == chvol1_ptr || NULL == chvol2_ptr) {
    3705 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Unexpected NULL pointer for cholla volume.\n");
         [ #  # ][ #  # ]
    3706                 :          0 :       return CUBIT_FAILURE;
    3707                 :            :     }
    3708         [ #  # ]:          0 :     assert(chvol1_ptr != chvol2_ptr);
    3709                 :            : 
    3710                 :            :     // create a copy of the non-manifold surface and attach it to volume 2
    3711                 :            : 
    3712 [ #  # ][ #  # ]:          0 :     ChollaSurface *newchsurf_ptr = new ChollaSurface( chsurf_ptr->get_block_id() );
                 [ #  # ]
    3713         [ #  # ]:          0 :     chollaSurfaceList.append(newchsurf_ptr);
    3714 [ #  # ][ #  # ]:          0 :     surf_map.insert(std::pair<ChollaSurface *, ChollaSurface *>(chsurf_ptr, newchsurf_ptr));
                 [ #  # ]
    3715                 :            : 
    3716         [ #  # ]:          0 :     chvol2_ptr->remove_surface(chsurf_ptr);
    3717         [ #  # ]:          0 :     chsurf_ptr->remove_volume(chvol2_ptr);
    3718         [ #  # ]:          0 :     chvol2_ptr->add_surface(newchsurf_ptr);
    3719         [ #  # ]:          0 :     newchsurf_ptr->add_volume(chvol2_ptr);
    3720                 :            :     
    3721         [ #  # ]:          0 :     chsurf_ptr->set_merge_partner(newchsurf_ptr);
    3722         [ #  # ]:          0 :     newchsurf_ptr->set_merge_partner(chsurf_ptr);
    3723                 :            : 
    3724                 :            :     // detach the curves  
    3725 [ #  # ][ #  # ]:          0 :     DLIList<ChollaCurve *> chcurv_list;
         [ #  # ][ #  # ]
    3726         [ #  # ]:          0 :     chsurf_ptr->get_curves(chcurv_list);    
    3727                 :            : 
    3728 [ #  # ][ #  # ]:          0 :     for( int k=chcurv_list.size(); k--; )
    3729                 :            :     {
    3730         [ #  # ]:          0 :       ChollaCurve *chcurve = chcurv_list.get_and_step();
    3731 [ #  # ][ #  # ]:          0 :       orig_curve_to_new_surf_map.insert( std::pair<ChollaCurve*, ChollaSurface*>( chcurve, newchsurf_ptr ) );
                 [ #  # ]
    3732                 :            :     }
    3733                 :            : 
    3734         [ #  # ]:          0 :     all_curves_in_surfs += chcurv_list;
    3735                 :            : 
    3736 [ #  # ][ #  # ]:          0 :     DLIList<ChollaPoint*> chpt_list;
    3737         [ #  # ]:          0 :     chsurf_ptr->get_vertices( chpt_list );
    3738         [ #  # ]:          0 :     all_points_in_surfs += chpt_list;
    3739                 :          0 :   }
    3740                 :            : 
    3741         [ #  # ]:          0 :   all_curves_in_surfs.uniquify_unordered();  
    3742                 :            :   
    3743 [ #  # ][ #  # ]:          0 :   for(int icurv = 0; icurv < all_curves_in_surfs.size(); icurv++)
    3744                 :            :   {    
    3745         [ #  # ]:          0 :     ChollaCurve *chcurv_ptr = all_curves_in_surfs.get_and_step();
    3746                 :            : 
    3747 [ #  # ][ #  # ]:          0 :     std::multimap<ChollaCurve*, ChollaSurface*>::iterator iter, upper_iter;
    3748         [ #  # ]:          0 :     DLIList<ChollaSurface*> new_surfs;
    3749                 :            : 
    3750         [ #  # ]:          0 :     iter = orig_curve_to_new_surf_map.find( chcurv_ptr );
    3751                 :            : 
    3752 [ #  # ][ #  # ]:          0 :     assert( iter != orig_curve_to_new_surf_map.end() );
                 [ #  # ]
    3753                 :            : 
    3754 [ #  # ][ #  # ]:          0 :     upper_iter = orig_curve_to_new_surf_map.upper_bound( iter->first );
    3755                 :            : 
    3756 [ #  # ][ #  # ]:          0 :     for(; iter!=upper_iter; ++iter )
                 [ #  # ]
    3757 [ #  # ][ #  # ]:          0 :       new_surfs.append( iter->second );
    3758                 :            : 
    3759         [ #  # ]:          0 :     rv = detach_curve( chcurv_ptr, new_surfs, vol_getting_new_surfs, curve_map, point_map );
    3760         [ #  # ]:          0 :     if (rv != CUBIT_SUCCESS)
    3761 [ #  # ][ #  # ]:          0 :       return rv;  
    3762                 :          0 :   }
    3763                 :            : 
    3764 [ #  # ][ #  # ]:          0 :   for( int i=chcurves.size(); i--; )
    3765                 :            :   {
    3766 [ #  # ][ #  # ]:          0 :     DLIList<ChollaPoint*> tmp_pts = chcurves.get_and_step()->get_points();
                 [ #  # ]
    3767         [ #  # ]:          0 :     all_points_in_surfs += tmp_pts;
    3768         [ #  # ]:          0 :   }
    3769                 :            : 
    3770         [ #  # ]:          0 :   rv = detach_curves( chcurves, vol_getting_new_surfs, curve_map, point_map );
    3771         [ #  # ]:          0 :   if( rv != CUBIT_SUCCESS )
    3772                 :          0 :     return rv;
    3773                 :            : 
    3774                 :            :   //add the points in the cholla     
    3775         [ #  # ]:          0 :   all_points_in_surfs.uniquify_unordered();
    3776 [ #  # ][ #  # ]:          0 :   for (int ipt = 0; ipt < all_points_in_surfs.size(); ipt++)
    3777                 :            :   {
    3778         [ #  # ]:          0 :     ChollaPoint *chpt_ptr = all_points_in_surfs.get_and_step();
    3779                 :            :     
    3780         [ #  # ]:          0 :     rv = detach_point( chpt_ptr, vol_getting_new_surfs, point_map, curve_map );
    3781         [ #  # ]:          0 :     if (rv != CUBIT_SUCCESS)
    3782                 :          0 :       return rv;
    3783                 :            :   }   
    3784                 :            :   
    3785         [ #  # ]:          0 :   return rv;
    3786                 :            : }
    3787                 :            : 
    3788                 :          0 : CubitStatus ChollaEngine::detach_curves( DLIList<ChollaCurve*> &curves,
    3789                 :            :                                          ChollaVolume *detaching_volume,                                         
    3790                 :            :                                          std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    3791                 :            :                                          std::map<ChollaPoint *, ChollaPoint *> &point_map )
    3792                 :            : {
    3793                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;
    3794                 :            : 
    3795         [ #  # ]:          0 :   DLIList<ChollaSurface*> tmp_surfs;
    3796 [ #  # ][ #  # ]:          0 :   DLIList<ChollaPoint*> points_to_detach;
    3797 [ #  # ][ #  # ]:          0 :   for( int i=curves.size(); i--; )
    3798                 :            :   {    
    3799         [ #  # ]:          0 :     ChollaCurve *tmp_curve = curves.get_and_step();    
    3800                 :            : 
    3801                 :            :     //get the surfaces in 'detaching_volume'
    3802         [ #  # ]:          0 :     tmp_surfs.clean_out();
    3803 [ #  # ][ #  # ]:          0 :     tmp_surfs = tmp_curve->get_surfaces();
    3804 [ #  # ][ #  # ]:          0 :     for( int k=0; k<tmp_surfs.size(); k++ )
    3805                 :            :     {
    3806 [ #  # ][ #  # ]:          0 :       if( !tmp_surfs[k]->is_in_volume( detaching_volume) )
                 [ #  # ]
    3807         [ #  # ]:          0 :         tmp_surfs[k] = NULL;      
    3808                 :            :     }
    3809         [ #  # ]:          0 :     tmp_surfs.remove_all_with_value(NULL);
    3810                 :            : 
    3811         [ #  # ]:          0 :     rv = detach_curve( tmp_curve, tmp_surfs, detaching_volume, curve_map, point_map );
    3812         [ #  # ]:          0 :     if (rv != CUBIT_SUCCESS)
    3813                 :          0 :       return rv;
    3814                 :            : 
    3815 [ #  # ][ #  # ]:          0 :     DLIList<ChollaPoint*> tmp_pts = tmp_curve->get_points();
    3816         [ #  # ]:          0 :     points_to_detach += tmp_pts;
    3817         [ #  # ]:          0 :   }
    3818                 :            : 
    3819                 :            :   //go through the map, setting up merge partners
    3820         [ #  # ]:          0 :   std::map<ChollaCurve*, ChollaCurve*>::iterator iter = curve_map.begin();
    3821 [ #  # ][ #  # ]:          0 :   for( ; iter != curve_map.end(); iter++ )
         [ #  # ][ #  # ]
    3822                 :            :   {
    3823         [ #  # ]:          0 :     ChollaCurve *ch_curv = iter->first;
    3824         [ #  # ]:          0 :     ChollaCurve *new_ch_curv = iter->second;
    3825                 :            : 
    3826         [ #  # ]:          0 :     ch_curv->set_merge_partner( new_ch_curv );
    3827         [ #  # ]:          0 :     new_ch_curv->set_merge_partner( ch_curv );
    3828                 :            :   }
    3829         [ #  # ]:          0 :   return rv;
    3830                 :            : }                                          
    3831                 :            : 
    3832                 :            : //=============================================================================
    3833                 :            : //Function: detach_curve 
    3834                 :            : //Description: given a non-manifold curve in a cholla model, create a copy
    3835                 :            : //             and update child entities. updates the curve_map
    3836                 :            : //Author:sjowen
    3837                 :            : //Date:  09/18/09
    3838                 :            : //=============================================================================
    3839                 :          0 : CubitStatus ChollaEngine::detach_curve(ChollaCurve *chcurv_ptr,
    3840                 :            :                                        DLIList<ChollaSurface*> &new_surfs,
    3841                 :            :                                        ChollaVolume *chvol2_ptr,
    3842                 :            :                                        std::map<ChollaCurve*, ChollaCurve*> &curve_map,
    3843                 :            :                                        std::map<ChollaPoint*, ChollaPoint*> &point_map )
    3844                 :            : {   
    3845                 :            :   // create a copy of the curve on the surface and add it to volume 2  
    3846                 :            : 
    3847 [ #  # ][ #  # ]:          0 :   ChollaCurve *newchcurv_ptr = new ChollaCurve( chcurv_ptr->get_block_id() );
                 [ #  # ]
    3848         [ #  # ]:          0 :   chollaCurveList.append( newchcurv_ptr );
    3849 [ #  # ][ #  # ]:          0 :   curve_map.insert(std::pair<ChollaCurve *, ChollaCurve *>(chcurv_ptr, newchcurv_ptr));
                 [ #  # ]
    3850                 :            :   
    3851 [ #  # ][ #  # ]:          0 :   for( int i=new_surfs.size(); i--; )
    3852                 :            :   {
    3853         [ #  # ]:          0 :     ChollaSurface *newchsurf_ptr = new_surfs.get_and_step();
    3854         [ #  # ]:          0 :     newchsurf_ptr->add_curve(newchcurv_ptr);
    3855         [ #  # ]:          0 :     newchcurv_ptr->add_surface(newchsurf_ptr);    
    3856                 :            :   }
    3857                 :            : 
    3858                 :            :   // any surfaces attached to this chcurv that are in vol2 are removed and the newchcurv is added
    3859 [ #  # ][ #  # ]:          0 :   DLIList<ChollaSurface *> chcsurf_list = chcurv_ptr->get_surfaces();
    3860 [ #  # ][ #  # ]:          0 :   for (int icsurf = 0; icsurf < chcsurf_list.size(); icsurf++)
    3861                 :            :   {
    3862         [ #  # ]:          0 :     ChollaSurface *chcsurf_ptr = chcsurf_list.get_and_step();
    3863                 :            : 
    3864                 :            :     //if the adjacent surfaces are in both volumes, don't do anything
    3865 [ #  # ][ #  # ]:          0 :     if(chcsurf_ptr->is_in_volume(chvol2_ptr) )      
    3866                 :            :     {
    3867         [ #  # ]:          0 :       chcurv_ptr->remove_surface(chcsurf_ptr);
    3868         [ #  # ]:          0 :       chcsurf_ptr->remove_curve(chcurv_ptr);
    3869         [ #  # ]:          0 :       newchcurv_ptr->add_surface(chcsurf_ptr);
    3870         [ #  # ]:          0 :       chcsurf_ptr->add_curve_unique(newchcurv_ptr);
    3871                 :            :     }  
    3872                 :            :   } 
    3873                 :            : 
    3874         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    3875                 :            : }
    3876                 :            : 
    3877                 :            : //=============================================================================
    3878                 :            : //Function: detach_point 
    3879                 :            : //Description: given a non-manifold point in a cholla model, create a copy
    3880                 :            : //             and update connectivity. updates the point_map
    3881                 :            : //Author:sjowen
    3882                 :            : //Date:  09/18/09
    3883                 :            : //=============================================================================
    3884                 :          0 : CubitStatus ChollaEngine::detach_point(ChollaPoint *chpt_ptr,
    3885                 :            :                                        ChollaVolume *chvol2_ptr,
    3886                 :            :                                        std::map<ChollaPoint *, ChollaPoint *> &point_map,
    3887                 :            :                                        std::map<ChollaCurve *, ChollaCurve *> &curve_map )                                       
    3888                 :            : { 
    3889                 :            :   
    3890                 :            :   
    3891 [ #  # ][ #  # ]:          0 :   ChollaPoint *newchpt_ptr = new ChollaPoint();
    3892         [ #  # ]:          0 :   chollaPointList.append( newchpt_ptr );
    3893 [ #  # ][ #  # ]:          0 :   point_map.insert(std::pair<ChollaPoint*, ChollaPoint*>(chpt_ptr, newchpt_ptr));  
                 [ #  # ]
    3894                 :            :      
    3895                 :            :   //find the curves that it is in
    3896 [ #  # ][ #  # ]:          0 :   DLIList<ChollaCurve *> chptcurv_list = chpt_ptr->get_curves();
    3897 [ #  # ][ #  # ]:          0 :   for (int iptcurv = 0; iptcurv < chptcurv_list.size(); iptcurv++)
    3898                 :            :   {
    3899         [ #  # ]:          0 :     ChollaCurve *chptcurv_ptr = chptcurv_list.get_and_step();
    3900                 :            : 
    3901                 :            :     // for curves that were copied (on the interface), add the new chollapoint to the new curve
    3902                 :            : 
    3903         [ #  # ]:          0 :     std::map<ChollaCurve *, ChollaCurve *>::iterator cmap_it;
    3904         [ #  # ]:          0 :     cmap_it = curve_map.find(chptcurv_ptr);
    3905 [ #  # ][ #  # ]:          0 :     if (cmap_it != curve_map.end())
                 [ #  # ]
    3906                 :            :     {
    3907         [ #  # ]:          0 :       ChollaCurve *new_chcurv_ptr = cmap_it->second;      
    3908         [ #  # ]:          0 :       new_chcurv_ptr->add_point(newchpt_ptr);
    3909         [ #  # ]:          0 :       newchpt_ptr->add_curve(new_chcurv_ptr);
    3910                 :            :       
    3911         [ #  # ]:          0 :       chpt_ptr->set_merge_partner( newchpt_ptr );
    3912         [ #  # ]:          0 :       newchpt_ptr->set_merge_partner( chpt_ptr );
    3913                 :            :     }
    3914                 :            :     else
    3915                 :            :     {
    3916                 :            :       // remove curve in vol 2 (not on interface) from the original point and add it to the new point
    3917                 :            :       
    3918 [ #  # ][ #  # ]:          0 :       if (chptcurv_ptr->is_in_volume(chvol2_ptr))
    3919                 :            :       {
    3920         [ #  # ]:          0 :         chpt_ptr->remove_curve(chptcurv_ptr);
    3921         [ #  # ]:          0 :         chptcurv_ptr->remove_point(chpt_ptr);
    3922         [ #  # ]:          0 :         newchpt_ptr->add_curve(chptcurv_ptr);
    3923         [ #  # ]:          0 :         chptcurv_ptr->add_point(newchpt_ptr);
    3924                 :            : 
    3925         [ #  # ]:          0 :         chpt_ptr->set_merge_partner( newchpt_ptr );
    3926         [ #  # ]:          0 :         newchpt_ptr->set_merge_partner( chpt_ptr );
    3927                 :            :       }
    3928                 :            :     }
    3929                 :            :   }
    3930                 :            : 
    3931         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    3932                 :            : }
    3933                 :            :   
    3934                 :            : 
    3935                 :            : //=============================================================================
    3936                 :            : //Function: detach_facets 
    3937                 :            : //Description: detach the individual facets to create a manifold representation
    3938                 :            : //Note: makes a copy of the facets on the merged surface and its child entities
    3939                 :            : //      and reconnects them locally
    3940                 :            : //Author:sjowen
    3941                 :            : //Date:  09/10/09
    3942                 :            : //=============================================================================
    3943                 :          0 : CubitStatus ChollaEngine::detach_facets(DLIList<ChollaSurface*> &chsurfs,
    3944                 :            :                                         DLIList<ChollaCurve*> &chcurves,
    3945                 :            :                                         ChollaVolume *chvol,
    3946                 :            :                                         std::map<ChollaSurface *, ChollaSurface *> &surf_map,
    3947                 :            :                                         std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    3948                 :            :                                         std::map<ChollaPoint *, ChollaPoint *> &point_map)
    3949                 :            : {  
    3950                 :            :   
    3951                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;
    3952                 :            :   
    3953         [ #  # ]:          0 :   std::vector<CubitPoint *> new_points;
    3954 [ #  # ][ #  # ]:          0 :   std::vector<CubitFacetEdge *> new_edges;
    3955                 :            :   
    3956                 :            :   rv = copy_facets_at_interface( chsurfs, chcurves, new_points, new_edges,
    3957         [ #  # ]:          0 :                                  surf_map, curve_map, point_map );
    3958         [ #  # ]:          0 :   if (rv != CUBIT_SUCCESS)
    3959                 :          0 :     return rv;
    3960                 :            :   
    3961         [ #  # ]:          0 :   rv = connect_facets_at_interface( chsurfs, chcurves, chvol, new_points, new_edges );
    3962         [ #  # ]:          0 :   if (rv != CUBIT_SUCCESS)
    3963                 :          0 :     return rv;
    3964                 :            :   
    3965         [ #  # ]:          0 :   return rv;
    3966                 :            : }
    3967                 :            :   
    3968                 :            : //=============================================================================
    3969                 :            : //Function: copy_facets_at_interface 
    3970                 :            : //Description: 
    3971                 :            : //Author:sjowen
    3972                 :            : //Date:  09/18/09
    3973                 :            : //=============================================================================
    3974                 :          0 : CubitStatus ChollaEngine::copy_facets_at_interface(DLIList<ChollaSurface*> &chsurfs,
    3975                 :            :                                                    DLIList<ChollaCurve*> &chcurves,
    3976                 :            :                                                    std::vector<CubitPoint *> &new_points,
    3977                 :            :                                                    std::vector<CubitFacetEdge *> &new_edges,                                                   
    3978                 :            :                                                    std::map<ChollaSurface *, ChollaSurface *> &surf_map,
    3979                 :            :                                                    std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    3980                 :            :                                                    std::map<ChollaPoint *, ChollaPoint *> &point_map)
    3981                 :            : 
    3982                 :            : {
    3983                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;
    3984                 :            :   
    3985                 :            :   // first set the marked flags on all facets entities on this surface to -1
    3986                 :            :   
    3987                 :            :   int ifacet;
    3988         [ #  # ]:          0 :   DLIList<FacetEntity *> facet_list;
    3989 [ #  # ][ #  # ]:          0 :   for( int i=chsurfs.size(); i--; )
    3990                 :            :   {
    3991         [ #  # ]:          0 :     ChollaSurface *chsurf_ptr = chsurfs.get_and_step();
    3992         [ #  # ]:          0 :     chsurf_ptr->get_facets( facet_list );
    3993                 :            :   }
    3994                 :            : 
    3995 [ #  # ][ #  # ]:          0 :   for( int i=chcurves.size(); i--; )
    3996                 :            :   {
    3997 [ #  # ][ #  # ]:          0 :     DLIList<FacetEntity*> tmp_facets = chcurves.get_and_step()->get_facet_list();
                 [ #  # ]
    3998         [ #  # ]:          0 :     facet_list += tmp_facets;
    3999         [ #  # ]:          0 :   }
    4000                 :            : 
    4001         [ #  # ]:          0 :   FacetDataUtil::mark_facets(facet_list, FACET_ENTITY_UNINITIALIZED);
    4002                 :            :   
    4003                 :            :   // create a copy of each of the facet entities on the surface.  The marked flag in the facet will
    4004                 :            :   // keep track of the new entity created.  It will be a location in the new_points or new_edges
    4005                 :            :   // array.  Once we are finished with creating points and edges, we can create the new facets
    4006                 :            :   // given the references in the marked flags.
    4007                 :            :   
    4008                 :            :   // create new points
    4009                 :            :   
    4010         [ #  # ]:          0 :   rv = copy_points_at_interface(facet_list, new_points, surf_map, curve_map, point_map);
    4011         [ #  # ]:          0 :   if (rv != CUBIT_SUCCESS)
    4012                 :          0 :     return rv;
    4013                 :            :   
    4014                 :            :   // create new edges
    4015                 :            :   
    4016         [ #  # ]:          0 :   rv = copy_edges_at_interface(facet_list, new_points, new_edges, surf_map, curve_map, point_map);
    4017         [ #  # ]:          0 :   if (rv != CUBIT_SUCCESS)
    4018                 :          0 :     return rv;
    4019                 :            :   
    4020                 :            :   // create new facets
    4021                 :            :   
    4022 [ #  # ][ #  # ]:          0 :   DLIList<CubitFacet *> new_facets;
    4023 [ #  # ][ #  # ]:          0 :   for (ifacet = 0; ifacet<facet_list.size(); ifacet++)
    4024                 :            :   {
    4025         [ #  # ]:          0 :     FacetEntity *facet_ptr = facet_list.get_and_step();
    4026         [ #  # ]:          0 :     CubitFacet *cfacet_ptr = dynamic_cast<CubitFacet *> (facet_ptr);
    4027         [ #  # ]:          0 :     if( cfacet_ptr )
    4028                 :            :     {
    4029                 :            :       CubitFacetEdge *fedge, *newfedges[3];
    4030                 :            :       CubitFacet *newcfacet_ptr;
    4031         [ #  # ]:          0 :       for (int ii=0; ii<3; ii++)
    4032                 :            :       {
    4033         [ #  # ]:          0 :         fedge = cfacet_ptr->edge(ii);
    4034         [ #  # ]:          0 :         int idx = fedge->marked();
    4035         [ #  # ]:          0 :         newfedges[ii] = new_edges[idx];
    4036                 :            :       }
    4037 [ #  # ][ #  # ]:          0 :       newcfacet_ptr = (CubitFacet *) new CubitFacetData(newfedges[0], newfedges[1], newfedges[2]);
    4038         [ #  # ]:          0 :       new_facets.append( newcfacet_ptr );
    4039                 :          0 :       FacetEntity *newfacet_ptr = dynamic_cast<FacetEntity *> (newcfacet_ptr);
    4040         [ #  # ]:          0 :       set_new_facet_owners( 2, facet_ptr, newfacet_ptr, surf_map, curve_map, point_map );
    4041                 :            :     } 
    4042                 :            :   }
    4043                 :            :   
    4044                 :            :   // make sure facets are oriented consistently on new volume
    4045 [ #  # ][ #  # ]:          0 :   if( new_facets.size() )
    4046                 :            :   {
    4047         [ #  # ]:          0 :     CubitFacet *start_facet = new_facets.get(); 
    4048                 :          0 :     CubitBoolean do_flip = CUBIT_TRUE;
    4049                 :            :     int nfacets;
    4050                 :          0 :     int mydebug = 0;
    4051         [ #  # ]:          0 :     rv = check_facet_orientation(start_facet, do_flip, nfacets, mydebug );
    4052                 :            :   }
    4053                 :            :   
    4054         [ #  # ]:          0 :   return rv;
    4055                 :            : }
    4056                 :            : 
    4057                 :            : 
    4058                 :          0 : CubitStatus ChollaEngine::detach_facet_edges(DLIList<ChollaCurve*> &chcurves,
    4059                 :            :                                              ChollaVolume *detaching_volume,                                             
    4060                 :            :                                              std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    4061                 :            :                                              std::map<ChollaPoint *, ChollaPoint *> &point_map )
    4062                 :            : {  
    4063                 :            :   
    4064                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;
    4065                 :            :   
    4066         [ #  # ]:          0 :   std::vector<CubitPoint *> new_points;
    4067 [ #  # ][ #  # ]:          0 :   std::vector<CubitFacetEdge *> new_edges;
    4068                 :            :   
    4069         [ #  # ]:          0 :   rv = copy_facet_edges_at_interface( chcurves, new_points, new_edges, curve_map, point_map );
    4070         [ #  # ]:          0 :   if (rv != CUBIT_SUCCESS)
    4071                 :          0 :     return rv;
    4072                 :            : 
    4073 [ #  # ][ #  # ]:          0 :   for (int i=chcurves.size(); i--; )
    4074                 :            :   {
    4075         [ #  # ]:          0 :     ChollaCurve *chcurv_ptr = chcurves.get_and_step();    
    4076         [ #  # ]:          0 :     rv = connect_points_at_interface( chcurv_ptr, detaching_volume, new_points );
    4077         [ #  # ]:          0 :     if (rv != CUBIT_SUCCESS)
    4078                 :          0 :       return rv;
    4079                 :            :     
    4080         [ #  # ]:          0 :     rv = connect_edges_at_interface( chcurv_ptr, detaching_volume, new_edges );
    4081         [ #  # ]:          0 :     if (rv != CUBIT_SUCCESS)
    4082                 :          0 :       return rv;
    4083                 :            :   }   
    4084                 :            :   
    4085         [ #  # ]:          0 :   return rv;
    4086                 :            : }
    4087                 :            : 
    4088                 :            : 
    4089                 :          0 : CubitStatus ChollaEngine::copy_facet_edges_at_interface(DLIList<ChollaCurve*> &chcurves,
    4090                 :            :                                                    std::vector<CubitPoint *> &new_points,
    4091                 :            :                                                    std::vector<CubitFacetEdge *> &new_edges,                                                                                                      
    4092                 :            :                                                    std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    4093                 :            :                                                    std::map<ChollaPoint *, ChollaPoint *> &point_map)
    4094                 :            : 
    4095                 :            : {
    4096                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;
    4097                 :            :   
    4098                 :            :   // first set the marked flags on all facets entities to -1  
    4099         [ #  # ]:          0 :   DLIList<FacetEntity *> facet_list;
    4100 [ #  # ][ #  # ]:          0 :   for( int i=chcurves.size(); i--; )
    4101                 :            :   {
    4102         [ #  # ]:          0 :     ChollaCurve *chcurv_ptr = chcurves.get_and_step();
    4103 [ #  # ][ #  # ]:          0 :     DLIList<FacetEntity*> tmp_facet_list = chcurv_ptr->get_facet_list();
    4104         [ #  # ]:          0 :     facet_list += tmp_facet_list;
    4105         [ #  # ]:          0 :   }
    4106                 :            : 
    4107         [ #  # ]:          0 :   FacetDataUtil::mark_facets(facet_list, FACET_ENTITY_UNINITIALIZED);
    4108                 :            :   
    4109                 :            :   // create a copy of each of the facet entities on the surface.  The marked flag in the facet will
    4110                 :            :   // keep track of the new entity created.  It will be a location in the new_points or new_edges
    4111                 :            :   // array.  Once we are finished with creating points and edges, we can create the new facets
    4112                 :            :   // given the references in the marked flags.
    4113                 :            :   
    4114                 :            :   // create new points
    4115                 :            : 
    4116 [ #  # ][ #  # ]:          0 :   std::map<ChollaSurface *, ChollaSurface *> dummy_surf_map;
    4117                 :            :   
    4118         [ #  # ]:          0 :   rv = copy_points_at_interface(facet_list, new_points, dummy_surf_map, curve_map, point_map);
    4119         [ #  # ]:          0 :   if (rv != CUBIT_SUCCESS)
    4120                 :          0 :     return rv;
    4121                 :            :   
    4122                 :            :   // create new edges
    4123                 :            :   
    4124         [ #  # ]:          0 :   rv = copy_edges_at_interface(facet_list, new_points, new_edges, dummy_surf_map, curve_map, point_map);
    4125         [ #  # ]:          0 :   if (rv != CUBIT_SUCCESS)
    4126                 :          0 :     return rv;  
    4127                 :            :   
    4128         [ #  # ]:          0 :   return rv;
    4129                 :            : }
    4130                 :            : 
    4131                 :            : //=============================================================================
    4132                 :            : //Function: copy_points_at_interface 
    4133                 :            : //Description: copy the points at the interface        
    4134                 :            : //Author:sjowen
    4135                 :            : //Date:  09/18/09
    4136                 :            : //=============================================================================
    4137                 :          0 : CubitStatus ChollaEngine::copy_points_at_interface(DLIList<FacetEntity *> &facet_list,
    4138                 :            :                                                    std::vector<CubitPoint *> &new_points,                                                   
    4139                 :            :                                                    std::map<ChollaSurface *, ChollaSurface *> &surf_map,
    4140                 :            :                                                    std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    4141                 :            :                                                    std::map<ChollaPoint *, ChollaPoint *> &point_map)
    4142                 :            : {
    4143                 :          0 :   int iploc = 0;
    4144                 :            :   
    4145                 :            :   FacetEntity *fe_ptr, *newfe_ptr;
    4146                 :            :   CubitPoint *point_ptr, *newpoint_ptr;
    4147                 :            : 
    4148 [ #  # ][ #  # ]:          0 :   for (int ifacet = 0; ifacet<facet_list.size(); ifacet++)
    4149                 :            :   {
    4150         [ #  # ]:          0 :     FacetEntity *facet_ptr = facet_list.get_and_step();
    4151         [ #  # ]:          0 :     CubitFacet *cfacet_ptr = dynamic_cast<CubitFacet*>(facet_ptr);
    4152         [ #  # ]:          0 :     if( cfacet_ptr )
    4153                 :            :     {     
    4154         [ #  # ]:          0 :       for (int ii=0; ii<3; ii++)
    4155                 :            :       {
    4156         [ #  # ]:          0 :         point_ptr = cfacet_ptr->point(ii);        
    4157 [ #  # ][ #  # ]:          0 :         if (point_ptr->marked() == FACET_ENTITY_UNINITIALIZED)
    4158                 :            :         {
    4159 [ #  # ][ #  # ]:          0 :           newpoint_ptr = (CubitPoint *) new CubitPointData( point_ptr->x(), point_ptr->y(), point_ptr->z() );
         [ #  # ][ #  # ]
                 [ #  # ]
    4160         [ #  # ]:          0 :           new_points.push_back(newpoint_ptr);
    4161         [ #  # ]:          0 :           point_ptr->marked(iploc++);
    4162                 :          0 :           fe_ptr = dynamic_cast<FacetEntity *> (point_ptr);
    4163                 :          0 :           newfe_ptr = dynamic_cast<FacetEntity *> (newpoint_ptr);
    4164         [ #  # ]:          0 :           set_new_facet_owners(0, fe_ptr, newfe_ptr, surf_map, curve_map, point_map );
    4165                 :            :         }   
    4166                 :            :       } 
    4167                 :            :     } 
    4168                 :            :     else
    4169                 :            :     {
    4170         [ #  # ]:          0 :       CubitFacetEdge *cfacet_edge_ptr = dynamic_cast<CubitFacetEdge*>(facet_ptr);      
    4171         [ #  # ]:          0 :       for (int ii=0; ii<2; ii++)
    4172                 :            :       {
    4173         [ #  # ]:          0 :         point_ptr = cfacet_edge_ptr->point(ii);
    4174 [ #  # ][ #  # ]:          0 :         if (point_ptr->marked() == FACET_ENTITY_UNINITIALIZED)
    4175                 :            :         {
    4176 [ #  # ][ #  # ]:          0 :           newpoint_ptr = (CubitPoint *) new CubitPointData( point_ptr->x(), point_ptr->y(), point_ptr->z() );
         [ #  # ][ #  # ]
                 [ #  # ]
    4177         [ #  # ]:          0 :           new_points.push_back(newpoint_ptr);
    4178         [ #  # ]:          0 :           point_ptr->marked(iploc++);
    4179                 :          0 :           fe_ptr = dynamic_cast<FacetEntity *> (point_ptr);
    4180                 :          0 :           newfe_ptr = dynamic_cast<FacetEntity *> (newpoint_ptr);
    4181         [ #  # ]:          0 :           set_new_facet_owners(0, fe_ptr, newfe_ptr, surf_map, curve_map, point_map );
    4182                 :            :         }   
    4183                 :            :       } 
    4184                 :            :     }
    4185                 :            :   }
    4186                 :            :   
    4187                 :          0 :   return CUBIT_SUCCESS;
    4188                 :            : }
    4189                 :            : 
    4190                 :            : //=============================================================================
    4191                 :            : //Function: copy_edges_at_interface 
    4192                 :            : //Description: copy the edges at the interface        
    4193                 :            : //Author:sjowen
    4194                 :            : //Date:  09/18/09
    4195                 :            : //=============================================================================
    4196                 :          0 : CubitStatus ChollaEngine::copy_edges_at_interface(DLIList<FacetEntity *> &facet_list,
    4197                 :            :                                                   std::vector<CubitPoint *> &new_points,
    4198                 :            :                                                   std::vector<CubitFacetEdge *> &new_edges,                                                  
    4199                 :            :                                                   std::map<ChollaSurface *, ChollaSurface *> &surf_map,
    4200                 :            :                                                   std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    4201                 :            :                                                   std::map<ChollaPoint *, ChollaPoint *> &point_map)
    4202                 :            : {
    4203                 :          0 :   int ieloc = 0;
    4204                 :            :   CubitFacetEdge *edge_ptr, *newedge_ptr;
    4205 [ #  # ][ #  # ]:          0 :   for (int ifacet = 0; ifacet<facet_list.size(); ifacet++)
    4206                 :            :   {
    4207         [ #  # ]:          0 :     FacetEntity *facet_ptr = facet_list.get_and_step();
    4208         [ #  # ]:          0 :     CubitFacet *cfacet_ptr = dynamic_cast<CubitFacet *> (facet_ptr);
    4209         [ #  # ]:          0 :     if( cfacet_ptr )
    4210                 :            :     {      
    4211         [ #  # ]:          0 :       for (int ii=0; ii<3; ii++)
    4212                 :            :       {
    4213         [ #  # ]:          0 :         edge_ptr = cfacet_ptr->edge(ii);
    4214 [ #  # ][ #  # ]:          0 :         if (edge_ptr->marked() == FACET_ENTITY_UNINITIALIZED)
    4215                 :            :         {
    4216         [ #  # ]:          0 :           CubitPoint *p0 = edge_ptr->point( 0 );
    4217         [ #  # ]:          0 :           CubitPoint *p1 = edge_ptr->point( 1 );
    4218         [ #  # ]:          0 :           int idx0 = p0->marked();
    4219         [ #  # ]:          0 :           int idx1 = p1->marked();
    4220         [ #  # ]:          0 :           CubitPoint *newp0 = new_points[idx0];
    4221         [ #  # ]:          0 :           CubitPoint *newp1 = new_points[idx1];
    4222 [ #  # ][ #  # ]:          0 :           newedge_ptr = (CubitFacetEdge *) new CubitFacetEdgeData( newp0, newp1 );
    4223         [ #  # ]:          0 :           new_edges.push_back(newedge_ptr);
    4224         [ #  # ]:          0 :           edge_ptr->marked(ieloc++);
    4225                 :          0 :           FacetEntity *fe_ptr = dynamic_cast<FacetEntity *> (edge_ptr);
    4226                 :          0 :           FacetEntity *newfe_ptr = dynamic_cast<FacetEntity *> (newedge_ptr);
    4227         [ #  # ]:          0 :           set_new_facet_owners( 1, fe_ptr, newfe_ptr, surf_map, curve_map, point_map );
    4228                 :            :         }  
    4229                 :            :       } 
    4230                 :            :     }
    4231                 :            :     else
    4232                 :            :     {
    4233         [ #  # ]:          0 :       CubitFacetEdge *edge_ptr = dynamic_cast<CubitFacetEdge*>(facet_ptr);
    4234 [ #  # ][ #  # ]:          0 :       if (edge_ptr->marked() == FACET_ENTITY_UNINITIALIZED)
    4235                 :            :       {
    4236         [ #  # ]:          0 :         CubitPoint *p0 = edge_ptr->point( 0 );
    4237         [ #  # ]:          0 :         CubitPoint *p1 = edge_ptr->point( 1 );
    4238         [ #  # ]:          0 :         int idx0 = p0->marked();
    4239         [ #  # ]:          0 :         int idx1 = p1->marked();
    4240         [ #  # ]:          0 :         CubitPoint *newp0 = new_points[idx0];
    4241         [ #  # ]:          0 :         CubitPoint *newp1 = new_points[idx1];
    4242 [ #  # ][ #  # ]:          0 :         newedge_ptr = (CubitFacetEdge *) new CubitFacetEdgeData( newp0, newp1 );
    4243         [ #  # ]:          0 :         new_edges.push_back(newedge_ptr);
    4244         [ #  # ]:          0 :         edge_ptr->marked(ieloc++);
    4245                 :          0 :         FacetEntity *fe_ptr = dynamic_cast<FacetEntity *> (edge_ptr);
    4246                 :          0 :         FacetEntity *newfe_ptr = dynamic_cast<FacetEntity *> (newedge_ptr);
    4247         [ #  # ]:          0 :         set_new_facet_owners( 1, fe_ptr, newfe_ptr, surf_map, curve_map, point_map );
    4248                 :            :       }
    4249                 :            :     }
    4250                 :            :   }
    4251                 :          0 :   return CUBIT_SUCCESS;
    4252                 :            : }
    4253                 :            : 
    4254                 :            : //=============================================================================
    4255                 :            : //Function: connect_facets_at_interface 
    4256                 :            : //Description: detach the facets from original points and edges and reattach to new copy         
    4257                 :            : //Author:sjowen
    4258                 :            : //Date:  09/18/09
    4259                 :            : //=============================================================================
    4260                 :          0 : CubitStatus ChollaEngine::connect_facets_at_interface(DLIList<ChollaSurface*> &chsurfs,
    4261                 :            :                                                       DLIList<ChollaCurve*> &chcurves,
    4262                 :            :                                                       ChollaVolume *chvol_ptr,
    4263                 :            :                                                       std::vector<CubitPoint *> &new_points,
    4264                 :            :                                                       std::vector<CubitFacetEdge *> &new_edges)
    4265                 :            : {
    4266                 :          0 :   CubitStatus rv = CUBIT_SUCCESS;  
    4267         [ #  # ]:          0 :   DLIList<ChollaCurve *> chcurv_list;
    4268                 :            :   
    4269 [ #  # ][ #  # ]:          0 :   for( int i=chsurfs.size(); i--; )
    4270                 :            :   {
    4271         [ #  # ]:          0 :     ChollaSurface *tmp_surf = chsurfs.get_and_step();    
    4272         [ #  # ]:          0 :     DLIList<ChollaCurve*> tmp_curves;
    4273         [ #  # ]:          0 :     tmp_surf->get_curves( tmp_curves );
    4274         [ #  # ]:          0 :     chcurv_list += tmp_curves;
    4275         [ #  # ]:          0 :   }
    4276                 :            : 
    4277         [ #  # ]:          0 :   chcurv_list += chcurves;
    4278         [ #  # ]:          0 :   chcurv_list.uniquify_unordered();
    4279                 :            : 
    4280 [ #  # ][ #  # ]:          0 :   for (int icrv = 0; icrv < chcurv_list.size(); icrv++)
    4281                 :            :   {
    4282         [ #  # ]:          0 :     ChollaCurve *chcurv_ptr = chcurv_list.get_and_step();    
    4283         [ #  # ]:          0 :     rv = connect_points_at_interface( chcurv_ptr, chvol_ptr, new_points );
    4284         [ #  # ]:          0 :     if (rv != CUBIT_SUCCESS)
    4285                 :          0 :       return rv;
    4286                 :            :     
    4287         [ #  # ]:          0 :     rv = connect_edges_at_interface( chcurv_ptr, chvol_ptr, new_edges );
    4288         [ #  # ]:          0 :     if (rv != CUBIT_SUCCESS)
    4289                 :          0 :       return rv;
    4290                 :            :   } 
    4291                 :            : 
    4292         [ #  # ]:          0 :   return rv;
    4293                 :            : }
    4294                 :            : 
    4295                 :            : //=============================================================================
    4296                 :            : //Function: connect_points_at_interface 
    4297                 :            : //Description: find adjacent CubitFacetEdges on volume 2 that needs updating 
    4298                 :            : //Notes: chcurv_ptr is a curve at the interface on the original volume
    4299                 :            : //       chvol_ptr is the second volume (new (copied) entities belong to vol 2)
    4300                 :            : //       This functions gets all edges attached to the original CubitPoints on the 
    4301                 :            : //       original curve 'chcurv_ptr'.  If any edge is on volume 2 (the volume we are 
    4302                 :            : //       splitting off) we need to update the edges on that volume to contain the
    4303                 :            : //       the new CubitPoint.
    4304                 :            : //Author:sjowen
    4305                 :            : //Date:  09/18/09
    4306                 :            : //=============================================================================
    4307                 :          0 : CubitStatus ChollaEngine::connect_points_at_interface(ChollaCurve *chcurv_ptr,
    4308                 :            :                                                       ChollaVolume *chvol_ptr,
    4309                 :            :                                                       std::vector<CubitPoint *> &new_points)
    4310                 :            : {
    4311         [ #  # ]:          0 :   DLIList<CubitPoint *> cp_list;
    4312         [ #  # ]:          0 :   chcurv_ptr->get_facet_points(cp_list, CUBIT_TRUE);
    4313 [ #  # ][ #  # ]:          0 :   for (int ip = 0; ip<cp_list.size(); ip++)
    4314                 :            :   {
    4315         [ #  # ]:          0 :     CubitPoint *cp_ptr = cp_list.get_and_step();
    4316 [ #  # ][ #  # ]:          0 :     CubitPoint *newcp_ptr = new_points[cp_ptr->marked()];
    4317                 :            :     
    4318                 :            :     // set the point into edges that are on volume 2.
    4319                 :            :     // Note that there is no direct reference from points to edges in our data structure 
    4320                 :            :     // so no need to add/remove the edge from the point
    4321                 :            :     
    4322         [ #  # ]:          0 :     DLIList<CubitFacetEdge *> pedge_list;
    4323         [ #  # ]:          0 :     cp_ptr->edges(pedge_list);
    4324 [ #  # ][ #  # ]:          0 :     for (int iedge=0; iedge<pedge_list.size(); iedge++)
    4325                 :            :     {
    4326         [ #  # ]:          0 :       CubitFacetEdge *edge_ptr = pedge_list.get_and_step();
    4327         [ #  # ]:          0 :       TDGeomFacet *td_geom = TDGeomFacet::get_geom_facet( edge_ptr );
    4328 [ #  # ][ #  # ]:          0 :       if (td_geom->is_in_volume( chvol_ptr ))
    4329                 :            :       {
    4330         [ #  # ]:          0 :         CubitPoint *p0 = edge_ptr->point(0);
    4331         [ #  # ]:          0 :         CubitPoint *p1 = edge_ptr->point(1);
    4332         [ #  # ]:          0 :         CubitFacetEdgeData *cfed_ptr = dynamic_cast<CubitFacetEdgeData *> (edge_ptr);
    4333         [ #  # ]:          0 :         if (p0 == cp_ptr)
    4334         [ #  # ]:          0 :           cfed_ptr->set_point( newcp_ptr, 0 );
    4335         [ #  # ]:          0 :         else if (p1 == cp_ptr)
    4336         [ #  # ]:          0 :           cfed_ptr->set_point( newcp_ptr, 1 );
    4337                 :            :       }
    4338                 :            :     }    
    4339                 :            :     
    4340                 :            :     // remove facets in volume 2 from the point and add the to the new point
    4341                 :            :     // update the point reference on the facet
    4342                 :            :     
    4343 [ #  # ][ #  # ]:          0 :     DLIList<CubitFacet *> pfacet_list;
    4344         [ #  # ]:          0 :     cp_ptr->facets(pfacet_list);
    4345 [ #  # ][ #  # ]:          0 :     for (int ifacet = 0; ifacet < pfacet_list.size(); ifacet++)
    4346                 :            :     {
    4347         [ #  # ]:          0 :       CubitFacet *facet_ptr = pfacet_list.get_and_step();
    4348         [ #  # ]:          0 :       TDGeomFacet *td_geom = TDGeomFacet::get_geom_facet( facet_ptr );
    4349 [ #  # ][ #  # ]:          0 :       if (td_geom->is_in_volume( chvol_ptr ))
    4350                 :            :       {
    4351         [ #  # ]:          0 :         cp_ptr->remove_facet( facet_ptr );        
    4352         [ #  # ]:          0 :         newcp_ptr->add_facet( facet_ptr );
    4353         [ #  # ]:          0 :         int ptidx = facet_ptr->point_index(cp_ptr);
    4354         [ #  # ]:          0 :         CubitFacetData *cfd_ptr = dynamic_cast<CubitFacetData *> (facet_ptr);
    4355         [ #  # ]:          0 :         cfd_ptr->set_point(newcp_ptr, ptidx);
    4356                 :            :       }
    4357                 :            :     }
    4358         [ #  # ]:          0 :   }
    4359         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    4360                 :            : }
    4361                 :            : 
    4362                 :            : //=============================================================================
    4363                 :            : //Function: connect_edges_at_interface 
    4364                 :            : //Description: detach the facet edges from original facets and reattach to new copy         
    4365                 :            : //Notes:    chcurv_ptr is a curve at the interface on the original volume
    4366                 :            : //       chvol_ptr is the second volume (new (copied) entities belong to vol 2)
    4367                 :            : //       This functions gets all CubitFacets attached to any CubitFacetEdges on the  
    4368                 :            : //       original curve 'chcurv_ptr'.  If any facet is on volume 2 (the volume we are 
    4369                 :            : //       splitting off) we need to update the edges on that facet on the new volume
    4370                 :            : //       to contain the new CubitFacetEdge.
    4371                 :            : //Author:sjowen
    4372                 :            : //Date:  09/18/09
    4373                 :            : //=============================================================================
    4374                 :          0 : CubitStatus ChollaEngine::connect_edges_at_interface(ChollaCurve *chcurv_ptr,
    4375                 :            :                                                      ChollaVolume *chvol_ptr,
    4376                 :            :                                                      std::vector<CubitFacetEdge *> &new_edges)
    4377                 :            : {
    4378 [ #  # ][ #  # ]:          0 :   DLIList<FacetEntity *> fe_list = chcurv_ptr->get_facet_list();
    4379 [ #  # ][ #  # ]:          0 :   for (int ie=0; ie<fe_list.size(); ie++)
    4380                 :            :   {
    4381         [ #  # ]:          0 :     FacetEntity *fe_ptr = fe_list.get_and_step();
    4382         [ #  # ]:          0 :     CubitFacetEdge *edge_ptr = dynamic_cast<CubitFacetEdge *> (fe_ptr);
    4383         [ #  # ]:          0 :     assert(edge_ptr != NULL);
    4384         [ #  # ]:          0 :     DLIList<CubitFacet *> efacet_list;
    4385         [ #  # ]:          0 :     edge_ptr->facets(efacet_list);
    4386 [ #  # ][ #  # ]:          0 :     for (int ifacet=0; ifacet<efacet_list.size(); ifacet++)
    4387                 :            :     {
    4388         [ #  # ]:          0 :       CubitFacet *facet_ptr = efacet_list.get_and_step();
    4389         [ #  # ]:          0 :       TDGeomFacet *td_geom = TDGeomFacet::get_geom_facet( facet_ptr );
    4390 [ #  # ][ #  # ]:          0 :       if (td_geom->is_in_volume( chvol_ptr ))
    4391                 :            :       {
    4392         [ #  # ]:          0 :         edge_ptr->remove_facet( facet_ptr );
    4393 [ #  # ][ #  # ]:          0 :         CubitFacetEdge *newedge_ptr = new_edges[edge_ptr->marked()];
    4394         [ #  # ]:          0 :         newedge_ptr->add_facet( facet_ptr );
    4395         [ #  # ]:          0 :         int edidx = facet_ptr->edge_index(edge_ptr);
    4396         [ #  # ]:          0 :         CubitFacetData *cfd_ptr = dynamic_cast<CubitFacetData *> (facet_ptr);
    4397         [ #  # ]:          0 :         cfd_ptr->edge(newedge_ptr, edidx);
    4398                 :            :       }
    4399                 :            :     }
    4400         [ #  # ]:          0 :   }
    4401         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    4402                 :            : }
    4403                 :            : 
    4404                 :            : //=============================================================================
    4405                 :            : //Function: set_new_facet_owners 
    4406                 :            : //Description: update the ownenrship of the new detached facet entity based upon
    4407                 :            : //             the map set up in detach_volumes
    4408                 :            : //            
    4409                 :            : //Author:sjowen
    4410                 :            : //Date:  09/14/09
    4411                 :            : //=============================================================================
    4412                 :          0 : CubitStatus ChollaEngine::set_new_facet_owners(int type, //0, 1, or 2 based on dimension of facet entity
    4413                 :            :                                                FacetEntity *fe_ptr, FacetEntity *newfe_ptr,                                                
    4414                 :            :                                                std::map<ChollaSurface *, ChollaSurface *> &surf_map,
    4415                 :            :                                                std::map<ChollaCurve *, ChollaCurve *> &curve_map,
    4416                 :            :                                                std::map<ChollaPoint *, ChollaPoint *> &point_map )
    4417                 :            : {
    4418                 :            :   
    4419                 :            :   // The tooldata on the original facet entity should tell us what cholla entity it belongs
    4420                 :            :   // to.  Using the map, we can then determine its new cholla entity partner.  With the
    4421                 :            :   // new merge partner, set the ownership of the new facet.  Note that this manages one-to-many
    4422                 :            :   // ownership cases where a facet lies on (or is owned by) any number of geometric entities
    4423                 :            :   
    4424         [ #  # ]:          0 :   TDGeomFacet *td_geom = TDGeomFacet::get_geom_facet( fe_ptr );
    4425 [ #  # ][ #  # ]:          0 :   TDGeomFacet::add_geom_facet(newfe_ptr, td_geom->get_block_id());
    4426                 :            :   
    4427                 :            :   // the original facet entity is owned by one or more surfaces
    4428                 :            :   
    4429         [ #  # ]:          0 :   DLIList<ChollaSurface *> surf_list;
    4430         [ #  # ]:          0 :   td_geom->get_cholla_surfs( surf_list );  
    4431 [ #  # ][ #  # ]:          0 :   for (int jj=0; jj<surf_list.size(); jj++)
    4432                 :            :   {
    4433         [ #  # ]:          0 :     ChollaSurface *surf_ptr = surf_list.get_and_step();
    4434         [ #  # ]:          0 :     std::map<ChollaSurface *, ChollaSurface *>::iterator map_it;
    4435         [ #  # ]:          0 :     map_it = surf_map.find( surf_ptr );
    4436 [ #  # ][ #  # ]:          0 :     assert(map_it != surf_map.end());
                 [ #  # ]
    4437         [ #  # ]:          0 :     ChollaSurface *newsurf_ptr = map_it->second;    
    4438         [ #  # ]:          0 :     TDGeomFacet *newtdgeom = TDGeomFacet::get_geom_facet( newfe_ptr );
    4439         [ #  # ]:          0 :     newtdgeom->add_cholla_surf( newsurf_ptr );
    4440                 :            :     
    4441                 :            :     // add this facet entity to the cholla surface only if this is a facet
    4442                 :            :     
    4443         [ #  # ]:          0 :     if (type == 2)
    4444         [ #  # ]:          0 :       newsurf_ptr->add_facet(newfe_ptr);
    4445                 :            :   }
    4446                 :            : 
    4447                 :            :   
    4448                 :            :   // the original facet entity is owned by one or more curves
    4449                 :            :   
    4450 [ #  # ][ #  # ]:          0 :   DLIList<ChollaCurve *> curv_list;
    4451         [ #  # ]:          0 :   td_geom->get_cholla_curves( curv_list );
    4452 [ #  # ][ #  # ]:          0 :   for (int jj=0; jj<curv_list.size(); jj++)
    4453                 :            :   {
    4454         [ #  # ]:          0 :     ChollaCurve *curv_ptr = curv_list.get_and_step();
    4455 [ #  # ][ #  # ]:          0 :     std::map<ChollaCurve *, ChollaCurve *>::iterator map_it, upper_iter;
    4456         [ #  # ]:          0 :     map_it = curve_map.find( curv_ptr );
    4457 [ #  # ][ #  # ]:          0 :     assert(map_it != curve_map.end());       
                 [ #  # ]
    4458                 :          0 :     ChollaCurve *newcurv_ptr = NULL;
    4459         [ #  # ]:          0 :     newcurv_ptr = map_it->second;
    4460                 :            :     
    4461         [ #  # ]:          0 :     TDGeomFacet *newtdgeom = TDGeomFacet::get_geom_facet( newfe_ptr );
    4462         [ #  # ]:          0 :     newtdgeom->add_cholla_curve( newcurv_ptr );
    4463                 :            :     
    4464                 :            :     // add this facet entity to the cholla curve only if this is a facetedge
    4465                 :            :     
    4466         [ #  # ]:          0 :     if (type == 1)
    4467         [ #  # ]:          0 :       newcurv_ptr->add_facet(newfe_ptr);      
    4468                 :            :   }
    4469                 :            :   
    4470                 :            :   // the original facet entity is owned by one or more points (vertices)
    4471                 :            :   
    4472 [ #  # ][ #  # ]:          0 :   DLIList<ChollaPoint *> point_list;
    4473         [ #  # ]:          0 :   td_geom->get_cholla_points( point_list );
    4474 [ #  # ][ #  # ]:          0 :   for (int jj=0; jj<point_list.size(); jj++)
    4475                 :            :   {
    4476         [ #  # ]:          0 :     ChollaPoint *point_ptr = point_list.get_and_step();
    4477 [ #  # ][ #  # ]:          0 :     std::map<ChollaPoint *, ChollaPoint *>::iterator map_it, upper_iter;
    4478         [ #  # ]:          0 :     map_it = point_map.find( point_ptr );
    4479 [ #  # ][ #  # ]:          0 :     assert(map_it != point_map.end());
                 [ #  # ]
    4480                 :          0 :     ChollaPoint *newchpoint_ptr = NULL;
    4481         [ #  # ]:          0 :     newchpoint_ptr = map_it->second;
    4482                 :            :   
    4483         [ #  # ]:          0 :     TDGeomFacet *newtdgeom = TDGeomFacet::get_geom_facet( newfe_ptr );
    4484         [ #  # ]:          0 :     newtdgeom->add_cholla_point( newchpoint_ptr );
    4485                 :            :     
    4486                 :            :     // add this facet entity to the cholla point only if this is a cubitpoint
    4487                 :            :     
    4488         [ #  # ]:          0 :     if (type == 0)
    4489         [ #  # ]:          0 :       newchpoint_ptr->add_facet(newfe_ptr);
    4490                 :            :   }
    4491         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    4492                 :            : 
    4493                 :            : }
    4494                 :            : 
    4495                 :            : //=============================================================================
    4496                 :            : //Function: verify_points_to_curves 
    4497                 :            : //Description: verify the connectivity between points and curves           
    4498                 :            : //Author:sjowen
    4499                 :            : //Date:  09/16/09
    4500                 :            : //=============================================================================
    4501                 :          0 : CubitStatus ChollaEngine::verify_points_to_curves()
    4502                 :            : {
    4503         [ #  # ]:          0 :   for (int ii=0; ii<chollaPointList.size(); ii++)
    4504                 :            :   {
    4505                 :          0 :     ChollaPoint *chpt = chollaPointList.get_and_step();
    4506         [ #  # ]:          0 :     if (!chpt->verify_curves())
    4507                 :            :     {
    4508 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("ChollaPoint %d not associated with one of its curves.\n", chpt->get_id());
    4509                 :          0 :       return CUBIT_FAILURE;
    4510                 :            :     }
    4511                 :            :   }
    4512         [ #  # ]:          0 :   for (int ii=0; ii<chollaCurveList.size(); ii++)
    4513                 :            :   {
    4514                 :          0 :     ChollaCurve *chcrv = chollaCurveList.get_and_step();
    4515         [ #  # ]:          0 :     if (!chcrv->verify_points())
    4516                 :            :     {
    4517 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("ChollaCurve %d not associated with one of its points.\n", chcrv->get_id());
    4518                 :          0 :       return CUBIT_FAILURE;
    4519                 :            :     }
    4520                 :            :   }
    4521                 :          0 :   return CUBIT_SUCCESS;
    4522                 :            : }
    4523                 :            : 
    4524                 :          0 : CubitStatus ChollaEngine::set_curve_endpoints(std::map<ChollaPoint *, ChollaPoint *> &point_map,
    4525                 :            :                                               std::map<ChollaCurve *, ChollaCurve *> &curve_map )
    4526                 :            :                                               
    4527                 :            : {   
    4528         [ #  # ]:          0 :   DLIList<ChollaPoint*> original_chpts;
    4529 [ #  # ][ #  # ]:          0 :   DLIList<ChollaPoint*> new_chpts;
    4530 [ #  # ][ #  # ]:          0 :   DLIList<ChollaCurve*> original_chcurves;
    4531 [ #  # ][ #  # ]:          0 :   DLIList<ChollaCurve*> new_chcurves;  
    4532                 :            : 
    4533         [ #  # ]:          0 :   std::map<ChollaCurve*, ChollaCurve*>::iterator curv_iter = curve_map.begin();
    4534 [ #  # ][ #  # ]:          0 :   for(; curv_iter!=curve_map.end(); curv_iter++ )
         [ #  # ][ #  # ]
    4535                 :            :   {
    4536         [ #  # ]:          0 :     ChollaCurve *orig_curve = curv_iter->first;
    4537         [ #  # ]:          0 :     ChollaCurve *new_curve = curv_iter->second;
    4538                 :            : 
    4539                 :            :     //curves
    4540         [ #  # ]:          0 :     original_chcurves.append( orig_curve );
    4541         [ #  # ]:          0 :     new_chcurves.append( new_curve );
    4542                 :            :     
    4543                 :            :     //points
    4544 [ #  # ][ #  # ]:          0 :     DLIList<ChollaPoint*> tmp_pts = orig_curve->get_points();
    4545         [ #  # ]:          0 :     original_chpts += tmp_pts;
    4546                 :            : 
    4547         [ #  # ]:          0 :     tmp_pts.clean_out();
    4548 [ #  # ][ #  # ]:          0 :     tmp_pts = new_curve->get_points();
    4549         [ #  # ]:          0 :     new_chpts += tmp_pts;
    4550         [ #  # ]:          0 :   }
    4551                 :            : 
    4552         [ #  # ]:          0 :   original_chpts.uniquify_unordered();
    4553         [ #  # ]:          0 :   original_chcurves.uniquify_unordered();
    4554         [ #  # ]:          0 :   new_chpts.uniquify_unordered();
    4555         [ #  # ]:          0 :   new_chcurves.uniquify_unordered();  
    4556                 :            :   
    4557         [ #  # ]:          0 :   std::map<ChollaPoint*,ChollaPoint*>::iterator pt_iter;
    4558 [ #  # ][ #  # ]:          0 :   for( int i=original_chpts.size(); i--; )
    4559                 :            :   {
    4560         [ #  # ]:          0 :     ChollaPoint *orig_pt = original_chpts.get_and_step();
    4561                 :            : 
    4562         [ #  # ]:          0 :     pt_iter = point_map.find( orig_pt );
    4563 [ #  # ][ #  # ]:          0 :     assert( pt_iter != point_map.end() );
                 [ #  # ]
    4564                 :            : 
    4565         [ #  # ]:          0 :     ChollaPoint *new_pt = pt_iter->second;    
    4566                 :            :     
    4567 [ #  # ][ #  # ]:          0 :     CubitPoint *new_cp = dynamic_cast<CubitPoint *>(new_pt->get_facets());
    4568 [ #  # ][ #  # ]:          0 :     CubitPoint *orig_cp = dynamic_cast<CubitPoint *>(orig_pt->get_facets());
    4569                 :            : 
    4570                 :            :     //get the curves attached to it that are in the original surface
    4571 [ #  # ][ #  # ]:          0 :     DLIList<ChollaCurve*> adj_curves = orig_pt->get_curves();
    4572                 :            : 
    4573 [ #  # ][ #  # ]:          0 :     for( int j=adj_curves.size(); j--; )
    4574                 :            :     {
    4575         [ #  # ]:          0 :       ChollaCurve *orig_curve = adj_curves.get_and_step();
    4576                 :            : 
    4577         [ #  # ]:          0 :       curv_iter = curve_map.find( orig_curve );
    4578                 :            : 
    4579                 :            :       //use the original curve's start/end pts as a guide to set the new curve's start/end pts
    4580 [ #  # ][ #  # ]:          0 :       if( curv_iter != curve_map.end() )
                 [ #  # ]
    4581                 :            :       {
    4582                 :            :         //if there is a corresponding new curve, get it
    4583         [ #  # ]:          0 :         ChollaCurve *new_curve_in_new_surf = curv_iter->second;
    4584                 :            : 
    4585                 :            :         CubitPoint *start, *end;
    4586         [ #  # ]:          0 :         orig_curve->get_ends(start, end);        
    4587         [ #  # ]:          0 :         assert(orig_cp != NULL);
    4588         [ #  # ]:          0 :         assert(start!= NULL);
    4589         [ #  # ]:          0 :         assert(end != NULL);
    4590                 :            : 
    4591         [ #  # ]:          0 :         if ( orig_cp == start )
    4592                 :            :         {
    4593         [ #  # ]:          0 :           new_curve_in_new_surf->set_start(new_cp);
    4594                 :            :         }        
    4595         [ #  # ]:          0 :         if ( orig_cp == end )
    4596                 :            :         {
    4597         [ #  # ]:          0 :           new_curve_in_new_surf->set_end(new_cp);
    4598                 :            :         }        
    4599                 :            :       }   
    4600                 :            :     }
    4601         [ #  # ]:          0 :   }
    4602                 :            : 
    4603                 :            :   //for each new point
    4604 [ #  # ][ #  # ]:          0 :   for( int i=new_chpts.size(); i--; )
    4605                 :            :   {
    4606         [ #  # ]:          0 :     ChollaPoint *new_point = new_chpts.get_and_step();
    4607                 :            : 
    4608 [ #  # ][ #  # ]:          0 :     DLIList<ChollaCurve*> curves_in_pt = new_point->get_curves();
    4609                 :            : 
    4610 [ #  # ][ #  # ]:          0 :     for( int k=curves_in_pt.size(); k--; )
    4611                 :            :     {
    4612         [ #  # ]:          0 :       ChollaCurve *curve_in_pt = curves_in_pt.get_and_step();
    4613                 :            : 
    4614                 :            :       //get adjacent curves that are not new (not in 'new_curves')
    4615 [ #  # ][ #  # ]:          0 :       if( !original_chcurves.is_in_list( curve_in_pt ) )
    4616                 :            :       {
    4617 [ #  # ][ #  # ]:          0 :         DLIList<ChollaPoint *> chpts_on_curve = curve_in_pt->get_points();        
    4618                 :            :         
    4619                 :            :         // one point on the curve assumes a periodic curve.  set both ends the same
    4620                 :            : 
    4621 [ #  # ][ #  # ]:          0 :         if (chpts_on_curve.size() == 1)
    4622                 :            :         {
    4623         [ #  # ]:          0 :           ChollaPoint *chpt_on_crv = chpts_on_curve.get();
    4624 [ #  # ][ #  # ]:          0 :           CubitPoint *cp = dynamic_cast<CubitPoint *> (chpt_on_crv->get_facets());
    4625         [ #  # ]:          0 :           curve_in_pt->set_start(cp);
    4626         [ #  # ]:          0 :           curve_in_pt->set_end(cp);
    4627                 :            :         }
    4628                 :            : 
    4629                 :            :         // standard case. one point of curve is on the interface and one is not.
    4630                 :            :         // In this case, one of the points has been replaced with a new point.
    4631                 :            :         // so one of the end point pointers are out of date.  Determine which one
    4632                 :            :         // and then set it.
    4633                 :            : 
    4634 [ #  # ][ #  # ]:          0 :         else if (chpts_on_curve.size() == 2)
    4635                 :            :         {
    4636         [ #  # ]:          0 :           ChollaPoint *chpt1_on_crv = chpts_on_curve.get_and_step();
    4637         [ #  # ]:          0 :           ChollaPoint *chpt2_on_crv = chpts_on_curve.get();
    4638 [ #  # ][ #  # ]:          0 :           CubitPoint *cp1 = dynamic_cast<CubitPoint *> (chpt1_on_crv->get_facets());
    4639 [ #  # ][ #  # ]:          0 :           CubitPoint *cp2 = dynamic_cast<CubitPoint *> (chpt2_on_crv->get_facets());
    4640                 :            :           CubitPoint *curstart, *curend;
    4641         [ #  # ]:          0 :           curve_in_pt->get_ends(curstart, curend);
    4642         [ #  # ]:          0 :           assert(curstart != NULL);
    4643         [ #  # ]:          0 :           assert(curend != NULL);
    4644                 :            : 
    4645         [ #  # ]:          0 :           if (curstart == cp1)
    4646                 :            :           {
    4647         [ #  # ]:          0 :             curve_in_pt->set_end(cp2);
    4648                 :            :           }
    4649         [ #  # ]:          0 :           else if (curstart == cp2)
    4650                 :            :           {
    4651         [ #  # ]:          0 :             curve_in_pt->set_end(cp1);
    4652                 :            :           }
    4653         [ #  # ]:          0 :           else if (curend == cp2)
    4654                 :            :           {
    4655         [ #  # ]:          0 :             curve_in_pt->set_start(cp1);
    4656                 :            :           }
    4657         [ #  # ]:          0 :           else if (curend == cp1)
    4658                 :            :           {
    4659         [ #  # ]:          0 :             curve_in_pt->set_start(cp2);
    4660                 :            :           }
    4661                 :            :           else
    4662                 :            :           {
    4663                 :            :             //do this by proximity
    4664 [ #  # ][ #  # ]:          0 :             double dist1 = curstart->coordinates().distance_between( cp1->coordinates() );
                 [ #  # ]
    4665 [ #  # ][ #  # ]:          0 :             double dist2 = curstart->coordinates().distance_between( cp2->coordinates() );
                 [ #  # ]
    4666                 :            : 
    4667         [ #  # ]:          0 :             if( dist1 < dist2 )
    4668         [ #  # ]:          0 :               curve_in_pt->set_start( cp1 );
    4669         [ #  # ]:          0 :             else if(dist2 < dist1 )
    4670         [ #  # ]:          0 :               curve_in_pt->set_start( cp2 );
    4671                 :            :             else
    4672                 :          0 :               assert(0);
    4673                 :            :           }
    4674                 :            :         }
    4675                 :            :         else
    4676         [ #  # ]:          0 :           assert(0);
    4677                 :            :       }
    4678                 :            :     } 
    4679         [ #  # ]:          0 :   }
    4680         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    4681 [ +  - ][ +  - ]:       6540 : }
    4682                 :            : 
    4683                 :            : // EOF

Generated by: LCOV version 1.11