LCOV - code coverage report
Current view: top level - geom - GeometryModifyTool.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 1282 10710 12.0 %
Date: 2020-06-30 00:58:45 Functions: 74 233 31.8 %
Branches: 1790 32377 5.5 %

           Branch data     Line data    Source code
       1                 :            : //-------------------------------------------------------------------------
       2                 :            : // Filename      : GeometryModifyTool.cpp
       3                 :            : //
       4                 :            : // Purpose       : The tool used to create and modify geometry
       5                 :            : //
       6                 :            : // Special Notes :
       7                 :            : //
       8                 :            : // Creator       : Tim Tautges
       9                 :            : //
      10                 :            : // Creation Date : 2/01
      11                 :            : //
      12                 :            : //-------------------------------------------------------------------------
      13                 :            : 
      14                 :            : #include <string.h>
      15                 :            : #include <assert.h>
      16                 :            : #include <stdlib.h>
      17                 :            : #include <math.h>
      18                 :            : #include <sstream>
      19                 :            : //#include <iostream>
      20                 :            : 
      21                 :            : #include "GeometryModifyTool.hpp"
      22                 :            : #include "CubitDefines.h"
      23                 :            : #include "GeometryDefines.h"
      24                 :            : #include "GeometryEntity.hpp"
      25                 :            : #include "GeometryQueryTool.hpp"
      26                 :            : #include "MergeTool.hpp"
      27                 :            : #include "SurfaceOverlapTool.hpp"
      28                 :            : #include "GeometryQueryEngine.hpp"
      29                 :            : #include "OldUnmergeCode.hpp"
      30                 :            : #include "GeometryModifyEngine.hpp"
      31                 :            : #include "AnalyticGeometryTool.hpp"
      32                 :            : #include "DAG.hpp"
      33                 :            : #include "TopologyBridge.hpp"
      34                 :            : #include "ModelQueryEngine.hpp"
      35                 :            : #include "CADefines.hpp"
      36                 :            : #include "GeomMeasureTool.hpp"
      37                 :            : #include "LocalToleranceTool.hpp"
      38                 :            : 
      39                 :            : #include "RefEntity.hpp"
      40                 :            : #include "RefEntityFactory.hpp"
      41                 :            : #include "RefEntityName.hpp"
      42                 :            : #include "BasicTopologyEntity.hpp"
      43                 :            : #include "RefVertex.hpp"
      44                 :            : #include "RefEdge.hpp"
      45                 :            : #include "RefFace.hpp"
      46                 :            : #include "RefVolume.hpp"
      47                 :            : 
      48                 :            : #include "CoVertex.hpp"
      49                 :            : #include "CoEdge.hpp"
      50                 :            : #include "CoFace.hpp"
      51                 :            : #include "CoVolume.hpp"
      52                 :            : 
      53                 :            : #include "Chain.hpp"
      54                 :            : #include "Loop.hpp"
      55                 :            : #include "Shell.hpp"
      56                 :            : #include "Body.hpp"
      57                 :            : 
      58                 :            : #include "Lump.hpp"
      59                 :            : #include "Surface.hpp"
      60                 :            : #include "Curve.hpp"
      61                 :            : #include "Point.hpp"
      62                 :            : #include "BodySM.hpp"
      63                 :            : #include "ShellSM.hpp"
      64                 :            : #include "LoopSM.hpp"
      65                 :            : #include "CoEdgeSM.hpp"
      66                 :            : 
      67                 :            : #include "CubitAttrib.hpp"
      68                 :            : #include "CubitVector.hpp"
      69                 :            : #include "CubitPlane.hpp"
      70                 :            : #include "CubitTransformMatrix.hpp"
      71                 :            : #include "GfxPreview.hpp"
      72                 :            : #include "AppUtil.hpp"
      73                 :            : 
      74                 :            : #include "DLIList.hpp"
      75                 :            : 
      76                 :            : #include "CubitMessage.hpp"
      77                 :            : #include "SettingHandler.hpp"
      78                 :            : 
      79                 :            : #include "CastTo.hpp"
      80                 :            : #include "CpuTimer.hpp"
      81                 :            : 
      82                 :            : #include "BridgeManager.hpp"
      83                 :            : #include "SplitSurfaceTool.hpp"
      84                 :            : #include "OffsetSplitTool.hpp"
      85                 :            : #include "AutoMidsurfaceTool.hpp"
      86                 :            : #include "TDSurfaceOverlap.hpp"
      87                 :            : #include "GfxDebug.hpp"
      88                 :            : 
      89                 :            : #include "CubitUndo.hpp"
      90                 :            : 
      91                 :            : /* Work around stupid #define hz equal to HZ on IBM */
      92                 :            : #ifdef hz
      93                 :            : #  undef hz
      94                 :            : #endif
      95                 :            : #ifdef PROE
      96                 :            : #include "CompositeTool.hpp"
      97                 :            : #endif
      98                 :            : 
      99                 :            : GeometryModifyTool* GeometryModifyTool::instance_ = 0;
     100                 :            : CubitBoolean GeometryModifyTool::allEdgesImprint = CUBIT_TRUE;
     101                 :            : CubitBoolean GeometryModifyTool::groupImprint = CUBIT_TRUE;
     102                 :            : CubitBoolean GeometryModifyTool::newIds = CUBIT_FALSE;
     103                 :            : CubitBoolean GeometryModifyTool::sepAfterWebcut = CUBIT_TRUE;
     104                 :            : CubitBoolean GeometryModifyTool::booleanRegularize = CUBIT_TRUE;
     105                 :            : CubitBoolean GeometryModifyTool::uniteMixedModels = CUBIT_TRUE;
     106                 :            : CubitBoolean GeometryModifyTool::oldNames = CUBIT_FALSE;
     107                 :            : CubitBoolean GeometryModifyTool::meshAutodelete = CUBIT_TRUE;
     108                 :            : CubitBoolean GeometryModifyTool::meshAutodeleteRemesh = CUBIT_FALSE;
     109                 :            : RefEntity* GeometryModifyTool::copyingEntity = NULL;
     110                 :            : 
     111                 :            : CubitStatus prepare_surface_sweep(
     112                 :            :                               DLIList<BodySM*> &blank_bodies,
     113                 :            :                               DLIList<Surface*> &surfaces,
     114                 :            :                               const CubitVector& sweep_vector,
     115                 :            :                               bool sweep_perp,
     116                 :            :                               bool through_all,
     117                 :            :                               bool outward,
     118                 :            :                               bool up_to_next,
     119                 :            :                               Surface *stop_surf,
     120                 :            :                               Curve *curve_to_sweep_along,
     121                 :            :                               BodySM* &cutting_tool_ptr ,
     122                 :            :                               const CubitVector* point = NULL,
     123                 :            :                               double *angle = NULL);
     124                 :            :   // prepare for webcut with swept_surfaces. if point and angle is known,
     125                 :            :   // do surface sweep rotated; or if curve_to_sweep_along is known, do
     126                 :            :   // sweep along curve; then if sweep_perp is true, do perpendicular sweep
     127                 :            :   // of the surfaces; lastly do sweep along vector.
     128                 :            : 
     129                 :            : CubitStatus webcut_w_cylinder( DLIList<BodySM*> &webcut_body_list,
     130                 :            :                                double radius,
     131                 :            :                                const CubitVector &axis,
     132                 :            :                                const CubitVector &center,
     133                 :            :                                DLIList<BodySM*>& neighbor_imprint_list,
     134                 :            :                                DLIList<BodySM*>& results_list,
     135                 :            :                                ImprintType imprint_type = NO_IMPRINT );
     136                 :            :   //- webcuts a body using a cylinder given the input parameters.
     137                 :            : 
     138                 :            : //-------------------------------------------------------------------------
     139                 :            : // Purpose       : Controls access and creation of the sole instance of this
     140                 :            : //                 class.
     141                 :            : //
     142                 :            : // Special Notes :
     143                 :            : //
     144                 :            : // Creator       : Xuechen Liu
     145                 :            : //
     146                 :            : // Creation Date : 07/11/96
     147                 :            : //-------------------------------------------------------------------------
     148                 :            : 
     149                 :       9570 : GeometryModifyTool* GeometryModifyTool::instance(GeometryModifyEngine *GMEPtr)
     150                 :            : {
     151                 :            :      // Check to see if we have created an instance of the class
     152                 :            :      // If not, proceed to create one.
     153                 :            : 
     154         [ +  + ]:       9570 :    if (instance_ == 0)
     155                 :            :    {
     156                 :            :         // When creating the instance, we should always have a valid
     157                 :            :         // SMEPtr. If not, complain.
     158                 :            : 
     159         [ +  - ]:        874 :      instance_ = new GeometryModifyTool (GMEPtr) ;
     160                 :            : 
     161                 :            :         // check to make sure there's a ref entity factory extant
     162                 :            :      //RefEntityFactory *factory =
     163                 :        874 :      RefEntityFactory::instance();
     164                 :            :    }
     165                 :            : 
     166                 :            :      // If there is an existing instance of the class, check if there
     167                 :            :      // was a request to set default solid modeling engine. If so, be nice
     168                 :            :      // to the calling routine :) :) and kindly set the default solid
     169                 :            :      // modeling engine.
     170                 :            : 
     171 [ -  + ][ #  # ]:       8696 :    else if ( GMEPtr != NULL && instance_->gmeList.move_to(GMEPtr)) {
                 [ -  + ]
     172         [ #  # ]:          0 :      delete instance_->gmeList.remove();
     173                 :          0 :      instance_->gmeList.insert(GMEPtr);
     174                 :            :    }
     175                 :            : 
     176                 :            :      // Return the a pointer to the instance of the class.
     177                 :            : 
     178                 :       9570 :    return instance_ ;
     179                 :            : }
     180                 :            : 
     181                 :            : //-------------------------------------------------------------------------
     182                 :            : // Purpose       : Destructor.
     183                 :            : //
     184                 :            : // Special Notes :
     185                 :            : //
     186                 :            : // Creator       : Xuechen Liu
     187                 :            : //
     188                 :            : // Creation Date : 07/11/96
     189                 :            : //-------------------------------------------------------------------------
     190                 :        542 : GeometryModifyTool::~GeometryModifyTool ()
     191                 :            : {
     192                 :        271 :    instance_ = NULL;
     193                 :            :      //Kill the geometry modify engine(s)
     194                 :            :    int i;
     195 [ +  - ][ +  + ]:        813 :    for (i = gmeList.size(); i > 0; i--)
     196 [ +  - ][ +  - ]:        542 :      delete gmeList.get_and_step();
                 [ +  - ]
     197                 :            : 
     198         [ +  - ]:        271 :    gmeList.clean_out();
     199                 :        271 : }
     200                 :            : 
     201                 :            : //-------------------------------------------------------------------------
     202                 :            : // Purpose       : Deletes instance variable
     203                 :            : //
     204                 :            : // Special Notes :
     205                 :            : //
     206                 :            : // Creator       : Corey Ernst
     207                 :            : //
     208                 :            : // Creation Date : 12/31/07
     209                 :            : //-------------------------------------------------------------------------
     210                 :        322 : void GeometryModifyTool::delete_instance()
     211                 :            : {
     212         [ +  + ]:        322 :   if( NULL != instance_ )
     213                 :            :   {
     214         [ +  - ]:        271 :     delete instance_;
     215                 :        271 :     instance_ = NULL;
     216                 :            :   }
     217                 :        322 : }
     218                 :            : 
     219                 :            : //-------------------------------------------------------------------------
     220                 :            : // Purpose       : Creates a Body corresponding to a sphere with the
     221                 :            : //                 given radius
     222                 :            : //
     223                 :            : // Special Notes :
     224                 :            : //
     225                 :            : // Creator       : Jihong Ma
     226                 :            : //
     227                 :            : // Creation Date : 09/18/96
     228                 :            : //-------------------------------------------------------------------------
     229                 :        153 : Body* GeometryModifyTool::sphere(double radius,
     230                 :            :                                  int x_shift,
     231                 :            :                                  int y_shift,
     232                 :            :                                  int z_shift,
     233                 :            :                                  double inner_radius,
     234                 :            :                                  bool delete_side )
     235                 :            : {
     236 [ +  - ][ -  + ]:        153 :    if (0 == gmeList.size())
     237                 :            :    {
     238 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
     239                 :          0 :       return NULL;
     240                 :            :    }
     241                 :            : 
     242                 :            :      // First make sure the radius is not zero or less
     243         [ -  + ]:        153 :    if ( radius <= 0.0 )
     244                 :            :    {
     245 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::sphere\n"
                 [ #  # ]
     246                 :            :                   "       Cannot make a sphere of radius %f\n",
     247         [ #  # ]:          0 :                   radius);
     248                 :          0 :       return NULL ;
     249                 :            :    }
     250                 :            : 
     251 [ +  - ][ -  + ]:        153 :   if( CubitUndo::get_undo_enabled() )
     252         [ #  # ]:          0 :     CubitUndo::save_state();
     253                 :            : 
     254         [ +  - ]:        153 :   GeometryModifyEngine *gme = gmeList.get();
     255                 :            : 
     256         [ +  - ]:        153 :   BodySM* body_sm = gme->sphere(radius);
     257                 :            : 
     258 [ +  - ][ +  - ]:        153 :   if (x_shift != 0 || y_shift != 0 || z_shift != 0)
                 [ -  + ]
     259                 :            :   {
     260                 :            :     BodySM *brick = gme->brick( 2.0 * radius,
     261                 :            :                                 2.0 * radius,
     262         [ #  # ]:          0 :                                 2.0 * radius);
     263                 :            : 
     264                 :            :     CubitVector delta( x_shift * radius,
     265                 :            :                        y_shift * radius,
     266         [ #  # ]:          0 :                        z_shift * radius );
     267                 :            : 
     268 [ #  # ][ #  # ]:          0 :     gme->get_gqe()->translate( brick, delta );
     269                 :            : 
     270         [ #  # ]:          0 :     DLIList<BodySM*> new_sms;
     271 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> from_bodies(1);
                 [ #  # ]
     272         [ #  # ]:          0 :     from_bodies.append( body_sm );
     273                 :          0 :     bool keep_old = true;
     274                 :            :     CubitStatus bool_status;
     275         [ #  # ]:          0 :     if( delete_side == false )
     276         [ #  # ]:          0 :        bool_status = gme->intersect( brick, from_bodies, new_sms, keep_old );
     277                 :            :     else
     278                 :            :     {
     279         [ #  # ]:          0 :       DLIList<BodySM*> tool_bodies(1);
     280         [ #  # ]:          0 :       tool_bodies.append( brick );
     281                 :          0 :       bool imprint = false;
     282 [ #  # ][ #  # ]:          0 :       bool_status = gme->subtract( tool_bodies, from_bodies, new_sms, imprint, keep_old );
     283                 :            :     }
     284                 :            : 
     285                 :            :     //delete the old bodies
     286 [ #  # ][ #  # ]:          0 :     gme->get_gqe()->delete_solid_model_entities( body_sm );
     287 [ #  # ][ #  # ]:          0 :     gme->get_gqe()->delete_solid_model_entities( brick );
     288                 :            : 
     289 [ #  # ][ #  # ]:          0 :     if( bool_status == CUBIT_FAILURE || new_sms.size() == 0 )
         [ #  # ][ #  # ]
     290                 :            :     {
     291 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Problems creating sphere.\n" );
         [ #  # ][ #  # ]
     292                 :          0 :       return NULL ;
     293                 :            :     }
     294                 :            : 
     295 [ #  # ][ #  # ]:          0 :     body_sm = new_sms.get();
                 [ #  # ]
     296                 :            :   }
     297                 :            : 
     298                 :        153 :   Body *new_body = NULL;
     299                 :        153 :   BodySM* inner_body_sm = NULL;
     300         [ -  + ]:        153 :   if( inner_radius )
     301                 :            :   {
     302         [ #  # ]:          0 :     inner_body_sm = gme->sphere(inner_radius);
     303         [ #  # ]:          0 :     DLIList<BodySM*> new_sms;
     304 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> from_bodies(1);
                 [ #  # ]
     305 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> tool_bodies(1);
                 [ #  # ]
     306         [ #  # ]:          0 :     from_bodies.append( body_sm );
     307         [ #  # ]:          0 :     tool_bodies.append( inner_body_sm );
     308                 :          0 :     bool imprint = false;
     309                 :          0 :     bool keep_old = true;
     310                 :            :     CubitStatus subtract_status =
     311         [ #  # ]:          0 :        gme->subtract( tool_bodies, from_bodies, new_sms, imprint, keep_old );
     312                 :            : 
     313                 :            :      //delete the old bodies
     314 [ #  # ][ #  # ]:          0 :     gme->get_gqe()->delete_solid_model_entities( body_sm );
     315 [ #  # ][ #  # ]:          0 :     gme->get_gqe()->delete_solid_model_entities( inner_body_sm );
     316                 :            : 
     317 [ #  # ][ #  # ]:          0 :     if( subtract_status == CUBIT_FAILURE || new_sms.size() == 0 )
         [ #  # ][ #  # ]
     318                 :            :     {
     319 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Problems creating sphere with inner radius.\n" );
         [ #  # ][ #  # ]
     320                 :          0 :       return NULL ;
     321                 :            :     }
     322                 :            : 
     323 [ #  # ][ #  # ]:          0 :     body_sm = new_sms.get();
                 [ #  # ]
     324                 :            :   }
     325                 :            : 
     326         [ -  + ]:        153 :   if (!body_sm)
     327                 :            :   {
     328 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("In GeometryModifyTool::sphere\n"
                 [ #  # ]
     329         [ #  # ]:          0 :                  "       Problems building a volume from the sphere.\n");
     330                 :            :   }
     331                 :            :   else
     332 [ +  - ][ +  - ]:        153 :     new_body = GeometryQueryTool::instance()->make_Body(body_sm);
     333                 :            : 
     334 [ +  - ][ -  + ]:        153 :   if( CubitUndo::get_undo_enabled() )
     335                 :            :   {
     336         [ #  # ]:          0 :     if( new_body )
     337         [ #  # ]:          0 :       CubitUndo::note_result_body( new_body );
     338                 :            :     else
     339         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
     340                 :            :   }
     341                 :            : 
     342                 :        153 :   return new_body;
     343                 :            : }
     344                 :            : 
     345                 :            : //-------------------------------------------------------------------------
     346                 :            : // Purpose       : Creates a Body corresponding to a brick with given width,
     347                 :            : //                 depth, and height.
     348                 :            : //
     349                 :            : // Special Notes :
     350                 :            : //
     351                 :            : // Creator       : Jihong Ma
     352                 :            : //
     353                 :            : // Creation Date : 09/18/96
     354                 :            : //-------------------------------------------------------------------------
     355                 :        302 : Body* GeometryModifyTool::brick(double width, double depth, double height)
     356                 :            : {
     357         [ -  + ]:        302 :    if (0 == gmeList.size())
     358                 :            :    {
     359 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
     360                 :          0 :       return NULL;
     361                 :            :    }
     362                 :            : 
     363                 :            :      // First make sure that none of the input values are zero or less
     364 [ +  - ][ +  - ]:        302 :    if ( width <= GEOMETRY_RESABS || depth <= GEOMETRY_RESABS || height <= GEOMETRY_RESABS )
                 [ -  + ]
     365                 :            :    {
     366         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::brick\n"
     367                 :            :                   "    Cannot make a cuboid of size %f x %f x %f\n"
     368                 :            :                   "       All dimensions must be > 0.0\n",
     369         [ #  # ]:          0 :                   width, depth, height);
     370                 :          0 :       return NULL;
     371                 :            :    }
     372                 :            : 
     373         [ -  + ]:        302 :   if( CubitUndo::get_undo_enabled() )
     374                 :          0 :     CubitUndo::save_state();
     375                 :            : 
     376                 :        302 :    Body *new_body = NULL;
     377                 :        302 :    BodySM* bodyPtr = gmeList.get()->brick(width, depth, height);
     378                 :            : 
     379         [ -  + ]:        302 :    if (bodyPtr == NULL)
     380                 :            :    {
     381         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::brick\n"
     382         [ #  # ]:          0 :                   "       Problem creating a brick.\n") ;
     383                 :            :    }
     384                 :            :    else
     385                 :        302 :      new_body = GeometryQueryTool::instance()->make_Body(bodyPtr);
     386                 :            : 
     387         [ -  + ]:        302 :   if( CubitUndo::get_undo_enabled() )
     388                 :            :   {
     389         [ #  # ]:          0 :     if( new_body )
     390                 :          0 :       CubitUndo::note_result_body( new_body );
     391                 :            :     else
     392                 :          0 :       CubitUndo::remove_last_undo();
     393                 :            :   }
     394                 :            : 
     395                 :        302 :    return new_body;
     396                 :            : }
     397                 :            : 
     398                 :            : #ifdef KCM_MESH_TO_GEOM
     399                 :            : //-------------------------------------------------------------------------
     400                 :            : // Purpose       : Create breps from mesh entities.
     401                 :            : //
     402                 :            : // Special Notes :
     403                 :            : //
     404                 :            : // Creator       : Brett Clark
     405                 :            : //
     406                 :            : // Creation Date : 12/21/2010
     407                 :            : //-------------------------------------------------------------------------
     408                 :            : CubitStatus GeometryModifyTool::mesh2brep(std::vector<double> &xvals,
     409                 :            :                         std::vector<double> &yvals,
     410                 :            :                         std::vector<double> &zvals,
     411                 :            :                         std::vector<unsigned int> &tri_connectivity,
     412                 :            :                         DLIList<BodySM*> &new_body_sms)
     413                 :            : {
     414                 :            :   if (0 == gmeList.size())
     415                 :            :   {
     416                 :            :     PRINT_WARNING("No active geometry engine.\n");
     417                 :            :     return CUBIT_FAILURE;
     418                 :            :   }
     419                 :            : 
     420                 :            :   return gmeList.get()->mesh2brep(xvals, yvals, zvals, tri_connectivity, new_body_sms);
     421                 :            : }
     422                 :            : #endif
     423                 :            : 
     424                 :            : //-------------------------------------------------------------------------
     425                 :            : // Purpose       : Creates a Body corresponding to a brick at given location,
     426                 :            : //                 orientation, and size.
     427                 :            : //
     428                 :            : // Special Notes : If one of the dimensions is zero, a planar sheet is created.
     429                 :            : //
     430                 :            : // Creator       : Steve Storm
     431                 :            : //
     432                 :            : // Creation Date : 10/09/2000
     433                 :            : //-------------------------------------------------------------------------
     434                 :         11 : Body* GeometryModifyTool::brick(const CubitVector &center,
     435                 :            :                                 const CubitVector axes[3],
     436                 :            :                                 const CubitVector &extension)
     437                 :            : {
     438         [ -  + ]:         11 :    if (0 == gmeList.size())
     439                 :            :    {
     440 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
     441                 :          0 :       return NULL;
     442                 :            :    }
     443                 :            : 
     444                 :         11 :    double width = 2.0*extension.x();
     445                 :         11 :    double height = 2.0*extension.y();
     446                 :         11 :    double depth = 2.0*extension.z();
     447                 :            :      // First make sure that entity creation is possible.  Allow at most
     448                 :            :      // only one of the dimensions to be zero - in which case a planar
     449                 :            :      // sheet is created.
     450 [ +  - ][ +  - ]:         11 :    if ( width < 0.0 || height < 0.0 || depth < 0.0 )
                 [ -  + ]
     451                 :            :    {
     452         [ #  # ]:          0 :       PRINT_ERROR( "Cannot make a brick of size %f x %f x %f\n"
     453                 :            :                    "     Negative dimensions are not allowed.\n",
     454         [ #  # ]:          0 :                    width, height, depth );
     455                 :          0 :       return NULL ;
     456                 :            :    }
     457                 :            : 
     458                 :         11 :    int wz = width < GEOMETRY_RESABS;
     459                 :         11 :    int hz = height < GEOMETRY_RESABS;
     460                 :         11 :    int dz = depth < GEOMETRY_RESABS;
     461 [ +  - ][ +  - ]:         11 :    if( wz || hz || dz )
                 [ -  + ]
     462                 :            :    {
     463         [ #  # ]:          0 :       if( (wz + hz + dz) > 1 )
     464                 :            :       {
     465 [ #  # ][ #  # ]:          0 :          PRINT_ERROR( "Cannot make a sheet of size %f x %f x %f\n"
                 [ #  # ]
     466                 :            :             "     At least two dimensions must be nonzero.\n",
     467         [ #  # ]:          0 :             width, height, depth );
     468                 :          0 :          return NULL ;
     469                 :            :       }
     470                 :            : 
     471                 :            :       // Make a sheet body instead of a cuboid
     472 [ #  # ][ #  # ]:          0 :       CubitVector sheet_axes[2];
     473         [ #  # ]:          0 :       if( wz )
     474                 :            :       {
     475         [ #  # ]:          0 :          sheet_axes[0] = axes[1];
     476         [ #  # ]:          0 :          sheet_axes[1] = axes[2];
     477         [ #  # ]:          0 :          return planar_sheet( center, sheet_axes, height, depth );
     478                 :            :       }
     479         [ #  # ]:          0 :       else if( hz )
     480                 :            :       {
     481         [ #  # ]:          0 :          sheet_axes[0] = axes[2];
     482         [ #  # ]:          0 :          sheet_axes[1] = axes[0];
     483         [ #  # ]:          0 :          return planar_sheet( center, sheet_axes, depth, width );
     484                 :            :       }
     485                 :            :       else
     486                 :            :       {
     487         [ #  # ]:          0 :          sheet_axes[0] = axes[0];
     488         [ #  # ]:          0 :          sheet_axes[1] = axes[1];
     489         [ #  # ]:          0 :          return planar_sheet( center, sheet_axes, width, height );
     490                 :            :       }
     491                 :            :    }
     492                 :            :    else
     493                 :            :    {
     494         [ -  + ]:         11 :       if( CubitUndo::get_undo_enabled() )
     495                 :          0 :         CubitUndo::save_state();
     496                 :            : 
     497                 :         11 :       BodySM* bodyPtr = gmeList.get()->brick(center, axes, extension) ;
     498                 :         11 :       Body *new_body = NULL;
     499         [ -  + ]:         11 :       if (bodyPtr == NULL)
     500                 :            :       {
     501         [ #  # ]:          0 :          PRINT_ERROR("In GeometryTool::brick\n"
     502         [ #  # ]:          0 :             "       Problem creating a brick.\n") ;
     503                 :            :       }
     504                 :            :       else
     505                 :         11 :         new_body = GeometryQueryTool::instance()->make_Body(bodyPtr);
     506                 :            : 
     507         [ -  + ]:         11 :       if( CubitUndo::get_undo_enabled() )
     508                 :            :       {
     509         [ #  # ]:          0 :         if( new_body )
     510                 :          0 :           CubitUndo::note_result_body( new_body );
     511                 :            :         else
     512                 :          0 :           CubitUndo::remove_last_undo();
     513                 :            :       }
     514                 :            : 
     515                 :         11 :       return new_body;
     516                 :            :    }
     517                 :            : }
     518                 :            : 
     519                 :            : //-------------------------------------------------------------------------
     520                 :            : // Purpose       : Creates a Body corresponding to a prism with height,
     521                 :            : //                 sides, major, minor radii
     522                 :            : //
     523                 :            : //
     524                 :            : // Special Notes :
     525                 :            : //
     526                 :            : // Creator       : Jihong Ma
     527                 :            : //
     528                 :            : // Creation Date : 09/18/96
     529                 :            : //-------------------------------------------------------------------------
     530                 :         11 : Body* GeometryModifyTool::prism( double height, int sides, double major, double minor)
     531                 :            : {
     532         [ -  + ]:         11 :    if (0 == gmeList.size())
     533                 :            :    {
     534 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
     535                 :          0 :       return NULL;
     536                 :            :    }
     537                 :            : 
     538                 :            :      // First make sure that the input values make sense
     539 [ +  - ][ +  - ]:         11 :    if ( major < minor ||
     540 [ +  - ][ +  - ]:         11 :         major <= GEOMETRY_RESABS || minor <= GEOMETRY_RESABS ||
     541         [ -  + ]:         11 :         height <= GEOMETRY_RESABS || sides < 3 )
     542                 :            :    {
     543         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::prism\n"
     544                 :            :                   "   Cannot make a prism of major-radius = %f,"
     545                 :            :                   " minor-radius = %f, height = %f, and"
     546                 :            :                   " number of sides = %d\n"
     547                 :            :                   "   All dimensions must be > 0.0, the major-radius\n"
     548                 :            :                   " should be greater than or equal to the minor-"
     549                 :            :                   "radius,\n and the number of sides should be greater"
     550         [ #  # ]:          0 :                   " than 2.\n", major, minor, height, sides);
     551                 :            : 
     552                 :          0 :       return NULL;
     553                 :            :    }
     554                 :            : 
     555         [ -  + ]:         11 :    if( CubitUndo::get_undo_enabled() )
     556                 :          0 :      CubitUndo::save_state();
     557                 :            : 
     558                 :            :      // Create a Body that represents the prism
     559                 :         11 :    BodySM* bodyPtr = gmeList.get()->prism(height,  sides, major, minor) ;
     560                 :         11 :    Body *new_body = NULL;
     561         [ -  + ]:         11 :    if (bodyPtr == NULL)
     562                 :            :    {
     563         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::prism\n"
     564         [ #  # ]:          0 :                   "       Problems building a volume from the prism.\n") ;
     565                 :            :    }
     566                 :            :    else
     567                 :         11 :      new_body = GeometryQueryTool::instance()->make_Body(bodyPtr);
     568                 :            : 
     569         [ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
     570                 :            :   {
     571         [ #  # ]:          0 :     if( new_body )
     572                 :          0 :       CubitUndo::note_result_body( new_body );
     573                 :            :     else
     574                 :          0 :       CubitUndo::remove_last_undo();
     575                 :            :   }
     576                 :            : 
     577                 :         11 :    return new_body;
     578                 :            : }
     579                 :            : 
     580                 :            : //-------------------------------------------------------------------------
     581                 :            : // Purpose       : Creates a Body corresponding to a pyramid with given
     582                 :            : //                 height, major, minor,top, sides
     583                 :            : //
     584                 :            : // Special Notes :
     585                 :            : //
     586                 :            : // Creator       : Jihong Ma
     587                 :            : //
     588                 :            : // Creation Date : 09/18/96
     589                 :            : //-------------------------------------------------------------------------
     590                 :         11 : Body* GeometryModifyTool::pyramid  ( double height, int sides, double major,
     591                 :            :                              double minor,  double top)
     592                 :            : {
     593         [ -  + ]:         11 :    if (0 == gmeList.size())
     594                 :            :    {
     595 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
     596                 :          0 :       return NULL;
     597                 :            :    }
     598                 :            : 
     599                 :            :      // First make sure that the input values make sense
     600 [ +  - ][ +  - ]:         11 :    if ( major < minor ||
     601 [ +  - ][ +  - ]:         11 :         major <= GEOMETRY_RESABS || minor <= GEOMETRY_RESABS ||
     602 [ +  - ][ -  + ]:         11 :         height <= GEOMETRY_RESABS || top < 0.0 || sides < 3  )
     603                 :            :    {
     604         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::pyramid\n"
     605                 :            :                   "    Cannot make a pyramid of major-radius = %f,"
     606                 :            :                   " minor-radius = %f, height = %f,"
     607                 :            :                   " top %f, and number of sides = %d\n"
     608                 :            :                   "     All dimensions must be > 0.0, the major-radius"
     609                 :            :                   " should be greater than the minor-radius, the "
     610                 :            :                   "number of sides should be greater than 2.\n",
     611         [ #  # ]:          0 :                   major, minor, height, top, sides);
     612                 :          0 :       return NULL;
     613                 :            :    }
     614                 :            : 
     615         [ -  + ]:         11 :    if( CubitUndo::get_undo_enabled() )
     616                 :          0 :      CubitUndo::save_state();
     617                 :            : 
     618                 :            :      // Create a Body that represents the prism
     619                 :         11 :    BodySM* bodyPtr = gmeList.get()->pyramid ( height, sides, major, minor, top);
     620                 :         11 :    Body *new_body = NULL;
     621         [ -  + ]:         11 :    if (bodyPtr == NULL)
     622                 :            :    {
     623         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::pyramid\n"
     624         [ #  # ]:          0 :                   "      Problems building a volume from the pyramid.\n");
     625                 :            :    }
     626                 :            :    else
     627                 :         11 :      new_body = GeometryQueryTool::instance()->make_Body(bodyPtr);
     628                 :            : 
     629         [ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
     630                 :            :   {
     631         [ #  # ]:          0 :     if( new_body )
     632                 :          0 :       CubitUndo::note_result_body( new_body );
     633                 :            :     else
     634                 :          0 :       CubitUndo::remove_last_undo();
     635                 :            :   }
     636                 :            : 
     637                 :         11 :    return new_body;
     638                 :            : }
     639                 :            : 
     640                 :            : //-------------------------------------------------------------------------
     641                 :            : // Purpose       : Creates a Body corresponding to a frustum of a cone with
     642                 :            : //                 height,
     643                 :            : //                 input radius in x-direction at base
     644                 :            : //                 input radius in y-direction at base
     645                 :            : //                 input radius in x-direction at top
     646                 :            : //
     647                 :            : // Special Notes :
     648                 :            : //
     649                 :            : // Creator       : Jihong Ma
     650                 :            : //
     651                 :            : // Creation Date : 09/18/96
     652                 :            : //-------------------------------------------------------------------------
     653                 :         86 : Body* GeometryModifyTool::cylinder ( double hi, double r1, double r2, double r3 )
     654                 :            : {
     655         [ -  + ]:         86 :    if (0 == gmeList.size())
     656                 :            :    {
     657 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
     658                 :          0 :       return NULL;
     659                 :            :    }
     660                 :            : 
     661                 :            :      // First make sure that the input values make sense
     662 [ +  - ][ +  - ]:         86 :    if ( hi <= GEOMETRY_RESABS || r1 <= GEOMETRY_RESABS ||
                 [ +  - ]
     663         [ -  + ]:         86 :         r2 <= GEOMETRY_RESABS || r3 < 0.0 )
     664                 :            :    {
     665         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::cylinder\n"
     666                 :            :                   " Cannot make a frustum of a cone with height = %f,"
     667                 :            :                   " lower x-direction radius = %f,"
     668                 :            :                   " lower y-direction radius = %f, and "
     669                 :            :                   "top radius = %f\n"
     670                 :            :                   "       All dimensions must be > 0.0\n",
     671         [ #  # ]:          0 :                   hi, r1, r2, r3);
     672                 :          0 :       return NULL;
     673                 :            :    }
     674                 :            : 
     675         [ -  + ]:         86 :    if( CubitUndo::get_undo_enabled() )
     676                 :          0 :      CubitUndo::save_state();
     677                 :            : 
     678                 :            :      // Create a Body that represents the prism
     679                 :         86 :    BodySM* bodyPtr = gmeList.get()->cylinder( hi, r1, r2, r3);
     680                 :         86 :    Body *new_body = NULL;
     681                 :            : 
     682         [ -  + ]:         86 :    if (bodyPtr == NULL)
     683                 :            :    {
     684         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::cylinder\n"
     685         [ #  # ]:          0 :                   "       Problems building a volume from the conical frustum.\n");
     686                 :            :    }
     687                 :            :    else
     688                 :         86 :      new_body = GeometryQueryTool::instance()->make_Body(bodyPtr);
     689                 :            : 
     690         [ -  + ]:         86 :   if( CubitUndo::get_undo_enabled() )
     691                 :            :   {
     692         [ #  # ]:          0 :     if( new_body )
     693                 :          0 :       CubitUndo::note_result_body( new_body );
     694                 :            :     else
     695                 :          0 :       CubitUndo::remove_last_undo();
     696                 :            :   }
     697                 :            : 
     698                 :         86 :    return new_body;
     699                 :            : }
     700                 :            : 
     701                 :            : //-------------------------------------------------------------------------
     702                 :            : // Purpose       : Creates a Body corresponding to a torus with major_radius
     703                 :            : //                 and minor_radius
     704                 :            : //
     705                 :            : //
     706                 :            : // Special Notes :
     707                 :            : //
     708                 :            : // Creator       : Jihong Ma
     709                 :            : //
     710                 :            : // Creation Date : 09/18/96
     711                 :            : //-------------------------------------------------------------------------
     712                 :         33 : Body* GeometryModifyTool::torus( double r1, double r2 )
     713         [ -  + ]:         33 : {   if (0 == gmeList.size())
     714                 :            :    {
     715 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
     716                 :          0 :       return NULL;
     717                 :            :    }
     718                 :            : 
     719                 :            : 
     720                 :            :      // First make sure that the input values make sense
     721 [ +  - ][ +  - ]:         33 :    if ( r1 <= r2 || r1 <= GEOMETRY_RESABS || r2 <= 0.0)
                 [ -  + ]
     722                 :            :    {
     723         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::torus\n"
     724                 :            :                   "  Cannot make a torus of major-radius = %f and"
     725                 :            :                   " minor-radius = %f\n",
     726         [ #  # ]:          0 :                   r1, r2);
     727                 :          0 :       return NULL;
     728                 :            :    }
     729                 :            : 
     730         [ -  + ]:         33 :    if( CubitUndo::get_undo_enabled() )
     731                 :          0 :      CubitUndo::save_state();
     732                 :            : 
     733                 :            :      // Create a Body that represents the torus
     734                 :         33 :    BodySM* bodyPtr = gmeList.get()->torus(r1, r2) ;
     735                 :         33 :    Body *new_body = NULL;
     736                 :            : 
     737         [ -  + ]:         33 :    if (bodyPtr == NULL)
     738                 :            :    {
     739         [ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::torus\n"
     740         [ #  # ]:          0 :                   "       Problems building a volume from the torus.\n") ;
     741                 :            :    }
     742                 :            :    else
     743                 :         33 :      new_body = GeometryQueryTool::instance()->make_Body(bodyPtr);
     744                 :            : 
     745         [ -  + ]:         33 :   if( CubitUndo::get_undo_enabled() )
     746                 :            :   {
     747         [ #  # ]:          0 :     if( new_body )
     748                 :          0 :       CubitUndo::note_result_body( new_body );
     749                 :            :     else
     750                 :          0 :       CubitUndo::remove_last_undo();
     751                 :            :   }
     752                 :            : 
     753                 :         33 :    return new_body;
     754                 :            : }
     755                 :            : 
     756                 :            : //-------------------------------------------------------------------------
     757                 :            : // Purpose       : Creates a planar sheet with the given corner locations.
     758                 :            : //
     759                 :            : // Special Notes :
     760                 :            : //
     761                 :            : // Creator       : Steve Storm
     762                 :            : //
     763                 :            : // Creation Date : 05/10/05
     764                 :            : //-------------------------------------------------------------------------
     765                 :         22 : Body* GeometryModifyTool::planar_sheet( const CubitVector& p1,
     766                 :            :                                         const CubitVector& p2,
     767                 :            :                                         const CubitVector& p3,
     768                 :            :                                         const CubitVector& p4 )
     769                 :            : {
     770         [ -  + ]:         22 :    if (0 == gmeList.size())
     771                 :            :    {
     772 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
     773                 :          0 :       return NULL;
     774                 :            :    }
     775                 :            : 
     776         [ -  + ]:         22 :    if( CubitUndo::get_undo_enabled() )
     777                 :          0 :      CubitUndo::save_state();
     778                 :            : 
     779                 :            :   // Create a Body that represents the sheet
     780                 :         22 :   BodySM* body_ptr = gmeList.get()->planar_sheet(p1, p2, p3, p4) ;
     781                 :         22 :   Body *new_body = NULL;
     782         [ -  + ]:         22 :   if( body_ptr == NULL )
     783                 :            :   {
     784         [ #  # ]:          0 :     PRINT_ERROR("In GeometryTool::planar_sheet\n"
     785         [ #  # ]:          0 :       "       Problems building a volume from the sheet.\n") ;
     786                 :            :   }
     787                 :            :   else
     788                 :         22 :     new_body = GeometryQueryTool::instance()->make_Body(body_ptr);
     789                 :            : 
     790         [ -  + ]:         22 :   if( CubitUndo::get_undo_enabled() )
     791                 :            :   {
     792         [ #  # ]:          0 :     if( new_body )
     793                 :          0 :       CubitUndo::note_result_body( new_body );
     794                 :            :     else
     795                 :          0 :       CubitUndo::remove_last_undo();
     796                 :            :   }
     797                 :            : 
     798                 :         22 :   return new_body;
     799                 :            : }
     800                 :            : 
     801                 :            : //-------------------------------------------------------------------------
     802                 :            : // Purpose       : Creates a planar sheet with the given input location,
     803                 :            : //                 orientation and size.
     804                 :            : //
     805                 :            : // Special Notes :
     806                 :            : //
     807                 :            : // Creator       : Steve Storm
     808                 :            : //
     809                 :            : // Creation Date : 10/09/00
     810                 :            : //-------------------------------------------------------------------------
     811                 :         11 : Body* GeometryModifyTool::planar_sheet ( const CubitVector &center,
     812                 :            :                                          const CubitVector axes[2],
     813                 :            :                                          double width, double height )
     814                 :            : {
     815 [ +  - ][ -  + ]:         11 :    if (0 == gmeList.size())
     816                 :            :    {
     817 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
     818                 :          0 :       return NULL;
     819                 :            :    }
     820                 :            : 
     821 [ +  - ][ +  - ]:         11 :    CubitVector p1, p2, p3, p4;
         [ +  - ][ +  - ]
     822                 :            : 
     823                 :            :    // Get the corners of the sheet
     824         [ +  - ]:         11 :    center.next_point( axes[0], width/2.0, p1 );
     825         [ +  - ]:         11 :    p1.next_point( axes[1], -height/2.0, p1 );
     826         [ +  - ]:         11 :    p1.next_point( axes[1], height, p2 );
     827         [ +  - ]:         11 :    p2.next_point( axes[0], -width, p3 );
     828         [ +  - ]:         11 :    p3.next_point( axes[1], -height, p4 );
     829                 :            : 
     830 [ +  - ][ -  + ]:         11 :    if( CubitUndo::get_undo_enabled() )
     831         [ #  # ]:          0 :      CubitUndo::save_state();
     832                 :            : 
     833                 :            :    // Create a Body that represents the sheet
     834 [ +  - ][ +  - ]:         11 :    BodySM* body_ptr = gmeList.get()->planar_sheet(p1, p2, p3, p4) ;
     835                 :         11 :    Body *new_body = NULL;
     836                 :            : 
     837         [ -  + ]:         11 :    if( body_ptr == NULL )
     838                 :            :    {
     839 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("In GeometryTool::planar_sheet\n"
                 [ #  # ]
     840         [ #  # ]:          0 :          "       Problems building a volume from the sheet.\n") ;
     841                 :            :    }
     842                 :            :    else
     843 [ +  - ][ +  - ]:         11 :      new_body = GeometryQueryTool::instance()->make_Body(body_ptr);
     844                 :            : 
     845 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
     846                 :            :   {
     847         [ #  # ]:          0 :     if( new_body )
     848         [ #  # ]:          0 :       CubitUndo::note_result_body( new_body );
     849                 :            :     else
     850         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
     851                 :            :   }
     852                 :            : 
     853                 :         11 :   return new_body;
     854                 :            : }
     855                 :            : 
     856                 :            : //-------------------------------------------------------------------------
     857                 :            : // Purpose       : Creates a planar sheet with the minimal amount of area
     858                 :            : //                 to cut through the given 3D bounding box.  The sheet
     859                 :            : //                 can be extended optionally to make it larger than this
     860                 :            : //                 minimal size.
     861                 :            : //
     862                 :            : // Special Notes : extension_types: 0-none, 1-percentage, 2-absolute
     863                 :            : //
     864                 :            : // Creator       : Steve Storm
     865                 :            : //
     866                 :            : // Creation Date : 10/19/98
     867                 :            : //-------------------------------------------------------------------------
     868                 :          0 : Body* GeometryModifyTool::planar_sheet ( const CubitPlane& plane,
     869                 :            :                                          const CubitBox& bounding_box,
     870                 :            :                                          int extension_type,
     871                 :            :                                          double extension )
     872                 :            : {
     873 [ #  # ][ #  # ]:          0 :    if (0 == gmeList.size())
     874                 :            :    {
     875 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
     876                 :          0 :       return NULL;
     877                 :            :    }
     878                 :            : 
     879 [ #  # ][ #  # ]:          0 :    CubitVector p1, p2, p3, p4;
         [ #  # ][ #  # ]
     880                 :            : 
     881                 :            :    // Get the corners of the sheet
     882         [ #  # ]:          0 :    if( AnalyticGeometryTool::instance()->
     883                 :            :       min_pln_box_int_corners( plane, bounding_box, extension_type,
     884 [ #  # ][ #  # ]:          0 :                                extension, p1, p2, p3, p4 ) == CUBIT_FAILURE )
     885                 :          0 :       return NULL;
     886                 :            : 
     887 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
     888         [ #  # ]:          0 :      CubitUndo::save_state();
     889                 :            : 
     890                 :            :    // Create a Body that represents the sheet
     891 [ #  # ][ #  # ]:          0 :    BodySM* body_ptr = gmeList.get()->planar_sheet(p1, p2, p3, p4) ;
     892                 :          0 :    Body *new_body = NULL;
     893                 :            : 
     894         [ #  # ]:          0 :    if( body_ptr == NULL )
     895                 :            :    {
     896 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("In GeometryModifyTool::planar_sheet\n"
                 [ #  # ]
     897         [ #  # ]:          0 :          "       Problems building a volume from the sheet.\n") ;
     898                 :            :    }
     899                 :            :    else
     900 [ #  # ][ #  # ]:          0 :      new_body = GeometryQueryTool::instance()->make_Body(body_ptr);
     901                 :            : 
     902 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
     903                 :            :    {
     904         [ #  # ]:          0 :      if( new_body )
     905         [ #  # ]:          0 :        CubitUndo::note_result_body( new_body );
     906                 :            :      else
     907         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
     908                 :            :    }
     909                 :            : 
     910                 :          0 :    return new_body;
     911                 :            : }
     912                 :            : 
     913                 :          0 : Body* GeometryModifyTool::create_body( VolumeFacets& volume, std::map<FacetShapes*, RefEntity*>& entity_map,
     914                 :            :                                        const FacetPointSet& points, int interp_order)
     915                 :            : {
     916         [ #  # ]:          0 :   GeometryModifyEngine* engine = gmeList.get();
     917 [ #  # ][ #  # ]:          0 :   if (!engine->supports_facets())
     918                 :          0 :     return NULL;
     919                 :            : 
     920                 :          0 :   Body* new_body = NULL;
     921                 :            : 
     922 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
     923         [ #  # ]:          0 :      CubitUndo::save_state();
     924                 :            : 
     925         [ #  # ]:          0 :   std::map<FacetShapes*, GeometryEntity*> geom_entity_map;
     926         [ #  # ]:          0 :   BodySM* body_sm = engine->create_body(volume, geom_entity_map, points, interp_order);
     927         [ #  # ]:          0 :   if(body_sm)
     928                 :            :   {
     929 [ #  # ][ #  # ]:          0 :     new_body = GeometryQueryTool::instance()->make_Body(body_sm);
     930                 :            :     // map information back to caller
     931         [ #  # ]:          0 :     std::map<FacetShapes*, GeometryEntity*>::iterator geom_iter;
     932 [ #  # ][ #  # ]:          0 :     for (geom_iter = geom_entity_map.begin(); geom_iter != geom_entity_map.end(); geom_iter++)
         [ #  # ][ #  # ]
                 [ #  # ]
     933 [ #  # ][ #  # ]:          0 :       entity_map[geom_iter->first] = dynamic_cast<RefEntity*>(geom_iter->second->topology_entity());
         [ #  # ][ #  # ]
                 [ #  # ]
     934                 :            :   }
     935                 :            : 
     936 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
     937                 :            :   {
     938         [ #  # ]:          0 :     if( new_body )
     939         [ #  # ]:          0 :       CubitUndo::note_result_body( new_body );
     940                 :            :     else
     941         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
     942                 :            :   }
     943                 :            : 
     944         [ #  # ]:          0 :   return new_body;
     945                 :            : }
     946                 :            : 
     947                 :          0 : RefVertex* GeometryModifyTool::make_RefVertex( RefVertex *vertex ) const
     948                 :            : {
     949         [ #  # ]:          0 :   if ( vertex == NULL )
     950                 :            :   {
     951 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Vertex is NULL\n");
         [ #  # ][ #  # ]
     952                 :          0 :     return NULL;
     953                 :            :   }
     954                 :            : 
     955                 :          0 :   TopologyBridge* bridge = 0;
     956         [ #  # ]:          0 :   GeometryModifyEngine* engine = get_engine(vertex, &bridge);
     957         [ #  # ]:          0 :   if (engine == NULL)
     958                 :            :   {
     959 [ #  # ][ #  # ]:          0 :      PRINT_ERROR( "%s (vertex %d) does not have a modify engine.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     960                 :            :                   vertex->entity_name().c_str(),
     961         [ #  # ]:          0 :                   vertex->id() );
     962                 :          0 :      return 0;
     963                 :            :   }
     964                 :            : 
     965         [ #  # ]:          0 :   CubitVector point = vertex->coordinates();
     966                 :            : 
     967                 :            :   // Call the default GeometryModifyEngine to create a new TBPoint
     968         [ #  # ]:          0 :   TBPoint* point_ptr = engine->make_Point(point);
     969                 :            : 
     970 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
     971         [ #  # ]:          0 :     CubitUndo::save_state();
     972                 :            : 
     973                 :            :   // Use the TBPoint to create a RefVertex
     974 [ #  # ][ #  # ]:          0 :   RefVertex* ref_vertex_ptr = RefEntityFactory::instance()->construct_RefVertex(point_ptr) ;
     975                 :            : 
     976 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
     977                 :            :   {
     978         [ #  # ]:          0 :     if( ref_vertex_ptr )
     979 [ #  # ][ #  # ]:          0 :       CubitUndo::note_result_entity( ref_vertex_ptr );
     980                 :            :     else
     981         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
     982                 :            :   }
     983                 :            : 
     984                 :            :   //transfer the names
     985         [ #  # ]:          0 :   DLIList<CubitString> names;
     986         [ #  # ]:          0 :   vertex->entity_names( names );
     987                 :            : 
     988                 :            :   int i;
     989 [ #  # ][ #  # ]:          0 :   for( i=names.size(); i--; )
     990                 :            :   {
     991 [ #  # ][ #  # ]:          0 :     CubitString tmp_name = names.get_and_step();
     992 [ #  # ][ #  # ]:          0 :     ref_vertex_ptr->entity_name( tmp_name );
                 [ #  # ]
     993         [ #  # ]:          0 :   }
     994                 :            : 
     995                 :            :   // Send a message to the model indicating the vertex was created
     996 [ #  # ][ #  # ]:          0 :   AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::FREE_REF_ENTITY_GENERATED, ref_vertex_ptr));
         [ #  # ][ #  # ]
                 [ #  # ]
     997                 :            : 
     998                 :            :   // Return the newly created RefVertex
     999         [ #  # ]:          0 :   return ref_vertex_ptr ;
    1000                 :            : }
    1001                 :            : 
    1002                 :            : 
    1003                 :            : //-------------------------------------------------------------------------
    1004                 :            : // Purpose       : This function takes a type information and a location
    1005                 :            : //                 to create a RefVertex. The underlying representation
    1006                 :            : //                 of the RefVertex is determined by the default
    1007                 :            : //                 GeometryModifyEngine.
    1008                 :            : //
    1009                 :            : // Special Notes :
    1010                 :            : //
    1011                 :            : // Creator       : Raikanta Sahu
    1012                 :            : //
    1013                 :            : // Creation Date : 03/27/97
    1014                 :            : //-------------------------------------------------------------------------
    1015                 :            : 
    1016                 :        121 : RefVertex* GeometryModifyTool::make_RefVertex(
    1017                 :            :                                         CubitVector const& point, int color) const
    1018                 :            : {
    1019         [ -  + ]:        121 :    if (0 == gmeList.size())
    1020                 :            :    {
    1021 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No active geometry engine.\n");
    1022                 :          0 :       return NULL;
    1023                 :            :    }
    1024                 :            : 
    1025                 :            :      // Call the default GeometryModifyEngine to create a new TBPoint
    1026                 :        121 :    TBPoint* point_ptr = gmeList.get()->make_Point(point);
    1027                 :            : 
    1028                 :            :      // If we get a NULL pointer, give a warning message and return
    1029                 :            :      // a NULL pointer.
    1030         [ -  + ]:        121 :    if ( point_ptr == NULL )
    1031                 :            :    {
    1032         [ #  # ]:          0 :       PRINT_WARNING("In GeometryModifyTool::make_RefVertex\n"
    1033                 :            :                     "         Got a NULL pointer to a TBPoint.\n"
    1034         [ #  # ]:          0 :                     "         Cannot make a RefVertex.\n") ;
    1035                 :          0 :       return (RefVertex *)NULL ;
    1036                 :            :    }
    1037                 :            : 
    1038         [ -  + ]:        121 :    if( CubitUndo::get_undo_enabled() )
    1039                 :          0 :      CubitUndo::save_state();
    1040                 :            : 
    1041                 :            :      // Use the TBPoint to create a RefVertex
    1042                 :        121 :    RefVertex* ref_vertex_ptr = RefEntityFactory::instance()->construct_RefVertex(point_ptr) ;
    1043                 :            : 
    1044         [ -  + ]:        121 :   if( CubitUndo::get_undo_enabled() )
    1045                 :            :   {
    1046         [ #  # ]:          0 :     if( ref_vertex_ptr )
    1047         [ #  # ]:          0 :       CubitUndo::note_result_entity( ref_vertex_ptr );
    1048                 :            :     else
    1049                 :          0 :       CubitUndo::remove_last_undo();
    1050                 :            :   }
    1051                 :            : 
    1052                 :        121 :    ref_vertex_ptr->color(color);
    1053                 :            : 
    1054                 :            :      // Send a message to the model indicating the vertex was created
    1055 [ +  - ][ +  - ]:        121 :    AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::FREE_REF_ENTITY_GENERATED, ref_vertex_ptr));
                 [ +  - ]
    1056                 :            : 
    1057                 :            :      // Return the newly created RefVertex
    1058                 :        121 :    return ref_vertex_ptr ;
    1059                 :            : }
    1060                 :            : 
    1061                 :         11 : Body *GeometryModifyTool::make_Body(Surface *surface) const
    1062                 :            : {
    1063                 :            :   // make a Body from a Surface
    1064                 :         11 :   BodySM *body_sm = surface->bodysm();
    1065                 :            : 
    1066                 :         11 :   GeometryModifyEngine* gme = get_engine(surface);
    1067                 :            : 
    1068 [ +  - ][ -  + ]:         11 :   if (gme && !body_sm)
    1069                 :          0 :     body_sm = gme->make_BodySM(surface);
    1070                 :            : 
    1071         [ -  + ]:         11 :   assert(body_sm != 0);
    1072                 :            : 
    1073                 :         11 :   return GeometryQueryTool::instance()->make_Body(body_sm);
    1074                 :            : }
    1075                 :            : 
    1076                 :            : //-------------------------------------------------------------------------
    1077                 :            : // Purpose       : This function takes RefEdge type information, too
    1078                 :            : //
    1079                 :            : // Creator       : David White
    1080                 :            : //
    1081                 :            : // Creation Date : 10/9/97
    1082                 :            : //-------------------------------------------------------------------------
    1083                 :          0 : RefEdge* GeometryModifyTool::make_RefEdge(RefEdge *ref_edge_ptr,
    1084                 :            :                                           bool copy_attribs,
    1085                 :            :                                           std::map< RefEntity*, RefEntity* > *old_to_new_map ) const
    1086                 :            : {
    1087         [ #  # ]:          0 :   if ( ref_edge_ptr == NULL )
    1088                 :            :   {
    1089 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("curve is NULL\n");
         [ #  # ][ #  # ]
    1090                 :          0 :     return (RefEdge*)NULL;
    1091                 :            :   }
    1092                 :            : 
    1093                 :          0 :   TopologyBridge* bridge = 0;
    1094         [ #  # ]:          0 :   GeometryModifyEngine* engine = get_engine(ref_edge_ptr, &bridge);
    1095         [ #  # ]:          0 :   Curve *old_curve = dynamic_cast<Curve*>(bridge);
    1096         [ #  # ]:          0 :   if (engine == NULL)
    1097                 :            :   {
    1098 [ #  # ][ #  # ]:          0 :      PRINT_ERROR( "%s (curve %d) does not have a modify engine.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1099                 :            :                   ref_edge_ptr->entity_name().c_str(),
    1100         [ #  # ]:          0 :                   ref_edge_ptr->id() );
    1101                 :          0 :      return 0;
    1102                 :            :   }
    1103                 :            : 
    1104                 :            :   Curve *tmp_curve;
    1105         [ #  # ]:          0 :   if( copy_attribs )
    1106                 :            :   {
    1107         [ #  # ]:          0 :     DLIList<RefEntity*> tmp_list;
    1108 [ #  # ][ #  # ]:          0 :     tmp_list.append( ref_edge_ptr );
    1109                 :            :     TopologyBridge *curve_bridge;
    1110 [ #  # ][ #  # ]:          0 :     prepare_for_copy( ref_edge_ptr, curve_bridge );
    1111 [ #  # ][ #  # ]:          0 :     tmp_curve = CAST_TO( curve_bridge, Curve);
    1112                 :            :   }
    1113                 :            :   else
    1114                 :          0 :     tmp_curve = old_curve;
    1115                 :            : 
    1116         [ #  # ]:          0 :   std::map<TopologyBridge*, TopologyBridge*> old_tb_to_new_tb;
    1117                 :          0 :   Curve *new_curve = NULL;
    1118         [ #  # ]:          0 :   if( old_to_new_map )
    1119         [ #  # ]:          0 :     new_curve = engine->make_Curve( tmp_curve, &old_tb_to_new_tb );
    1120                 :            :   else 
    1121         [ #  # ]:          0 :     new_curve = engine->make_Curve( tmp_curve );
    1122                 :            : 
    1123         [ #  # ]:          0 :   if (!new_curve)
    1124                 :            :   {
    1125         [ #  # ]:          0 :     if( copy_attribs )
    1126         [ #  # ]:          0 :       clean_up_from_copy_failure( old_curve );
    1127                 :          0 :     return (RefEdge *)NULL;
    1128                 :            :   }
    1129                 :            : 
    1130                 :            :   TopologyBridge *new_curve_bridge;
    1131         [ #  # ]:          0 :   if( copy_attribs )
    1132                 :            :   {
    1133                 :          0 :     new_curve_bridge = new_curve;
    1134         [ #  # ]:          0 :     finish_copy( new_curve_bridge, old_curve );
    1135         [ #  # ]:          0 :     new_curve = CAST_TO( new_curve_bridge, Curve);
    1136                 :            :   }
    1137                 :            : 
    1138 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    1139         [ #  # ]:          0 :     CubitUndo::save_state();
    1140                 :            : 
    1141                 :            :   // Complete the task of linking this new Curve into the rest of the
    1142                 :            :   // geometry datastructures and return the new RefEdge.
    1143 [ #  # ][ #  # ]:          0 :   RefEdge *new_ref_edge = GeometryQueryTool::instance()->make_free_RefEdge(new_curve);
    1144                 :            : 
    1145         [ #  # ]:          0 :   if( old_to_new_map )
    1146         [ #  # ]:          0 :      create_old_to_new_ref_ent_map( old_curve, new_curve, *old_to_new_map, old_tb_to_new_tb );
    1147                 :            : 
    1148 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    1149 [ #  # ][ #  # ]:          0 :     CubitUndo::note_result_entity( new_ref_edge );
    1150                 :            : 
    1151         [ #  # ]:          0 :   return new_ref_edge;
    1152                 :            : }
    1153                 :            : 
    1154                 :        199 : CubitStatus GeometryModifyTool::prepare_for_copy( RefEntity *ref_ent,
    1155                 :            :                                                   TopologyBridge *&top_bridge )
    1156                 :            : {
    1157                 :            :   //save attribute settings
    1158 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->save_current_attribute_states();
    1159                 :            : 
    1160 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->auto_flag(1);
                 [ +  - ]
    1161                 :            :   // Groups are saved directly in the Cubit file, not with attributes
    1162 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_GROUP, CUBIT_FALSE);
                 [ +  - ]
    1163 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_GROUP, CUBIT_FALSE);
                 [ +  - ]
    1164 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_GROUP, CUBIT_FALSE);
                 [ +  - ]
    1165 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_GROUP, CUBIT_FALSE);
                 [ +  - ]
    1166                 :            : 
    1167                 :            :   // The mesh container is only used for the Exodus save/resore method
    1168 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_MESH_CONTAINER, CUBIT_FALSE);
                 [ +  - ]
    1169 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_MESH_CONTAINER, CUBIT_FALSE);
                 [ +  - ]
    1170 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_MESH_CONTAINER, CUBIT_FALSE);
                 [ +  - ]
    1171 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_MESH_CONTAINER, CUBIT_FALSE);
                 [ +  - ]
    1172                 :            : 
    1173                 :            :   // Genesis Entities are saved directly in the Cubit file, not with attributes
    1174 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_GENESIS_ENTITY, CUBIT_FALSE);
                 [ +  - ]
    1175 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_GENESIS_ENTITY, CUBIT_FALSE);
                 [ +  - ]
    1176 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_GENESIS_ENTITY, CUBIT_FALSE);
                 [ +  - ]
    1177 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_GENESIS_ENTITY, CUBIT_FALSE);
                 [ +  - ]
    1178                 :            : 
    1179                 :            :   //Don't save out entity ids
    1180 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_ENTITY_ID, CUBIT_FALSE);
                 [ +  - ]
    1181 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_ENTITY_ID, CUBIT_FALSE);
                 [ +  - ]
    1182 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_ENTITY_ID, CUBIT_FALSE);
                 [ +  - ]
    1183 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_ENTITY_ID, CUBIT_FALSE);
                 [ +  - ]
    1184                 :            : 
    1185                 :            :   //Don't save out graphics
    1186 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_GRAPHICS_OPTS, CUBIT_FALSE);
                 [ +  - ]
    1187 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_GRAPHICS_OPTS, CUBIT_FALSE);
                 [ +  - ]
    1188 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_GRAPHICS_OPTS, CUBIT_FALSE);
                 [ +  - ]
    1189 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_GRAPHICS_OPTS, CUBIT_FALSE);
                 [ +  - ]
    1190                 :            : 
    1191                 :            :   //Flag to say "we're copying" attributes
    1192                 :        199 :   copyingEntity = ref_ent;
    1193                 :            : 
    1194                 :            :   //Get all children
    1195         [ +  - ]:        199 :   DLIList<RefEntity*> child_list;
    1196         [ +  - ]:        199 :   ref_ent->get_all_child_ref_entities( child_list );
    1197                 :            : 
    1198                 :            :   //Puts attributes on all the entities
    1199         [ +  - ]:        199 :   child_list.append( ref_ent );
    1200         [ +  - ]:        199 :   CubitAttribUser::auto_update_cubit_attrib( child_list );
    1201                 :            : 
    1202                 :            :   //Prepare virtual
    1203         [ -  + ]:        199 :   TopologyEntity *topo_ptr = dynamic_cast<TopologyEntity*>( ref_ent );
    1204 [ +  - ][ +  - ]:        199 :   top_bridge = topo_ptr->bridge_manager()->topology_bridge();
    1205 [ +  - ][ +  - ]:        398 :   DLIList<TopologyBridge*> bridge_list;
    1206         [ +  - ]:        199 :   bridge_list.append( top_bridge );
    1207 [ +  - ][ +  - ]:        199 :   GeometryQueryTool::instance()->ige_export_geom( bridge_list );
    1208                 :            : 
    1209                 :            :   //Should only have 1 bridge in the list
    1210 [ +  - ][ -  + ]:        199 :   assert( bridge_list.size() == 1 );
    1211         [ +  - ]:        199 :   TopologyBridge *tmp_bridge_after = bridge_list.get();
    1212         [ -  + ]:        199 :   if( top_bridge != tmp_bridge_after)
    1213                 :          0 :     top_bridge = tmp_bridge_after;
    1214                 :            : 
    1215                 :            :   //Done copying attributes
    1216                 :        199 :   copyingEntity = NULL;
    1217                 :            : 
    1218         [ +  - ]:        199 :   return CUBIT_SUCCESS;
    1219                 :            : 
    1220                 :            : }
    1221                 :            : 
    1222                 :          0 : CubitStatus GeometryModifyTool::clean_up_from_copy_failure( TopologyBridge *old_bridge )
    1223                 :            : {
    1224                 :            :   //Remove attributes on underlying entities of virtual geometry
    1225                 :            :   //entities which do not have corresponding RefEntities.
    1226         [ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list;
    1227         [ #  # ]:          0 :   bridge_list.append( old_bridge );
    1228 [ #  # ][ #  # ]:          0 :   GeometryQueryTool::instance()->ige_remove_attributes( bridge_list );
    1229                 :            : 
    1230                 :            :   //Remove attributes on original entity and children
    1231 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> child_list;
    1232 [ #  # ][ #  # ]:          0 :   RefEntity *ref_ent = CAST_TO( old_bridge->topology_entity(), RefEntity );
    1233         [ #  # ]:          0 :   ref_ent->get_all_child_ref_entities( child_list );
    1234                 :            :   //child_list.append( ref_ent );
    1235         [ #  # ]:          0 :   CubitAttribUser::clear_all_simple_attrib( child_list );
    1236         [ #  # ]:          0 :   child_list.clean_out();
    1237         [ #  # ]:          0 :   child_list.append( ref_ent );
    1238         [ #  # ]:          0 :   CubitAttribUser::clear_all_simple_attrib( child_list );
    1239                 :            : 
    1240 [ #  # ][ #  # ]:          0 :   CGMApp::instance()->restore_previous_attribute_states();
    1241                 :            : 
    1242         [ #  # ]:          0 : return CUBIT_SUCCESS;
    1243                 :            : }
    1244                 :            : 
    1245                 :        199 : CubitStatus GeometryModifyTool::finish_copy( TopologyBridge *&new_bridge,
    1246                 :            :                                              TopologyBridge *old_bridge )
    1247                 :            : {
    1248                 :            :   //Remove attributes on underlying entities of virtual geometry
    1249                 :            :   //entities which do not have corresponding RefEntities.
    1250         [ +  - ]:        199 :   DLIList<TopologyBridge*> bridge_list;
    1251         [ +  - ]:        199 :   bridge_list.append( old_bridge );
    1252 [ +  - ][ +  - ]:        199 :   GeometryQueryTool::instance()->ige_remove_attributes( bridge_list );
    1253                 :            : 
    1254                 :            :   //Remove attributes on original entity and children
    1255 [ +  - ][ +  - ]:        398 :   DLIList<RefEntity*> child_list;
    1256 [ +  - ][ -  + ]:        199 :   RefEntity *ref_ent = CAST_TO( old_bridge->topology_entity(), RefEntity );
    1257         [ +  - ]:        199 :   ref_ent->get_all_child_ref_entities( child_list );
    1258                 :            :   //child_list.append( ref_ent );
    1259         [ +  - ]:        199 :   CubitAttribUser::clear_all_simple_attrib( child_list );
    1260         [ +  - ]:        199 :   child_list.clean_out();
    1261         [ +  - ]:        199 :   child_list.append( ref_ent );
    1262         [ +  - ]:        199 :   CubitAttribUser::clear_all_simple_attrib( child_list );
    1263                 :            : 
    1264                 :            : 
    1265                 :            :   //Restore virtual
    1266                 :            :   //Could create virtual geometry here so the Topology Bridge can change
    1267         [ +  - ]:        199 :   bridge_list.clean_out();
    1268         [ +  - ]:        199 :   bridge_list.append( new_bridge );
    1269                 :        199 :   TopologyBridge *tmp_bridge_before = new_bridge;
    1270 [ +  - ][ +  - ]:        199 :   GeometryQueryTool::instance()->ige_import_geom( bridge_list );
    1271 [ +  - ][ -  + ]:        199 :   assert( bridge_list.size() == 1 );
    1272 [ +  - ][ -  + ]:        199 :   if( tmp_bridge_before != bridge_list.get() )
    1273         [ #  # ]:          0 :     new_bridge = bridge_list.get();
    1274                 :            : 
    1275                 :            :   //make the RefEntities
    1276                 :        199 :   Curve *curve = NULL;
    1277                 :        199 :   Surface *surface = NULL;
    1278                 :        199 :   Lump *lump = NULL;
    1279                 :        199 :   BodySM *body = NULL;
    1280                 :            : 
    1281                 :        199 :   RefEntity *new_ref_ent = NULL;
    1282 [ -  + ][ -  + ]:        199 :   if( (curve = CAST_TO( new_bridge, Curve ) ) != NULL )
    1283 [ #  # ][ #  # ]:          0 :     new_ref_ent = GeometryQueryTool::instance()->make_RefEdge( curve );
                 [ #  # ]
    1284 [ -  + ][ +  + ]:        199 :   else if( (surface = CAST_TO( new_bridge, Surface) ) != NULL )
    1285 [ +  - ][ +  - ]:         11 :     new_ref_ent = GeometryQueryTool::instance()->make_RefFace( surface );
                 [ +  - ]
    1286 [ -  + ][ -  + ]:        188 :   else if( (lump = CAST_TO( new_bridge, Lump) ) != NULL )
    1287 [ #  # ][ #  # ]:          0 :     new_ref_ent = GeometryQueryTool::instance()->make_Body( lump->bodysm() );
         [ #  # ][ #  # ]
    1288 [ -  + ][ +  - ]:        188 :   else if( (body = CAST_TO( new_bridge, BodySM) ) != NULL )
    1289 [ +  - ][ +  - ]:        188 :     new_ref_ent = GeometryQueryTool::instance()->make_Body( body );
                 [ +  - ]
    1290                 :            : 
    1291                 :            :   //actuate the attributes on everything
    1292         [ +  - ]:        199 :   child_list.clean_out();
    1293         [ +  - ]:        199 :   new_ref_ent->get_all_child_ref_entities( child_list );
    1294         [ +  - ]:        199 :   child_list.append( new_ref_ent );
    1295         [ +  - ]:        199 :   GeometryQueryTool::import_actuate( child_list );
    1296                 :            : 
    1297                 :            :   //Remove attributes on new entity and children
    1298         [ +  - ]:        199 :   child_list.clean_out();
    1299         [ +  - ]:        199 :   new_ref_ent->get_all_child_ref_entities( child_list );
    1300         [ +  - ]:        199 :   CubitAttribUser::clear_all_simple_attrib( child_list );
    1301         [ +  - ]:        199 :   child_list.clean_out();
    1302         [ +  - ]:        199 :   child_list.append( new_ref_ent );
    1303         [ +  - ]:        199 :   CubitAttribUser::clear_all_simple_attrib( child_list );
    1304                 :            : 
    1305 [ +  - ][ +  - ]:        199 :   CGMApp::instance()->restore_previous_attribute_states();
    1306         [ +  - ]:        199 :   return CUBIT_SUCCESS;
    1307                 :            : }
    1308                 :            : #ifdef PROE
    1309                 :            : CubitStatus GeometryModifyTool::prepare_for_topology_update( BodySM* old_bodysm )
    1310                 :            : {
    1311                 :            :   DLIList<BodySM*> old_bodysms;
    1312                 :            :   old_bodysms.append(old_bodysm);
    1313                 :            : 
    1314                 :            :   do_attribute_setup();
    1315                 :            :   push_attributes_before_modify( old_bodysms );
    1316                 :            : 
    1317                 :            :   return CUBIT_SUCCESS;
    1318                 :            : }
    1319                 :            : CubitStatus GeometryModifyTool::finish_topology_update( BodySM* new_bodysm,
    1320                 :            :                                                         Body* old_body )
    1321                 :            : {
    1322                 :            :   DLIList<Body*> input_bodies,result_bodies;
    1323                 :            :   DLIList<BodySM*> new_bodysms, old_bodysms;
    1324                 :            :   input_bodies.append(old_body);
    1325                 :            :   new_bodysms.append(new_bodysm);
    1326                 :            :   old_bodysms.clean_out();
    1327                 :            : 
    1328                 :            :   DLIList<int> merged_surface_ids;
    1329                 :            :   DLIList<int> merged_curve_ids;
    1330                 :            : 
    1331                 :            : 
    1332                 :            :   get_merged_curve_and_surface_ids( input_bodies, merged_surface_ids, merged_curve_ids );
    1333                 :            :   ///*
    1334                 :            :   //Store information about what surfaces were originally merged
    1335                 :            :   //
    1336                 :            :   //This fixes a problem caused by the lack of support
    1337                 :            :   //for automatically remerging surfaces that contain any
    1338                 :            :   //virtual geometry.
    1339                 :            :   //This should be removed if this issue is ever fixed - AHH
    1340                 :            :   std::map< int , DLIList<Surface*> > merged_map;
    1341                 :            :   for(int i=0; i< merged_surface_ids.size(); i++ )
    1342                 :            :     {
    1343                 :            :     int refface_id = merged_surface_ids.get_and_step();
    1344                 :            :     RefFace* old_merged_refface = RefEntityFactory::instance()->get_ref_face( refface_id );
    1345                 :            :     if( old_merged_refface && old_merged_refface->bridge_manager()->number_of_bridges() > 1 )
    1346                 :            :       {
    1347                 :            :       DLIList<Surface*> merged_surfsms;
    1348                 :            :       DLIList<TopologyBridge*> bridge_list;
    1349                 :            :       old_merged_refface->bridge_manager()->get_bridge_list( bridge_list );
    1350                 :            :       for(int j=0; j< bridge_list.size(); j++ )
    1351                 :            :         {
    1352                 :            :         Surface* merging_surf = CAST_TO(bridge_list.get_and_step(),Surface);
    1353                 :            :         if( merging_surf )
    1354                 :            :           merged_surfsms.append_unique( merging_surf );
    1355                 :            :         }
    1356                 :            :       merged_map[ refface_id ] = merged_surfsms;
    1357                 :            :       }
    1358                 :            :     }
    1359                 :            :   //*/
    1360                 :            :   /*
    1361                 :            :   //check to see if any curves have been orphaned inside virtual geometry
    1362                 :            :   DLIList<TBPoint*> point_list;
    1363                 :            :   new_bodysm->points( point_list );
    1364                 :            :   CubitBoolean loop = CUBIT_TRUE;
    1365                 :            :   while( loop )
    1366                 :            :     {
    1367                 :            :     for(i=0; i< point_list.size(); i++)
    1368                 :            :       {
    1369                 :            :       //loop all the points and see if any will be on only one live curve
    1370                 :            :       TBPoint* curr_point = point_list.get_and_step();
    1371                 :            :       DLIList<Curve*> curves_on_point;
    1372                 :            :       DLIList<Curve*> curves_to_keep;
    1373                 :            :       curr_point->curves( curves_on_point );
    1374                 :            :       for(int j=0; j< curves_on_point.size(); j++)
    1375                 :            :         {
    1376                 :            :         Curve* curr_curve = curves_on_point.get_and_step();
    1377                 :            :         DLIList<CubitSimpleAttrib*> attrib_list;
    1378                 :            :         CubitSimpleAttrib* attrib = CompositeEngine::find_attribute_by_name( curr_curve, "COMPOSITE_GEOM" );
    1379                 :            :         if( attrib )
    1380                 :            :           {
    1381                 :            :           attrib_list.append(attrib);
    1382                 :            :           }
    1383                 :            :         else
    1384                 :            :           curves_to_keep.append_unique( curr_curve );
    1385                 :            :         //curr_curve->get_simple_attribute( "COMPOSITE_GEOM", attrib_list );
    1386                 :            :         //if ( !attrib_list.size() )
    1387                 :            :           //curves_to_keep.append_unique( curr_curve );
    1388                 :            :         }
    1389                 :            :       //if all but one curve on this point will be removed we need to remove the other one too
    1390                 :            :       if( curves_to_keep.size() == 1 )
    1391                 :            :         {
    1392                 :            :         CubitString name("COMPOSITE_GEOM");
    1393                 :            :         DLIList<CubitString*> string_list;
    1394                 :            :         string_list.append( &name );
    1395                 :            :         CubitSimpleAttrib geom_attrib( &string_list, 0, 0 );
    1396                 :            :         curves_to_keep.get()->append_simple_attribute_virt( &geom_attrib );
    1397                 :            :         curr_point->append_simple_attribute_virt( &geom_attrib );
    1398                 :            :         loop = CUBIT_FALSE;
    1399                 :            :         }
    1400                 :            :       else if( curves_to_keep.size() == 0 )
    1401                 :            :         {
    1402                 :            :         DLIList<CubitSimpleAttrib*> attrib_list;
    1403                 :            :         curr_point->get_simple_attribute( "COMPOSIT_GEOM", attrib_list );
    1404                 :            :         if( !attrib_list.size() )
    1405                 :            :           {
    1406                 :            :           CubitString name("COMPOSITE_GEOM");
    1407                 :            :           DLIList<CubitString*> string_list;
    1408                 :            :           string_list.append( &name );
    1409                 :            :           CubitSimpleAttrib geom_attrib( &string_list, 0, 0 );
    1410                 :            :           curr_point->append_simple_attribute_virt( &geom_attrib );
    1411                 :            :           loop = CUBIT_TRUE;
    1412                 :            :           }
    1413                 :            :         }
    1414                 :            :       }
    1415                 :            :     if( loop )
    1416                 :            :       loop = CUBIT_FALSE;
    1417                 :            :     else
    1418                 :            :       loop = CUBIT_TRUE;
    1419                 :            :     }
    1420                 :            :   */
    1421                 :            :   GeometryModifyEngine* gme = GeometryModifyTool::instance()->get_engine(old_body);
    1422                 :            : 
    1423                 :            :   restore_vg_after_modify(new_bodysms, input_bodies, gme);
    1424                 :            : 
    1425                 :            : 
    1426                 :            :   DLIList<RefVolume*> volume_list;
    1427                 :            : 
    1428                 :            :   int i;
    1429                 :            :   for(i=new_bodysms.size(); i--;)
    1430                 :            :   {
    1431                 :            :     BodySM *bsm = new_bodysms.get_and_step();
    1432                 :            :     Body *body = dynamic_cast<Body*>(bsm->topology_entity());
    1433                 :            :     if(body)
    1434                 :            :     {
    1435                 :            :       // Append to the total list of volumes.
    1436                 :            :       body->ref_volumes(volume_list);
    1437                 :            :     }
    1438                 :            :   }
    1439                 :            :   // get all child entities (only get entities below volumes)
    1440                 :            :   DLIList<RefEntity*> child_list, ref_ent_list;
    1441                 :            :   CAST_LIST_TO_PARENT(volume_list, ref_ent_list);
    1442                 :            :   RefEntity::get_all_child_ref_entities( ref_ent_list, child_list );
    1443                 :            : 
    1444                 :            :   // Only push the id attributes if we are doing persistent ids.
    1445                 :            :   for(i=child_list.size(); i--;)
    1446                 :            :   {
    1447                 :            :   child_list.get_and_step()->auto_actuate_cubit_attrib(CUBIT_FALSE,CUBIT_TRUE);
    1448                 :            :   }
    1449                 :            : 
    1450                 :            :   remove_pushed_attributes(new_bodysms, input_bodies);
    1451                 :            : 
    1452                 :            :   finish_sm_op( input_bodies, new_bodysms , result_bodies);
    1453                 :            : 
    1454                 :            :   fixup_merged_entities( merged_surface_ids, merged_curve_ids);
    1455                 :            : 
    1456                 :            :   //Look for RefEdges that are orphaned inside of virtual surfaces
    1457                 :            :   CubitBoolean loop = CUBIT_TRUE;
    1458                 :            :   DLIList<RefVertex*> vertex_list;
    1459                 :            :   while(loop)
    1460                 :            :     {
    1461                 :            :     loop = CUBIT_FALSE;
    1462                 :            :     vertex_list.clean_out();
    1463                 :            :     for(i=0; i< volume_list.size(); i++)
    1464                 :            :       {
    1465                 :            :       RefVolume* curr_volume = volume_list.get_and_step();
    1466                 :            :       curr_volume->ref_vertices( vertex_list );
    1467                 :            :       }
    1468                 :            :     for(i=0; i< vertex_list.size(); i++)
    1469                 :            :       {
    1470                 :            :       RefVertex* curr_vertex = vertex_list.get_and_step();
    1471                 :            :       DLIList<RefEdge*> edges_on_vertex;
    1472                 :            :       curr_vertex->ref_edges( edges_on_vertex );
    1473                 :            :       edges_on_vertex.uniquify_unordered();
    1474                 :            :       if( edges_on_vertex.size() == 1 )
    1475                 :            :         {
    1476                 :            :         RefEdge* edge_to_remove = edges_on_vertex.get();
    1477                 :            :         CompositeTool::instance()->remove_edge(edge_to_remove);
    1478                 :            :         loop = CUBIT_TRUE;
    1479                 :            :         break;
    1480                 :            :         }
    1481                 :            :       }
    1482                 :            :     }
    1483                 :            :   ///*
    1484                 :            :   //Force merge faces that were missed by finish_sm_op
    1485                 :            :   //
    1486                 :            :   //This fixes a problem caused by the lack of support
    1487                 :            :   //for automatically remerging surfaces that contain any
    1488                 :            :   //virtual geometry.
    1489                 :            :   //This should be removed if this issue is ever fixed - AHH
    1490                 :            :   for(i=0; i< merged_surface_ids.size(); i++)
    1491                 :            :     {
    1492                 :            :     int refface_id = merged_surface_ids.get_and_step();
    1493                 :            :     DLIList<RefFace*> ref_faces_to_remerge;
    1494                 :            :     if(merged_map.find( refface_id ) != merged_map.end())
    1495                 :            :       {
    1496                 :            :       DLIList<Surface*> merged_surfsms = merged_map[ refface_id ];
    1497                 :            :       for(int k=0; k< merged_surfsms.size(); k++)
    1498                 :            :         {
    1499                 :            :         Surface* merging_surf = merged_surfsms.get_and_step();
    1500                 :            :         RefFace* merging_refface = CAST_TO(merging_surf->topology_entity(),RefFace);
    1501                 :            :         if(merging_refface)
    1502                 :            :           ref_faces_to_remerge.append_unique(merging_refface);
    1503                 :            :         }
    1504                 :            :       }
    1505                 :            :     if( ref_faces_to_remerge.size() == 2 )
    1506                 :            :       {
    1507                 :            :       RefFace* first_remerge_face = ref_faces_to_remerge.get_and_step();
    1508                 :            :       RefFace* second_remerge_face = ref_faces_to_remerge.get_and_step();
    1509                 :            :       int first_id = first_remerge_face->id();
    1510                 :            :       int second_id = second_remerge_face->id();
    1511                 :            :       MergeTool::instance()->force_merge( first_remerge_face , second_remerge_face );
    1512                 :            :       PRINT_WARNING("Remerging Surfaces %i and %i\n",first_id,second_id);
    1513                 :            :       }
    1514                 :            :     }
    1515                 :            :   //*/
    1516                 :            :   //do_attribute_cleanup();
    1517                 :            : 
    1518                 :            :   return CUBIT_SUCCESS;
    1519                 :            : }
    1520                 :            : 
    1521                 :            : #endif
    1522                 :            : GeometryModifyEngine*
    1523                 :         99 : GeometryModifyTool::make_RefEdge_common( RefVertex* start_vertex,
    1524                 :            :                                          RefVertex* end_vertex,
    1525                 :            :                                          TBPoint*& start_point,
    1526                 :            :                                          TBPoint*& end_point,
    1527                 :            :                                          RefFace* ref_face,
    1528                 :            :                                          Surface** surface ) const
    1529                 :            : {
    1530         [ +  - ]:         99 :   DLIList<TopologyEntity*> entity_list(3);
    1531 [ +  - ][ +  - ]:        198 :   DLIList<TopologyBridge*> bridge_list(3);
    1532                 :         99 :   TopologyBridge* bridge = 0;
    1533                 :         99 :   GeometryModifyEngine* gme = 0;
    1534                 :         99 :   start_point = end_point = 0;
    1535                 :            : 
    1536         [ +  - ]:         99 :   bool new_start_point = start_vertex->get_parents() > 0;
    1537         [ +  - ]:         99 :   bool new_end_point = end_vertex->get_parents() > 0;
    1538                 :            : 
    1539         [ -  + ]:         99 :   if (ref_face)
    1540         [ #  # ]:          0 :     entity_list.append( ref_face );
    1541         [ +  + ]:         99 :   if (!new_start_point)
    1542         [ +  - ]:         33 :     entity_list.append( start_vertex );
    1543         [ +  + ]:         99 :   if (!new_end_point)
    1544         [ +  - ]:         44 :     entity_list.append( end_vertex );
    1545                 :            : 
    1546 [ +  - ][ +  + ]:         99 :   if (entity_list.size())
    1547         [ +  - ]:         44 :     gme = common_modify_engine( entity_list, bridge_list );
    1548                 :            : 
    1549         [ +  + ]:         99 :   if (gme)
    1550                 :            :   {
    1551         [ +  - ]:         44 :     bridge_list.reset();
    1552         [ -  + ]:         44 :     if (ref_face)
    1553 [ #  # ][ #  # ]:          0 :       *surface = dynamic_cast<Surface*>(bridge_list.get_and_step());
    1554         [ +  + ]:         44 :     if (!new_start_point)
    1555 [ +  - ][ -  + ]:         33 :       start_point = dynamic_cast<TBPoint*>(bridge_list.get_and_step());
    1556         [ +  - ]:         44 :     if (!new_end_point)
    1557 [ +  - ][ -  + ]:         44 :       end_point = dynamic_cast<TBPoint*>(bridge_list.get_and_step());
    1558                 :            :   }
    1559         [ -  + ]:         55 :   else if (ref_face)
    1560                 :            :   {
    1561         [ #  # ]:          0 :     gme = get_engine( ref_face, &bridge );
    1562         [ #  # ]:          0 :     if (!gme)
    1563                 :            :     {
    1564 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("No modify engine for surface %d\n", ref_face->id()) ;
         [ #  # ][ #  # ]
                 [ #  # ]
    1565                 :          0 :       return 0;
    1566                 :            :     }
    1567         [ #  # ]:          0 :     *surface = dynamic_cast<Surface*>(bridge);
    1568         [ #  # ]:          0 :     GeometryQueryEngine* gqe = bridge->get_geometry_query_engine();
    1569         [ #  # ]:          0 :     if (!new_start_point)
    1570                 :            :       start_point = dynamic_cast<TBPoint*>( start_vertex->
    1571 [ #  # ][ #  # ]:          0 :                                   bridge_manager()->topology_bridge( gqe ) );
                 [ #  # ]
    1572         [ #  # ]:          0 :     if (!new_end_point)
    1573                 :            :       end_point = dynamic_cast<TBPoint*>( end_vertex->
    1574 [ #  # ][ #  # ]:          0 :                                   bridge_manager()->topology_bridge( gqe ) );
                 [ #  # ]
    1575                 :            :   }
    1576 [ -  + ][ #  # ]:         55 :   else if (!new_start_point && (gme = get_engine( start_vertex, &bridge )))
         [ #  # ][ -  + ]
    1577                 :            :   {
    1578         [ #  # ]:          0 :     start_point = dynamic_cast<TBPoint*>(bridge);
    1579         [ #  # ]:          0 :     if (!new_end_point)
    1580                 :            :       end_point = dynamic_cast<TBPoint*>( end_vertex->bridge_manager()->
    1581 [ #  # ][ #  # ]:          0 :                     topology_bridge( bridge->get_geometry_query_engine() ) );
         [ #  # ][ #  # ]
    1582                 :            :   }
    1583 [ -  + ][ #  # ]:         55 :   else if (!new_end_point && (gme = get_engine( end_vertex, &bridge )))
         [ #  # ][ -  + ]
    1584                 :            :   {
    1585         [ #  # ]:          0 :     end_point = dynamic_cast<TBPoint*>(bridge);
    1586                 :            :   }
    1587                 :            :   else
    1588                 :            :   {
    1589         [ +  - ]:         55 :     gme = get_gme();
    1590                 :            :   }
    1591                 :            : 
    1592                 :            : 
    1593         [ +  + ]:         99 :   if (!start_point)
    1594 [ +  - ][ +  - ]:         66 :     start_point = gme->make_Point( start_vertex->coordinates() );
    1595         [ +  + ]:         99 :   if (!end_point)
    1596 [ +  - ][ +  - ]:         55 :     end_point = gme->make_Point( end_vertex->coordinates());
    1597                 :            : 
    1598         [ +  - ]:        198 :   return gme;
    1599                 :            : }
    1600                 :            : 
    1601                 :            : //-------------------------------------------------------------------------
    1602                 :            : // Purpose       : This function uses the vertices and surface to create
    1603                 :            : //                 a curve along this surface.  The solid modeler will actually
    1604                 :            : //                 do most of the work.
    1605                 :            : // Note          : The optional third vertex will not be part of the curve,
    1606                 :            : //                 it is used for interpolation purposes.
    1607                 :            : //
    1608                 :            : // Creator       : David White
    1609                 :            : //
    1610                 :            : // Creation Date : 10/9/97
    1611                 :            : //
    1612                 :            : // Rewriting for new GeometryQueryTool interface - J.Kraftcheck 9/03
    1613                 :            : //-------------------------------------------------------------------------
    1614                 :          0 : RefEdge* GeometryModifyTool::make_RefEdge(RefVertex *ref_vertex_1,
    1615                 :            :                                     RefVertex *ref_vertex_2,
    1616                 :            :                                     RefFace* ref_face_ptr,
    1617                 :            :                                     RefVertex const* ref_vertex_3 ) const
    1618                 :            : {
    1619                 :            :           //make sure that the vertices are on the ref-face.
    1620         [ #  # ]:          0 :    CubitVector vert_1 = ref_vertex_1->coordinates();
    1621         [ #  # ]:          0 :    CubitVector vert_2 = ref_vertex_2->coordinates();
    1622                 :            : 
    1623         [ #  # ]:          0 :    ref_face_ptr->move_to_surface(vert_1);
    1624         [ #  # ]:          0 :    ref_face_ptr->move_to_surface(vert_2);
    1625                 :            : 
    1626         [ #  # ]:          0 :    GeometryQueryEngine *gqe = ref_face_ptr->get_geometry_query_engine();
    1627                 :            : 
    1628 [ #  # ][ #  # ]:          0 :    if (!ref_vertex_1->coordinates().within_tolerance(vert_1, gqe->get_sme_resabs_tolerance()))
         [ #  # ][ #  # ]
    1629                 :            :    {
    1630 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("vertices must lie within tolerance to the given"
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1631                 :            :                   " surface.\n"
    1632                 :            :                   "%s (Vertex %d) does not lie on %s (Surface %d).\n",
    1633                 :            :                   ref_vertex_1->entity_name().c_str(),
    1634                 :            :                   ref_vertex_1->id(),
    1635                 :            :                   ref_face_ptr->entity_name().c_str(),
    1636         [ #  # ]:          0 :                   ref_face_ptr->id() );
    1637                 :          0 :       return (RefEdge*)NULL;
    1638                 :            :    }
    1639 [ #  # ][ #  # ]:          0 :    else if (!ref_vertex_2->coordinates().within_tolerance(vert_2, gqe->get_sme_resabs_tolerance() ))
         [ #  # ][ #  # ]
    1640                 :            :    {
    1641 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("vertices must lie within tolerance to the given"
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1642                 :            :                   " surface.\n"
    1643                 :            :                   "%s (Vertex %d) does not lie on %s (Surface %d).\n",
    1644                 :            :                   ref_vertex_2->entity_name().c_str(),
    1645                 :            :                   ref_vertex_2->id(),
    1646                 :            :                   ref_face_ptr->entity_name().c_str(),
    1647         [ #  # ]:          0 :                   ref_face_ptr->id() );
    1648                 :          0 :       return (RefEdge*)NULL;
    1649                 :            :    }
    1650                 :            :      //Now let us find the points on the surface.  We want to
    1651                 :            :      //create them as we go for accuracy.
    1652                 :            : 
    1653                 :            :           // Get the GME of the first RefVertex.
    1654                 :          0 :    GeometryModifyEngine* GMEPtr = 0;
    1655                 :            : 
    1656                 :            :      // Extract the end Points to be used to make the RefEdge
    1657                 :          0 :    TBPoint* point_ptr1 = NULL;
    1658                 :          0 :    TBPoint* point_ptr2 = NULL;
    1659                 :          0 :    Surface* surface_ptr = NULL;
    1660                 :            : 
    1661                 :            :    // Look for a common GeometryModifyEngine
    1662                 :            :   GMEPtr = make_RefEdge_common( ref_vertex_1, ref_vertex_2,
    1663                 :            :                                 point_ptr1, point_ptr2,
    1664         [ #  # ]:          0 :                                 ref_face_ptr, &surface_ptr );
    1665                 :            : 
    1666                 :            :   //If we did not find a common GeometryModifyEngine, fail
    1667         [ #  # ]:          0 :   if( ! GMEPtr )
    1668                 :            :   {
    1669 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Surface %d, vertex %d and vertex %d do not "
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1670                 :            :       "belong to the same geometric modeling engine.\n", ref_face_ptr->id(),
    1671         [ #  # ]:          0 :       ref_vertex_1->id(), ref_vertex_2->id() );
    1672                 :            : 
    1673                 :          0 :     return 0;
    1674                 :            :   }
    1675                 :            : 
    1676                 :          0 :    CubitVector *third_vector_ptr = NULL;
    1677         [ #  # ]:          0 :    CubitVector third_vector;
    1678         [ #  # ]:          0 :    if ( ref_vertex_3 != NULL )
    1679                 :            :    {
    1680 [ #  # ][ #  # ]:          0 :       third_vector = ref_vertex_3->coordinates();
    1681                 :          0 :       third_vector_ptr = &third_vector;
    1682         [ #  # ]:          0 :       ref_face_ptr->move_to_surface( third_vector );
    1683                 :            :    }
    1684                 :            : 
    1685                 :            :      // Make sure that we get back valid Points
    1686 [ #  # ][ #  # ]:          0 :    assert ( point_ptr1 != NULL && point_ptr2 != NULL );
    1687                 :            :    
    1688 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    1689                 :            :    {
    1690                 :            :      //if endpoints are free vertices, need to save them out
    1691         [ #  # ]:          0 :      DLIList<RefVertex*> verts_to_save;
    1692         [ #  # ]:          0 :      verts_to_save.append( ref_vertex_1 );
    1693         [ #  # ]:          0 :      verts_to_save.append( ref_vertex_2 );
    1694                 :          0 :      bool save_only_if_free = true;
    1695 [ #  # ][ #  # ]:          0 :      CubitUndo::save_state_with_cubit_file( verts_to_save, save_only_if_free );
    1696                 :            :    }
    1697                 :            : 
    1698                 :            :      // Request the GME to create a Curve using the Points
    1699                 :            :    Curve *curve_ptr;
    1700                 :            :    curve_ptr = GMEPtr->make_Curve( point_ptr1,
    1701                 :            :                           point_ptr2,
    1702                 :            :                           surface_ptr,
    1703         [ #  # ]:          0 :                           third_vector_ptr);
    1704                 :            : 
    1705                 :            : 
    1706                 :            :      // If we get a NULL pointer, give a warning message and return
    1707                 :            :      // a NULL pointer.
    1708         [ #  # ]:          0 :    if ( curve_ptr == NULL )
    1709                 :            :    {
    1710 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("In GeometryModifyTool::make_RefEdge\n"
         [ #  # ][ #  # ]
                 [ #  # ]
    1711                 :            :                     "\tProblems making a spline curve from Vertex %d and %d\n"
    1712                 :            :                     "\tand the input list of positions.\n",
    1713         [ #  # ]:          0 :                     ref_vertex_1->id(), ref_vertex_2->id());
    1714                 :          0 :       return (RefEdge *)NULL ;
    1715                 :            :    }
    1716                 :            :   
    1717                 :            : 
    1718                 :            :      // Complete the task of linking this new Curve into the rest of the
    1719                 :            :      // geometry datastructures and return the new RefEdge.
    1720 [ #  # ][ #  # ]:          0 :    RefEdge *new_edge = GeometryQueryTool::instance()->make_free_RefEdge(curve_ptr);
    1721 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    1722                 :            :    {
    1723         [ #  # ]:          0 :      if( new_edge )
    1724 [ #  # ][ #  # ]:          0 :        CubitUndo::note_result_entity( new_edge );
    1725                 :            :    }
    1726                 :          0 :    return new_edge;
    1727                 :            : }
    1728                 :            : 
    1729                 :          0 : RefEdge* GeometryModifyTool::make_elliptical_RefEdge( RefVertex *vert1,
    1730                 :            :                                                       RefVertex *vert2,
    1731                 :            :                                                       CubitVector center_point,
    1732                 :            :                                                       double start_angle,
    1733                 :            :                                                       double end_angle,
    1734                 :            :                                                       CubitSense sense) const
    1735                 :            : {
    1736                 :          0 :   GeometryModifyEngine* GMEPtr = 0;
    1737                 :            : 
    1738                 :            :   // Extract the Points to be used to make the RefEdge
    1739                 :          0 :   TBPoint* point_ptr1 = NULL;
    1740                 :          0 :   TBPoint* point_ptr2 = NULL;
    1741                 :            : 
    1742                 :            :   // Look for a common geometric modeling engine to use
    1743                 :            :   GMEPtr = make_RefEdge_common( vert1, vert2,
    1744         [ #  # ]:          0 :                                 point_ptr1, point_ptr2 );
    1745         [ #  # ]:          0 :   if (!GMEPtr)
    1746                 :          0 :     return 0;
    1747                 :            : 
    1748                 :            :   // Make sure that we get back valid Points
    1749 [ #  # ][ #  # ]:          0 :   assert ( point_ptr1 != NULL && point_ptr2 != NULL ) ;
    1750                 :            : 
    1751 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    1752                 :            :   {
    1753                 :            :     //if endpoints are free vertices, need to save them out
    1754         [ #  # ]:          0 :     DLIList<RefVertex*> verts_to_save;
    1755         [ #  # ]:          0 :     verts_to_save.append( vert1 );
    1756         [ #  # ]:          0 :     verts_to_save.append( vert2 );
    1757                 :          0 :     bool save_only_if_free = true;
    1758 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( verts_to_save, save_only_if_free );
    1759                 :            :   }
    1760                 :            : 
    1761                 :            :   // Request the GME to create a Curve using the Points
    1762                 :            :   Curve* curve_ptr = GMEPtr->make_elliptical_Curve(point_ptr1,
    1763                 :            :                                                    point_ptr2,
    1764                 :            :                                                    center_point,
    1765                 :            :                                                    start_angle,
    1766                 :            :                                                    end_angle,
    1767         [ #  # ]:          0 :                                                    sense);
    1768                 :            : 
    1769                 :            :   // If we get a NULL pointer, give a warning message and return
    1770                 :            :   // a NULL pointer.
    1771         [ #  # ]:          0 :   if ( curve_ptr == NULL )
    1772                 :            :   {
    1773 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("In GeometryModifyTool::make_elliptical_RefEdge\n"
         [ #  # ][ #  # ]
                 [ #  # ]
    1774                 :            :                   "         Got a NULL pointer to a Curve.\n"
    1775                 :            :                   "         Problems making RefEdge from RefVertex %d and %d\n",
    1776         [ #  # ]:          0 :                   vert1->id(), vert2->id());
    1777                 :          0 :     return (RefEdge *)NULL ;
    1778                 :            :   }
    1779                 :            : 
    1780                 :            :   // Complete the task of linking this new Curve into the rest of the
    1781                 :            :   // geometry datastructures and return the new RefEdge.
    1782 [ #  # ][ #  # ]:          0 :   RefEdge *new_edge = GeometryQueryTool::instance()->make_free_RefEdge( curve_ptr );
    1783 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    1784                 :            :   {
    1785         [ #  # ]:          0 :     if( new_edge )
    1786 [ #  # ][ #  # ]:          0 :       CubitUndo::note_result_entity( new_edge );
    1787                 :            :   }
    1788                 :            : 
    1789                 :          0 :   return new_edge;
    1790                 :            : }
    1791                 :            : 
    1792                 :            : 
    1793                 :            : 
    1794                 :            : 
    1795                 :            : 
    1796                 :            : 
    1797                 :            : //-------------------------------------------------------------------------
    1798                 :            : // Purpose       : This function takes RefEdge type information, two
    1799                 :            : //                 RefVertices, and a list of positions in space (represented
    1800                 :            : //                 by CubitVectors) to create a RefEdge. The RefVertices must
    1801                 :            : //                 be associated with the same GeometryModifyEngine.
    1802                 :            : //                 The return value can be a NULL pointer, if the RefEdge
    1803                 :            : //                 cannot be succesfully made for some reason.
    1804                 :            : //
    1805                 :            : // Special Notes : The interpolated curve is a spline curve.
    1806                 :            : //                 If the input refface_ptr is not NULL, the points are first
    1807                 :            : //                 moved to the surface before interpolation.
    1808                 :            : //
    1809                 :            : // Creator       : Malcolm Panthaki
    1810                 :            : //
    1811                 :            : // Creation Date : 05/15/97
    1812                 :            : //
    1813                 :            : // Rewriting for new GeometryQueryTool interface - J.Kraftcheck 9/03
    1814                 :            : //-------------------------------------------------------------------------
    1815                 :         11 : RefEdge* GeometryModifyTool::make_RefEdge(GeometryType ref_edge_type,
    1816                 :            :                                     RefVertex *ref_vertex_1,
    1817                 :            :                                     RefVertex *ref_vertex_2,
    1818                 :            :                                     DLIList<CubitVector*>& vector_list,
    1819                 :            :                                     RefFace* refface_ptr) const
    1820                 :            : {
    1821                 :         11 :    GeometryModifyEngine* GMEPtr = 0;
    1822                 :            : 
    1823                 :            :      // Extract the end Points to be used to make the RefEdge
    1824                 :         11 :    TBPoint* point_ptr1 = NULL;
    1825                 :         11 :    TBPoint* point_ptr2 = NULL;
    1826                 :         11 :    Surface* surface_ptr = NULL;
    1827                 :            : 
    1828                 :            :    // Look for a common GeometryModifyEngine
    1829                 :            :   GMEPtr = make_RefEdge_common( ref_vertex_1, ref_vertex_2,
    1830                 :            :                                 point_ptr1, point_ptr2,
    1831         [ +  - ]:         11 :                                 refface_ptr, &surface_ptr );
    1832         [ -  + ]:         11 :   if (!GMEPtr)
    1833                 :          0 :     return 0;
    1834                 :            : 
    1835                 :            :      // Make sure that we get back valid Points
    1836 [ +  - ][ -  + ]:         11 :    assert ( point_ptr1 != NULL && point_ptr2 != NULL );
    1837                 :            : 
    1838 [ +  - ][ -  + ]:         11 :    if( CubitUndo::get_undo_enabled() )
    1839                 :            :    {
    1840                 :            :      //if endpoints are free vertices, need to save them out
    1841         [ #  # ]:          0 :      DLIList<RefVertex*> verts_to_save;
    1842         [ #  # ]:          0 :      verts_to_save.append( ref_vertex_1 );
    1843         [ #  # ]:          0 :      verts_to_save.append( ref_vertex_2 );
    1844                 :          0 :      bool save_only_if_free = true;
    1845 [ #  # ][ #  # ]:          0 :      CubitUndo::save_state_with_cubit_file( verts_to_save, save_only_if_free );
    1846                 :            :    }
    1847                 :            : 
    1848                 :            :      // Request the GME to create a Curve using the Points
    1849                 :            :    Curve* curve_ptr = GMEPtr->make_Curve(ref_edge_type,
    1850                 :            :                                          point_ptr1,
    1851                 :            :                                          point_ptr2,
    1852                 :            :                                          vector_list,
    1853 [ -  + ][ #  # ]:         11 :                                          refface_ptr ? refface_ptr->get_surface_ptr() : 0);
                 [ +  - ]
    1854                 :            : 
    1855                 :            :      // If we get a NULL pointer, give a warning message and return
    1856                 :            :      // a NULL pointer.
    1857         [ -  + ]:         11 :    if ( curve_ptr == NULL )
    1858                 :            :    {
    1859 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("In GeometryModifyTool::make_RefEdge\n"
         [ #  # ][ #  # ]
                 [ #  # ]
    1860                 :            :                     "         Got a NULL pointer to a Curve.\n"
    1861                 :            :                     "         Problems making a spline RefEdge from RefVertex %d and %d\n"
    1862                 :            :                     "         and the input list of positions.\n",
    1863         [ #  # ]:          0 :                     ref_vertex_1->id(), ref_vertex_2->id());
    1864                 :          0 :       return (RefEdge *)NULL ;
    1865                 :            :    }
    1866                 :            : 
    1867                 :            :      // Complete the task of linking this new Curve into the rest of the
    1868                 :            :      // geometry datastructures and return the new RefEdge.
    1869 [ +  - ][ +  - ]:         11 :    RefEdge *new_edge = GeometryQueryTool::instance()->make_free_RefEdge(curve_ptr);
    1870 [ +  - ][ -  + ]:         11 :    if( CubitUndo::get_undo_enabled() )
    1871                 :            :    {
    1872         [ #  # ]:          0 :      if( new_edge )
    1873 [ #  # ][ #  # ]:          0 :        CubitUndo::note_result_entity( new_edge );
    1874                 :            :    }
    1875                 :         11 :    return new_edge;
    1876                 :            : }
    1877                 :            : 
    1878                 :            : //-------------------------------------------------------------------------
    1879                 :            : // Purpose       : This function takes a type information, two
    1880                 :            : //                 RefVertices, an intermediate position, and a sense
    1881                 :            : //                 information to create a RefEdge. The RefVertices must
    1882                 :            : //                 be associated with the same GeometryModifyEngine.
    1883                 :            : //                 The return value can be a NULL pointer, if the RefEdge
    1884                 :            : //                 cannot be succesfully made for some reason.
    1885                 :            : //
    1886                 :            : // Special Notes :
    1887                 :            : //
    1888                 :            : // Creator       : Raikanta Sahu
    1889                 :            : //
    1890                 :            : // Creation Date : 03/27/97
    1891                 :            : //-------------------------------------------------------------------------
    1892                 :         88 : RefEdge* GeometryModifyTool::make_RefEdge(GeometryType ref_edge_type,
    1893                 :            :                                     RefVertex *ref_vertex_1,
    1894                 :            :                                     RefVertex *ref_vertex_2,
    1895                 :            :                                     CubitVector const* intermediate_point ) const
    1896                 :            : {
    1897                 :         88 :    GeometryModifyEngine* GMEPtr = 0;
    1898                 :            : 
    1899                 :            :      // Extract the Points to be used to make the RefEdge
    1900                 :         88 :    TBPoint* point_ptr1 = NULL;
    1901                 :         88 :    TBPoint* point_ptr2 = NULL;
    1902                 :            : 
    1903                 :            :     // Look for a common geometric modeling engine to use
    1904                 :            :   GMEPtr = make_RefEdge_common( ref_vertex_1, ref_vertex_2,
    1905         [ +  - ]:         88 :                                 point_ptr1, point_ptr2 );
    1906         [ -  + ]:         88 :   if (!GMEPtr)
    1907                 :          0 :     return 0;
    1908                 :            : 
    1909                 :            :      // Make sure that we get back valid Points
    1910 [ +  - ][ -  + ]:         88 :    assert ( point_ptr1 != NULL && point_ptr2 != NULL ) ;
    1911                 :            : 
    1912 [ +  - ][ -  + ]:         88 :    if( CubitUndo::get_undo_enabled() )
    1913                 :            :    {
    1914                 :            :      //if endpoints are free vertices, need to save them out
    1915         [ #  # ]:          0 :      DLIList<RefVertex*> verts_to_save;
    1916         [ #  # ]:          0 :      verts_to_save.append( ref_vertex_1 );
    1917         [ #  # ]:          0 :      verts_to_save.append( ref_vertex_2 );
    1918                 :          0 :      bool save_only_if_free = true;
    1919 [ #  # ][ #  # ]:          0 :      CubitUndo::save_state_with_cubit_file( verts_to_save, save_only_if_free );
    1920                 :            :    }
    1921                 :            : 
    1922                 :            :      // Request the GME to create a Curve using the Points
    1923                 :            :    Curve* curve_ptr = GMEPtr->make_Curve(ref_edge_type,
    1924                 :            :                                          point_ptr1,
    1925                 :            :                                          point_ptr2,
    1926         [ +  - ]:         88 :                                          intermediate_point );
    1927                 :            : 
    1928                 :            :      // If we get a NULL pointer, give a warning message and return
    1929                 :            :      // a NULL pointer.
    1930         [ -  + ]:         88 :    if ( curve_ptr == NULL )
    1931                 :            :    {
    1932 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("In GeometryModifyTool::make_RefEdge\n"
         [ #  # ][ #  # ]
                 [ #  # ]
    1933                 :            :                     "         Got a NULL pointer to a Curve.\n"
    1934                 :            :                     "         Problems making RefEdge from RefVertex %d and %d\n",
    1935         [ #  # ]:          0 :                     ref_vertex_1->id(), ref_vertex_2->id());
    1936                 :          0 :       return (RefEdge *)NULL ;
    1937                 :            :    }
    1938                 :            : 
    1939                 :            :      // Complete the task of linking this new Curve into the rest of the
    1940                 :            :      // geometry datastructures and return the new RefEdge.
    1941 [ +  - ][ +  - ]:         88 :    RefEdge *new_edge = GeometryQueryTool::instance()->make_free_RefEdge( curve_ptr );
    1942 [ +  - ][ -  + ]:         88 :    if( CubitUndo::get_undo_enabled() )
    1943                 :            :    {
    1944         [ #  # ]:          0 :      if( new_edge )
    1945 [ #  # ][ #  # ]:          0 :        CubitUndo::note_result_entity( new_edge );
    1946                 :            :    }
    1947                 :         88 :    return new_edge;
    1948                 :            : }
    1949                 :            : 
    1950                 :            : //-------------------------------------------------------------------------
    1951                 :            : // Purpose       : This function creates a RefFace from an existing RefFace.
    1952                 :            : //                 The new face is a sheet body, double sided face with no
    1953                 :            : //                 volume to the body.
    1954                 :            : //
    1955                 :            : // Special Notes :
    1956                 :            : //
    1957                 :            : // Creator       : Raikanta Sahu
    1958                 :            : //
    1959                 :            : // Creation Date : 03/27/97
    1960                 :            : //-------------------------------------------------------------------------
    1961                 :            : 
    1962                 :         11 : RefFace* GeometryModifyTool::make_RefFace(RefFace *from_ref_face,                                    
    1963                 :            :                                     std::map< RefEntity*, RefEntity* > *old_to_new_map ) const
    1964                 :            : {
    1965         [ +  - ]:         11 :    GeometryModifyEngine* GME_ptr = get_engine(from_ref_face);
    1966                 :            : 
    1967         [ -  + ]:         11 :    if (!GME_ptr)
    1968                 :            :    {
    1969 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Cannot create surface from another virtual surface.\n");
         [ #  # ][ #  # ]
    1970                 :          0 :       return NULL;
    1971                 :            :    }
    1972                 :            :      //From the surface create a new surface.
    1973                 :         11 :    TopologyBridge* bridge = 0;
    1974         [ +  - ]:         11 :    GeometryModifyEngine* engine = get_engine(from_ref_face, &bridge);
    1975         [ -  + ]:         11 :    Surface* old_surface_ptr = dynamic_cast<Surface*>(bridge);
    1976         [ -  + ]:         11 :    if ( engine == NULL )
    1977                 :            :    {
    1978 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("%s (surface %d) does not have a modify engine.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1979                 :            :                   from_ref_face->entity_name().c_str(),
    1980         [ #  # ]:          0 :                   from_ref_face->id() );
    1981                 :          0 :       return (RefFace*)NULL;
    1982                 :            :    }
    1983                 :            : 
    1984 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
    1985         [ #  # ]:          0 :     CubitUndo::save_state();
    1986                 :            : 
    1987                 :            :   //this list will get all the TB's what we'll be copying
    1988                 :         11 :   TopologyBridge *top_bridge = old_surface_ptr;
    1989                 :            : 
    1990                 :            :   
    1991                 :            :   //if( !extended_from )
    1992                 :            :   {
    1993 [ +  - ][ +  - ]:         11 :     prepare_for_copy( from_ref_face, top_bridge );
    1994                 :            :   }
    1995                 :            : 
    1996         [ -  + ]:         11 :   Surface *tmp_surface = CAST_TO( top_bridge, Surface );
    1997         [ +  - ]:         11 :   std::map< TopologyBridge*, TopologyBridge* > old_tb_to_new_tb;
    1998         [ +  - ]:         11 :   Surface* new_surface_ptr = engine->make_Surface( tmp_surface, &old_tb_to_new_tb );
    1999                 :            : 
    2000         [ -  + ]:         11 :   if (!new_surface_ptr)
    2001                 :            :   {
    2002 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Surface copy failed.\n");
         [ #  # ][ #  # ]
    2003                 :            :     //if( !extended_from )
    2004         [ #  # ]:          0 :       clean_up_from_copy_failure( old_surface_ptr );
    2005                 :            : 
    2006 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    2007         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
    2008                 :            : 
    2009                 :          0 :     return 0;
    2010                 :            :   }
    2011                 :            :   
    2012                 :            :   //if( !extended_from  )
    2013                 :            :   {
    2014                 :         11 :     TopologyBridge *top_bridge_new = new_surface_ptr;
    2015         [ +  - ]:         11 :     finish_copy( top_bridge_new, old_surface_ptr );
    2016         [ -  + ]:         11 :     new_surface_ptr = CAST_TO( top_bridge_new, Surface );
    2017                 :            :   }
    2018                 :            : 
    2019         [ +  - ]:         11 :   Body *new_Body = make_Body(new_surface_ptr);
    2020 [ +  - ][ +  - ]:         22 :   DLIList<RefFace*> ref_faces;
    2021         [ +  - ]:         11 :   new_Body->ref_faces(ref_faces);
    2022 [ +  - ][ -  + ]:         11 :   assert(ref_faces.size() > 0);
    2023                 :            :   
    2024         [ -  + ]:         11 :   if( old_to_new_map )
    2025         [ #  # ]:          0 :     create_old_to_new_ref_ent_map( tmp_surface, new_surface_ptr, *old_to_new_map, old_tb_to_new_tb );
    2026                 :            : 
    2027 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
    2028                 :            :   {
    2029         [ #  # ]:          0 :     if( new_Body )
    2030         [ #  # ]:          0 :       CubitUndo::note_result_body( new_Body );
    2031                 :            :     else
    2032         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    2033                 :            :   }
    2034                 :            : 
    2035 [ +  - ][ +  - ]:         22 :   return ref_faces.get();
    2036                 :            : }
    2037                 :            : 
    2038                 :            : //-------------------------------------------------------------------------
    2039                 :            : // Purpose       : This function creates a sheet body by extending out a
    2040                 :            : //                 set of surfaces.  The sheet body is a double sided face
    2041                 :            : //                 with no volume.
    2042                 :            : //
    2043                 :            : // Special Notes :
    2044                 :            : //
    2045                 :            : // Creator       : Steve Storm
    2046                 :            : //
    2047                 :            : // Creation Date : 02/28/08
    2048                 :            : //-------------------------------------------------------------------------
    2049                 :            : Body*
    2050                 :          0 : GeometryModifyTool::make_extended_sheet( DLIList<RefFace*> &ref_face_list,
    2051                 :            :                                          CubitBox *clip_box_ptr,
    2052                 :            :                                          bool preview ) const
    2053                 :            : {
    2054 [ #  # ][ #  # ]:          0 :   if( !ref_face_list.size() )
    2055                 :          0 :     return 0;
    2056                 :            : 
    2057         [ #  # ]:          0 :   GfxPreview::clear();
    2058                 :            : 
    2059                 :            :   // Check for virtual geometry
    2060         [ #  # ]:          0 :   DLIList<RefEntity*> ref_ent_list;
    2061 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2062 [ #  # ][ #  # ]:          0 :   if ( GeometryQueryTool::instance()->contains_intermediate_geometry(ref_ent_list) )
                 [ #  # ]
    2063                 :            :   {
    2064 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("EXTENDING surfaces containing virtual geometry is not\n"
                 [ #  # ]
    2065                 :            :       "       allowed. Delete virtual geometry on these surfaces\n"
    2066         [ #  # ]:          0 :       "       before operation.\n" );
    2067                 :          0 :     return 0;
    2068                 :            :   }
    2069                 :            : 
    2070                 :            :   // Look for a common GeometryModifyEngine for all of the RefFaces
    2071         [ #  # ]:          0 :   int count = ref_face_list.size();
    2072 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(count);
    2073 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
    2074 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( ref_face_list, entity_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2075                 :            : 
    2076                 :            :   GeometryModifyEngine* GME_ptr =
    2077         [ #  # ]:          0 :     common_modify_engine( entity_list, bridge_list );
    2078         [ #  # ]:          0 :   if(! GME_ptr )
    2079                 :            :   {
    2080 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Cannot construct an extended sheet using surfaces that\n"
                 [ #  # ]
    2081         [ #  # ]:          0 :                  "       do not share a common geometry engine.\n");
    2082                 :          0 :      return 0;
    2083                 :            :   }
    2084                 :            : 
    2085 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list(count);
    2086 [ #  # ][ #  # ]:          0 :   CAST_LIST( bridge_list, surface_list, Surface );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2087                 :            :   
    2088 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    2089         [ #  # ]:          0 :     CubitUndo::save_state();
    2090                 :            : 
    2091                 :            :   BodySM *bodySM_ptr = GME_ptr->make_extended_sheet( surface_list,
    2092         [ #  # ]:          0 :     clip_box_ptr, preview );
    2093                 :            : 
    2094         [ #  # ]:          0 :   if( !bodySM_ptr )
    2095         [ #  # ]:          0 :     CubitUndo::remove_last_undo();
    2096                 :            : 
    2097         [ #  # ]:          0 :   if( bodySM_ptr )
    2098                 :            :   {
    2099 [ #  # ][ #  # ]:          0 :     Body *tmp_body = GeometryQueryTool::instance()->make_Body(bodySM_ptr);
    2100                 :            : 
    2101 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
    2102                 :            :     {
    2103         [ #  # ]:          0 :       if( tmp_body )
    2104 [ #  # ][ #  # ]:          0 :         CubitUndo::note_result_entity( tmp_body );
    2105                 :            :       else 
    2106         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
    2107                 :            :     }
    2108                 :            : 
    2109                 :          0 :     return tmp_body;
    2110                 :            :   }
    2111                 :            :   else
    2112         [ #  # ]:          0 :     return 0;
    2113                 :            : }
    2114                 :            : 
    2115                 :            : //-------------------------------------------------------------------------
    2116                 :            : // Purpose       : This function takes a type information and a list of
    2117                 :            : //                 RefEdges to create a Body with just one RefFace. The
    2118                 :            : //                 underlying representation of the RefFace is determined
    2119                 :            : //                 by the GeometryModifyEngine of the RefEdges. All the
    2120                 :            : //                 RefEdges in the list must be associated with the same
    2121                 :            : //                 GeometryModifyEngine. The return value can be a
    2122                 :            : //                 NULL pointer, if the RefFace cannot be succesfully
    2123                 :            : //                 made for some reason.
    2124                 :            : //
    2125                 :            : // Special Notes :
    2126                 :            : //
    2127                 :            : // Creator       : David White
    2128                 :            : //
    2129                 :            : // Creation Date : 10/23/97
    2130                 :            : //-------------------------------------------------------------------------
    2131                 :            : 
    2132                 :          0 : RefFace* GeometryModifyTool::make_RefFace(GeometryType ref_face_type,
    2133                 :            :                                     DLIList<RefEdge*>& ref_edge_list,
    2134                 :            :                                     bool is_free_face,
    2135                 :            :                                     RefFace *ref_face_ptr,
    2136                 :            :                                     bool check_edges ) const
    2137                 :            : {
    2138                 :            :     //Look for a common GeometryModifyEngine for all of
    2139                 :            :     //the RefEdges.
    2140                 :            : 
    2141 [ #  # ][ #  # ]:          0 :   const int count = ref_edge_list.size() + (ref_face_ptr ? 1 : 0);
    2142         [ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(count);
    2143 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
    2144 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( ref_edge_list, entity_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2145 [ #  # ][ #  # ]:          0 :   if( ref_face_ptr ) entity_list.append( ref_face_ptr );
    2146                 :            : 
    2147                 :            :   GeometryModifyEngine* GME_ptr =
    2148         [ #  # ]:          0 :     common_modify_engine( entity_list, bridge_list );
    2149         [ #  # ]:          0 :   if(! GME_ptr )
    2150                 :            :   {
    2151 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Cannot construct a Surface using entities that do "
                 [ #  # ]
    2152         [ #  # ]:          0 :                  "not share a common geometry engine.\n");
    2153                 :          0 :      return 0;
    2154                 :            :   }
    2155                 :            : 
    2156                 :          0 :    Surface* old_surface_ptr = 0;
    2157         [ #  # ]:          0 :    if (ref_face_ptr)
    2158 [ #  # ][ #  # ]:          0 :     old_surface_ptr = dynamic_cast<Surface*>(bridge_list.pop());
    2159                 :            : 
    2160                 :            :    //Collect all the names on vertices to propagate after you create
    2161                 :            :    //the surface
    2162 [ #  # ][ #  # ]:          0 :    DLIList<CubitVector> vertex_coordinates;
    2163 [ #  # ][ #  # ]:          0 :    DLIList<CubitString> vertex_names;
    2164 [ #  # ][ #  # ]:          0 :    DLIList<RefEdge*> free_ref_edges;
    2165                 :            :    int kk;
    2166 [ #  # ][ #  # ]:          0 :    for( kk=ref_edge_list.size(); kk--; )
    2167                 :            :    {
    2168         [ #  # ]:          0 :      DLIList<CubitString> tmp_names;
    2169         [ #  # ]:          0 :      RefEdge *tmp_edge = ref_edge_list.get_and_step();
    2170                 :            : 
    2171 [ #  # ][ #  # ]:          0 :      if( tmp_edge->num_parent_ref_entities() == 0 )
    2172         [ #  # ]:          0 :        free_ref_edges.append( tmp_edge );
    2173                 :            : 
    2174         [ #  # ]:          0 :      RefVertex *s_vertex = tmp_edge->start_vertex();
    2175         [ #  # ]:          0 :      RefVertex *e_vertex = tmp_edge->end_vertex();
    2176                 :            :      int jj;
    2177                 :            : 
    2178         [ #  # ]:          0 :      s_vertex->entity_names( tmp_names );
    2179 [ #  # ][ #  # ]:          0 :      for( jj=tmp_names.size(); jj--; )
    2180                 :            :      {
    2181 [ #  # ][ #  # ]:          0 :        CubitVector tmp_vec = tmp_edge->start_vertex()->coordinates();
    2182 [ #  # ][ #  # ]:          0 :        CubitString name = tmp_names.get_and_step();
    2183         [ #  # ]:          0 :        vertex_coordinates.append( tmp_vec );
    2184         [ #  # ]:          0 :        vertex_names.append( name );
    2185         [ #  # ]:          0 :      }
    2186                 :            : 
    2187         [ #  # ]:          0 :      tmp_names.clean_out();
    2188         [ #  # ]:          0 :      e_vertex->entity_names( tmp_names );
    2189 [ #  # ][ #  # ]:          0 :      for( jj=tmp_names.size(); jj--; )
    2190                 :            :      {
    2191 [ #  # ][ #  # ]:          0 :        CubitVector tmp_vec = tmp_edge->end_vertex()->coordinates();
    2192 [ #  # ][ #  # ]:          0 :        CubitString name = tmp_names.get_and_step();
    2193         [ #  # ]:          0 :        vertex_coordinates.append( tmp_vec );
    2194         [ #  # ]:          0 :        vertex_names.append( name );
    2195         [ #  # ]:          0 :      }
    2196         [ #  # ]:          0 :    }
    2197                 :            : 
    2198 [ #  # ][ #  # ]:          0 :    DLIList<Curve*> curve_list(ref_edge_list.size());
                 [ #  # ]
    2199 [ #  # ][ #  # ]:          0 :    CAST_LIST( bridge_list, curve_list, Curve );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2200                 :            : 
    2201                 :            :      // Use the Curves to create a Surface
    2202                 :            :    Surface* surface_ptr = GME_ptr->make_Surface(ref_face_type, curve_list,
    2203         [ #  # ]:          0 :                                                 old_surface_ptr, check_edges) ;
    2204                 :            : 
    2205         [ #  # ]:          0 :    if (surface_ptr == NULL) {
    2206 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Couldn't make new RefFace.\n");
         [ #  # ][ #  # ]
    2207                 :          0 :      return NULL;
    2208                 :            :    }
    2209                 :            : 
    2210         [ #  # ]:          0 :    GeometryQueryTool* const gqt = GeometryQueryTool::instance();
    2211                 :            : 
    2212         [ #  # ]:          0 :    RefFace* result_face = gqt->make_free_RefFace(surface_ptr, is_free_face);
    2213         [ #  # ]:          0 :    gqt->cleanout_deactivated_geometry();
    2214                 :            : 
    2215                 :            :    //send out events for free curves saying that their 'free' status has
    2216                 :            :    //be changed
    2217                 :            : 
    2218 [ #  # ][ #  # ]:          0 :   for( kk=0; kk<free_ref_edges.size(); kk++ )
    2219                 :            :   {
    2220         [ #  # ]:          0 :     RefEdge *free_edge = free_ref_edges.get_and_step();
    2221 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOP_LEVEL_ENTITY_DESTRUCTED, free_edge));
         [ #  # ][ #  # ]
                 [ #  # ]
    2222 [ #  # ][ #  # ]:          0 :     CGMHistory::Event evt(CGMHistory::TOP_LEVEL_ENTITY_DELETED, free_edge );
    2223 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->history().add_event(evt);
                 [ #  # ]
    2224         [ #  # ]:          0 :   }
    2225                 :            : 
    2226                 :            : 
    2227                 :            :    //look for a vertex at the same location of the original
    2228                 :            :    //vertex(s).  Add the name to this new vertex.
    2229 [ #  # ][ #  # ]:          0 :    DLIList<RefVertex*> tmp_verts;
    2230         [ #  # ]:          0 :    result_face->ref_vertices( tmp_verts);
    2231 [ #  # ][ #  # ]:          0 :    for( kk=vertex_coordinates.size(); kk--; )
    2232                 :            :    {
    2233 [ #  # ][ #  # ]:          0 :      CubitVector tmp_coord = vertex_coordinates.get_and_step();
    2234 [ #  # ][ #  # ]:          0 :      CubitString tmp_name = vertex_names.get_and_step();
    2235                 :            : 
    2236                 :            :      int jj;
    2237 [ #  # ][ #  # ]:          0 :      for( jj=tmp_verts.size(); jj--; )
    2238                 :            :      {
    2239         [ #  # ]:          0 :        RefVertex *tmp_vert = tmp_verts.get_and_step();
    2240 [ #  # ][ #  # ]:          0 :        if( tmp_coord.distance_between( tmp_vert->coordinates() ) < GEOMETRY_RESABS )
                 [ #  # ]
    2241                 :            :        {
    2242                 :            :          //add the name if it doesn't already exist
    2243 [ #  # ][ #  # ]:          0 :          RefEntityName::instance()->add_refentity_name( tmp_vert, tmp_name );
                 [ #  # ]
    2244                 :            :        }
    2245                 :            :      }
    2246         [ #  # ]:          0 :    }
    2247                 :            : 
    2248         [ #  # ]:          0 :    return result_face;
    2249                 :            : }
    2250                 :            : 
    2251                 :            : //-------------------------------------------------------------------------
    2252                 :            : // Purpose       : This function takes a list of RefVolumes to create a
    2253                 :            : //                 Body. The underlying representation of the Body is
    2254                 :            : //                 determined by the GeometryModifyEngine of the
    2255                 :            : //                 RefVolumes. All the RefVolumes in the list must be
    2256                 :            : //                 associated with the same GeometryModifyEngine. The
    2257                 :            : //                 return value can be a NULL pointer, if the RefFace
    2258                 :            : //                 cannot be succesfully made for some reason.
    2259                 :            : //
    2260                 :            : // Special Notes :
    2261                 :            : //
    2262                 :            : // Creator       : Raikanta Sahu
    2263                 :            : //
    2264                 :            : // Creation Date : 03/29/97
    2265                 :            : //-------------------------------------------------------------------------
    2266                 :            : 
    2267                 :          0 : Body* GeometryModifyTool::make_Body(DLIList<RefVolume*>& ref_volume_list) const
    2268                 :            : {
    2269         [ #  # ]:          0 :   DLIList<TopologyEntity*> topo_list;
    2270 [ #  # ][ #  # ]:          0 :   DLIList<Lump*> lump_list;
    2271 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list;
    2272 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( ref_volume_list, topo_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2273                 :            :   GeometryModifyEngine* GME_ptr =
    2274         [ #  # ]:          0 :     common_modify_engine( topo_list, bridge_list, CUBIT_FALSE );
    2275         [ #  # ]:          0 :   if( ! GME_ptr )
    2276                 :            :   {
    2277 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("The specified volumes do not belong to the same "
                 [ #  # ]
    2278                 :            :       "geometry engine, and therefore cannot be used to form a "
    2279         [ #  # ]:          0 :       "single body.");
    2280                 :          0 :     return 0;
    2281                 :            :   }
    2282 [ #  # ][ #  # ]:          0 :   CAST_LIST( bridge_list, lump_list, Lump );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2283 [ #  # ][ #  # ]:          0 :   assert( ref_volume_list.size() == lump_list.size() );
                 [ #  # ]
    2284                 :            : 
    2285                 :            : 
    2286                 :            :      // Use the Lumps to create a BodySM
    2287         [ #  # ]:          0 :    BodySM* bodySM_ptr = GME_ptr->make_BodySM(lump_list) ;
    2288                 :            : 
    2289                 :            :      // If we get a NULL pointer, give a warning message and return
    2290                 :            :      // a NULL pointer.
    2291         [ #  # ]:          0 :    if ( bodySM_ptr == NULL )
    2292                 :            :    {
    2293 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("In GeometryModifyTool::make_Body\n"
                 [ #  # ]
    2294                 :            :                     "         Got a NULL pointer to a BodySM.\n"
    2295         [ #  # ]:          0 :                     "         Cannot make a Body.\n") ;
    2296                 :          0 :       return (Body *)NULL;
    2297                 :            :    }
    2298                 :            : 
    2299 [ #  # ][ #  # ]:          0 :    return GeometryQueryTool::instance()->make_Body(bodySM_ptr);
                 [ #  # ]
    2300                 :            : }
    2301                 :            : 
    2302                 :            : //-------------------------------------------------------------------------
    2303                 :            : // Purpose       : This function creates a sheet body from an existing
    2304                 :            : //                 RefFace.
    2305                 :            : //
    2306                 :            : // Special Notes :
    2307                 :            : //
    2308                 :            : // Creator       : Raikanta Sahu
    2309                 :            : //
    2310                 :            : // Creation Date : 03/29/97
    2311                 :            : //-------------------------------------------------------------------------
    2312                 :            : 
    2313                 :          0 : Body* GeometryModifyTool::make_Body(RefFace *from_ref_face,                              
    2314                 :            :                               std::map< RefEntity*, RefEntity* > *old_to_new_map ) const
    2315                 :            : {
    2316                 :            :      // Given the arguments, make a RefFace.
    2317                 :            :    RefFace* new_ref_face = this->make_RefFace(from_ref_face,
    2318         [ #  # ]:          0 :                                               old_to_new_map );
    2319         [ #  # ]:          0 :    if (!new_ref_face)
    2320                 :            :    {
    2321                 :          0 :       return (Body *)NULL;
    2322                 :            :    }
    2323                 :            : 
    2324         [ #  # ]:          0 :    DLIList<Body*> bodies;
    2325         [ #  # ]:          0 :    new_ref_face->bodies(bodies);
    2326                 :            : 
    2327 [ #  # ][ #  # ]:          0 :    if (!bodies.size()) {
    2328         [ #  # ]:          0 :      GeometryEntity *ge_ptr = new_ref_face->get_geometry_entity_ptr();
    2329         [ #  # ]:          0 :      Surface *surf_ptr = CAST_TO(ge_ptr, Surface);
    2330         [ #  # ]:          0 :      assert(surf_ptr != 0);
    2331                 :            : 
    2332 [ #  # ][ #  # ]:          0 :      BodySM *body_sm = gmeList.get()->make_BodySM(surf_ptr);
    2333 [ #  # ][ #  # ]:          0 :      return GeometryQueryTool::instance()->make_Body(body_sm);
    2334                 :            :    }
    2335                 :            : 
    2336 [ #  # ][ #  # ]:          0 :    else return bodies.get();
    2337                 :            : }
    2338                 :            : //-------------------------------------------------------------------------
    2339                 :            : // Purpose       : This function takes a type information and a list of
    2340                 :            : //                 RefEdges to create a Body that has just one RefFace.
    2341                 :            : //                 The underlying representation of the Body is
    2342                 :            : //                 determined by the GeometryModifyEngine of the
    2343                 :            : //                 RefEdges. All the RefEdges in the list must be
    2344                 :            : //                 associated with the same GeometryModifyEngine. The
    2345                 :            : //                 return value can be a NULL pointer, if the Body cannot
    2346                 :            : //                 be succesfully made for some reason.
    2347                 :            : //
    2348                 :            : // Special Notes :
    2349                 :            : //
    2350                 :            : // Creator       : Raikanta Sahu
    2351                 :            : //
    2352                 :            : // Creation Date : 03/29/97
    2353                 :            : //-------------------------------------------------------------------------
    2354                 :            : 
    2355                 :          0 : Body* GeometryModifyTool::make_Body(GeometryType ref_face_type,
    2356                 :            :                               DLIList<RefEdge*>& ref_edge_list,
    2357                 :            :                               RefFace *ref_face_ptr) const
    2358                 :            : {
    2359 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    2360         [ #  # ]:          0 :      CubitUndo::save_state_with_cubit_file( ref_edge_list );
    2361                 :            : 
    2362                 :          0 :    bool is_free_face = false;
    2363                 :            : 
    2364                 :            :      // Given the arguments, make a RefFace.
    2365                 :            :    RefFace* new_ref_face = this->make_RefFace(ref_face_type,
    2366                 :            :                                               ref_edge_list,
    2367                 :            :                                               is_free_face,
    2368         [ #  # ]:          0 :                                               ref_face_ptr);
    2369                 :            : 
    2370         [ #  # ]:          0 :    if( new_ref_face == NULL )
    2371                 :          0 :       return NULL;
    2372                 :            : 
    2373                 :            :       // If new_ref_face doesn't have a body, create one.
    2374         [ #  # ]:          0 :    DLIList<Body*> bodies;
    2375         [ #  # ]:          0 :    new_ref_face->bodies(bodies);
    2376                 :            : 
    2377 [ #  # ][ #  # ]:          0 :    if (!bodies.size()) {
    2378         [ #  # ]:          0 :      Surface *surf_ptr = new_ref_face->get_surface_ptr();
    2379         [ #  # ]:          0 :      assert(surf_ptr != 0);
    2380         [ #  # ]:          0 :      GeometryModifyEngine* engine = get_engine(surf_ptr);
    2381         [ #  # ]:          0 :      assert(engine != 0);
    2382                 :            : 
    2383         [ #  # ]:          0 :      BodySM *body_sm = engine->make_BodySM(surf_ptr);
    2384 [ #  # ][ #  # ]:          0 :      Body* body = GeometryQueryTool::instance()->make_Body(body_sm);
    2385         [ #  # ]:          0 :      bodies.append( body );
    2386                 :            :    }
    2387                 :            : 
    2388 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    2389                 :            :    {
    2390 [ #  # ][ #  # ]:          0 :      if( bodies.size() )
    2391 [ #  # ][ #  # ]:          0 :        CubitUndo::note_result_entity( bodies.get() );
                 [ #  # ]
    2392                 :            :      else
    2393         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    2394                 :            :    }
    2395                 :            : 
    2396                 :            :      // Return the body containing the new RefFace.
    2397 [ #  # ][ #  # ]:          0 :    return bodies.get();
    2398                 :            : }
    2399                 :            : 
    2400                 :            : //-------------------------------------------------------------------------
    2401                 :            : // Purpose       : The following functions copy the input Body to create
    2402                 :            : //                 a new one.  Some transformations may be applied to the
    2403                 :            : //                 newly copied Body before returning it:
    2404                 :            : //                    copy
    2405                 :            : //                    copy_and_move
    2406                 :            : //                    copy_and_rotate
    2407                 :            : //
    2408                 :            : // Special Notes :
    2409                 :            : //
    2410                 :            : // Creator       : Malcolm J. Panthaki
    2411                 :            : //
    2412                 :            : // Creation Date : 10/1/96
    2413                 :            : //-------------------------------------------------------------------------
    2414                 :        188 : Body* GeometryModifyTool::copy_body ( Body* bodyPtr, 
    2415                 :            :   std::map< RefEntity*, RefEntity* > *old_to_new_map )
    2416                 :            : {
    2417         [ +  - ]:        188 :    BodySM* body_sm = bodyPtr->get_body_sm_ptr();
    2418         [ -  + ]:        188 :    if (!body_sm)
    2419                 :            :    {
    2420 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Body %d is invalid -- no attached BodySM.\n", bodyPtr->id());
         [ #  # ][ #  # ]
                 [ #  # ]
    2421                 :          0 :      return 0;
    2422                 :            :    }
    2423                 :            : 
    2424                 :            :    //this list will get all the TB's what we'll be copying
    2425         [ +  - ]:        188 :    DLIList<RefEntity*> tmp_list;
    2426 [ +  - ][ +  - ]:        188 :    tmp_list.append( bodyPtr );
    2427                 :            :    TopologyBridge *top_bridge;
    2428 [ +  - ][ +  - ]:        188 :    prepare_for_copy( bodyPtr, top_bridge );
    2429                 :            : 
    2430         [ -  + ]:        188 :    BodySM *tmp_body_sm = CAST_TO( top_bridge, BodySM );
    2431                 :            : 
    2432         [ +  - ]:        188 :    GeometryModifyEngine* GMEPtr = get_engine(tmp_body_sm);
    2433         [ -  + ]:        188 :    if ( GMEPtr == NULL )
    2434                 :            :    {
    2435         [ #  # ]:          0 :      clean_up_from_copy_failure( top_bridge );
    2436 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Cannot copy volume %d\n"
         [ #  # ][ #  # ]
                 [ #  # ]
    2437                 :            :                  "     Copy is supported for bodies based on solid "
    2438         [ #  # ]:          0 :                  "models only\n", bodyPtr->ref_volume()->id() );
    2439                 :          0 :      return NULL ;
    2440                 :            :    }
    2441 [ +  - ][ +  - ]:        376 :    std::map<TopologyBridge*, TopologyBridge*> old_tb_to_new_tb;  
    2442                 :            : 
    2443         [ +  - ]:        188 :    BodySM *new_bodysm = GMEPtr->copy_body(tmp_body_sm, &old_tb_to_new_tb );
    2444                 :            : 
    2445         [ -  + ]:        188 :    if (!new_bodysm)
    2446                 :            :    {
    2447         [ #  # ]:          0 :      clean_up_from_copy_failure( top_bridge );
    2448 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Failed to copy volume %d\n", bodyPtr->ref_volume()->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2449                 :          0 :      return 0;
    2450                 :            :    }
    2451                 :            : 
    2452                 :        188 :    TopologyBridge *top_bridge_new = new_bodysm;
    2453         [ +  - ]:        188 :    finish_copy( top_bridge_new, body_sm );
    2454                 :            : 
    2455         [ -  + ]:        188 :    new_bodysm = CAST_TO( top_bridge_new, BodySM );
    2456 [ +  - ][ +  - ]:        188 :    Body *body_new = GeometryQueryTool::instance()->make_Body(new_bodysm);
    2457                 :            : 
    2458         [ -  + ]:        188 :    if( old_to_new_map )
    2459         [ #  # ]:          0 :      create_old_to_new_ref_ent_map( body_sm, new_bodysm, *old_to_new_map, old_tb_to_new_tb );
    2460                 :            : 
    2461         [ +  - ]:        376 :    return body_new;
    2462                 :            : }
    2463                 :            : 
    2464                 :            : //-------------------------------------------------------------------------
    2465                 :            : // Purpose       : Check if bodies can be webcut
    2466                 :            : //
    2467                 :            : // Special Notes :
    2468                 :            : //
    2469                 :            : // Creator       : Jason Kraftcheck
    2470                 :            : //
    2471                 :            : // Creation Date : 10/10/03
    2472                 :            : //-------------------------------------------------------------------------
    2473                 :        259 : CubitStatus GeometryModifyTool::okay_to_modify(
    2474                 :            :                                  DLIList<Body*>& webcut_body_list,
    2475                 :            :                                  const char* op ) const
    2476                 :            : {
    2477                 :        259 :   CubitStatus ret = CUBIT_SUCCESS;
    2478                 :            : 
    2479                 :        259 :   Body *b = webcut_body_list.get();
    2480         [ +  - ]:        259 :   if(b)
    2481                 :            :   {
    2482                 :        259 :     GeometryModifyEngine *gme = get_engine(b);
    2483         [ +  - ]:        259 :     if(gme)
    2484                 :            :     {
    2485   [ -  +  #  # ]:        259 :       if(!gme->supports_interoperability() &&
                 [ -  + ]
    2486                 :          0 :           contains_intermediate_geom(webcut_body_list))
    2487                 :            :       {
    2488 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Intermixing real and virtual geometry operations using the current solid modeling kernel is not allowed.\n");
    2489                 :        259 :         ret = CUBIT_FAILURE;
    2490                 :            :       }
    2491                 :            :     }
    2492                 :            :   }
    2493                 :            : 
    2494         [ +  - ]:        259 :   if(ret == CUBIT_SUCCESS)
    2495                 :            :   {
    2496                 :            :     // If the operation is not one of the ones below...
    2497 [ +  + ][ +  - ]:        259 :     if(strcmp(op, "WEBCUT") &&
    2498         [ +  + ]:        237 :       strcmp(op, "CHOP") &&
    2499         [ +  - ]:        150 :       strcmp(op, "UNITE") &&
    2500         [ +  + ]:        150 :       strcmp(op, "TWEAK") &&
    2501         [ +  - ]:        119 :       strcmp(op, "IMPRINT") &&
    2502         [ +  - ]:        119 :       strcmp(op, "REGULARIZE") &&
    2503         [ +  - ]:        119 :       strcmp(op, "SPLIT_SURFACE") &&
    2504         [ +  + ]:        119 :       strcmp(op, "REMOVE_TOPOLOGY") &&
    2505         [ +  + ]:        108 :       strcmp(op, "SPLIT") &&
    2506                 :        108 :       strcmp(op, "NON_UNIFORM_SCALE"))
    2507                 :            :     {
    2508         [ -  + ]:         97 :       if (contains_intermediate_geom(webcut_body_list))
    2509                 :            :       {
    2510 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Performing %s on volumes containing virtual geometry is not allowed.\n", op);
    2511                 :          0 :         ret = CUBIT_FAILURE;
    2512                 :            :       }
    2513                 :            :     }
    2514                 :            :     else
    2515                 :            :     {
    2516         [ -  + ]:        162 :       if(contains_partitions(webcut_body_list))
    2517                 :            :       {
    2518 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Performing %s on volumes containing virtual partitions is not allowed.\n", op);
    2519                 :        259 :         ret = CUBIT_FAILURE;
    2520                 :            :       }
    2521                 :            :     }
    2522                 :            :   }
    2523                 :            : 
    2524                 :        259 :   return ret;
    2525                 :            : }
    2526                 :            : 
    2527                 :            : 
    2528                 :            : //-------------------------------------------------------------------------
    2529                 :            : // Purpose       : Common code for finishing webcut operations.
    2530                 :            : //
    2531                 :            : // Special Notes :
    2532                 :            : //
    2533                 :            : // Creator       : Jason Kraftcheck
    2534                 :            : //
    2535                 :            : // Creation Date : 09/25/03
    2536                 :            : //-------------------------------------------------------------------------
    2537                 :         22 : CubitStatus GeometryModifyTool::finish_webcut( DLIList<Body*>& webcut_body_list,
    2538                 :            :                                                DLIList<BodySM*>& result_body_sms,
    2539                 :            :                                                CubitBoolean merge,
    2540                 :            :                                                CubitStatus status,
    2541                 :            :                                                DLIList<Body*>& result_list,
    2542                 :            :                                                DLIList<int> *merged_surface_ids,
    2543                 :            :                                                DLIList<int> *merged_curve_ids,
    2544                 :            :                                                CubitBoolean print_info) const
    2545                 :            : {
    2546 [ +  - ][ -  + ]:         22 :    if (!finish_sm_op(webcut_body_list, result_body_sms, result_list,(bool)print_info))
    2547                 :          0 :      status = CUBIT_FAILURE;
    2548                 :            : 
    2549         [ +  - ]:         22 :    DLIList<Body*> temp_result_list;
    2550         [ +  - ]:         22 :    if (status)
    2551                 :            :    {
    2552         [ +  - ]:         22 :      status = separate_body_after_webcut( result_list, temp_result_list);
    2553         [ +  - ]:         22 :      result_list = temp_result_list;
    2554                 :            :    }
    2555                 :            : 
    2556 [ +  - ][ +  - ]:         22 :    if( merged_surface_ids && merged_curve_ids )
    2557         [ +  - ]:         22 :      fixup_merged_entities( *merged_surface_ids, *merged_curve_ids );
    2558                 :            : 
    2559 [ -  + ][ #  # ]:         22 :    if (merge && status)
    2560                 :            :    {
    2561         [ #  # ]:          0 :      DLIList<Body*> temp_results(result_list);
    2562 [ #  # ][ #  # ]:          0 :      status = MergeTool::instance()->merge_bodies( temp_results );
                 [ #  # ]
    2563                 :            :    }
    2564         [ +  - ]:         22 :    return status;
    2565                 :            : }
    2566                 :            : 
    2567                 :            : 
    2568                 :            : //-------------------------------------------------------------------------
    2569                 :            : // Purpose       : Complete solid modeling operation on bodies
    2570                 :            : //
    2571                 :            : // Special Notes :
    2572                 :            : //
    2573                 :            : // Creator       : Jason Kraftcheck
    2574                 :            : //
    2575                 :            : // Creation Date : 09/25/03
    2576                 :            : //-------------------------------------------------------------------------
    2577                 :        237 : CubitStatus GeometryModifyTool::finish_sm_op( DLIList<Body*>& input_bodies,
    2578                 :            :                                               DLIList<BodySM*>& new_bodies,
    2579                 :            :                                               DLIList<Body*>& result_bodies,
    2580                 :            :                                               bool print_info ) const
    2581                 :            : {
    2582                 :            :   int i;
    2583         [ +  - ]:        237 :   GeometryQueryTool* gqt = GeometryQueryTool::instance();
    2584                 :            : 
    2585 [ +  - ][ +  - ]:        474 :   DLIList<int> updated_ids, created_ids, destroyed_ids;
         [ +  - ][ +  - ]
                 [ +  - ]
    2586 [ +  - ][ +  - ]:        474 :   DLIList<int> updated_vol_ids, created_vol_ids, destroyed_vol_ids;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2587                 :            : 
    2588                 :            :   // traverse the body object and remove any meshes from modified objects
    2589                 :            :   int b;
    2590 [ +  - ][ +  + ]:        819 :   for (b = 0; b < input_bodies.size(); b++) {
    2591         [ +  - ]:        582 :           Body* body = input_bodies.get_and_step();
    2592 [ +  - ][ +  - ]:        582 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_MODIFIED, body));
         [ +  - ][ +  - ]
                 [ +  - ]
    2593                 :            :   }
    2594                 :            : 
    2595                 :            :     // Remove dead bodies
    2596         [ +  - ]:        237 :   input_bodies.reset();
    2597 [ +  - ][ +  + ]:        819 :   for (i = input_bodies.size(); i--;)
    2598                 :            :   {
    2599         [ +  - ]:        582 :     Body* body = input_bodies.step_and_get();
    2600                 :            : 
    2601         [ +  - ]:        582 :     BodySM* bodysm = body->get_body_sm_ptr();
    2602         [ +  + ]:        582 :     if (!bodysm)
    2603                 :            :     {
    2604                 :            :         // If the body was destroyed, update the list
    2605 [ +  - ][ +  - ]:        337 :       destroyed_ids.append( body->id() );
    2606                 :            : 
    2607         [ +  - ]:        337 :       DLIList<RefVolume*> temp_vols;
    2608         [ +  - ]:        337 :       body->ref_volumes( temp_vols );
    2609 [ +  - ][ +  + ]:        695 :       for( int nv = temp_vols.size(); nv > 0; nv-- )
    2610                 :            :       {
    2611 [ +  - ][ +  - ]:        358 :         if( !temp_vols.get()->get_lump_ptr() )
                 [ +  - ]
    2612 [ +  - ][ +  - ]:        358 :           destroyed_vol_ids.append( temp_vols.get_and_step()->id() );
                 [ +  - ]
    2613                 :            :       }
    2614                 :            : 
    2615         [ +  - ]:        337 :       input_bodies.change_to(0);
    2616 [ +  - ][ +  - ]:        337 :       gqt->destroy_dead_entity(body);
    2617                 :            :     }
    2618                 :            :     else
    2619                 :            :     {
    2620 [ +  - ][ +  - ]:        245 :       remove_dead_entity_names( body );
    2621                 :            :     }
    2622                 :            :   }
    2623         [ +  - ]:        237 :   gqt->cleanout_deactivated_geometry();
    2624                 :            : 
    2625                 :            :     // Create new bodies
    2626         [ +  - ]:        237 :   new_bodies.last();
    2627 [ +  - ][ +  + ]:        487 :   for (i = new_bodies.size(); i--; )
    2628                 :            :   {
    2629         [ +  - ]:        250 :     BodySM* bodysm = new_bodies.step_and_get();
    2630         [ +  - ]:        250 :     bool newbody = bodysm->owner() == 0;
    2631         [ +  - ]:        250 :     Body* body = gqt->make_Body(bodysm);
    2632         [ +  - ]:        250 :     result_bodies.append(body);
    2633                 :            : 
    2634         [ +  + ]:        250 :     if (newbody)
    2635                 :            :     {
    2636 [ +  - ][ +  - ]:         76 :       created_ids.append(body->id());
    2637                 :            : 
    2638         [ +  - ]:         76 :       DLIList<RefVolume*> temp_vols;
    2639         [ +  - ]:         76 :       body->ref_volumes( temp_vols );
    2640 [ +  - ][ +  + ]:        349 :       for( int nv = temp_vols.size(); nv > 0; nv-- )
    2641                 :            :       {
    2642 [ +  - ][ +  - ]:        273 :         created_vol_ids.append( temp_vols.get_and_step()->id() );
                 [ +  - ]
    2643         [ +  - ]:         76 :       }
    2644                 :            :     }
    2645                 :            :     else
    2646                 :            :     {
    2647 [ +  - ][ +  - ]:        174 :       updated_ids.append(body->id());
    2648                 :            : 
    2649         [ +  - ]:        174 :       DLIList<RefVolume*> temp_vols;
    2650         [ +  - ]:        174 :       body->ref_volumes( temp_vols );
    2651 [ +  - ][ +  + ]:        348 :       for( int nv = temp_vols.size(); nv > 0; nv-- )
    2652                 :            :       {
    2653 [ +  - ][ +  - ]:        174 :         updated_vol_ids.append( temp_vols.get_and_step()->id() );
                 [ +  - ]
    2654         [ +  - ]:        250 :       }
    2655                 :            :     }
    2656                 :            :   }
    2657         [ +  - ]:        237 :   gqt->cleanout_deactivated_geometry();
    2658                 :            : 
    2659         [ +  - ]:        237 :   if (print_info)
    2660                 :            :   {
    2661 [ +  - ][ +  - ]:        237 :     if( DEBUG_FLAG( 153 ) )
                 [ -  + ]
    2662                 :            :     {
    2663 [ #  # ][ #  # ]:          0 :       if (created_ids.size())
    2664         [ #  # ]:          0 :          CubitUtil::list_entity_ids( "Created body(s): ", created_ids );
    2665 [ #  # ][ #  # ]:          0 :       if (updated_ids.size())
    2666         [ #  # ]:          0 :          CubitUtil::list_entity_ids( "Updated body(s): ", updated_ids );
    2667 [ #  # ][ #  # ]:          0 :       if (destroyed_ids.size())
    2668         [ #  # ]:          0 :          CubitUtil::list_entity_ids( "Destroyed body(s): ", destroyed_ids );
    2669                 :            :     }
    2670                 :            : 
    2671 [ +  - ][ +  + ]:        237 :     if (created_vol_ids.size())
    2672         [ +  - ]:         76 :        CubitUtil::list_entity_ids( "Created volume(s): ", created_vol_ids );
    2673 [ +  - ][ +  + ]:        237 :     if (updated_vol_ids.size())
    2674         [ +  - ]:        163 :        CubitUtil::list_entity_ids( "Updated volume(s): ", updated_vol_ids );
    2675 [ +  - ][ +  + ]:        237 :     if (destroyed_vol_ids.size())
    2676         [ +  - ]:        173 :        CubitUtil::list_entity_ids( "Destroyed volume(s): ", destroyed_vol_ids );
    2677                 :            :   }
    2678                 :            : 
    2679         [ +  - ]:        237 :   return CUBIT_SUCCESS;
    2680                 :            : }
    2681                 :            : 
    2682                 :            : 
    2683                 :            : 
    2684                 :            : //-------------------------------------------------------------------------
    2685                 :            : // Purpose       : Webcut a body with a cylinder given the input parameters.
    2686                 :            : // Special Notes :
    2687                 :            : //
    2688                 :            : // Creator       : David White
    2689                 :            : //
    2690                 :            : // Creation Date : 10/28/97
    2691                 :            : //-------------------------------------------------------------------------
    2692                 :          0 : CubitStatus GeometryModifyTool::webcut_with_cylinder(
    2693                 :            :                                        DLIList<Body*>& webcut_body_list,
    2694                 :            :                                        double radius,
    2695                 :            :                                        const CubitVector &axis,
    2696                 :            :                                        const CubitVector &center,
    2697                 :            :                                        DLIList<Body*>& results_list,
    2698                 :            :                                        DLIList<Body*> &neighboring_bodies,
    2699                 :            :                                        ImprintType imprint_type,
    2700                 :            :                                        CubitBoolean merge,
    2701                 :            :                                        CubitBoolean preview)
    2702                 :            : {
    2703 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    2704                 :          0 :     return CUBIT_FAILURE;
    2705                 :            : 
    2706         [ #  # ]:          0 :   GfxPreview::clear();
    2707                 :            : 
    2708                 :          0 :   CubitStatus rval = CUBIT_SUCCESS;
    2709                 :            : 
    2710         [ #  # ]:          0 :   if (preview)
    2711                 :            :   {
    2712                 :            :     // find the bounding box for the cylinder
    2713         [ #  # ]:          0 :     CubitBox bounding_box;
    2714         [ #  # ]:          0 :     Body* body_ptr = webcut_body_list.get_and_step();
    2715 [ #  # ][ #  # ]:          0 :     bounding_box = body_ptr->bounding_box();
                 [ #  # ]
    2716                 :            : 
    2717                 :            :     int i;
    2718 [ #  # ][ #  # ]:          0 :     for( i=1; i<webcut_body_list.size(); i++ )
    2719                 :            :     {
    2720         [ #  # ]:          0 :        body_ptr = webcut_body_list.get_and_step();
    2721 [ #  # ][ #  # ]:          0 :        bounding_box |= body_ptr->bounding_box();
                 [ #  # ]
    2722                 :            :     }
    2723                 :            : 
    2724                 :          0 :     int color = CUBIT_BLUE_INDEX;
    2725         [ #  # ]:          0 :     GfxPreview::draw_cylinder(axis, center, bounding_box, (float) radius, color);
    2726         [ #  # ]:          0 :     GfxPreview::flush();
    2727         [ #  # ]:          0 :     return rval;
    2728                 :            :   }
    2729                 :            : 
    2730 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    2731                 :            :   {
    2732         [ #  # ]:          0 :     DLIList<Body*> bodies_to_save;
    2733         [ #  # ]:          0 :     bodies_to_save += webcut_body_list;
    2734         [ #  # ]:          0 :     bodies_to_save += neighboring_bodies;
    2735 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies_to_save );
    2736                 :            :   }
    2737                 :            : 
    2738         [ #  # ]:          0 :   const int count = webcut_body_list.size();
    2739         [ #  # ]:          0 :   DLIList<BodySM*> result_sm_list;
    2740 [ #  # ][ #  # ]:          0 :   DLIList<Body*> body_list(webcut_body_list);
    2741 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> engine_body_sms(count);
    2742 [ #  # ][ #  # ]:          0 :   DLIList<Body*> engine_bodies(count);
    2743                 :          0 :   GeometryModifyEngine* gme = 0;
    2744                 :            : 
    2745         [ #  # ]:          0 :   if(!preview)
    2746         [ #  # ]:          0 :     do_attribute_setup();
    2747                 :            : 
    2748 [ #  # ][ #  # ]:          0 :   while ( (gme = group_bodies_by_engine(body_list, engine_bodies, engine_body_sms)) )
    2749                 :            :   {
    2750                 :            :     //get all bodysms that we might modify in this operation
    2751         [ #  # ]:          0 :     DLIList<BodySM*> neighbor_imprint_list;
    2752 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> bodies_sm_to_modify;
                 [ #  # ]
    2753 [ #  # ][ #  # ]:          0 :     DLIList<Body*> bodies_to_modify;
                 [ #  # ]
    2754         [ #  # ]:          0 :     bodies_to_modify += engine_bodies;
    2755                 :            :     int i;
    2756 [ #  # ][ #  # ]:          0 :     for( i=neighboring_bodies.size(); i--; )
    2757                 :            :     {
    2758         [ #  # ]:          0 :       Body *tmp_body = neighboring_bodies.get_and_step();
    2759         [ #  # ]:          0 :       BodySM *tmp_body_sm = tmp_body->get_body_sm_ptr();
    2760 [ #  # ][ #  # ]:          0 :       if( gme == get_engine(tmp_body_sm ) )
    2761                 :            :       {
    2762         [ #  # ]:          0 :         neighbor_imprint_list.append( tmp_body_sm );
    2763         [ #  # ]:          0 :         bodies_to_modify.append( tmp_body );
    2764                 :            :       }
    2765                 :            :     }
    2766                 :            : 
    2767 [ #  # ][ #  # ]:          0 :     DLIList<int> merged_surface_ids;
                 [ #  # ]
    2768 [ #  # ][ #  # ]:          0 :     DLIList<int> merged_curve_ids;
                 [ #  # ]
    2769                 :            : 
    2770         [ #  # ]:          0 :     if(!preview)
    2771                 :            :     {
    2772         [ #  # ]:          0 :       bodies_sm_to_modify += neighbor_imprint_list;
    2773                 :            : 
    2774         [ #  # ]:          0 :       push_attributes_before_modify( bodies_sm_to_modify );
    2775                 :            :       //get all the child entities that have been merged
    2776         [ #  # ]:          0 :       get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    2777                 :            :     }
    2778                 :            : 
    2779                 :            :     // note that preview actually gets handled before this point
    2780                 :            :     CubitStatus status = webcut_w_cylinder(engine_body_sms, radius, axis,
    2781         [ #  # ]:          0 :               center, neighbor_imprint_list, result_sm_list, imprint_type );
    2782                 :            : 
    2783         [ #  # ]:          0 :     if ( status != CUBIT_FAILURE )
    2784                 :            :     {
    2785         [ #  # ]:          0 :       if(!preview)
    2786                 :            :       {
    2787         [ #  # ]:          0 :         restore_vg_after_modify(result_sm_list, bodies_to_modify, gme);
    2788         [ #  # ]:          0 :         remove_pushed_attributes(result_sm_list, bodies_to_modify);
    2789                 :            :       }
    2790                 :            :       status = finish_webcut( engine_bodies, result_sm_list, merge, status,
    2791         [ #  # ]:          0 :                               results_list, &merged_surface_ids, &merged_curve_ids );
    2792                 :            :     }
    2793                 :            :     else
    2794                 :            :     {
    2795         [ #  # ]:          0 :       if(!preview)
    2796         [ #  # ]:          0 :         remove_pushed_attributes(result_sm_list, engine_bodies);
    2797                 :            :     }
    2798                 :            : 
    2799                 :            : 
    2800         [ #  # ]:          0 :     engine_bodies.clean_out();
    2801         [ #  # ]:          0 :     engine_body_sms.clean_out();
    2802         [ #  # ]:          0 :     result_sm_list.clean_out();
    2803                 :            : 
    2804         [ #  # ]:          0 :     if ( status == CUBIT_FAILURE )
    2805                 :            :     {
    2806                 :          0 :       rval = CUBIT_FAILURE;
    2807 [ #  # ][ #  # ]:          0 :       break;
    2808                 :            :     }
    2809                 :          0 :   }
    2810                 :            : 
    2811         [ #  # ]:          0 :   if(!preview)
    2812         [ #  # ]:          0 :     do_attribute_cleanup();
    2813                 :            : 
    2814 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    2815                 :            :   {
    2816         [ #  # ]:          0 :     if( rval == CUBIT_SUCCESS )
    2817         [ #  # ]:          0 :       CubitUndo::note_result_bodies( results_list );
    2818                 :            :     else
    2819         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    2820                 :            :   }
    2821                 :            : 
    2822         [ #  # ]:          0 :   return rval;
    2823                 :            : }
    2824                 :            : //*************************************************************************************************************************************
    2825                 :            : //-------------------------------------------------------------------------
    2826                 :            : // Purpose       : Webcut a body with a cone given the input parameters.
    2827                 :            : // Special Notes :
    2828                 :            : //
    2829                 :            : // Creator       : Ajoy
    2830                 :            : //
    2831                 :            : // Creation Date : 04/23/2012
    2832                 :            : //-------------------------------------------------------------------------
    2833                 :          0 : CubitStatus GeometryModifyTool::webcut_with_Cone(
    2834                 :            :                                        DLIList<Body*>& webcut_body_list,
    2835                 :            :                                        DLIList<BodySM*> &webcut_bodySM_list,
    2836                 :            :                                        double outer_radius,double inner_radius,
    2837                 :            :                                        CubitVector& AxisPt1,
    2838                 :            :                                        CubitVector& AxisPt2,
    2839                 :            :                                        DLIList<Body*>& results_list,
    2840                 :            :                                        DLIList<Body*> &neighboring_bodies,
    2841                 :            :                                        ImprintType imprint_type,
    2842                 :            :                                        CubitBoolean merge,
    2843                 :            :                                        CubitBoolean preview)
    2844                 :            : {
    2845 [ #  # ][ #  # ]:          0 :     if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    2846                 :          0 :         return CUBIT_FAILURE;
    2847                 :            : 
    2848                 :          0 :     CubitStatus rval = CUBIT_SUCCESS;
    2849                 :            : 
    2850                 :            : 
    2851         [ #  # ]:          0 :     GfxPreview::clear();
    2852                 :            : 
    2853                 :            : 
    2854                 :            :     // find the height
    2855 [ #  # ][ #  # ]:          0 :     double dHeight  =  sqrt( (AxisPt2.x()-AxisPt1.x()) * (AxisPt2.x()-AxisPt1.x())+
         [ #  # ][ #  # ]
    2856 [ #  # ][ #  # ]:          0 :                             (AxisPt2.y()-AxisPt1.y()) * (AxisPt2.y()-AxisPt1.y())+
         [ #  # ][ #  # ]
    2857 [ #  # ][ #  # ]:          0 :                             (AxisPt2.z()-AxisPt1.z()) * (AxisPt2.z()-AxisPt1.z()) );
         [ #  # ][ #  # ]
    2858                 :            : 
    2859                 :            :     // Find the Tan Angle
    2860                 :          0 :     double Diff        = fabs(outer_radius - inner_radius);
    2861                 :          0 :            Diff       /= dHeight;
    2862                 :          0 :     double dTanAngle   = atan ( Diff ) ;
    2863                 :            : 
    2864         [ #  # ]:          0 :     if (preview)
    2865                 :            :     {
    2866                 :            :         // find the bounding box for the cylinder
    2867         [ #  # ]:          0 :         CubitBox bounding_box;
    2868         [ #  # ]:          0 :         Body* body_ptr = webcut_body_list.get_and_step();
    2869 [ #  # ][ #  # ]:          0 :         bounding_box = body_ptr->bounding_box();
                 [ #  # ]
    2870                 :            : 
    2871                 :            :         int i;
    2872 [ #  # ][ #  # ]:          0 :         for( i=1; i<webcut_body_list.size(); i++ )
    2873                 :            :         {
    2874         [ #  # ]:          0 :             body_ptr = webcut_body_list.get_and_step();
    2875 [ #  # ][ #  # ]:          0 :             bounding_box |= body_ptr->bounding_box();
                 [ #  # ]
    2876                 :            :         }
    2877                 :            : 
    2878         [ #  # ]:          0 :         CubitVector axis;
    2879 [ #  # ][ #  # ]:          0 :         axis.x( AxisPt2.x()-AxisPt1.x() ); axis.y( AxisPt2.y()-AxisPt1.y() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2880 [ #  # ][ #  # ]:          0 :         axis.z( AxisPt2.z()-AxisPt1.z() );
                 [ #  # ]
    2881                 :            : 
    2882                 :            : 
    2883         [ #  # ]:          0 :         CubitVector start;
    2884         [ #  # ]:          0 :         CubitVector end;
    2885                 :            :         double dExtendedOuterRadius;
    2886                 :            :         double dExtendedInnerRadius;
    2887                 :            : 
    2888                 :            : 
    2889                 :            :         // Now extend the 2 end points to extend beyond the BBox limits. In case it converges, stop at the Apex.
    2890                 :            : 
    2891                 :            :          FindExtendedPoints( AxisPt1 , AxisPt2 , outer_radius , inner_radius , axis, dHeight , bounding_box ,
    2892 [ #  # ][ #  # ]:          0 :                              dTanAngle, start , end, dExtendedOuterRadius , dExtendedInnerRadius );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2893                 :            : 
    2894                 :          0 :         int color = CUBIT_BLUE_INDEX;
    2895 [ #  # ][ #  # ]:          0 :         GfxPreview::draw_frustum(axis, start, end, dExtendedOuterRadius, dExtendedInnerRadius ,bounding_box , color);
         [ #  # ][ #  # ]
    2896         [ #  # ]:          0 :         GfxPreview::flush();
    2897         [ #  # ]:          0 :         return rval;
    2898                 :            :     }
    2899                 :            : 
    2900 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
    2901                 :            :     {
    2902         [ #  # ]:          0 :         DLIList<Body*> bodies_to_save;
    2903         [ #  # ]:          0 :         bodies_to_save += webcut_body_list;
    2904         [ #  # ]:          0 :         bodies_to_save += neighboring_bodies;
    2905 [ #  # ][ #  # ]:          0 :         CubitUndo::save_state_with_cubit_file( bodies_to_save );
    2906                 :            :     }
    2907                 :            : 
    2908         [ #  # ]:          0 :     const int count = webcut_body_list.size();
    2909         [ #  # ]:          0 :     DLIList<BodySM*> result_sm_list;
    2910 [ #  # ][ #  # ]:          0 :     DLIList<Body*> body_list(webcut_body_list);
    2911 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> engine_body_sms(count);
    2912 [ #  # ][ #  # ]:          0 :     DLIList<Body*> engine_bodies(count);
    2913                 :          0 :     GeometryModifyEngine* gme = 0;
    2914                 :            : 
    2915         [ #  # ]:          0 :     if(!preview)
    2916         [ #  # ]:          0 :         do_attribute_setup();
    2917                 :            : 
    2918 [ #  # ][ #  # ]:          0 :     while ( (gme = group_bodies_by_engine(webcut_body_list, engine_bodies, engine_body_sms)) )
    2919                 :            :     {
    2920                 :            :         //get all bodysms that we might modify in this operation
    2921         [ #  # ]:          0 :         DLIList<BodySM*> neighbor_imprint_list;
    2922 [ #  # ][ #  # ]:          0 :         DLIList<BodySM*> bodies_sm_to_modify;
                 [ #  # ]
    2923 [ #  # ][ #  # ]:          0 :         DLIList<Body*> bodies_to_modify;
                 [ #  # ]
    2924         [ #  # ]:          0 :         bodies_to_modify += engine_bodies;
    2925                 :            :         int i;
    2926 [ #  # ][ #  # ]:          0 :         for( i=neighboring_bodies.size(); i--; )
    2927                 :            :         {
    2928         [ #  # ]:          0 :             Body *tmp_body = neighboring_bodies.get_and_step();
    2929         [ #  # ]:          0 :             BodySM *tmp_body_sm = tmp_body->get_body_sm_ptr();
    2930 [ #  # ][ #  # ]:          0 :             if( gme == get_engine(tmp_body_sm ) )
    2931                 :            :             {
    2932         [ #  # ]:          0 :                 neighbor_imprint_list.append( tmp_body_sm );
    2933         [ #  # ]:          0 :                 bodies_to_modify.append( tmp_body );
    2934                 :            :             }
    2935                 :            :         }
    2936                 :            : 
    2937                 :            : 
    2938 [ #  # ][ #  # ]:          0 :         DLIList<BodySM*> Body_to_Cut_SM;
                 [ #  # ]
    2939                 :            : 
    2940 [ #  # ][ #  # ]:          0 :         for( i = 0 ;i<webcut_body_list.size(); i++  )
    2941                 :            :         {
    2942         [ #  # ]:          0 :             Body* body           = webcut_body_list.get_and_step();
    2943         [ #  # ]:          0 :             BodySM *Body_To_Cut  = body->get_body_sm_ptr();
    2944                 :            : 
    2945         [ #  # ]:          0 :             Body_to_Cut_SM.append( Body_To_Cut ) ;
    2946                 :            :         }
    2947                 :            : 
    2948                 :            : 
    2949                 :            : 
    2950 [ #  # ][ #  # ]:          0 :         DLIList<int> merged_surface_ids;
                 [ #  # ]
    2951 [ #  # ][ #  # ]:          0 :         DLIList<int> merged_curve_ids;
                 [ #  # ]
    2952                 :            : 
    2953         [ #  # ]:          0 :         if(!preview)
    2954                 :            :         {
    2955         [ #  # ]:          0 :             bodies_sm_to_modify += neighbor_imprint_list;
    2956                 :            : 
    2957         [ #  # ]:          0 :             push_attributes_before_modify( bodies_sm_to_modify );
    2958                 :            :             //get all the child entities that have been merged
    2959         [ #  # ]:          0 :             get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    2960                 :            :         }
    2961                 :            : 
    2962                 :            : 
    2963                 :            :         // Get the overall bounding box of the bodies list
    2964                 :          0 :         Body* body_ptr = NULL;
    2965 [ #  # ][ #  # ]:          0 :         CubitBox bounding_box;
                 [ #  # ]
    2966 [ #  # ][ #  # ]:          0 :         if(body_list.size())
    2967                 :            :         {
    2968         [ #  # ]:          0 :             body_ptr  = body_list.get_and_step();
    2969 [ #  # ][ #  # ]:          0 :             bounding_box = body_ptr->bounding_box();
                 [ #  # ]
    2970 [ #  # ][ #  # ]:          0 :             for( i=1; i<webcut_body_list.size(); i++ )
    2971                 :            :             {
    2972         [ #  # ]:          0 :                 body_ptr = body_list.get_and_step();
    2973 [ #  # ][ #  # ]:          0 :                 bounding_box |= body_ptr->bounding_box();
                 [ #  # ]
    2974                 :            :             }
    2975                 :            :         }
    2976                 :            : 
    2977                 :            : 
    2978                 :            : 
    2979                 :            :         // Get the Geometry engine
    2980                 :            :         GeometryModifyEngine* gme =
    2981 [ #  # ][ #  # ]:          0 :             GeometryModifyTool::instance()->get_engine( body_ptr );
    2982                 :            : 
    2983                 :            : 
    2984                 :            :         //// note that preview actually gets handled before this point
    2985                 :            :         //CubitStatus status = CreateCircularBody(webcut_body_list );
    2986                 :            : 
    2987                 :          0 :         CubitStatus status = CUBIT_SUCCESS;
    2988                 :            : 
    2989                 :            : 
    2990         [ #  # ]:          0 :         CubitVector axis;
    2991 [ #  # ][ #  # ]:          0 :         axis.x( AxisPt2.x()-AxisPt1.x() ); axis.y( AxisPt2.y()-AxisPt1.y() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2992 [ #  # ][ #  # ]:          0 :         axis.z( AxisPt2.z()-AxisPt1.z() );
                 [ #  # ]
    2993                 :            : 
    2994                 :            : 
    2995                 :            : 
    2996                 :            : 
    2997                 :            :         // Set The important deciders.
    2998                 :            : 
    2999                 :          0 :         bool bIfReverseAxis = false;
    3000         [ #  # ]:          0 :         if( outer_radius < inner_radius )
    3001                 :            :         {
    3002                 :          0 :             bIfReverseAxis = true;
    3003                 :            :         }
    3004                 :            : 
    3005                 :            : 
    3006                 :            :         //**************************************//
    3007                 :            :         // find the extension of the narrow end.
    3008                 :            :         //**************************************//
    3009                 :            : 
    3010                 :            :         // For this find the extended end point, at the smaller end
    3011                 :            :         // and assign zero radius, setting that point to be the AxisPt2.
    3012                 :            : 
    3013                 :            :         // Will be done only if outerRad is bigger than innerRad
    3014                 :            :         // Else set a bool to remember that, the inner_radius is set as the outer.
    3015                 :            : 
    3016         [ #  # ]:          0 :         CubitVector endpt ;
    3017         [ #  # ]:          0 :         if( outer_radius > inner_radius )
    3018                 :            :         {
    3019                 :            :             //EndPt  = FindExtendedEndPt( outer_radius , inner_radius , AxisPt2 , axis,  dHeight );
    3020                 :            : 
    3021                 :            : 
    3022                 :          0 :             double Diff     = (outer_radius - inner_radius);
    3023                 :          0 :             Diff    /= dHeight;
    3024                 :          0 :             double dAngle   = atan ( Diff ) ;
    3025         [ #  # ]:          0 :             axis.normalize();
    3026                 :            : 
    3027                 :          0 :             double dTan         = tan( dAngle );
    3028                 :          0 :             double dExtendvalue = inner_radius / dTan;
    3029                 :            : 
    3030 [ #  # ][ #  # ]:          0 :             endpt.x( ( axis.x() * dExtendvalue )  + AxisPt2.x() );
                 [ #  # ]
    3031 [ #  # ][ #  # ]:          0 :             endpt.y( ( axis.y() * dExtendvalue )  + AxisPt2.y() );
                 [ #  # ]
    3032 [ #  # ][ #  # ]:          0 :             endpt.z( ( axis.z() * dExtendvalue )  + AxisPt2.z() );
                 [ #  # ]
    3033                 :            : 
    3034                 :            : 
    3035                 :            : 
    3036 [ #  # ][ #  # ]:          0 :             dHeight = sqrt( (endpt.x() - AxisPt1.x()) * (endpt.x() - AxisPt1.x())+
         [ #  # ][ #  # ]
    3037 [ #  # ][ #  # ]:          0 :                 (endpt.y() - AxisPt1.y()) * (endpt.y() - AxisPt1.y())+
         [ #  # ][ #  # ]
    3038 [ #  # ][ #  # ]:          0 :                 (endpt.z() - AxisPt1.z()) * (endpt.z() - AxisPt1.z()) );
         [ #  # ][ #  # ]
    3039                 :            : 
    3040 [ #  # ][ #  # ]:          0 :             AxisPt2.x( endpt.x() );
    3041 [ #  # ][ #  # ]:          0 :             AxisPt2.y( endpt.y() );
    3042 [ #  # ][ #  # ]:          0 :             AxisPt2.z( endpt.z() );
    3043                 :            :         }
    3044                 :            :         else
    3045                 :            :         {
    3046                 :            :             // reverse the axis.
    3047                 :            : 
    3048 [ #  # ][ #  # ]:          0 :             axis.x( -axis.x());
    3049 [ #  # ][ #  # ]:          0 :             axis.y( -axis.y());
    3050 [ #  # ][ #  # ]:          0 :             axis.z( -axis.z());
    3051                 :            : 
    3052                 :            :             //endpt  = FindExtendedendpt( inner_radius , outer_radius , AxisPt1 , axis,  dHeight );
    3053                 :            : 
    3054                 :            : 
    3055                 :          0 :             double Diff     = (inner_radius - outer_radius);
    3056                 :          0 :             Diff    /= dHeight;
    3057                 :          0 :             double dAngle   = atan ( Diff ) ;
    3058         [ #  # ]:          0 :             axis.normalize();
    3059                 :            : 
    3060                 :          0 :             double dTan        = tan( dAngle );
    3061                 :          0 :             double dExtendvalue = outer_radius / dTan;
    3062                 :            : 
    3063 [ #  # ][ #  # ]:          0 :             endpt.x( ( axis.x() * dExtendvalue )  + AxisPt1.x() );
                 [ #  # ]
    3064 [ #  # ][ #  # ]:          0 :             endpt.y( ( axis.y() * dExtendvalue )  + AxisPt1.y() );
                 [ #  # ]
    3065 [ #  # ][ #  # ]:          0 :             endpt.z( ( axis.z() * dExtendvalue )  + AxisPt1.z() );
                 [ #  # ]
    3066                 :            : 
    3067                 :            : 
    3068                 :            : 
    3069                 :            : 
    3070 [ #  # ][ #  # ]:          0 :             dHeight = sqrt( (endpt.x() - AxisPt2.x()) * (endpt.x() - AxisPt2.x())+
         [ #  # ][ #  # ]
    3071 [ #  # ][ #  # ]:          0 :                 (endpt.y() - AxisPt2.y()) * (endpt.y() - AxisPt2.y())+
         [ #  # ][ #  # ]
    3072 [ #  # ][ #  # ]:          0 :                 (endpt.z() - AxisPt2.z()) * (endpt.z() - AxisPt2.z()) );
         [ #  # ][ #  # ]
    3073                 :            : 
    3074 [ #  # ][ #  # ]:          0 :             AxisPt1.x( endpt.x() );
    3075 [ #  # ][ #  # ]:          0 :             AxisPt1.y( endpt.y() );
    3076 [ #  # ][ #  # ]:          0 :             AxisPt1.z( endpt.z() );
    3077                 :            : 
    3078                 :            :              // reset the axis.
    3079                 :            : 
    3080 [ #  # ][ #  # ]:          0 :             axis.x( -axis.x());
    3081 [ #  # ][ #  # ]:          0 :             axis.y( -axis.y());
    3082 [ #  # ][ #  # ]:          0 :             axis.z( -axis.z());
    3083                 :            : 
    3084                 :            :         }
    3085                 :            : 
    3086                 :            : 
    3087                 :            : 
    3088                 :            :         //*****************************************//
    3089                 :            :         // Now find the extension of the bigger end.
    3090                 :            :         //*****************************************//
    3091                 :            : 
    3092                 :            :         //CubitVector EndPt ;
    3093                 :            :         double dExtendedRadius;
    3094         [ #  # ]:          0 :         if( outer_radius > inner_radius )
    3095                 :            :         {
    3096                 :            :             // reverse the axis.
    3097 [ #  # ][ #  # ]:          0 :             axis.x( -axis.x());
    3098 [ #  # ][ #  # ]:          0 :             axis.y( -axis.y());
    3099 [ #  # ][ #  # ]:          0 :             axis.z( -axis.z());
    3100                 :            : 
    3101                 :            : 
    3102                 :            :             //EndPt  = FindExtendedStartPt( bounding_box , outer_radius , inner_radius , AxisPt1 , axis,  dHeight , dTanAngle , dExtendedRadius );
    3103                 :            : 
    3104                 :            : 
    3105                 :            : 
    3106         [ #  # ]:          0 :             CubitVector Extended_Start_Pt;
    3107                 :            : 
    3108                 :            :             // Find the Difference between the Max and thre min values in all 3 directions.
    3109                 :            :             // Incase the point is within the box limits, then add the difference values
    3110                 :            :             // in all 3 directions , witht he " Axis " as the direction vector and extend the point.
    3111                 :            : 
    3112                 :            :             // After that find the Radius of this bigger end.
    3113                 :            : 
    3114         [ #  # ]:          0 :             CubitVector DiffVec;
    3115                 :            : 
    3116         [ #  # ]:          0 :             axis.normalize();
    3117                 :            : 
    3118 [ #  # ][ #  # ]:          0 :             DiffVec.x( fabs( bounding_box.max_x() - bounding_box.min_x() ));
                 [ #  # ]
    3119 [ #  # ][ #  # ]:          0 :             DiffVec.y( fabs( bounding_box.max_y() - bounding_box.min_y() ));
                 [ #  # ]
    3120 [ #  # ][ #  # ]:          0 :             DiffVec.z( fabs( bounding_box.max_z() - bounding_box.min_z() ));
                 [ #  # ]
    3121                 :            : 
    3122                 :            :             // Extend the start Pt
    3123                 :            : 
    3124 [ #  # ][ #  # ]:          0 :             Extended_Start_Pt.x( AxisPt1.x() + ( axis.x() * DiffVec.x() ) );
         [ #  # ][ #  # ]
    3125 [ #  # ][ #  # ]:          0 :             Extended_Start_Pt.y( AxisPt1.y() + ( axis.y() * DiffVec.y() ) );
         [ #  # ][ #  # ]
    3126 [ #  # ][ #  # ]:          0 :             Extended_Start_Pt.z( AxisPt1.z() + ( axis.z() * DiffVec.z() ) );
         [ #  # ][ #  # ]
    3127                 :            : 
    3128                 :            : 
    3129                 :            :             // Find the length
    3130                 :            : 
    3131 [ #  # ][ #  # ]:          0 :             double dLength = sqrt( (( AxisPt1.x() - Extended_Start_Pt.x()) *  (AxisPt1.x() - Extended_Start_Pt.x()) ) +
         [ #  # ][ #  # ]
    3132 [ #  # ][ #  # ]:          0 :                 (( AxisPt1.y() - Extended_Start_Pt.y()) *  (AxisPt1.y() - Extended_Start_Pt.y()) ) +
         [ #  # ][ #  # ]
    3133 [ #  # ][ #  # ]:          0 :                 (( AxisPt1.z() - Extended_Start_Pt.z()) *  (AxisPt1.z() - Extended_Start_Pt.z()) ) );
         [ #  # ][ #  # ]
    3134                 :            : 
    3135                 :            : 
    3136                 :            : 
    3137                 :            :             // Find the Extended Radius
    3138                 :            : 
    3139                 :          0 :             dExtendedRadius = outer_radius + ( tan( dTanAngle ) * dLength ) ;
    3140                 :            : 
    3141                 :            : 
    3142 [ #  # ][ #  # ]:          0 :             dHeight = sqrt( (Extended_Start_Pt.x() - AxisPt2.x()) * (Extended_Start_Pt.x() - AxisPt2.x())+
         [ #  # ][ #  # ]
    3143 [ #  # ][ #  # ]:          0 :                 (Extended_Start_Pt.y() - AxisPt2.y()) * (Extended_Start_Pt.y() - AxisPt2.y())+
         [ #  # ][ #  # ]
    3144 [ #  # ][ #  # ]:          0 :                 (Extended_Start_Pt.z() - AxisPt2.z()) * (Extended_Start_Pt.z() - AxisPt2.z()) );
         [ #  # ][ #  # ]
    3145                 :            : 
    3146         [ #  # ]:          0 :             if( dExtendedRadius == 0 )
    3147                 :          0 :                 dExtendedRadius = outer_radius;
    3148                 :            : 
    3149 [ #  # ][ #  # ]:          0 :             AxisPt1.x( Extended_Start_Pt.x() );
    3150 [ #  # ][ #  # ]:          0 :             AxisPt1.y( Extended_Start_Pt.y() );
    3151 [ #  # ][ #  # ]:          0 :             AxisPt1.z( Extended_Start_Pt.z() );
    3152                 :            : 
    3153                 :            :             // reverse the axis.
    3154 [ #  # ][ #  # ]:          0 :             axis.x( -axis.x());
    3155 [ #  # ][ #  # ]:          0 :             axis.y( -axis.y());
    3156 [ #  # ][ #  # ]:          0 :             axis.z( -axis.z());
    3157                 :            : 
    3158                 :            :         }
    3159                 :            :         else
    3160                 :            :         {
    3161                 :            :             //EndPt  = FindExtendedStartPt( bounding_box ,  inner_radius , outer_radius , AxisPt2 , axis,  dHeight , dTanAngle , dExtendedRadius );
    3162                 :            : 
    3163                 :            : 
    3164                 :            : 
    3165                 :            : 
    3166         [ #  # ]:          0 :             CubitVector Extended_Start_Pt;
    3167                 :            : 
    3168                 :            :             // Find the Difference between the Max and thre min values in all 3 directions.
    3169                 :            :             // Incase the point is within the box limits, then add the difference values
    3170                 :            :             // in all 3 directions , witht he " Axis " as the direction vector and extend the point.
    3171                 :            : 
    3172                 :            :             // After that find the Radius of this bigger end.
    3173                 :            : 
    3174         [ #  # ]:          0 :             CubitVector DiffVec;
    3175                 :            : 
    3176         [ #  # ]:          0 :             axis.normalize();
    3177                 :            : 
    3178 [ #  # ][ #  # ]:          0 :             DiffVec.x( fabs( bounding_box.max_x() - bounding_box.min_x() ));
                 [ #  # ]
    3179 [ #  # ][ #  # ]:          0 :             DiffVec.y( fabs( bounding_box.max_y() - bounding_box.min_y() ));
                 [ #  # ]
    3180 [ #  # ][ #  # ]:          0 :             DiffVec.z( fabs( bounding_box.max_z() - bounding_box.min_z() ));
                 [ #  # ]
    3181                 :            : 
    3182                 :            :             // Extend the start Pt
    3183                 :            : 
    3184 [ #  # ][ #  # ]:          0 :             Extended_Start_Pt.x( AxisPt2.x() + ( axis.x() * DiffVec.x() ) );
         [ #  # ][ #  # ]
    3185 [ #  # ][ #  # ]:          0 :             Extended_Start_Pt.y( AxisPt2.y() + ( axis.y() * DiffVec.y() ) );
         [ #  # ][ #  # ]
    3186 [ #  # ][ #  # ]:          0 :             Extended_Start_Pt.z( AxisPt2.z() + ( axis.z() * DiffVec.z() ) );
         [ #  # ][ #  # ]
    3187                 :            : 
    3188                 :            : 
    3189                 :            :             // Find the length
    3190                 :            : 
    3191 [ #  # ][ #  # ]:          0 :             double dLength = sqrt( (( AxisPt2.x() - Extended_Start_Pt.x()) *  (AxisPt2.x() - Extended_Start_Pt.x()) ) +
         [ #  # ][ #  # ]
    3192 [ #  # ][ #  # ]:          0 :                 (( AxisPt2.y() - Extended_Start_Pt.y()) *  (AxisPt2.y() - Extended_Start_Pt.y()) ) +
         [ #  # ][ #  # ]
    3193 [ #  # ][ #  # ]:          0 :                 (( AxisPt2.z() - Extended_Start_Pt.z()) *  (AxisPt2.z() - Extended_Start_Pt.z()) ) );
         [ #  # ][ #  # ]
    3194                 :            : 
    3195                 :            : 
    3196                 :            : 
    3197                 :            :             // Find the Extended Radius
    3198                 :            : 
    3199                 :          0 :             dExtendedRadius = inner_radius + ( tan( dTanAngle ) * dLength ) ;
    3200                 :            : 
    3201                 :            : 
    3202 [ #  # ][ #  # ]:          0 :             dHeight = sqrt( (Extended_Start_Pt.x() - AxisPt1.x()) * (Extended_Start_Pt.x() - AxisPt1.x())+
         [ #  # ][ #  # ]
    3203 [ #  # ][ #  # ]:          0 :                 (Extended_Start_Pt.y() - AxisPt1.y()) * (Extended_Start_Pt.y() - AxisPt1.y())+
         [ #  # ][ #  # ]
    3204 [ #  # ][ #  # ]:          0 :                 (Extended_Start_Pt.z() - AxisPt1.z()) * (Extended_Start_Pt.z() - AxisPt1.z()) );
         [ #  # ][ #  # ]
    3205                 :            : 
    3206 [ #  # ][ #  # ]:          0 :             AxisPt2.x( Extended_Start_Pt.x() );
    3207 [ #  # ][ #  # ]:          0 :             AxisPt2.y( Extended_Start_Pt.y() );
    3208 [ #  # ][ #  # ]:          0 :             AxisPt2.z( Extended_Start_Pt.z() );
    3209                 :            : 
    3210         [ #  # ]:          0 :             if( dExtendedRadius == 0 )
    3211                 :          0 :                 dExtendedRadius = outer_radius;
    3212                 :            : 
    3213                 :            :         }
    3214                 :            : 
    3215                 :            : 
    3216                 :            : 
    3217                 :            :         //Create the cylinder
    3218                 :            : 
    3219                 :          0 :         BodySM* bodySM_Ptr = NULL;
    3220                 :          0 :         outer_radius       = dExtendedRadius;
    3221                 :          0 :         inner_radius       = 0;
    3222 [ #  # ][ #  # ]:          0 :         bodySM_Ptr         = gmeList.get()->cylinder( dHeight, outer_radius, outer_radius, inner_radius );
    3223                 :            : 
    3224                 :            : 
    3225         [ #  # ]:          0 :         if( !bodySM_Ptr )
    3226                 :            :         {
    3227                 :          0 :             return CUBIT_FAILURE;
    3228                 :            :         }
    3229                 :            : 
    3230                 :            : 
    3231 [ #  # ][ #  # ]:          0 :         DLIList<Curve*> curve_list;
                 [ #  # ]
    3232                 :            : 
    3233         [ #  # ]:          0 :         bodySM_Ptr->curves(curve_list);
    3234                 :            : 
    3235                 :            :         // infor for the Frustum Axis
    3236                 :            : 
    3237         [ #  # ]:          0 :         CubitVector Frustum_Axis;
    3238                 :            : 
    3239         [ #  # ]:          0 :         Frustum_Axis.x(0);
    3240         [ #  # ]:          0 :         Frustum_Axis.y(0);
    3241         [ #  # ]:          0 :         Frustum_Axis.z(dHeight);
    3242                 :            : 
    3243                 :            : 
    3244                 :            : 
    3245                 :            : 
    3246         [ #  # ]:          0 :         if( bIfReverseAxis )
    3247 [ #  # ][ #  # ]:          0 :             axis.z( -axis.z() );
    3248                 :            : 
    3249                 :            : 
    3250                 :            :         // Get Cross product for the resultant vector, which will be the axis for rotation
    3251         [ #  # ]:          0 :         CubitVector cross;
    3252 [ #  # ][ #  # ]:          0 :         cross = Frustum_Axis * axis;
    3253                 :            : 
    3254                 :            : 
    3255                 :            :         // 2. Find the Angle Between them
    3256         [ #  # ]:          0 :         CubitVector Angle;
    3257         [ #  # ]:          0 :         double dAngle  = Angle.vector_angle( Frustum_Axis , axis );
    3258                 :            : 
    3259                 :            : 
    3260                 :            : 
    3261                 :            :         //Now find the angle and the axis to rotate about...
    3262                 :            : 
    3263                 :          0 :         dAngle = 180.0*dAngle/CUBIT_PI;
    3264                 :            : 
    3265         [ #  # ]:          0 :         if( bIfReverseAxis )
    3266                 :          0 :             dAngle = 360 - dAngle ;
    3267                 :            : 
    3268                 :            : 
    3269                 :            : 
    3270                 :            :         // 3. Rotate the body for the received cross product axis ( cross ) as the axis
    3271                 :            :         // and for the angle, dAngle
    3272                 :            :         //GeometryQueryTool::instance()->rotate( cutting_tool_ptr , cross , dAngle );
    3273                 :            : 
    3274         [ #  # ]:          0 :         GeometryQueryEngine* engine = bodySM_Ptr->get_geometry_query_engine();
    3275         [ #  # ]:          0 :         CubitStatus result = engine->rotate( bodySM_Ptr, cross, dAngle );
    3276                 :            : 
    3277                 :            : 
    3278                 :            :         // 4. Now find the mid-point of the specified 2 vertices, and assign that as the
    3279                 :            :         //    2'nd parameter, for the Pt at which the center of the, created frustum should lie.
    3280                 :            : 
    3281         [ #  # ]:          0 :         CubitVector Pt;
    3282 [ #  # ][ #  # ]:          0 :         Pt.x( (AxisPt1.x() + AxisPt2.x() )/2  );
                 [ #  # ]
    3283 [ #  # ][ #  # ]:          0 :         Pt.y( (AxisPt1.y() + AxisPt2.y() )/2  );
                 [ #  # ]
    3284 [ #  # ][ #  # ]:          0 :         Pt.z( (AxisPt1.z() + AxisPt2.z() )/2  );
                 [ #  # ]
    3285                 :            : 
    3286                 :            : 
    3287                 :            : 
    3288                 :            :         // 5 . Now move the body to the location of the target_center.
    3289                 :            : 
    3290 [ #  # ][ #  # ]:          0 :         CubitTransformMatrix xform;
                 [ #  # ]
    3291         [ #  # ]:          0 :         xform.translate( Pt );
    3292         [ #  # ]:          0 :         result = engine->translate( bodySM_Ptr, Pt );
    3293                 :            : 
    3294                 :            : 
    3295                 :            : 
    3296                 :            : 
    3297         [ #  # ]:          0 :         if (!result )
    3298                 :            :         {
    3299         [ #  # ]:          0 :             if(!preview)
    3300                 :            :             {
    3301         [ #  # ]:          0 :                 restore_vg_after_modify(result_sm_list, bodies_to_modify, gme);
    3302         [ #  # ]:          0 :                 remove_pushed_attributes(result_sm_list, bodies_to_modify);
    3303                 :            :             }
    3304                 :            :             status = finish_webcut( engine_bodies, result_sm_list, merge, status,
    3305         [ #  # ]:          0 :                 results_list, &merged_surface_ids, &merged_curve_ids );
    3306                 :            :         }
    3307                 :            :         else
    3308                 :            :         {
    3309         [ #  # ]:          0 :             if(!preview)
    3310         [ #  # ]:          0 :                 remove_pushed_attributes(result_sm_list, engine_bodies);
    3311                 :            :         }
    3312                 :            : 
    3313         [ #  # ]:          0 :         if ( !result )
    3314                 :            :         {
    3315                 :          0 :             rval = CUBIT_FAILURE;
    3316         [ #  # ]:          0 :             engine_bodies.clean_out();
    3317         [ #  # ]:          0 :             engine_body_sms.clean_out();
    3318         [ #  # ]:          0 :             result_sm_list.clean_out();
    3319                 :          0 :             return rval;
    3320                 :            :         }
    3321                 :            : 
    3322 [ #  # ][ #  # ]:          0 :         DLIList<BodySM*> results_list_SM;
         [ #  # ][ #  # ]
    3323 [ #  # ][ #  # ]:          0 :         DLIList<BodySM*> neighboring_bodies_SM;
    3324                 :            :         // Use the BODY to perform webcut
    3325                 :            :         rval = gme->webcut(engine_body_sms, bodySM_Ptr,
    3326         [ #  # ]:          0 :             neighboring_bodies_SM, results_list_SM, imprint_type, preview );
    3327                 :            : 
    3328 [ #  # ][ #  # ]:          0 :         if( GeometryQueryTool::instance()->history().is_tracking() )
         [ #  # ][ #  # ]
    3329                 :            :         {
    3330         [ #  # ]:          0 :             if( rval == CUBIT_SUCCESS )
    3331                 :            :             {
    3332 [ #  # ][ #  # ]:          0 :                 gme->get_gqe()->delete_solid_model_entities(bodySM_Ptr);
    3333                 :            :             }
    3334                 :            :         }
    3335                 :            : 
    3336                 :            :         // if we're doing the real thing (not preview) finish the process
    3337         [ #  # ]:          0 :         if (!preview)
    3338                 :            :         {
    3339         [ #  # ]:          0 :             restore_vg_after_modify(results_list_SM, body_list, gme);
    3340         [ #  # ]:          0 :             remove_pushed_attributes(results_list_SM, body_list);
    3341                 :            :             rval = finish_webcut( bodies_to_modify, results_list_SM, merge,
    3342         [ #  # ]:          0 :                 rval, results_list);
    3343         [ #  # ]:          0 :             do_attribute_cleanup();
    3344                 :            : 
    3345                 :            :             //GeometryQueryTool::instance()->delete_Body( cutting_tool_ptr );
    3346         [ #  # ]:          0 :             GeometryQueryEngine* gqe = bodySM_Ptr->get_geometry_query_engine();
    3347         [ #  # ]:          0 :             gqe->delete_solid_model_entities(bodySM_Ptr);
    3348                 :            :         }
    3349                 :            : 
    3350 [ #  # ][ #  # ]:          0 :         if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
    3351                 :            :         {
    3352         [ #  # ]:          0 :             if( rval == CUBIT_SUCCESS )
    3353         [ #  # ]:          0 :                 CubitUndo::note_result_bodies( results_list );
    3354                 :            :             else
    3355         [ #  # ]:          0 :                 CubitUndo::remove_last_undo();
    3356                 :            :         }
    3357                 :            : 
    3358         [ #  # ]:          0 :         engine_bodies.clean_out();
    3359         [ #  # ]:          0 :         engine_body_sms.clean_out();
    3360         [ #  # ]:          0 :         result_sm_list.clean_out();
    3361                 :          0 :     }
    3362         [ #  # ]:          0 :     return rval;
    3363                 :            : }
    3364                 :            : //************************************************************************************************************************************************************
    3365                 :        120 : void GeometryModifyTool::do_attribute_setup(void)
    3366                 :            : {
    3367                 :            :   //save attribute settings
    3368                 :        120 :   CGMApp::instance()->save_current_attribute_states();
    3369                 :            : 
    3370                 :            :   //Turn off all attributes
    3371                 :        120 :   CubitAttribManager *attrib_manager = CGMApp::instance()->attrib_manager();
    3372                 :        120 :   attrib_manager->set_all_auto_update_flags( CUBIT_FALSE );
    3373                 :        120 :   attrib_manager->set_all_auto_actuate_flags( CUBIT_FALSE );
    3374                 :        120 :   attrib_manager->set_all_auto_write_flags( CUBIT_FALSE );
    3375                 :        120 :   attrib_manager->set_all_auto_read_flags( CUBIT_FALSE );
    3376                 :            : 
    3377                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_ENTITY_NAME, CUBIT_TRUE);
    3378                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_ENTITY_NAME, CUBIT_TRUE);
    3379                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_ENTITY_NAME, CUBIT_TRUE);
    3380                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_ENTITY_NAME, CUBIT_TRUE);
    3381                 :            : 
    3382                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_MESH_OUTPUT_GROUP, CUBIT_TRUE);
    3383                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_MESH_OUTPUT_GROUP, CUBIT_TRUE);
    3384                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_MESH_OUTPUT_GROUP, CUBIT_TRUE);
    3385                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_MESH_OUTPUT_GROUP, CUBIT_TRUE);
    3386                 :            : 
    3387                 :            : 
    3388                 :            :   // enable update, actuate, write, read for composite attributes
    3389                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_COMPOSITE_VG, CUBIT_TRUE);
    3390                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_COMPOSITE_VG, CUBIT_TRUE);
    3391                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_COMPOSITE_VG, CUBIT_TRUE);
    3392                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_COMPOSITE_VG, CUBIT_TRUE);
    3393                 :            :   // enable update, actuate, write, read for partition attributes
    3394                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_PARTITION_VG, CUBIT_TRUE);
    3395                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_PARTITION_VG, CUBIT_TRUE);
    3396                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_PARTITION_VG, CUBIT_TRUE);
    3397                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_PARTITION_VG, CUBIT_TRUE);
    3398                 :            :   // enable update, actuate, write, read for entity ids
    3399                 :            :   // We will use these ID atts to make sure the ref entities associated with unmodified
    3400                 :            :   // virtual bridges will maintain the same ids after real operations.
    3401                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_ENTITY_ID, CUBIT_TRUE);
    3402                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_ENTITY_ID, CUBIT_TRUE);
    3403                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_ENTITY_ID, CUBIT_TRUE);
    3404                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_ENTITY_ID, CUBIT_TRUE);
    3405                 :            :   // enable metadata attributes
    3406                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_ASSEMBLY_DATA, CUBIT_TRUE);
    3407                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_ASSEMBLY_DATA, CUBIT_TRUE);
    3408                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_write_flag(CA_ASSEMBLY_DATA, CUBIT_TRUE);
    3409                 :        120 :   CGMApp::instance()->attrib_manager()->set_auto_read_flag(CA_ASSEMBLY_DATA, CUBIT_TRUE);
    3410                 :        120 : }
    3411                 :            : 
    3412                 :        120 : void GeometryModifyTool::do_attribute_cleanup(void)
    3413                 :            : {
    3414                 :            : 
    3415                 :        120 :   CGMApp::instance()->restore_previous_attribute_states();
    3416                 :        120 : }
    3417                 :            : 
    3418                 :            : // Pushes virtual geometry and boundary condition
    3419                 :            : //attributes down to the underlying solid model topology
    3420                 :        120 : void GeometryModifyTool::push_attributes_before_modify(DLIList<BodySM*> &old_sms)
    3421                 :            : {
    3422                 :            :   // Get all of the ref entities involved and push CA_ENTITY_ID attributes
    3423                 :            :   // on to them.  This will help us maintain ids on virtual that doesn't
    3424                 :            :   // get modified by the real operation.
    3425                 :            :   int i;
    3426         [ +  - ]:        120 :   DLIList<RefVolume*> volume_list;
    3427                 :            : 
    3428 [ +  - ][ +  + ]:        437 :   for(i=old_sms.size(); i--;)
    3429                 :            :   {
    3430         [ +  - ]:        317 :     BodySM *bsm = old_sms.get_and_step();
    3431 [ +  - ][ -  + ]:        317 :     Body *body = dynamic_cast<Body*>(bsm->topology_entity());
    3432         [ +  - ]:        317 :     if(body)
    3433                 :            :     {
    3434                 :            :       // Append to the total list of volumes.
    3435         [ +  - ]:        317 :       body->ref_volumes(volume_list);
    3436                 :            :     }
    3437                 :            :   }
    3438                 :            :   // get all child entities (only get entities below volumes)
    3439 [ +  - ][ +  - ]:        240 :   DLIList<RefEntity*> child_list, ref_ent_list;
         [ +  - ][ +  - ]
    3440 [ +  - ][ +  - ]:        437 :   CAST_LIST_TO_PARENT(volume_list, ref_ent_list);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  + ]
    3441         [ +  - ]:        120 :   RefEntity::get_all_child_ref_entities( ref_ent_list, child_list );
    3442                 :            : 
    3443                 :            :   //by including the volumes we can propagate the bcs on them
    3444                 :            :   //across webcuts
    3445         [ +  - ]:        120 :   child_list+=ref_ent_list;
    3446                 :            : 
    3447                 :            : 
    3448                 :            :   // Only push the id attributes if we are doing persistent ids.
    3449 [ +  - ][ +  - ]:        120 :   if(!get_new_ids())
    3450         [ +  - ]:        120 :     CubitAttribUser::auto_update_cubit_attrib(child_list);
    3451                 :            : 
    3452 [ +  - ][ +  - ]:        240 :   DLIList<TopologyBridge*> top_bridges;
    3453 [ +  - ][ +  - ]:        437 :   CAST_LIST_TO_PARENT(old_sms, top_bridges);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
    3454 [ +  - ][ +  - ]:        240 :   GeometryQueryTool::instance()->ige_export_geom(top_bridges);
                 [ +  - ]
    3455                 :        120 : }
    3456                 :            : 
    3457                 :            : // Push imprint specific attributes down to the underlying solid model
    3458                 :            : // topology prior to imprinting.
    3459                 :          0 : void GeometryModifyTool::push_imprint_attributes_before_modify(DLIList<BodySM*> &body_sms)
    3460                 :            : {
    3461                 :          0 :   GeometryQueryTool::instance()->ige_push_imprint_attributes_before_modify(body_sms);
    3462                 :          0 : }
    3463                 :            : 
    3464                 :          0 : void GeometryModifyTool::push_named_attributes_to_curves_and_points(DLIList<TopologyBridge*> &tb_list,
    3465                 :            :                                                              const char *name_in)
    3466                 :            : {
    3467                 :          0 :   GeometryQueryTool::instance()->ige_push_named_attributes_to_curves_and_points(tb_list, name_in);
    3468                 :          0 : }
    3469                 :            : 
    3470                 :            : // Cleanup imprint attributes that were pushed onto the underlying solid
    3471                 :            : // model topology.
    3472                 :          0 : void GeometryModifyTool::remove_imprint_attributes_after_modify(DLIList<BodySM*> &old_sms,
    3473                 :            :                                                                 DLIList<BodySM*> &new_sms)
    3474                 :            : {
    3475                 :          0 :   GeometryQueryTool::instance()->ige_remove_imprint_attributes_after_modify(old_sms, new_sms);
    3476                 :          0 : }
    3477                 :            : 
    3478                 :            : #ifdef CAT
    3479                 :            : CubitStatus GeometryModifyTool::webcut_across_translate(
    3480                 :            :                                           DLIList<Body*> &webcut_body_list,
    3481                 :            :                                           RefFace *ref_face_top,
    3482                 :            :                                           RefFace *ref_face_bottom,
    3483                 :            :                                           DLIList<Body*> &results_list,
    3484                 :            :                                           ImprintType imprint_type,
    3485                 :            :                                           CubitBoolean merge,
    3486                 :            :                                           CubitBoolean preview)
    3487                 :            : {
    3488                 :            :   if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    3489                 :            :     return CUBIT_FAILURE;
    3490                 :            : 
    3491                 :            :   DLIList<Body*> original_body_list = webcut_body_list;
    3492                 :            :   const int count = webcut_body_list.size() + 2;
    3493                 :            :   DLIList<TopologyEntity*> entity_list(count);
    3494                 :            :   DLIList<TopologyBridge*> bridge_list(count);
    3495                 :            :   CAST_LIST_TO_PARENT(webcut_body_list, entity_list);
    3496                 :            :   entity_list.append( ref_face_top );
    3497                 :            :   entity_list.append( ref_face_bottom );
    3498                 :            :   GeometryModifyEngine* gme = common_modify_engine( entity_list, bridge_list );
    3499                 :            : 
    3500                 :            :   if ( !gme )
    3501                 :            :   {
    3502                 :            :      PRINT_ERROR("Performing WEBCUTS on volumes containing geometry from\n"
    3503                 :            :                  "different modeling engines is not allowed.\n"
    3504                 :            :                  "Delete uncommon geometry on these volumes before operation.\n\n");
    3505                 :            :      return CUBIT_FAILURE;
    3506                 :            :   }
    3507                 :            : 
    3508                 :            :   Surface* surface_bottom = dynamic_cast<Surface*>(bridge_list.pop());
    3509                 :            :   Surface* surface_top    = dynamic_cast<Surface*>(bridge_list.pop());
    3510                 :            :   DLIList<BodySM*> result_sm_list, webcut_sm_list(bridge_list.size());
    3511                 :            :   CAST_LIST(bridge_list, webcut_sm_list, BodySM);
    3512                 :            : 
    3513                 :            :   if (!preview)
    3514                 :            :   {
    3515                 :            :     do_attribute_setup();
    3516                 :            :     push_attributes_before_modify(webcut_sm_list);
    3517                 :            :   }
    3518                 :            : 
    3519                 :            :   DLIList<BodySM*> neighbor_list;
    3520                 :            :   CubitStatus result_val = gme->webcut_across_translate (
    3521                 :            :     webcut_sm_list, surface_top, surface_bottom, result_sm_list, neighbor_list, imprint_type, preview );
    3522                 :            : 
    3523                 :            :   // if we're doing the real thing (not preview) finish the process
    3524                 :            :   if (!preview)
    3525                 :            :   {
    3526                 :            :     restore_vg_after_modify(result_sm_list, original_body_list, gme);
    3527                 :            :     remove_pushed_attributes(result_sm_list, original_body_list);
    3528                 :            :     result_val = finish_webcut( webcut_body_list, result_sm_list, merge,
    3529                 :            :                                 result_val, results_list);
    3530                 :            :     do_attribute_cleanup();
    3531                 :            :   }
    3532                 :            : 
    3533                 :            :   return result_val;
    3534                 :            : }
    3535                 :            : #endif
    3536                 :            : 
    3537                 :            : //-------------------------------------------------------------------------
    3538                 :            : // Purpose       : This functions webcuts a list of bodies using a loop
    3539                 :            : //                 of curves
    3540                 :            : //
    3541                 :            : // Special Notes :
    3542                 :            : //
    3543                 :            : // Creator       : Eric W. Nielsen
    3544                 :            : //
    3545                 :            : // Creation Date : 12/20/99
    3546                 :            : //-------------------------------------------------------------------------
    3547                 :          0 : CubitStatus GeometryModifyTool::webcut_with_curve_loop(
    3548                 :            :                                          DLIList<Body*>& webcut_body_list,
    3549                 :            :                                          DLIList<RefEdge*>& refedge_list,
    3550                 :            :                                          DLIList<Body*>& results_list,
    3551                 :            :                                          DLIList<Body*> &neighboring_bodies,
    3552                 :            :                                          ImprintType imprint_type,
    3553                 :            :                                          CubitBoolean merge,
    3554                 :            :                                          CubitBoolean preview)
    3555                 :            : 
    3556                 :            : {
    3557 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    3558                 :          0 :     return CUBIT_FAILURE;
    3559                 :            : 
    3560         [ #  # ]:          0 :   GfxPreview::clear();
    3561                 :            : 
    3562                 :            :    int i;
    3563 [ #  # ][ #  # ]:          0 :    const int count = webcut_body_list.size() + refedge_list.size();
    3564         [ #  # ]:          0 :    DLIList<TopologyEntity*> entity_list(count);
    3565 [ #  # ][ #  # ]:          0 :    DLIList<TopologyBridge*> bridge_list(count);
    3566 [ #  # ][ #  # ]:          0 :    CAST_LIST_TO_PARENT(webcut_body_list, entity_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3567         [ #  # ]:          0 :    refedge_list.reset();
    3568 [ #  # ][ #  # ]:          0 :    for (i = refedge_list.size(); i--; )
    3569 [ #  # ][ #  # ]:          0 :      entity_list.append(refedge_list.get_and_step());
    3570         [ #  # ]:          0 :    GeometryModifyEngine* gme = common_modify_engine( entity_list, bridge_list );
    3571                 :            : 
    3572         [ #  # ]:          0 :    if ( !gme )
    3573                 :            :    {
    3574 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing WEBCUTS on volumes containing geometry from\n"
                 [ #  # ]
    3575                 :            :                   "different modeling engines is not allowed.\n"
    3576         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    3577                 :          0 :       return CUBIT_FAILURE;
    3578                 :            :    }
    3579                 :            : 
    3580 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
    3581                 :            :    {
    3582         [ #  # ]:          0 :      DLIList<Body*> bodies_to_save;
    3583         [ #  # ]:          0 :      bodies_to_save += webcut_body_list;
    3584         [ #  # ]:          0 :      bodies_to_save += neighboring_bodies;
    3585 [ #  # ][ #  # ]:          0 :      CubitUndo::save_state_with_cubit_file( bodies_to_save );
    3586                 :            :    }
    3587                 :            : 
    3588 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list(webcut_body_list.size()), result_sm_list;
         [ #  # ][ #  # ]
                 [ #  # ]
    3589 [ #  # ][ #  # ]:          0 :    DLIList<Curve*> curve_list(refedge_list.size());
                 [ #  # ]
    3590 [ #  # ][ #  # ]:          0 :    CAST_LIST(bridge_list, body_sm_list, BodySM);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3591 [ #  # ][ #  # ]:          0 :    CAST_LIST(bridge_list, curve_list, Curve);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3592 [ #  # ][ #  # ]:          0 :    assert(body_sm_list.size() == webcut_body_list.size());
                 [ #  # ]
    3593 [ #  # ][ #  # ]:          0 :    assert(curve_list.size() == refedge_list.size());
                 [ #  # ]
    3594                 :            : 
    3595 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_surface_ids;
    3596 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_curve_ids;
    3597 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> neighbor_imprint_list;
    3598 [ #  # ][ #  # ]:          0 :    DLIList<Body*> bodies_to_modify;
    3599                 :            : 
    3600                 :            :    //make copies of the curves.
    3601 [ #  # ][ #  # ]:          0 :    DLIList<Curve*> copied_curves;
    3602                 :          0 :    Curve* temp_curve = NULL;
    3603 [ #  # ][ #  # ]:          0 :    for (int i = curve_list.size(); i--;)
    3604                 :            :      {
    3605 [ #  # ][ #  # ]:          0 :        temp_curve = gme->make_Curve(curve_list.get_and_step());
    3606         [ #  # ]:          0 :        if(temp_curve != NULL)
    3607         [ #  # ]:          0 :          copied_curves.append(temp_curve);
    3608                 :            :      }
    3609                 :            : 
    3610                 :            :    //make a face out of the curves
    3611         [ #  # ]:          0 :    Surface * surf = gme->make_Surface(PLANE_SURFACE_TYPE, copied_curves, NULL, false );
    3612         [ #  # ]:          0 :    if (surf == NULL)
    3613                 :            :      {
    3614 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("webcut tool surface is not created from occ.\n");
         [ #  # ][ #  # ]
    3615                 :          0 :        return CUBIT_FAILURE;
    3616                 :            :      }
    3617                 :            : 
    3618                 :            : 
    3619                 :            :    //get cutting tool BodySM.
    3620         [ #  # ]:          0 :    BodySM* cutting_tool_ptr = gme->make_BodySM(surf);
    3621         [ #  # ]:          0 :    assert(cutting_tool_ptr );
    3622                 :            : 
    3623         [ #  # ]:          0 :    if (!preview)
    3624                 :            :    {
    3625                 :            :      int i;
    3626 [ #  # ][ #  # ]:          0 :      for( i=neighboring_bodies.size(); i--; )
    3627                 :            :      {
    3628         [ #  # ]:          0 :        Body *neighbor_body = neighboring_bodies.get_and_step();
    3629         [ #  # ]:          0 :        BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    3630         [ #  # ]:          0 :        GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    3631                 :            : 
    3632         [ #  # ]:          0 :        if( gme == neighbor_gme )
    3633         [ #  # ]:          0 :          neighbor_imprint_list.append( tmp_body );
    3634                 :            :      }
    3635                 :            : 
    3636         [ #  # ]:          0 :      do_attribute_setup();
    3637         [ #  # ]:          0 :      DLIList<BodySM*> bodies_sm_to_modify;
    3638         [ #  # ]:          0 :      bodies_sm_to_modify += body_sm_list;
    3639         [ #  # ]:          0 :      bodies_sm_to_modify += neighbor_imprint_list;
    3640         [ #  # ]:          0 :      push_attributes_before_modify( bodies_sm_to_modify );
    3641         [ #  # ]:          0 :      bodies_to_modify += webcut_body_list;
    3642         [ #  # ]:          0 :      bodies_to_modify += neighboring_bodies;
    3643 [ #  # ][ #  # ]:          0 :      get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    3644                 :            :    }
    3645                 :            : 
    3646                 :            : 
    3647                 :            :    CubitStatus result_val = gme->webcut(
    3648                 :            :                      body_sm_list, cutting_tool_ptr,
    3649                 :            :                      neighbor_imprint_list,
    3650                 :            :                      result_sm_list,
    3651         [ #  # ]:          0 :                      imprint_type, preview) ;
    3652                 :            : 
    3653                 :            :    // Delete the BodySM that was created to be used as a tool
    3654 [ #  # ][ #  # ]:          0 :    gme->get_gqe()->delete_solid_model_entities(cutting_tool_ptr) ;
    3655                 :            : 
    3656                 :            :    // finish up if we're doing the real thing
    3657         [ #  # ]:          0 :    if (!preview)
    3658                 :            :    {
    3659         [ #  # ]:          0 :      restore_vg_after_modify(result_sm_list, bodies_to_modify, gme);
    3660         [ #  # ]:          0 :      remove_pushed_attributes(result_sm_list, bodies_to_modify);
    3661                 :            : 
    3662                 :            :      result_val = finish_webcut( webcut_body_list, result_sm_list, merge,
    3663                 :            :                                  result_val, results_list,
    3664         [ #  # ]:          0 :                                  &merged_surface_ids, &merged_curve_ids );
    3665         [ #  # ]:          0 :      do_attribute_cleanup();
    3666                 :            :    }
    3667                 :            : 
    3668 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
    3669                 :            :   {
    3670         [ #  # ]:          0 :     if( result_val == CUBIT_SUCCESS )
    3671         [ #  # ]:          0 :       CubitUndo::note_result_bodies( results_list );
    3672                 :            :     else
    3673         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    3674                 :            :   }
    3675                 :            : 
    3676         [ #  # ]:          0 :    return result_val;
    3677                 :            : }
    3678                 :            : 
    3679                 :            : //-------------------------------------------------------------------------
    3680                 :            : // Purpose       : This functions webcuts a list of bodies through a plane
    3681                 :            : //                 defined by a refFace. The newly created bodies are
    3682                 :            : //                 merged and imprinted depeding on the respective flags.
    3683                 :            : //
    3684                 :            : // Special Notes :
    3685                 :            : //
    3686                 :            : // Creator       : Raikanta Sahu
    3687                 :            : //
    3688                 :            : // Creation Date : 12/16/96
    3689                 :            : //-------------------------------------------------------------------------
    3690                 :            : 
    3691                 :          0 : CubitStatus GeometryModifyTool::webcut_with_surface(
    3692                 :            :                                       DLIList<Body*>& webcut_body_list,
    3693                 :            :                                       RefFace* refFace,
    3694                 :            :                                       DLIList<Body*>& results_list,
    3695                 :            :                                       DLIList<Body*> &neighboring_bodies,
    3696                 :            :                                       ImprintType imprint_type,
    3697                 :            :                                       CubitBoolean merge,
    3698                 :            :                                       CubitBoolean preview)
    3699                 :            : {
    3700                 :            :   //make sure that this refface is planar, or you'll get unexpected results
    3701 [ #  # ][ #  # ]:          0 :   if( refFace->geometry_type() != PLANE_SURFACE_TYPE )
    3702                 :            :   {
    3703 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Surface %d is not planar.\n", refFace->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
    3704                 :          0 :     return CUBIT_FAILURE;
    3705                 :            :   }
    3706                 :            : 
    3707                 :            :      // Using the face, get three positions (CubitVectors :) :) )
    3708                 :            :      // The positions can be used by a GeometryModifyEngine to generate its
    3709                 :            :      // own webcutting tool and perform the webcut.
    3710         [ #  # ]:          0 :    CubitVector vector1 = refFace->position_from_u_v(0, 1) ;
    3711         [ #  # ]:          0 :    CubitVector vector3 = refFace->position_from_u_v(1, 0) ;
    3712         [ #  # ]:          0 :    CubitVector vector2 = refFace->position_from_u_v(0, 0) ;
    3713                 :            : 
    3714                 :            :    CubitStatus result_val = this->webcut_with_plane(webcut_body_list, vector1,
    3715                 :            :                                   vector2, vector3, results_list, neighboring_bodies,
    3716         [ #  # ]:          0 :                                   imprint_type, merge, preview) ;
    3717                 :            : 
    3718                 :          0 :    return result_val;
    3719                 :            : }
    3720                 :            : 
    3721                 :            : //-------------------------------------------------------------------------
    3722                 :            : // Purpose       : This functions webcuts a list of bodies using a plane
    3723                 :            : //                 defined by a refFace. The newly created bodies are
    3724                 :            : //                 merged and imprinted depending on the respective flags.
    3725                 :            : //
    3726                 :            : // Special Notes :
    3727                 :            : //
    3728                 :            : // Creator       : Raikanta Sahu
    3729                 :            : //
    3730                 :            : // Creation Date : 12/16/96
    3731                 :            : //-------------------------------------------------------------------------
    3732                 :            : 
    3733                 :         11 : CubitStatus GeometryModifyTool::webcut_with_body(
    3734                 :            :                                    DLIList<Body*>& webcut_body_list,
    3735                 :            :                                    Body* tool_body,
    3736                 :            :                                    DLIList<Body*>& results_list,
    3737                 :            :                                    DLIList<Body*> &neighboring_bodies,
    3738                 :            :                                    ImprintType imprint_type,
    3739                 :            :                                    CubitBoolean merge,
    3740                 :            :                                    CubitBoolean preview)
    3741                 :            : {
    3742                 :            : 
    3743                 :            :   CubitStatus ret;
    3744                 :            : 
    3745 [ +  - ][ -  + ]:         11 :   if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    3746                 :          0 :     return CUBIT_FAILURE;
    3747                 :            : 
    3748         [ +  - ]:         11 :   CubitBox tool_bounding_box = tool_body->bounding_box();
    3749         [ +  - ]:         11 :   remove_bodies_outside_bounding_box( webcut_body_list, tool_bounding_box );
    3750                 :            : 
    3751 [ +  - ][ -  + ]:         11 :   if( webcut_body_list.size() == 0 )
    3752                 :            :   {
    3753 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Tool does not intersect any bodies/volumes.\n");
         [ #  # ][ #  # ]
    3754                 :          0 :     return CUBIT_FAILURE;
    3755                 :            :   }
    3756                 :            : 
    3757 [ +  - ][ +  - ]:         22 :   DLIList<BodySM*> body_sm_list(webcut_body_list.size()), result_sm_list;
         [ +  - ][ +  - ]
                 [ +  - ]
    3758         [ +  - ]:         11 :   BodySM* tool_sm = tool_body->get_body_sm_ptr();
    3759                 :         11 :   GeometryModifyEngine* gme = 0;
    3760 [ +  - ][ +  - ]:         11 :   if (!tool_sm || !(gme = get_engine(tool_sm)))
         [ -  + ][ -  + ]
    3761                 :            :   {
    3762 [ #  # ][ #  # ]:          0 :     PRINT_DEBUG_153("No modify engine available for body %d.\n", tool_body->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3763 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("No modify engine available for volume %d.\n", tool_body->ref_volume()->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3764                 :          0 :     return CUBIT_FAILURE;
    3765                 :            :   }
    3766                 :            : 
    3767         [ +  - ]:         11 :   webcut_body_list.reset();
    3768                 :            :   int i;
    3769 [ +  - ][ +  + ]:         22 :   for (i = webcut_body_list.size(); i--; )
    3770                 :            :   {
    3771         [ +  - ]:         11 :     Body* body_ptr = webcut_body_list.get_and_step();
    3772         [ +  - ]:         11 :     BodySM* sm_ptr = body_ptr->get_body_sm_ptr();
    3773 [ +  - ][ +  - ]:         11 :     if (!sm_ptr || get_engine(sm_ptr) != gme)
         [ -  + ][ -  + ]
    3774                 :            :     {
    3775 [ #  # ][ #  # ]:          0 :       PRINT_DEBUG_153("ERROR: Body %d does not belong to the same geometric engine "
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3776         [ #  # ]:          0 :                   "as body %d\n", body_ptr->id(), tool_body->id());
    3777 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Volume %d does not belong to the same geometric engine "
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3778         [ #  # ]:          0 :                   "as volume %d\n", body_ptr->ref_volume()->id(), tool_body->ref_volume()->id());
    3779                 :          0 :       return CUBIT_FAILURE;
    3780                 :            :     }
    3781                 :            : 
    3782         [ +  - ]:         11 :     body_sm_list.append(sm_ptr);
    3783                 :            :   }
    3784                 :            : 
    3785 [ +  - ][ +  - ]:         22 :   DLIList<int> merged_surface_ids;
    3786 [ +  - ][ +  - ]:         22 :   DLIList<int> merged_curve_ids;
    3787 [ +  - ][ +  - ]:         22 :   DLIList<BodySM*> neighbor_imprint_list;
    3788 [ +  - ][ +  - ]:         22 :   DLIList<Body*> bodies_to_modify;
    3789                 :            : 
    3790         [ +  - ]:         11 :   if (!preview)
    3791                 :            :   {
    3792 [ +  - ][ -  + ]:         11 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ -  + ]
    3793                 :            :     {
    3794         [ #  # ]:          0 :       DLIList<Body*> bodies_to_save;
    3795         [ #  # ]:          0 :       bodies_to_save += webcut_body_list;
    3796         [ #  # ]:          0 :       bodies_to_save += neighboring_bodies;
    3797 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( bodies_to_save );
    3798                 :            :     }
    3799                 :            : 
    3800                 :            :     int i;
    3801 [ +  - ][ -  + ]:         11 :     for( i=neighboring_bodies.size(); i--; )
    3802                 :            :     {
    3803         [ #  # ]:          0 :       Body *neighbor_body = neighboring_bodies.get_and_step();
    3804         [ #  # ]:          0 :       BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    3805         [ #  # ]:          0 :       GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    3806                 :            : 
    3807         [ #  # ]:          0 :       if( gme == neighbor_gme )
    3808         [ #  # ]:          0 :         neighbor_imprint_list.append( tmp_body );
    3809                 :            :     }
    3810                 :            : 
    3811         [ +  - ]:         11 :     do_attribute_setup();
    3812         [ +  - ]:         11 :     DLIList<BodySM*> bodies_sm_to_modify;
    3813         [ +  - ]:         11 :     bodies_sm_to_modify += body_sm_list;
    3814         [ +  - ]:         11 :     bodies_sm_to_modify += neighbor_imprint_list;
    3815         [ +  - ]:         11 :     push_attributes_before_modify( bodies_sm_to_modify );
    3816         [ +  - ]:         11 :     bodies_to_modify += webcut_body_list;
    3817         [ +  - ]:         11 :     bodies_to_modify += neighboring_bodies;
    3818 [ +  - ][ +  - ]:         11 :     get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    3819                 :            :   }
    3820                 :            : 
    3821                 :            : 
    3822                 :            :   int count = gme->webcut(body_sm_list, tool_sm,
    3823                 :            :                           neighbor_imprint_list,
    3824         [ +  - ]:         11 :                           result_sm_list, imprint_type, preview);
    3825                 :            : 
    3826                 :            :   // finish up if we're doing the real thing
    3827         [ +  - ]:         11 :   if (!preview)
    3828                 :            :   {
    3829         [ +  - ]:         11 :     restore_vg_after_modify(result_sm_list, bodies_to_modify, gme);
    3830         [ +  - ]:         11 :     remove_pushed_attributes(result_sm_list, bodies_to_modify );
    3831                 :            : 
    3832                 :            :     ret = finish_webcut(webcut_body_list, result_sm_list, merge,
    3833                 :            :                           count > 0 ? CUBIT_SUCCESS : CUBIT_FAILURE,
    3834 [ +  - ][ +  - ]:         11 :                           results_list, &merged_surface_ids, &merged_curve_ids );
    3835                 :            : 
    3836         [ +  - ]:         11 :     do_attribute_cleanup();
    3837                 :            :   }
    3838                 :            :   else
    3839         [ #  # ]:          0 :     ret = count > 0 ? CUBIT_SUCCESS : CUBIT_FAILURE;
    3840                 :            : 
    3841 [ +  - ][ +  - ]:         11 :   if( preview == CUBIT_FALSE && CubitUndo::get_undo_enabled() )
         [ -  + ][ -  + ]
    3842                 :            :   {
    3843         [ #  # ]:          0 :     if( ret == CUBIT_SUCCESS )
    3844         [ #  # ]:          0 :       CubitUndo::note_result_bodies( results_list );
    3845                 :            :     else
    3846         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    3847                 :            :   }
    3848                 :            : 
    3849         [ +  - ]:         11 :   return ret;
    3850                 :            : }
    3851                 :            : 
    3852                 :         11 : CubitStatus GeometryModifyTool::section(
    3853                 :            :                                    DLIList<Body*> &section_body_list,
    3854                 :            :                                    const CubitVector &point_1,
    3855                 :            :                                    const CubitVector &point_2,
    3856                 :            :                                    const CubitVector &point_3,
    3857                 :            :                                    DLIList<Body*> &new_body_list,
    3858                 :            :                                    CubitBoolean keep_normal_side,
    3859                 :            :                                    CubitBoolean keep_old )
    3860                 :            : {
    3861 [ +  - ][ -  + ]:         11 :   if( section_body_list.size() == 0 )
    3862                 :          0 :     return CUBIT_FAILURE;
    3863                 :            : 
    3864 [ +  - ][ -  + ]:         11 :   if (!okay_to_modify( section_body_list, "SECTION" ))
    3865                 :          0 :     return CUBIT_FAILURE;
    3866                 :         11 :    CubitStatus rval = CUBIT_SUCCESS;
    3867                 :            : 
    3868         [ +  - ]:         11 :    const int count = section_body_list.size();
    3869         [ +  - ]:         11 :    DLIList<BodySM*> result_sm_list;
    3870 [ +  - ][ +  - ]:         22 :    DLIList<Body*> body_list(section_body_list);
    3871 [ +  - ][ +  - ]:         22 :    DLIList<BodySM*> engine_body_sms(count);
    3872 [ +  - ][ +  - ]:         22 :    DLIList<Body*> engine_bodies(count);
    3873                 :         11 :    GeometryModifyEngine* gme = 0;
    3874                 :            : 
    3875 [ +  - ][ -  + ]:         11 :    if( CubitUndo::get_undo_enabled() )
    3876                 :            :    {
    3877         [ #  # ]:          0 :      if( keep_old )
    3878         [ #  # ]:          0 :        CubitUndo::save_state();
    3879                 :            :      else
    3880         [ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( section_body_list );
    3881                 :            :    }
    3882                 :            : 
    3883 [ +  - ][ +  + ]:         22 :    while ( (gme = group_bodies_by_engine(body_list, engine_bodies, engine_body_sms)) )
    3884                 :            :    {
    3885                 :            :       //get all the child entities that have been merged
    3886         [ +  - ]:         11 :       DLIList<int> merged_surface_ids;
    3887 [ +  - ][ +  - ]:         22 :       DLIList<int> merged_curve_ids;
    3888         [ +  - ]:         11 :       get_merged_curve_and_surface_ids( engine_bodies, merged_surface_ids, merged_curve_ids );
    3889                 :            : 
    3890                 :            :       CubitStatus result = gme->section( engine_body_sms,
    3891                 :            :                                          point_1, point_2, point_3,
    3892                 :            :                                          result_sm_list,
    3893         [ +  - ]:         11 :                                          keep_normal_side, keep_old );
    3894                 :            : 
    3895 [ +  - ][ -  + ]:         11 :       if (!finish_sm_op( engine_bodies, result_sm_list, new_body_list ))
    3896                 :          0 :         result = CUBIT_FAILURE;
    3897         [ -  + ]:         11 :       if (!result)
    3898                 :          0 :         rval = CUBIT_FAILURE;
    3899                 :            : 
    3900 [ +  - ][ +  - ]:         11 :       if( merged_surface_ids.size() || merged_curve_ids.size() )
         [ +  - ][ -  + ]
                 [ -  + ]
    3901         [ #  # ]:          0 :         fixup_merged_entities( merged_surface_ids, merged_curve_ids);
    3902                 :            : 
    3903         [ +  - ]:         11 :       engine_body_sms.clean_out();
    3904         [ +  - ]:         11 :       engine_bodies.clean_out();
    3905         [ +  - ]:         11 :       result_sm_list.clean_out();
    3906         [ +  - ]:         11 :    }
    3907                 :            : 
    3908 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
    3909                 :            :   {
    3910 [ #  # ][ #  # ]:          0 :     if( new_body_list.size() ) //if there are new bodies...something succeeded
    3911         [ #  # ]:          0 :       CubitUndo::note_result_bodies( new_body_list );
    3912                 :            :     else
    3913         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    3914                 :            :   }
    3915                 :            : 
    3916         [ +  - ]:         11 :    return rval;
    3917                 :            : }
    3918                 :            : 
    3919                 :            : CubitStatus
    3920                 :        110 : GeometryModifyTool::offset_curves( DLIList<RefEdge*>& ref_edge_list,
    3921                 :            :                                    DLIList<RefEdge*>& output_edge_list,
    3922                 :            :                                    double offset_distance,
    3923                 :            :                                    const CubitVector& offset_direction,
    3924                 :            :                                    int gap_type )
    3925                 :            : {
    3926                 :            :   // Make sure all curves are from same geometry engine
    3927 [ +  - ][ +  - ]:        110 :   DLIList<TopologyEntity*> entity_list(ref_edge_list.size());
    3928 [ +  - ][ +  - ]:        220 :   DLIList<TopologyBridge*> bridge_list(ref_edge_list.size());
                 [ +  - ]
    3929 [ +  - ][ +  - ]:        231 :   CAST_LIST_TO_PARENT(ref_edge_list, entity_list);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
    3930         [ +  - ]:        110 :   GeometryModifyEngine* gme_ptr = common_modify_engine(entity_list, bridge_list);
    3931         [ -  + ]:        110 :   if ( !gme_ptr )
    3932                 :            :   {
    3933 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Can't create offset curves that don't all originate from same\n"
                 [ #  # ]
    3934         [ #  # ]:          0 :       "       modeling engine.\n");
    3935                 :          0 :     return CUBIT_FAILURE;
    3936                 :            :   }
    3937                 :            : 
    3938 [ +  - ][ -  + ]:        110 :   if( CubitUndo::get_undo_enabled() )
    3939         [ #  # ]:          0 :     CubitUndo::save_state();
    3940                 :            : 
    3941 [ +  - ][ +  - ]:        220 :   DLIList<Curve*> curve_list(bridge_list.size()), result_list;
         [ +  - ][ +  - ]
                 [ +  - ]
    3942 [ +  - ][ +  - ]:        231 :   CAST_LIST(bridge_list, curve_list, Curve);
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
    3943 [ +  - ][ +  - ]:        110 :   assert(curve_list.size() == ref_edge_list.size());
                 [ -  + ]
    3944                 :            : 
    3945                 :            :   CubitStatus rval = gme_ptr->offset_curves( curve_list, result_list,
    3946         [ +  - ]:        110 :                         offset_distance, offset_direction, gap_type );
    3947 [ +  + ][ +  - ]:        110 :   assert( rval || !result_list.size() );
                 [ -  + ]
    3948         [ +  - ]:        110 :   result_list.reset();
    3949                 :            : 
    3950 [ +  - ][ +  - ]:        220 :   DLIList<RefEntity*> created_edges;
    3951         [ +  - ]:        110 :   output_edge_list.clean_out();
    3952 [ +  - ][ +  + ]:        176 :   for (int i = result_list.size(); i--; )
    3953                 :            :   {
    3954 [ +  - ][ +  - ]:         66 :     RefEdge *new_edge = GeometryQueryTool::instance()->make_free_RefEdge(result_list.get_and_step());
                 [ +  - ]
    3955 [ +  - ][ +  - ]:         66 :     created_edges.append( new_edge );
    3956         [ +  - ]:         66 :     output_edge_list.append( new_edge );
    3957                 :            :   }
    3958                 :            : 
    3959 [ +  - ][ -  + ]:        110 :   if( CubitUndo::get_undo_enabled() )
    3960                 :            :   {
    3961 [ #  # ][ #  # ]:          0 :     if( created_edges.size() )
    3962         [ #  # ]:          0 :       CubitUndo::note_result_entities( created_edges );
    3963                 :            :     else
    3964         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    3965                 :            :   }
    3966                 :            : 
    3967         [ +  - ]:        110 :   return rval;
    3968                 :            : }
    3969                 :            : 
    3970                 :            : // Compute the transformation requried to align my_face with target_face
    3971                 :            : // with respecct to reference_body_ptr.  Then perform the transformation
    3972                 :            : // on all entities in entities_to_move
    3973                 :          0 : CubitStatus GeometryModifyTool::align_entities( RefFace *source_face,  
    3974                 :            :   RefFace *target_face,
    3975                 :            :   DLIList<RefEntity*> &entities_to_move,
    3976                 :            :   bool reverse,
    3977                 :            :   CubitVector &my_center,
    3978                 :            :   CubitVector &axis_of_rot,
    3979                 :            :   CubitVector &target_center,
    3980                 :            :   double &angle,
    3981                 :            :   bool preview)
    3982                 :            : {
    3983                 :            :   // Initialize angle to zero, so we are passing back a valid
    3984                 :            :   // value if we never need to rotate the body
    3985                 :          0 :   angle = 0.0;
    3986                 :            : 
    3987                 :            :   //Align the body, which contains my_face, with the target_face.
    3988                 :            : 
    3989                 :            :   //Essentially we want to align the body at my_face with the target_face.
    3990 [ #  # ][ #  # ]:          0 :   my_center = source_face->center_point();
    3991 [ #  # ][ #  # ]:          0 :   target_center = target_face->center_point();
    3992                 :            :   
    3993         [ #  # ]:          0 :   CubitVector my_vector = source_face->normal_at( my_center );
    3994         [ #  # ]:          0 :   CubitVector target_vector = target_face->normal_at( target_center );
    3995                 :            : 
    3996 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && !preview )
         [ #  # ][ #  # ]
    3997                 :            :   {
    3998         [ #  # ]:          0 :     DLIList<RefEntity*> free_ents_to_save;
    3999 [ #  # ][ #  # ]:          0 :     DLIList<Body*> align_list(entities_to_move.size());
                 [ #  # ]
    4000 [ #  # ][ #  # ]:          0 :     for ( int k=0; k<entities_to_move.size(); k++ )
    4001                 :            :     {
    4002         [ #  # ]:          0 :       RefEntity *ref_ent = entities_to_move[k];      
    4003         [ #  # ]:          0 :       Body *tmp_body = dynamic_cast<Body*>(ref_ent);
    4004         [ #  # ]:          0 :       if( tmp_body )       
    4005         [ #  # ]:          0 :         align_list.append( tmp_body );              
    4006                 :            :       else
    4007         [ #  # ]:          0 :         free_ents_to_save.append( ref_ent );       
    4008                 :            :     }     
    4009 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( align_list, &free_ents_to_save );
    4010                 :            :   }
    4011                 :            : 
    4012 [ #  # ][ #  # ]:          0 :   axis_of_rot = my_vector * target_vector;
    4013                 :            : 
    4014 [ #  # ][ #  # ]:          0 :   if( axis_of_rot.length() < CUBIT_RESABS )  
    4015                 :            :   {
    4016 [ #  # ][ #  # ]:          0 :     CubitVector v1,v2;
    4017         [ #  # ]:          0 :     my_vector.orthogonal_vectors(v1, v2 );
    4018         [ #  # ]:          0 :     axis_of_rot = v1;    
    4019                 :            :   }
    4020                 :            : 
    4021 [ #  # ][ #  # ]:          0 :   if( axis_of_rot.length() > CUBIT_RESABS )
    4022                 :            :   {
    4023         [ #  # ]:          0 :     angle = axis_of_rot.vector_angle( my_vector, target_vector );
    4024                 :            : 
    4025                 :            :     //Now we have the angle and the axis to rotate about...
    4026                 :          0 :     angle = 180.0*angle/CUBIT_PI;
    4027                 :            :     
    4028         [ #  # ]:          0 :     if( angle > 90 )
    4029                 :          0 :       angle = angle - 180;
    4030                 :            : 
    4031         [ #  # ]:          0 :     if( reverse )
    4032                 :          0 :       angle += 180;
    4033                 :            :   }
    4034         [ #  # ]:          0 :   CubitVector origin(0.,0.,0.);
    4035                 :            : 
    4036         [ #  # ]:          0 :   if (preview)
    4037                 :            :   {    
    4038 [ #  # ][ #  # ]:          0 :     preview_align( -my_center, target_center, angle, axis_of_rot, entities_to_move );     
         [ #  # ][ #  # ]
    4039                 :            :   }
    4040                 :            :   else 
    4041                 :            :   {   
    4042                 :            :     //Move the body so that the center of my_face
    4043                 :            :     //is at the origin.   
    4044         [ #  # ]:          0 :     DLIList<RefEntity*> entities_transformed;
    4045                 :            :     GeometryQueryTool::instance()->translate( entities_to_move,
    4046         [ #  # ]:          0 :       -my_center.x(),
    4047         [ #  # ]:          0 :       -my_center.y(),
    4048         [ #  # ]:          0 :       -my_center.z(),
    4049                 :            :       false,
    4050 [ #  # ][ #  # ]:          0 :       entities_transformed);
    4051                 :            : 
    4052                 :            :     //If the axis length is zero we dont want to do a rotation,
    4053                 :            :     //they are already parallel..  
    4054 [ #  # ][ #  # ]:          0 :     if (axis_of_rot.length() > CUBIT_RESABS )
    4055                 :            :     {    
    4056                 :            :       //Now rotate the body about the axis.
    4057                 :            :       GeometryQueryTool::instance()->rotate(entities_to_move, origin, 
    4058                 :            :         axis_of_rot, angle, false, entities_transformed,
    4059 [ #  # ][ #  # ]:          0 :         false);
    4060                 :            :     }
    4061                 :            :     //Now move the body to the location of the target_center.    
    4062                 :            :     GeometryQueryTool::instance()->translate( entities_to_move,
    4063         [ #  # ]:          0 :       target_center.x(),
    4064         [ #  # ]:          0 :       target_center.y(),
    4065         [ #  # ]:          0 :       target_center.z(),
    4066                 :            :       false,
    4067                 :            :       entities_transformed,
    4068 [ #  # ][ #  # ]:          0 :       preview);
                 [ #  # ]
    4069                 :            :   }
    4070                 :            : 
    4071                 :            :   //That should do it.
    4072                 :          0 :   return CUBIT_SUCCESS;
    4073                 :            : }
    4074                 :            : 
    4075                 :          0 : CubitStatus GeometryModifyTool::align_entities( DLIList<RefEntity*> &entities_to_align,
    4076                 :            :                                            CubitVector &pos_to_align,
    4077                 :            :                                            CubitVector &pos_to_align_to,
    4078                 :            :                                            CubitVector &axis_origin,
    4079                 :            :                                            CubitVector &axis_of_rot,
    4080                 :            :                                            double &angle_of_rotation,
    4081                 :            :                                            bool preview)
    4082                 :            : {
    4083                 :            :   //project pos_to_align to axis
    4084         [ #  # ]:          0 :   axis_of_rot.normalize();
    4085         [ #  # ]:          0 :   CubitVector tmp_vec = pos_to_align - axis_origin;  
    4086         [ #  # ]:          0 :   double dot_prod = tmp_vec%axis_of_rot;
    4087 [ #  # ][ #  # ]:          0 :   CubitVector int_pt1 = axis_origin + (dot_prod*axis_of_rot);
    4088                 :            : 
    4089                 :            :   //project pos_to_align_to to axis
    4090 [ #  # ][ #  # ]:          0 :   tmp_vec = pos_to_align_to - axis_origin;  
    4091         [ #  # ]:          0 :   dot_prod = tmp_vec%axis_of_rot;
    4092 [ #  # ][ #  # ]:          0 :   CubitVector int_pt2 = axis_origin + (dot_prod*axis_of_rot);
    4093                 :            : 
    4094                 :            :   //determine angle of rotation
    4095 [ #  # ][ #  # ]:          0 :   tmp_vec = pos_to_align - int_pt1;
    4096         [ #  # ]:          0 :   CubitVector tmp_vec2 = pos_to_align_to - int_pt2;
    4097         [ #  # ]:          0 :   angle_of_rotation = axis_of_rot.vector_angle( tmp_vec, tmp_vec2 );
    4098                 :          0 :   angle_of_rotation *= 180.0/CUBIT_PI;
    4099                 :            :   
    4100         [ #  # ]:          0 :   if( angle_of_rotation < CUBIT_RESABS )
    4101                 :            :   {
    4102 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("Points already aligned.\n");
         [ #  # ][ #  # ]
    4103                 :          0 :     return CUBIT_SUCCESS;
    4104                 :            :   }
    4105                 :            : 
    4106 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && !preview )
         [ #  # ][ #  # ]
    4107                 :            :   {
    4108         [ #  # ]:          0 :     DLIList<RefEntity*> free_ents_to_save;
    4109 [ #  # ][ #  # ]:          0 :     DLIList<Body*> align_list(entities_to_align.size());
                 [ #  # ]
    4110 [ #  # ][ #  # ]:          0 :     for ( int k=0; k<entities_to_align.size(); k++ )
    4111                 :            :     {
    4112         [ #  # ]:          0 :       RefEntity *ref_ent = entities_to_align[k];      
    4113         [ #  # ]:          0 :       Body *tmp_body = dynamic_cast<Body*>(ref_ent);
    4114         [ #  # ]:          0 :       if( tmp_body )       
    4115         [ #  # ]:          0 :         align_list.append( tmp_body );              
    4116                 :            :       else
    4117         [ #  # ]:          0 :         free_ents_to_save.append( ref_ent );       
    4118                 :            :     }     
    4119 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( align_list, &free_ents_to_save );
    4120                 :            :   }
    4121                 :            : 
    4122         [ #  # ]:          0 :   CubitVector translation_vector( int_pt1 );
    4123                 :            : 
    4124         [ #  # ]:          0 :   if( preview )
    4125                 :            :   {    
    4126                 :            :     preview_align( -translation_vector, translation_vector, 
    4127 [ #  # ][ #  # ]:          0 :       angle_of_rotation, axis_of_rot, entities_to_align );     
         [ #  # ][ #  # ]
    4128                 :            :   }
    4129                 :            :   else
    4130                 :            :   {
    4131                 :            :     //translate to origin
    4132         [ #  # ]:          0 :     DLIList<RefEntity*> entities_transformed;
    4133                 :            :     GeometryQueryTool::instance()->translate( entities_to_align,
    4134         [ #  # ]:          0 :       -translation_vector.x(),
    4135         [ #  # ]:          0 :       -translation_vector.y(),
    4136         [ #  # ]:          0 :       -translation_vector.z(),
    4137                 :            :       false,
    4138 [ #  # ][ #  # ]:          0 :       entities_transformed);
    4139                 :            : 
    4140                 :            :     //rotate to align
    4141         [ #  # ]:          0 :     CubitVector origin(0,0,0);
    4142                 :            :     GeometryQueryTool::instance()->rotate( entities_to_align, origin, axis_of_rot, angle_of_rotation, false, 
    4143 [ #  # ][ #  # ]:          0 :       entities_transformed, false );
    4144                 :            : 
    4145                 :            :     //translate back
    4146                 :            :     GeometryQueryTool::instance()->translate( entities_to_align,
    4147         [ #  # ]:          0 :       translation_vector.x(),
    4148         [ #  # ]:          0 :       translation_vector.y(),
    4149         [ #  # ]:          0 :       translation_vector.z(),
    4150                 :            :       false,
    4151 [ #  # ][ #  # ]:          0 :       entities_transformed);      
                 [ #  # ]
    4152                 :            :   }
    4153                 :            : 
    4154                 :            :   //That should do it.
    4155                 :          0 :   return CUBIT_SUCCESS;  
    4156                 :            : }
    4157                 :            : 
    4158                 :          0 : CubitStatus GeometryModifyTool::align_entities( DLIList<RefEntity*>& reference_entities,
    4159                 :            :                                                 DLIList<RefEntity*> &entities_to_move,
    4160                 :            :                                                 CubitVector align_to_vec,                                                 
    4161                 :            :                                                 CubitVector &my_center,                                           
    4162                 :            :                                                 CubitVector &axis_of_rot,
    4163                 :            :                                                 double &angle,                                           
    4164                 :            :                                                 bool preview)
    4165                 :            : {
    4166         [ #  # ]:          0 :    DLIList<RefFace*> ref_face_list;
    4167 [ #  # ][ #  # ]:          0 :    DLIList<RefVertex*> ref_vertex_list;
    4168                 :            : 
    4169 [ #  # ][ #  # ]:          0 :    CAST_LIST(reference_entities, ref_face_list, RefFace);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4170 [ #  # ][ #  # ]:          0 :    CAST_LIST(reference_entities, ref_vertex_list, RefVertex);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4171                 :            : 
    4172                 :          0 :    angle = 0.0;   
    4173                 :            : 
    4174         [ #  # ]:          0 :    CubitVector translation_vector;
    4175         [ #  # ]:          0 :    CubitVector axis_of_rotation;
    4176         [ #  # ]:          0 :    CubitVector vector_to_rotate;
    4177                 :            : 
    4178 [ #  # ][ #  # ]:          0 :    if( ref_face_list.size() == 1 &&
         [ #  # ][ #  # ]
    4179         [ #  # ]:          0 :        ref_vertex_list.size() == 0 )
    4180                 :            :    {   
    4181                 :            :      //now form the axis of rotation
    4182         [ #  # ]:          0 :      RefFace *my_face = ref_face_list.get_and_step();
    4183 [ #  # ][ #  # ]:          0 :      translation_vector = my_face->center_point();     
    4184         [ #  # ]:          0 :      my_center = translation_vector;
    4185 [ #  # ][ #  # ]:          0 :      vector_to_rotate = my_face->normal_at( translation_vector );     
    4186 [ #  # ][ #  # ]:          0 :      axis_of_rot = align_to_vec * vector_to_rotate;
    4187                 :            :    }
    4188 [ #  # ][ #  # ]:          0 :    else if( ref_face_list.size() == 0 &&
         [ #  # ][ #  # ]
    4189         [ #  # ]:          0 :             ref_vertex_list.size() == 2 )
    4190                 :            :    {
    4191         [ #  # ]:          0 :      RefVertex *vertex_1 = ref_vertex_list.get_and_step();
    4192         [ #  # ]:          0 :      RefVertex *vertex_2 = ref_vertex_list.get_and_step();     
    4193                 :            : 
    4194                 :            :      //now form the axis of rotation
    4195 [ #  # ][ #  # ]:          0 :      translation_vector = vertex_1->coordinates();
    4196 [ #  # ][ #  # ]:          0 :      my_center = vertex_1->coordinates();     
    4197 [ #  # ][ #  # ]:          0 :      vector_to_rotate = vertex_2->coordinates() - vertex_1->coordinates();     
         [ #  # ][ #  # ]
    4198 [ #  # ][ #  # ]:          0 :      axis_of_rot = align_to_vec * vector_to_rotate;
    4199                 :            :    }   
    4200                 :            : 
    4201 [ #  # ][ #  # ]:          0 :    if( axis_of_rot.length() < CUBIT_RESABS )  
    4202                 :            :    {
    4203         [ #  # ]:          0 :     double dot_prod = align_to_vec%vector_to_rotate;
    4204                 :            :     //normals could be 180 degrees from one another
    4205         [ #  # ]:          0 :     if( dot_prod < 0 ) 
    4206                 :            :     {
    4207 [ #  # ][ #  # ]:          0 :       CubitVector v1,v2;
    4208         [ #  # ]:          0 :       align_to_vec.orthogonal_vectors(v1, v2 );
    4209         [ #  # ]:          0 :       axis_of_rot = v1;
    4210                 :            :     }
    4211                 :            :   }
    4212                 :            : 
    4213 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() && !preview )
         [ #  # ][ #  # ]
    4214                 :            :    {
    4215         [ #  # ]:          0 :      DLIList<RefEntity*> free_ents_to_save;
    4216 [ #  # ][ #  # ]:          0 :      DLIList<Body*> align_list(entities_to_move.size());
                 [ #  # ]
    4217 [ #  # ][ #  # ]:          0 :      for ( int k=0; k<entities_to_move.size(); k++ )
    4218                 :            :      {
    4219         [ #  # ]:          0 :        RefEntity *ref_ent = entities_to_move[k];      
    4220         [ #  # ]:          0 :        Body *tmp_body = dynamic_cast<Body*>(ref_ent);
    4221         [ #  # ]:          0 :        if( tmp_body )       
    4222         [ #  # ]:          0 :          align_list.append( tmp_body );              
    4223                 :            :        else
    4224         [ #  # ]:          0 :          free_ents_to_save.append( ref_ent );       
    4225                 :            :      }     
    4226 [ #  # ][ #  # ]:          0 :      CubitUndo::save_state_with_cubit_file( align_list, &free_ents_to_save );
    4227                 :            :    }
    4228                 :            : 
    4229                 :            :    //determine the angle of rotation   
    4230         [ #  # ]:          0 :    angle = axis_of_rot.vector_angle( vector_to_rotate, align_to_vec );
    4231                 :          0 :    angle = 180.0*angle/CUBIT_PI;
    4232                 :            : 
    4233         [ #  # ]:          0 :    if( preview )
    4234                 :            :    {
    4235                 :            :      preview_align( -translation_vector, translation_vector, 
    4236 [ #  # ][ #  # ]:          0 :                   angle, axis_of_rot, entities_to_move );     
         [ #  # ][ #  # ]
    4237                 :            :    }
    4238                 :            :    else
    4239                 :            :    {
    4240                 :            :      //translate to origin
    4241         [ #  # ]:          0 :      DLIList<RefEntity*> entities_transformed;
    4242                 :            :      GeometryQueryTool::instance()->translate( entities_to_move,
    4243         [ #  # ]:          0 :        -translation_vector.x(),
    4244         [ #  # ]:          0 :        -translation_vector.y(),
    4245         [ #  # ]:          0 :        -translation_vector.z(),
    4246                 :            :        false,
    4247 [ #  # ][ #  # ]:          0 :        entities_transformed);
    4248                 :            : 
    4249                 :            :      //rotate to align
    4250         [ #  # ]:          0 :      CubitVector origin(0,0,0);
    4251                 :            :      GeometryQueryTool::instance()->rotate( entities_to_move, origin, axis_of_rot, angle, false, 
    4252 [ #  # ][ #  # ]:          0 :        entities_transformed, false );
    4253                 :            : 
    4254                 :            :      //translate back
    4255                 :            :      GeometryQueryTool::instance()->translate( entities_to_move,
    4256         [ #  # ]:          0 :        translation_vector.x(),
    4257         [ #  # ]:          0 :        translation_vector.y(),
    4258         [ #  # ]:          0 :        translation_vector.z(),
    4259                 :            :        false,
    4260 [ #  # ][ #  # ]:          0 :        entities_transformed);      
                 [ #  # ]
    4261                 :            :    }
    4262                 :            : 
    4263                 :            :    //That should do it.
    4264         [ #  # ]:          0 :    return CUBIT_SUCCESS;  
    4265                 :            : }
    4266                 :            : 
    4267                 :          0 : void GeometryModifyTool::preview_align( CubitVector translation_to_origin,
    4268                 :            :                                         CubitVector origin_to_target,
    4269                 :            :                                         double angle_of_rotation,
    4270                 :            :                                         CubitVector axis_of_rotation,
    4271                 :            :                                         DLIList<RefEntity*> &entities )
    4272                 :            : {
    4273         [ #  # ]:          0 :   CubitTransformMatrix prev_xform;
    4274         [ #  # ]:          0 :   prev_xform.translate(translation_to_origin);
    4275                 :            : 
    4276 [ #  # ][ #  # ]:          0 :   CubitTransformMatrix rot_mat;
    4277         [ #  # ]:          0 :   rot_mat.rotate( angle_of_rotation, axis_of_rotation );
    4278                 :            : 
    4279 [ #  # ][ #  # ]:          0 :   CubitTransformMatrix mov_mat;
    4280         [ #  # ]:          0 :   mov_mat.translate( origin_to_target );
    4281                 :            : 
    4282 [ #  # ][ #  # ]:          0 :   for( int k=0; k<entities.size(); k++ )
    4283                 :            :   {
    4284         [ #  # ]:          0 :     RefEntity *tmp_ent = entities[k];           
    4285         [ #  # ]:          0 :     TopologyEntity *te = dynamic_cast<TopologyEntity*>(tmp_ent);
    4286         [ #  # ]:          0 :     if( NULL == te )
    4287                 :          0 :       continue;
    4288                 :            : 
    4289         [ #  # ]:          0 :     DLIList<RefEdge*> edges;
    4290         [ #  # ]:          0 :     te->ref_edges(edges);      
    4291 [ #  # ][ #  # ]:          0 :     for (int i = 0; i < edges.size(); i++)
    4292                 :            :     {
    4293         [ #  # ]:          0 :       GMem poly;
    4294 [ #  # ][ #  # ]:          0 :       if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
                 [ #  # ]
    4295                 :            :       {
    4296         [ #  # ]:          0 :         poly.transform(prev_xform);
    4297         [ #  # ]:          0 :         poly.transform(rot_mat);
    4298         [ #  # ]:          0 :         poly.transform(mov_mat);
    4299 [ #  # ][ #  # ]:          0 :         GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
                 [ #  # ]
    4300                 :            :       }
    4301 [ #  # ][ #  # ]:          0 :       else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
         [ #  # ][ #  # ]
                 [ #  # ]
    4302                 :            :       {
    4303 [ #  # ][ #  # ]:          0 :         CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
                 [ #  # ]
    4304 [ #  # ][ #  # ]:          0 :         tmp_pt = prev_xform*tmp_pt;
    4305 [ #  # ][ #  # ]:          0 :         tmp_pt = rot_mat*tmp_pt;
    4306 [ #  # ][ #  # ]:          0 :         tmp_pt = mov_mat*tmp_pt;       
    4307         [ #  # ]:          0 :         GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
    4308                 :            :       }
    4309         [ #  # ]:          0 :     }
    4310 [ #  # ][ #  # ]:          0 :   }
    4311                 :          0 : }
    4312                 :            : 
    4313                 :            : 
    4314                 :            : 
    4315                 :         11 : CubitStatus GeometryModifyTool::sweep_setup(
    4316                 :            :                          const char* name,
    4317                 :            :                          DLIList<RefEntity*>& input_entity_list,
    4318                 :            :                          DLIList<Body*>& output_body_list,
    4319                 :            :                          GeometryModifyEngine*& output_engine,
    4320                 :            :                          CubitBoolean& changed_new_ids,
    4321                 :            :                          DLIList<GeometryEntity*>& output_geom_list,
    4322                 :            :                          bool keep_old,
    4323                 :            :                          DLIList<RefEdge*>* input_edge_list,
    4324                 :            :                          DLIList<Curve*>* output_curve_list )
    4325                 :            : {
    4326                 :            :   int i;
    4327                 :            : 
    4328 [ +  - ][ -  + ]:         11 :   if (input_entity_list.size() == 0)
    4329                 :          0 :     return CUBIT_FAILURE;
    4330                 :            : 
    4331         [ +  - ]:         11 :   DLIList<RefFace*> ref_face_list;
    4332 [ +  - ][ +  - ]:         22 :   DLIList<RefEdge*> ref_edge_list;
    4333 [ +  - ][ +  - ]:         22 :   CAST_LIST( input_entity_list, ref_face_list, RefFace );
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
    4334 [ +  - ][ +  - ]:         22 :   CAST_LIST( input_entity_list, ref_edge_list, RefEdge );
         [ +  - ][ -  + ]
         [ -  + ][ #  # ]
                 [ +  + ]
    4335 [ +  - ][ +  - ]:         11 :   if( ref_face_list.size() && ref_edge_list.size() )
         [ +  - ][ -  + ]
                 [ -  + ]
    4336                 :            :   {
    4337 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Currently cannot sweep curves and surfaces at the same time\n" );
         [ #  # ][ #  # ]
    4338                 :          0 :     return CUBIT_FAILURE;
    4339                 :            :   }
    4340                 :            : 
    4341 [ +  - ][ +  - ]:         11 :   if( (ref_face_list.size()+ref_edge_list.size()) != input_entity_list.size() )
         [ +  - ][ -  + ]
    4342                 :            :   {
    4343 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Can only sweep surfaces or curves\n" );
         [ #  # ][ #  # ]
    4344                 :          0 :     return CUBIT_FAILURE;
    4345                 :            :   }
    4346                 :            : 
    4347                 :            :   // Currently faces to be swept have to belong to different bodies.  It
    4348                 :            :   // doesn't work well to sweep multiple faces from the same body (also
    4349                 :            :   // current implementation in AGE crashes).
    4350 [ +  - ][ +  - ]:         11 :   if( ref_face_list.size() && false == keep_old )
         [ +  - ][ +  - ]
    4351                 :            :   {
    4352                 :         11 :     int free_surf_cnt = 0; // Number of free surfaces being swept
    4353         [ +  - ]:         11 :     DLIList<Body*> body_list;
    4354                 :            :     RefFace *ref_face_ptr;
    4355 [ +  - ][ +  + ]:         22 :     for( i=ref_face_list.size(); i--; )
    4356                 :            :     {
    4357         [ +  - ]:         11 :       ref_face_ptr = ref_face_list.get_and_step();
    4358         [ +  - ]:         11 :       DLIList<Body*> tmp_body_list;
    4359         [ +  - ]:         11 :       ref_face_ptr->bodies( tmp_body_list );
    4360 [ +  - ][ -  + ]:         11 :       if( tmp_body_list.size() > 1 )
    4361                 :            :       {
    4362 [ #  # ][ #  # ]:          0 :         PRINT_ERROR( "Surface %d belongs to more than one volume; cannot sweep.\n",
         [ #  # ][ #  # ]
    4363         [ #  # ]:          0 :           ref_face_ptr->id() );
    4364                 :          0 :         return CUBIT_FAILURE;
    4365                 :            :       }
    4366                 :            : 
    4367 [ +  - ][ +  - ]:         11 :       if( tmp_body_list.size() > 0 )
    4368 [ +  - ][ +  - ]:         11 :         body_list.append_unique( tmp_body_list.get() );
    4369                 :            :       else
    4370 [ +  - ][ +  - ]:         11 :         free_surf_cnt++;
    4371                 :         11 :     }
    4372                 :            : 
    4373 [ +  - ][ +  - ]:         11 :     if( body_list.size()+free_surf_cnt != ref_face_list.size() )
                 [ -  + ]
    4374                 :            :     {
    4375                 :            :       //if each is a sheet body, and every surface is in the list,
    4376                 :            :       //it is ok to sweep it
    4377                 :            : 
    4378                 :            :       //PRINT_ERROR("The surfaces to be swept cannot belong to the same volume\n");
    4379                 :            :       //return CUBIT_FAILURE;
    4380                 :            : 
    4381 [ #  # ][ #  # ]:          0 :       for( int k=body_list.size(); k--; )
    4382                 :            :       {
    4383         [ #  # ]:          0 :         Body *tmp_body = body_list.get_and_step();
    4384         [ #  # ]:          0 :         DLIList<RefFace*> tmp_ref_faces;
    4385         [ #  # ]:          0 :         tmp_body->ref_faces( tmp_ref_faces );
    4386                 :            : 
    4387                 :            :         //all surfaces must be swept
    4388 [ #  # ][ #  # ]:          0 :         if( tmp_body->is_sheet_body() )
    4389                 :            :         {
    4390         [ #  # ]:          0 :           tmp_ref_faces -= ref_face_list;
    4391 [ #  # ][ #  # ]:          0 :           if( tmp_ref_faces.size() )
    4392                 :            :           {
    4393 [ #  # ][ #  # ]:          0 :             PRINT_ERROR( "When sweeping a sheet body, all surfaces must be specified\n");
         [ #  # ][ #  # ]
    4394                 :          0 :             return CUBIT_FAILURE;
    4395                 :            :           }
    4396                 :            :         }
    4397                 :            :         else // only 1 surface can be swept
    4398                 :            :         {
    4399         [ #  # ]:          0 :           int num_surfaces_before = tmp_ref_faces.size();
    4400         [ #  # ]:          0 :           tmp_ref_faces -= ref_face_list;
    4401                 :            : 
    4402 [ #  # ][ #  # ]:          0 :           if( (num_surfaces_before - tmp_ref_faces.size() ) > 1 )
    4403                 :            :           {
    4404 [ #  # ][ #  # ]:          0 :             PRINT_ERROR( "The surfaces to be swept cannot belong to the same volume\n" );
         [ #  # ][ #  # ]
    4405 [ #  # ][ #  # ]:          0 :             return CUBIT_FAILURE;
    4406                 :            :           }
    4407                 :            :         }
    4408                 :          0 :       }
    4409                 :            :     }
    4410                 :            : 
    4411 [ +  - ][ +  - ]:         11 :     output_body_list = body_list;
                 [ +  - ]
    4412                 :            :   }
    4413                 :            : 
    4414                 :            :   // Make sure all entities are from same modify engine
    4415 [ +  - ][ +  - ]:         22 :   DLIList<TopologyEntity*> te_list;
    4416 [ +  - ][ +  - ]:         22 :   CAST_LIST(input_entity_list, te_list, TopologyEntity);
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
    4417                 :            : 
    4418                 :            :   // This is for sweeping along a curve list
    4419         [ -  + ]:         11 :   if (input_edge_list)
    4420                 :            :   {
    4421         [ #  # ]:          0 :     input_edge_list->reset();
    4422 [ #  # ][ #  # ]:          0 :     for( i=input_edge_list->size(); i--; )
    4423 [ #  # ][ #  # ]:          0 :       te_list.append( input_edge_list->get_and_step() );
    4424                 :            :   }
    4425                 :            : 
    4426 [ +  - ][ +  - ]:         22 :   DLIList<TopologyBridge*> bridge_list( te_list.size() );
                 [ +  - ]
    4427         [ +  - ]:         11 :   output_engine = common_modify_engine( te_list, bridge_list );
    4428         [ -  + ]:         11 :   if( output_engine == NULL )
    4429                 :            :   {
    4430 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Can't sweep with entities from different modeling engines.\n");
         [ #  # ][ #  # ]
    4431                 :          0 :      return CUBIT_FAILURE;
    4432                 :            :   }
    4433                 :            : 
    4434                 :            :   // Check for virtual anywhere in participating bodies.  This will catch cases where
    4435                 :            :   // the result from sweeping would interact with some virtual somewhere. bwc 12/22/05.
    4436 [ +  - ][ +  + ]:         22 :   for(i=output_body_list.size(); i--;)
    4437                 :            :   {
    4438 [ +  - ][ -  + ]:         11 :      if(GeometryQueryTool::instance()->contains_intermediate_geometry(
    4439 [ +  - ][ +  - ]:         11 :         output_body_list.get_and_step()))
                 [ +  - ]
    4440                 :            :      {
    4441 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Can't sweep faces of bodies containing virtual geometry.\n");
         [ #  # ][ #  # ]
    4442                 :          0 :         return CUBIT_FAILURE;
    4443                 :            :      }
    4444                 :            :   }
    4445                 :            : 
    4446                 :         11 :   changed_new_ids = CUBIT_FALSE;
    4447                 :            : 
    4448                 :            :   TopologyBridge* bridge_ptr;
    4449         [ +  - ]:         11 :   bridge_list.reset();
    4450 [ +  - ][ +  + ]:         22 :   for( i=input_entity_list.size(); i--; )
    4451                 :            :   {
    4452         [ +  - ]:         11 :     bridge_ptr = bridge_list.get_and_step();
    4453         [ -  + ]:         11 :     GeometryEntity* geom_ptr = dynamic_cast<GeometryEntity*>(bridge_ptr);
    4454         [ +  - ]:         11 :     output_geom_list.append(geom_ptr);
    4455                 :            :   }
    4456                 :            : 
    4457         [ -  + ]:         11 :   if( input_edge_list )
    4458                 :            :   {
    4459 [ #  # ][ #  # ]:          0 :     for( i=input_edge_list->size(); i--; )
    4460                 :            :     {
    4461         [ #  # ]:          0 :       bridge_ptr = bridge_list.get_and_step();
    4462         [ #  # ]:          0 :       Curve* curve_ptr = dynamic_cast<Curve*>(bridge_ptr);
    4463         [ #  # ]:          0 :       output_curve_list->append(curve_ptr);
    4464                 :            :     }
    4465                 :            :   }
    4466                 :            : 
    4467         [ +  - ]:         22 :   return CUBIT_SUCCESS;
    4468                 :            : }
    4469                 :            : 
    4470                 :         11 : CubitStatus GeometryModifyTool::sweep_finish(
    4471                 :            :                                      const char* const,
    4472                 :            :                                      DLIList<Body*>& input_body_list,
    4473                 :            :                                      DLIList<BodySM*>& new_body_list,
    4474                 :            :                                      DLIList<Body*>& output_body_list,
    4475                 :            :                                      CubitBoolean changed_new_ids )
    4476                 :            : {
    4477                 :            :   int i;
    4478         [ +  - ]:         11 :   DLIList<BodySM*> regen_list( new_body_list );
    4479         [ +  - ]:         11 :   GeometryQueryTool *gqt = GeometryQueryTool::instance();
    4480                 :            : 
    4481         [ +  - ]:         11 :   input_body_list.reset();
    4482 [ +  - ][ +  + ]:         22 :   for (i = input_body_list.size(); i--; )
    4483                 :            :   {
    4484         [ +  - ]:         11 :     Body* body = input_body_list.get_and_step();
    4485         [ +  - ]:         11 :     BodySM* bodysm = body->get_body_sm_ptr();
    4486         [ -  + ]:         11 :     if (bodysm)
    4487                 :            :     {
    4488         [ #  # ]:          0 :       regen_list.append_unique(bodysm);
    4489 [ #  # ][ #  # ]:          0 :       remove_dead_entity_names(body);
    4490         [ #  # ]:          0 :       output_body_list.append( body );
    4491                 :            :     }
    4492                 :            :     else
    4493                 :            :     {
    4494         [ +  - ]:         11 :       gqt->destroy_dead_entity(body);
    4495                 :            :     }
    4496                 :            :   }
    4497         [ +  - ]:         11 :   gqt->cleanout_deactivated_geometry();
    4498                 :            : 
    4499         [ +  - ]:         11 :   regen_list.reset();
    4500 [ +  - ][ +  + ]:         22 :   for (i = regen_list.size(); i--; )
    4501                 :            :   {
    4502         [ +  - ]:         11 :     BodySM* bodysm = regen_list.get_and_step();
    4503         [ +  - ]:         11 :     Body* body = gqt->make_Body(bodysm);
    4504         [ +  - ]:         11 :     output_body_list.append_unique( body );
    4505 [ +  - ][ +  - ]:         22 :     PRINT_INFO("%s volume %d\n",
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    4506                 :            :       new_body_list.is_in_list(bodysm) ? "Created swept" : "Updated",
    4507         [ +  - ]:         11 :       body->ref_volume()->id());
    4508                 :            :   }
    4509                 :            : 
    4510 [ -  + ][ #  # ]:         11 :   if (changed_new_ids) set_new_ids(CUBIT_FALSE);
    4511         [ +  - ]:         11 :   gqt->cleanout_deactivated_geometry();
    4512                 :            : 
    4513         [ +  - ]:         11 :   return CUBIT_SUCCESS;
    4514                 :            : }
    4515                 :            : 
    4516                 :            : 
    4517                 :            : 
    4518                 :            : 
    4519                 :            : 
    4520                 :         11 : CubitStatus GeometryModifyTool::sweep_rotational(
    4521                 :            :                                         DLIList<RefEntity*>& ref_ent_list,
    4522                 :            :                                         const CubitVector& point,
    4523                 :            :                                         const CubitVector& sweep_axis,
    4524                 :            :                                         double angle,
    4525                 :            :                                         DLIList<Body*>& output_body_list,
    4526                 :            :                                         CubitBoolean anchor_entity,
    4527                 :            :                                         CubitBoolean keep_old,
    4528                 :            :                                         int steps,
    4529                 :            :                                         double draft_angle,
    4530                 :            :                                         int draft_type,
    4531                 :            :                                         CubitBoolean switchside,
    4532                 :            :                                         CubitBoolean make_solid,
    4533                 :            :                                         CubitBoolean rigid)
    4534                 :            : {
    4535         [ +  - ]:         11 :   DLIList<Body*> body_list;
    4536 [ +  - ][ +  - ]:         22 :   DLIList<GeometryEntity*> geom_list;
    4537                 :         11 :   GeometryModifyEngine* gePtr1 = 0;
    4538                 :            :   CubitBoolean change_newids;
    4539         [ -  + ]:         11 :   if (!sweep_setup("rotational", ref_ent_list, body_list, gePtr1,
    4540         [ +  - ]:         11 :                    change_newids, geom_list, keep_old))
    4541                 :          0 :     return CUBIT_FAILURE;
    4542                 :            : 
    4543 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled())
    4544                 :            :   {
    4545         [ #  # ]:          0 :     DLIList<RefEdge*> edge_list;
    4546 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> face_list;
    4547                 :            : 
    4548 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, edge_list, RefEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4549 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, face_list, RefFace );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4550                 :            : 
    4551 [ #  # ][ #  # ]:          0 :     DLIList<RefEdge*> free_edges;
    4552 [ #  # ][ #  # ]:          0 :     for(int i=0;i<edge_list.size();i++)
    4553                 :            :     {
    4554         [ #  # ]:          0 :       RefEdge* edge= edge_list[i];
    4555 [ #  # ][ #  # ]:          0 :       if(edge->num_parent_ref_entities()==0)
    4556                 :            :       {
    4557         [ #  # ]:          0 :         free_edges.append(edge);
    4558                 :            :       }
    4559                 :            :     }
    4560                 :            : 
    4561 [ #  # ][ #  # ]:          0 :     if(free_edges.size())
    4562         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( free_edges );
    4563 [ #  # ][ #  # ]:          0 :     else if( edge_list.size() || keep_old )
         [ #  # ][ #  # ]
    4564         [ #  # ]:          0 :       CubitUndo::save_state();
    4565                 :            :     else
    4566                 :            :      //Faces will get consumed so you have to save out original entities
    4567 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( face_list );
    4568                 :            :   }
    4569                 :            : 
    4570 [ +  - ][ +  - ]:         22 :   DLIList<BodySM*> result_list;
    4571                 :            :   CubitStatus status = gePtr1->sweep_rotational( geom_list,
    4572                 :            :                                                  result_list,
    4573                 :            :                                                  point,
    4574                 :            :                                                  sweep_axis,
    4575                 :            :                                                  angle,
    4576                 :            :                                                  steps,
    4577                 :            :                                                  draft_angle,
    4578                 :            :                                                  draft_type,
    4579                 :            :                                                  switchside,
    4580                 :            :                                                  make_solid,
    4581                 :            :                                                  rigid,
    4582                 :            :                                                  anchor_entity,
    4583         [ +  - ]:         11 :                                                  keep_old );
    4584                 :            : 
    4585         [ -  + ]:         11 :   if( keep_old )
    4586         [ #  # ]:          0 :     body_list.clean_out();
    4587                 :            : 
    4588 [ +  - ][ -  + ]:         11 :   if (!sweep_finish("rotational", body_list, result_list, output_body_list, change_newids))
    4589                 :          0 :     status = CUBIT_FAILURE;
    4590                 :            : 
    4591 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled())
    4592                 :            :   {
    4593         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
    4594         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    4595                 :            :     else
    4596         [ #  # ]:          0 :       CubitUndo::note_result_bodies( output_body_list );
    4597                 :            :   }
    4598                 :            : 
    4599         [ +  - ]:         11 :   return status;
    4600                 :            : }
    4601                 :            : 
    4602                 :            : 
    4603                 :          0 : CubitStatus GeometryModifyTool::sweep_helical( DLIList<RefEntity*>& ref_ent_list,
    4604                 :            :                                                CubitVector &location,
    4605                 :            :                                                CubitVector &direction,
    4606                 :            :                                                double &thread_distance,
    4607                 :            :                                                double &angle,
    4608                 :            :                                                bool right_handed,
    4609                 :            :                                                CubitBoolean anchor_entity,
    4610                 :            :                                                CubitBoolean keep_old,
    4611                 :            :                                                DLIList<Body*>& output_body_list)
    4612                 :            : {
    4613         [ #  # ]:          0 :   DLIList<Body*> body_list;
    4614 [ #  # ][ #  # ]:          0 :   DLIList<GeometryEntity*> geom_list;
    4615                 :          0 :   GeometryModifyEngine* gePtr1 = 0;
    4616                 :            :   CubitBoolean change_newids;
    4617         [ #  # ]:          0 :   if (!sweep_setup("translational", ref_ent_list, body_list, gePtr1,
    4618         [ #  # ]:          0 :                    change_newids, geom_list, keep_old))
    4619                 :          0 :     return CUBIT_FAILURE;
    4620                 :            : 
    4621 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    4622                 :            :   {
    4623         [ #  # ]:          0 :     DLIList<RefEdge*> edge_list;
    4624 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> face_list;
    4625                 :            : 
    4626 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, edge_list, RefEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4627 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, face_list, RefFace );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4628                 :            : 
    4629                 :            :     //Edges aren't consumed, so there's nothing to save out
    4630 [ #  # ][ #  # ]:          0 :     if( edge_list.size() || keep_old )
         [ #  # ][ #  # ]
    4631         [ #  # ]:          0 :       CubitUndo::save_state();
    4632                 :            :     else
    4633                 :            :      //Faces will get consumed so you have to save out original entities
    4634 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( face_list );
    4635                 :            :   }
    4636                 :            : 
    4637 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> result_list;
    4638                 :            :   CubitStatus status = gePtr1->
    4639                 :            :     sweep_helical( geom_list, result_list, location,
    4640         [ #  # ]:          0 :                    direction, thread_distance, angle, right_handed, anchor_entity, keep_old );
    4641                 :            : 
    4642         [ #  # ]:          0 :   if( keep_old )
    4643         [ #  # ]:          0 :     body_list.clean_out();
    4644                 :            : 
    4645 [ #  # ][ #  # ]:          0 :   if (!sweep_finish("translational", body_list, result_list, output_body_list, change_newids))
    4646                 :          0 :     status = CUBIT_FAILURE;
    4647                 :            : 
    4648 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    4649                 :            :   {
    4650         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
    4651         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    4652                 :            :     else
    4653         [ #  # ]:          0 :       CubitUndo::note_result_bodies( output_body_list );
    4654                 :            :   }
    4655                 :            : 
    4656         [ #  # ]:          0 :   return status;
    4657                 :            : 
    4658                 :            : 
    4659                 :            : 
    4660                 :            : 
    4661                 :            : 
    4662                 :            : }
    4663                 :            : 
    4664                 :          0 : CubitStatus GeometryModifyTool::sweep_translational(
    4665                 :            :                                          DLIList<RefEntity*>& ref_ent_list,
    4666                 :            :                                          const CubitVector& sweep_vector,
    4667                 :            :                                          double draft_angle,
    4668                 :            :                                          int draft_type,
    4669                 :            :                                          CubitBoolean switchside,
    4670                 :            :                                          CubitBoolean rigid,
    4671                 :            :                                          CubitBoolean anchor_entity,
    4672                 :            :                                          CubitBoolean keep_old,
    4673                 :            :                                          DLIList<Body*>& output_body_list)
    4674                 :            : {
    4675         [ #  # ]:          0 :   DLIList<Body*> body_list;
    4676 [ #  # ][ #  # ]:          0 :   DLIList<GeometryEntity*> geom_list;
    4677                 :          0 :   GeometryModifyEngine* gePtr1 = 0;
    4678                 :            :   CubitBoolean change_newids;
    4679         [ #  # ]:          0 :   if (!sweep_setup("translational", ref_ent_list, body_list, gePtr1,
    4680         [ #  # ]:          0 :                    change_newids, geom_list, keep_old))
    4681                 :          0 :     return CUBIT_FAILURE;
    4682                 :            : 
    4683 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    4684                 :            :   {
    4685         [ #  # ]:          0 :     DLIList<RefEdge*> edge_list;
    4686 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> face_list;
    4687                 :            : 
    4688 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, edge_list, RefEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4689 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, face_list, RefFace );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4690                 :            : 
    4691                 :            :     //find any free edges
    4692 [ #  # ][ #  # ]:          0 :     DLIList<RefEdge*> free_edges;
    4693 [ #  # ][ #  # ]:          0 :     for( int k=edge_list.size(); k--; )
    4694                 :            :     {
    4695         [ #  # ]:          0 :       RefEdge *tmp_edge = edge_list.get_and_step();
    4696 [ #  # ][ #  # ]:          0 :       if( tmp_edge->num_parent_ref_entities() == 0 )
    4697         [ #  # ]:          0 :         free_edges.append( tmp_edge );
    4698                 :            :     }    
    4699                 :            : 
    4700 [ #  # ][ #  # ]:          0 :     if( free_edges.size() ) 
    4701                 :            :       //Free edges will get consumed..save them out 
    4702         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( free_edges );
    4703 [ #  # ][ #  # ]:          0 :     else if( edge_list.size() || keep_old )
         [ #  # ][ #  # ]
    4704         [ #  # ]:          0 :       CubitUndo::save_state();
    4705                 :            :     else
    4706                 :            :      //Faces will get consumed so you have to save out original entities
    4707 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( face_list );
    4708                 :            :   }
    4709                 :            : 
    4710 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> result_list;
    4711                 :            :   CubitStatus status = gePtr1->
    4712                 :            :     sweep_translational( geom_list,
    4713                 :            :                          result_list,
    4714                 :            :                          sweep_vector,
    4715                 :            :                          draft_angle,
    4716                 :            :                          draft_type,
    4717                 :            :                          switchside,
    4718                 :            :                          rigid,
    4719                 :            :                          anchor_entity,
    4720         [ #  # ]:          0 :                          keep_old);
    4721                 :            : 
    4722         [ #  # ]:          0 :   if( keep_old )
    4723         [ #  # ]:          0 :     body_list.clean_out();
    4724                 :            : 
    4725 [ #  # ][ #  # ]:          0 :   if (!sweep_finish("translational", body_list, result_list, output_body_list, change_newids))
    4726                 :          0 :     status = CUBIT_FAILURE;
    4727                 :            : 
    4728 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    4729                 :            :   {
    4730         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
    4731         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    4732                 :            :     else
    4733         [ #  # ]:          0 :       CubitUndo::note_result_bodies( output_body_list );
    4734                 :            :   }
    4735                 :            : 
    4736         [ #  # ]:          0 :   return status;
    4737                 :            : }
    4738                 :            : 
    4739                 :            : //Author:: Jonathan Bugman
    4740                 :            : //Sept 10, 2006
    4741                 :          0 : CubitStatus GeometryModifyTool::sweep_curve_target(CubitPlane ref_plane,
    4742                 :            :                                              DLIList<RefEntity*>& ref_ent_list)
    4743                 :            : {
    4744                 :            :         double distance1;
    4745                 :            :         double distance2;
    4746                 :            :         double distance3;
    4747                 :          0 :         double temp_counter=0;
    4748         [ #  # ]:          0 :         CubitVector begin_point;
    4749         [ #  # ]:          0 :         CubitVector target_begin_point;
    4750         [ #  # ]:          0 :         CubitVector get_mid_point;
    4751         [ #  # ]:          0 :         CubitVector target_mid_point;
    4752         [ #  # ]:          0 :         CubitVector end_point;
    4753         [ #  # ]:          0 :         CubitVector target_end_point;
    4754         [ #  # ]:          0 :         DLIList<RefEdge*> edge_list;
    4755 [ #  # ][ #  # ]:          0 :         CAST_LIST(ref_ent_list, edge_list, RefEdge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4756         [ #  # ]:          0 :         CubitVector result;
    4757                 :          0 :         double max_distance_for_edge=0;
    4758         [ #  # ]:          0 :         CubitVector max_result;
    4759                 :            :         //make sure that there are actually edges in list
    4760 [ #  # ][ #  # ]:          0 :         if(edge_list.size() > 0)
    4761                 :            :         {
    4762                 :            :                 //this part of the code steps through all edges that could be
    4763                 :            :                 //selected by user and finds the largest distance of all edges from three
    4764                 :            :                 //points: midpoint, endpoint, and beginpoint
    4765 [ #  # ][ #  # ]:          0 :                 for (int i=0;i<edge_list.size();i++)
    4766                 :            :                 {
    4767                 :            :                         //find the midpoint vector of the edge
    4768 [ #  # ][ #  # ]:          0 :                         edge_list[i]->mid_point(get_mid_point);
    4769                 :            : 
    4770                 :            :                         //Project the midpoint onto the specified plane
    4771 [ #  # ][ #  # ]:          0 :                         target_mid_point = ref_plane.project(get_mid_point);
    4772                 :            : 
    4773                 :            :                         //Calculate the distance between the mid_point, and target_point
    4774         [ #  # ]:          0 :                         distance1 = target_mid_point.distance_between(get_mid_point);
    4775                 :            : 
    4776                 :            :                         //the next two blocks are just copies of the above three steps
    4777                 :          0 :                         double fraction_along_curve = 1;
    4778 [ #  # ][ #  # ]:          0 :                         edge_list[i]->position_from_fraction(fraction_along_curve, end_point);
    4779 [ #  # ][ #  # ]:          0 :                         target_end_point = ref_plane.project(end_point);
    4780         [ #  # ]:          0 :                         distance2 = target_end_point.distance_between(end_point);
    4781                 :            : 
    4782                 :          0 :                         fraction_along_curve = 0;
    4783 [ #  # ][ #  # ]:          0 :                         edge_list[i]->position_from_fraction(fraction_along_curve, begin_point);
    4784 [ #  # ][ #  # ]:          0 :                         target_begin_point = ref_plane.project(begin_point);
    4785         [ #  # ]:          0 :                         distance3 = target_begin_point.distance_between(begin_point);
    4786                 :            : 
    4787                 :            :                         //see which of the three distances is greater for that edge
    4788                 :            :                         //and compare its distance to the other edges that have already been calculated
    4789                 :            :                         //saving the vector of the largest distance
    4790 [ #  # ][ #  # ]:          0 :                         if (distance1>distance2 && distance1>distance3)
    4791                 :            :                         {
    4792 [ #  # ][ #  # ]:          0 :                                 result = 2*(target_mid_point - get_mid_point);
                 [ #  # ]
    4793                 :          0 :                                 max_distance_for_edge=distance1;
    4794         [ #  # ]:          0 :                                 if (max_distance_for_edge>temp_counter)
    4795                 :            :                                 {
    4796                 :          0 :                                         temp_counter=max_distance_for_edge;
    4797         [ #  # ]:          0 :                                         max_result=result;
    4798                 :            :                                 }
    4799                 :            :                         }
    4800         [ #  # ]:          0 :                         else if (distance2>distance3)
    4801                 :            :                         {
    4802 [ #  # ][ #  # ]:          0 :                                 result = 2*(target_end_point - end_point);
                 [ #  # ]
    4803                 :          0 :                                 max_distance_for_edge=distance2;
    4804         [ #  # ]:          0 :                                 if (max_distance_for_edge>temp_counter)
    4805                 :            :                                 {
    4806                 :          0 :                                         temp_counter=max_distance_for_edge;
    4807         [ #  # ]:          0 :                                         max_result=result;
    4808                 :            :                                 }
    4809                 :            :                         }
    4810                 :            :                         else
    4811                 :            :                         {
    4812 [ #  # ][ #  # ]:          0 :                                 result = 2*(target_begin_point - begin_point);
                 [ #  # ]
    4813                 :          0 :                                 max_distance_for_edge=distance3;
    4814         [ #  # ]:          0 :                                 if (max_distance_for_edge>temp_counter)
    4815                 :            :                                 {
    4816                 :          0 :                                         temp_counter=max_distance_for_edge;
    4817         [ #  # ]:          0 :                                         max_result=result;
    4818                 :            :                                 }
    4819                 :            :                         }
    4820                 :            :                 }
    4821                 :            : 
    4822                 :            :                 //using the 'facet edges' defined by the drawing geometry take the leading
    4823                 :            :                 //and trailing edge projection vectors of this small edge.  With that,
    4824                 :            :                 //calc the dot product and if negative, the vectors are opposite of each
    4825                 :            :                 //other meaning the curve travels through the plane and the sweep function will fail
    4826 [ #  # ][ #  # ]:          0 :                 for (int ii=0;ii<edge_list.size();ii++)
    4827                 :            :                 {
    4828                 :            :                         Curve *facet_curve;
    4829 [ #  # ][ #  # ]:          0 :                         facet_curve=edge_list[ii]->get_curve_ptr();
    4830                 :            :                         CubitStatus response;
    4831         [ #  # ]:          0 :                         GMem g_mem;
    4832                 :            : 
    4833                 :            :                         //get number of points and their locations
    4834                 :            :                         //on the curve as defined by the drawing geometry algorithm
    4835         [ #  # ]:          0 :                         response = facet_curve->get_geometry_query_engine()->
    4836         [ #  # ]:          0 :                                 get_graphics( facet_curve, &g_mem );
    4837                 :          0 :                         int num_points = g_mem.pointListCount;
    4838                 :            : 
    4839 [ #  # ][ #  # ]:          0 :                         if (response==CUBIT_FAILURE || num_points == 0)
    4840                 :            :                         {
    4841 [ #  # ][ #  # ]:          0 :                                 PRINT_WARNING("Facet Curve calling function failed\n" );
         [ #  # ][ #  # ]
    4842                 :            :                         }
    4843                 :            : 
    4844         [ #  # ]:          0 :                         GPoint *point_data = g_mem.point_list();
    4845                 :            : 
    4846 [ #  # ][ #  # ]:          0 :                         for (int jj=0; jj < (num_points-1); jj++)
                 [ #  # ]
    4847                 :            :                         {
    4848                 :            :                                 //get first points vectors
    4849         [ #  # ]:          0 :                                 CubitVector point_1;
    4850         [ #  # ]:          0 :                                 point_1.x(point_data[jj].x);
    4851         [ #  # ]:          0 :                                 point_1.y(point_data[jj].y);
    4852         [ #  # ]:          0 :                                 point_1.z(point_data[jj].z);
    4853                 :            :                                 //get second points vectors
    4854         [ #  # ]:          0 :                                 CubitVector point_2;
    4855         [ #  # ]:          0 :                                 point_2.x(point_data[jj+1].x);
    4856         [ #  # ]:          0 :                                 point_2.y(point_data[jj+1].y);
    4857         [ #  # ]:          0 :                                 point_2.z(point_data[jj+1].z);
    4858                 :            :                                 //project the two points onto target plane
    4859         [ #  # ]:          0 :                                 CubitVector target_point_1;
    4860 [ #  # ][ #  # ]:          0 :                                 target_point_1 = ref_plane.project(point_1);
    4861         [ #  # ]:          0 :                                 CubitVector target_point_2;
    4862 [ #  # ][ #  # ]:          0 :                                 target_point_2 = ref_plane.project(point_2);
    4863                 :            :                                 //calc vector from point on curve to point on surface
    4864         [ #  # ]:          0 :                                 CubitVector vec_1 = point_1 - target_point_1;
    4865         [ #  # ]:          0 :                                 CubitVector vec_2 = point_2 - target_point_2;
    4866                 :            :                                 //make them unit vectors
    4867         [ #  # ]:          0 :                                 vec_1.normalize();
    4868         [ #  # ]:          0 :                                 vec_2.normalize();
    4869                 :            :                                 //calculate dot product
    4870 [ #  # ][ #  # ]:          0 :                                 double dot = vec_1.x()*vec_2.x()+vec_1.y()*vec_2.y()+vec_1.z()*vec_2.z();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    4871                 :            :                                 //check to see if dot product sign is zero
    4872                 :            :                                 //the and statement checks for if the first or last vertex of the edge
    4873                 :            :                                 //which may be sitting on the surface, this is alright
    4874                 :            :                                 //and should still be able to sweep
    4875                 :            : //                              if (dot<0 && (jj+1!=num_points || jj==0))
    4876 [ #  # ][ #  # ]:          0 :                                 if (dot<0 && (jj!=(num_points-2) || jj==0))
                 [ #  # ]
    4877                 :            :                                 {
    4878 [ #  # ][ #  # ]:          0 :                                         PRINT_ERROR( "The edge is traveling through the plane\n" );
         [ #  # ][ #  # ]
    4879 [ #  # ][ #  # ]:          0 :                                         PRINT_ERROR( "and thus forces the sweep direction to switch\n" );
         [ #  # ][ #  # ]
    4880 [ #  # ][ #  # ]:          0 :                                         PRINT_ERROR( "direction. Try splitting the edge.\n" );
         [ #  # ][ #  # ]
    4881                 :          0 :                                         return CUBIT_FAILURE;
    4882                 :            :                                 }
    4883                 :            :                         }
    4884                 :          0 :                 }
    4885         [ #  # ]:          0 :                 DLIList<BodySM*> webcut_results_list;
    4886 [ #  # ][ #  # ]:          0 :                 DLIList<Body*> body_list;
                 [ #  # ]
    4887 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> sweep_result_list;
                 [ #  # ]
    4888 [ #  # ][ #  # ]:          0 :                 DLIList<GeometryEntity*> geom_list;
                 [ #  # ]
    4889                 :          0 :                 GeometryModifyEngine* gePtr1 = 0;
    4890                 :            :                 CubitBoolean change_newids;
    4891                 :            : 
    4892         [ #  # ]:          0 :                 if (!sweep_setup("translational", ref_ent_list , body_list, gePtr1,
    4893         [ #  # ]:          0 :                         change_newids, geom_list, false))
    4894                 :          0 :                         return CUBIT_FAILURE;
    4895                 :            : 
    4896                 :            :                 //below block is default settings to be fed into sweep_translational
    4897                 :          0 :                 CubitBoolean rigid = CUBIT_FALSE;
    4898                 :          0 :                 CubitBoolean switchside = CUBIT_FALSE;
    4899                 :          0 :                 int draft_type = 0;
    4900                 :          0 :                 double draft_angle=0.0;
    4901                 :            : 
    4902                 :            :                 //sweep the curve through and hopefully past the target surface
    4903                 :            :                 CubitStatus status = gePtr1->sweep_translational( geom_list,sweep_result_list,
    4904         [ #  # ]:          0 :                         max_result,draft_angle, draft_type,switchside,rigid);
    4905                 :            : 
    4906         [ #  # ]:          0 :                 if (status == 0)
    4907                 :            :                 {
    4908 [ #  # ][ #  # ]:          0 :                         PRINT_ERROR( "Sweep operation failed!\n" );
         [ #  # ][ #  # ]
    4909                 :            :                         //delete sweep_result_list memory
    4910 [ #  # ][ #  # ]:          0 :                         gePtr1->get_gqe()->delete_solid_model_entities(sweep_result_list);
    4911                 :          0 :                         return CUBIT_FAILURE;
    4912                 :            :                 }
    4913                 :            : 
    4914                 :            :                 //below lines are used to define the ref_plane with three points for webcut input
    4915                 :            :                 //find normal vector to user specified plane
    4916 [ #  # ][ #  # ]:          0 :                 CubitVector vec1 = ref_plane.normal();
    4917         [ #  # ]:          0 :                 CubitVector vec2;
    4918         [ #  # ]:          0 :                 CubitVector vec3;
    4919                 :            :                 //get orthogonal vectors of the normal vector
    4920         [ #  # ]:          0 :                 vec1.orthogonal_vectors(vec2, vec3);
    4921                 :            :                 //place the orthogonal vectors at a point on the plane as opposed to the origin
    4922 [ #  # ][ #  # ]:          0 :                 vec2=vec2+target_mid_point;
    4923 [ #  # ][ #  # ]:          0 :                 vec3=vec3+target_mid_point;
    4924                 :            : 
    4925 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> neighbor_imprint_list;
                 [ #  # ]
    4926                 :            :                 //do a webcut with a plane created from the three projected points above
    4927                 :            :                 CubitStatus status2 = gePtr1->webcut(sweep_result_list,target_mid_point,
    4928         [ #  # ]:          0 :                         vec2,vec3, neighbor_imprint_list, webcut_results_list);
    4929                 :            : 
    4930         [ #  # ]:          0 :                 if (status2 == 0)
    4931                 :            :                 {
    4932 [ #  # ][ #  # ]:          0 :                         PRINT_ERROR( "Sweep operation worked; however, webcut operation failed.\n" );
         [ #  # ][ #  # ]
    4933                 :            :                         //delete memory since it failed
    4934 [ #  # ][ #  # ]:          0 :                         gePtr1->get_gqe()->delete_solid_model_entities(sweep_result_list);
    4935                 :          0 :                         return CUBIT_FAILURE;
    4936                 :            :                 }
    4937                 :            : 
    4938 [ #  # ][ #  # ]:          0 :                 if (webcut_results_list.size()==0)
    4939                 :            :                 {
    4940 [ #  # ][ #  # ]:          0 :                         PRINT_ERROR( "Number of bodies from webcut is zero, unable to perform rest of sweep operation\n" );
         [ #  # ][ #  # ]
    4941                 :            :                         //delete memory since it failed
    4942 [ #  # ][ #  # ]:          0 :                         gePtr1->get_gqe()->delete_solid_model_entities(sweep_result_list);
    4943                 :          0 :                         return CUBIT_FAILURE;
    4944                 :            :                 }
    4945                 :            : 
    4946         [ #  # ]:          0 :                 CubitVector created_curve_mid;
    4947         [ #  # ]:          0 :                 CubitVector user_mid;
    4948 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> keep_bodies_list;
         [ #  # ][ #  # ]
    4949 [ #  # ][ #  # ]:          0 :                 DLIList<Curve*> curve_list;
    4950                 :            : 
    4951                 :            :                 //generate a list of curves from the webcut_results_list
    4952 [ #  # ][ #  # ]:          0 :                 for (int counter = 0;counter < webcut_results_list.size(); counter++)
    4953                 :            :                 {
    4954         [ #  # ]:          0 :                         BodySM* OO = webcut_results_list[counter];
    4955         [ #  # ]:          0 :                         OO->curves(curve_list);
    4956                 :            :                 }
    4957                 :            : 
    4958                 :            :                 //step through each of the user specified edges
    4959 [ #  # ][ #  # ]:          0 :                 for (int edge_counter = 0; edge_counter < edge_list.size(); edge_counter++)
    4960                 :            :                 {
    4961                 :            :                         //find the midpoint of a user specified edge
    4962 [ #  # ][ #  # ]:          0 :                         edge_list[edge_counter]->position_from_fraction(.5,user_mid);
    4963                 :          0 :                         double min_dist=DBL_MAX;
    4964                 :            :                         double distance;
    4965                 :          0 :                         Curve* closest_curve=0;
    4966                 :            : 
    4967                 :            :                         //step through all of the curves
    4968 [ #  # ][ #  # ]:          0 :                         for (int counter2 = 0; counter2 < curve_list.size(); counter2++)
    4969                 :            :                         {
    4970                 :            :                                 //find the midpoint of the created curve
    4971 [ #  # ][ #  # ]:          0 :                                 curve_list[counter2]->position_from_fraction(.5,created_curve_mid);
    4972                 :            :                                 //calculate the distance between the two midpoints
    4973         [ #  # ]:          0 :                                 distance=created_curve_mid.distance_between(user_mid);
    4974                 :            : 
    4975                 :            :                                 //find the minimum distance between all the curves
    4976         [ #  # ]:          0 :                                 if (distance<min_dist)
    4977                 :            :                                 {
    4978                 :            :                                         //reset the min_distance
    4979                 :          0 :                                         min_dist=distance;
    4980                 :            :                                         //keep track of which curve is associated with the shortest distance
    4981         [ #  # ]:          0 :                                         closest_curve=curve_list[counter2];
    4982                 :            :                                 }
    4983                 :            :                         }
    4984                 :            :                         //find the parent body of the minimum distance curve
    4985         [ #  # ]:          0 :                         BodySM* body_sm = closest_curve->bodysm();
    4986                 :            :                         //append that body to a keep list
    4987         [ #  # ]:          0 :                         keep_bodies_list.append(body_sm);
    4988                 :            :                 }
    4989                 :            :                 //delete bodies which repeat (useful only when in granite engine)
    4990         [ #  # ]:          0 :     keep_bodies_list.uniquify_ordered();
    4991                 :            :                 //subtract the keep_list from the webcut_results_list
    4992         [ #  # ]:          0 :                 webcut_results_list -=keep_bodies_list;
    4993                 :            :                 //delete webcut_results_list memory
    4994 [ #  # ][ #  # ]:          0 :                 gePtr1->get_gqe()->delete_solid_model_entities(webcut_results_list);
    4995                 :            : 
    4996 [ #  # ][ #  # ]:          0 :                 if( CubitUndo::get_undo_enabled() )
    4997         [ #  # ]:          0 :                   CubitUndo::save_state();
    4998                 :            : 
    4999                 :            :                 //builds ref bodies
    5000 [ #  # ][ #  # ]:          0 :     DLIList<Body*> output_body_list;
    5001 [ #  # ][ #  # ]:          0 :                 if (!sweep_finish("translational", body_list, keep_bodies_list, output_body_list, change_newids))
    5002                 :            :                 {
    5003 [ #  # ][ #  # ]:          0 :                         gePtr1->get_gqe()->delete_solid_model_entities(keep_bodies_list);
    5004                 :          0 :                         status = CUBIT_FAILURE;
    5005                 :            :                 }
    5006                 :            : 
    5007 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled())
    5008                 :            :     {
    5009         [ #  # ]:          0 :       if( status == CUBIT_FAILURE )
    5010         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
    5011                 :            :       else
    5012         [ #  # ]:          0 :         CubitUndo::note_result_bodies( output_body_list );
    5013                 :          0 :     }
    5014                 :            :         }
    5015                 :            :         else
    5016                 :            :         {
    5017 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "No edge(s) found - sweep creation failed.\n" );
         [ #  # ][ #  # ]
    5018                 :          0 :                 return CUBIT_FAILURE;
    5019                 :            :         }
    5020                 :            : 
    5021         [ #  # ]:          0 :         return CUBIT_SUCCESS;
    5022                 :            : }
    5023                 :            : // Author: Derek Quam
    5024                 :            : // Dec. 1, 2008
    5025                 :          0 : CubitStatus GeometryModifyTool::sweep_surface_target(RefFace *face,
    5026                 :            :                                                      Body *target_body,
    5027                 :            :                                                      CubitVector distance,
    5028                 :            :                                                      CubitPlane stop_plane,
    5029                 :            :                                                      double magnitude)
    5030                 :            : {
    5031                 :            :   //  Declare local variables
    5032                 :            :   Surface *source_surf;
    5033                 :          0 :   bool set_dist = true, set_plane = true, set_mag = true;
    5034         [ #  # ]:          0 :   CubitVector direction;
    5035                 :            :   CubitStatus status;
    5036         [ #  # ]:          0 :   DLIList<Body*> body_list;
    5037 [ #  # ][ #  # ]:          0 :   DLIList<GeometryEntity*> geom_list;
    5038                 :          0 :   GeometryModifyEngine* gePtr1 = 0;
    5039                 :            :   CubitBoolean change_newids;
    5040 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> ref_ent_list;
    5041 [ #  # ][ #  # ]:          0 :   ref_ent_list.append(face);
    5042                 :            : 
    5043                 :            :   // Check to make sure the target body is a solid
    5044 [ #  # ][ #  # ]:          0 :   if (target_body->is_sheet_body())
    5045                 :            :   {
    5046 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Target body must be a solid body.\n");
         [ #  # ][ #  # ]
    5047                 :          0 :     return CUBIT_FAILURE;
    5048                 :            :   }
    5049                 :            : 
    5050                 :            :   // Set up the sweep
    5051         [ #  # ]:          0 :   if (!sweep_setup("target", ref_ent_list, body_list, gePtr1,
    5052         [ #  # ]:          0 :                     change_newids, geom_list, false))
    5053                 :          0 :     return CUBIT_FAILURE;
    5054                 :            : 
    5055                 :            :   // Get the Surface * from the RefFace *
    5056         [ #  # ]:          0 :   source_surf = face->get_surface_ptr();
    5057                 :            : 
    5058                 :            :   // Check if the direction vector and stop plane were specified
    5059 [ #  # ][ #  # ]:          0 :   if (distance.length() < 0.0001)
    5060                 :          0 :     set_dist = false;
    5061 [ #  # ][ #  # ]:          0 :   if (stop_plane.normal().length() < 0.0001)
                 [ #  # ]
    5062                 :          0 :     set_plane = false;
    5063         [ #  # ]:          0 :   if (magnitude < 0.0001)
    5064                 :          0 :     set_mag = false;
    5065                 :            : 
    5066                 :            :   // Calculate the direction of the sweep
    5067         [ #  # ]:          0 :   if (!set_dist)
    5068 [ #  # ][ #  # ]:          0 :     direction = face->normal_at(face->center_point());
                 [ #  # ]
    5069                 :            :   else
    5070         [ #  # ]:          0 :     direction = distance;
    5071         [ #  # ]:          0 :   direction.normalize();
    5072                 :            : 
    5073                 :          0 :   double length = 0.0;
    5074 [ #  # ][ #  # ]:          0 :   if (!set_mag && !set_plane)
    5075                 :            :   {
    5076         [ #  # ]:          0 :     CubitVector center_body = target_body->center_point();
    5077         [ #  # ]:          0 :     CubitVector center_face = face->center_point();
    5078         [ #  # ]:          0 :     length = center_face.distance_between(center_body);
    5079                 :            :   }
    5080         [ #  # ]:          0 :   else if (set_plane)
    5081                 :            :   {
    5082 [ #  # ][ #  # ]:          0 :     length = stop_plane.intersect(face->center_point(), direction).distance_between(face->center_point());
         [ #  # ][ #  # ]
    5083                 :            :   }
    5084                 :            :   else
    5085                 :            :   {
    5086                 :          0 :     length = magnitude;
    5087                 :            :   }
    5088 [ #  # ][ #  # ]:          0 :   if (set_mag && length > magnitude)
    5089                 :          0 :     length = magnitude;
    5090         [ #  # ]:          0 :   direction *= length;
    5091                 :            : 
    5092 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodies;
    5093 [ #  # ][ #  # ]:          0 :   status = gePtr1->sweep_to_body(source_surf, target_body->get_body_sm_ptr(), direction, new_bodies );
                 [ #  # ]
    5094                 :            : 
    5095         [ #  # ]:          0 :   if (status != CUBIT_SUCCESS)
    5096                 :          0 :     return status;
    5097                 :            : 
    5098 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    5099         [ #  # ]:          0 :     CubitUndo::save_state();
    5100                 :            : 
    5101                 :            :   // Make all the new bodies
    5102 [ #  # ][ #  # ]:          0 :   DLIList<Body*> output_body_list;
    5103 [ #  # ][ #  # ]:          0 :   if (!sweep_finish("target", body_list, new_bodies, output_body_list, change_newids))
    5104                 :          0 :     status = CUBIT_FAILURE;
    5105                 :            : 
    5106 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    5107                 :            :     {
    5108         [ #  # ]:          0 :       if( status == CUBIT_FAILURE )
    5109         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
    5110                 :            :       else
    5111                 :            :       {
    5112                 :            :         //For some reason the ouput_body_list contains one of the original
    5113                 :            :         //volumes that we do not want to delete when we are performing an 
    5114                 :            :         //undo on the sweep. So we remove that original volume from the 
    5115                 :            :         //"to undo" list.
    5116         [ #  # ]:          0 :         Body* to_delete = output_body_list[1];
    5117         [ #  # ]:          0 :         output_body_list.clean_out();
    5118         [ #  # ]:          0 :         output_body_list.append(to_delete);
    5119         [ #  # ]:          0 :         CubitUndo::note_result_bodies( output_body_list );
    5120                 :            :       }
    5121                 :            :     }
    5122                 :            : 
    5123                 :            :   /*
    5124                 :            :   for (int i = 0; i < new_bodies.size(); i++)
    5125                 :            :     GeometryQueryTool::instance()->make_Body(new_bodies.get_and_step());
    5126                 :            :     */
    5127                 :            : 
    5128                 :            : 
    5129         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    5130                 :            : }
    5131                 :            : 
    5132                 :            : // Author: Andrew Rout and Derek Quam
    5133                 :            : // Nov. 14, 2008
    5134                 :          0 : CubitStatus GeometryModifyTool::sweep_curve_target(DLIList<RefEdge*>& edge_list,
    5135                 :            :                                                    Body *target_body,
    5136                 :            :                                                    DLIList<Body*> &out_bodies,
    5137                 :            :                                                    CubitVector distance,
    5138                 :            :                                                    CubitPlane stop_plane,
    5139                 :            :                                                    bool unite)
    5140                 :            : {
    5141         [ #  # ]:          0 :   DLIList<BodySM*> new_bodies;
    5142 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list;
    5143                 :          0 :   bool set_dist = true, set_plane = true;
    5144                 :          0 :   double larDist = 1.0;
    5145         [ #  # ]:          0 :   CubitVector dir = distance;
    5146                 :            :   CubitStatus status;
    5147                 :            : 
    5148                 :            :   // Check to make sure the target body is a sheetbody
    5149 [ #  # ][ #  # ]:          0 :   if (!target_body->is_sheet_body())
    5150                 :            :   {
    5151 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Target body must be a sheet body.\n");
         [ #  # ][ #  # ]
    5152                 :          0 :     return CUBIT_FAILURE;
    5153                 :            :   }
    5154                 :            : 
    5155                 :            :   // Get the Curve *'s from the RefEdge *'s
    5156 [ #  # ][ #  # ]:          0 :   for (int i = 0; i < edge_list.size(); i++)
    5157                 :            :   {
    5158 [ #  # ][ #  # ]:          0 :     edge_list[i]->get_curve_ptr()->set_saved_id(edge_list[i]->id());
         [ #  # ][ #  # ]
                 [ #  # ]
    5159 [ #  # ][ #  # ]:          0 :     curve_list.append(edge_list[i]->get_curve_ptr());
                 [ #  # ]
    5160                 :            :   }
    5161                 :            :   // Check if the direction vector and stop plane were specified
    5162 [ #  # ][ #  # ]:          0 :   if (distance.length() < 0.0001)
    5163                 :          0 :     set_dist = false;
    5164 [ #  # ][ #  # ]:          0 :   if (stop_plane.normal().length() < 0.0001)
                 [ #  # ]
    5165                 :          0 :     set_plane = false;
    5166                 :            : 
    5167                 :            :   // Check inputs
    5168 [ #  # ][ #  # ]:          0 :   if (!set_plane && !set_dist)
    5169                 :            :   {
    5170 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("User must specify a stop plane, a direction, or both.\n");
         [ #  # ][ #  # ]
    5171                 :          0 :     return CUBIT_FAILURE;
    5172                 :            :   }
    5173                 :            : 
    5174                 :            :   // Calculate the direction vector
    5175                 :            :   double begDist, midDist, endDist;
    5176 [ #  # ][ #  # ]:          0 :   for (int i = 0; i < edge_list.size(); i++)
    5177                 :            :   {
    5178 [ #  # ][ #  # ]:          0 :     CubitVector beg, mid, end, begP, midP, endP;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5179         [ #  # ]:          0 :     RefEdge *temp = edge_list.get_and_step();
    5180                 :            : 
    5181                 :            :     // Retrieve the beginning, middle, and end coordinates of the edge
    5182 [ #  # ][ #  # ]:          0 :     beg = temp->start_coordinates();
    5183         [ #  # ]:          0 :     temp->mid_point(mid);
    5184 [ #  # ][ #  # ]:          0 :     end = temp->end_coordinates();
    5185                 :            : 
    5186         [ #  # ]:          0 :     if (set_plane)
    5187                 :            :     {
    5188                 :            :       // Project the start, mid, and end point onto the stop plane
    5189 [ #  # ][ #  # ]:          0 :       begP = stop_plane.project(beg);
    5190 [ #  # ][ #  # ]:          0 :       midP = stop_plane.project(mid);
    5191 [ #  # ][ #  # ]:          0 :       endP = stop_plane.project(end);
    5192                 :            : 
    5193                 :            :       // Calculate the distance between the points
    5194         [ #  # ]:          0 :       begDist = beg.distance_between(begP);
    5195         [ #  # ]:          0 :       midDist = mid.distance_between(midP);
    5196         [ #  # ]:          0 :       endDist = end.distance_between(endP);
    5197                 :            :     }
    5198                 :            :     else  // No stop plane specified
    5199                 :            :     {
    5200 [ #  # ][ #  # ]:          0 :       begDist = beg.distance_between(target_body->center_point());
    5201 [ #  # ][ #  # ]:          0 :       midDist = mid.distance_between(target_body->center_point());
    5202 [ #  # ][ #  # ]:          0 :       endDist = end.distance_between(target_body->center_point());
    5203                 :            :     }
    5204                 :            : 
    5205                 :            :     // Find the largest distance
    5206         [ #  # ]:          0 :     if (begDist > larDist)
    5207                 :          0 :       larDist = begDist;
    5208         [ #  # ]:          0 :     if (midDist > larDist)
    5209                 :          0 :       larDist = midDist;
    5210         [ #  # ]:          0 :     if (endDist > larDist)
    5211                 :          0 :       larDist = endDist;
    5212                 :            : 
    5213                 :            :     // Make sure the plane normal is pointing the right way
    5214         [ #  # ]:          0 :     if (set_plane)
    5215                 :            :     {
    5216 [ #  # ][ #  # ]:          0 :       double planeNorm = stop_plane.normal().interior_angle(beg-begP);
                 [ #  # ]
    5217 [ #  # ][ #  # ]:          0 :       if (planeNorm <= 90 || planeNorm >= 270)
    5218         [ #  # ]:          0 :         stop_plane.reverse();
    5219                 :            :     }
    5220                 :            : 
    5221         [ #  # ]:          0 :     if (!set_dist)
    5222 [ #  # ][ #  # ]:          0 :       dir += (midP-mid);
    5223                 :            : 
    5224                 :            :   } // End for loop
    5225         [ #  # ]:          0 :   if (!set_dist)
    5226 [ #  # ][ #  # ]:          0 :     dir /= edge_list.size();
    5227                 :            : 
    5228                 :            :   // Unitize the direction vector
    5229 [ #  # ][ #  # ]:          0 :   dir /= dir.length();
    5230                 :            : 
    5231                 :            :   // Add the magnitude to the direction vector and check for intersection with the stop plane
    5232         [ #  # ]:          0 :   dir *= larDist;
    5233         [ #  # ]:          0 :   if (set_plane)
    5234                 :            :   {
    5235 [ #  # ][ #  # ]:          0 :     double angle = dir.interior_angle(stop_plane.normal());
    5236 [ #  # ][ #  # ]:          0 :     if (angle >= 90 && angle <= 270)
    5237 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("Direction vector does not intersect stop plane!\n");
         [ #  # ][ #  # ]
    5238                 :            :   }
    5239                 :            : 
    5240                 :            :   // Call the geometry function
    5241 [ #  # ][ #  # ]:          0 :   status = get_gme()->sweep_to_body(curve_list, target_body->get_body_sm_ptr(), dir, new_bodies, unite);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5242                 :            : 
    5243         [ #  # ]:          0 :   if (status != CUBIT_SUCCESS)
    5244                 :          0 :     return CUBIT_FAILURE;
    5245                 :            : 
    5246                 :            :   // Make all the new bodies
    5247 [ #  # ][ #  # ]:          0 :   for (int i = 0; i < new_bodies.size(); i++)
    5248                 :            :   {
    5249 [ #  # ][ #  # ]:          0 :     out_bodies.append(GeometryQueryTool::instance()->make_Body(new_bodies.get_and_step()));
         [ #  # ][ #  # ]
    5250 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Created volume in body %d\n", out_bodies[i]->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5251                 :            :   }
    5252                 :            : 
    5253         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    5254                 :            : }
    5255                 :            : 
    5256                 :            : //Author: Jonathan Bugman
    5257                 :            : //Sept 10, 2006
    5258                 :          0 : CubitStatus GeometryModifyTool::sweep_surface_target(CubitPlane ref_plane,
    5259                 :            :                                     DLIList<RefEntity*>& ref_ent_list)
    5260                 :            : {
    5261         [ #  # ]:          0 :         DLIList<RefFace*> surface_list;
    5262 [ #  # ][ #  # ]:          0 :         CAST_LIST(ref_ent_list, surface_list, RefFace);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5263                 :            :         double distance1;
    5264                 :            :         double distance2;
    5265                 :            :         double distance3;
    5266                 :          0 :         double temp_counter=0;
    5267         [ #  # ]:          0 :         CubitVector begin_point;
    5268         [ #  # ]:          0 :         CubitVector target_begin_point;
    5269         [ #  # ]:          0 :         CubitVector get_mid_point;
    5270         [ #  # ]:          0 :         CubitVector target_mid_point;
    5271         [ #  # ]:          0 :         CubitVector end_point;
    5272         [ #  # ]:          0 :         CubitVector target_end_point;
    5273         [ #  # ]:          0 :         CubitVector result;
    5274                 :          0 :         double max_distance_for_edge=0;
    5275         [ #  # ]:          0 :         CubitVector max_result;
    5276 [ #  # ][ #  # ]:          0 :         DLIList<RefEdge*> surf_edge_list;
    5277                 :            : 
    5278                 :            :         //make sure that only one surface has been selected
    5279 [ #  # ][ #  # ]:          0 :         if(surface_list.size() == 0)
    5280                 :            :         {
    5281 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "No surface found - sweep surface to target failed.\n" );
         [ #  # ][ #  # ]
    5282                 :          0 :                 return CUBIT_FAILURE;
    5283                 :            :         }
    5284                 :            : 
    5285                 :            :         //make sure that there are actually surfaces in list
    5286 [ #  # ][ #  # ]:          0 :         else if(surface_list.size() > 1)
    5287                 :            :         {
    5288 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "You can only use this operation \n with one surface selected at a time\n" );
         [ #  # ][ #  # ]
    5289                 :          0 :                 return CUBIT_FAILURE;
    5290                 :            :         }
    5291                 :            :         else
    5292                 :            :         {
    5293                 :            :                 //this part of the code steps through all edges that could be
    5294                 :            :                 //selected by user and finds the largest distance of all edges from three
    5295                 :            :                 //points: midpoint, endpoint, and beginpoint
    5296 [ #  # ][ #  # ]:          0 :                 for (int i=0;i<surface_list.size();i++)
    5297                 :            :                 {
    5298 [ #  # ][ #  # ]:          0 :                         surface_list[i]->ref_edges(surf_edge_list);
    5299 [ #  # ][ #  # ]:          0 :                         for (int j=0;j<surf_edge_list.size();j++)
    5300                 :            :                         {
    5301                 :            :                                 //get midpoint of edge on surface
    5302 [ #  # ][ #  # ]:          0 :                                 surf_edge_list[j]->mid_point(get_mid_point);
    5303                 :            :                                 //Project the midpoint of each surface edge onto the specified plane
    5304 [ #  # ][ #  # ]:          0 :                                 target_mid_point = ref_plane.project(get_mid_point);
    5305                 :            : 
    5306                 :            :                                 //Calculate the distance between the mid_point, and target_point
    5307         [ #  # ]:          0 :                                 distance1 = target_mid_point.distance_between(get_mid_point);
    5308                 :            : 
    5309                 :            :                                 //the next two blocks are just copies of the above three steps
    5310                 :            : 
    5311                 :          0 :                                 int fraction_along_curve = 1;
    5312 [ #  # ][ #  # ]:          0 :                                 surf_edge_list[j]->position_from_fraction(fraction_along_curve, end_point);
    5313 [ #  # ][ #  # ]:          0 :                                 target_end_point = ref_plane.project(end_point);
    5314         [ #  # ]:          0 :                                 distance2 = target_end_point.distance_between(end_point);
    5315                 :            : 
    5316                 :          0 :                                 fraction_along_curve = 0;
    5317 [ #  # ][ #  # ]:          0 :                                 surf_edge_list[j]->position_from_fraction(fraction_along_curve, begin_point);
    5318 [ #  # ][ #  # ]:          0 :                                 target_begin_point = ref_plane.project(begin_point);
    5319         [ #  # ]:          0 :                                 distance3 = target_begin_point.distance_between(begin_point);
    5320                 :            : 
    5321                 :            :                                 //see which of the three distances is greater of the edge
    5322                 :            :                                 //and compare its distance to the other edges
    5323 [ #  # ][ #  # ]:          0 :                                 if (distance1>distance2 && distance1>distance3)
    5324                 :            :                                 {
    5325 [ #  # ][ #  # ]:          0 :                                         result = 2*(target_mid_point - get_mid_point);
                 [ #  # ]
    5326                 :          0 :                                         max_distance_for_edge=distance1;
    5327         [ #  # ]:          0 :                                         if (max_distance_for_edge>temp_counter)
    5328                 :            :                                         {
    5329                 :          0 :                                                 temp_counter = max_distance_for_edge;
    5330         [ #  # ]:          0 :                                                 max_result=result;
    5331                 :            : 
    5332                 :            :                                         }
    5333                 :            :                                 }
    5334         [ #  # ]:          0 :                                 else if (distance2>distance3)
    5335                 :            :                                 {
    5336 [ #  # ][ #  # ]:          0 :                                         result = 2*(target_end_point - end_point);
                 [ #  # ]
    5337                 :          0 :                                         max_distance_for_edge=distance2;
    5338         [ #  # ]:          0 :                                         if (max_distance_for_edge>temp_counter)
    5339                 :            :                                         {
    5340                 :          0 :                                                 temp_counter = max_distance_for_edge;
    5341         [ #  # ]:          0 :                                                 max_result=result;
    5342                 :            : 
    5343                 :            :                                         }
    5344                 :            :                                 }
    5345                 :            :                                 else
    5346                 :            :                                 {
    5347 [ #  # ][ #  # ]:          0 :                                         result = 2*(target_begin_point - begin_point);
                 [ #  # ]
    5348                 :          0 :                                         max_distance_for_edge=distance3;
    5349         [ #  # ]:          0 :                                         if (max_distance_for_edge>temp_counter)
    5350                 :            :                                         {
    5351                 :          0 :                                                 temp_counter = max_distance_for_edge;
    5352         [ #  # ]:          0 :                                                 max_result=result;
    5353                 :            : 
    5354                 :            :                                         }
    5355                 :            :                                 }
    5356                 :            :                                 //just checking to make sure the user didn't specify a surface as both
    5357                 :            :                                 //a target surface and sweeping surface which would result in a CUBIT crash
    5358 [ #  # ][ #  # ]:          0 :                                 if (i==surface_list.size()-1 && j==surf_edge_list.size()-1 &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5359                 :            :                                         max_distance_for_edge < 0.000000000000001)
    5360                 :            :                                 {
    5361 [ #  # ][ #  # ]:          0 :                                         PRINT_ERROR( "The sweep distance is less than the geometry tolerance\n" );
         [ #  # ][ #  # ]
    5362 [ #  # ][ #  # ]:          0 :                                         PRINT_ERROR( "This may be caused by selecting the same\n");
         [ #  # ][ #  # ]
    5363 [ #  # ][ #  # ]:          0 :                                         PRINT_ERROR( "sweep surface and target surface\n" );
         [ #  # ][ #  # ]
    5364                 :          0 :                                         return CUBIT_FAILURE;
    5365                 :            :                                 }
    5366                 :            :                         }
    5367                 :            :                 }
    5368                 :            :                 //using the facet edges defined by the drawing geometry code; take the leading
    5369                 :            :                 //and trailing edge vectors of each facet edge;  With that, calc the dot product
    5370                 :            :                 //and if negative (meaning the vector directions switched) the curve travels
    5371                 :            :                 //through the plane and the sweep function will fail
    5372         [ #  # ]:          0 :                 surface_list.reset();
    5373         [ #  # ]:          0 :                 surf_edge_list.clean_out();
    5374 [ #  # ][ #  # ]:          0 :                 for (int kk=0;kk<surface_list.size();kk++)
    5375                 :            :                 {
    5376 [ #  # ][ #  # ]:          0 :                         surface_list[kk]->ref_edges(surf_edge_list);
    5377 [ #  # ][ #  # ]:          0 :                         for (int ii=0;ii<surf_edge_list.size();ii++)
    5378                 :            :                         {
    5379                 :            :                                 Curve *facet_curve;
    5380 [ #  # ][ #  # ]:          0 :                                 facet_curve=surf_edge_list[ii]->get_curve_ptr();
    5381                 :            :                                 CubitStatus response;
    5382         [ #  # ]:          0 :                                 GMem g_mem;
    5383                 :            : 
    5384                 :            :                                 //get number of points and their locations
    5385                 :            :                                 //on the curve as defined by the drawing geometry algorithm
    5386         [ #  # ]:          0 :                                 response = facet_curve->get_geometry_query_engine()->
    5387         [ #  # ]:          0 :                                         get_graphics( facet_curve, &g_mem );
    5388                 :            : 
    5389                 :          0 :         int num_points = g_mem.pointListCount;
    5390                 :            : 
    5391 [ #  # ][ #  # ]:          0 :                                 if (response==CUBIT_FAILURE || num_points == 0)
    5392                 :            :                                 {
    5393 [ #  # ][ #  # ]:          0 :                                         PRINT_WARNING("Unable to preview a curve\n" );
         [ #  # ][ #  # ]
    5394                 :            :                                 }
    5395                 :            : 
    5396         [ #  # ]:          0 :                                 GPoint *point_data = g_mem.point_list();
    5397                 :            : 
    5398 [ #  # ][ #  # ]:          0 :                                 for (int jj=0; jj < (num_points-1); jj++)
                 [ #  # ]
    5399                 :            :                                 {
    5400                 :            :                                         //get first points vectors
    5401         [ #  # ]:          0 :                                         CubitVector point_1;
    5402         [ #  # ]:          0 :                                         point_1.x(point_data[jj].x);
    5403         [ #  # ]:          0 :                                         point_1.y(point_data[jj].y);
    5404         [ #  # ]:          0 :                                         point_1.z(point_data[jj].z);
    5405                 :            :                                         //get second points vectors
    5406         [ #  # ]:          0 :                                         CubitVector point_2;
    5407         [ #  # ]:          0 :                                         point_2.x(point_data[jj+1].x);
    5408         [ #  # ]:          0 :                                         point_2.y(point_data[jj+1].y);
    5409         [ #  # ]:          0 :                                         point_2.z(point_data[jj+1].z);
    5410                 :            :                                         //project the two points onto target plane
    5411         [ #  # ]:          0 :                                         CubitVector target_point_1;
    5412 [ #  # ][ #  # ]:          0 :                                         target_point_1 = ref_plane.project(point_1);
    5413         [ #  # ]:          0 :                                         CubitVector target_point_2;
    5414 [ #  # ][ #  # ]:          0 :                                         target_point_2 = ref_plane.project(point_2);
    5415                 :            :                                         //calc vector from point on curve to point on surface
    5416         [ #  # ]:          0 :                                         CubitVector vec_1 = point_1 - target_point_1;
    5417         [ #  # ]:          0 :                                         CubitVector vec_2 = point_2 - target_point_2;
    5418                 :            :                                         //make them unit vectors
    5419         [ #  # ]:          0 :                                         vec_1.normalize();
    5420         [ #  # ]:          0 :                                         vec_2.normalize();
    5421                 :            :                                         //double dot = DotProduct(vec_1,vec_2);
    5422                 :            :                                         //calculate dot product
    5423 [ #  # ][ #  # ]:          0 :                                         double dot = vec_1.x()*vec_2.x()+vec_1.y()*vec_2.y()+vec_1.z()*vec_2.z();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5424                 :            : 
    5425                 :            :                                         //check to see if dot product sign is zero
    5426                 :            :                                         //the and statement checks for if the first or last vertex of the edge
    5427                 :            :                                         //which may be sitting on the surface, this is alright
    5428                 :            :                                         //and should still be able to sweep
    5429 [ #  # ][ #  # ]:          0 :                                         if (dot<0 && 0<jj && jj<(num_points-2))
                 [ #  # ]
    5430                 :            :                                         {
    5431 [ #  # ][ #  # ]:          0 :                                                 PRINT_ERROR( "The surface is traveling through the plane\n" );
         [ #  # ][ #  # ]
    5432 [ #  # ][ #  # ]:          0 :                                                 PRINT_ERROR( "and thus forces the sweep direction to switch\n" );
         [ #  # ][ #  # ]
    5433 [ #  # ][ #  # ]:          0 :                                                 PRINT_ERROR( "direction. Try splitting the surface.\n" );
         [ #  # ][ #  # ]
    5434                 :          0 :                                                 return CUBIT_FAILURE;
    5435                 :            :                                         }
    5436                 :            :                                 }
    5437                 :          0 :                         }
    5438                 :            :                 }
    5439                 :            : 
    5440         [ #  # ]:          0 :                 DLIList<Body*> body_list;
    5441 [ #  # ][ #  # ]:          0 :                 DLIList<GeometryEntity*> geom_list;
                 [ #  # ]
    5442                 :          0 :                 GeometryModifyEngine* gePtr1 = 0;
    5443                 :            :                 CubitBoolean change_newids;
    5444                 :            : 
    5445         [ #  # ]:          0 :                 if (!sweep_setup("translational", ref_ent_list, body_list, gePtr1,
    5446         [ #  # ]:          0 :                         change_newids, geom_list, false ))
    5447                 :          0 :                         return CUBIT_FAILURE;
    5448                 :            : 
    5449 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled())
    5450                 :            :       //Faces will get consumed so you have to save out original entities
    5451         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( surface_list );
    5452                 :            : 
    5453 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> sweep_result_list;
                 [ #  # ]
    5454                 :            : 
    5455                 :            :                 //below block is default settings to be fed into sweep_translational
    5456                 :          0 :                 CubitBoolean rigid = CUBIT_FALSE;
    5457                 :          0 :                 CubitBoolean switchside = CUBIT_FALSE;
    5458                 :          0 :                 int draft_type = 0;
    5459                 :          0 :                 double draft_angle=0.0;
    5460                 :            : 
    5461                 :            :                 //find normal vector to user specified plane
    5462 [ #  # ][ #  # ]:          0 :                 CubitVector vec1 = ref_plane.normal();
    5463         [ #  # ]:          0 :                 CubitVector vec2;
    5464         [ #  # ]:          0 :                 CubitVector vec3;
    5465                 :            :                 //get orthogonal vectors of the normal vector
    5466         [ #  # ]:          0 :                 vec1.orthogonal_vectors(vec2, vec3);
    5467                 :            :                 //place the orthogonal vectors at a point on the plane as opposed to the origin
    5468 [ #  # ][ #  # ]:          0 :                 vec2=vec2+target_mid_point;
    5469 [ #  # ][ #  # ]:          0 :                 vec3=vec3+target_mid_point;
    5470 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> webcut_results_list;
                 [ #  # ]
    5471                 :            :                 //get a point on the first user specified surface before it gets consumed in the sweep_translational function
    5472         [ #  # ]:          0 :                 CubitVector mid_point_surface;
    5473 [ #  # ][ #  # ]:          0 :                 mid_point_surface = surface_list[0]->center_point();
                 [ #  # ]
    5474                 :            : 
    5475                 :            :                 //sweep the curve down through and hopefully past the target surface
    5476                 :            :                 CubitStatus status = gePtr1->sweep_translational( geom_list,sweep_result_list,
    5477         [ #  # ]:          0 :                         max_result,draft_angle, draft_type,switchside,rigid,CUBIT_FALSE,CUBIT_FALSE);
    5478                 :            : 
    5479         [ #  # ]:          0 :                 if (status == 0)
    5480                 :            :                 {
    5481                 :            :                         //If in here, sweep_translational failed so delete result_list and
    5482                 :            :                         //print an error to the screen for the user
    5483 [ #  # ][ #  # ]:          0 :                         gePtr1->get_gqe()->delete_solid_model_entities(sweep_result_list);
    5484 [ #  # ][ #  # ]:          0 :                         PRINT_ERROR( "Error occured in the sweep operation.\n" );
         [ #  # ][ #  # ]
    5485                 :            : 
    5486 [ #  # ][ #  # ]:          0 :                         if( CubitUndo::get_undo_enabled())
    5487         [ #  # ]:          0 :                           CubitUndo::remove_last_undo();
    5488                 :          0 :                         return CUBIT_FAILURE;
    5489                 :            :                 }
    5490                 :            : 
    5491 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> neighbor_imprint_list;
                 [ #  # ]
    5492                 :            :                 //do a webcut with a plane created from the three projected points
    5493                 :            :                 CubitStatus status2 = gePtr1->webcut(sweep_result_list,target_mid_point,
    5494         [ #  # ]:          0 :                         vec2,vec3,neighbor_imprint_list, webcut_results_list);
    5495                 :            : 
    5496         [ #  # ]:          0 :                 if (status2 == 0)
    5497                 :            :                 {
    5498                 :            :                         //If in here, webcut operation failed so delete result_list and
    5499                 :            :                         //print an error to the screen for the user
    5500 [ #  # ][ #  # ]:          0 :                         gePtr1->get_gqe()->delete_solid_model_entities(sweep_result_list);
    5501 [ #  # ][ #  # ]:          0 :                         gePtr1->get_gqe()->delete_solid_model_entities(webcut_results_list);
    5502 [ #  # ][ #  # ]:          0 :                         PRINT_ERROR( "Error occured in the webcut operation.\n" );
         [ #  # ][ #  # ]
    5503                 :            : 
    5504 [ #  # ][ #  # ]:          0 :                         if( CubitUndo::get_undo_enabled())
    5505         [ #  # ]:          0 :                           CubitUndo::remove_last_undo();
    5506                 :          0 :                         return CUBIT_FAILURE;
    5507                 :            :                 }
    5508                 :            : 
    5509 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> keep_bodies_list = webcut_results_list;
                 [ #  # ]
    5510                 :          0 :                 int bodies_deleted_counter=0;
    5511         [ #  # ]:          0 :                 CubitVector target_mid_point_volume;
    5512         [ #  # ]:          0 :                 CubitVector mid_point_volume;
    5513         [ #  # ]:          0 :                 CubitVector target_mid_point_surface;
    5514                 :            :                 double volume_size;
    5515                 :            : 
    5516                 :            :                 //project the mid_point of user specified surface onto target plane
    5517 [ #  # ][ #  # ]:          0 :                 target_mid_point_surface = ref_plane.project(mid_point_surface);
    5518                 :            :                 //calculate vector between the two points and then normalize
    5519         [ #  # ]:          0 :                 CubitVector vec_1 = mid_point_surface - target_mid_point_surface;
    5520         [ #  # ]:          0 :                 vec_1.normalize();
    5521                 :            : 
    5522                 :            :                 //step through the
    5523 [ #  # ][ #  # ]:          0 :                 for (int counter=0;counter<webcut_results_list.size();counter++)
    5524                 :            :                 {
    5525                 :            :                         //find the geometric midpoint of the body and project that point on the target plane
    5526 [ #  # ][ #  # ]:          0 :                         webcut_results_list[counter]->mass_properties(mid_point_volume,volume_size);
    5527 [ #  # ][ #  # ]:          0 :                         target_mid_point_volume = ref_plane.project(mid_point_volume);
    5528                 :            :                         //generate a vector between the two points and then normalize
    5529         [ #  # ]:          0 :                         CubitVector vec_2 = mid_point_volume - target_mid_point_volume;
    5530         [ #  # ]:          0 :                         vec_2.normalize();
    5531                 :            : 
    5532                 :            :                         //calculate the dot product
    5533 [ #  # ][ #  # ]:          0 :                         double dot = vec_1.x()*vec_2.x()+vec_1.y()*vec_2.y()+vec_1.z()*vec_2.z();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5534                 :            : 
    5535                 :            :                         //if a negative dot product delete it because it is on the opposite side of the target plane
    5536         [ #  # ]:          0 :                         if (dot < 0)
    5537                 :            :                         {
    5538 [ #  # ][ #  # ]:          0 :                                 keep_bodies_list.remove(webcut_results_list[counter]);
    5539                 :          0 :                                 bodies_deleted_counter = bodies_deleted_counter + 1;
    5540                 :            :                         }
    5541                 :            : 
    5542                 :            :                 }
    5543                 :            : 
    5544                 :            :                 //test to see if all bodies have been deleted and if so let the user know
    5545 [ #  # ][ #  # ]:          0 :                 if (bodies_deleted_counter == webcut_results_list.size())
    5546                 :            :                 {
    5547 [ #  # ][ #  # ]:          0 :                         PRINT_ERROR( "All sweeped surfaces deleted - sweep_target failed.\n" );
         [ #  # ][ #  # ]
    5548 [ #  # ][ #  # ]:          0 :                         PRINT_ERROR( "This may be due to granite engine limitations and/or\n" );
         [ #  # ][ #  # ]
    5549 [ #  # ][ #  # ]:          0 :                         PRINT_ERROR( "angle between curve and target surface\n" );
         [ #  # ][ #  # ]
    5550                 :            : 
    5551 [ #  # ][ #  # ]:          0 :                         if( CubitUndo::get_undo_enabled())
    5552         [ #  # ]:          0 :                           CubitUndo::remove_last_undo();
    5553                 :          0 :                         return CUBIT_FAILURE;
    5554                 :            :                 }
    5555                 :            : 
    5556                 :            :                 //delete webcut_results_list since it is no longer of use
    5557         [ #  # ]:          0 :                 webcut_results_list -= keep_bodies_list;
    5558 [ #  # ][ #  # ]:          0 :                 gePtr1->get_gqe()->delete_solid_model_entities(webcut_results_list);
    5559                 :            : 
    5560                 :            :                 //builds ref bodies
    5561 [ #  # ][ #  # ]:          0 :     DLIList<Body*> output_body_list;
         [ #  # ][ #  # ]
    5562 [ #  # ][ #  # ]:          0 :                 if (!sweep_finish("translational", body_list, keep_bodies_list, output_body_list, change_newids))
    5563                 :          0 :                         status = CUBIT_FAILURE;
    5564                 :            : 
    5565 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled())
    5566                 :            :     {
    5567         [ #  # ]:          0 :       if( status == CUBIT_FAILURE )
    5568         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
    5569                 :            :       else
    5570         [ #  # ]:          0 :         CubitUndo::note_result_bodies( output_body_list );
    5571                 :          0 :     }
    5572                 :            : 
    5573                 :            :         }
    5574         [ #  # ]:          0 :         return CUBIT_SUCCESS;
    5575                 :            : }
    5576                 :            : 
    5577                 :            : 
    5578                 :          0 : CubitStatus GeometryModifyTool::sweep_perpendicular( DLIList<RefEntity*>& ref_ent_list,
    5579                 :            :                                                      double distance,
    5580                 :            :                                                      double draft_angle,
    5581                 :            :                                                      int draft_type,
    5582                 :            :                                                      CubitBoolean switchside,
    5583                 :            :                                                      CubitBoolean rigid,
    5584                 :            :                                                      CubitBoolean anchor_entity,
    5585                 :            :                                                      CubitBoolean keep_old,
    5586                 :            :                                                      DLIList<Body*>& output_body_list)
    5587                 :            : {
    5588         [ #  # ]:          0 :   DLIList<Body*> body_list;
    5589 [ #  # ][ #  # ]:          0 :   DLIList<GeometryEntity*> geom_list;
    5590                 :          0 :   GeometryModifyEngine* gePtr1 = 0;
    5591                 :            :   CubitBoolean change_newids;
    5592         [ #  # ]:          0 :   if (!sweep_setup("translational", ref_ent_list, body_list, gePtr1,
    5593         [ #  # ]:          0 :                    change_newids, geom_list, keep_old))
    5594                 :          0 :     return CUBIT_FAILURE;
    5595                 :            : 
    5596 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    5597                 :            :   {
    5598         [ #  # ]:          0 :     DLIList<RefEdge*> edge_list;
    5599 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> face_list;
    5600                 :            : 
    5601 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, edge_list, RefEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5602 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, face_list, RefFace );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5603                 :            : 
    5604                 :            :     //Edges aren't consumed, so there's nothing to save out
    5605 [ #  # ][ #  # ]:          0 :     if( edge_list.size() || keep_old )
         [ #  # ][ #  # ]
    5606         [ #  # ]:          0 :       CubitUndo::save_state();
    5607                 :            :     else
    5608                 :            :      //Faces will get consumed so you have to save out original entities
    5609 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( face_list );
    5610                 :            :   }
    5611                 :            : 
    5612 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> result_list;
    5613                 :            :   CubitStatus status = gePtr1->
    5614                 :            :     sweep_perpendicular( geom_list,
    5615                 :            :                          result_list,
    5616                 :            :                          distance,
    5617                 :            :                          draft_angle,
    5618                 :            :                          draft_type,
    5619                 :            :                          switchside,
    5620                 :            :                          rigid,
    5621                 :            :                          anchor_entity,
    5622         [ #  # ]:          0 :                          keep_old );
    5623                 :            : 
    5624         [ #  # ]:          0 :   if( keep_old )
    5625         [ #  # ]:          0 :     body_list.clean_out();
    5626                 :            : 
    5627 [ #  # ][ #  # ]:          0 :   if (!sweep_finish("perpendicular", body_list, result_list, output_body_list, change_newids))
    5628                 :          0 :     status = CUBIT_FAILURE;
    5629                 :            : 
    5630 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    5631                 :            :   {
    5632         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
    5633         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    5634                 :            :     else
    5635         [ #  # ]:          0 :       CubitUndo::note_result_bodies( output_body_list );
    5636                 :            :   }
    5637                 :            : 
    5638         [ #  # ]:          0 :   return status;
    5639                 :            : }
    5640                 :          0 : CubitStatus GeometryModifyTool::sweep_along_curve(DLIList<RefEntity*>& ref_ent_list,
    5641                 :            :                                                   DLIList<RefEdge*>& ref_edge_list,
    5642                 :            :                                                   DLIList<Body*>& output_body_list,
    5643                 :            :                                                   CubitBoolean anchor_entity,
    5644                 :            :                                                   CubitBoolean keep_old,
    5645                 :            :                                                   double draft_angle,
    5646                 :            :                                                   int draft_type,
    5647                 :            :                                                   CubitBoolean rigid)
    5648                 :            : 
    5649                 :            : {
    5650 [ #  # ][ #  # ]:          0 :   DLIList<GeometryEntity*> geom_list(ref_ent_list.size());
    5651 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
                 [ #  # ]
    5652 [ #  # ][ #  # ]:          0 :   DLIList<Body*> body_list(ref_ent_list.size());
                 [ #  # ]
    5653                 :          0 :   GeometryModifyEngine* engine_ptr = 0;
    5654                 :          0 :   CubitBoolean changed_new_ids = CUBIT_FALSE;
    5655                 :            :   CubitStatus status = sweep_setup( "along_curve",
    5656                 :            :                                     ref_ent_list,
    5657                 :            :                                     body_list,
    5658                 :            :                                     engine_ptr,
    5659                 :            :                                     changed_new_ids,
    5660                 :            :                                     geom_list,
    5661                 :            :                                     keep_old,
    5662                 :            :                                     &ref_edge_list,
    5663         [ #  # ]:          0 :                                     &curve_list );
    5664         [ #  # ]:          0 :   if (status != CUBIT_SUCCESS)
    5665                 :          0 :   return status;
    5666                 :            : 
    5667 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    5668                 :            :   {
    5669         [ #  # ]:          0 :     DLIList<RefEdge*> edge_list;
    5670 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> face_list;
    5671                 :            : 
    5672 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, edge_list, RefEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5673 [ #  # ][ #  # ]:          0 :     CAST_LIST( ref_ent_list, face_list, RefFace );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5674                 :            : 
    5675                 :            :     //Edges aren't consumed, so there's nothing to save out
    5676         [ #  # ]:          0 :     if( keep_old )
    5677         [ #  # ]:          0 :       CubitUndo::save_state();
    5678                 :            :     else
    5679                 :            :     {
    5680                 :          0 :       bool free_curves = false;
    5681 [ #  # ][ #  # ]:          0 :       for( int i=edge_list.size(); i--; )
    5682                 :            :       {
    5683 [ #  # ][ #  # ]:          0 :         if( edge_list.get_and_step()->num_parent_ref_entities() == 0 )
                 [ #  # ]
    5684                 :            :         {
    5685                 :          0 :           free_curves = true;
    5686                 :          0 :           break;
    5687                 :            :         }
    5688                 :            :       }
    5689                 :            : 
    5690         [ #  # ]:          0 :       DLIList<Body*> bodies_to_save;
    5691 [ #  # ][ #  # ]:          0 :       DLIList<RefEntity*> free_surfaces;
    5692 [ #  # ][ #  # ]:          0 :       for( int i=face_list.size(); i--; )
    5693                 :            :       {
    5694         [ #  # ]:          0 :         RefFace *ref_face = face_list.get_and_step();
    5695                 :            : 
    5696 [ #  # ][ #  # ]:          0 :         if( ref_face->num_parent_ref_entities() == 0 )
    5697 [ #  # ][ #  # ]:          0 :           free_surfaces.append( ref_face );
    5698                 :            :         else
    5699 [ #  # ][ #  # ]:          0 :           bodies_to_save.append_unique( ref_face->ref_volume()->body() );
                 [ #  # ]
    5700                 :            :       }
    5701                 :            :       //Faces will get consumed so you have to save out original entities
    5702 [ #  # ][ #  # ]:          0 :       if( bodies_to_save.size() || free_surfaces.size() )
         [ #  # ][ #  # ]
                 [ #  # ]
    5703         [ #  # ]:          0 :         CubitUndo::save_state_with_cubit_file( bodies_to_save, &free_surfaces );
    5704         [ #  # ]:          0 :       else if(free_curves )
    5705         [ #  # ]:          0 :         CubitUndo::save_state_with_cubit_file( edge_list );
    5706                 :            :       else
    5707 [ #  # ][ #  # ]:          0 :         CubitUndo::save_state();
    5708         [ #  # ]:          0 :     }
    5709                 :            :   }
    5710                 :            : 
    5711 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> result_list;
    5712                 :            :   status = engine_ptr->sweep_along_curve( geom_list,
    5713                 :            :                                           result_list,
    5714                 :            :                                           curve_list,
    5715                 :            :                                           draft_angle,
    5716                 :            :                                           draft_type,
    5717                 :            :                                           rigid,
    5718                 :            :                                           anchor_entity,
    5719         [ #  # ]:          0 :                                           keep_old);
    5720                 :            : 
    5721         [ #  # ]:          0 :   if( keep_old )
    5722         [ #  # ]:          0 :     body_list.clean_out();
    5723                 :            : 
    5724 [ #  # ][ #  # ]:          0 :   if (!sweep_finish("along_curve", body_list, result_list, output_body_list, changed_new_ids))
    5725                 :          0 :   status = CUBIT_FAILURE;
    5726                 :            : 
    5727 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled())
    5728                 :            :   {
    5729         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
    5730         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    5731                 :            :     else
    5732         [ #  # ]:          0 :       CubitUndo::note_result_bodies( output_body_list );
    5733                 :            :   }
    5734                 :            : 
    5735         [ #  # ]:          0 :   return status;
    5736                 :            : }
    5737                 :            : 
    5738                 :        874 : void GeometryModifyTool::initialize_settings() {
    5739                 :            : 
    5740                 :            : 
    5741                 :            :   SettingHandler::instance()->add_setting("Group Imprint",
    5742                 :            :                                           GeometryModifyTool::set_group_imprint,
    5743                 :        874 :                                           GeometryModifyTool::get_group_imprint);
    5744                 :            : 
    5745                 :            :   SettingHandler::instance()->add_setting("NonRegImprint",
    5746                 :            :                                           GeometryModifyTool::set_all_edges_imprint,
    5747                 :        874 :                                           GeometryModifyTool::get_all_edges_imprint);
    5748                 :            : 
    5749                 :            :   SettingHandler::instance()->add_setting("New Ids",
    5750                 :            :                                           GeometryModifyTool::set_new_ids,
    5751                 :        874 :                                           GeometryModifyTool::get_new_ids);
    5752                 :            : 
    5753                 :            :   SettingHandler::instance()->add_setting("Separate After Webcut",
    5754                 :            :                                           GeometryModifyTool::set_sep_after_webcut_setting,
    5755                 :        874 :                                           GeometryModifyTool::get_sep_after_webcut_setting);
    5756                 :            : 
    5757                 :            :   SettingHandler::instance()->add_setting("old names",
    5758                 :            :             GeometryModifyTool::set_old_names,
    5759                 :        874 :             GeometryModifyTool::get_old_names);
    5760                 :        874 : }
    5761                 :            : 
    5762                 :            : 
    5763                 :            : 
    5764                 :            : // ********** END PUBLIC FUNCTIONS         **********
    5765                 :            : 
    5766                 :            : // ********** BEGIN PROTECTED FUNCTIONS    **********
    5767                 :            : 
    5768                 :            : //-------------------------------------------------------------------------
    5769                 :            : // Purpose       : Constructor of the GeometryModifyTool class.
    5770                 :            : //
    5771                 :            : // Special Notes :
    5772                 :            : //
    5773                 :            : // Creator       : Xuechen Liu
    5774                 :            : //
    5775                 :            : // Creation Date : 07/11/96
    5776                 :            : //-------------------------------------------------------------------------
    5777                 :       1748 : GeometryModifyTool::GeometryModifyTool(GeometryModifyEngine*gme_ptr)
    5778                 :            : {
    5779 [ -  + ][ #  # ]:        874 :   if (gme_ptr) gmeList.append(gme_ptr);
    5780                 :        874 : }
    5781                 :            : 
    5782                 :            : //-------------------------------------------------------------------------
    5783                 :            : // Purpose       : This functions webcuts a list of bodies through a plane.
    5784                 :            : //                 The newly created bodies are and merged depeding on the
    5785                 :            : //                 respective flags.
    5786                 :            : //
    5787                 :            : // Special Notes :
    5788                 :            : //
    5789                 :            : // Creator       : Raikanta Sahu
    5790                 :            : //
    5791                 :            : // Creation Date : 12/17/96
    5792                 :            : //-------------------------------------------------------------------------
    5793                 :            : 
    5794                 :          0 : CubitStatus GeometryModifyTool::webcut_with_brick(
    5795                 :            :                                            DLIList<Body*>& webcut_body_list,
    5796                 :            :                                            const CubitVector &center,
    5797                 :            :                                            const CubitVector axes[3],
    5798                 :            :                                            const CubitVector &extension,
    5799                 :            :                                            DLIList<Body*> &results_list,
    5800                 :            :                                            DLIList<Body*> &neighboring_bodies,
    5801                 :            :                                            ImprintType imprint_type,
    5802                 :            :                                            CubitBoolean merge,
    5803                 :            :                                            CubitBoolean preview)
    5804                 :            : {
    5805                 :            :    // Make sure that entity creation is possible.  Allow at most
    5806                 :            :    // only one of the dimensions to be zero - in which case a planar
    5807                 :            :    // sheet is used to do the cutting.
    5808         [ #  # ]:          0 :    double width = 2.0*extension.x();
    5809         [ #  # ]:          0 :    double height = 2.0*extension.y();
    5810         [ #  # ]:          0 :    double depth = 2.0*extension.z();
    5811 [ #  # ][ #  # ]:          0 :    if ( width < 0.0 || height < 0.0 || depth < 0.0 )
                 [ #  # ]
    5812                 :            :    {
    5813 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Cannot make a brick of size %f x %f x %f\n"
                 [ #  # ]
    5814                 :            :                    "     Negative dimensions are not allowed.\n",
    5815         [ #  # ]:          0 :                    width, height, depth );
    5816                 :          0 :       return CUBIT_FAILURE ;
    5817                 :            :    }
    5818                 :            : 
    5819                 :          0 :    BodySM *cutting_tool_ptr = NULL;
    5820                 :          0 :    CubitBoolean is_sheet_body = CUBIT_FALSE;
    5821 [ #  # ][ #  # ]:          0 :    CubitVector p1, p2, p3, p4;
         [ #  # ][ #  # ]
    5822                 :          0 :    int wz = width < GEOMETRY_RESABS;
    5823                 :          0 :    int hz = height < GEOMETRY_RESABS;
    5824                 :          0 :    int dz = depth < GEOMETRY_RESABS;
    5825                 :          0 :    int num_zero_dim = wz + hz + dz;
    5826         [ #  # ]:          0 :    if( num_zero_dim > 0 )
    5827                 :            :    {
    5828         [ #  # ]:          0 :       if( num_zero_dim > 1 )
    5829                 :            :       {
    5830 [ #  # ][ #  # ]:          0 :          PRINT_ERROR( "Cannot make a sheet of size %f x %f x %f\n"
                 [ #  # ]
    5831                 :            :             "     At least two dimensions must be nonzero.\n",
    5832         [ #  # ]:          0 :             width, height, depth );
    5833                 :          0 :          return CUBIT_FAILURE ;
    5834                 :            :       }
    5835                 :            : 
    5836                 :            :       // Make a sheet body instead of a cuboid
    5837 [ #  # ][ #  # ]:          0 :       CubitVector sheet_axes[2];
    5838         [ #  # ]:          0 :       if( wz )
    5839                 :            :       {
    5840         [ #  # ]:          0 :          sheet_axes[0] = axes[1];
    5841         [ #  # ]:          0 :          sheet_axes[1] = axes[2];
    5842                 :          0 :          width = depth;
    5843                 :            :       }
    5844         [ #  # ]:          0 :       else if( hz )
    5845                 :            :       {
    5846         [ #  # ]:          0 :          sheet_axes[0] = axes[2];
    5847         [ #  # ]:          0 :          sheet_axes[1] = axes[0];
    5848                 :          0 :          height = depth;
    5849                 :            :       }
    5850                 :            :       else
    5851                 :            :       {
    5852         [ #  # ]:          0 :          sheet_axes[0] = axes[0];
    5853         [ #  # ]:          0 :          sheet_axes[1] = axes[1];
    5854                 :            :       }
    5855                 :            : 
    5856                 :            :       // Get the corners of the sheet ready
    5857         [ #  # ]:          0 :       center.next_point( axes[0], width/2.0, p1 );
    5858         [ #  # ]:          0 :       p1.next_point( axes[1], -height/2.0, p1 );
    5859         [ #  # ]:          0 :       p1.next_point( axes[1], height, p2 );
    5860         [ #  # ]:          0 :       p2.next_point( axes[0], -width, p3 );
    5861         [ #  # ]:          0 :       p3.next_point( axes[1], -height, p4 );
    5862                 :            :    }
    5863                 :            : 
    5864 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    5865                 :          0 :      return CUBIT_FAILURE;
    5866                 :            : 
    5867 [ #  # ][ #  # ]:          0 :    CubitVector tmp_vec( center.x()+width, center.y()+height, center.z()+depth );
         [ #  # ][ #  # ]
    5868         [ #  # ]:          0 :    CubitBox tmp_box(tmp_vec);
    5869 [ #  # ][ #  # ]:          0 :    tmp_vec.set( center.x()-width, center.y()-height, center.z()-depth );
         [ #  # ][ #  # ]
    5870         [ #  # ]:          0 :    tmp_box |= tmp_vec;
    5871         [ #  # ]:          0 :    remove_bodies_outside_bounding_box( webcut_body_list, tmp_box );
    5872                 :            : 
    5873 [ #  # ][ #  # ]:          0 :    if( webcut_body_list.size() == 0 )
    5874                 :            :    {
    5875 [ #  # ][ #  # ]:          0 :      PRINT_INFO("Tool does not intersect any bodies/volumes.\n");
         [ #  # ][ #  # ]
    5876                 :          0 :      return CUBIT_FAILURE;
    5877                 :            :    }
    5878                 :            : 
    5879 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    5880                 :            :    {
    5881         [ #  # ]:          0 :      DLIList<Body*> bodies_to_save;
    5882         [ #  # ]:          0 :      bodies_to_save += webcut_body_list;
    5883         [ #  # ]:          0 :      bodies_to_save += neighboring_bodies;
    5884 [ #  # ][ #  # ]:          0 :      CubitUndo::save_state_with_cubit_file( bodies_to_save );
    5885                 :            :    }
    5886                 :            : 
    5887                 :          0 :    CubitStatus rval = CUBIT_SUCCESS;
    5888                 :            : 
    5889         [ #  # ]:          0 :    const int count = webcut_body_list.size();
    5890 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> result_sm_list;
    5891 [ #  # ][ #  # ]:          0 :    DLIList<Body*> body_list(webcut_body_list);
    5892 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> engine_body_sms(count);
    5893 [ #  # ][ #  # ]:          0 :    DLIList<Body*> engine_bodies(count);
    5894                 :          0 :    GeometryModifyEngine* gme = 0;
    5895                 :            : 
    5896 [ #  # ][ #  # ]:          0 :    while ( (gme = group_bodies_by_engine(body_list, engine_bodies, engine_body_sms)) )
    5897                 :            :    {
    5898         [ #  # ]:          0 :      DLIList<int> merged_surface_ids;
    5899 [ #  # ][ #  # ]:          0 :      DLIList<int> merged_curve_ids;
              [ #  #  # ]
    5900 [ #  # ][ #  # ]:          0 :      DLIList<BodySM*> neighbor_imprint_list;
              [ #  #  # ]
    5901         [ #  # ]:          0 :      if (!preview)
    5902                 :            :      {
    5903                 :            :        int i;
    5904 [ #  # ][ #  # ]:          0 :        for( i=neighboring_bodies.size(); i--; )
    5905                 :            :        {
    5906         [ #  # ]:          0 :          Body *neighbor_body = neighboring_bodies.get_and_step();
    5907         [ #  # ]:          0 :          BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    5908         [ #  # ]:          0 :          GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    5909                 :            : 
    5910         [ #  # ]:          0 :          if( gme == neighbor_gme )
    5911                 :            :          {
    5912         [ #  # ]:          0 :            neighbor_imprint_list.append( tmp_body );
    5913         [ #  # ]:          0 :            engine_bodies.append( neighbor_body );
    5914                 :            :          }
    5915                 :            :        }
    5916                 :            : 
    5917         [ #  # ]:          0 :        do_attribute_setup();
    5918         [ #  # ]:          0 :        DLIList<BodySM*> bodies_to_modify;
    5919         [ #  # ]:          0 :        bodies_to_modify += engine_body_sms;
    5920         [ #  # ]:          0 :        bodies_to_modify += neighbor_imprint_list;
    5921         [ #  # ]:          0 :        push_attributes_before_modify( bodies_to_modify );
    5922 [ #  # ][ #  # ]:          0 :        get_merged_curve_and_surface_ids( engine_bodies, merged_surface_ids, merged_curve_ids );
    5923                 :            :      }
    5924                 :            : 
    5925                 :            :      // Create the brick to cut with
    5926         [ #  # ]:          0 :     if (is_sheet_body)
    5927         [ #  # ]:          0 :       cutting_tool_ptr = gme->planar_sheet(p1,p2,p3,p4);
    5928                 :            :     else
    5929         [ #  # ]:          0 :       cutting_tool_ptr = gme->brick( center, axes, extension );
    5930         [ #  # ]:          0 :     if( cutting_tool_ptr == NULL )
    5931                 :          0 :        return CUBIT_FAILURE;
    5932                 :            : 
    5933                 :            :     CubitStatus status = gme->webcut (
    5934                 :            :       engine_body_sms, cutting_tool_ptr,
    5935                 :            :       neighbor_imprint_list,
    5936         [ #  # ]:          0 :       result_sm_list, imprint_type, preview );
    5937                 :            : 
    5938                 :            :     // Delete the BodySM that was created to be used as a tool
    5939 [ #  # ][ #  # ]:          0 :     gme->get_gqe()->delete_solid_model_entities(cutting_tool_ptr) ;
    5940                 :            : 
    5941                 :            :       // just continue the loop if previewing
    5942         [ #  # ]:          0 :       if (preview)
    5943                 :            :       {
    5944                 :          0 :         rval = status;
    5945                 :          0 :         continue;
    5946                 :            :       }
    5947                 :            : 
    5948         [ #  # ]:          0 :       restore_vg_after_modify(result_sm_list, engine_bodies, gme);
    5949         [ #  # ]:          0 :       remove_pushed_attributes(result_sm_list, engine_bodies);
    5950                 :            : 
    5951                 :            :       status = finish_webcut( engine_bodies, result_sm_list, merge, status, results_list,
    5952         [ #  # ]:          0 :                               &merged_surface_ids, &merged_curve_ids );
    5953                 :            : 
    5954         [ #  # ]:          0 :       if (!status)
    5955                 :          0 :         rval = CUBIT_FAILURE;
    5956                 :            : 
    5957         [ #  # ]:          0 :       engine_bodies.clean_out();
    5958         [ #  # ]:          0 :       engine_body_sms.clean_out();
    5959 [ #  # ][ #  # ]:          0 :       result_sm_list.clean_out();
              [ #  #  # ]
    5960                 :          0 :    }
    5961                 :            : 
    5962         [ #  # ]:          0 :    if (!preview)
    5963         [ #  # ]:          0 :      do_attribute_cleanup();
    5964                 :            : 
    5965 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
    5966                 :            :    {
    5967 [ #  # ][ #  # ]:          0 :      if( results_list.size() ) //if there are new bodies...something succeeded
    5968         [ #  # ]:          0 :        CubitUndo::note_result_bodies( results_list );
    5969                 :            :      else
    5970         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    5971                 :            :    }
    5972                 :            : 
    5973         [ #  # ]:          0 :    return rval;
    5974                 :            : }
    5975                 :            : 
    5976                 :          0 : CubitStatus GeometryModifyTool::webcut_with_planar_sheet(
    5977                 :            :                                            DLIList<Body*>& webcut_body_list,
    5978                 :            :                                            const CubitVector &center,
    5979                 :            :                                            const CubitVector axes[2],
    5980                 :            :                                            double width, double height,
    5981                 :            :                                            DLIList<Body*> &results_list,
    5982                 :            :                                            DLIList<Body*> &neighboring_bodies,
    5983                 :            :                                            ImprintType imprint_type,
    5984                 :            :                                            CubitBoolean merge,
    5985                 :            :                                            CubitBoolean preview)
    5986                 :            : {
    5987 [ #  # ][ #  # ]:          0 :    if ( width <= GEOMETRY_RESABS || height <= GEOMETRY_RESABS )
    5988                 :            :    {
    5989 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Cannot webcut with a sheet of size %f x %f\n"
                 [ #  # ]
    5990                 :            :                    "     Negative or zero dimensions are not allowed.\n",
    5991         [ #  # ]:          0 :                    width, height );
    5992                 :          0 :       return CUBIT_FAILURE ;
    5993                 :            :    }
    5994                 :            : 
    5995 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    5996                 :          0 :      return CUBIT_FAILURE;
    5997                 :            : 
    5998                 :          0 :    CubitStatus rval = CUBIT_SUCCESS;
    5999                 :            : 
    6000 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    6001                 :            :   {
    6002         [ #  # ]:          0 :     DLIList<Body*> bodies_to_save;
    6003         [ #  # ]:          0 :     bodies_to_save += webcut_body_list;
    6004         [ #  # ]:          0 :     bodies_to_save += neighboring_bodies;
    6005 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies_to_save );
    6006                 :            :   }
    6007                 :            : 
    6008         [ #  # ]:          0 :    const int count = webcut_body_list.size();
    6009         [ #  # ]:          0 :    DLIList<BodySM*> result_sm_list;
    6010 [ #  # ][ #  # ]:          0 :    DLIList<Body*> body_list(webcut_body_list);
    6011 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> engine_body_sms(count);
    6012 [ #  # ][ #  # ]:          0 :    DLIList<Body*> engine_bodies(count);
    6013                 :          0 :    GeometryModifyEngine* gme = 0;
    6014                 :            : 
    6015 [ #  # ][ #  # ]:          0 :    while ( (gme = group_bodies_by_engine(body_list, engine_bodies, engine_body_sms)) )
    6016                 :            :    {
    6017         [ #  # ]:          0 :      DLIList<int> merged_surface_ids;
    6018 [ #  # ][ #  # ]:          0 :      DLIList<int> merged_curve_ids;
              [ #  #  # ]
    6019 [ #  # ][ #  # ]:          0 :      DLIList<BodySM*> neighbor_imprint_list;
              [ #  #  # ]
    6020         [ #  # ]:          0 :      if (!preview)
    6021                 :            :      {
    6022                 :            :        int i;
    6023 [ #  # ][ #  # ]:          0 :        for( i=neighboring_bodies.size(); i--; )
    6024                 :            :        {
    6025         [ #  # ]:          0 :          Body *neighbor_body = neighboring_bodies.get_and_step();
    6026         [ #  # ]:          0 :          BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    6027         [ #  # ]:          0 :          GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    6028                 :            : 
    6029         [ #  # ]:          0 :          if( gme == neighbor_gme )
    6030                 :            :          {
    6031         [ #  # ]:          0 :            neighbor_imprint_list.append( tmp_body );
    6032         [ #  # ]:          0 :            engine_bodies.append( neighbor_body );
    6033                 :            :          }
    6034                 :            :        }
    6035                 :            : 
    6036         [ #  # ]:          0 :        do_attribute_setup();
    6037         [ #  # ]:          0 :        DLIList<BodySM*> bodies_sms_to_modify;
    6038         [ #  # ]:          0 :        bodies_sms_to_modify += engine_body_sms;
    6039         [ #  # ]:          0 :        bodies_sms_to_modify += neighbor_imprint_list;
    6040         [ #  # ]:          0 :        push_attributes_before_modify( bodies_sms_to_modify );
    6041 [ #  # ][ #  # ]:          0 :        get_merged_curve_and_surface_ids( engine_bodies, merged_surface_ids, merged_curve_ids );
    6042                 :            :      }
    6043                 :            : 
    6044                 :            :      // Create the planar sheet to cut with
    6045 [ #  # ][ #  # ]:          0 :      CubitVector p1, p2, p3, p4;
         [ #  # ][ #  # ]
    6046                 :            : 
    6047                 :            :      // Get the corners of the sheet
    6048         [ #  # ]:          0 :      center.next_point( axes[0], width/2.0, p1 );
    6049         [ #  # ]:          0 :      p1.next_point( axes[1], -height/2.0, p1 );
    6050         [ #  # ]:          0 :      p1.next_point( axes[1], height, p2 );
    6051         [ #  # ]:          0 :      p2.next_point( axes[0], -width, p3 );
    6052         [ #  # ]:          0 :      p3.next_point( axes[1], -height, p4 );
    6053                 :            : 
    6054         [ #  # ]:          0 :      BodySM *cutting_tool_ptr = gme->planar_sheet(p1,p2,p3,p4);
    6055         [ #  # ]:          0 :      if( cutting_tool_ptr == NULL )
    6056                 :          0 :         return CUBIT_FAILURE;
    6057                 :            : 
    6058                 :            :      CubitStatus status = gme->webcut (
    6059                 :            :        engine_body_sms, cutting_tool_ptr,
    6060                 :            :        neighbor_imprint_list,
    6061         [ #  # ]:          0 :        result_sm_list, imprint_type, preview );
    6062                 :            : 
    6063                 :            :      // Delete the BodySM that was created to be used as a tool
    6064 [ #  # ][ #  # ]:          0 :      gme->get_gqe()->delete_solid_model_entities(cutting_tool_ptr) ;
    6065                 :            : 
    6066                 :            :       // just continue the loop if previewing
    6067         [ #  # ]:          0 :       if (preview)
    6068                 :            :       {
    6069                 :          0 :         rval = status;
    6070                 :          0 :         continue;
    6071                 :            :       }
    6072                 :            : 
    6073         [ #  # ]:          0 :       restore_vg_after_modify(result_sm_list, engine_bodies, gme);
    6074         [ #  # ]:          0 :       remove_pushed_attributes(result_sm_list, engine_bodies);
    6075                 :            : 
    6076                 :            :       status = finish_webcut( engine_bodies, result_sm_list, merge, status, results_list,
    6077         [ #  # ]:          0 :                               &merged_surface_ids, &merged_curve_ids );
    6078         [ #  # ]:          0 :       if (!status)
    6079                 :          0 :         rval = CUBIT_FAILURE;
    6080                 :            : 
    6081         [ #  # ]:          0 :       engine_bodies.clean_out();
    6082         [ #  # ]:          0 :       engine_body_sms.clean_out();
    6083 [ #  # ][ #  # ]:          0 :       result_sm_list.clean_out();
              [ #  #  # ]
    6084                 :          0 :    }
    6085                 :            : 
    6086         [ #  # ]:          0 :    if (!preview)
    6087         [ #  # ]:          0 :      do_attribute_cleanup();
    6088                 :            : 
    6089 [ #  # ][ #  # ]:          0 :   if( preview == CUBIT_FALSE && CubitUndo::get_undo_enabled() )
         [ #  # ][ #  # ]
    6090                 :            :   {
    6091         [ #  # ]:          0 :     if( rval == CUBIT_SUCCESS )
    6092         [ #  # ]:          0 :       CubitUndo::note_result_bodies( results_list );
    6093                 :            :     else
    6094         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    6095                 :            :   }
    6096                 :            : 
    6097         [ #  # ]:          0 :    return rval;
    6098                 :            : }
    6099                 :            : 
    6100                 :         11 : CubitStatus GeometryModifyTool::webcut_with_plane(
    6101                 :            :                                     DLIList<Body*>& webcut_body_list,
    6102                 :            :                                     const CubitVector &vector1,
    6103                 :            :                                     const CubitVector &vector2,
    6104                 :            :                                     const CubitVector &vector3,
    6105                 :            :                                     DLIList<Body*>& results_list,
    6106                 :            :                                     DLIList<Body*> &neighboring_bodies,
    6107                 :            :                                     ImprintType imprint_type,
    6108                 :            :                                     CubitBoolean merge,
    6109                 :            :                                     CubitBoolean preview)
    6110                 :            : {
    6111 [ +  - ][ -  + ]:         11 :   if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    6112                 :          0 :     return CUBIT_FAILURE;
    6113                 :            : 
    6114         [ +  - ]:         11 :   GfxPreview::clear();
    6115                 :            : 
    6116                 :         11 :   CubitStatus rval = CUBIT_SUCCESS;
    6117         [ -  + ]:         11 :   if (preview)
    6118                 :            :   {
    6119         [ #  # ]:          0 :     GeometryModifyTool::plane_preview(webcut_body_list, vector1, vector2, vector3);
    6120                 :          0 :     return rval;
    6121                 :            :   }
    6122                 :            : 
    6123                 :            :   //remove bodies that won't intersect plane bounding box
    6124 [ +  - ][ +  - ]:         11 :   remove_bodies_outside_bounding_box( webcut_body_list, vector1, vector2, vector3 );
         [ +  - ][ +  - ]
    6125                 :            : 
    6126 [ +  - ][ -  + ]:         11 :   if( webcut_body_list.size() == 0 )
    6127                 :            :   {
    6128 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Tool does not intersect any bodies/volumes.\n");
         [ #  # ][ #  # ]
    6129                 :          0 :     return CUBIT_FAILURE;
    6130                 :            :   }
    6131                 :            : 
    6132 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ -  + ]
    6133                 :            :   {
    6134         [ #  # ]:          0 :     DLIList<Body*> bodies_to_save;
    6135         [ #  # ]:          0 :     bodies_to_save += webcut_body_list;
    6136         [ #  # ]:          0 :     bodies_to_save += neighboring_bodies;
    6137 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies_to_save );
    6138                 :            :   }
    6139                 :            : 
    6140         [ +  - ]:         11 :   const int count = webcut_body_list.size();
    6141 [ +  - ][ +  - ]:         11 :   DLIList<BodySM*> temp_sm_list(webcut_body_list.size());
    6142 [ +  - ][ +  - ]:         22 :   DLIList<BodySM*> result_sm_list;
    6143 [ +  - ][ +  - ]:         22 :   DLIList<Body*> body_list(webcut_body_list);
    6144 [ +  - ][ +  - ]:         22 :   DLIList<BodySM*> engine_body_sms(count);
    6145 [ +  - ][ +  - ]:         22 :   DLIList<Body*> engine_bodies(count);
    6146                 :         11 :   GeometryModifyEngine* gme = 0;
    6147                 :            : 
    6148                 :            :   // all preview stuff handled before this point
    6149         [ +  - ]:         11 :   if(!preview)
    6150         [ +  - ]:         11 :     do_attribute_setup();
    6151                 :            : 
    6152 [ +  - ][ +  + ]:         22 :   while ( (gme = group_bodies_by_engine(body_list, engine_bodies, engine_body_sms)) )
    6153                 :            :   {
    6154                 :            : 
    6155                 :            :     //get all the child entities that have been merged
    6156         [ +  - ]:         11 :     DLIList<int> merged_surface_ids;
    6157 [ +  - ][ +  - ]:         22 :     DLIList<int> merged_curve_ids;
                 [ +  - ]
    6158 [ +  - ][ +  - ]:         22 :     DLIList<BodySM*> neighbor_imprint_list;
                 [ +  - ]
    6159                 :            : 
    6160         [ +  - ]:         11 :     if (!preview)
    6161                 :            :     {
    6162                 :            :       int i;
    6163 [ +  - ][ -  + ]:         11 :       for( i=neighboring_bodies.size(); i--; )
    6164                 :            :       {
    6165         [ #  # ]:          0 :         Body *neighbor_body = neighboring_bodies.get_and_step();
    6166         [ #  # ]:          0 :         BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    6167         [ #  # ]:          0 :         GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    6168                 :            : 
    6169         [ #  # ]:          0 :         if( gme == neighbor_gme )
    6170                 :            :         {
    6171         [ #  # ]:          0 :           neighbor_imprint_list.append( tmp_body );
    6172         [ #  # ]:          0 :           engine_bodies.append( neighbor_body );
    6173                 :            :         }
    6174                 :            :       }
    6175                 :            : 
    6176         [ +  - ]:         11 :       DLIList<BodySM*> bodies_sms_to_modify;
    6177         [ +  - ]:         11 :       bodies_sms_to_modify += engine_body_sms;
    6178         [ +  - ]:         11 :       bodies_sms_to_modify += neighbor_imprint_list;
    6179         [ +  - ]:         11 :       push_attributes_before_modify( bodies_sms_to_modify );
    6180 [ +  - ][ +  - ]:         11 :       get_merged_curve_and_surface_ids( engine_bodies, merged_surface_ids, merged_curve_ids );
    6181                 :            :     }
    6182                 :            : 
    6183                 :            :     CubitStatus status = gme->webcut(engine_body_sms, vector1, vector2,
    6184         [ +  - ]:         11 :               vector3, neighbor_imprint_list, result_sm_list, imprint_type, preview );
    6185                 :            : 
    6186         [ +  - ]:         11 :     if ( status != CUBIT_FAILURE )
    6187                 :            :     {
    6188         [ +  - ]:         11 :       if(!preview)
    6189                 :            :       {
    6190         [ +  - ]:         11 :         restore_vg_after_modify(result_sm_list, engine_bodies, gme);
    6191         [ +  - ]:         11 :         remove_pushed_attributes(result_sm_list, engine_bodies);
    6192                 :            :       }
    6193                 :            :       status = finish_webcut( engine_bodies, result_sm_list, merge, status, results_list,
    6194         [ +  - ]:         11 :                               &merged_surface_ids, &merged_curve_ids );
    6195                 :            :     }
    6196                 :            :     else
    6197                 :            :     {
    6198         [ #  # ]:          0 :       if(!preview)
    6199         [ #  # ]:          0 :         remove_pushed_attributes(result_sm_list, engine_bodies);
    6200                 :            :     }
    6201                 :            : 
    6202         [ +  - ]:         11 :     engine_bodies.clean_out();
    6203         [ +  - ]:         11 :     engine_body_sms.clean_out();
    6204         [ +  - ]:         11 :     result_sm_list.clean_out();
    6205                 :            : 
    6206         [ -  + ]:         11 :     if ( status == CUBIT_FAILURE )
    6207                 :            :     {
    6208                 :          0 :       rval = CUBIT_FAILURE;
    6209 [ +  - ][ +  - ]:         11 :       break;
    6210                 :            :     }
    6211                 :         11 :   }
    6212                 :            : 
    6213 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ -  + ]
    6214                 :            :   {
    6215         [ #  # ]:          0 :     if( rval == CUBIT_SUCCESS )
    6216         [ #  # ]:          0 :       CubitUndo::note_result_bodies( results_list );
    6217                 :            :     else
    6218         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    6219                 :            :   }
    6220                 :            : 
    6221         [ +  - ]:         11 :   if(!preview)
    6222         [ +  - ]:         11 :     do_attribute_cleanup();
    6223                 :            : 
    6224         [ +  - ]:         11 :   return rval;
    6225                 :            : }
    6226                 :            : 
    6227                 :        120 : void GeometryModifyTool::remove_pushed_attributes(DLIList<BodySM*> &new_sms,
    6228                 :            :                                                         DLIList<Body*> &old_bodies)
    6229                 :            : {
    6230 [ +  - ][ +  - ]:        120 :   DLIList<TopologyBridge*> old_bridges(old_bodies.size());
    6231 [ +  - ][ +  - ]:        240 :   DLIList<TopologyBridge*> new_bridges(new_sms.size());
                 [ +  - ]
    6232 [ +  - ][ +  - ]:        262 :   CAST_LIST(new_sms, new_bridges, TopologyBridge);
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
    6233                 :            : 
    6234                 :            :   // Get bridges for all of the old Bodies.
    6235                 :            :   int k;
    6236 [ +  - ][ +  + ]:        426 :   for(k = old_bodies.size(); k>0; k--)
    6237                 :            :   {
    6238         [ +  - ]:        306 :     Body *body = old_bodies.get_and_step();
    6239 [ +  - ][ +  - ]:        306 :     TopologyBridge *tb = body->bridge_manager()->topology_bridge();
    6240         [ +  + ]:        306 :     if(tb)
    6241                 :            :     {
    6242         [ +  - ]:         77 :       old_bridges.append(tb);
    6243         [ +  - ]:         77 :       DLIList<TopologyBridge*> bridge_list;
    6244         [ +  - ]:         77 :       bridge_list.append(tb);
    6245                 :            :       // Add any bodies with composites to the new_sms list so that
    6246                 :            :       // make_Body gets called on them.  This will make sure that the
    6247                 :            :       // virtual gets ref entities properly built.
    6248 [ +  - ][ -  + ]:         77 :       if(this->contains_composites(bridge_list))
    6249                 :            :       {
    6250         [ #  # ]:          0 :         BodySM *bsm = dynamic_cast<BodySM*>(tb);
    6251         [ #  # ]:          0 :         if(bsm)
    6252         [ #  # ]:          0 :           new_sms.append_unique(bsm);
    6253         [ +  - ]:         77 :       }
    6254                 :            :     }
    6255                 :            :   }
    6256                 :            : 
    6257                 :            :   // Make a list including all of the bridges passed in.
    6258 [ +  - ][ +  - ]:        240 :   DLIList<TopologyBridge*> all_bridges;
    6259         [ +  - ]:        120 :   all_bridges = new_bridges;
    6260 [ +  - ][ +  + ]:        197 :   for(k=old_bridges.size(); k--;)
    6261 [ +  - ][ +  - ]:         77 :     all_bridges.append_unique(old_bridges.get_and_step());   
    6262                 :            :   
    6263                 :            :   
    6264                 :            :   //Remove ENTITY_ID attributes off non-virtual entities
    6265 [ +  - ][ +  - ]:        240 :   DLIList<CubitSimpleAttrib> list;
    6266 [ +  - ][ +  + ]:        262 :   for( k=all_bridges.size(); k--; )
    6267                 :            :   {
    6268         [ +  - ]:        142 :     TopologyBridge *top_bridge = all_bridges.get_and_step();    
    6269         [ +  - ]:        142 :     GeometryModifyEngine *gme = get_engine(top_bridge);    
    6270         [ +  - ]:        142 :     DLIList<TopologyBridge*> children;
    6271         [ +  - ]:        142 :     gme->get_possible_invalid_tbs(all_bridges, children);
    6272                 :            : 
    6273 [ +  - ][ +  + ]:       9784 :     for( int j=children.size(); j--; )
    6274                 :            :     {
    6275         [ +  - ]:       9642 :       TopologyBridge *tmp_bridge = children.get_and_step();
    6276 [ +  - ][ +  - ]:       9642 :       if( !GeometryQueryTool::instance()->is_intermediate_geometry( tmp_bridge ) )
                 [ +  - ]
    6277                 :            :       {
    6278 [ +  - ][ +  - ]:       9642 :         tmp_bridge->get_simple_attribute( "ENTITY_ID", list );
                 [ +  - ]
    6279 [ +  - ][ +  + ]:      12931 :         while( list.size() )    
    6280 [ +  - ][ +  - ]:       3289 :           tmp_bridge->remove_simple_attribute_virt(list.pop());
                 [ +  - ]
    6281                 :            :       }
    6282                 :            :     }
    6283         [ +  - ]:        142 :   }    
    6284                 :            : 
    6285                 :            :   // At this point we don't need any more attributes on the underlying
    6286                 :            :   // entities so make sure they are cleaned up.
    6287 [ +  - ][ +  - ]:        240 :   GeometryQueryTool::instance()->ige_remove_attributes( all_bridges );
                 [ +  - ]
    6288                 :        120 : }
    6289                 :            : 
    6290                 :        120 : CubitStatus GeometryModifyTool::restore_vg_after_modify(DLIList<BodySM*> &new_sms,
    6291                 :            :                                                         DLIList<Body*> &old_bodies,
    6292                 :            :                                                         GeometryModifyEngine *gme)
    6293                 :            : {
    6294 [ +  - ][ +  - ]:        120 :   DLIList<TopologyBridge*> old_bridges(old_bodies.size());
    6295 [ +  - ][ +  - ]:        240 :   DLIList<TopologyBridge*> new_bridges(new_sms.size());
                 [ +  - ]
    6296 [ +  - ][ +  - ]:        262 :   CAST_LIST(new_sms, new_bridges, TopologyBridge);
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
    6297                 :            : 
    6298                 :            :   // Get bridges for all of the old Bodies.
    6299                 :            :   int k;
    6300 [ +  - ][ +  + ]:        426 :   for(k = old_bodies.size(); k>0; k--)
    6301                 :            :   {
    6302         [ +  - ]:        306 :     Body *body = old_bodies.get_and_step();
    6303 [ +  - ][ +  - ]:        306 :     TopologyBridge *tb = body->bridge_manager()->topology_bridge();
    6304         [ +  + ]:        306 :     if(tb)
    6305                 :            :     {
    6306         [ +  - ]:         77 :       old_bridges.append(tb);
    6307         [ +  - ]:         77 :       DLIList<TopologyBridge*> bridge_list;
    6308         [ +  - ]:         77 :       bridge_list.append(tb);
    6309                 :            :       // Add any bodies with composites to the new_sms list so that
    6310                 :            :       // make_Body gets called on them.  This will make sure that the
    6311                 :            :       // virtual gets ref entities properly built.
    6312 [ +  - ][ -  + ]:         77 :       if(this->contains_composites(bridge_list))
    6313                 :            :       {
    6314         [ #  # ]:          0 :         BodySM *bsm = dynamic_cast<BodySM*>(tb);
    6315         [ #  # ]:          0 :         if(bsm)
    6316         [ #  # ]:          0 :           new_sms.append_unique(bsm);
    6317         [ +  - ]:         77 :       }
    6318                 :            :     }
    6319                 :            :   }
    6320                 :            : 
    6321                 :            :   // Make a list including all of the bridges passed in.
    6322 [ +  - ][ +  - ]:        240 :   DLIList<TopologyBridge*> all_bridges;
    6323         [ +  - ]:        120 :   all_bridges = new_bridges;
    6324 [ +  - ][ +  + ]:        197 :   for(k=old_bridges.size(); k--;)
    6325 [ +  - ][ +  - ]:         77 :     all_bridges.append_unique(old_bridges.get_and_step());
    6326                 :            : 
    6327 [ +  - ][ +  - ]:        240 :   DLIList<TopologyBridge*> tbs_to_check;
    6328         [ +  - ]:        120 :   if(gme)
    6329         [ +  - ]:        120 :     gme->get_possible_invalid_tbs(all_bridges, tbs_to_check);
    6330                 :            : 
    6331 [ +  - ][ +  - ]:        240 :   DLIList<Surface*> all_surfs;
    6332 [ +  - ][ +  - ]:        240 :   DLIList<Curve*> all_curves;
    6333 [ +  - ][ +  - ]:        240 :   DLIList<TBPoint*> all_points;
    6334 [ +  - ][ +  - ]:        120 :   if(tbs_to_check.size() > 0)
    6335                 :            :   {
    6336 [ +  - ][ +  + ]:       6880 :     for(k=tbs_to_check.size(); k--;)
    6337                 :            :     {
    6338         [ +  - ]:       6760 :       TopologyBridge *tb = tbs_to_check.get_and_step();
    6339         [ -  + ]:       6760 :       Surface *surf = dynamic_cast<Surface*>(tb);
    6340         [ +  + ]:       6760 :       if(surf)
    6341         [ +  - ]:       1655 :         all_surfs.append(surf);
    6342                 :            :       else
    6343                 :            :       {
    6344         [ -  + ]:       5105 :         Curve *cur = dynamic_cast<Curve*>(tb);
    6345         [ +  + ]:       5105 :         if(cur)
    6346         [ +  - ]:       3019 :           all_curves.append(cur);
    6347                 :            :         else
    6348                 :            :         {
    6349         [ -  + ]:       2086 :           TBPoint *pt = dynamic_cast<TBPoint*>(tb);
    6350         [ +  - ]:       2086 :           if(pt)
    6351         [ +  - ]:       6760 :             all_points.append(pt);
    6352                 :            :         }
    6353                 :            :       }
    6354                 :            :     }
    6355                 :            :   }
    6356                 :            : 
    6357                 :            :   // This function has been changed to blown away any virtual (really only doing
    6358                 :            :   // composites right now).  The virtual will rebuilt from the attributes stored
    6359                 :            :   // on the  entities.
    6360 [ +  - ][ +  - ]:        120 :   GeometryQueryTool::instance()->ige_remove_modified(all_surfs, all_curves, all_points);
    6361                 :            : 
    6362                 :            :   //Restore virtual
    6363 [ +  - ][ +  - ]:        120 :   GeometryQueryTool::instance()->ige_import_geom( all_bridges );
    6364                 :            : 
    6365         [ +  - ]:        120 :   return CUBIT_SUCCESS;
    6366                 :            : }
    6367                 :            : 
    6368                 :         44 : GeometryModifyEngine* GeometryModifyTool::group_bodies_by_engine(
    6369                 :            :                                   DLIList<Body*>& remaining_bodies,
    6370                 :            :                                   DLIList<Body*>& engine_bodies,
    6371                 :            :                                   DLIList<BodySM*>& engine_body_sms ) const
    6372                 :            : {
    6373                 :         44 :   int i = remaining_bodies.size();
    6374                 :         44 :   remaining_bodies.reset();
    6375                 :         44 :   GeometryModifyEngine* engine = 0;
    6376                 :            : 
    6377         [ +  + ]:         44 :   if (i == 0)
    6378                 :         22 :     return 0;
    6379                 :            : 
    6380                 :            :     // Skip over any bodies that don't have a modify engine.
    6381         [ +  - ]:         22 :   while (i--)
    6382                 :            :   {
    6383         [ +  - ]:         22 :     Body* body = remaining_bodies.get();
    6384                 :         22 :     TopologyBridge* bridge = 0;
    6385         [ +  - ]:         22 :     engine = get_engine(body, &bridge);
    6386         [ +  - ]:         22 :     if (engine)
    6387                 :            :     {
    6388         [ +  - ]:         22 :       remaining_bodies.change_to(0);
    6389         [ +  - ]:         22 :       engine_bodies.append(body);
    6390 [ -  + ][ +  - ]:         22 :       engine_body_sms.append(dynamic_cast<BodySM*>(bridge));
    6391         [ +  - ]:         22 :       remaining_bodies.step();
    6392                 :         22 :       break;
    6393                 :            :     }
    6394         [ #  # ]:          0 :     remaining_bodies.step();
    6395                 :            :   }
    6396                 :            : 
    6397                 :            :   // catch case where no engine was found
    6398         [ -  + ]:         22 :   if (0 == engine)
    6399                 :            :   {
    6400 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No geometry modify engine found for this operation.");
    6401                 :          0 :     return engine;
    6402                 :            :   }
    6403                 :            : 
    6404                 :            : 
    6405                 :            :     // Get remaining bodies with same modify engine.
    6406         [ -  + ]:         22 :   while (i--)
    6407                 :            :   {
    6408         [ #  # ]:          0 :     Body* body = remaining_bodies.get();
    6409                 :          0 :     TopologyBridge* bridge = 0;
    6410 [ #  # ][ #  # ]:          0 :     if (get_engine(body, &bridge) == engine)
    6411                 :            :     {
    6412         [ #  # ]:          0 :       remaining_bodies.change_to(0);
    6413         [ #  # ]:          0 :       engine_bodies.append(body);
    6414 [ #  # ][ #  # ]:          0 :       engine_body_sms.append(dynamic_cast<BodySM*>(bridge));
    6415                 :            :     }
    6416         [ #  # ]:          0 :     remaining_bodies.step();
    6417                 :            :   }
    6418                 :            : 
    6419         [ +  - ]:         22 :   remaining_bodies.remove_all_with_value(0);
    6420                 :         44 :   return engine;
    6421                 :            : }
    6422                 :            : 
    6423                 :            : 
    6424                 :            : 
    6425                 :            : 
    6426                 :            : // ********** END PRIVATE FUNCTIONS        **********
    6427                 :            : 
    6428                 :            : // ********** BEGIN HELPER CLASSES         **********
    6429                 :            : // ********** END HELPER CLASSES           **********
    6430                 :            : 
    6431                 :            : // ********** BEGIN EXTERN FUNCTIONS       **********
    6432                 :            : // ********** END EXTERN FUNCTIONS         **********
    6433                 :            : 
    6434                 :            : // ********** BEGIN STATIC FUNCTIONS       **********
    6435                 :            : // ********** END STATIC FUNCTIONS         **********
    6436                 :            : 
    6437                 :         87 : CubitStatus GeometryModifyTool::unite( DLIList<BodySM*> &body_sm_list,
    6438                 :            :                                        DLIList<BodySM*> &new_body_sm_list,
    6439                 :            :                                        bool keep_old)
    6440                 :            : {
    6441                 :            :   //this assumes that all bodies have the same modify engine
    6442                 :         87 :   GeometryModifyEngine *gme = get_engine( body_sm_list.get() );
    6443                 :         87 :   CubitStatus result = gme->unite(body_sm_list, new_body_sm_list, keep_old);
    6444                 :         87 :   return result;
    6445                 :            : }
    6446                 :            : 
    6447                 :            : CubitStatus
    6448                 :         87 : GeometryModifyTool::unite( DLIList<Body*> &bodies,
    6449                 :            :                            DLIList<Body*> &new_body_list,
    6450                 :            :                            bool keep_old )
    6451                 :            : {
    6452 [ +  - ][ -  + ]:         87 :   if( bodies.size() <= 1 )
    6453                 :            :   {
    6454 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("There is only one volume in the list. Nothing modified.\n");
         [ #  # ][ #  # ]
    6455                 :          0 :     return CUBIT_FAILURE;
    6456                 :            :   }
    6457 [ +  - ][ -  + ]:         87 :   if (!okay_to_modify( bodies, "UNITE" ))
    6458                 :          0 :     return CUBIT_FAILURE;
    6459                 :            : 
    6460                 :            :   int i;
    6461         [ +  - ]:         87 :   const int count = bodies.size();
    6462         [ +  - ]:         87 :   DLIList<TopologyEntity*> entity_list(count);
    6463 [ +  - ][ +  - ]:        174 :   DLIList<TopologyBridge*> bridge_list(count);
    6464         [ +  - ]:         87 :   bodies.reset();
    6465 [ +  - ][ +  + ]:        371 :   for (i = bodies.size(); i--; )
    6466 [ +  - ][ +  - ]:        284 :     entity_list.append_unique(bodies.get_and_step());
    6467         [ +  - ]:         87 :   GeometryModifyEngine* gme = common_modify_engine( entity_list, bridge_list );
    6468                 :            : 
    6469         [ -  + ]:         87 :   if( !gme )
    6470                 :            :   {
    6471 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing UNITE with volumes containing geometry from\n"
                 [ #  # ]
    6472                 :            :       "different modeling engines is not allowed.\n"
    6473         [ #  # ]:          0 :       "Delete uncommon geometry on these volumes before operation.\n\n");
    6474                 :          0 :     return CUBIT_FAILURE;
    6475                 :            :   }
    6476                 :            : 
    6477                 :            :   // Cubit can't mesh mixed sheet/solid bodies that are united together. If
    6478                 :            :   // required, separate the unite between these types.
    6479                 :            :   CubitStatus result;
    6480 [ +  - ][ +  - ]:         87 :   if( GeometryModifyTool::instance()->unite_mixed_models() )
                 [ +  - ]
    6481         [ +  - ]:         87 :     result = unite_all( gme, bodies, new_body_list, keep_old );
    6482                 :            :   else
    6483         [ #  # ]:          0 :     result = unite_separately( gme, bodies, new_body_list, keep_old );
    6484                 :            : 
    6485         [ -  + ]:         87 :   if( result == CUBIT_FAILURE )
    6486 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("UNITE failed\n");
         [ #  # ][ #  # ]
    6487                 :            : 
    6488         [ +  - ]:        174 :   return result;
    6489                 :            : }
    6490                 :            : 
    6491                 :            : CubitStatus
    6492                 :          0 : GeometryModifyTool::unite_separately( GeometryModifyEngine *gme_ptr,
    6493                 :            :                                       DLIList<Body*> &bodies,
    6494                 :            :                                       DLIList<Body*> &new_body_list,
    6495                 :            :                                       bool keep_old )
    6496                 :            : {
    6497                 :            :   // Cubit can't mesh mixed sheet/solid bodies that are united together. Sort
    6498                 :            :   // based on these types.
    6499                 :            :   int i;
    6500                 :            :   Body *body_ptr;
    6501         [ #  # ]:          0 :   DLIList<Body*> solid_body_list;
    6502 [ #  # ][ #  # ]:          0 :   DLIList<Body*> sheet_body_list;
    6503         [ #  # ]:          0 :   bodies.reset();
    6504 [ #  # ][ #  # ]:          0 :   for( i=bodies.size(); i--; )
    6505                 :            :   {
    6506         [ #  # ]:          0 :     body_ptr = bodies.get_and_step();
    6507                 :            : 
    6508 [ #  # ][ #  # ]:          0 :     if( body_ptr->is_sheet_body() )
    6509         [ #  # ]:          0 :       sheet_body_list.append( body_ptr );
    6510                 :            :     else
    6511         [ #  # ]:          0 :       solid_body_list.append( body_ptr );
    6512                 :            :   }
    6513                 :            : 
    6514 [ #  # ][ #  # ]:          0 :   if( sheet_body_list.size() == 1 && solid_body_list.size() == 1 )
         [ #  # ][ #  # ]
                 [ #  # ]
    6515                 :            :   {
    6516 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Cannot unite solid and sheet bodies together\n" );
         [ #  # ][ #  # ]
    6517                 :          0 :     return CUBIT_FAILURE;
    6518                 :            :   }
    6519                 :            : 
    6520                 :            :   // Setup undo
    6521 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    6522                 :            :   {
    6523         [ #  # ]:          0 :     if( keep_old )
    6524         [ #  # ]:          0 :       CubitUndo::save_state();
    6525                 :            :     else
    6526         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( bodies );
    6527                 :            :   }
    6528                 :            : 
    6529                 :            :   // Unite solids with each other, and sheets with each other separately
    6530                 :          0 :   CubitStatus result1 = CUBIT_SUCCESS;
    6531                 :          0 :   CubitStatus result2 = CUBIT_SUCCESS;
    6532 [ #  # ][ #  # ]:          0 :   if( solid_body_list.size() > 1 )
    6533         [ #  # ]:          0 :     result1 = unite_private( gme_ptr, solid_body_list, new_body_list, keep_old );
    6534 [ #  # ][ #  # ]:          0 :   if( sheet_body_list.size() > 1 )
    6535         [ #  # ]:          0 :     result2 = unite_private( gme_ptr, sheet_body_list, new_body_list, keep_old );
    6536                 :            : 
    6537                 :            :   // Finish undo
    6538 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    6539                 :            :   {
    6540 [ #  # ][ #  # ]:          0 :     if( new_body_list.size() )
    6541         [ #  # ]:          0 :       CubitUndo::note_result_bodies( new_body_list );
    6542                 :            :     else
    6543         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    6544                 :            :   }
    6545                 :            : 
    6546                 :            :   // Return success if both unites successful
    6547 [ #  # ][ #  # ]:          0 :   if( result1 == CUBIT_SUCCESS && result2 == CUBIT_SUCCESS )
    6548                 :          0 :     return CUBIT_SUCCESS;
    6549                 :            : 
    6550                 :            :   // Return success if either unite was successful
    6551 [ #  # ][ #  # ]:          0 :   if( ( solid_body_list.size() > 1 && result1 == CUBIT_SUCCESS ) ||
         [ #  # ][ #  # ]
                 [ #  # ]
    6552 [ #  # ][ #  # ]:          0 :       ( sheet_body_list.size() > 1 && result2 == CUBIT_SUCCESS ) )
    6553                 :            :   {
    6554                 :            :     // Give warning if one or the other failed
    6555         [ #  # ]:          0 :     if( result1 == CUBIT_FAILURE )
    6556 [ #  # ][ #  # ]:          0 :       PRINT_WARNING( "Unite of solid volumes failed\n" );
         [ #  # ][ #  # ]
    6557         [ #  # ]:          0 :     if( result2 == CUBIT_FAILURE )
    6558 [ #  # ][ #  # ]:          0 :       PRINT_WARNING( "Unite of sheet bodies failed\n" );
         [ #  # ][ #  # ]
    6559                 :            : 
    6560                 :          0 :     return CUBIT_SUCCESS;
    6561                 :            :   }
    6562                 :            : 
    6563         [ #  # ]:          0 :   return CUBIT_FAILURE;
    6564                 :            : }
    6565                 :            : 
    6566                 :            : CubitStatus
    6567                 :         87 : GeometryModifyTool::unite_all( GeometryModifyEngine *gme_ptr,
    6568                 :            :                                DLIList<Body*> &bodies,
    6569                 :            :                                DLIList<Body*> &new_body_list,
    6570                 :            :                                bool keep_old )
    6571                 :            : {
    6572                 :            :   // Setup undo
    6573         [ -  + ]:         87 :   if( CubitUndo::get_undo_enabled() )
    6574                 :            :   {
    6575         [ #  # ]:          0 :     if( keep_old )
    6576                 :          0 :       CubitUndo::save_state();
    6577                 :            :     else
    6578                 :          0 :       CubitUndo::save_state_with_cubit_file( bodies );
    6579                 :            :   }
    6580                 :            : 
    6581                 :            :   // Unite solids with each other, and sheets with each other separately
    6582                 :         87 :   CubitStatus result = unite_private( gme_ptr, bodies, new_body_list, keep_old );
    6583                 :            : 
    6584                 :            :   // Finish undo
    6585         [ -  + ]:         87 :   if( CubitUndo::get_undo_enabled() )
    6586                 :            :   {
    6587         [ #  # ]:          0 :     if( new_body_list.size() )
    6588                 :          0 :       CubitUndo::note_result_bodies( new_body_list );
    6589                 :            :     else
    6590                 :          0 :       CubitUndo::remove_last_undo();
    6591                 :            :   }
    6592                 :            : 
    6593                 :         87 :   return result;
    6594                 :            : }
    6595                 :            : 
    6596                 :            : // Private workhorse function for unite
    6597                 :            : CubitStatus
    6598                 :         87 : GeometryModifyTool::unite_private( GeometryModifyEngine *gme_ptr,
    6599                 :            :                                    DLIList<Body*> &body_list,
    6600                 :            :                                    DLIList<Body*> &new_body_list,
    6601                 :            :                                    bool keep_old )
    6602                 :            : {
    6603 [ +  - ][ -  + ]:         87 :   if( !body_list.size() )
    6604                 :          0 :     return CUBIT_SUCCESS;
    6605                 :            : 
    6606                 :            :   int i, j;
    6607                 :            :   Body *body_ptr;
    6608                 :            :   CubitStatus result;
    6609                 :            : 
    6610                 :            :   // Give 1st body all the names of all bodies being united
    6611         [ +  - ]:         87 :   std::list<CubitString> names_list;
    6612 [ +  - ][ +  - ]:        174 :   DLIList<CubitString> entity_names;
    6613                 :            : 
    6614         [ +  - ]:         87 :   body_list.reset();
    6615 [ +  - ][ +  + ]:        371 :   for( i=body_list.size(); i--; )
    6616                 :            :   {
    6617         [ +  - ]:        284 :     body_ptr = body_list.get_and_step();
    6618                 :            : 
    6619                 :            :     // See if body has names
    6620 [ +  - ][ +  + ]:        284 :     if( body_ptr->num_names() )
    6621                 :            :     {
    6622                 :            :       // Put the names in a list
    6623         [ +  - ]:         20 :       body_ptr->entity_names( entity_names );
    6624         [ +  - ]:         20 :       entity_names.reset();
    6625                 :            : 
    6626                 :            :       // Loop through names
    6627 [ +  - ][ +  + ]:         60 :       for( j=entity_names.size(); j--; )
    6628 [ +  - ][ +  - ]:         40 :         names_list.push_back( entity_names.get_and_step() );
    6629                 :            : 
    6630         [ +  - ]:         20 :       entity_names.clean_out();
    6631         [ +  - ]:         20 :       body_ptr->remove_entity_names();
    6632                 :            :     }
    6633                 :            :   }
    6634                 :            : 
    6635         [ +  - ]:         87 :   do_attribute_setup();
    6636                 :            : 
    6637 [ +  - ][ +  - ]:        174 :   DLIList<TopologyEntity*> entity_list(body_list.size());
                 [ +  - ]
    6638 [ +  - ][ +  - ]:        174 :   DLIList<TopologyBridge*> bridge_list(body_list.size());
                 [ +  - ]
    6639         [ +  - ]:         87 :   body_list.reset();
    6640 [ +  - ][ +  + ]:        371 :   for( i=body_list.size(); i--; )
    6641 [ +  - ][ +  - ]:        284 :     entity_list.append_unique(body_list.get_and_step());
    6642         [ +  - ]:         87 :   common_modify_engine( entity_list, bridge_list );
    6643                 :            : 
    6644 [ +  - ][ +  - ]:        174 :   DLIList<BodySM*> body_sm_list(body_list.size());
                 [ +  - ]
    6645 [ +  - ][ +  - ]:        371 :   CAST_LIST(bridge_list, body_sm_list, BodySM);
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
    6646                 :            : 
    6647         [ +  - ]:         87 :   push_attributes_before_modify(body_sm_list);
    6648                 :            : 
    6649 [ +  - ][ +  - ]:        174 :   DLIList<int> merged_surface_ids;
    6650 [ +  - ][ +  - ]:        174 :   DLIList<int> merged_curve_ids;
    6651                 :            : 
    6652         [ +  - ]:         87 :   get_merged_curve_and_surface_ids( body_list, merged_surface_ids, merged_curve_ids );
    6653                 :            : 
    6654 [ +  - ][ +  - ]:        174 :   DLIList<BodySM*> new_body_sm_list;
    6655         [ +  - ]:         87 :   result = unite( body_sm_list, new_body_sm_list, keep_old );
    6656                 :            : 
    6657         [ +  - ]:         87 :   restore_vg_after_modify( new_body_sm_list, body_list, gme_ptr );
    6658         [ +  - ]:         87 :   remove_pushed_attributes( new_body_sm_list, body_list );
    6659                 :            : 
    6660 [ +  - ][ +  - ]:        174 :   DLIList<Body*> result_list;
    6661 [ +  - ][ -  + ]:         87 :   if( !finish_sm_op(body_list, new_body_sm_list, result_list) )
    6662                 :          0 :     result = CUBIT_FAILURE;
    6663                 :            : 
    6664         [ +  - ]:         87 :   if( keep_old == CUBIT_FALSE )
    6665         [ +  - ]:         87 :     fixup_merged_entities( merged_surface_ids, merged_curve_ids );
    6666                 :            : 
    6667         [ +  - ]:         87 :   do_attribute_cleanup();
    6668                 :            : 
    6669         [ +  - ]:         87 :   if( result )
    6670                 :            :   {
    6671         [ +  - ]:         87 :     new_body_list += result_list;
    6672                 :            : 
    6673 [ +  - ][ +  + ]:        174 :     for( j=result_list.size(); j--; )
    6674                 :            :     {
    6675                 :            :       //Add names to 1st body
    6676 [ +  - ][ +  - ]:         87 :       std::list<CubitString>::iterator iter, end = names_list.end();
    6677 [ +  - ][ +  - ]:        127 :       for (iter = names_list.begin(); iter != end; ++iter)
         [ +  - ][ +  + ]
    6678 [ +  - ][ +  - ]:         40 :         result_list.get_and_step()->entity_name( *iter );
         [ +  - ][ +  - ]
                 [ +  - ]
    6679                 :            :     }
    6680                 :            :   }
    6681                 :            : 
    6682         [ +  - ]:         87 :   return result;
    6683                 :            : }
    6684                 :            : 
    6685                 :          0 : CubitStatus GeometryModifyTool::chop( DLIList<Body*> &bodies,
    6686                 :            :                                       DLIList<Body*> &intersectBodies,
    6687                 :            :                                       DLIList<Body*> &outsideBodies,
    6688                 :            :                                       Body*& leftoversBody,
    6689                 :            :                                       bool keep_old,
    6690                 :            :                                       bool nonreg )
    6691                 :            : {
    6692                 :          0 :    leftoversBody = 0;
    6693 [ #  # ][ #  # ]:          0 :    if (bodies.size() <= 1)
    6694                 :            :    {
    6695 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("There is only one body in the list. Nothing modified\n");
         [ #  # ][ #  # ]
    6696                 :          0 :       return CUBIT_FAILURE;
    6697                 :            :    }
    6698 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( bodies, "CHOP" ))
    6699                 :          0 :      return CUBIT_FAILURE;
    6700                 :            : 
    6701                 :            :   int i;
    6702         [ #  # ]:          0 :   const int count = bodies.size();
    6703         [ #  # ]:          0 :   DLIList<Body*> original_body_list = bodies;
    6704 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
    6705 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(count);
    6706         [ #  # ]:          0 :   bodies.reset();
    6707 [ #  # ][ #  # ]:          0 :   for (i = bodies.size(); i--; )
    6708 [ #  # ][ #  # ]:          0 :     entity_list.append_unique(bodies.get_and_step());
    6709         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine( entity_list, bridge_list );
    6710                 :            : 
    6711         [ #  # ]:          0 :   if ( !gme )
    6712                 :            :   {
    6713 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing CHOP with volumes containing geometry\n"
                 [ #  # ]
    6714                 :            :                   " from different modeling engines is not allowed.\n"
    6715         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    6716                 :          0 :       return CUBIT_FAILURE;
    6717                 :            :   }
    6718                 :            : 
    6719 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list;
    6720 [ #  # ][ #  # ]:          0 :    CAST_LIST( bridge_list, body_sm_list, BodySM );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    6721 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> intersect_bodies, outside_bodies;
         [ #  # ][ #  # ]
    6722                 :          0 :    BodySM *leftovers_body = 0;
    6723                 :            : 
    6724 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    6725                 :            :    {
    6726         [ #  # ]:          0 :      if( keep_old )
    6727         [ #  # ]:          0 :        CubitUndo::save_state();
    6728                 :            :      else
    6729                 :            :      {
    6730                 :            :        //Get all the bodies associated with the vertex
    6731         [ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( bodies );
    6732                 :            :      }
    6733                 :            :    }
    6734                 :            : 
    6735 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_surface_ids;
    6736 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_curve_ids;
    6737 [ #  # ][ #  # ]:          0 :    DLIList<Body*> tmp_bodies(1);
    6738 [ #  # ][ #  # ]:          0 :    tmp_bodies.append( bodies.get() );
    6739         [ #  # ]:          0 :    if( keep_old == CUBIT_FALSE )
    6740         [ #  # ]:          0 :      get_merged_curve_and_surface_ids( tmp_bodies, merged_surface_ids, merged_curve_ids );
    6741                 :            : 
    6742         [ #  # ]:          0 :    do_attribute_setup();
    6743                 :            : 
    6744                 :            :    // Push attributes down onto the blank body (first one in list).
    6745 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> tmp_body_sm_list;
    6746         [ #  # ]:          0 :    body_sm_list.reset();
    6747 [ #  # ][ #  # ]:          0 :    tmp_body_sm_list.append(body_sm_list.get());
    6748         [ #  # ]:          0 :    push_attributes_before_modify(tmp_body_sm_list);
    6749                 :            : 
    6750                 :            :    CubitStatus result = gme->chop( body_sm_list, intersect_bodies,
    6751         [ #  # ]:          0 :                           outside_bodies, leftovers_body, keep_old, nonreg );
    6752                 :            : 
    6753         [ #  # ]:          0 :    if( result == CUBIT_FAILURE )
    6754                 :            :    {
    6755 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    6756         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    6757                 :            : 
    6758 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("CHOP failed\n");
         [ #  # ][ #  # ]
    6759         [ #  # ]:          0 :      remove_pushed_attributes(tmp_body_sm_list, tmp_bodies);
    6760         [ #  # ]:          0 :      do_attribute_cleanup();
    6761                 :          0 :      return CUBIT_FAILURE;
    6762                 :            :    }
    6763                 :            : 
    6764 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> all_sms = intersect_bodies;
    6765         [ #  # ]:          0 :    all_sms += outside_bodies;
    6766                 :            : 
    6767         [ #  # ]:          0 :    restore_vg_after_modify(all_sms, tmp_bodies, gme);
    6768         [ #  # ]:          0 :    remove_pushed_attributes(all_sms, tmp_bodies);
    6769                 :            : 
    6770 [ #  # ][ #  # ]:          0 :    DLIList<Body*> result_bodies;
    6771                 :            : 
    6772         [ #  # ]:          0 :    body_sm_list.clean_out();
    6773         [ #  # ]:          0 :    body_sm_list += intersect_bodies;
    6774                 :            : 
    6775         [ #  # ]:          0 :    CubitStatus stat = finish_sm_op(bodies, body_sm_list, result_bodies);
    6776                 :            : 
    6777 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    6778                 :            :    {
    6779         [ #  # ]:          0 :      if( stat == CUBIT_SUCCESS )
    6780         [ #  # ]:          0 :        CubitUndo::note_result_bodies( result_bodies );
    6781                 :            :      else
    6782         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    6783                 :            :    }
    6784                 :            : 
    6785         [ #  # ]:          0 :    if( stat == CUBIT_FAILURE )
    6786                 :            :    {
    6787 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    6788         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    6789                 :            : 
    6790 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("CHOP failed\n");
         [ #  # ][ #  # ]
    6791         [ #  # ]:          0 :      do_attribute_cleanup();
    6792                 :          0 :      return CUBIT_FAILURE;
    6793                 :            :    }
    6794         [ #  # ]:          0 :    intersectBodies += result_bodies;
    6795         [ #  # ]:          0 :    bodies.clean_out();
    6796                 :            : 
    6797         [ #  # ]:          0 :    body_sm_list.clean_out();
    6798         [ #  # ]:          0 :    body_sm_list += outside_bodies;
    6799         [ #  # ]:          0 :    result_bodies.clean_out();
    6800 [ #  # ][ #  # ]:          0 :    if (!finish_sm_op(bodies, body_sm_list, result_bodies))
    6801                 :            :    {
    6802 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    6803         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    6804                 :            : 
    6805 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("CHOP failed\n");
         [ #  # ][ #  # ]
    6806         [ #  # ]:          0 :      do_attribute_cleanup();
    6807                 :          0 :      return CUBIT_FAILURE;
    6808                 :            :    }
    6809         [ #  # ]:          0 :    outsideBodies += result_bodies;
    6810                 :            : 
    6811         [ #  # ]:          0 :    if( leftovers_body )
    6812                 :            :    {
    6813         [ #  # ]:          0 :      body_sm_list.clean_out();
    6814         [ #  # ]:          0 :      body_sm_list.append( leftovers_body );
    6815         [ #  # ]:          0 :      result_bodies.clean_out();
    6816 [ #  # ][ #  # ]:          0 :      if (!finish_sm_op(bodies, body_sm_list, result_bodies))
    6817                 :            :      {
    6818 [ #  # ][ #  # ]:          0 :        if( CubitUndo::get_undo_enabled() )
    6819         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    6820                 :            : 
    6821 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("CHOP failed\n");
         [ #  # ][ #  # ]
    6822         [ #  # ]:          0 :        do_attribute_cleanup();
    6823                 :          0 :        return CUBIT_FAILURE;
    6824                 :            :      }
    6825         [ #  # ]:          0 :      leftoversBody = result_bodies.get();
    6826                 :            : 
    6827                 :            :    }
    6828                 :            : 
    6829         [ #  # ]:          0 :    if( keep_old == CUBIT_FALSE )
    6830         [ #  # ]:          0 :      fixup_merged_entities( merged_surface_ids, merged_curve_ids);
    6831                 :            : 
    6832 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    6833                 :            :   {
    6834         [ #  # ]:          0 :     if( leftoversBody )
    6835                 :            :     {
    6836         [ #  # ]:          0 :       DLIList<Body*> tmp_list(1);
    6837         [ #  # ]:          0 :       tmp_list.append( leftoversBody );
    6838 [ #  # ][ #  # ]:          0 :       CubitUndo::note_result_bodies( tmp_list );
    6839                 :            :     }
    6840         [ #  # ]:          0 :     CubitUndo::note_result_bodies( intersectBodies );
    6841         [ #  # ]:          0 :     CubitUndo::note_result_bodies( outsideBodies );
    6842                 :            :   }
    6843                 :            : 
    6844         [ #  # ]:          0 :   do_attribute_cleanup();
    6845         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    6846                 :            : }
    6847                 :            : 
    6848                 :          0 : CubitStatus GeometryModifyTool::hollow( DLIList<Body*>& bodies,
    6849                 :            :                                         DLIList<RefFace*> faces_to_remove,
    6850                 :            :                                         DLIList<Body*>& new_bodies,
    6851                 :            :                                         double depth)
    6852                 :            : {
    6853 [ #  # ][ #  # ]:          0 :   if (bodies.size() <= 0 || faces_to_remove.size() <= 0)
         [ #  # ][ #  # ]
                 [ #  # ]
    6854                 :            :   {
    6855 [ #  # ][ #  # ]:          0 :      PRINT_WARNING("Needs at least one body and one face. Nothing modified\n");
         [ #  # ][ #  # ]
    6856                 :          0 :      return CUBIT_FAILURE;
    6857                 :            :   }
    6858                 :            : 
    6859 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( bodies, "HOLLOW" ))
    6860                 :          0 :     return CUBIT_FAILURE;
    6861                 :            : 
    6862                 :            :   // Get the GeometryEngine for each Body of the list to check
    6863                 :            :   // if they are the same and if they are GeometryModifyEngine
    6864                 :            : 
    6865         [ #  # ]:          0 :   const int count = bodies.size();
    6866         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
    6867 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(count);
    6868 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(bodies, entity_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    6869         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine( entity_list, bridge_list );
    6870                 :            : 
    6871         [ #  # ]:          0 :   if (!gme)
    6872                 :            :   {
    6873 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Performing THICKEN with volumes containing geometry\n"
                 [ #  # ]
    6874                 :            :                  " from different modeling engines is not allowed.\n"
    6875         [ #  # ]:          0 :                  "Delete uncommon geometry on these volumes before operation.\n\n");
    6876                 :          0 :      return CUBIT_FAILURE;
    6877                 :            :   }
    6878                 :            : 
    6879 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_sms(count);
    6880 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms(count);
    6881 [ #  # ][ #  # ]:          0 :   CAST_LIST(bridge_list, body_sms, BodySM);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    6882                 :            : 
    6883 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    6884                 :            :   {
    6885         [ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies );
    6886                 :            :   }
    6887                 :            : 
    6888 [ #  # ][ #  # ]:          0 :   DLIList <Surface*> surfs_to_remove;
    6889 [ #  # ][ #  # ]:          0 :   for(int i = 0 ; i < faces_to_remove.size(); i++)
    6890                 :            :   {
    6891 [ #  # ][ #  # ]:          0 :     Surface* surf = faces_to_remove.get_and_step()->get_surface_ptr();
    6892         [ #  # ]:          0 :     if(surf)
    6893         [ #  # ]:          0 :       surfs_to_remove.append(surf);
    6894                 :            :   }
    6895                 :            : 
    6896                 :            : 
    6897 [ #  # ][ #  # ]:          0 :   DLIList<int> merged_surface_ids;
    6898 [ #  # ][ #  # ]:          0 :   DLIList<int> merged_curve_ids;
    6899         [ #  # ]:          0 :   get_merged_curve_and_surface_ids( bodies, merged_surface_ids, merged_curve_ids );
    6900         [ #  # ]:          0 :   do_attribute_setup();
    6901                 :            : 
    6902                 :            :   // Push attributes down onto the bodies to be hollowed
    6903         [ #  # ]:          0 :   push_attributes_before_modify( body_sms );
    6904                 :            : 
    6905         [ #  # ]:          0 :   CubitStatus result = gme->hollow( body_sms, surfs_to_remove, new_sms, depth);
    6906                 :            : 
    6907         [ #  # ]:          0 :    if( result == CUBIT_FAILURE )
    6908                 :            :    {
    6909 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    6910         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    6911                 :            : 
    6912 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Hollow failed\n");
         [ #  # ][ #  # ]
    6913         [ #  # ]:          0 :      remove_pushed_attributes(body_sms, bodies);
    6914         [ #  # ]:          0 :      do_attribute_cleanup();
    6915                 :          0 :      return CUBIT_FAILURE;
    6916                 :            :    }
    6917                 :            : 
    6918                 :            :   // check for resued entities, they have been moved and we need to notify observers
    6919 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
    6920                 :            :   int i;
    6921 [ #  # ][ #  # ]:          0 :   for(i=0; i<new_sms.size(); i++)
    6922                 :            :   {
    6923         [ #  # ]:          0 :     BodySM* bodysm = new_sms.get_and_step();
    6924         [ #  # ]:          0 :     DLIList<TopologyBridge*> to_check;
    6925 [ #  # ][ #  # ]:          0 :     DLIList<TopologyBridge*> tmp;
    6926 [ #  # ][ #  # ]:          0 :     DLIList<Surface*> surfs;
    6927         [ #  # ]:          0 :     bodysm->surfaces(surfs);
    6928 [ #  # ][ #  # ]:          0 :     DLIList<Curve*> curves;
    6929         [ #  # ]:          0 :     bodysm->curves(curves);
    6930 [ #  # ][ #  # ]:          0 :     DLIList<TBPoint*> points;
    6931         [ #  # ]:          0 :     bodysm->points(points);
    6932         [ #  # ]:          0 :     to_check.append(bodysm);
    6933 [ #  # ][ #  # ]:          0 :     to_check.append(bodysm->lump());
    6934 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(surfs, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    6935         [ #  # ]:          0 :     to_check += tmp;
    6936 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    6937         [ #  # ]:          0 :     to_check += tmp;
    6938 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    6939         [ #  # ]:          0 :     to_check += tmp;
    6940                 :            : 
    6941                 :            :     int k;
    6942 [ #  # ][ #  # ]:          0 :     for(k=0; k<to_check.size(); k++)
    6943 [ #  # ][ #  # ]:          0 :       if(BridgeManager* m = to_check.get_and_step()->bridge_manager())
                 [ #  # ]
    6944 [ #  # ][ #  # ]:          0 :         if(TopologyEntity* t = m->topology_entity())
    6945 [ #  # ][ #  # ]:          0 :           entities_to_update.append(CAST_TO(t, RefEntity));
    6946                 :            : 
    6947         [ #  # ]:          0 :   }
    6948                 :            : 
    6949         [ #  # ]:          0 :   restore_vg_after_modify( new_sms, bodies, gme );
    6950         [ #  # ]:          0 :   remove_pushed_attributes( new_sms, bodies );
    6951                 :            : 
    6952         [ #  # ]:          0 :   result = finish_sm_op(bodies, new_sms, new_bodies);
    6953         [ #  # ]:          0 :   fixup_merged_entities( merged_surface_ids, merged_curve_ids);
    6954                 :            : 
    6955         [ #  # ]:          0 :   if (CUBIT_FAILURE == result) {
    6956 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
    6957         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    6958                 :            : 
    6959 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Hollow failed\n");
         [ #  # ][ #  # ]
    6960         [ #  # ]:          0 :     do_attribute_cleanup();
    6961                 :          0 :     return CUBIT_FAILURE;
    6962                 :            :   }
    6963 [ #  # ][ #  # ]:          0 :   else if( CubitUndo::get_undo_enabled() ) {
    6964         [ #  # ]:          0 :     CubitUndo::note_result_bodies( new_bodies );
    6965                 :            :   }
    6966                 :            : 
    6967         [ #  # ]:          0 :   do_attribute_cleanup();
    6968         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    6969                 :            : }
    6970                 :            : 
    6971                 :          0 : CubitStatus GeometryModifyTool::thicken( DLIList<Body*>& bodies,
    6972                 :            :                                          DLIList<Body*>& new_bodies,
    6973                 :            :                                          double depth,
    6974                 :            :                                          bool both )
    6975                 :            : {
    6976 [ #  # ][ #  # ]:          0 :   if (bodies.size() <= 0)
    6977                 :            :   {
    6978 [ #  # ][ #  # ]:          0 :      PRINT_WARNING("There is only one body in the list. Nothing modified\n");
         [ #  # ][ #  # ]
    6979                 :          0 :      return CUBIT_FAILURE;
    6980                 :            :   }
    6981                 :            : 
    6982 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( bodies, "THICKEN" ))
    6983                 :          0 :     return CUBIT_FAILURE;
    6984                 :            : 
    6985                 :            :   // Get the GeometryEngine for each Body of the list to check
    6986                 :            :   // if they are the same and if they are GeometryModifyEngine
    6987                 :            : 
    6988         [ #  # ]:          0 :   const int count = bodies.size();
    6989         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
    6990 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(count);
    6991 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(bodies, entity_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    6992         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine( entity_list, bridge_list );
    6993                 :            : 
    6994         [ #  # ]:          0 :   if (!gme)
    6995                 :            :   {
    6996 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Performing THICKEN with volumes containing geometry\n"
                 [ #  # ]
    6997                 :            :                  " from different modeling engines is not allowed.\n"
    6998         [ #  # ]:          0 :                  "Delete uncommon geometry on these volumes before operation.\n\n");
    6999                 :          0 :      return CUBIT_FAILURE;
    7000                 :            :   }
    7001                 :            : 
    7002 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    7003         [ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies );
    7004                 :            : 
    7005 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_sms(count);
    7006 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms(count);
    7007 [ #  # ][ #  # ]:          0 :   CAST_LIST(bridge_list, body_sms, BodySM);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    7008         [ #  # ]:          0 :   CubitStatus result = gme->thicken( body_sms, new_sms, depth, both);
    7009                 :            : 
    7010                 :            :   // check for resued entities, they have been moved and we need to notify observers
    7011 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
    7012                 :            :   int i;
    7013 [ #  # ][ #  # ]:          0 :   for(i=0; i<new_sms.size(); i++)
    7014                 :            :   {
    7015         [ #  # ]:          0 :     BodySM* bodysm = new_sms.get_and_step();
    7016         [ #  # ]:          0 :     DLIList<TopologyBridge*> to_check;
    7017 [ #  # ][ #  # ]:          0 :     DLIList<TopologyBridge*> tmp;
    7018 [ #  # ][ #  # ]:          0 :     DLIList<Surface*> surfs;
    7019         [ #  # ]:          0 :     bodysm->surfaces(surfs);
    7020 [ #  # ][ #  # ]:          0 :     DLIList<Curve*> curves;
    7021         [ #  # ]:          0 :     bodysm->curves(curves);
    7022 [ #  # ][ #  # ]:          0 :     DLIList<TBPoint*> points;
    7023         [ #  # ]:          0 :     bodysm->points(points);
    7024         [ #  # ]:          0 :     to_check.append(bodysm);
    7025 [ #  # ][ #  # ]:          0 :     to_check.append(bodysm->lump());
    7026 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(surfs, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7027         [ #  # ]:          0 :     to_check += tmp;
    7028 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7029         [ #  # ]:          0 :     to_check += tmp;
    7030 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7031         [ #  # ]:          0 :     to_check += tmp;
    7032                 :            : 
    7033                 :            :     int k;
    7034 [ #  # ][ #  # ]:          0 :     for(k=0; k<to_check.size(); k++)
    7035 [ #  # ][ #  # ]:          0 :       if(BridgeManager* m = to_check.get_and_step()->bridge_manager())
                 [ #  # ]
    7036 [ #  # ][ #  # ]:          0 :         if(TopologyEntity* t = m->topology_entity())
    7037 [ #  # ][ #  # ]:          0 :           entities_to_update.append(CAST_TO(t, RefEntity));
    7038                 :            : 
    7039         [ #  # ]:          0 :   }
    7040                 :            : 
    7041 [ #  # ][ #  # ]:          0 :   if (!finish_sm_op(bodies, new_sms, new_bodies))
    7042                 :          0 :     result = CUBIT_FAILURE;
    7043                 :            : 
    7044 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    7045                 :            :   {
    7046 [ #  # ][ #  # ]:          0 :     if( new_bodies.size() )
    7047         [ #  # ]:          0 :       CubitUndo::note_result_bodies( new_bodies );
    7048                 :            :     else
    7049         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    7050                 :            :   }
    7051                 :            : 
    7052                 :            :   // Update graphics
    7053 [ #  # ][ #  # ]:          0 :   while (entities_to_update.size())
    7054                 :            :   {
    7055         [ #  # ]:          0 :     RefEntity* entity = entities_to_update.pop();
    7056 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entity));
         [ #  # ][ #  # ]
    7057                 :            :   }
    7058                 :            : 
    7059         [ #  # ]:          0 :   return result;
    7060                 :            : }
    7061                 :            : 
    7062                 :            : 
    7063                 :          0 : CubitStatus GeometryModifyTool::validate_normals(DLIList<Body*>& bodies,
    7064                 :            :                                                  RefFace *surf_ref,
    7065                 :            :                                                  bool reverse)
    7066                 :            : {
    7067 [ #  # ][ #  # ]:          0 :    if (bodies.size() <= 0)
    7068                 :            :    {
    7069 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("There are no entities in the list. Nothing modified\n");
         [ #  # ][ #  # ]
    7070                 :          0 :       return CUBIT_FAILURE;
    7071                 :            :    }
    7072                 :            : 
    7073         [ #  # ]:          0 :    DLIList<RefEntity*> temp;
    7074 [ #  # ][ #  # ]:          0 :    CAST_LIST_TO_PARENT(bodies, temp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    7075 [ #  # ][ #  # ]:          0 :    if ( !same_modify_engine(temp, CUBIT_TRUE))
    7076                 :            :    {
    7077 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing VALIDATE NORMALS with volumes containing geometry\n"
                 [ #  # ]
    7078                 :            :             "      from different modeling engines is not allowed. Delete uncommon\n"
    7079         [ #  # ]:          0 :             "      geometry on these volumes before operation.\n\n");
    7080                 :          0 :       return CUBIT_FAILURE;
    7081                 :            :    }
    7082                 :            : 
    7083                 :            :    // Get the GeometryEngine for each Body of the list to check
    7084                 :            :    // if they are the same and if they are GeometryModifyEngine
    7085 [ #  # ][ #  # ]:          0 :    GeometryModifyEngine* gePtr1 = get_engine(bodies.get());
    7086                 :            :    GeometryModifyEngine* gePtr2;
    7087                 :          0 :    Body* Body_ptr = NULL;
    7088         [ #  # ]:          0 :    bodies.reset();
    7089 [ #  # ][ #  # ]:          0 :    for( int i = bodies.size(); i > 0; i--)
    7090                 :            :    {
    7091         [ #  # ]:          0 :       Body_ptr = bodies.get_and_step();
    7092         [ #  # ]:          0 :       gePtr2 = get_engine(Body_ptr);
    7093         [ #  # ]:          0 :       if (gePtr1 != gePtr2)
    7094                 :            :       {
    7095 [ #  # ][ #  # ]:          0 :          PRINT_ERROR("In GeometryModifyTool::validate_normals\n"
                 [ #  # ]
    7096         [ #  # ]:          0 :             "  Volumes are associated with different GMEs. \n");
    7097                 :          0 :          return CUBIT_FAILURE;
    7098                 :            :       }
    7099         [ #  # ]:          0 :       if ( gePtr2 == NULL)
    7100                 :            :       {
    7101 [ #  # ][ #  # ]:          0 :          PRINT_ERROR("In GeometryModifyTool::validate_normals\n"
         [ #  # ][ #  # ]
    7102                 :            :             "       Body %d is not associated with a SME.\n",
    7103         [ #  # ]:          0 :             Body_ptr->id());
    7104                 :          0 :          return CUBIT_FAILURE;
    7105                 :            :       }
    7106                 :            :    }
    7107                 :            : 
    7108                 :            : 
    7109 [ #  # ][ #  # ]:          0 :    DLIList<RefFace*> ref_face_list;
    7110 [ #  # ][ #  # ]:          0 :    DLIList<RefFace*> free_face_list;
    7111 [ #  # ][ #  # ]:          0 :    DLIList<RefFace*> bad_face_list;
    7112                 :            : 
    7113                 :            :    //gather all the faces from all the bodies
    7114         [ #  # ]:          0 :    bodies.reset();
    7115 [ #  # ][ #  # ]:          0 :    for( int i=bodies.size(); i--; )
    7116                 :            :    {
    7117         [ #  # ]:          0 :      Body* BodyPtr = bodies.get_and_step();
    7118         [ #  # ]:          0 :      BodyPtr->ref_faces(free_face_list);
    7119                 :            :    }
    7120                 :            : 
    7121                 :            :    RefFace *ref_face_ptr;
    7122                 :            :    RefFace *inter_face_ptr;
    7123                 :            : 
    7124         [ #  # ]:          0 :    if(surf_ref != NULL)   // getting the starting surface
    7125                 :            :    {
    7126                 :          0 :      ref_face_ptr = surf_ref;
    7127                 :            :    }
    7128                 :            :    else
    7129                 :            :    {
    7130         [ #  # ]:          0 :      ref_face_ptr = free_face_list.get_and_step();
    7131                 :            :    }
    7132                 :            : 
    7133         [ #  # ]:          0 :    ref_face_list.append(ref_face_ptr);
    7134         [ #  # ]:          0 :    free_face_list.remove(ref_face_ptr);
    7135         [ #  # ]:          0 :    free_face_list.reset();
    7136                 :            : 
    7137 [ #  # ][ #  # ]:          0 :    while(free_face_list.size())
    7138                 :            :    {
    7139         [ #  # ]:          0 :       DLIList<RefEdge*> curve_list;
    7140         [ #  # ]:          0 :       ref_face_ptr->ref_edges(curve_list);
    7141         [ #  # ]:          0 :       free_face_list.reset();
    7142 [ #  # ][ #  # ]:          0 :       for(int jj=free_face_list.size(); jj > 0; jj--)  // getting a new searching surface
    7143                 :            :       {
    7144         [ #  # ]:          0 :          inter_face_ptr = free_face_list.get_and_step();
    7145         [ #  # ]:          0 :          DLIList<RefEdge*> inter_curve_list;
    7146         [ #  # ]:          0 :          inter_face_ptr->ref_edges(inter_curve_list);
    7147         [ #  # ]:          0 :          curve_list.reset();
    7148                 :            :         // PRINT_INFO("base face %d working on face %d\n", ref_face_ptr->id(),inter_face_ptr->id());
    7149                 :            : 
    7150 [ #  # ][ #  # ]:          0 :          for (int k= curve_list.size(); k > 0; k--)  // looping through all of the surface curves
    7151                 :            :          {
    7152         [ #  # ]:          0 :             RefEdge *ref_check_curve = curve_list.step_and_get();
    7153         [ #  # ]:          0 :             inter_curve_list.reset();
    7154                 :            : 
    7155 [ #  # ][ #  # ]:          0 :             for (int kk = inter_curve_list.size(); kk > 0; kk--)
    7156                 :            :             {
    7157         [ #  # ]:          0 :                RefEdge *check_curve = inter_curve_list.step_and_get();
    7158                 :            : 
    7159         [ #  # ]:          0 :                if(ref_check_curve == check_curve)  // finding if a surface is connected
    7160                 :            :                {
    7161         [ #  # ]:          0 :                   DLIList<CoEdge*> coedge_list;
    7162         [ #  # ]:          0 :                   check_curve->co_edges(coedge_list);
    7163                 :            : 
    7164         [ #  # ]:          0 :                   CoEdge* first_coedge = coedge_list.get_and_step();
    7165         [ #  # ]:          0 :                   CoEdge* second_coedge = coedge_list.get_and_step();
    7166                 :            : 
    7167 [ #  # ][ #  # ]:          0 :                   if((first_coedge->get_sense() == second_coedge->get_sense() &&
         [ #  # ][ #  # ]
    7168 [ #  # ][ #  # ]:          0 :                      !bad_face_list.is_in_list(ref_face_ptr) ) ||
                 [ #  # ]
    7169 [ #  # ][ #  # ]:          0 :                      (first_coedge->get_sense() != second_coedge->get_sense() &&
                 [ #  # ]
    7170         [ #  # ]:          0 :                      bad_face_list.is_in_list(ref_face_ptr) ))    // finding if a surface has a fliped normal
    7171                 :            :                   {
    7172         [ #  # ]:          0 :                      bad_face_list.append(inter_face_ptr);
    7173 [ #  # ][ #  # ]:          0 :                      PRINT_INFO("Surface %d is not consistent\n", inter_face_ptr->id());
         [ #  # ][ #  # ]
                 [ #  # ]
    7174                 :            :                   }
    7175                 :            : 
    7176         [ #  # ]:          0 :                   ref_face_list.append(inter_face_ptr);  // adding to the searched list
    7177 [ #  # ][ #  # ]:          0 :                   free_face_list.remove(inter_face_ptr); // removing from the unsearched list
    7178                 :            :                }
    7179                 :            : 
    7180                 :            :             }
    7181                 :            : 
    7182                 :            :          }
    7183                 :            : 
    7184         [ #  # ]:          0 :       }
    7185                 :            : 
    7186         [ #  # ]:          0 :       ref_face_list.remove(ref_face_ptr);     // removeing from the searched list
    7187         [ #  # ]:          0 :       ref_face_list.last();
    7188 [ #  # ][ #  # ]:          0 :       if(ref_face_list.size() <= 0)
    7189                 :            :       {
    7190 [ #  # ][ #  # ]:          0 :          PRINT_ERROR("In GeometryModifyTool::validate_normals\n"
                 [ #  # ]
    7191         [ #  # ]:          0 :             "       all surfaces must be connected\n");
    7192                 :          0 :          return CUBIT_FAILURE;
    7193                 :            :       }
    7194 [ #  # ][ #  # ]:          0 :       ref_face_ptr = ref_face_list.get();
                 [ #  # ]
    7195                 :          0 :   }
    7196                 :            : 
    7197 [ #  # ][ #  # ]:          0 :   if (reverse && bad_face_list.size())
         [ #  # ][ #  # ]
    7198                 :            :   {
    7199                 :            :      //CubitStatus result = gePtr1->flip_normals(bad_face_list);
    7200 [ #  # ][ #  # ]:          0 :      CubitStatus result = GeometryModifyTool::instance()->reverse(bad_face_list);
    7201         [ #  # ]:          0 :      if ( result == CUBIT_FAILURE )
    7202                 :            :      {
    7203                 :          0 :        return CUBIT_FAILURE;
    7204                 :            :     }
    7205                 :            :   }
    7206 [ #  # ][ #  # ]:          0 :   else if(!bad_face_list.size())
    7207                 :            :   {
    7208 [ #  # ][ #  # ]:          0 :     PRINT_INFO("All surfaces are consistent\n");
         [ #  # ][ #  # ]
    7209                 :            :   }
    7210         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    7211                 :            : }
    7212                 :            : 
    7213                 :            : 
    7214                 :            : 
    7215                 :         86 : CubitStatus GeometryModifyTool::subtract( Body* tool_body, DLIList<Body*> &from_bodies,
    7216                 :            :                                           DLIList<Body*> &new_bodies,
    7217                 :            :                                           bool imprint,
    7218                 :            :                                           bool keep_old )
    7219                 :            : {
    7220         [ +  - ]:         86 :   DLIList<Body*> temp_body_list;
    7221         [ +  - ]:         86 :   temp_body_list.append(tool_body);
    7222 [ +  - ][ +  - ]:         86 :   return subtract(temp_body_list, from_bodies, new_bodies, imprint, keep_old);
    7223                 :            : }
    7224                 :            : 
    7225                 :            : 
    7226                 :         86 : CubitStatus GeometryModifyTool::subtract( DLIList<Body*>  &tool_body_list,
    7227                 :            :                                           DLIList<Body*> &from_bodies,
    7228                 :            :                                           DLIList<Body*> &new_bodies,
    7229                 :            :                                           bool imprint,
    7230                 :            :                                           bool keep_old )
    7231                 :            : {
    7232 [ +  - ][ -  + ]:         86 :    if(tool_body_list.size() == 0 )
    7233                 :          0 :        return CUBIT_FAILURE;
    7234 [ +  - ][ -  + ]:         86 :    if(from_bodies.size() == 0 )
    7235                 :          0 :        return CUBIT_FAILURE;
    7236         [ +  - ]:         86 :    DLIList<Body*> tem_bodies(tool_body_list);
    7237                 :            : 
    7238                 :            :    // cannot subtract from self
    7239         [ +  - ]:         86 :    int old_size = from_bodies.size();
    7240         [ +  - ]:         86 :    from_bodies -= tool_body_list;
    7241 [ +  - ][ -  + ]:         86 :    if (from_bodies.size() != old_size)
    7242                 :            :    {
    7243 [ #  # ][ #  # ]:          0 :      PRINT_WARNING("Cannot subtract body from itself.  Ignoring \"from\" body.\n");
         [ #  # ][ #  # ]
    7244 [ #  # ][ #  # ]:          0 :      if (!from_bodies.size())
    7245                 :          0 :        return CUBIT_FAILURE;
    7246                 :            :    }
    7247                 :            : 
    7248         [ +  - ]:         86 :    tem_bodies += from_bodies;
    7249 [ +  - ][ -  + ]:         86 :    if (!okay_to_modify( tem_bodies, "SUBTRACT" ))
    7250                 :          0 :      return CUBIT_FAILURE;
    7251                 :            : 
    7252 [ +  - ][ +  - ]:        172 :    DLIList<BodySM*> tool_sms(tool_body_list.size());
                 [ +  - ]
    7253 [ +  - ][ +  - ]:        172 :    DLIList<BodySM*> from_sms(from_bodies.size());
                 [ +  - ]
    7254         [ +  - ]:         86 :    GeometryModifyEngine* gme = common_modify_engine( tool_body_list, tool_sms );
    7255         [ +  - ]:         86 :    GeometryModifyEngine* gme2 = common_modify_engine( from_bodies, from_sms );
    7256 [ +  - ][ -  + ]:         86 :    if (!gme || gme != gme2)
    7257                 :            :    {
    7258 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing SUBTRACTION with volumes containing geometry\n"
                 [ #  # ]
    7259                 :            :                   "from different modeling engines is not allowed.\n"
    7260         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    7261                 :          0 :       return CUBIT_FAILURE;
    7262                 :            :    }
    7263                 :            : 
    7264 [ +  - ][ -  + ]:         86 :    if( CubitUndo::get_undo_enabled() )
    7265                 :            :    {
    7266         [ #  # ]:          0 :      if( keep_old )
    7267         [ #  # ]:          0 :        CubitUndo::save_state();
    7268                 :            :      else
    7269                 :            :      {
    7270                 :            :        //Get all the bodies associated with the vertex
    7271         [ #  # ]:          0 :        DLIList<Body*> bodies;
    7272         [ #  # ]:          0 :        bodies += tool_body_list;
    7273         [ #  # ]:          0 :        bodies += from_bodies;
    7274 [ #  # ][ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( bodies );
    7275                 :            :      }
    7276                 :            :    }
    7277                 :            : 
    7278 [ +  - ][ +  - ]:        172 :    DLIList<int> merged_surface_ids;
    7279 [ +  - ][ +  - ]:        172 :    DLIList<int> merged_curve_ids;
    7280         [ +  - ]:         86 :    if( keep_old == CUBIT_FALSE )
    7281         [ +  - ]:         86 :      get_merged_curve_and_surface_ids( from_bodies, merged_surface_ids, merged_curve_ids );
    7282                 :            : 
    7283                 :            : 
    7284                 :            :      // Do the subtract operation
    7285 [ +  - ][ +  - ]:        172 :    DLIList<BodySM*> new_sms;
    7286         [ +  - ]:         86 :    CubitStatus result = gme->subtract(tool_sms, from_sms, new_sms, imprint, keep_old );
    7287                 :            : 
    7288 [ +  - ][ -  + ]:         86 :    if( CubitUndo::get_undo_enabled() && result == CUBIT_FAILURE )
         [ #  # ][ -  + ]
    7289         [ #  # ]:          0 :      CubitUndo::remove_last_undo();
    7290                 :            : 
    7291         [ +  - ]:         86 :    CubitStatus result2 = finish_sm_op(tem_bodies, new_sms, new_bodies);
    7292                 :            : 
    7293 [ +  - ][ -  + ]:         86 :    if( CubitUndo::get_undo_enabled() )
    7294                 :            :    {
    7295         [ #  # ]:          0 :      if( result == CUBIT_SUCCESS )
    7296         [ #  # ]:          0 :        CubitUndo::note_result_bodies( new_bodies );
    7297                 :            :      else
    7298         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    7299                 :            :    }
    7300                 :            : 
    7301 [ +  - ][ -  + ]:         86 :    if ( result == CUBIT_FAILURE || result2 == CUBIT_FAILURE)
    7302                 :            :    {
    7303 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Subtract FAILED\n" );
         [ #  # ][ #  # ]
    7304                 :          0 :      return CUBIT_FAILURE;
    7305                 :            :    }
    7306                 :            : 
    7307         [ +  - ]:         86 :    if( keep_old == CUBIT_FALSE )
    7308         [ +  - ]:         86 :      fixup_merged_entities( merged_surface_ids, merged_curve_ids);
    7309                 :            : 
    7310         [ +  - ]:        172 :    return CUBIT_SUCCESS;
    7311                 :            : }
    7312                 :            : 
    7313                 :          0 : CubitStatus GeometryModifyTool::intersect( DLIList<Body*> &from_bodies,
    7314                 :            :                                            DLIList<Body*> &new_bodies,
    7315                 :            :                                            bool keep_old,
    7316                 :            :                                            bool preview)
    7317                 :            : {
    7318         [ #  # ]:          0 :   DLIList<Body*> tem_bodies = from_bodies;
    7319 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( tem_bodies, "INTERSECT" ))
    7320                 :          0 :     return CUBIT_FAILURE;
    7321                 :            : 
    7322         [ #  # ]:          0 :   GfxPreview::clear();
    7323                 :            : 
    7324 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> from_sm_list(tem_bodies.size());
                 [ #  # ]
    7325         [ #  # ]:          0 :   GeometryModifyEngine* engine = common_modify_engine(tem_bodies, from_sm_list);
    7326         [ #  # ]:          0 :   if ( NULL == engine )
    7327                 :            :   {
    7328 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing INTERSECTION with volumes containing geometry\n"
                 [ #  # ]
    7329                 :            :                 "from different modeling engines is not allowed.\n"
    7330         [ #  # ]:          0 :                 "Delete uncommon geometry on these volumes before operation.\n\n");
    7331                 :          0 :     return CUBIT_FAILURE;
    7332                 :            :   }
    7333                 :            : 
    7334 [ #  # ][ #  # ]:          0 :   if( !preview && CubitUndo::get_undo_enabled() )
         [ #  # ][ #  # ]
    7335                 :            :   {
    7336         [ #  # ]:          0 :     if( keep_old )
    7337         [ #  # ]:          0 :       CubitUndo::save_state();
    7338                 :            :     else
    7339         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( from_bodies );
    7340                 :            :   }
    7341                 :            : 
    7342 [ #  # ][ #  # ]:          0 :   DLIList<int> merged_surface_ids;
    7343 [ #  # ][ #  # ]:          0 :   DLIList<int> merged_curve_ids;
    7344 [ #  # ][ #  # ]:          0 :   if( !preview && (keep_old == CUBIT_FALSE) )
    7345         [ #  # ]:          0 :     get_merged_curve_and_surface_ids( from_bodies, merged_surface_ids, merged_curve_ids );
    7346                 :            : 
    7347 [ #  # ][ #  # ]:          0 :   GeometryModifyEngine* gme_ptr = get_engine(from_sm_list.get());
    7348         [ #  # ]:          0 :   GeometryQueryEngine* gqe_ptr = gme_ptr->get_gqe();
    7349                 :            : 
    7350 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> all_new_bodysms;
    7351                 :            :   int i,j;
    7352 [ #  # ][ #  # ]:          0 :   for( i=0; i<from_sm_list.size(); i++ )
    7353                 :            :   {
    7354         [ #  # ]:          0 :     from_sm_list.reset();
    7355         [ #  # ]:          0 :     from_sm_list.step(i);
    7356         [ #  # ]:          0 :     BodySM *body1 = from_sm_list.get_and_step();
    7357                 :            : 
    7358 [ #  # ][ #  # ]:          0 :     for(j=i+1; j<from_sm_list.size(); j++ )
    7359                 :            :     {
    7360         [ #  # ]:          0 :       BodySM *body2 = from_sm_list.get_and_step();
    7361                 :            : 
    7362         [ #  # ]:          0 :       if( body1 == body2 )
    7363                 :          0 :         continue;
    7364                 :            : 
    7365                 :            :       //copy the bodies
    7366         [ #  # ]:          0 :       BodySM *body1_copy = gme_ptr->copy_body( body1 );
    7367         [ #  # ]:          0 :       BodySM *body2_copy = gme_ptr->copy_body( body2 );
    7368                 :            : 
    7369         [ #  # ]:          0 :       DLIList<BodySM*> tmp_sm_list(1);
    7370         [ #  # ]:          0 :       tmp_sm_list.append( body2_copy );
    7371 [ #  # ][ #  # ]:          0 :       DLIList<BodySM*> new_sms;
                 [ #  # ]
    7372                 :            : 
    7373                 :            :       CubitStatus result =
    7374         [ #  # ]:          0 :           engine->intersect(body1_copy, tmp_sm_list, new_sms, true, preview );
    7375                 :            : 
    7376                 :            :       //delete the copies
    7377         [ #  # ]:          0 :       gqe_ptr->delete_solid_model_entities( body1_copy );
    7378         [ #  # ]:          0 :       gqe_ptr->delete_solid_model_entities( body2_copy );
    7379                 :            : 
    7380         [ #  # ]:          0 :       if (!preview)
    7381                 :            :       {
    7382 [ #  # ][ #  # ]:          0 :         if ( result == CUBIT_FAILURE || new_sms.size() == 0 )
         [ #  # ][ #  # ]
    7383                 :            :         {
    7384 [ #  # ][ #  # ]:          0 :           RefEntity* ref_ent1 = dynamic_cast<RefEntity*>(body1->topology_entity());
    7385 [ #  # ][ #  # ]:          0 :           RefEntity* ref_ent2 = dynamic_cast<RefEntity*>(body2->topology_entity());
    7386                 :            : 
    7387 [ #  # ][ #  # ]:          0 :           PRINT_WARNING("INTERSECTION of %s with %s failed\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    7388                 :            :             ref_ent1->entity_name().c_str(),
    7389         [ #  # ]:          0 :             ref_ent2->entity_name().c_str() );
    7390                 :          0 :           continue;
    7391                 :            : 
    7392                 :            :         }
    7393                 :            : 
    7394 [ #  # ][ #  # ]:          0 :         all_new_bodysms += new_sms;
                 [ #  # ]
    7395                 :            :       }
    7396                 :          0 :     }
    7397                 :            :   }
    7398                 :            : 
    7399         [ #  # ]:          0 :   if (!preview)
    7400                 :            :   {
    7401                 :            :     //now make all the RefEntities
    7402         [ #  # ]:          0 :     all_new_bodysms.reset();
    7403 [ #  # ][ #  # ]:          0 :     for( i=all_new_bodysms.size(); i--; )
    7404                 :            :     {
    7405 [ #  # ][ #  # ]:          0 :       Body *new_body = GeometryQueryTool::instance()->make_Body(all_new_bodysms.get_and_step());
                 [ #  # ]
    7406         [ #  # ]:          0 :       if( new_body )
    7407         [ #  # ]:          0 :         new_bodies.append( new_body );
    7408                 :            :     }
    7409                 :            : 
    7410 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
    7411                 :            :     {
    7412 [ #  # ][ #  # ]:          0 :       if( all_new_bodysms.size() )
    7413         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_bodies );
    7414                 :            :       else
    7415         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
    7416                 :            :     }
    7417                 :            : 
    7418         [ #  # ]:          0 :     if( keep_old == CUBIT_FALSE )
    7419         [ #  # ]:          0 :       fixup_merged_entities( merged_surface_ids, merged_curve_ids);
    7420                 :            :   }
    7421                 :            : 
    7422         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    7423                 :            : }
    7424                 :            : 
    7425                 :            : 
    7426                 :            : 
    7427                 :          0 : CubitStatus GeometryModifyTool::intersect( Body *tool_body_ptr,
    7428                 :            :                                            DLIList<Body*> &from_bodies,
    7429                 :            :                                            DLIList<Body*> &new_bodies,
    7430                 :            :                                            bool keep_old,
    7431                 :            :                                            bool preview)
    7432                 :            : {
    7433         [ #  # ]:          0 :   if(tool_body_ptr == NULL )
    7434                 :          0 :     return CUBIT_FAILURE;
    7435 [ #  # ][ #  # ]:          0 :   if(from_bodies.size() == 0 || from_bodies.get() == NULL )
         [ #  # ][ #  # ]
                 [ #  # ]
    7436                 :          0 :     return CUBIT_FAILURE;
    7437                 :            : 
    7438         [ #  # ]:          0 :   GfxPreview::clear();
    7439                 :            : 
    7440         [ #  # ]:          0 :   DLIList<Body*> tem_bodies = from_bodies;
    7441         [ #  # ]:          0 :   tem_bodies.append( tool_body_ptr );
    7442 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( tem_bodies, "INTERSECT" ))
    7443                 :          0 :     return CUBIT_FAILURE;
    7444                 :            : 
    7445 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> from_sm_list(tem_bodies.size());
                 [ #  # ]
    7446         [ #  # ]:          0 :   GeometryModifyEngine* engine = common_modify_engine(tem_bodies, from_sm_list);
    7447         [ #  # ]:          0 :   if ( NULL == engine )
    7448                 :            :   {
    7449 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing INTERSECTION with volumes containing geometry\n"
                 [ #  # ]
    7450                 :            :                 "from different modeling engines is not allowed.\n"
    7451         [ #  # ]:          0 :                 "Delete uncommon geometry on these volumes before operation.\n\n");
    7452                 :          0 :     return CUBIT_FAILURE;
    7453                 :            :   }
    7454                 :            : 
    7455         [ #  # ]:          0 :   BodySM* tool_sm = from_sm_list.pop();
    7456                 :            : 
    7457                 :            : 
    7458                 :            :   //cannot intersect tool with itself
    7459         [ #  # ]:          0 :   from_sm_list.remove_all_with_value( tool_sm );
    7460 [ #  # ][ #  # ]:          0 :   if( from_sm_list.size() == 0 )
    7461                 :            :   {
    7462 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot intersect volume %d from itself\n",
         [ #  # ][ #  # ]
                 [ #  # ]
    7463         [ #  # ]:          0 :                  tool_body_ptr->ref_volume()->id() );
    7464                 :          0 :     return CUBIT_FAILURE;
    7465                 :            :   }
    7466                 :            : 
    7467 [ #  # ][ #  # ]:          0 :   if( !preview && CubitUndo::get_undo_enabled() )
         [ #  # ][ #  # ]
    7468                 :            :   {
    7469         [ #  # ]:          0 :     if( keep_old )
    7470         [ #  # ]:          0 :       CubitUndo::save_state();
    7471                 :            :     else
    7472                 :            :     {
    7473         [ #  # ]:          0 :       DLIList<Body*> bodies;
    7474         [ #  # ]:          0 :       bodies.append( tool_body_ptr );
    7475         [ #  # ]:          0 :       bodies += from_bodies;
    7476 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( bodies );
    7477                 :            :     }
    7478                 :            :   }
    7479                 :            : 
    7480 [ #  # ][ #  # ]:          0 :   DLIList<int> merged_surface_ids;
    7481 [ #  # ][ #  # ]:          0 :   DLIList<int> merged_curve_ids;
    7482 [ #  # ][ #  # ]:          0 :   if( !preview && (keep_old == CUBIT_FALSE) )
    7483         [ #  # ]:          0 :     get_merged_curve_and_surface_ids( from_bodies, merged_surface_ids, merged_curve_ids );
    7484                 :            : 
    7485                 :            :      // Do the intersect operation
    7486 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_sms;
    7487                 :            :   CubitStatus result =
    7488         [ #  # ]:          0 :       engine->intersect(tool_sm, from_sm_list, new_sms, keep_old, preview );
    7489                 :            : 
    7490         [ #  # ]:          0 :   if (!preview)
    7491                 :            :   {
    7492         [ #  # ]:          0 :     result = finish_sm_op(tem_bodies, new_sms, new_bodies);
    7493                 :            : 
    7494 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
    7495                 :            :     {
    7496         [ #  # ]:          0 :       if( result == CUBIT_SUCCESS )
    7497         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_bodies );
    7498                 :            :       else
    7499         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
    7500                 :            :     }
    7501                 :            : 
    7502         [ #  # ]:          0 :     if ( result == CUBIT_FAILURE )
    7503                 :            :     {
    7504 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Intersect FAILED\n" );
         [ #  # ][ #  # ]
    7505                 :          0 :       return CUBIT_FAILURE;
    7506                 :            :     }
    7507                 :            : 
    7508         [ #  # ]:          0 :     if( keep_old == CUBIT_FALSE )
    7509         [ #  # ]:          0 :       fixup_merged_entities( merged_surface_ids, merged_curve_ids);
    7510                 :            :   }
    7511                 :            : 
    7512         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    7513                 :            : }
    7514                 :            : 
    7515                 :         31 : CubitStatus GeometryModifyTool::imprint( DLIList<Body*> &from_body_list,
    7516                 :            :                                          DLIList<Body*> &new_body_list,
    7517                 :            :                                          CubitBoolean keep_old )
    7518                 :            : {
    7519 [ +  - ][ -  + ]:         31 :   if( from_body_list.size() == 1 )
    7520                 :            :   {
    7521 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("Need more than 1 body or volume to imprint.\n");
         [ #  # ][ #  # ]
    7522                 :          0 :     return CUBIT_FAILURE;
    7523                 :            :   }
    7524                 :            : 
    7525 [ +  - ][ -  + ]:         31 :    if (get_group_imprint() == CUBIT_FALSE)
    7526                 :            :    {
    7527         [ #  # ]:          0 :      CubitStatus result = imprint_singly( from_body_list, new_body_list, keep_old );
    7528                 :          0 :      return result;
    7529                 :            :    }
    7530                 :            : 
    7531                 :            :      // Check the GeometryEngine for each of the Body's; check to
    7532                 :            :      // make sure they're all the same
    7533         [ +  - ]:         31 :    from_body_list.reset();
    7534 [ +  - ][ -  + ]:         31 :    if (!okay_to_modify( from_body_list, "IMPRINT" ))
    7535                 :          0 :      return CUBIT_FAILURE;
    7536                 :            : 
    7537                 :            :      //Check for repeats in each individual list and for overlap
    7538                 :            :      //between the two lists.
    7539         [ +  - ]:         31 :    from_body_list.uniquify_ordered();
    7540                 :            : 
    7541 [ +  - ][ +  - ]:         62 :    DLIList<BodySM*> from_sms(from_body_list.size()), new_sms;
         [ +  - ][ +  - ]
    7542         [ +  - ]:         31 :    GeometryModifyEngine* gePtr1 = common_modify_engine(from_body_list, from_sms);
    7543         [ -  + ]:         31 :    if ( !gePtr1 )
    7544                 :            :    {
    7545 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing IMPRINT with volumes containing geometry\n"
                 [ #  # ]
    7546                 :            :                   "from different modeling engines is not allowed.\n"
    7547         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    7548                 :          0 :       return CUBIT_FAILURE;
    7549                 :            :    }
    7550                 :            : 
    7551 [ +  - ][ -  + ]:         31 :    if( CubitUndo::get_undo_enabled() )
    7552                 :            :    {
    7553         [ #  # ]:          0 :      if( keep_old )
    7554         [ #  # ]:          0 :        CubitUndo::save_state();
    7555                 :            :      else
    7556         [ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( from_body_list );
    7557                 :            :    }
    7558                 :            : 
    7559                 :         31 :    int process_composites = 0;
    7560 [ +  - ][ -  + ]:         31 :    if(contains_composites(from_body_list))
    7561                 :          0 :      process_composites = 1;
    7562                 :            : 
    7563         [ -  + ]:         31 :    if(process_composites)
    7564                 :            :    {
    7565                 :            :       // Push virtual attributes down to solid model topology before
    7566                 :            :       // doing the imprint.
    7567         [ #  # ]:          0 :       do_attribute_setup();
    7568         [ #  # ]:          0 :       push_attributes_before_modify(from_sms);
    7569                 :            :       // This must be done after pushing the vg atts because it uses them.
    7570         [ #  # ]:          0 :       DLIList<TopologyBridge*> tb_list;
    7571 [ #  # ][ #  # ]:          0 :       CAST_LIST(from_sms, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7572         [ #  # ]:          0 :       push_named_attributes_to_curves_and_points(tb_list, "IMPRINTER");
    7573 [ #  # ][ #  # ]:          0 :       push_named_attributes_to_curves_and_points(tb_list, "ORIGINAL");
    7574                 :            :    }
    7575                 :            : 
    7576         [ +  - ]:         31 :    CubitStatus result =  gePtr1->imprint(from_sms, new_sms, keep_old);
    7577                 :            : 
    7578                 :            :    int i, j;
    7579         [ -  + ]:         31 :    if(process_composites)
    7580                 :            :    {
    7581         [ #  # ]:          0 :      if(result == CUBIT_SUCCESS)
    7582                 :            :      {
    7583                 :            :         // Analyze the results and adjust virtual attributes as necessary.
    7584         [ #  # ]:          0 :        DLIList<TopologyBridge*> tb_list;
    7585 [ #  # ][ #  # ]:          0 :        CAST_LIST(new_sms, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7586 [ #  # ][ #  # ]:          0 :         GeometryQueryTool::instance()->ige_attribute_after_imprinting(tb_list, from_body_list);
    7587                 :            : 
    7588                 :            :         // Clean up attributes.
    7589         [ #  # ]:          0 :         remove_imprint_attributes_after_modify(from_sms, new_sms);
    7590                 :            : 
    7591                 :            :         // Restore the virtual geometry.
    7592 [ #  # ][ #  # ]:          0 :         restore_vg_after_modify(new_sms, from_body_list, gePtr1);
    7593                 :            :      }
    7594         [ #  # ]:          0 :      remove_pushed_attributes(new_sms, from_body_list);
    7595                 :            :    }
    7596                 :            : 
    7597 [ +  - ][ +  - ]:         31 :    if (get_old_names() == CUBIT_FALSE)
    7598                 :            :    {
    7599 [ +  - ][ -  + ]:         31 :      if (!finish_sm_op(from_body_list, new_sms, new_body_list))
    7600                 :          0 :        result = CUBIT_FAILURE;
    7601                 :            : 
    7602 [ +  - ][ -  + ]:         31 :      if( CubitUndo::get_undo_enabled() )
    7603                 :            :      {
    7604         [ #  # ]:          0 :        if( result == CUBIT_SUCCESS )
    7605         [ #  # ]:          0 :          CubitUndo::note_result_bodies( new_body_list );
    7606                 :            :        else
    7607         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    7608                 :            :      }
    7609                 :            : 
    7610         [ -  + ]:         31 :      if(process_composites)
    7611         [ #  # ]:          0 :        do_attribute_cleanup();
    7612                 :            : 
    7613                 :         31 :      return result;
    7614                 :            :    }
    7615                 :            : 
    7616         [ #  # ]:          0 :    if(process_composites)
    7617         [ #  # ]:          0 :      do_attribute_cleanup();
    7618                 :            : 
    7619                 :            :    // If old_names is true, need to make sure things are deleted in
    7620                 :            :    // the correct order so that entities get the same @A type extension
    7621                 :            :    // on their names.
    7622                 :            : 
    7623                 :            :    // Update existing bodies.
    7624         [ #  # ]:          0 :    from_body_list.reset();
    7625 [ #  # ][ #  # ]:          0 :    for (i = from_body_list.size(); i--; )
    7626                 :            :    {
    7627         [ #  # ]:          0 :      Body* body = from_body_list.get();
    7628         [ #  # ]:          0 :      BodySM* body_sm = body->get_body_sm_ptr();
    7629         [ #  # ]:          0 :      if (!body_sm)
    7630                 :            :      {
    7631 [ #  # ][ #  # ]:          0 :        GeometryQueryTool::instance()->destroy_dead_entity(body);
    7632         [ #  # ]:          0 :        from_body_list.change_to(0);
    7633                 :            :      }
    7634                 :            :      else
    7635                 :            :      {
    7636 [ #  # ][ #  # ]:          0 :        remove_dead_entity_names(body);
    7637 [ #  # ][ #  # ]:          0 :        GeometryQueryTool::instance()->make_Body(body_sm);
    7638                 :            :      }
    7639         [ #  # ]:          0 :      from_body_list.step();
    7640                 :            :    }
    7641                 :            : 
    7642                 :            :       // Construct new bodies
    7643         [ #  # ]:          0 :    new_sms.reset();
    7644 [ #  # ][ #  # ]:          0 :    for (j = new_sms.size(); j--; )
    7645                 :            :    {
    7646         [ #  # ]:          0 :      BodySM* body_sm = new_sms.get_and_step();
    7647 [ #  # ][ #  # ]:          0 :      Body* body = GeometryQueryTool::instance()->make_Body(body_sm);
    7648         [ #  # ]:          0 :      new_body_list.append(body);
    7649                 :            :    }
    7650 [ #  # ][ #  # ]:          0 :    GeometryQueryTool::instance()->cleanout_deactivated_geometry();
    7651                 :            : 
    7652 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    7653                 :            :    {
    7654         [ #  # ]:          0 :      if( result == CUBIT_SUCCESS )
    7655         [ #  # ]:          0 :        CubitUndo::note_result_bodies( new_body_list );
    7656                 :            :      else
    7657         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    7658                 :            :    }
    7659                 :            : 
    7660         [ +  - ]:         31 :    return result;
    7661                 :            : }
    7662                 :            : 
    7663                 :         11 : CubitStatus GeometryModifyTool::scale( Body *&body,
    7664                 :            :                                       const CubitVector& point,
    7665                 :            :                                        const CubitVector& factors,
    7666                 :            :                                        bool check_to_transform,
    7667                 :            :                                        bool preview /*=false*/,
    7668                 :            :                                        bool reset_preview /*true*/)
    7669                 :            : {
    7670         [ +  - ]:         11 :   if( check_to_transform )
    7671 [ +  - ][ +  - ]:         11 :     if (!GeometryQueryTool::instance()->okay_to_transform( body ))
                 [ -  + ]
    7672                 :          0 :       return CUBIT_FAILURE;
    7673                 :            : 
    7674         [ +  - ]:         11 :   DLIList<Body*> body_list;
    7675         [ +  - ]:         11 :   body_list.append(body);
    7676 [ +  - ][ -  + ]:         11 :   if (!okay_to_modify( body_list, "NON_UNIFORM_SCALE" ))
    7677                 :          0 :     return CUBIT_FAILURE;
    7678                 :            : 
    7679         [ +  - ]:         11 :   if(reset_preview)
    7680         [ +  - ]:         11 :     GfxPreview::clear();
    7681                 :            : 
    7682         [ -  + ]:         11 :   if (preview)
    7683                 :            :   {
    7684         [ #  # ]:          0 :     DLIList<RefEdge*> edges;
    7685         [ #  # ]:          0 :     body->ref_edges(edges);
    7686                 :            : 
    7687                 :            :     //set up the matrices
    7688 [ #  # ][ #  # ]:          0 :     CubitTransformMatrix pre_mat, scale_mat, post_mat;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7689 [ #  # ][ #  # ]:          0 :     pre_mat.translate(-point);    
    7690         [ #  # ]:          0 :     scale_mat.scale_about_origin(factors);   
    7691         [ #  # ]:          0 :     post_mat.translate(point);
    7692                 :            : 
    7693 [ #  # ][ #  # ]:          0 :     for (int i = 0; i < edges.size(); i++)
    7694                 :            :     {
    7695         [ #  # ]:          0 :       GMem poly;
    7696                 :            : 
    7697 [ #  # ][ #  # ]:          0 :       if( CUBIT_SUCCESS == edges[i]->get_graphics(poly) )
                 [ #  # ]
    7698                 :            :       {
    7699         [ #  # ]:          0 :         poly.transform(pre_mat);
    7700         [ #  # ]:          0 :         poly.transform(scale_mat);
    7701         [ #  # ]:          0 :         poly.transform(post_mat);
    7702 [ #  # ][ #  # ]:          0 :         GfxPreview::draw_polyline(poly.point_list(), poly.point_list_size(), CUBIT_BLUE_INDEX);
                 [ #  # ]
    7703                 :            :       }
    7704 [ #  # ][ #  # ]:          0 :       else if( edges[i]->start_vertex() == edges[i]->end_vertex() )
         [ #  # ][ #  # ]
                 [ #  # ]
    7705                 :            :       {       
    7706 [ #  # ][ #  # ]:          0 :         CubitVector tmp_pt = edges[i]->start_vertex()->coordinates();
                 [ #  # ]
    7707 [ #  # ][ #  # ]:          0 :         tmp_pt = pre_mat*tmp_pt;
    7708 [ #  # ][ #  # ]:          0 :         tmp_pt = scale_mat*tmp_pt;
    7709 [ #  # ][ #  # ]:          0 :         tmp_pt = post_mat*tmp_pt;          
    7710         [ #  # ]:          0 :         GfxPreview::draw_point( tmp_pt, CUBIT_BLUE_INDEX);
    7711                 :            :       }      
    7712         [ #  # ]:          0 :     }
    7713         [ #  # ]:          0 :     GfxPreview::flush();
    7714         [ #  # ]:          0 :     return CUBIT_SUCCESS;
    7715                 :            :   }
    7716                 :            : 
    7717         [ +  - ]:         11 :   do_attribute_setup();
    7718                 :            : 
    7719         [ +  - ]:         11 :   BodySM* bodysm = body->get_body_sm_ptr();
    7720 [ +  - ][ +  - ]:         22 :   DLIList<BodySM*> body_sm_list;
    7721         [ +  - ]:         11 :   body_sm_list.append(bodysm);
    7722                 :            : 
    7723         [ +  - ]:         11 :   push_attributes_before_modify(body_sm_list);
    7724                 :            : 
    7725         [ +  - ]:         11 :   GeometryModifyEngine* engine = get_engine( bodysm );
    7726                 :            :   CubitStatus result;
    7727         [ -  + ]:         11 :   if( !engine )
    7728                 :            :   {
    7729         [ #  # ]:          0 :     GeometryQueryEngine* tmp_engine = bodysm->get_geometry_query_engine();
    7730 [ #  # ][ #  # ]:          0 :     result = tmp_engine->translate( bodysm, -point );
    7731         [ #  # ]:          0 :     result = tmp_engine->scale( bodysm, factors );
    7732         [ #  # ]:          0 :     result = tmp_engine->translate( bodysm, point );
    7733                 :            : 
    7734                 :            :   }
    7735                 :            :   else
    7736                 :            :   {
    7737         [ +  - ]:         11 :     GeometryQueryEngine* tmp_engine = bodysm->get_geometry_query_engine();
    7738 [ +  - ][ +  - ]:         11 :     result = tmp_engine->translate( bodysm, -point );
    7739         [ +  - ]:         11 :     result = engine->scale( bodysm, factors );
    7740         [ +  - ]:         11 :     result = tmp_engine->translate( bodysm, point );
    7741                 :            :   }
    7742                 :            : 
    7743                 :            :   // The bodysm pointer may get changed depending on the underlying
    7744                 :            :   // engine.  Make sure to put the most current pointer in the list
    7745                 :            :   // for further processing.
    7746         [ +  - ]:         11 :   body_sm_list.clean_out();
    7747         [ +  - ]:         11 :   body_sm_list.append(bodysm);
    7748                 :            :   // The old body will probably have stale data at this point
    7749                 :            :   // so don't send it down for further processing.
    7750         [ +  - ]:         11 :   body_list.clean_out();
    7751                 :            : 
    7752         [ +  - ]:         11 :   restore_vg_after_modify( body_sm_list, body_list, engine );
    7753         [ +  - ]:         11 :   remove_pushed_attributes( body_sm_list, body_list );
    7754                 :            : 
    7755                 :            :   //for non-uniform scaling, topology can change...need to update stuff
    7756 [ +  - ][ +  - ]:         33 :   if( factors.x() != factors.y() ||
         [ +  - ][ -  + ]
    7757 [ +  - ][ +  - ]:         22 :       factors.y() != factors.z() ||
         [ +  - ][ -  + ]
    7758 [ +  - ][ +  - ]:         11 :       factors.z() != factors.x() )
    7759 [ #  # ][ #  # ]:          0 :     body = GeometryQueryTool::instance()->make_Body(bodysm);
    7760                 :            : 
    7761         [ +  - ]:         11 :   do_attribute_cleanup();
    7762                 :            : 
    7763         [ +  - ]:         11 :   if (result)
    7764                 :            :   {
    7765                 :            : 
    7766         [ +  - ]:         11 :     CubitTransformMatrix pre_mat;
    7767 [ +  - ][ +  - ]:         11 :     pre_mat.translate(-point);
    7768                 :            : 
    7769 [ +  - ][ +  - ]:         22 :     CubitTransformMatrix scale_mat;
    7770         [ +  - ]:         11 :     scale_mat.scale_about_origin(factors);
    7771                 :            : 
    7772 [ +  - ][ +  - ]:         22 :     CubitTransformMatrix post_mat;
    7773         [ +  - ]:         11 :     post_mat.translate(point);
    7774 [ +  - ][ +  - ]:         11 :     GeometryQueryTool::instance()->notify_intermediate_of_transform( body, pre_mat );
    7775 [ +  - ][ +  - ]:         11 :     GeometryQueryTool::instance()->notify_intermediate_of_transform( body, scale_mat );
    7776 [ +  - ][ +  - ]:         11 :     GeometryQueryTool::instance()->notify_intermediate_of_transform( body, post_mat );
    7777 [ +  - ][ +  - ]:         22 :     GeometryQueryTool::instance()->notify_observers_of_transform( body );
         [ +  - ][ +  - ]
    7778                 :            :   }
    7779                 :            :   else
    7780 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Scale of %s (%s %d) failed.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7781         [ #  # ]:          0 :       body->entity_name().c_str(), body->class_name(), body->id() );
    7782                 :            : 
    7783         [ +  - ]:         11 :   return result;
    7784                 :            : }
    7785                 :            : 
    7786                 :            : 
    7787                 :            : 
    7788                 :          0 : CubitStatus GeometryModifyTool::imprint_singly( DLIList<Body*> &from_body_list,
    7789                 :            :                                                 DLIList<Body*> &new_body_list,
    7790                 :            :                                                 CubitBoolean keep_old )
    7791                 :            : {
    7792                 :            : 
    7793                 :            :      // Check the GeometryEngine for each of the Body's; check to
    7794                 :            :      // make sure they're all the same
    7795         [ #  # ]:          0 :    from_body_list.reset();
    7796 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( from_body_list, "IMPRINT" ))
    7797                 :          0 :      return CUBIT_FAILURE;
    7798                 :            : 
    7799                 :            :      //Check for repeats in each individual list and for overlap
    7800                 :            :      //between the two lists.
    7801         [ #  # ]:          0 :    from_body_list.uniquify_ordered();
    7802                 :            : 
    7803 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> from_sms(from_body_list.size());
    7804         [ #  # ]:          0 :    GeometryModifyEngine* gePtr1 = common_modify_engine(from_body_list, from_sms);
    7805         [ #  # ]:          0 :    if ( !gePtr1 )
    7806                 :            :    {
    7807 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing IMPRINT with volumes containing geometry\n"
                 [ #  # ]
    7808                 :            :                   "from different modeling engines is not allowed.\n"
    7809         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    7810                 :          0 :       return CUBIT_FAILURE;
    7811                 :            :    }
    7812                 :            : 
    7813                 :          0 :    CubitBoolean reset_new_ids = CUBIT_FALSE;
    7814 [ #  # ][ #  # ]:          0 :    if (get_new_ids() == CUBIT_FALSE) {
    7815 [ #  # ][ #  # ]:          0 :      PRINT_WARNING("New ids must be TRUE when group imprint FALSE; "
                 [ #  # ]
    7816         [ #  # ]:          0 :                    "setting new ids TRUE for this operation only.\n");
    7817         [ #  # ]:          0 :      set_new_ids(CUBIT_TRUE);
    7818                 :          0 :      reset_new_ids = CUBIT_TRUE;
    7819                 :            :    }
    7820                 :            : 
    7821                 :            :      // do the imprinting; bounding box should be checked in
    7822                 :            :      // SMEEngine function
    7823         [ #  # ]:          0 :    new_body_list = from_body_list;
    7824         [ #  # ]:          0 :    GeometryQueryTool* gqt = GeometryQueryTool::instance();
    7825                 :            : 
    7826 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    7827                 :            :    {
    7828         [ #  # ]:          0 :      if( keep_old )
    7829         [ #  # ]:          0 :        CubitUndo::save_state();
    7830                 :            :      else
    7831         [ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( from_body_list );
    7832                 :            :    }
    7833                 :            : 
    7834                 :            :    int i;
    7835 [ #  # ][ #  # ]:          0 :    for (i = 0; i < new_body_list.size(); i++) {
    7836 [ #  # ][ #  # ]:          0 :      for (int j = 1; j < new_body_list.size()-i; j++) {
    7837         [ #  # ]:          0 :        new_body_list.reset();
    7838         [ #  # ]:          0 :        new_body_list.step(i);
    7839         [ #  # ]:          0 :        Body *body_1 = new_body_list.get();
    7840         [ #  # ]:          0 :        Body *body_2 = new_body_list.next(j);
    7841                 :          0 :        Body *newBodyPtr1 = NULL;
    7842                 :          0 :        Body *newBodyPtr2 = NULL;
    7843                 :            : 
    7844         [ #  # ]:          0 :        if (body_1 == body_2) {
    7845 [ #  # ][ #  # ]:          0 :          PRINT_WARNING("Can't imprint a volume with itself.\n");
         [ #  # ][ #  # ]
    7846                 :            : 
    7847 [ #  # ][ #  # ]:          0 :          if (reset_new_ids == CUBIT_TRUE) set_new_ids(CUBIT_FALSE);
    7848                 :            : 
    7849                 :          0 :          return CUBIT_FAILURE;
    7850                 :            :        }
    7851                 :            : 
    7852                 :            :        BodySM *new_sm_1, *new_sm_2;
    7853                 :            :        CubitStatus status = gePtr1->imprint(body_1->get_body_sm_ptr(),
    7854                 :            :                                             body_2->get_body_sm_ptr(),
    7855                 :            :                                             new_sm_1, new_sm_2,
    7856 [ #  # ][ #  # ]:          0 :                                             keep_old);
                 [ #  # ]
    7857                 :            : 
    7858 [ #  # ][ #  # ]:          0 :        if ( status != CUBIT_FAILURE &&
    7859         [ #  # ]:          0 :             (new_sm_1 != NULL ||
    7860                 :          0 :              new_sm_2 != NULL) )
    7861                 :            :        {
    7862         [ #  # ]:          0 :          from_body_list.reset();
    7863         [ #  # ]:          0 :          from_body_list.step(i);
    7864                 :            : 
    7865                 :            :            //put the new ones in the new list and
    7866                 :            :            //remove the olds ones.
    7867         [ #  # ]:          0 :          if ( new_sm_1 != NULL )
    7868                 :            :          {
    7869 [ #  # ][ #  # ]:          0 :            if (!body_1->get_body_sm_ptr())
    7870         [ #  # ]:          0 :              gqt->destroy_dead_entity(body_1);
    7871         [ #  # ]:          0 :            newBodyPtr1 = gqt->make_Body(new_sm_1);
    7872         [ #  # ]:          0 :            new_body_list.change_to(newBodyPtr1);
    7873         [ #  # ]:          0 :            from_body_list.change_to(0);
    7874                 :            :          }
    7875                 :            :          else
    7876 [ #  # ][ #  # ]:          0 :            gqt->make_Body(body_1->get_body_sm_ptr());
    7877                 :            : 
    7878         [ #  # ]:          0 :          new_body_list.step(j);
    7879         [ #  # ]:          0 :          from_body_list.step(j);
    7880         [ #  # ]:          0 :          if ( new_sm_2 != NULL )
    7881                 :            :          {
    7882 [ #  # ][ #  # ]:          0 :            if (!body_2->get_body_sm_ptr())
    7883         [ #  # ]:          0 :              gqt->destroy_dead_entity(body_2);
    7884         [ #  # ]:          0 :            newBodyPtr2 = gqt->make_Body(new_sm_2);
    7885         [ #  # ]:          0 :            new_body_list.change_to(newBodyPtr2);
    7886         [ #  # ]:          0 :            from_body_list.change_to(NULL);
    7887                 :            :          }
    7888                 :            :          else
    7889 [ #  # ][ #  # ]:          0 :            gqt->make_Body(body_2->get_body_sm_ptr());
    7890                 :            :        }
    7891         [ #  # ]:          0 :        gqt->cleanout_deactivated_geometry();
    7892                 :            :      }
    7893                 :            :    }
    7894                 :            : 
    7895         [ #  # ]:          0 :    from_body_list.remove_all_with_value(NULL);
    7896                 :            :    Body *temp_body;
    7897 [ #  # ][ #  # ]:          0 :    for (i = from_body_list.size(); i > 0; i--)
    7898                 :            :    {
    7899         [ #  # ]:          0 :      temp_body = from_body_list.get_and_step();
    7900 [ #  # ][ #  # ]:          0 :      while (new_body_list.move_to(temp_body)) new_body_list.remove();
                 [ #  # ]
    7901                 :            :    }
    7902                 :            : 
    7903 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    7904                 :            :    {
    7905 [ #  # ][ #  # ]:          0 :      if( new_body_list.size() )
    7906         [ #  # ]:          0 :        CubitUndo::note_result_bodies( new_body_list );
    7907                 :            :      else
    7908         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    7909                 :            :    }
    7910                 :            : 
    7911 [ #  # ][ #  # ]:          0 :    PRINT_INFO("\n");
         [ #  # ][ #  # ]
    7912 [ #  # ][ #  # ]:          0 :    if( DEBUG_FLAG( 153 ) )
                 [ #  # ]
    7913                 :            :    {
    7914 [ #  # ][ #  # ]:          0 :      PRINT_INFO( "  New Body(ies) created:");
         [ #  # ][ #  # ]
    7915         [ #  # ]:          0 :      new_body_list.reset();
    7916 [ #  # ][ #  # ]:          0 :      for (i = 0; i < new_body_list.size(); i++)
    7917                 :            :      {
    7918 [ #  # ][ #  # ]:          0 :        if (i != 0) PRINT_INFO( ",");
         [ #  # ][ #  # ]
                 [ #  # ]
    7919 [ #  # ][ #  # ]:          0 :        PRINT_INFO( " %d", new_body_list.get_and_step()->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7920                 :            :      }
    7921 [ #  # ][ #  # ]:          0 :      PRINT_INFO("\n");
         [ #  # ][ #  # ]
    7922 [ #  # ][ #  # ]:          0 :      PRINT_INFO( "  Original Body(ies) retained:");
         [ #  # ][ #  # ]
    7923         [ #  # ]:          0 :      from_body_list.reset();
    7924 [ #  # ][ #  # ]:          0 :      for (i = 0; i < from_body_list.size(); i++)
    7925                 :            :      {
    7926 [ #  # ][ #  # ]:          0 :        if (i != 0) PRINT_INFO( ",");
         [ #  # ][ #  # ]
                 [ #  # ]
    7927 [ #  # ][ #  # ]:          0 :        PRINT_INFO( " %d", from_body_list.get_and_step()->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7928                 :            :      }
    7929 [ #  # ][ #  # ]:          0 :      PRINT_INFO("\n");
         [ #  # ][ #  # ]
    7930                 :            :    }
    7931                 :            : 
    7932 [ #  # ][ #  # ]:          0 :    PRINT_INFO( "  New Volume(s) created:");
         [ #  # ][ #  # ]
    7933         [ #  # ]:          0 :    new_body_list.reset();
    7934 [ #  # ][ #  # ]:          0 :    DLIList<RefVolume*> new_vol_list;
    7935 [ #  # ][ #  # ]:          0 :    for (i = 0; i < new_body_list.size(); i++)
    7936                 :            :    {
    7937         [ #  # ]:          0 :      DLIList<RefVolume*> t2;
    7938 [ #  # ][ #  # ]:          0 :      new_body_list.get_and_step()->ref_volumes( t2 );
    7939         [ #  # ]:          0 :      new_vol_list += t2;
    7940         [ #  # ]:          0 :    }
    7941                 :            : 
    7942 [ #  # ][ #  # ]:          0 :    for( i = 0; i < new_vol_list.size(); i++ )
    7943                 :            :    {
    7944 [ #  # ][ #  # ]:          0 :      if (i != 0) PRINT_INFO( ",");
         [ #  # ][ #  # ]
                 [ #  # ]
    7945 [ #  # ][ #  # ]:          0 :      PRINT_INFO( " %d", new_vol_list.get_and_step()->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7946                 :            :    }
    7947 [ #  # ][ #  # ]:          0 :    PRINT_INFO("\n");
         [ #  # ][ #  # ]
    7948                 :            : 
    7949 [ #  # ][ #  # ]:          0 :    PRINT_INFO( "  Original Volume(s) retained:");
         [ #  # ][ #  # ]
    7950         [ #  # ]:          0 :    from_body_list.reset();
    7951 [ #  # ][ #  # ]:          0 :    DLIList<RefVolume*> from_vol_list;
    7952 [ #  # ][ #  # ]:          0 :    for (i = 0; i < from_body_list.size(); i++)
    7953                 :            :    {
    7954         [ #  # ]:          0 :      DLIList<RefVolume*> t2;
    7955 [ #  # ][ #  # ]:          0 :      from_body_list.get_and_step()->ref_volumes( t2 );
    7956         [ #  # ]:          0 :      from_vol_list += t2;
    7957         [ #  # ]:          0 :    }
    7958                 :            : 
    7959 [ #  # ][ #  # ]:          0 :    for( i = 0; i < from_vol_list.size(); i++ )
    7960                 :            :    {
    7961 [ #  # ][ #  # ]:          0 :      if (i != 0) PRINT_INFO( ",");
         [ #  # ][ #  # ]
                 [ #  # ]
    7962 [ #  # ][ #  # ]:          0 :      PRINT_INFO( " %d", from_vol_list.get_and_step()->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7963                 :            :    }
    7964 [ #  # ][ #  # ]:          0 :    PRINT_INFO("\n");
         [ #  # ][ #  # ]
    7965                 :            : 
    7966 [ #  # ][ #  # ]:          0 :    if (reset_new_ids) set_new_ids(CUBIT_FALSE);
    7967                 :            : 
    7968         [ #  # ]:          0 :    return CUBIT_SUCCESS;
    7969                 :            : }
    7970                 :            : 
    7971                 :            : 
    7972                 :          0 : CubitStatus GeometryModifyTool::imprint( DLIList<Body*> &body_list,
    7973                 :            :                                          DLIList<RefEdge*> &ref_edge_list,
    7974                 :            :                                          DLIList<Body*>& new_body_list,
    7975                 :            :                                          CubitBoolean keep_old_body,
    7976                 :            :                                          CubitBoolean show_messages)
    7977                 :            : {
    7978                 :            :   // Check the GeometryEngine for each of the bodies; check to
    7979                 :            :   // make sure they're all the same
    7980         [ #  # ]:          0 :   body_list.reset();
    7981                 :            :   int i;
    7982                 :            : 
    7983 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( body_list, "IMPRINT" ))
    7984                 :          0 :     return CUBIT_FAILURE;
    7985                 :            : 
    7986 [ #  # ][ #  # ]:          0 :   const int count = body_list.size() + ref_edge_list.size();
    7987         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
    7988 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(count);
    7989 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(body_list, entity_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7990         [ #  # ]:          0 :   ref_edge_list.reset();
    7991 [ #  # ][ #  # ]:          0 :   for (i = ref_edge_list.size(); i--;)
    7992 [ #  # ][ #  # ]:          0 :     entity_list.append(ref_edge_list.get_and_step());
    7993                 :            : 
    7994         [ #  # ]:          0 :   GeometryModifyEngine* gePtr1 = common_modify_engine(entity_list, bridge_list);
    7995                 :            : 
    7996 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sm_list(body_list.size());
                 [ #  # ]
    7997 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
                 [ #  # ]
    7998 [ #  # ][ #  # ]:          0 :   CAST_LIST(bridge_list, body_sm_list, BodySM);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    7999 [ #  # ][ #  # ]:          0 :   CAST_LIST(bridge_list, curve_list, Curve);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    8000                 :            : 
    8001 [ #  # ][ #  # ]:          0 :   if ( !gePtr1 ||
    8002 [ #  # ][ #  # ]:          0 :       body_sm_list.size() != body_list.size() ||
         [ #  # ][ #  # ]
    8003 [ #  # ][ #  # ]:          0 :       curve_list.size() != ref_edge_list.size() )
    8004                 :            :   {
    8005 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing IMPRINT with volumes containing geometry from\n"
                 [ #  # ]
    8006                 :            :                 "different modeling engines is not allowed.\n"
    8007         [ #  # ]:          0 :                 "Delete uncommon geometry on these volumes before operation.\n\n");
    8008                 :          0 :     return CUBIT_FAILURE;
    8009                 :            :   }
    8010                 :            : 
    8011 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    8012                 :            :   {
    8013         [ #  # ]:          0 :     if( keep_old_body )
    8014         [ #  # ]:          0 :       CubitUndo::save_state();
    8015                 :            :     else
    8016         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( body_list );
    8017                 :            :   }
    8018                 :            : 
    8019                 :          0 :   int process_composites = 0;
    8020 [ #  # ][ #  # ]:          0 :   if(contains_composites(body_list))
    8021                 :          0 :     process_composites = 1;
    8022                 :            : 
    8023         [ #  # ]:          0 :   if(process_composites)
    8024                 :            :   {
    8025                 :            :     // Turn certain attributes on.
    8026         [ #  # ]:          0 :     do_attribute_setup();
    8027                 :            :     // Push virtual attributes down to solid model topology before
    8028                 :            :     // doing the imprint.
    8029         [ #  # ]:          0 :     push_attributes_before_modify(body_sm_list);
    8030                 :            :     // Put "ORIGINAL" attributes on the bodies being imprinted and
    8031                 :            :     // the curves as these originally existed.
    8032         [ #  # ]:          0 :     DLIList<TopologyBridge*> tb_list;
    8033 [ #  # ][ #  # ]:          0 :     CAST_LIST(body_sm_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8034         [ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tb_list, "ORIGINAL");
    8035         [ #  # ]:          0 :     tb_list.clean_out();
    8036 [ #  # ][ #  # ]:          0 :     CAST_LIST(curve_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8037 [ #  # ][ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tb_list, "ORIGINAL");
    8038                 :            :   }
    8039                 :            : 
    8040 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_sm_list;
    8041                 :            :   // The bridges doing the imprinting often get split during the process but
    8042                 :            :   // because of the way we are making copies, the IMPRINTER attribute doesn't
    8043                 :            :   // get propagated to them.  temporary_bridges will be filled in with any
    8044                 :            :   // additional IMPRINTER bridges we need to consider below when deciding whether to
    8045                 :            :   // keep composite attributes.
    8046 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> temporary_bridges;
    8047                 :            :   CubitStatus status = gePtr1->imprint( body_sm_list, curve_list,
    8048         [ #  # ]:          0 :             new_sm_list, temporary_bridges, keep_old_body, show_messages);
    8049                 :            : 
    8050         [ #  # ]:          0 :   temporary_bridges.uniquify_ordered();
    8051                 :            : 
    8052         [ #  # ]:          0 :   if(status == CUBIT_FAILURE)
    8053                 :            :   {
    8054         [ #  # ]:          0 :     if(process_composites)
    8055                 :            :     {
    8056         [ #  # ]:          0 :       remove_pushed_attributes(new_sm_list, body_list);
    8057         [ #  # ]:          0 :       do_attribute_cleanup();
    8058                 :            :     }
    8059                 :            : 
    8060 [ #  # ][ #  # ]:          0 :     while(temporary_bridges.size())
    8061                 :            :     {
    8062         [ #  # ]:          0 :       TopologyBridge* bridge = temporary_bridges.pop();
    8063 [ #  # ][ #  # ]:          0 :       bridge->get_geometry_query_engine()->delete_topology_bridge(bridge);
    8064                 :            :     }
    8065                 :            : 
    8066                 :          0 :     return status;
    8067                 :            :   }
    8068                 :            :   else
    8069                 :            :   {
    8070         [ #  # ]:          0 :     if(process_composites)
    8071                 :            :     {
    8072         [ #  # ]:          0 :       DLIList<TopologyBridge*> tb_list;
    8073                 :            :       // Analyze the results and adjust virtual attributes as necessary.
    8074 [ #  # ][ #  # ]:          0 :       CAST_LIST(new_sm_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8075                 :            :       // The bridges coming back in temporary_bridges may not have IMPRINTER
    8076                 :            :       // attributes on them becuase of the way they were generated below.  Make
    8077                 :            :       // sure they get IMPRINTER attributes.
    8078         [ #  # ]:          0 :       push_named_attributes_to_curves_and_points(temporary_bridges, "IMPRINTER");
    8079         [ #  # ]:          0 :       tb_list += temporary_bridges;
    8080 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->ige_attribute_after_imprinting(tb_list, body_list);
    8081                 :            : 
    8082                 :            :       // Clean up attributes.
    8083         [ #  # ]:          0 :       remove_imprint_attributes_after_modify(body_sm_list, new_sm_list);
    8084                 :            : 
    8085                 :            :       // Restore the virtual geometry.
    8086         [ #  # ]:          0 :       restore_vg_after_modify(new_sm_list, body_list, gePtr1);
    8087 [ #  # ][ #  # ]:          0 :       remove_pushed_attributes(new_sm_list, body_list);
    8088                 :            :     }
    8089                 :            :   }
    8090                 :            : 
    8091 [ #  # ][ #  # ]:          0 :   while(temporary_bridges.size())
    8092                 :            :   {
    8093         [ #  # ]:          0 :     TopologyBridge* bridge = temporary_bridges.pop();
    8094 [ #  # ][ #  # ]:          0 :     bridge->get_geometry_query_engine()->delete_topology_bridge(bridge);
    8095                 :            :   }
    8096                 :            : 
    8097         [ #  # ]:          0 :   status = finish_sm_op(body_list, new_sm_list, new_body_list);
    8098                 :            : 
    8099         [ #  # ]:          0 :   if(process_composites)
    8100         [ #  # ]:          0 :     do_attribute_cleanup();
    8101                 :            : 
    8102 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    8103                 :            :    {
    8104         [ #  # ]:          0 :      if( status == CUBIT_SUCCESS )
    8105         [ #  # ]:          0 :        CubitUndo::note_result_bodies( new_body_list );
    8106                 :            :      else
    8107         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    8108                 :            :    }
    8109                 :            : 
    8110         [ #  # ]:          0 :    return status;
    8111                 :            : }
    8112                 :            : 
    8113                 :          0 : CubitStatus GeometryModifyTool::imprint( DLIList<RefFace*> &ref_face_list,
    8114                 :            :                                          DLIList<RefEdge*> &ref_edge_list,
    8115                 :            :                                          DLIList<Body*>& new_body_list,
    8116                 :            :                                          CubitBoolean keep_old_body )
    8117                 :            : {
    8118 [ #  # ][ #  # ]:          0 :   for(int j=0;j<ref_edge_list.size();j++)
    8119                 :            :   {
    8120         [ #  # ]:          0 :     RefEdge* edge=ref_edge_list[j];
    8121 [ #  # ][ #  # ]:          0 :     if(edge->get_arc_length()<=edge->get_geometry_query_engine()->get_sme_resabs_tolerance())
         [ #  # ][ #  # ]
    8122                 :            :     {
    8123                 :            : 
    8124 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Curve %d has zero length.\n To imprint curve as a hard point use the vertex of the curve.\n",edge->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
    8125                 :          0 :       return CUBIT_FAILURE;
    8126                 :            : 
    8127                 :            :     }
    8128                 :            :   }
    8129                 :            : 
    8130                 :            :   //get the owning bodies of the faces and edges
    8131         [ #  # ]:          0 :   DLIList<Body*> body_list;
    8132                 :            :   int j;
    8133 [ #  # ][ #  # ]:          0 :   for(j=ref_face_list.size(); j--;)
    8134 [ #  # ][ #  # ]:          0 :     ref_face_list.get_and_step()->bodies( body_list );
    8135 [ #  # ][ #  # ]:          0 :   for(j=ref_edge_list.size(); j--;)
    8136 [ #  # ][ #  # ]:          0 :     ref_edge_list.get_and_step()->bodies( body_list );
    8137         [ #  # ]:          0 :   body_list.uniquify_ordered();
    8138 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( body_list, "IMPRINT" ))
    8139                 :          0 :     return CUBIT_FAILURE;
    8140                 :            : 
    8141 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> temp_list, temp_list_2, body_me_list;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8142 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, temp_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8143 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_edge_list, temp_list_2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8144         [ #  # ]:          0 :   temp_list += temp_list_2;
    8145 [ #  # ][ #  # ]:          0 :   ModelQueryEngine::instance()->query_model(temp_list, DagType::body_type(), body_me_list );
                 [ #  # ]
    8146                 :            : 
    8147 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surf_list(ref_face_list.size());
                 [ #  # ]
    8148 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
                 [ #  # ]
    8149                 :            :   GeometryModifyEngine* gePtr1 = common_modify_engine( ref_face_list,ref_edge_list,surf_list,
    8150         [ #  # ]:          0 :                              curve_list,true);
    8151         [ #  # ]:          0 :   if ( !gePtr1 )
    8152                 :            :   {
    8153 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing IMPRINT with volumes containing geometry from\n"
                 [ #  # ]
    8154                 :            :             "different modeling engines is not allowed.\n"
    8155         [ #  # ]:          0 :             "Delete uncommon geometry on these volumes before operation.\n\n");
    8156                 :          0 :     return CUBIT_FAILURE;
    8157                 :            :   }
    8158                 :            : 
    8159 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    8160                 :            :   {
    8161         [ #  # ]:          0 :     if( keep_old_body )
    8162         [ #  # ]:          0 :       CubitUndo::save_state();
    8163                 :            :     else
    8164         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_face_list );
    8165                 :            :   }
    8166                 :            : 
    8167                 :          0 :   int process_composites = 0;
    8168 [ #  # ][ #  # ]:          0 :   if(contains_composites(body_list))
    8169                 :          0 :     process_composites = 1;
    8170                 :            : 
    8171                 :            :   int i;
    8172 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sm_list;
    8173         [ #  # ]:          0 :   if(process_composites)
    8174                 :            :   {
    8175                 :            :     // Turn certain attributes on.
    8176         [ #  # ]:          0 :     do_attribute_setup();
    8177 [ #  # ][ #  # ]:          0 :     for(i=body_list.size(); i--;)
    8178 [ #  # ][ #  # ]:          0 :       body_sm_list.append_unique(body_list.get_and_step()->get_body_sm_ptr());
                 [ #  # ]
    8179                 :            :     // Push virtual attributes down to solid model topology before
    8180                 :            :     // doing the imprint.
    8181         [ #  # ]:          0 :     push_attributes_before_modify(body_sm_list);
    8182                 :            :     // Put "ORIGINAL" attributes on the bodies being imprinted and
    8183                 :            :     // the curves as these originally existed.
    8184         [ #  # ]:          0 :     DLIList<TopologyBridge*> tmp_tb_list;
    8185 [ #  # ][ #  # ]:          0 :     CAST_LIST(surf_list, tmp_tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8186 [ #  # ][ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tmp_tb_list, "ORIGINAL");
    8187                 :            :   }
    8188                 :            : 
    8189 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_sm_list;
    8190                 :            :   // The bridges doing the imprinting often get split during the process but
    8191                 :            :   // because of the way we are making copies, the IMPRINTER attribute doesn't
    8192                 :            :   // get propagated to them.  temporary_bridges will be filled in with any
    8193                 :            :   // additional IMPRINTER bridges we need to consider below when deciding whether to
    8194                 :            :   // keep composite attributes.
    8195 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> temporary_bridges;
    8196                 :            :   CubitStatus status = gePtr1->imprint( surf_list, curve_list, temporary_bridges,
    8197         [ #  # ]:          0 :                                          new_sm_list, keep_old_body );
    8198         [ #  # ]:          0 :   temporary_bridges.uniquify_ordered();
    8199                 :            : 
    8200         [ #  # ]:          0 :   if(process_composites)
    8201                 :            :   {
    8202                 :            :     // Analyze the results and adjust virtual attributes as necessary.
    8203         [ #  # ]:          0 :     DLIList<TopologyBridge*> tb_list;
    8204 [ #  # ][ #  # ]:          0 :     CAST_LIST(new_sm_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8205                 :            :     // The bridges coming back in temporary_bridges may not have IMPRINTER
    8206                 :            :     // attributes on them becuase of the way they were generated below.  Make
    8207                 :            :     // sure they get IMPRINTER attributes.
    8208         [ #  # ]:          0 :     push_named_attributes_to_curves_and_points(temporary_bridges, "IMPRINTER");
    8209         [ #  # ]:          0 :     tb_list += temporary_bridges;
    8210 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->ige_attribute_after_imprinting(tb_list, body_list);
    8211                 :            : 
    8212                 :            :     // Clean up attributes.
    8213         [ #  # ]:          0 :     remove_imprint_attributes_after_modify(body_sm_list, new_sm_list);
    8214                 :            : 
    8215         [ #  # ]:          0 :     restore_vg_after_modify(body_sm_list, body_list, gePtr1);
    8216 [ #  # ][ #  # ]:          0 :     remove_pushed_attributes(body_sm_list, body_list);
    8217                 :            :   }
    8218                 :            : 
    8219 [ #  # ][ #  # ]:          0 :   while(temporary_bridges.size())
    8220                 :            :   {
    8221         [ #  # ]:          0 :     TopologyBridge* bridge = temporary_bridges.pop();
    8222 [ #  # ][ #  # ]:          0 :     bridge->get_geometry_query_engine()->delete_topology_bridge(bridge);
    8223                 :            :   }
    8224                 :            : 
    8225         [ #  # ]:          0 :   CubitStatus status2 = finish_sm_op(body_list, new_sm_list, new_body_list);
    8226                 :            : 
    8227         [ #  # ]:          0 :   if(process_composites)
    8228         [ #  # ]:          0 :     do_attribute_cleanup();
    8229                 :            : 
    8230 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    8231                 :            :    {
    8232         [ #  # ]:          0 :      if( status == CUBIT_SUCCESS )
    8233         [ #  # ]:          0 :        CubitUndo::note_result_bodies( new_body_list );
    8234                 :            :      else
    8235         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    8236                 :            :    }
    8237                 :            : 
    8238 [ #  # ][ #  # ]:          0 :    if( status == CUBIT_SUCCESS && status2 == CUBIT_SUCCESS)
    8239                 :          0 :      return status;
    8240                 :            : 
    8241                 :            :    else
    8242         [ #  # ]:          0 :      return CUBIT_FAILURE;
    8243                 :            : }
    8244                 :            : 
    8245                 :          0 : CubitStatus GeometryModifyTool::imprint( DLIList<Surface*> &surface_list,
    8246                 :            :                                          DLIList<DLIList<Curve*>*> &curve_lists_list,
    8247                 :            :                                          Body*& /*new_body*/,
    8248                 :            :                                          CubitBoolean keep_old_body,
    8249                 :            :                                          CubitBoolean expand)
    8250                 :            : {
    8251                 :            :   int i;
    8252                 :            :   DLIList<Curve*> *curve_list_ptr;
    8253                 :            : 
    8254                 :            :   // Check to see if any curves exist - if none, just exit
    8255                 :          0 :   int have_curves = 0;
    8256 [ #  # ][ #  # ]:          0 :   for( i=curve_lists_list.size(); i--; )
    8257                 :            :   {
    8258         [ #  # ]:          0 :     curve_list_ptr = curve_lists_list.get_and_step();
    8259 [ #  # ][ #  # ]:          0 :     for(int j=0;j<curve_list_ptr->size();j++)
    8260                 :            :     {
    8261         [ #  # ]:          0 :       Curve* curve=(*curve_list_ptr)[j];
    8262 [ #  # ][ #  # ]:          0 :       if(curve->get_arc_length()<=curve->get_geometry_query_engine()->get_sme_resabs_tolerance())
         [ #  # ][ #  # ]
    8263                 :            :       {
    8264 [ #  # ][ #  # ]:          0 :         RefEdge* edge = dynamic_cast<RefEdge*>(curve->topology_entity());
    8265         [ #  # ]:          0 :         if(edge)
    8266                 :            :         {
    8267 [ #  # ][ #  # ]:          0 :           PRINT_ERROR( "Curve %d has zero length.\n To imprint as a hard point use the vertex of the curve.\n",edge->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
    8268                 :          0 :           return CUBIT_FAILURE;
    8269                 :            :         }
    8270                 :            :         else
    8271                 :            :         {
    8272                 :          0 :           return CUBIT_FAILURE;
    8273                 :            :         }
    8274                 :            :       }
    8275                 :            :       else
    8276                 :            :       {
    8277                 :          0 :         have_curves++;
    8278                 :          0 :         break;
    8279                 :            :       }
    8280                 :            :     }
    8281                 :            :   }
    8282         [ #  # ]:          0 :   if( !have_curves )
    8283                 :          0 :     return CUBIT_SUCCESS;
    8284                 :            : 
    8285                 :            :   // Get parent bodies
    8286         [ #  # ]:          0 :   DLIList<Body*> old_body_list;
    8287         [ #  # ]:          0 :   surface_list.reset();
    8288 [ #  # ][ #  # ]:          0 :   for( i=surface_list.size(); i--; )
    8289                 :            :   {
    8290         [ #  # ]:          0 :     Surface *surf_ptr = surface_list.get_and_step();
    8291 [ #  # ][ #  # ]:          0 :     RefEntity* ref_ent = dynamic_cast<RefEntity*>(surf_ptr->topology_entity());
    8292         [ #  # ]:          0 :     RefFace *ref_face_ptr = CAST_TO( ref_ent, RefFace );
    8293                 :            : 
    8294         [ #  # ]:          0 :     if( ref_face_ptr )
    8295                 :            :     {
    8296         [ #  # ]:          0 :       DLIList<Body*> body_list;
    8297         [ #  # ]:          0 :       ref_face_ptr->bodies( body_list );
    8298 [ #  # ][ #  # ]:          0 :       old_body_list.merge_unique( body_list );
    8299                 :            :     }
    8300                 :            :   }
    8301                 :            : 
    8302 [ #  # ][ #  # ]:          0 :   if( old_body_list.size() > 1 )
    8303                 :            :   {
    8304 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "This operation requires all surfaces to be from the same volume\n" );
         [ #  # ][ #  # ]
    8305                 :            :     // Note: this restriction could be pretty easily lifted by sorting the
    8306                 :            :     //       input lists and calling the GeometryModifyEngine for each body
    8307                 :            :     //       separately, or having engines handle this.
    8308                 :          0 :     return CUBIT_FAILURE;
    8309                 :            :   }
    8310                 :            : 
    8311                 :            : 
    8312                 :            :   // In order to support imprinting on composite surfaces we will
    8313                 :            :   // get any surfaces underlying the surfaces passed in.  For now
    8314                 :            :   // we will only do this if a single surface is coming in but
    8315                 :            :   // it could be extended for multiple surfaces as well.
    8316 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> new_surface_list;
    8317 [ #  # ][ #  # ]:          0 :   if(surface_list.size() == 1)
    8318                 :            :   {
    8319 [ #  # ][ #  # ]:          0 :     GeometryQueryEngine *gqe = surface_list.get()->get_geometry_query_engine();
    8320         [ #  # ]:          0 :     DLIList<TopologyBridge*> tbs;
    8321 [ #  # ][ #  # ]:          0 :     gqe->get_underlying_surfaces(surface_list.get(), tbs);
    8322 [ #  # ][ #  # ]:          0 :     if(tbs.size() > 0)
    8323                 :            :     {
    8324 [ #  # ][ #  # ]:          0 :       for(int k=tbs.size(); k--;)
    8325 [ #  # ][ #  # ]:          0 :         new_surface_list.append(dynamic_cast<Surface*>(tbs.get_and_step()));
                 [ #  # ]
    8326                 :            :     }
    8327                 :            :     else
    8328 [ #  # ][ #  # ]:          0 :       new_surface_list.append(surface_list.get());
                 [ #  # ]
    8329                 :            :   }
    8330                 :            :   else
    8331         [ #  # ]:          0 :     new_surface_list = surface_list;
    8332                 :            : 
    8333                 :            :   // Check engines - must all be the same
    8334                 :            :   GeometryModifyEngine* gme;
    8335         [ #  # ]:          0 :   new_surface_list.reset();
    8336 [ #  # ][ #  # ]:          0 :   gme = get_engine( new_surface_list.get() );
    8337 [ #  # ][ #  # ]:          0 :   for( i=new_surface_list.size(); i--; )
    8338                 :            :   {
    8339         [ #  # ]:          0 :     Surface *surf_ptr = new_surface_list.get_and_step();
    8340         [ #  # ]:          0 :     GeometryModifyEngine* gme2 = get_engine( surf_ptr );
    8341         [ #  # ]:          0 :     if( gme != gme2 )
    8342                 :            :     {
    8343 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "All surfaces being imprinted must be from the same geometry engine\n" );
         [ #  # ][ #  # ]
    8344                 :          0 :       return CUBIT_FAILURE;
    8345                 :            :     }
    8346                 :            :   }
    8347                 :            : 
    8348                 :            :   int j;
    8349 [ #  # ][ #  # ]:          0 :   for( i=curve_lists_list.size(); i--; )
    8350                 :            :   {
    8351         [ #  # ]:          0 :     curve_list_ptr = curve_lists_list.get_and_step();
    8352 [ #  # ][ #  # ]:          0 :     for( j=curve_list_ptr->size(); j--; )
    8353                 :            :     {
    8354         [ #  # ]:          0 :       Curve *curve_ptr = curve_list_ptr->get_and_step();
    8355         [ #  # ]:          0 :       GeometryModifyEngine* gme2 = get_engine( curve_ptr );
    8356         [ #  # ]:          0 :       if( gme != gme2 )
    8357                 :            :       {
    8358 [ #  # ][ #  # ]:          0 :         PRINT_ERROR( "Curves used to imprint must be from same geometry engine as Surface\n" );
         [ #  # ][ #  # ]
    8359                 :          0 :         return CUBIT_FAILURE;
    8360                 :            :       }
    8361                 :            :     }
    8362                 :            :   }
    8363                 :            : 
    8364 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    8365                 :            :    {
    8366         [ #  # ]:          0 :      if( keep_old_body )
    8367         [ #  # ]:          0 :        CubitUndo::save_state();
    8368                 :            :      else
    8369         [ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( old_body_list );
    8370                 :            :    }
    8371                 :            : 
    8372                 :          0 :   int process_composites = 0;
    8373 [ #  # ][ #  # ]:          0 :   if(contains_composites(old_body_list))
    8374                 :          0 :     process_composites = 1;
    8375                 :            : 
    8376                 :          0 :   BodySM* new_body_sm = 0;
    8377 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sm_list;
    8378                 :            : 
    8379 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> tb_list;
    8380         [ #  # ]:          0 :   if(process_composites)
    8381                 :            :   {
    8382         [ #  # ]:          0 :     do_attribute_setup();
    8383 [ #  # ][ #  # ]:          0 :     for(i=old_body_list.size(); i--;)
    8384 [ #  # ][ #  # ]:          0 :       body_sm_list.append_unique(old_body_list.get_and_step()->get_body_sm_ptr());
                 [ #  # ]
    8385         [ #  # ]:          0 :     push_attributes_before_modify(body_sm_list);
    8386                 :            :  //   push_imprint_attributes_before_modify(body_sm_list);
    8387         [ #  # ]:          0 :     DLIList<TopologyBridge*> tmp_tb_list;
    8388 [ #  # ][ #  # ]:          0 :     CAST_LIST(new_surface_list, tmp_tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8389         [ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tmp_tb_list, "ORIGINAL");
    8390                 :            : 
    8391 [ #  # ][ #  # ]:          0 :     for(i=curve_lists_list.size(); i>0; i--)
    8392                 :            :     {
    8393         [ #  # ]:          0 :       DLIList<Curve*> *cur_list = curve_lists_list.get_and_step();
    8394 [ #  # ][ #  # ]:          0 :       for(j=cur_list->size(); j>0; j--)
    8395                 :            :       {
    8396         [ #  # ]:          0 :         Curve *cur_curve = cur_list->get_and_step();
    8397         [ #  # ]:          0 :         tb_list.append(cur_curve);
    8398                 :            :       }
    8399                 :            :     }
    8400 [ #  # ][ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tb_list, "IMPRINTER");
    8401                 :            :   }
    8402                 :            : 
    8403                 :            :   CubitStatus status = gme->imprint( new_surface_list, curve_lists_list,
    8404         [ #  # ]:          0 :     new_body_sm, keep_old_body, expand);
    8405                 :            : 
    8406 [ #  # ][ #  # ]:          0 :   DLIList<Body*> new_body_list;
    8407 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_sm_list;
    8408         [ #  # ]:          0 :   new_sm_list.append( new_body_sm );
    8409                 :            : 
    8410         [ #  # ]:          0 :   if(process_composites)
    8411                 :            :   {
    8412                 :            :     // Analyze the results and adjust virtual attributes as necessary.
    8413         [ #  # ]:          0 :        DLIList<TopologyBridge*> tmp_tb_list;
    8414 [ #  # ][ #  # ]:          0 :        CAST_LIST(new_sm_list, tmp_tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8415         [ #  # ]:          0 :        tb_list += tmp_tb_list;
    8416 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->ige_attribute_after_imprinting(tb_list, old_body_list);
    8417                 :            : 
    8418                 :            :     // Clean up attributes.
    8419         [ #  # ]:          0 :     remove_imprint_attributes_after_modify(body_sm_list, new_sm_list);
    8420                 :            : 
    8421         [ #  # ]:          0 :     restore_vg_after_modify(body_sm_list, old_body_list, gme);
    8422 [ #  # ][ #  # ]:          0 :     remove_pushed_attributes(body_sm_list, old_body_list);
    8423                 :            :   }
    8424                 :            : 
    8425         [ #  # ]:          0 :   CubitStatus status2 = finish_sm_op(old_body_list, new_sm_list, new_body_list);
    8426                 :            : 
    8427         [ #  # ]:          0 :   if(process_composites)
    8428         [ #  # ]:          0 :     do_attribute_cleanup();
    8429                 :            : 
    8430 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    8431                 :            :   {
    8432         [ #  # ]:          0 :     if( status == CUBIT_SUCCESS )
    8433         [ #  # ]:          0 :       CubitUndo::note_result_bodies( new_body_list );
    8434                 :            :     else
    8435         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    8436                 :            :   }
    8437                 :            : 
    8438 [ #  # ][ #  # ]:          0 :   if( status == CUBIT_SUCCESS && status2 == CUBIT_SUCCESS)
    8439                 :          0 :      return status;
    8440                 :            : 
    8441                 :            :    else
    8442         [ #  # ]:          0 :      return CUBIT_FAILURE;
    8443                 :            : }
    8444                 :            : 
    8445                 :          0 : CubitStatus GeometryModifyTool::imprint( DLIList<Body*> &body_list,
    8446                 :            :                                          DLIList<CubitVector> &vector_list,
    8447                 :            :                                          DLIList<Body*>& new_body_list,
    8448                 :            :                                          CubitBoolean keep_old_body,
    8449                 :            :                                          CubitBoolean merge )
    8450                 :            : {
    8451                 :            :   // Check the GeometryEngine for each of the RefEdges; check to
    8452                 :            :   // make sure they're all the same
    8453         [ #  # ]:          0 :   body_list.reset();
    8454                 :            : 
    8455 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( body_list, "IMPRINT" ))
    8456                 :          0 :     return CUBIT_FAILURE;
    8457                 :            : 
    8458 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sm_list(body_list.size()), new_sm_list;
         [ #  # ][ #  # ]
    8459         [ #  # ]:          0 :   GeometryModifyEngine* gePtr1 = common_modify_engine(body_list, body_sm_list);
    8460         [ #  # ]:          0 :   if ( !gePtr1 )
    8461                 :            :   {
    8462 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing IMPRINT with volumes containing geometry from\n"
                 [ #  # ]
    8463                 :            :                 "different modeling engines is not allowed.\n"
    8464         [ #  # ]:          0 :                 "Delete uncommon geometry on these volumes before operation.\n\n");
    8465                 :          0 :     return CUBIT_FAILURE;
    8466                 :            :   }
    8467                 :            : 
    8468 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    8469                 :            :   {
    8470         [ #  # ]:          0 :     if( keep_old_body )
    8471         [ #  # ]:          0 :       CubitUndo::save_state();
    8472                 :            :     else
    8473         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( body_list );
    8474                 :            :   }
    8475                 :            : 
    8476                 :          0 :   int process_composites = 0;
    8477 [ #  # ][ #  # ]:          0 :   if(contains_composites(body_list))
    8478                 :          0 :     process_composites = 1;
    8479                 :            : 
    8480                 :            :   int i;
    8481 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> temporary_bridges;
    8482         [ #  # ]:          0 :   if(process_composites)
    8483                 :            :   {
    8484                 :            :     // Turn certain attributes on.
    8485         [ #  # ]:          0 :     do_attribute_setup();
    8486                 :            :     // Push virtual attributes down to solid model topology before
    8487                 :            :     // doing the imprint.
    8488         [ #  # ]:          0 :     push_attributes_before_modify(body_sm_list);
    8489                 :            :     // Create temporary bridges for the vector positions.  We do
    8490                 :            :     // this so that we can put an IMPRINTER attribute on them
    8491                 :            :     // and use them later for deciding whether to keep composite
    8492                 :            :     // attributes or not.
    8493 [ #  # ][ #  # ]:          0 :     for(i=vector_list.size(); i>0; i--)
    8494                 :            :     {
    8495 [ #  # ][ #  # ]:          0 :       CubitVector vec = vector_list.get_and_step();
    8496         [ #  # ]:          0 :       TBPoint *pt = gePtr1->make_Point(vec);
    8497         [ #  # ]:          0 :       temporary_bridges.append(pt);
    8498                 :            :     }
    8499         [ #  # ]:          0 :     push_named_attributes_to_curves_and_points(temporary_bridges, "IMPRINTER");
    8500         [ #  # ]:          0 :     DLIList<TopologyBridge*> tmp_tb_list;
    8501 [ #  # ][ #  # ]:          0 :     CAST_LIST(body_sm_list, tmp_tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8502                 :            :     // Put "ORIGINAL" attributes on the bridges that originally existed.
    8503 [ #  # ][ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tmp_tb_list, "ORIGINAL");
    8504                 :            :   }
    8505                 :            : 
    8506                 :            :   CubitStatus status = gePtr1->imprint( body_sm_list, vector_list,new_sm_list,
    8507         [ #  # ]:          0 :     keep_old_body);
    8508                 :            : 
    8509         [ #  # ]:          0 :   temporary_bridges.uniquify_ordered();
    8510                 :            : 
    8511         [ #  # ]:          0 :   if(process_composites)
    8512                 :            :   {
    8513                 :            :     // Analyze the results and adjust virtual attributes as necessary.
    8514         [ #  # ]:          0 :     DLIList<TopologyBridge*> tb_list;
    8515 [ #  # ][ #  # ]:          0 :     CAST_LIST(new_sm_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8516         [ #  # ]:          0 :     tb_list += temporary_bridges;
    8517 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->ige_attribute_after_imprinting(tb_list, body_list);
    8518                 :            : 
    8519 [ #  # ][ #  # ]:          0 :     while(temporary_bridges.size())
    8520                 :            :     {
    8521         [ #  # ]:          0 :       TopologyBridge* bridge = temporary_bridges.pop();
    8522 [ #  # ][ #  # ]:          0 :       bridge->get_geometry_query_engine()->delete_topology_bridge(bridge);
    8523                 :            :     }
    8524                 :            : 
    8525                 :            :     // Clean up attributes.
    8526         [ #  # ]:          0 :     remove_imprint_attributes_after_modify(body_sm_list, new_sm_list);
    8527                 :            : 
    8528                 :            :     // Restore the virtual geometry.
    8529         [ #  # ]:          0 :     restore_vg_after_modify(new_sm_list, body_list, gePtr1);
    8530 [ #  # ][ #  # ]:          0 :     remove_pushed_attributes(new_sm_list, body_list);
    8531                 :            :   }
    8532                 :            : 
    8533         [ #  # ]:          0 :   CubitStatus status2 = finish_sm_op(body_list, new_sm_list, new_body_list);
    8534                 :            : 
    8535         [ #  # ]:          0 :   if(process_composites)
    8536         [ #  # ]:          0 :     do_attribute_cleanup();
    8537                 :            : 
    8538         [ #  # ]:          0 :    if( merge )
    8539                 :            :    {
    8540         [ #  # ]:          0 :      DLIList<Body*> bodies_to_merge;
    8541                 :            :      int i;
    8542 [ #  # ][ #  # ]:          0 :      for( i=new_body_list.size(); i--; )
    8543                 :            :      {
    8544         [ #  # ]:          0 :        Body *tmp_body = new_body_list.get_and_step();
    8545         [ #  # ]:          0 :        DLIList<RefEdge*> ref_edge_list;
    8546         [ #  # ]:          0 :        tmp_body->ref_edges( ref_edge_list );
    8547                 :            : 
    8548                 :            :        int j;
    8549 [ #  # ][ #  # ]:          0 :        for( j=ref_edge_list.size(); j--; )
    8550                 :            :        {
    8551         [ #  # ]:          0 :          RefEdge *tmp_edge = ref_edge_list.get_and_step();
    8552         [ #  # ]:          0 :          DLIList<Body*> body_list;
    8553         [ #  # ]:          0 :          tmp_edge->bodies( body_list );
    8554         [ #  # ]:          0 :          bodies_to_merge.merge_unique( body_list );
    8555         [ #  # ]:          0 :        }
    8556         [ #  # ]:          0 :      }
    8557 [ #  # ][ #  # ]:          0 :      MergeTool::instance()->merge_bodies( bodies_to_merge );
                 [ #  # ]
    8558                 :            :    }
    8559                 :            : 
    8560 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    8561                 :            :    {
    8562         [ #  # ]:          0 :      if( status == CUBIT_SUCCESS )
    8563         [ #  # ]:          0 :        CubitUndo::note_result_bodies( new_body_list );
    8564                 :            :      else
    8565         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    8566                 :            :    }
    8567                 :            : 
    8568 [ #  # ][ #  # ]:          0 :    if( status == CUBIT_SUCCESS && status2 == CUBIT_SUCCESS)
    8569                 :          0 :      return status;
    8570                 :            : 
    8571                 :            :    else
    8572         [ #  # ]:          0 :      return CUBIT_FAILURE;
    8573                 :            : }
    8574                 :          0 : CubitStatus GeometryModifyTool::project_edges( DLIList<RefFace*> &ref_face_list,
    8575                 :            :                                                DLIList<RefEdge*> &ref_edge_list_in,
    8576                 :            :                                                DLIList<RefEdge*> &ref_edge_list_new,
    8577                 :            :                                                CubitBoolean trim_projected)
    8578                 :            : {
    8579                 :            :   int i, j;
    8580                 :            : 
    8581                 :            :    // Check the GeometryEngine for each of the RefEdges; check to
    8582                 :            :    // make sure they're all the same
    8583 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list(ref_face_list.size());
    8584 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list_in(ref_edge_list_in.size()), curve_list_new;
         [ #  # ][ #  # ]
                 [ #  # ]
    8585                 :            :   GeometryModifyEngine* gme = common_modify_engine( ref_face_list,
    8586                 :            :                                                     ref_edge_list_in,
    8587                 :            :                                                     surface_list,
    8588         [ #  # ]:          0 :                                                     curve_list_in );
    8589                 :            : 
    8590         [ #  # ]:          0 :   if ( !gme ) {
    8591 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("In GeometryTool::create_blend\n"
                 [ #  # ]
    8592         [ #  # ]:          0 :                 "       Curves have different modify engines.\n");
    8593                 :          0 :     return CUBIT_FAILURE;
    8594                 :            :   }
    8595                 :            : 
    8596                 :            :    CubitStatus status = gme->
    8597         [ #  # ]:          0 :      project_edges( surface_list, curve_list_in, curve_list_new);
    8598                 :            : 
    8599 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && status == CUBIT_SUCCESS )
         [ #  # ][ #  # ]
    8600         [ #  # ]:          0 :     CubitUndo::save_state();
    8601                 :            : 
    8602                 :            : 
    8603         [ #  # ]:          0 :    curve_list_new.reset();
    8604                 :            : 
    8605         [ #  # ]:          0 :    if(trim_projected){
    8606 [ #  # ][ #  # ]:          0 :      DLIList<Curve*> tmp_curves, all_new_curves;
         [ #  # ][ #  # ]
    8607                 :            :      Curve* tmp_curve;
    8608                 :            :      Surface* tmp_surface;
    8609                 :            : 
    8610 [ #  # ][ #  # ]:          0 :      for(i = 0; i< surface_list.size(); i++){
    8611         [ #  # ]:          0 :        tmp_curves.clean_out();
    8612         [ #  # ]:          0 :        tmp_surface = surface_list.get_and_step();
    8613 [ #  # ][ #  # ]:          0 :        for(j=0; j<curve_list_new.size(); j++){
    8614         [ #  # ]:          0 :          tmp_curve = curve_list_new.get_and_step();
    8615         [ #  # ]:          0 :          status = gme->curve_surface_intersection( tmp_surface, tmp_curve, tmp_curves);
    8616                 :            :        }
    8617         [ #  # ]:          0 :        all_new_curves += tmp_curves;
    8618                 :            : 
    8619                 :            :      }
    8620                 :            : 
    8621 [ #  # ][ #  # ]:          0 :      if(!all_new_curves.size()){
    8622 [ #  # ][ #  # ]:          0 :        if(!curve_list_new.size()){
    8623 [ #  # ][ #  # ]:          0 :          PRINT_ERROR("Projection resulted in no curves.\n");
         [ #  # ][ #  # ]
    8624                 :          0 :          return CUBIT_FAILURE;
    8625                 :            :        }
    8626                 :            :        else{
    8627 [ #  # ][ #  # ]:          0 :          PRINT_WARNING("No curve remained after trimming operation.  \n \tCurve projection may lie completely outside of trimmed surface.\n");
         [ #  # ][ #  # ]
    8628                 :            :        }
    8629                 :            :      }
    8630                 :            : 
    8631                 :            :        //fix this...
    8632                 :            :        //can we just cleanout this list or do we need to delete the entities in it.
    8633 [ #  # ][ #  # ]:          0 :      for( i = 0; i< curve_list_new.size(); i++ )
    8634                 :            :      {
    8635         [ #  # ]:          0 :        Curve *tmp_curve = curve_list_new.get_and_step();
    8636 [ #  # ][ #  # ]:          0 :        gme->get_gqe()->delete_solid_model_entities( tmp_curve );
    8637                 :            :      }
    8638                 :            : 
    8639         [ #  # ]:          0 :      curve_list_new.clean_out();
    8640         [ #  # ]:          0 :      curve_list_new = all_new_curves;
    8641                 :            : 
    8642 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() && status == CUBIT_SUCCESS )
         [ #  # ][ #  # ]
    8643 [ #  # ][ #  # ]:          0 :        CubitUndo::save_state();
                 [ #  # ]
    8644                 :            :    }
    8645                 :            : 
    8646                 :            : 
    8647                 :            : 
    8648         [ #  # ]:          0 :    curve_list_new.reset();
    8649 [ #  # ][ #  # ]:          0 :    for (i = curve_list_new.size(); i--; )
    8650                 :            :    {
    8651         [ #  # ]:          0 :      Curve* curve = curve_list_new.get_and_step();
    8652 [ #  # ][ #  # ]:          0 :      RefEdge* new_edge = GeometryQueryTool::instance()->make_free_RefEdge(curve);
    8653 [ #  # ][ #  # ]:          0 :      PRINT_INFO("Created Curve %d\n", new_edge->id());
         [ #  # ][ #  # ]
                 [ #  # ]
    8654         [ #  # ]:          0 :      ref_edge_list_new.append(new_edge);
    8655 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() && new_edge )
         [ #  # ][ #  # ]
    8656 [ #  # ][ #  # ]:          0 :        CubitUndo::note_result_entity( new_edge );
    8657                 :            :    }
    8658                 :            : 
    8659 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    8660                 :            :    {
    8661 [ #  # ][ #  # ]:          0 :      if( ref_edge_list_new.size() == 0 )
    8662         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    8663                 :            :    }
    8664                 :            : 
    8665         [ #  # ]:          0 :    return status;
    8666                 :            : }
    8667                 :            : 
    8668                 :            : CubitStatus
    8669                 :          0 : GeometryModifyTool::imprint_projected_edges(DLIList<RefFace*> &ref_face_list,
    8670                 :            :                                             DLIList<RefEdge*> &ref_edge_list_in,
    8671                 :            :                                             DLIList<Body*>& new_body_list,
    8672                 :            :                                             CubitBoolean keep_old_body,
    8673                 :            :                                             CubitBoolean keep_free_edges)
    8674                 :            : {
    8675                 :            : 
    8676 [ #  # ][ #  # ]:          0 :    DLIList<Surface*> surface_list(ref_face_list.size());
    8677 [ #  # ][ #  # ]:          0 :    DLIList<Curve*> curve_list(ref_edge_list_in.size());
                 [ #  # ]
    8678                 :            :    GeometryModifyEngine* gme = common_modify_engine( ref_face_list,
    8679                 :            :                                                      ref_edge_list_in,
    8680                 :            :                                                      surface_list,
    8681         [ #  # ]:          0 :                                                      curve_list );
    8682         [ #  # ]:          0 :    if ( !gme )
    8683                 :            :    {
    8684 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing IMPRINT with volumes containing geometry from\n"
                 [ #  # ]
    8685                 :            :                   "different modeling engines is not allowed.\n"
    8686         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    8687                 :          0 :       return CUBIT_FAILURE;
    8688                 :            :    }
    8689                 :            : 
    8690 [ #  # ][ #  # ]:          0 :    DLIList<TopologyEntity*> query_output, query_input(ref_face_list.size());
         [ #  # ][ #  # ]
                 [ #  # ]
    8691 [ #  # ][ #  # ]:          0 :    CAST_LIST_TO_PARENT(ref_face_list, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8692 [ #  # ][ #  # ]:          0 :    ModelQueryEngine::instance()->query_model(query_input, DagType::body_type(), query_output);
                 [ #  # ]
    8693 [ #  # ][ #  # ]:          0 :    DLIList<Body*> body_list(query_output.size());
                 [ #  # ]
    8694 [ #  # ][ #  # ]:          0 :    CAST_LIST(query_output, body_list, Body);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    8695 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> new_sm_list;
    8696 [ #  # ][ #  # ]:          0 :    DLIList<Curve*> kept_free_edges;
    8697                 :            : 
    8698 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    8699                 :            :    {
    8700         [ #  # ]:          0 :      if( keep_old_body )
    8701         [ #  # ]:          0 :        CubitUndo::save_state();
    8702                 :            :      else
    8703         [ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( ref_face_list );
    8704                 :            :    }
    8705                 :            : 
    8706                 :            :    CubitStatus status = gme->imprint_projected_edges( surface_list, curve_list,
    8707                 :            :                                                       new_sm_list, kept_free_edges,
    8708         [ #  # ]:          0 :                                                       keep_old_body, keep_free_edges);
    8709                 :            : 
    8710 [ #  # ][ #  # ]:          0 :    if (!finish_sm_op(body_list, new_sm_list, new_body_list))
    8711                 :          0 :      status = CUBIT_FAILURE;
    8712                 :            : 
    8713 [ #  # ][ #  # ]:          0 :    DLIList<RefEdge*> kept_ref_edges;
    8714         [ #  # ]:          0 :    if( keep_free_edges )
    8715                 :            :    {
    8716 [ #  # ][ #  # ]:          0 :      for( int i=kept_free_edges.size(); i--; )
    8717                 :            :      {
    8718 [ #  # ][ #  # ]:          0 :        RefEdge *tmp_edge = GeometryQueryTool::instance()->make_free_RefEdge( kept_free_edges.get_and_step());
                 [ #  # ]
    8719         [ #  # ]:          0 :        if( tmp_edge )
    8720         [ #  # ]:          0 :          kept_ref_edges.append(tmp_edge );
    8721                 :            :      }
    8722                 :            :    }
    8723                 :            : 
    8724 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    8725                 :            :    {
    8726         [ #  # ]:          0 :      if( status == CUBIT_FAILURE )
    8727         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
    8728                 :            :      else
    8729                 :            :      {
    8730         [ #  # ]:          0 :        CubitUndo::note_result_bodies( new_body_list );
    8731         [ #  # ]:          0 :        if( keep_free_edges )
    8732                 :            :        {
    8733         [ #  # ]:          0 :          DLIList<RefEntity*> ref_ents;
    8734 [ #  # ][ #  # ]:          0 :          for( int i=kept_ref_edges.size(); i--; )
    8735 [ #  # ][ #  # ]:          0 :            ref_ents.append( kept_ref_edges.get_and_step() );
                 [ #  # ]
    8736 [ #  # ][ #  # ]:          0 :          CubitUndo::note_result_entities( ref_ents );
    8737                 :            :        }
    8738                 :            :      }
    8739                 :            :    }
    8740                 :            : 
    8741         [ #  # ]:          0 :    return status;
    8742                 :            : }
    8743                 :            : 
    8744                 :            : CubitStatus
    8745                 :          0 : GeometryModifyTool::imprint_projected_edges(DLIList<RefFace*> &ref_face_list,
    8746                 :            :                                             DLIList<Body*> &body_list,
    8747                 :            :                                             DLIList<RefEdge*> &ref_edge_list_in,
    8748                 :            :                                             DLIList<Body*>& new_body_list,
    8749                 :            :                                             CubitBoolean keep_old_body,
    8750                 :            :                                             CubitBoolean keep_free_edges)
    8751                 :            : {
    8752                 :            : 
    8753 [ #  # ][ #  # ]:          0 :    DLIList<Surface*> surface_list(ref_face_list.size());
    8754 [ #  # ][ #  # ]:          0 :    DLIList<Curve*>     curve_list(ref_edge_list_in.size());
                 [ #  # ]
    8755 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*>  body_sm_list(body_list.size()), new_sm_list;
         [ #  # ][ #  # ]
                 [ #  # ]
    8756                 :            :    GeometryModifyEngine* gme = common_modify_engine(ref_face_list,
    8757                 :            :                                                     ref_edge_list_in,
    8758                 :            :                                                     surface_list,
    8759         [ #  # ]:          0 :                                                     curve_list);
    8760 [ #  # ][ #  # ]:          0 :    if (!gme || gme != common_modify_engine(body_list, body_sm_list))
         [ #  # ][ #  # ]
    8761                 :            :    {
    8762 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing IMPRINT with volumes containing geometry from\n"
                 [ #  # ]
    8763                 :            :                   "different modeling engines is not allowed.\n"
    8764         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    8765                 :          0 :       return CUBIT_FAILURE;
    8766                 :            :    }
    8767                 :            : 
    8768                 :            :      // Get RefFace bodies
    8769 [ #  # ][ #  # ]:          0 :    DLIList<TopologyEntity*> query_output, query_input(ref_face_list.size());
         [ #  # ][ #  # ]
                 [ #  # ]
    8770 [ #  # ][ #  # ]:          0 :    CAST_LIST_TO_PARENT(ref_face_list, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    8771                 :            :    ModelQueryEngine::instance()->
    8772 [ #  # ][ #  # ]:          0 :      query_model( query_input, DagType::body_type(), query_output );
                 [ #  # ]
    8773 [ #  # ][ #  # ]:          0 :    DLIList<Body*> face_body_list;
    8774 [ #  # ][ #  # ]:          0 :    CAST_LIST(query_output, face_body_list, Body);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    8775                 :            : 
    8776                 :            :    CubitStatus status = gme->imprint_projected_edges( surface_list,
    8777                 :            :                                                       body_sm_list,
    8778                 :            :                                                       curve_list,
    8779                 :            :                                                       new_sm_list,
    8780                 :            :                                                       keep_old_body,
    8781         [ #  # ]:          0 :                                                       keep_free_edges);
    8782         [ #  # ]:          0 :    face_body_list += body_list;
    8783 [ #  # ][ #  # ]:          0 :    if (!finish_sm_op(face_body_list, new_sm_list, new_body_list))
    8784                 :          0 :      status = CUBIT_FAILURE;
    8785                 :            : 
    8786         [ #  # ]:          0 :    return status;
    8787                 :            : 
    8788                 :            : }
    8789                 :            : 
    8790                 :            : 
    8791                 :         11 : RefEntity* GeometryModifyTool::copy_refentity( RefEntity *old_entity )
    8792                 :            : {
    8793                 :         11 :    RefEntity *new_entity = NULL;
    8794                 :            : 
    8795         [ -  + ]:         11 :    if( old_entity == NULL )
    8796                 :          0 :        return (RefEntity*) NULL;
    8797                 :            : 
    8798 [ +  - ][ -  + ]:         11 :    if( CAST_TO( old_entity, RefVolume ) )
                 [ -  + ]
    8799                 :          0 :        return (RefEntity*) NULL;
    8800                 :            : 
    8801         [ -  + ]:         11 :    RefFace *old_face = CAST_TO( old_entity, RefFace );
    8802         [ +  - ]:         11 :    if( old_face )
    8803                 :            :    {
    8804                 :         11 :       RefFace *new_face = instance()->make_RefFace( old_face );
    8805         [ +  - ]:         11 :       new_entity = CAST_TO( new_face, RefEntity );
    8806                 :            :    }
    8807                 :            : 
    8808         [ -  + ]:         11 :    RefEdge *old_edge = CAST_TO( old_entity, RefEdge );
    8809         [ -  + ]:         11 :    if( old_edge )
    8810                 :            :    {
    8811                 :          0 :       RefEdge *new_edge = instance()->make_RefEdge( old_edge );
    8812         [ #  # ]:          0 :       new_entity = CAST_TO( new_edge, RefEntity );
    8813                 :            :    }
    8814                 :            : 
    8815         [ -  + ]:         11 :    RefVertex *old_vert = CAST_TO( old_entity, RefVertex );
    8816         [ -  + ]:         11 :    if( old_vert )
    8817                 :            :    {
    8818 [ #  # ][ #  # ]:          0 :       RefVertex *new_vert = instance()->make_RefVertex( old_vert->coordinates() );
    8819         [ #  # ]:          0 :       new_entity = CAST_TO( new_vert, RefEntity );
    8820                 :            :    }
    8821                 :            : 
    8822                 :         11 :    return new_entity;
    8823                 :            : }
    8824                 :            : 
    8825                 :            : //  Calls solid modeling engine to webcut with a sheet body.
    8826                 :          0 : CubitStatus GeometryModifyTool::webcut_with_sheet( DLIList<Body*> &webcut_body_list,
    8827                 :            :                                                    Body *sheet_body,
    8828                 :            :                                                    DLIList<Body*> &new_bodies,
    8829                 :            :                                                    DLIList<Body*> &neighboring_bodies,
    8830                 :            :                                                    ImprintType imprint_type,
    8831                 :            :                                                    CubitBoolean merge,
    8832                 :            :                                                    CubitBoolean preview)
    8833                 :            : {
    8834 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    8835                 :          0 :      return CUBIT_FAILURE;
    8836                 :            : 
    8837         [ #  # ]:          0 :    GfxPreview::clear();
    8838                 :            : 
    8839                 :            :    //remove any bodies with bbox that does not intersect tool body bbox
    8840         [ #  # ]:          0 :    CubitBox tool_bounding_box = sheet_body->bounding_box();
    8841         [ #  # ]:          0 :    remove_bodies_outside_bounding_box( webcut_body_list, tool_bounding_box );
    8842                 :            : 
    8843 [ #  # ][ #  # ]:          0 :    if( webcut_body_list.size() == 0 )
    8844                 :            :    {
    8845 [ #  # ][ #  # ]:          0 :      PRINT_INFO("Tool does not intersect any bodies/volumes.\n");
         [ #  # ][ #  # ]
    8846                 :          0 :      return CUBIT_FAILURE;
    8847                 :            :    }
    8848                 :            : 
    8849 [ #  # ][ #  # ]:          0 :    DLIList<Body*> original_body_list = webcut_body_list;
    8850         [ #  # ]:          0 :    webcut_body_list.append(sheet_body);
    8851 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list(webcut_body_list.size()), new_sms;
         [ #  # ][ #  # ]
                 [ #  # ]
    8852         [ #  # ]:          0 :    GeometryModifyEngine* gme = common_modify_engine(webcut_body_list, body_sm_list);
    8853         [ #  # ]:          0 :    if ( !gme )
    8854                 :            :    {
    8855 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing WEBCUTS with volumes containing geometry from\n"
                 [ #  # ]
    8856                 :            :                   "different modeling engines is not allowed.\n"
    8857         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    8858                 :          0 :       return CUBIT_FAILURE;
    8859                 :            :    }
    8860         [ #  # ]:          0 :    BodySM* tool_sm = body_sm_list.pop();
    8861                 :            : 
    8862 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_surface_ids;
    8863 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_curve_ids;
    8864 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> neighbor_imprint_list;
    8865 [ #  # ][ #  # ]:          0 :    DLIList<Body*> bodies_to_modify;
    8866                 :            : 
    8867         [ #  # ]:          0 :    if (!preview)
    8868                 :            :    {
    8869 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    8870                 :            :      {
    8871         [ #  # ]:          0 :        DLIList<Body*> bodies_to_save;
    8872         [ #  # ]:          0 :        bodies_to_save += webcut_body_list;
    8873         [ #  # ]:          0 :        bodies_to_save += neighboring_bodies;
    8874 [ #  # ][ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( bodies_to_save );
    8875                 :            :      }
    8876                 :            : 
    8877                 :            :      int i;
    8878 [ #  # ][ #  # ]:          0 :      for( i=neighboring_bodies.size(); i--; )
    8879                 :            :      {
    8880         [ #  # ]:          0 :        Body *neighbor_body = neighboring_bodies.get_and_step();
    8881         [ #  # ]:          0 :        BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    8882         [ #  # ]:          0 :        GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    8883                 :            : 
    8884         [ #  # ]:          0 :        if( gme == neighbor_gme )
    8885         [ #  # ]:          0 :          neighbor_imprint_list.append( tmp_body );
    8886                 :            :      }
    8887                 :            : 
    8888         [ #  # ]:          0 :      do_attribute_setup();
    8889         [ #  # ]:          0 :      DLIList<BodySM*> bodies_sm_to_modify;
    8890         [ #  # ]:          0 :      bodies_sm_to_modify += body_sm_list;
    8891         [ #  # ]:          0 :      bodies_sm_to_modify += neighbor_imprint_list;
    8892         [ #  # ]:          0 :      push_attributes_before_modify( bodies_sm_to_modify );
    8893         [ #  # ]:          0 :      bodies_to_modify += webcut_body_list;
    8894         [ #  # ]:          0 :      bodies_to_modify += neighboring_bodies;
    8895 [ #  # ][ #  # ]:          0 :      get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    8896                 :            :    }
    8897                 :            : 
    8898                 :            :    CubitStatus stat = gme->webcut (
    8899                 :            :        body_sm_list, tool_sm, neighbor_imprint_list,
    8900         [ #  # ]:          0 :        new_sms, imprint_type, preview  );
    8901                 :            : 
    8902         [ #  # ]:          0 :    if (!preview)
    8903                 :            :    {
    8904         [ #  # ]:          0 :      restore_vg_after_modify(new_sms, bodies_to_modify, gme);
    8905         [ #  # ]:          0 :      remove_pushed_attributes(new_sms, bodies_to_modify );
    8906                 :            :    }
    8907                 :            : 
    8908         [ #  # ]:          0 :    if( stat == CUBIT_FAILURE )
    8909                 :            :    {
    8910         [ #  # ]:          0 :      do_attribute_cleanup();
    8911                 :            : 
    8912 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
    8913                 :            :      {
    8914         [ #  # ]:          0 :        if( stat == CUBIT_SUCCESS )
    8915         [ #  # ]:          0 :          CubitUndo::note_result_bodies( new_bodies );
    8916                 :            :        else
    8917         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    8918                 :            :      }
    8919                 :          0 :      return CUBIT_FAILURE;
    8920                 :            :    }
    8921                 :            : 
    8922                 :            :    // finish up if not a preview
    8923         [ #  # ]:          0 :    if (!preview)
    8924                 :            :    {
    8925                 :            :      stat = finish_webcut( webcut_body_list, new_sms, merge, stat, new_bodies,
    8926         [ #  # ]:          0 :                            &merged_surface_ids, &merged_curve_ids );
    8927                 :            :       // leave webcut_body_list as we found it -- remove appended tool body
    8928         [ #  # ]:          0 :      webcut_body_list.pop();
    8929                 :            : 
    8930         [ #  # ]:          0 :      do_attribute_cleanup();
    8931                 :            : 
    8932 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    8933                 :            :      {
    8934         [ #  # ]:          0 :        if( stat == CUBIT_SUCCESS )
    8935         [ #  # ]:          0 :          CubitUndo::note_result_bodies( new_bodies );
    8936                 :            :        else
    8937         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    8938                 :            :      }
    8939                 :            :    }
    8940                 :            : 
    8941                 :            : 
    8942         [ #  # ]:          0 :    return stat;
    8943                 :            : }
    8944                 :            : //  Calls solid modeling engine to webcut with a sheet body.
    8945                 :          0 : CubitStatus GeometryModifyTool::webcut_with_extended_sheet( DLIList<Body*> &webcut_body_list,
    8946                 :            :                                                            DLIList<RefFace*> &ref_face_list,
    8947                 :            :                                                            DLIList<Body*> &new_bodies,
    8948                 :            :                                                            DLIList<Body*> &neighboring_bodies,
    8949                 :            :                                                            int &num_cut,
    8950                 :            :                                                            ImprintType imprint_type,
    8951                 :            :                                                            CubitBoolean merge,
    8952                 :            :                                                            CubitBoolean preview)
    8953                 :            : {
    8954 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    8955                 :          0 :      return CUBIT_FAILURE;
    8956                 :            : 
    8957         [ #  # ]:          0 :    GfxPreview::clear();
    8958                 :            : 
    8959         [ #  # ]:          0 :    DLIList<RefEntity*> ref_entity_list;
    8960 [ #  # ][ #  # ]:          0 :    CAST_LIST( ref_face_list, ref_entity_list, RefEntity );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    8961 [ #  # ][ #  # ]:          0 :    if( !same_modify_engine( ref_entity_list ) )
    8962                 :            :    {
    8963 [ #  # ][ #  # ]:          0 :      PRINT_ERROR( "Extending surfaces from different geometry engines is\n"
                 [ #  # ]
    8964         [ #  # ]:          0 :        "       not allowed.\n\n" );
    8965                 :          0 :      return CUBIT_FAILURE;
    8966                 :            :    }
    8967                 :            : 
    8968 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list(webcut_body_list.size()), new_sms;
         [ #  # ][ #  # ]
                 [ #  # ]
    8969         [ #  # ]:          0 :    GeometryModifyEngine* gme = common_modify_engine(webcut_body_list, body_sm_list);
    8970                 :            : 
    8971         [ #  # ]:          0 :    if( !gme )
    8972                 :            :    {
    8973 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Performing WEBCUTS on volumes containing geometry from\n"
                 [ #  # ]
    8974                 :            :                   "different modeling engines is not allowed.\n"
    8975         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    8976                 :          0 :       return CUBIT_FAILURE;
    8977                 :            :    }
    8978                 :            : 
    8979                 :            :    const char* modeler =
    8980 [ #  # ][ #  # ]:          0 :           ref_face_list.get()->get_geometry_query_engine()->modeler_type();
                 [ #  # ]
    8981         [ #  # ]:          0 :    if (strncmp("virtual", modeler, 7) == 0)
    8982                 :            :    {
    8983 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Cannot extend virtual surfaces.\n"
                 [ #  # ]
    8984         [ #  # ]:          0 :                  "Remove virtual layer before operation.\n");
    8985                 :          0 :      return CUBIT_FAILURE;
    8986                 :            :    }
    8987                 :            : 
    8988                 :          0 :    Surface* surf_ptr = 0;
    8989 [ #  # ][ #  # ]:          0 :    TopologyBridge* bridge = ref_face_list.get()->bridge_manager()->topology_bridge(gme->get_gqe());
         [ #  # ][ #  # ]
    8990         [ #  # ]:          0 :    surf_ptr = dynamic_cast<Surface*>(bridge);
    8991                 :            : 
    8992         [ #  # ]:          0 :    if ( !surf_ptr )
    8993                 :            :    {
    8994 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing WEBCUTS on volumes containing geometry from a\n"
                 [ #  # ]
    8995                 :            :                   "different modeling engine than the extended surfaces is\n"
    8996                 :            :                   "not allowed.\n"
    8997         [ #  # ]:          0 :                   "Delete uncommon geometry on these volumes before operation.\n\n");
    8998                 :          0 :       return CUBIT_FAILURE;
    8999                 :            :    }
    9000                 :            : 
    9001         [ #  # ]:          0 :    GeometryQueryEngine *gqe = gme->get_gqe();
    9002                 :            : 
    9003                 :            :    int i;
    9004                 :            :    RefFace *ref_face_ptr;
    9005 [ #  # ][ #  # ]:          0 :    DLIList<Surface*> surf_list;
    9006 [ #  # ][ #  # ]:          0 :    for( i=ref_face_list.size(); i--; )
    9007                 :            :    {
    9008         [ #  # ]:          0 :      ref_face_ptr = ref_face_list.get_and_step();
    9009 [ #  # ][ #  # ]:          0 :      bridge = ref_face_ptr->bridge_manager()->topology_bridge(gqe);
    9010         [ #  # ]:          0 :      surf_ptr = dynamic_cast<Surface*>(bridge);
    9011         [ #  # ]:          0 :      surf_list.append( surf_ptr );
    9012                 :            :    }
    9013                 :            : 
    9014 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_surface_ids;
    9015 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_curve_ids;
    9016 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> neighbor_imprint_list;
    9017 [ #  # ][ #  # ]:          0 :    DLIList<Body*> bodies_to_modify;
    9018                 :            : 
    9019         [ #  # ]:          0 :    if (!preview)
    9020                 :            :    {
    9021 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9022                 :            :      {
    9023         [ #  # ]:          0 :        DLIList<Body*> bodies_to_save;
    9024         [ #  # ]:          0 :        bodies_to_save += webcut_body_list;
    9025         [ #  # ]:          0 :        bodies_to_save += neighboring_bodies;
    9026 [ #  # ][ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( bodies_to_save );
    9027                 :            :      }
    9028                 :            : 
    9029                 :            :      int i;
    9030 [ #  # ][ #  # ]:          0 :      for( i=neighboring_bodies.size(); i--; )
    9031                 :            :      {
    9032         [ #  # ]:          0 :        Body *neighbor_body = neighboring_bodies.get_and_step();
    9033         [ #  # ]:          0 :        BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    9034         [ #  # ]:          0 :        GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    9035                 :            : 
    9036         [ #  # ]:          0 :        if( gme == neighbor_gme )
    9037         [ #  # ]:          0 :          neighbor_imprint_list.append( tmp_body );
    9038                 :            :      }
    9039                 :            : 
    9040         [ #  # ]:          0 :      do_attribute_setup();
    9041         [ #  # ]:          0 :      DLIList<BodySM*> bodies_sm_to_modify;
    9042         [ #  # ]:          0 :      bodies_sm_to_modify += body_sm_list;
    9043         [ #  # ]:          0 :      bodies_sm_to_modify += neighbor_imprint_list;
    9044         [ #  # ]:          0 :      push_attributes_before_modify( bodies_sm_to_modify );
    9045         [ #  # ]:          0 :      bodies_to_modify += webcut_body_list;
    9046         [ #  # ]:          0 :      bodies_to_modify += neighboring_bodies;
    9047 [ #  # ][ #  # ]:          0 :      get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    9048                 :            :    }
    9049                 :            : 
    9050                 :            :    CubitStatus stat = gme->webcut_with_extended_sheet( body_sm_list,
    9051                 :            :      surf_list, neighbor_imprint_list, new_sms, num_cut, imprint_type,
    9052         [ #  # ]:          0 :      preview );
    9053                 :            : 
    9054         [ #  # ]:          0 :    if (!preview)
    9055                 :            :    {
    9056         [ #  # ]:          0 :      restore_vg_after_modify(new_sms, bodies_to_modify, gme);
    9057         [ #  # ]:          0 :      remove_pushed_attributes(new_sms, bodies_to_modify);
    9058                 :            :      stat = finish_webcut(webcut_body_list, new_sms, merge, stat, new_bodies,
    9059         [ #  # ]:          0 :                           &merged_surface_ids, &merged_curve_ids );
    9060         [ #  # ]:          0 :      do_attribute_cleanup();
    9061                 :            : 
    9062 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9063                 :            :      {
    9064         [ #  # ]:          0 :        if( stat == CUBIT_SUCCESS )
    9065         [ #  # ]:          0 :          CubitUndo::note_result_bodies( new_bodies );
    9066                 :            :        else
    9067         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    9068                 :            :      }
    9069                 :            :    }
    9070                 :            : 
    9071         [ #  # ]:          0 :    return stat;
    9072                 :            : }
    9073                 :            : 
    9074                 :            : 
    9075                 :          0 : CubitStatus GeometryModifyTool::webcut_with_sweep_surfaces_rotated(
    9076                 :            :                             DLIList<Body*> &webcut_body_list,
    9077                 :            :                             DLIList<RefFace*> &tool_faces,
    9078                 :            :                             CubitVector &point,
    9079                 :            :                             CubitVector &sweep_axis,
    9080                 :            :                             double angle,
    9081                 :            :                             RefFace* stop_surf,
    9082                 :            :                             bool up_to_next,
    9083                 :            :                             DLIList<Body*> &new_bodies,
    9084                 :            :                             DLIList<Body*> &neighboring_bodies,
    9085                 :            :                             ImprintType imprint_type,
    9086                 :            :                             CubitBoolean merge,
    9087                 :            :                             CubitBoolean preview)
    9088                 :            : {
    9089                 :            : 
    9090 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    9091                 :          0 :      return CUBIT_FAILURE;
    9092                 :            : 
    9093         [ #  # ]:          0 :    GfxPreview::clear();
    9094                 :            : 
    9095 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list(webcut_body_list.size()), new_sms;
         [ #  # ][ #  # ]
    9096         [ #  # ]:          0 :    GeometryModifyEngine* gme = common_modify_engine(webcut_body_list, body_sm_list);
    9097 [ #  # ][ #  # ]:          0 :    DLIList<Surface*> surfaces_to_sweep;
    9098         [ #  # ]:          0 :    if (gme)
    9099                 :            :    {
    9100         [ #  # ]:          0 :      GeometryModifyEngine* surf_gme = common_modify_engine( tool_faces, surfaces_to_sweep );
    9101         [ #  # ]:          0 :      if( gme != surf_gme )
    9102 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("All geometry not from the same modeling engine.\n");
         [ #  # ][ #  # ]
    9103                 :            :    }
    9104                 :            : 
    9105                 :          0 :    Surface *stop_surface = NULL;
    9106         [ #  # ]:          0 :    if( stop_surf )
    9107                 :            :    {
    9108         [ #  # ]:          0 :      GeometryModifyEngine *tmp_gme = get_engine(stop_surf);
    9109                 :            : 
    9110         [ #  # ]:          0 :      if( gme != tmp_gme )
    9111                 :            :      {
    9112 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Stop surface %d is not of same modeling engine as other input geometry.\n",
         [ #  # ][ #  # ]
    9113         [ #  # ]:          0 :                     stop_surf->id() );
    9114                 :          0 :        return CUBIT_FAILURE;
    9115                 :            :      }
    9116                 :            : 
    9117         [ #  # ]:          0 :      stop_surface = stop_surf->get_surface_ptr();
    9118                 :            :    }
    9119                 :            : 
    9120 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_surface_ids;
    9121 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_curve_ids;
    9122 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> neighbor_imprint_list;
    9123 [ #  # ][ #  # ]:          0 :    DLIList<Body*> bodies_to_modify;
    9124                 :            : 
    9125         [ #  # ]:          0 :    if (!preview)
    9126                 :            :    {
    9127 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9128                 :            :      {
    9129         [ #  # ]:          0 :        DLIList<Body*> bodies_to_save;
    9130         [ #  # ]:          0 :        bodies_to_save += webcut_body_list;
    9131         [ #  # ]:          0 :        bodies_to_save += neighboring_bodies;
    9132 [ #  # ][ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( bodies_to_save );
    9133                 :            :      }
    9134                 :            : 
    9135                 :            :      int i;
    9136 [ #  # ][ #  # ]:          0 :      for( i=neighboring_bodies.size(); i--; )
    9137                 :            :      {
    9138         [ #  # ]:          0 :        Body *neighbor_body = neighboring_bodies.get_and_step();
    9139         [ #  # ]:          0 :        BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    9140         [ #  # ]:          0 :        GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    9141                 :            : 
    9142         [ #  # ]:          0 :        if( gme == neighbor_gme )
    9143         [ #  # ]:          0 :          neighbor_imprint_list.append( tmp_body );
    9144                 :            :      }
    9145                 :            : 
    9146         [ #  # ]:          0 :      do_attribute_setup();
    9147         [ #  # ]:          0 :      DLIList<BodySM*> bodies_sm_to_modify;
    9148         [ #  # ]:          0 :      bodies_sm_to_modify += body_sm_list;
    9149         [ #  # ]:          0 :      bodies_sm_to_modify += neighbor_imprint_list;
    9150         [ #  # ]:          0 :      push_attributes_before_modify( bodies_sm_to_modify );
    9151         [ #  # ]:          0 :      bodies_to_modify += webcut_body_list;
    9152         [ #  # ]:          0 :      bodies_to_modify += neighboring_bodies;
    9153 [ #  # ][ #  # ]:          0 :      get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    9154                 :            :    }
    9155                 :            : 
    9156                 :          0 :    BodySM* cutting_tool_ptr = NULL;
    9157                 :            :    CubitStatus stat = prepare_surface_sweep(body_sm_list,surfaces_to_sweep,
    9158                 :            :                            sweep_axis,false,false,false,
    9159         [ #  # ]:          0 :                            up_to_next,stop_surface, NULL, cutting_tool_ptr, &point, &angle);
    9160         [ #  # ]:          0 :    if(stat == CUBIT_SUCCESS )
    9161                 :            :    {
    9162                 :            :      stat = gme->webcut( body_sm_list, cutting_tool_ptr, neighbor_imprint_list,
    9163         [ #  # ]:          0 :                          new_sms, imprint_type, preview );
    9164                 :            : 
    9165                 :            :      // Delete the BodySM that was created to be used as a tool
    9166 [ #  # ][ #  # ]:          0 :      gme->get_gqe()->delete_solid_model_entities(cutting_tool_ptr) ;
    9167                 :            :    }
    9168                 :            : 
    9169                 :            :    else
    9170                 :            :    {
    9171 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Can't create a swept surface for webcut.\n");
         [ #  # ][ #  # ]
    9172                 :          0 :      return CUBIT_FAILURE;
    9173                 :            :    }
    9174                 :            : 
    9175                 :            :    // if not previewing do the rest of the creation
    9176         [ #  # ]:          0 :    if (!preview)
    9177                 :            :    {
    9178         [ #  # ]:          0 :      restore_vg_after_modify(new_sms, bodies_to_modify, gme);
    9179         [ #  # ]:          0 :      remove_pushed_attributes(new_sms, bodies_to_modify);
    9180                 :            :      stat = finish_webcut(webcut_body_list, new_sms, merge, stat, new_bodies,
    9181         [ #  # ]:          0 :                           &merged_surface_ids, &merged_curve_ids );
    9182         [ #  # ]:          0 :      do_attribute_cleanup();
    9183                 :            : 
    9184 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9185                 :            :      {
    9186         [ #  # ]:          0 :        if( stat == CUBIT_SUCCESS )
    9187         [ #  # ]:          0 :          CubitUndo::note_result_bodies( new_bodies );
    9188                 :            :        else
    9189         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    9190                 :            :      }
    9191                 :            :    }
    9192                 :            : 
    9193         [ #  # ]:          0 :    return stat;
    9194                 :            : }
    9195                 :            : 
    9196                 :          0 : CubitStatus GeometryModifyTool::webcut_with_sweep_curves_rotated(
    9197                 :            :                             DLIList<Body*> &webcut_body_list,
    9198                 :            :                             DLIList<RefEdge*> &tool_curves,
    9199                 :            :                             CubitVector &point,
    9200                 :            :                             CubitVector &sweep_axis,
    9201                 :            :                             double angle,
    9202                 :            :                             RefFace* stop_surf,
    9203                 :            :                             DLIList<Body*> &new_bodies,
    9204                 :            :                             DLIList<Body*> &neighboring_bodies,
    9205                 :            :                             ImprintType imprint_type,
    9206                 :            :                             CubitBoolean merge,
    9207                 :            :                             CubitBoolean preview)
    9208                 :            : {
    9209                 :            : 
    9210 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    9211                 :          0 :      return CUBIT_FAILURE;
    9212                 :            : 
    9213         [ #  # ]:          0 :    GfxPreview::clear();
    9214                 :            : 
    9215 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list(webcut_body_list.size()), new_sms;
         [ #  # ][ #  # ]
    9216         [ #  # ]:          0 :    GeometryModifyEngine* gme = common_modify_engine(webcut_body_list, body_sm_list);
    9217 [ #  # ][ #  # ]:          0 :    DLIList<Curve*> curves_to_sweep;
    9218         [ #  # ]:          0 :    if (gme)
    9219                 :            :    {
    9220         [ #  # ]:          0 :      DLIList<RefFace*> dummy1;
    9221 [ #  # ][ #  # ]:          0 :      DLIList<Surface*> dummy2;
    9222                 :            :      GeometryModifyEngine* surf_gme = common_modify_engine( dummy1, tool_curves,
    9223         [ #  # ]:          0 :                                                             dummy2, curves_to_sweep );
    9224         [ #  # ]:          0 :      if( gme != surf_gme )
    9225 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("All geometry not from the same modeling engine.\n");
         [ #  # ][ #  # ]
                 [ #  # ]
    9226                 :            :    }
    9227                 :            : 
    9228                 :          0 :    Surface *stop_surface = NULL;
    9229         [ #  # ]:          0 :    if( stop_surf )
    9230                 :            :    {
    9231         [ #  # ]:          0 :      GeometryModifyEngine *tmp_gme = get_engine(stop_surf);
    9232                 :            : 
    9233         [ #  # ]:          0 :      if( gme != tmp_gme )
    9234                 :            :      {
    9235 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Stop surface %d is not of same modeling engine as other input geometry.\n",
         [ #  # ][ #  # ]
    9236         [ #  # ]:          0 :                     stop_surf->id() );
    9237                 :          0 :        return CUBIT_FAILURE;
    9238                 :            :      }
    9239                 :            : 
    9240         [ #  # ]:          0 :      stop_surface = stop_surf->get_surface_ptr();
    9241                 :            :    }
    9242                 :            : 
    9243 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_surface_ids;
    9244 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_curve_ids;
    9245 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> neighbor_imprint_list;
    9246 [ #  # ][ #  # ]:          0 :    DLIList<Body*> bodies_to_modify;
    9247                 :            : 
    9248         [ #  # ]:          0 :    if (!preview)
    9249                 :            :    {
    9250 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9251                 :            :      {
    9252         [ #  # ]:          0 :        DLIList<Body*> bodies_to_save;
    9253         [ #  # ]:          0 :        bodies_to_save += webcut_body_list;
    9254         [ #  # ]:          0 :        bodies_to_save += neighboring_bodies;
    9255 [ #  # ][ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( bodies_to_save );
    9256                 :            :      }
    9257                 :            : 
    9258                 :            :      int i;
    9259 [ #  # ][ #  # ]:          0 :      for( i=neighboring_bodies.size(); i--; )
    9260                 :            :      {
    9261         [ #  # ]:          0 :        Body *neighbor_body = neighboring_bodies.get_and_step();
    9262         [ #  # ]:          0 :        BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    9263         [ #  # ]:          0 :        GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    9264                 :            : 
    9265         [ #  # ]:          0 :        if( gme == neighbor_gme )
    9266         [ #  # ]:          0 :          neighbor_imprint_list.append( tmp_body );
    9267                 :            :      }
    9268                 :            : 
    9269         [ #  # ]:          0 :      do_attribute_setup();
    9270         [ #  # ]:          0 :      DLIList<BodySM*> bodies_sm_to_modify;
    9271         [ #  # ]:          0 :      bodies_sm_to_modify += body_sm_list;
    9272         [ #  # ]:          0 :      bodies_sm_to_modify += neighbor_imprint_list;
    9273         [ #  # ]:          0 :      push_attributes_before_modify( bodies_sm_to_modify );
    9274         [ #  # ]:          0 :      bodies_to_modify += webcut_body_list;
    9275         [ #  # ]:          0 :      bodies_to_modify += neighboring_bodies;
    9276 [ #  # ][ #  # ]:          0 :      get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    9277                 :            :    }
    9278                 :            : 
    9279                 :            :    //sweep the curves.
    9280 [ #  # ][ #  # ]:          0 :    DLIList<GeometryEntity*> ref_ent_list;
    9281 [ #  # ][ #  # ]:          0 :    for(int i = 0; i < curves_to_sweep.size(); i++)
    9282 [ #  # ][ #  # ]:          0 :      ref_ent_list.append((GeometryEntity*)(curves_to_sweep.get_and_step()));
    9283                 :            : 
    9284 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> swept_bodies;
    9285                 :            :    CubitStatus stat = gme->sweep_rotational(ref_ent_list,swept_bodies,point,
    9286                 :            :                                       sweep_axis,angle,0, 0.0, 0,false,false,
    9287         [ #  # ]:          0 :                                       false,stop_surface);
    9288 [ #  # ][ #  # ]:          0 :    if(stat == CUBIT_FAILURE  && swept_bodies.size() == 0)
         [ #  # ][ #  # ]
    9289                 :          0 :      return stat;
    9290                 :            : 
    9291                 :            :    //stitch faces together
    9292                 :          0 :    BodySM* cutting_tool_ptr = NULL;
    9293 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> cutting_tools;
    9294         [ #  # ]:          0 :    stat = gme->stitch(swept_bodies, cutting_tools, CUBIT_FALSE, 1E-6);
    9295                 :            : 
    9296 [ #  # ][ #  # ]:          0 :    if(cutting_tools.size() > 1 || cutting_tools.size() == 0)
         [ #  # ][ #  # ]
                 [ #  # ]
    9297                 :            :      {
    9298                 :            :        //delete all swept faces
    9299 [ #  # ][ #  # ]:          0 :        for(int i = 0; i < cutting_tools.size(); i++)
    9300 [ #  # ][ #  # ]:          0 :          gme->get_gqe()->delete_solid_model_entities(cutting_tools.get_and_step()) ;
                 [ #  # ]
    9301                 :          0 :        return stat;
    9302                 :            :      }
    9303                 :            :    else
    9304                 :            :    {
    9305         [ #  # ]:          0 :      cutting_tool_ptr = cutting_tools.get();
    9306                 :            :      stat = gme->webcut( body_sm_list, cutting_tool_ptr, neighbor_imprint_list,
    9307         [ #  # ]:          0 :                          new_sms, imprint_type, preview);
    9308                 :            : 
    9309                 :            :      // Delete the BodySM that was created to be used as a tool
    9310 [ #  # ][ #  # ]:          0 :      gme->get_gqe()->delete_solid_model_entities(cutting_tool_ptr) ;
    9311                 :            :    }
    9312                 :            : 
    9313         [ #  # ]:          0 :    if (!preview)
    9314                 :            :    {
    9315         [ #  # ]:          0 :      restore_vg_after_modify(new_sms, bodies_to_modify, gme);
    9316         [ #  # ]:          0 :      remove_pushed_attributes(new_sms, bodies_to_modify);
    9317                 :            :      stat = finish_webcut(webcut_body_list, new_sms, merge, stat, new_bodies,
    9318         [ #  # ]:          0 :                           &merged_surface_ids, &merged_curve_ids );
    9319         [ #  # ]:          0 :      do_attribute_cleanup();
    9320                 :            : 
    9321 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9322                 :            :      {
    9323         [ #  # ]:          0 :        if( stat == CUBIT_SUCCESS )
    9324         [ #  # ]:          0 :          CubitUndo::note_result_bodies( new_bodies );
    9325                 :            :        else
    9326         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    9327                 :            :      }
    9328                 :            :    }
    9329                 :            : 
    9330         [ #  # ]:          0 :    return stat;
    9331                 :            : }
    9332                 :            : 
    9333                 :          0 : CubitStatus GeometryModifyTool::webcut_with_sweep_curves(
    9334                 :            :                             DLIList<Body*> &webcut_body_list,
    9335                 :            :                             DLIList<RefEdge*> &tool_curves,
    9336                 :            :                             const CubitVector sweep_vector,
    9337                 :            :                             bool through_all,
    9338                 :            :                             RefFace *stop_surf,
    9339                 :            :                             RefEdge* edge_to_sweep_along,
    9340                 :            :                             DLIList<Body*> &new_bodies,
    9341                 :            :                             DLIList<Body*> &neighboring_bodies,
    9342                 :            :                             ImprintType imprint_type,
    9343                 :            :                             CubitBoolean merge,
    9344                 :            :                             CubitBoolean preview)
    9345                 :            : {
    9346 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    9347                 :          0 :      return CUBIT_FAILURE;
    9348                 :            : 
    9349         [ #  # ]:          0 :    GfxPreview::clear();
    9350                 :            : 
    9351 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list(webcut_body_list.size()), new_sms;
         [ #  # ][ #  # ]
    9352         [ #  # ]:          0 :    GeometryModifyEngine* gme = common_modify_engine(webcut_body_list, body_sm_list);
    9353 [ #  # ][ #  # ]:          0 :    DLIList<Curve*> curves_to_sweep;
    9354         [ #  # ]:          0 :    if (gme)
    9355                 :            :    {
    9356         [ #  # ]:          0 :      DLIList<RefFace*> dummy1;
    9357 [ #  # ][ #  # ]:          0 :      DLIList<Surface*> dummy2;
                 [ #  # ]
    9358                 :            :      GeometryModifyEngine* surf_gme = common_modify_engine( dummy1, tool_curves,
    9359         [ #  # ]:          0 :                                                             dummy2, curves_to_sweep );
    9360         [ #  # ]:          0 :      if( gme != surf_gme ){
    9361 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("All geometry not from the same modeling engine.\n");
         [ #  # ][ #  # ]
    9362 [ #  # ][ #  # ]:          0 :        return CUBIT_FAILURE;
    9363                 :          0 :      }
    9364                 :            :    }
    9365                 :            :    else{
    9366 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("All volumes not from the same modeling engine.\n");
         [ #  # ][ #  # ]
    9367                 :          0 :      return CUBIT_FAILURE;
    9368                 :            :    }
    9369                 :            : 
    9370                 :          0 :    Surface *stop_surface = NULL;
    9371         [ #  # ]:          0 :    if( stop_surf )
    9372                 :            :    {
    9373         [ #  # ]:          0 :      GeometryModifyEngine *tmp_gme = get_engine(stop_surf);
    9374                 :            : 
    9375         [ #  # ]:          0 :      if( gme != tmp_gme )
    9376                 :            :      {
    9377 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Stop surface %d is not of same modeling engine as other input geometry.\n",
         [ #  # ][ #  # ]
    9378         [ #  # ]:          0 :                     stop_surf->id() );
    9379                 :          0 :        return CUBIT_FAILURE;
    9380                 :            :      }
    9381                 :            : 
    9382         [ #  # ]:          0 :      stop_surface = stop_surf->get_surface_ptr();
    9383                 :            :    }
    9384                 :            : 
    9385                 :          0 :    Curve *curve_to_sweep_along = NULL;
    9386         [ #  # ]:          0 :    if( edge_to_sweep_along )
    9387                 :            :    {
    9388         [ #  # ]:          0 :      GeometryModifyEngine *tmp_gme = get_engine(edge_to_sweep_along);
    9389                 :            : 
    9390         [ #  # ]:          0 :      if( gme != tmp_gme )
    9391                 :            :      {
    9392 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Curve %d does is not of same modeling as other input geometry.\n",
         [ #  # ][ #  # ]
    9393         [ #  # ]:          0 :                     edge_to_sweep_along->id() );
    9394                 :          0 :        return CUBIT_FAILURE;
    9395                 :            :      }
    9396                 :            : 
    9397         [ #  # ]:          0 :      curve_to_sweep_along = edge_to_sweep_along->get_curve_ptr();
    9398                 :            :    }
    9399                 :            : 
    9400 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_surface_ids;
    9401 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_curve_ids;
    9402 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> neighbor_imprint_list;
    9403 [ #  # ][ #  # ]:          0 :    DLIList<Body*> bodies_to_modify;
    9404                 :            : 
    9405         [ #  # ]:          0 :    if (!preview)
    9406                 :            :    {
    9407 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9408                 :            :      {
    9409         [ #  # ]:          0 :        DLIList<Body*> bodies_to_save;
    9410         [ #  # ]:          0 :        bodies_to_save += webcut_body_list;
    9411         [ #  # ]:          0 :        bodies_to_save += neighboring_bodies;
    9412 [ #  # ][ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( bodies_to_save );
    9413                 :            :      }
    9414                 :            : 
    9415                 :            :      int i;
    9416 [ #  # ][ #  # ]:          0 :      for( i=neighboring_bodies.size(); i--; )
    9417                 :            :      {
    9418         [ #  # ]:          0 :        Body *neighbor_body = neighboring_bodies.get_and_step();
    9419         [ #  # ]:          0 :        BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    9420         [ #  # ]:          0 :        GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    9421                 :            : 
    9422         [ #  # ]:          0 :        if( gme == neighbor_gme )
    9423         [ #  # ]:          0 :          neighbor_imprint_list.append( tmp_body );
    9424                 :            :      }
    9425                 :            : 
    9426         [ #  # ]:          0 :      do_attribute_setup();
    9427         [ #  # ]:          0 :      DLIList<BodySM*> bodies_sm_to_modify;
    9428         [ #  # ]:          0 :      bodies_sm_to_modify += body_sm_list;
    9429         [ #  # ]:          0 :      bodies_sm_to_modify += neighbor_imprint_list;
    9430         [ #  # ]:          0 :      push_attributes_before_modify( bodies_sm_to_modify );
    9431         [ #  # ]:          0 :      bodies_to_modify += webcut_body_list;
    9432         [ #  # ]:          0 :      bodies_to_modify += neighboring_bodies;
    9433 [ #  # ][ #  # ]:          0 :      get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    9434                 :            :    }
    9435                 :            : 
    9436         [ #  # ]:          0 :    CubitVector tmp_sweep_vector = sweep_vector;
    9437                 :            :     //get model bbox info...will scale sweep vector by its diagonal
    9438                 :            :     //so that we go far enough
    9439 [ #  # ][ #  # ]:          0 :     if( through_all || stop_surf )
    9440                 :            :       {
    9441 [ #  # ][ #  # ]:          0 :         CubitBox bounding_box = GeometryQueryTool::instance()->model_bounding_box();
    9442         [ #  # ]:          0 :         tmp_sweep_vector.normalize();
    9443 [ #  # ][ #  # ]:          0 :         tmp_sweep_vector*=(2*bounding_box.diagonal().length());
         [ #  # ][ #  # ]
    9444                 :            :       }
    9445                 :            : 
    9446 [ #  # ][ #  # ]:          0 :     DLIList<GeometryEntity*> ref_ent_list;
    9447 [ #  # ][ #  # ]:          0 :     for(int i = 0; i < curves_to_sweep.size(); i++)
    9448 [ #  # ][ #  # ]:          0 :       ref_ent_list.append((GeometryEntity*)(curves_to_sweep.get_and_step()));
    9449 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> swept_bodies;
    9450                 :            :     CubitStatus stat;
    9451                 :            : 
    9452         [ #  # ]:          0 :     if( curve_to_sweep_along )
    9453                 :            :     {
    9454         [ #  # ]:          0 :       DLIList<Curve*> curves_to_sweep_along;
    9455         [ #  # ]:          0 :       curves_to_sweep_along.append(curve_to_sweep_along);
    9456                 :            :       stat = gme->sweep_along_curve(ref_ent_list, swept_bodies,
    9457         [ #  # ]:          0 :                                curves_to_sweep_along,0.0,0,false,stop_surface);
    9458                 :            : 
    9459 [ #  # ][ #  # ]:          0 :       if (!stat && swept_bodies.size() == 0)
         [ #  # ][ #  # ]
    9460 [ #  # ][ #  # ]:          0 :         return stat;
    9461                 :            :     }
    9462                 :            : 
    9463                 :            :     else
    9464                 :            :     {
    9465                 :            :       stat = gme->sweep_translational(ref_ent_list, swept_bodies,
    9466         [ #  # ]:          0 :                              tmp_sweep_vector,0.0,0, false, false, stop_surface);
    9467                 :            : 
    9468 [ #  # ][ #  # ]:          0 :       if (!stat && swept_bodies.size() == 0)
         [ #  # ][ #  # ]
    9469                 :          0 :         return stat;
    9470                 :            :     }
    9471                 :            : 
    9472                 :            :     //stitch faces together
    9473                 :          0 :     BodySM* cutting_tool_ptr = NULL;
    9474 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> cutting_tools;
    9475         [ #  # ]:          0 :     stat = gme->stitch(swept_bodies, cutting_tools, CUBIT_FALSE, 1E-6);
    9476                 :            : 
    9477 [ #  # ][ #  # ]:          0 :     if(cutting_tools.size() > 1 || cutting_tools.size() == 0)
         [ #  # ][ #  # ]
                 [ #  # ]
    9478                 :            :     {
    9479                 :            :         //delete all swept faces
    9480 [ #  # ][ #  # ]:          0 :         for(int i = 0; i < cutting_tools.size(); i++)
    9481 [ #  # ][ #  # ]:          0 :           gme->get_gqe()->delete_solid_model_entities(cutting_tools.get_and_step()) ;
                 [ #  # ]
    9482                 :          0 :         return CUBIT_FAILURE;
    9483                 :            :     }
    9484                 :            :     else
    9485                 :            :     {
    9486         [ #  # ]:          0 :         cutting_tool_ptr = cutting_tools.get();
    9487                 :            :         stat = gme->webcut( body_sm_list, cutting_tool_ptr, neighbor_imprint_list,
    9488         [ #  # ]:          0 :                             new_sms, imprint_type, preview );
    9489                 :            : 
    9490                 :            :         // Delete the BodySM that was created to be used as a tool
    9491 [ #  # ][ #  # ]:          0 :         gme->get_gqe()->delete_solid_model_entities(cutting_tool_ptr) ;
    9492                 :            :     }
    9493                 :            : 
    9494         [ #  # ]:          0 :    if (!preview)
    9495                 :            :    {
    9496         [ #  # ]:          0 :      restore_vg_after_modify(new_sms, bodies_to_modify, gme);
    9497         [ #  # ]:          0 :      remove_pushed_attributes(new_sms, bodies_to_modify);
    9498                 :            :      stat = finish_webcut(webcut_body_list, new_sms, merge, stat, new_bodies,
    9499         [ #  # ]:          0 :                           &merged_surface_ids, &merged_curve_ids );
    9500         [ #  # ]:          0 :      do_attribute_cleanup();
    9501                 :            : 
    9502 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9503                 :            :      {
    9504         [ #  # ]:          0 :        if( stat == CUBIT_SUCCESS )
    9505         [ #  # ]:          0 :          CubitUndo::note_result_bodies( new_bodies );
    9506                 :            :        else
    9507         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    9508                 :            :      }
    9509                 :            :    }
    9510                 :            : 
    9511         [ #  # ]:          0 :    return stat;
    9512                 :            : }
    9513                 :            : 
    9514                 :          0 : CubitStatus GeometryModifyTool::webcut_with_sweep_surfaces(
    9515                 :            :                             DLIList<Body*> &webcut_body_list,
    9516                 :            :                             DLIList<RefFace*> &tool_faces,
    9517                 :            :                             const CubitVector sweep_vector,
    9518                 :            :                             bool sweep_perp,
    9519                 :            :                             bool through_all,
    9520                 :            :                             bool outward,
    9521                 :            :                             bool up_to_next,
    9522                 :            :                             RefFace* stop_surf,
    9523                 :            :                             RefEdge* edge_to_sweep_along,
    9524                 :            :                             DLIList<Body*> &new_bodies,
    9525                 :            :                             DLIList<Body*> &neighboring_bodies,
    9526                 :            :                             ImprintType imprint_type,
    9527                 :            :                             CubitBoolean merge,
    9528                 :            :                             CubitBoolean preview)
    9529                 :            : {
    9530 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( webcut_body_list, "WEBCUT" ))
    9531                 :          0 :      return CUBIT_FAILURE;
    9532                 :            : 
    9533         [ #  # ]:          0 :    GfxPreview::clear();
    9534                 :            : 
    9535 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list(webcut_body_list.size()), new_sms;
         [ #  # ][ #  # ]
    9536         [ #  # ]:          0 :    GeometryModifyEngine* gme = common_modify_engine(webcut_body_list, body_sm_list);
    9537 [ #  # ][ #  # ]:          0 :    DLIList<Surface*> surfaces_to_sweep;
    9538         [ #  # ]:          0 :    if (gme)
    9539                 :            :    {
    9540         [ #  # ]:          0 :      GeometryModifyEngine* surf_gme = common_modify_engine( tool_faces, surfaces_to_sweep );
    9541         [ #  # ]:          0 :      if( gme != surf_gme ){
    9542 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("All geometry not from the same modeling engine.\n");
         [ #  # ][ #  # ]
    9543                 :          0 :        return CUBIT_FAILURE;
    9544                 :            :      }
    9545                 :            :    }
    9546                 :            :    else{
    9547 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("All volumes not from the same modeling engine.\n");
         [ #  # ][ #  # ]
    9548                 :          0 :      return CUBIT_FAILURE;
    9549                 :            :    }
    9550                 :            : 
    9551                 :          0 :    Surface *stop_surface = NULL;
    9552         [ #  # ]:          0 :    if( stop_surf )
    9553                 :            :    {
    9554         [ #  # ]:          0 :      GeometryModifyEngine *tmp_gme = get_engine(stop_surf);
    9555                 :            : 
    9556         [ #  # ]:          0 :      if( gme != tmp_gme )
    9557                 :            :      {
    9558 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Stop surface %d is not of same modeling engine as other input geometry.\n",
         [ #  # ][ #  # ]
    9559         [ #  # ]:          0 :                     stop_surf->id() );
    9560                 :          0 :        return CUBIT_FAILURE;
    9561                 :            :      }
    9562                 :            : 
    9563         [ #  # ]:          0 :      stop_surface = stop_surf->get_surface_ptr();
    9564                 :            :    }
    9565                 :            : 
    9566                 :          0 :    Curve *curve_to_sweep_along = NULL;
    9567         [ #  # ]:          0 :    if( edge_to_sweep_along )
    9568                 :            :    {
    9569         [ #  # ]:          0 :      GeometryModifyEngine *tmp_gme = get_engine(edge_to_sweep_along);
    9570                 :            : 
    9571         [ #  # ]:          0 :      if( gme != tmp_gme )
    9572                 :            :      {
    9573 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Curve %d does is not of same modeling as other input geometry.\n",
         [ #  # ][ #  # ]
    9574         [ #  # ]:          0 :                     edge_to_sweep_along->id() );
    9575                 :          0 :        return CUBIT_FAILURE;
    9576                 :            :      }
    9577                 :            : 
    9578                 :            :      //make sure that the curve is not part of the surface(s) being swept
    9579         [ #  # ]:          0 :      DLIList<RefFace*> faces_of_edge;
    9580         [ #  # ]:          0 :      edge_to_sweep_along->ref_faces( faces_of_edge );
    9581                 :            : 
    9582                 :            :      int kk;
    9583 [ #  # ][ #  # ]:          0 :      for( kk=faces_of_edge.size(); kk--; )
    9584                 :            :      {
    9585 [ #  # ][ #  # ]:          0 :        if( tool_faces.is_in_list( faces_of_edge.get_and_step() ) )
                 [ #  # ]
    9586                 :            :        {
    9587         [ #  # ]:          0 :          faces_of_edge.back();
    9588 [ #  # ][ #  # ]:          0 :          PRINT_ERROR("Cannot perform sweep.  Curve %d is in Surface %d\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    9589         [ #  # ]:          0 :                       edge_to_sweep_along->id(), faces_of_edge.get()->id() );
    9590                 :          0 :          return CUBIT_FAILURE;
    9591                 :            :        }
    9592                 :            :      }
    9593                 :            : 
    9594 [ #  # ][ #  # ]:          0 :      curve_to_sweep_along = edge_to_sweep_along->get_curve_ptr();
                 [ #  # ]
    9595                 :            :    }
    9596                 :            : 
    9597 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> neighbor_imprint_list;
    9598 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_surface_ids;
    9599 [ #  # ][ #  # ]:          0 :    DLIList<int> merged_curve_ids;
    9600 [ #  # ][ #  # ]:          0 :    DLIList<Body*> bodies_to_modify;
    9601                 :            : 
    9602         [ #  # ]:          0 :    if (!preview)
    9603                 :            :    {
    9604 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9605                 :            :      {
    9606         [ #  # ]:          0 :        DLIList<Body*> bodies_to_save;
    9607         [ #  # ]:          0 :        bodies_to_save += webcut_body_list;
    9608         [ #  # ]:          0 :        bodies_to_save += neighboring_bodies;
    9609 [ #  # ][ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( bodies_to_save );
    9610                 :            :      }
    9611                 :            : 
    9612                 :            :      int i;
    9613 [ #  # ][ #  # ]:          0 :      for( i=neighboring_bodies.size(); i--; )
    9614                 :            :      {
    9615         [ #  # ]:          0 :        Body *neighbor_body = neighboring_bodies.get_and_step();
    9616         [ #  # ]:          0 :        BodySM *tmp_body = neighbor_body->get_body_sm_ptr();
    9617         [ #  # ]:          0 :        GeometryModifyEngine *neighbor_gme = get_engine( tmp_body );
    9618                 :            : 
    9619         [ #  # ]:          0 :        if( gme == neighbor_gme )
    9620         [ #  # ]:          0 :          neighbor_imprint_list.append( tmp_body );
    9621                 :            :      }
    9622                 :            : 
    9623         [ #  # ]:          0 :      do_attribute_setup();
    9624         [ #  # ]:          0 :      DLIList<BodySM*> bodies_sm_to_modify;
    9625         [ #  # ]:          0 :      bodies_sm_to_modify += body_sm_list;
    9626         [ #  # ]:          0 :      bodies_sm_to_modify += neighbor_imprint_list;
    9627         [ #  # ]:          0 :      push_attributes_before_modify( bodies_sm_to_modify );
    9628         [ #  # ]:          0 :      bodies_to_modify += webcut_body_list;
    9629         [ #  # ]:          0 :      bodies_to_modify += neighboring_bodies;
    9630 [ #  # ][ #  # ]:          0 :      get_merged_curve_and_surface_ids( bodies_to_modify, merged_surface_ids, merged_curve_ids );
    9631                 :            :    }
    9632                 :            : 
    9633                 :          0 :    BodySM* cutting_tool_ptr = NULL;
    9634                 :            :    CubitStatus stat = prepare_surface_sweep(
    9635                 :            :       body_sm_list, surfaces_to_sweep, sweep_vector, sweep_perp, through_all, outward,
    9636         [ #  # ]:          0 :       up_to_next, stop_surface, curve_to_sweep_along, cutting_tool_ptr );
    9637         [ #  # ]:          0 :    if (stat == CUBIT_SUCCESS)
    9638                 :            :    {
    9639                 :            :       stat = gme->webcut( body_sm_list, cutting_tool_ptr, neighbor_imprint_list,
    9640         [ #  # ]:          0 :                           new_sms, imprint_type, preview );
    9641                 :            : 
    9642                 :            :       // Delete the BodySM that was created to be used as a tool
    9643 [ #  # ][ #  # ]:          0 :       gme->get_gqe()->delete_solid_model_entities(cutting_tool_ptr) ;
    9644                 :            :    }
    9645                 :            : 
    9646         [ #  # ]:          0 :    if (!preview)
    9647                 :            :    {
    9648         [ #  # ]:          0 :      restore_vg_after_modify(new_sms, bodies_to_modify, gme);
    9649         [ #  # ]:          0 :      remove_pushed_attributes(new_sms, bodies_to_modify);
    9650                 :            :      stat = finish_webcut(webcut_body_list, new_sms, merge, stat, new_bodies,
    9651         [ #  # ]:          0 :                           &merged_surface_ids, &merged_curve_ids );
    9652         [ #  # ]:          0 :      do_attribute_cleanup();
    9653                 :            : 
    9654 [ #  # ][ #  # ]:          0 :      if( CubitUndo::get_undo_enabled() )
    9655                 :            :      {
    9656         [ #  # ]:          0 :        if( stat  == CUBIT_SUCCESS )
    9657         [ #  # ]:          0 :          CubitUndo::note_result_bodies( new_bodies );
    9658                 :            :        else
    9659         [ #  # ]:          0 :          CubitUndo::remove_last_undo();
    9660                 :            :      }
    9661                 :            :    }
    9662                 :            : 
    9663         [ #  # ]:          0 :    return stat;
    9664                 :            : }
    9665                 :            : 
    9666                 :         11 : CubitStatus GeometryModifyTool::split_free_curve(RefEdge *ref_edge,
    9667                 :            :                                                   DLIList<CubitVector> &split_locations,
    9668                 :            :                                                   DLIList<RefEdge*> &new_ref_edges )
    9669                 :            : {
    9670                 :         11 :   TopologyBridge* bridge = 0;
    9671         [ +  - ]:         11 :   GeometryModifyEngine* gme_ptr = get_engine(ref_edge, &bridge);
    9672         [ -  + ]:         11 :   Curve *curve = dynamic_cast<Curve*>(bridge);
    9673                 :            : 
    9674 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
    9675                 :            :   {
    9676         [ #  # ]:          0 :     DLIList<RefEdge*> tmp_ents(1);
    9677         [ #  # ]:          0 :     tmp_ents.append( ref_edge );
    9678 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( tmp_ents );
    9679                 :            :   }
    9680                 :            : 
    9681         [ +  - ]:         11 :   DLIList<Curve*> new_curves;
    9682 [ +  - ][ +  - ]:         11 :   if(split_locations.size() == 1)
    9683 [ +  - ][ +  - ]:         11 :     gme_ptr->split_curve(curve, (split_locations.get()), new_curves);
    9684                 :            :   else
    9685         [ #  # ]:          0 :     gme_ptr->split_free_curve( curve, split_locations, new_curves );
    9686                 :            : 
    9687 [ +  - ][ -  + ]:         11 :   if (!new_curves.size())
    9688                 :            :   {
    9689 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
    9690         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
    9691                 :          0 :     return CUBIT_FAILURE;
    9692                 :            :   }
    9693                 :            : 
    9694 [ +  - ][ +  - ]:         11 :   GeometryQueryTool::instance()->delete_RefEdge( ref_edge );
    9695                 :            : 
    9696                 :            :   int i;
    9697 [ +  - ][ +  + ]:         33 :   for( i=0; i<new_curves.size(); i++ )
    9698                 :            :   {
    9699         [ +  - ]:         22 :     Curve *new_curve = new_curves.get_and_step();
    9700 [ +  - ][ +  - ]:         22 :     RefEdge* new_edge = GeometryQueryTool::instance()->make_free_RefEdge(new_curve);
    9701         [ +  - ]:         22 :     if(new_edge)
    9702         [ +  - ]:         22 :       new_ref_edges.append(new_edge);
    9703 [ +  - ][ -  + ]:         22 :     if( CubitUndo::get_undo_enabled() )
    9704 [ #  # ][ #  # ]:          0 :       CubitUndo::note_result_entity( new_edge );
    9705                 :            :   }
    9706                 :            : 
    9707         [ +  - ]:         11 :   return CUBIT_SUCCESS;
    9708                 :            : }
    9709                 :            : 
    9710                 :            : //-------------------------------------------------------------------------
    9711                 :            : // Purpose       : split a multiple volume body into several bodies
    9712                 :            : //                 each containing a single volume.
    9713                 :            : //
    9714                 :            : // Special Notes :
    9715                 :            : //
    9716                 :            : // Creator       : David White
    9717                 :            : //
    9718                 :            : // Creation Date : 09/26/97
    9719                 :            : //-------------------------------------------------------------------------
    9720                 :         44 : CubitStatus GeometryModifyTool::split_body( Body *body_ptr,
    9721                 :            :                                             DLIList<Body*> &new_bodies ) const
    9722                 :            : {
    9723                 :            :   int i;
    9724         [ +  - ]:         44 :   DLIList<RefVolume*> ref_vols;
    9725         [ +  - ]:         44 :   body_ptr->ref_volumes(ref_vols);
    9726 [ +  - ][ +  + ]:         44 :   if ( ref_vols.size() < 2 )
    9727                 :            :   {
    9728                 :            :     //no need to split...
    9729         [ +  - ]:         33 :     new_bodies.append(body_ptr);
    9730                 :         33 :     return CUBIT_SUCCESS;
    9731                 :            :   }
    9732                 :            : 
    9733 [ +  - ][ +  - ]:         22 :   DLIList<Body*> b_list;
    9734         [ +  - ]:         11 :   b_list.append(body_ptr);
    9735 [ +  - ][ -  + ]:         11 :   if (!okay_to_modify( b_list, "SPLIT" ))
    9736                 :          0 :     return CUBIT_FAILURE;
    9737                 :            : 
    9738                 :            :   // Call the owning GeometryModifyEngine to split the body
    9739                 :            :   // so that there is one volume per body.
    9740         [ +  - ]:         11 :   BodySM* bodysm_ptr = body_ptr->get_body_sm_ptr();
    9741         [ +  - ]:         11 :   GeometryModifyEngine* engine_ptr = get_engine(bodysm_ptr);
    9742         [ -  + ]:         11 :   if (!engine_ptr) {
    9743 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("There is no modify engine available for this volume."
                 [ #  # ]
    9744         [ #  # ]:          0 :       " Volume cannot be split.\n");
    9745                 :          0 :     return CUBIT_FAILURE;
    9746                 :            :   }
    9747                 :            : 
    9748 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
    9749                 :            :   {
    9750         [ #  # ]:          0 :     DLIList<Body*> bodies(1);
    9751         [ #  # ]:          0 :     bodies.append( body_ptr );
    9752 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies );
    9753                 :            :   }
    9754                 :            : 
    9755 [ +  - ][ +  - ]:         22 :   DLIList<BodySM*> new_sm_list;
    9756         [ +  - ]:         11 :   CubitStatus stat = engine_ptr->split_body( bodysm_ptr, new_sm_list );
    9757 [ +  - ][ -  + ]:         11 :   if ( new_sm_list.size() == 0 )
    9758                 :            :   {
    9759 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("failed in splitting volumes, orginal was lost.\n");
         [ #  # ][ #  # ]
    9760 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->destroy_dead_entity(body_ptr);
    9761                 :          0 :     return CUBIT_FAILURE;
    9762                 :            :   }
    9763                 :            : 
    9764         [ +  - ]:         11 :   bodysm_ptr = body_ptr->get_body_sm_ptr();
    9765         [ -  + ]:         11 :   if (bodysm_ptr)
    9766                 :            :   {
    9767 [ #  # ][ #  # ]:          0 :     remove_dead_entity_names(body_ptr);
    9768 [ #  # ][ #  # ]:          0 :     body_ptr = GeometryQueryTool::instance()->make_Body(bodysm_ptr);
    9769                 :            :   }
    9770                 :            :   else
    9771                 :            :   {
    9772 [ +  - ][ +  - ]:         11 :     GeometryQueryTool::instance()->destroy_dead_entity(body_ptr);
    9773                 :            :   }
    9774                 :            : 
    9775         [ +  - ]:         11 :   new_sm_list.reset();
    9776 [ +  - ][ +  + ]:         99 :   for (i = new_sm_list.size(); i--; )
    9777                 :            :   {
    9778         [ +  - ]:         88 :     bodysm_ptr = new_sm_list.get_and_step();
    9779 [ +  - ][ +  - ]:         88 :     Body* body = GeometryQueryTool::instance()->make_Body(bodysm_ptr);
    9780         [ +  - ]:         88 :     new_bodies.append(body);
    9781                 :            :   }
    9782                 :            : 
    9783 [ +  - ][ +  - ]:         11 :   if ( !GeometryModifyTool::instance()->get_new_ids())
                 [ +  - ]
    9784                 :            :   {
    9785                 :            :     //Now reuse the body ids.
    9786         [ +  - ]:         11 :     DLIList<RefVolume*> new_ref_vols;
    9787 [ +  - ][ +  + ]:         99 :     for ( int ii = new_bodies.size(); ii > 0; ii-- )
    9788                 :            :     {
    9789         [ +  - ]:         88 :       Body *temp_body = new_bodies.get_and_step();
    9790         [ +  - ]:         88 :       new_ref_vols.clean_out();
    9791         [ +  - ]:         88 :       temp_body->ref_volumes(new_ref_vols);
    9792 [ +  - ][ +  - ]:         88 :       int vol_id = new_ref_vols.get()->id();
    9793 [ +  - ][ +  - ]:         88 :       if ( temp_body->id() != vol_id )
    9794                 :            :       {
    9795                 :            :         //Check to see if this id is being used by
    9796                 :            :         //some other body.
    9797 [ +  - ][ +  - ]:         88 :         if ( RefEntityFactory::instance()->get_body(vol_id) == NULL )
                 [ +  + ]
    9798                 :            :         {
    9799         [ +  - ]:         66 :           temp_body->set_id(vol_id);
    9800                 :            :         }
    9801                 :            :         //if it is in use, then we shouldn't mess around with it...
    9802                 :            :       }
    9803         [ +  - ]:         11 :     }
    9804                 :            :   }
    9805                 :            : 
    9806 [ +  - ][ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
    9807         [ #  # ]:          0 :     CubitUndo::note_result_bodies( new_bodies );
    9808                 :            : 
    9809 [ +  - ][ +  - ]:         11 :   GeometryQueryTool::instance()->cleanout_deactivated_geometry();
    9810         [ +  - ]:         55 :   return stat;
    9811                 :            : }
    9812                 :            : 
    9813                 :            : //-------------------------------------------------------------------------
    9814                 :            : // Purpose       : Separate surfaces from a sheet body into separate bodies.
    9815                 :            : //                 Connected surfaces will remain united but be placed in
    9816                 :            : //                 a new body.
    9817                 :            : //
    9818                 :            : // Special Notes :
    9819                 :            : //
    9820                 :            : // Creator       : Steve Storm
    9821                 :            : //
    9822                 :            : // Creation Date : 02/23/2008
    9823                 :            : //-------------------------------------------------------------------------
    9824                 :            : CubitStatus
    9825                 :          0 : GeometryModifyTool::separate_surfaces( DLIList<RefFace*> &ref_face_list,
    9826                 :            :                                        DLIList<Body*> &new_bodies )
    9827                 :            : {
    9828                 :            :   int i;
    9829                 :            :   RefFace *ref_face_ptr;
    9830                 :            : 
    9831 [ #  # ][ #  # ]:          0 :   for( i=ref_face_list.size(); i--; )
    9832                 :            :   {
    9833         [ #  # ]:          0 :     ref_face_ptr = ref_face_list.get();
    9834                 :            : 
    9835                 :            :     // Check for no body
    9836         [ #  # ]:          0 :     DLIList<Body*> body_list;
    9837         [ #  # ]:          0 :     ref_face_ptr->bodies( body_list );
    9838 [ #  # ][ #  # ]:          0 :     if( body_list.size()==0 )
    9839                 :            :     {
    9840 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Surface %d is not contained within a parent body.\n"
         [ #  # ][ #  # ]
    9841         [ #  # ]:          0 :         "       It cannot be separated.\n", ref_face_ptr->id() );
    9842 [ #  # ][ #  # ]:          0 :       return CUBIT_FAILURE;
    9843                 :            :     }
    9844                 :          0 :   }
    9845                 :            : 
    9846                 :            :   // Check for virtual geometry
    9847         [ #  # ]:          0 :   DLIList<RefEntity*> ref_ent_list;
    9848 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    9849 [ #  # ][ #  # ]:          0 :   if ( GeometryQueryTool::instance()->contains_intermediate_geometry(ref_ent_list) )
                 [ #  # ]
    9850                 :            :   {
    9851 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("SEPARATING surfaces containing virtual geometry is not\n"
                 [ #  # ]
    9852                 :            :       "       allowed. Delete virtual geometry on these surfaces\n"
    9853         [ #  # ]:          0 :       "       before operation.\n" );
    9854                 :          0 :     return CUBIT_FAILURE;
    9855                 :            :   }
    9856                 :            : 
    9857                 :            :   // Prep for undo
    9858 [ #  # ][ #  # ]:          0 :   DLIList<Body*> body_list;
    9859 [ #  # ][ #  # ]:          0 :   for( i=ref_face_list.size(); i--; )
    9860 [ #  # ][ #  # ]:          0 :     ref_face_list.get_and_step()->bodies( body_list );
    9861         [ #  # ]:          0 :   body_list.uniquify_ordered();
    9862                 :            : 
    9863 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    9864         [ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( body_list );
    9865                 :            : 
    9866                 :            :   // Handle surfaces from different modify engines.  Copy the input list since
    9867                 :            :   // we will be pulling RefFaces out of it.
    9868 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> copied_ref_face_list = ref_face_list;
    9869                 :            : 
    9870                 :            :   // Keep track of errors and success
    9871                 :          0 :   int error_occurred = 0;
    9872                 :          0 :   int successful_case = 0;
    9873                 :            : 
    9874                 :            :   GeometryModifyEngine *gme_ptr;
    9875 [ #  # ][ #  # ]:          0 :   while( copied_ref_face_list.size() )
    9876                 :            :   {
    9877                 :            :     // Need to send in Surfaces
    9878         [ #  # ]:          0 :     DLIList<Surface*> surface_list;
    9879 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> gme_face_list;
              [ #  #  # ]
    9880                 :            : 
    9881                 :            :     gme_ptr = pull_common_surfs( copied_ref_face_list, gme_face_list,
    9882         [ #  # ]:          0 :                                  surface_list );
    9883         [ #  # ]:          0 :     if( !gme_ptr )
    9884                 :          0 :       return CUBIT_FAILURE;
    9885                 :            : 
    9886                 :            :     // Get the owning bodies of the faces...needed for finish_sm_op
    9887 [ #  # ][ #  # ]:          0 :     DLIList<Body*> gme_body_list;
              [ #  #  # ]
    9888 [ #  # ][ #  # ]:          0 :     for( i=gme_face_list.size(); i--; )
    9889 [ #  # ][ #  # ]:          0 :       gme_face_list.get_and_step()->bodies( gme_body_list );
    9890         [ #  # ]:          0 :     gme_body_list.uniquify_ordered();
    9891                 :            : 
    9892 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> new_sm_list;
                 [ #  # ]
    9893 [ #  # ][ #  # ]:          0 :     DLIList<Body*> new_body_list;
                 [ #  # ]
    9894 [ #  # ][ #  # ]:          0 :     if( gme_ptr->separate_surfaces( surface_list, new_sm_list ) == CUBIT_FAILURE ||
         [ #  # ][ #  # ]
    9895         [ #  # ]:          0 :         finish_sm_op(gme_body_list, new_sm_list, new_body_list ) == CUBIT_FAILURE )
    9896                 :            :     {
    9897                 :          0 :       error_occurred++;
    9898                 :          0 :       continue;
    9899                 :            :     }
    9900                 :            : 
    9901         [ #  # ]:          0 :     new_bodies += new_body_list;
    9902 [ #  # ][ #  # ]:          0 :     successful_case++;
    9903                 :          0 :   }
    9904                 :            : 
    9905 [ #  # ][ #  # ]:          0 :   if( error_occurred && !successful_case )
    9906                 :          0 :     return CUBIT_FAILURE;
    9907                 :            : 
    9908                 :            :   // Following is copied from split_body - to keep same behavior. When all
    9909                 :            :   // surfaces are separated from a given body, separate_surfaces just separates
    9910                 :            :   // the body. Without the code below we get new body ids.
    9911 [ #  # ][ #  # ]:          0 :   if ( !GeometryModifyTool::instance()->get_new_ids())
                 [ #  # ]
    9912                 :            :   {
    9913                 :            :     //Now reuse the body ids.
    9914         [ #  # ]:          0 :     DLIList<RefVolume*> new_ref_vols;
    9915 [ #  # ][ #  # ]:          0 :     for ( int ii = new_bodies.size(); ii > 0; ii-- )
    9916                 :            :     {
    9917         [ #  # ]:          0 :       Body *temp_body = new_bodies.get_and_step();
    9918         [ #  # ]:          0 :       new_ref_vols.clean_out();
    9919         [ #  # ]:          0 :       temp_body->ref_volumes(new_ref_vols);
    9920 [ #  # ][ #  # ]:          0 :       int vol_id = new_ref_vols.get()->id();
    9921 [ #  # ][ #  # ]:          0 :       if ( temp_body->id() != vol_id )
    9922                 :            :       {
    9923                 :            :         //Check to see if this id is being used by
    9924                 :            :         //some other body.
    9925 [ #  # ][ #  # ]:          0 :         if ( RefEntityFactory::instance()->get_body(vol_id) == NULL )
                 [ #  # ]
    9926                 :            :         {
    9927         [ #  # ]:          0 :           temp_body->set_id(vol_id);
    9928                 :            :         }
    9929                 :            :         //if it is in use, then we shouldn't mess around with it...
    9930                 :            :       }
    9931         [ #  # ]:          0 :     }
    9932                 :            :   }
    9933                 :            : 
    9934 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
    9935         [ #  # ]:          0 :     CubitUndo::note_result_bodies( new_bodies );
    9936                 :            : 
    9937         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    9938                 :            : }
    9939                 :            : 
    9940                 :            : //-------------------------------------------------------------------------
    9941                 :            : // Purpose       : Reverse a body
    9942                 :            : //
    9943                 :            : // Special Notes : Moved from Body
    9944                 :            : //
    9945                 :            : // Creator       : Jason Kraftcheck
    9946                 :            : //
    9947                 :            : // Creation Date :
    9948                 :            : //-------------------------------------------------------------------------
    9949                 :          0 : CubitStatus GeometryModifyTool::reverse( DLIList<Body*> &body_list )
    9950                 :            : {
    9951         [ #  # ]:          0 :    DLIList<Body*> reversed_bodies;
    9952                 :            :    int i;
    9953 [ #  # ][ #  # ]:          0 :    for( i=body_list.size(); i--; )
    9954                 :            :    {
    9955         [ #  # ]:          0 :      Body *body = body_list.get_and_step();
    9956         [ #  # ]:          0 :      BodySM* body_sm = body->get_body_sm_ptr();
    9957         [ #  # ]:          0 :      GeometryModifyEngine* gme = get_engine( body_sm );
    9958         [ #  # ]:          0 :      if (!gme) {
    9959 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Body %d does not have a modify engine.\n", body->id());
         [ #  # ][ #  # ]
                 [ #  # ]
    9960                 :          0 :         continue;
    9961                 :            :      }
    9962                 :            : 
    9963         [ #  # ]:          0 :      CubitStatus stat = gme->reverse_body( body_sm );
    9964                 :            : 
    9965         [ #  # ]:          0 :      if ( CUBIT_SUCCESS != stat )
    9966                 :            :      {
    9967 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Reverse failed.\n");
         [ #  # ][ #  # ]
    9968                 :          0 :        continue;
    9969                 :            :      }
    9970                 :            :      else
    9971                 :            :      {
    9972         [ #  # ]:          0 :        reversed_bodies.append( body );
    9973 [ #  # ][ #  # ]:          0 :        GeometryQueryTool::instance()->make_Body( body_sm );
    9974 [ #  # ][ #  # ]:          0 :        AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, body));
         [ #  # ][ #  # ]
                 [ #  # ]
    9975 [ #  # ][ #  # ]:          0 :        PRINT_INFO("Reversed body %d.\n", body->id());
         [ #  # ][ #  # ]
                 [ #  # ]
    9976                 :          0 :        continue;
    9977                 :            :      }
    9978                 :            :    }
    9979                 :            : 
    9980 [ #  # ][ #  # ]:          0 :    if( CubitUndo::get_undo_enabled() )
    9981                 :            :    {
    9982         [ #  # ]:          0 :      CubitString undo_command("reverse body ");
    9983 [ #  # ][ #  # ]:          0 :      for( i=reversed_bodies.size(); i--; )
    9984                 :            :      {
    9985 [ #  # ][ #  # ]:          0 :        undo_command += CubitString::number(reversed_bodies.get_and_step()->id());
         [ #  # ][ #  # ]
                 [ #  # ]
    9986 [ #  # ][ #  # ]:          0 :        undo_command += " ";
                 [ #  # ]
    9987                 :            :      }
    9988 [ #  # ][ #  # ]:          0 :      CubitUndo::set_undo_by_command( undo_command );
         [ #  # ][ #  # ]
    9989                 :            :    }
    9990                 :            : 
    9991         [ #  # ]:          0 :    return CUBIT_SUCCESS;
    9992                 :            : }
    9993                 :            : 
    9994                 :            : //===============================================================================
    9995                 :            : // Function   : reverse
    9996                 :            : // Member Type: PUBLIC
    9997                 :            : // Description: Reverse given surfaces (flip normals)
    9998                 :            : // Author     : Steve Storm (CAT)
    9999                 :            : // Date       : 4/3/2007
   10000                 :            : //===============================================================================
   10001                 :          0 : CubitStatus GeometryModifyTool::reverse( DLIList<RefFace*> &ref_face_list )
   10002                 :            : {
   10003                 :            :   // Check for virtual geometry
   10004         [ #  # ]:          0 :   DLIList<RefEntity*> ref_ent_list;
   10005 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10006 [ #  # ][ #  # ]:          0 :   if( GeometryQueryTool::instance()->contains_intermediate_geometry(ref_ent_list) )
                 [ #  # ]
   10007                 :            :   {
   10008 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("REVERSING surfaces containing virtual geometry is not\n"
                 [ #  # ]
   10009                 :            :       "       allowed. Delete virtual geometry on surfaces before\n"
   10010         [ #  # ]:          0 :       "       operation.\n" );
   10011                 :          0 :     return CUBIT_FAILURE;
   10012                 :            :   }
   10013                 :            : 
   10014                 :            :   // Get the owning bodies of the faces
   10015                 :            :   int i;
   10016 [ #  # ][ #  # ]:          0 :   DLIList<Body*> body_list;
   10017 [ #  # ][ #  # ]:          0 :   for( i=ref_face_list.size(); i--; )
   10018 [ #  # ][ #  # ]:          0 :     ref_face_list.get_and_step()->bodies( body_list );
   10019         [ #  # ]:          0 :   body_list.uniquify_ordered();
   10020                 :            : 
   10021                 :            :   // Handle surfaces from different modify engines.  Copy the input list since
   10022                 :            :   // we will be pulling RefFaces out of it.
   10023 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> copied_ref_face_list = ref_face_list;
   10024                 :            : 
   10025                 :            :   // Keep track of overall errors and successes
   10026                 :          0 :   int error_occurred = 0;
   10027                 :          0 :   int successful_case = 0;
   10028                 :            :   GeometryModifyEngine *gme_ptr;
   10029                 :            : 
   10030 [ #  # ][ #  # ]:          0 :   while( copied_ref_face_list.size() )
   10031                 :            :   {
   10032                 :            :     // Need to send in Surfaces
   10033         [ #  # ]:          0 :     DLIList<Surface*> surface_list;
   10034 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> common_face_list;
                 [ #  # ]
   10035                 :            : 
   10036                 :            :     gme_ptr = pull_common_surfs( copied_ref_face_list, common_face_list,
   10037         [ #  # ]:          0 :                                  surface_list );
   10038         [ #  # ]:          0 :     if( !gme_ptr )
   10039                 :          0 :       return CUBIT_FAILURE;
   10040                 :            : 
   10041 [ #  # ][ #  # ]:          0 :     if( gme_ptr->flip_normals( surface_list ) == CUBIT_FAILURE )
   10042                 :          0 :       error_occurred = 1;
   10043                 :            :     else
   10044 [ #  # ][ #  # ]:          0 :       successful_case = 1;
   10045                 :          0 :   }
   10046                 :            : 
   10047 [ #  # ][ #  # ]:          0 :   if( error_occurred && !successful_case )
   10048                 :          0 :     return CUBIT_FAILURE;
   10049                 :            : 
   10050                 :            :   // Update the impacted bodies
   10051                 :            :   Body *body_ptr;
   10052                 :            :   BodySM* body_sm_ptr;
   10053 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_sm_list;
   10054 [ #  # ][ #  # ]:          0 :   for( i=body_list.size(); i--; )
   10055                 :            :   {
   10056         [ #  # ]:          0 :     body_ptr = body_list.get_and_step();
   10057         [ #  # ]:          0 :     body_sm_ptr = body_ptr->get_body_sm_ptr();
   10058         [ #  # ]:          0 :     new_sm_list.append( body_sm_ptr );
   10059                 :            :   }
   10060                 :            : 
   10061 [ #  # ][ #  # ]:          0 :   DLIList<Body*> new_body_list;
   10062         [ #  # ]:          0 :   CubitStatus status = finish_sm_op(body_list, new_sm_list, new_body_list );
   10063                 :            : 
   10064         [ #  # ]:          0 :   if( CUBIT_FAILURE == status )
   10065                 :          0 :     return CUBIT_FAILURE;
   10066                 :            :   
   10067 [ #  # ][ #  # ]:          0 :   for( int k=0; k< ref_face_list.size(); k++ )
   10068 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, ref_face_list.get_and_step() ));  
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   10069                 :            : 
   10070         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   10071                 :            : }
   10072                 :            : 
   10073                 :            : //-------------------------------------------------------------------------
   10074                 :            : // Purpose       : split a periodic surface.
   10075                 :            : //
   10076                 :            : // Special Notes :
   10077                 :            : //
   10078                 :            : // Creator       : David White
   10079                 :            : //
   10080                 :            : // Creation Date : 09/26/97
   10081                 :            : //-------------------------------------------------------------------------
   10082                 :            : 
   10083                 :          0 : CubitStatus GeometryModifyTool::split_periodic(Body *body_ptr,
   10084                 :            :                                                Body *&new_body_ptr )
   10085                 :            : {
   10086         [ #  # ]:          0 :    DLIList<Body*> b_list(1);
   10087         [ #  # ]:          0 :    b_list.append(body_ptr);
   10088 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( b_list, "SPLIT" ))
   10089                 :          0 :      return CUBIT_FAILURE;
   10090                 :            : 
   10091         [ #  # ]:          0 :    BodySM* body_sm = body_ptr->get_body_sm_ptr();
   10092         [ #  # ]:          0 :    GeometryModifyEngine* gme = get_engine(body_sm);
   10093         [ #  # ]:          0 :    if (!gme) {
   10094 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Volume %d does not have a modify engine.\n", body_ptr->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   10095                 :          0 :       return CUBIT_FAILURE;
   10096                 :            :    }
   10097                 :            : 
   10098                 :          0 :    BodySM* new_sm = 0;
   10099                 :            : 
   10100 [ #  # ][ #  # ]:          0 :    if (CubitUndo::get_undo_enabled())
   10101         [ #  # ]:          0 :      CubitUndo::save_state_with_cubit_file(b_list);
   10102                 :            : 
   10103 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sms;
   10104         [ #  # ]:          0 :    body_sms.append(body_sm);
   10105                 :            : 
   10106         [ #  # ]:          0 :    do_attribute_setup();
   10107         [ #  # ]:          0 :    push_attributes_before_modify(body_sms);
   10108                 :            : 
   10109                 :            :    // Call the default GeometryModifyEngine to create a new TBPoint
   10110         [ #  # ]:          0 :    CubitStatus stat = gme->split_periodic( body_sm, new_sm );
   10111                 :            : 
   10112 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> new_bodysm_list;
   10113         [ #  # ]:          0 :    if(new_sm)
   10114         [ #  # ]:          0 :      new_bodysm_list.append(new_sm);
   10115 [ #  # ][ #  # ]:          0 :    DLIList<Body*> old_body_list;
   10116         [ #  # ]:          0 :    old_body_list.append(body_ptr);
   10117         [ #  # ]:          0 :    restore_vg_after_modify(new_bodysm_list, old_body_list, gme);
   10118         [ #  # ]:          0 :    remove_pushed_attributes(new_bodysm_list, old_body_list);
   10119         [ #  # ]:          0 :    do_attribute_cleanup();
   10120                 :            : 
   10121         [ #  # ]:          0 :    update_body(body_ptr);
   10122                 :            : 
   10123                 :          0 :    new_body_ptr = 0;
   10124         [ #  # ]:          0 :    if (new_sm)
   10125 [ #  # ][ #  # ]:          0 :      new_body_ptr = GeometryQueryTool::instance()->make_Body(new_sm);
   10126                 :            : 
   10127         [ #  # ]:          0 :    if (new_body_ptr)
   10128                 :            :    {
   10129 [ #  # ][ #  # ]:          0 :      if (CubitUndo::get_undo_enabled())
   10130         [ #  # ]:          0 :        CubitUndo::note_result_body(new_body_ptr);
   10131                 :            :    }
   10132                 :            :    else
   10133                 :            :    {
   10134 [ #  # ][ #  # ]:          0 :      if (CubitUndo::get_undo_enabled())
   10135         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
   10136                 :            :    }
   10137                 :            : 
   10138 [ #  # ][ #  # ]:          0 :    GeometryQueryTool::instance()->cleanout_deactivated_geometry();
   10139                 :            : 
   10140         [ #  # ]:          0 :    return stat;
   10141                 :            : }
   10142                 :            : 
   10143                 :            : //===============================================================================
   10144                 :            : // Function   : split_surface
   10145                 :            : // Member Type: PUBLIC
   10146                 :            : // Description: Split a single surface into one or more pieces
   10147                 :            : // Author     : Steve Storm (CAT)
   10148                 :            : // Date       : 07/04
   10149                 :            : //===============================================================================
   10150                 :            : CubitStatus
   10151                 :          0 : GeometryModifyTool::split_surface( RefFace *ref_face_ptr,
   10152                 :            :                                    DLIList<CubitVector*> &locations,
   10153                 :            :                                    DLIList<DLIList<CubitVector*>*> &vec_lists,
   10154                 :            :                                    CubitBoolean preview_flg,
   10155                 :            :                                    CubitBoolean create_ref_edges_flg,
   10156                 :            :                                    CubitBoolean clear_previous_previews )
   10157                 :            : {
   10158                 :            :   // Check for virtual geometry
   10159         [ #  # ]:          0 :   DLIList<RefFace*> ref_face_list;
   10160         [ #  # ]:          0 :   ref_face_list.append( ref_face_ptr );
   10161                 :            : 
   10162 [ #  # ][ #  # ]:          0 :   DLIList<Body*> b_list;
   10163         [ #  # ]:          0 :   Body* body = ref_face_ptr->body();
   10164         [ #  # ]:          0 :   if (body)
   10165         [ #  # ]:          0 :           b_list.append(body);
   10166                 :            :   else
   10167                 :            :   {
   10168 [ #  # ][ #  # ]:          0 :           PRINT_ERROR( "Surface %d is not contained within a parent body.\n"
         [ #  # ][ #  # ]
   10169         [ #  # ]:          0 :                   "      It cannot be split.\n", ref_face_ptr->id() );
   10170                 :          0 :           return CUBIT_FAILURE;
   10171                 :            :   }
   10172                 :            : 
   10173 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( b_list, "SPLIT_SURFACE" ))
   10174                 :          0 :     return CUBIT_FAILURE;
   10175                 :            : 
   10176                 :            :   int i;
   10177 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   10178 [ #  # ][ #  # ]:          0 :   for( i=ref_face_list.size(); i--; )
   10179                 :            :   {
   10180         [ #  # ]:          0 :     ref_face_ptr = ref_face_list.get_and_step();
   10181                 :            : 
   10182         [ #  # ]:          0 :     DLIList<Body*> body_list;
   10183         [ #  # ]:          0 :     ref_face_ptr->bodies( body_list );
   10184         [ #  # ]:          0 :     old_body_list.merge_unique( body_list );
   10185         [ #  # ]:          0 :   }
   10186                 :            : 
   10187                 :            :   //bad geom with no body -- dont try to imprint this...
   10188                 :            :   //quick and dirty fix by (aga@cat|1/7/04)
   10189 [ #  # ][ #  # ]:          0 :   if( old_body_list.size() < 1 )
   10190                 :            :   {
   10191 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Surface %d is not contained within a parent body\n."
         [ #  # ][ #  # ]
   10192         [ #  # ]:          0 :       "      It cannot be split.\n", ref_face_ptr->id() );
   10193                 :          0 :     return CUBIT_FAILURE;
   10194                 :            :   }
   10195                 :            : 
   10196 [ #  # ][ #  # ]:          0 :   SplitSurfaceTool sst;
   10197         [ #  # ]:          0 :   if( preview_flg == CUBIT_TRUE )
   10198                 :            :     return sst.preview( ref_face_ptr, locations, vec_lists, create_ref_edges_flg,
   10199         [ #  # ]:          0 :                         clear_previous_previews );
   10200                 :            :   else
   10201 [ #  # ][ #  # ]:          0 :     return sst.split_surface( ref_face_ptr, vec_lists );
   10202                 :            : }
   10203                 :            : 
   10204                 :            : //===============================================================================
   10205                 :            : // Function   : split_surface
   10206                 :            : // Member Type: PUBLIC
   10207                 :            : // Description: Split multiple surfaces
   10208                 :            : // Author     : Greg Schebler (CAT)
   10209                 :            : // Date       : 06/08
   10210                 :            : //===============================================================================
   10211                 :            : 
   10212                 :            : CubitStatus
   10213                 :          0 : GeometryModifyTool::split_surface( DLIList<RefFace*> &ref_face_list,
   10214                 :            :                                   DLIList<CubitVector*> &locations,
   10215                 :            :                                   DLIList<DLIList<DLIList<CubitVector*>*>*> &list_of_vec_lists,
   10216                 :            :                                   CubitBoolean preview_flg,
   10217                 :            :                                   CubitBoolean create_ref_edges_flg,
   10218                 :            :                                   CubitBoolean clear_previous_previews )
   10219                 :            : {
   10220                 :            :    // Check for virtual geometry
   10221         [ #  # ]:          0 :    DLIList<Body*> b_list;
   10222                 :            :    int gg;
   10223 [ #  # ][ #  # ]:          0 :    for( gg = ref_face_list.size() ; gg > 0 ; gg--)
   10224                 :            :    {
   10225         [ #  # ]:          0 :       RefFace* ref_face_ptr = ref_face_list.get_and_step();
   10226         [ #  # ]:          0 :       Body* body = ref_face_ptr->body();
   10227         [ #  # ]:          0 :       if (body)
   10228         [ #  # ]:          0 :          b_list.append(body);
   10229                 :            :       else
   10230                 :            :       {
   10231 [ #  # ][ #  # ]:          0 :          PRINT_ERROR( "Surface %d is not contained within a parent body.\n"
         [ #  # ][ #  # ]
   10232         [ #  # ]:          0 :             "      It cannot be split.\n", ref_face_ptr->id() );
   10233                 :          0 :          return CUBIT_FAILURE;
   10234                 :            :       }
   10235                 :            :    }
   10236 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( b_list, "SPLIT_SURFACE" ))
   10237                 :          0 :       return CUBIT_FAILURE;
   10238                 :            : 
   10239                 :            :    int ii;
   10240                 :            : 
   10241 [ #  # ][ #  # ]:          0 :    for( ii = ref_face_list.size(); ii > 0 ; ii--)
   10242                 :            :    {
   10243         [ #  # ]:          0 :       DLIList<Body*> old_body_list;
   10244         [ #  # ]:          0 :       RefFace* ref_face_ptr = ref_face_list.get_and_step();
   10245                 :            : 
   10246 [ #  # ][ #  # ]:          0 :       DLIList<Body*> body_list;
                 [ #  # ]
   10247         [ #  # ]:          0 :       ref_face_ptr->bodies( body_list );
   10248         [ #  # ]:          0 :       old_body_list.merge_unique( body_list );
   10249                 :            : 
   10250 [ #  # ][ #  # ]:          0 :       if( old_body_list.size() < 1 )
   10251                 :            :       {
   10252 [ #  # ][ #  # ]:          0 :          PRINT_ERROR( "Surface %d is not contained within a parent body\n."
         [ #  # ][ #  # ]
   10253         [ #  # ]:          0 :             "      It cannot be split.\n", ref_face_ptr->id() );
   10254 [ #  # ][ #  # ]:          0 :          return CUBIT_FAILURE;
   10255                 :            :       }
   10256                 :          0 :    }
   10257                 :            : 
   10258 [ #  # ][ #  # ]:          0 :    SplitSurfaceTool sst;
   10259         [ #  # ]:          0 :    if( preview_flg == CUBIT_TRUE )
   10260                 :            :       return sst.preview( ref_face_list, locations, list_of_vec_lists, create_ref_edges_flg,
   10261         [ #  # ]:          0 :       clear_previous_previews );
   10262                 :            :    else
   10263 [ #  # ][ #  # ]:          0 :       return sst.split_surface( ref_face_list, list_of_vec_lists );
   10264                 :            : }
   10265                 :            : 
   10266                 :            : //===============================================================================
   10267                 :            : // Function   : split_surfaces_extend
   10268                 :            : // Member Type: PUBLIC
   10269                 :            : // Description: Split surfaces by extending hardline curves on the surface
   10270                 :            : // Author     : Steve Storm (CAT)
   10271                 :            : // Date       : 10/07
   10272                 :            : //===============================================================================
   10273                 :            : CubitStatus
   10274                 :          0 : GeometryModifyTool::split_surfaces_extend( DLIList<RefFace*> &ref_face_list,
   10275                 :            :                                            DLIList<RefVertex*> &ref_vertex_list,
   10276                 :            :                                            CubitBoolean preview_flg,
   10277                 :            :                                            CubitBoolean create_ref_edges_flg )
   10278                 :            : {
   10279                 :            :   int i;
   10280                 :            :   RefFace *ref_face_ptr;
   10281                 :            : 
   10282 [ #  # ][ #  # ]:          0 :   for( i=ref_face_list.size(); i--; )
   10283                 :            :   {
   10284         [ #  # ]:          0 :     ref_face_ptr = ref_face_list.get();
   10285                 :            : 
   10286                 :            :     // Check for no body
   10287         [ #  # ]:          0 :     DLIList<Body*> body_list;
   10288         [ #  # ]:          0 :     ref_face_ptr->bodies( body_list );
   10289 [ #  # ][ #  # ]:          0 :     if( body_list.size()==0 )
   10290                 :            :     {
   10291 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Surface %d is not contained within a parent body.\n"
         [ #  # ][ #  # ]
   10292         [ #  # ]:          0 :         "       It cannot be split.\n", ref_face_ptr->id() );
   10293 [ #  # ][ #  # ]:          0 :       return CUBIT_FAILURE;
   10294                 :            :     }
   10295                 :          0 :   }
   10296                 :            : 
   10297                 :            :   // Check for virtual geometry
   10298         [ #  # ]:          0 :   DLIList<RefEntity*> ref_ent_list;
   10299 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10300 [ #  # ][ #  # ]:          0 :   if ( GeometryQueryTool::instance()->contains_intermediate_geometry(ref_ent_list) )
                 [ #  # ]
   10301                 :            :   {
   10302 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("SPLITTING surfaces containing virtual geometry is not\n"
                 [ #  # ]
   10303                 :            :       "       allowed. Delete virtual geometry on these surfaces\n"
   10304         [ #  # ]:          0 :       "       before operation.\n" );
   10305                 :          0 :     return CUBIT_FAILURE;
   10306                 :            :   }
   10307                 :            : 
   10308                 :            :   // Make sure all surfaces are from same geometry engine
   10309 [ #  # ][ #  # ]:          0 :   if ( !same_modify_engine(ref_ent_list, CUBIT_TRUE) )
   10310                 :            :   {
   10311 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing SPLIT with surfaces containing geometry from\n"
                 [ #  # ]
   10312                 :            :       "different modeling engines is not allowed.\n"
   10313         [ #  # ]:          0 :       "Delete uncommon geometry on these surfaces before operation.\n\n");
   10314                 :          0 :     return CUBIT_FAILURE;
   10315                 :            :   }
   10316                 :            : 
   10317 [ #  # ][ #  # ]:          0 :   SplitSurfaceTool sst;
   10318                 :            :   return sst.split_surfaces_extend( ref_face_list, ref_vertex_list,
   10319 [ #  # ][ #  # ]:          0 :     preview_flg, create_ref_edges_flg );
   10320                 :            : }
   10321                 :            : 
   10322                 :            : //===============================================================================
   10323                 :            : // Function   : split_surfaces
   10324                 :            : // Member Type: PUBLIC
   10325                 :            : // Description: Split a chain of surfaces into one or more pieces
   10326                 :            : // Author     : Steve Storm (CAT)
   10327                 :            : // Date       : 01/04
   10328                 :            : //===============================================================================
   10329                 :            : CubitStatus
   10330                 :          0 : GeometryModifyTool::split_surfaces( DLIList<RefFace*> &ref_face_list,
   10331                 :            :                                     int num_segs,
   10332                 :            :                                     double fraction,
   10333                 :            :                                     double distance,
   10334                 :            :                                     RefEdge *from_curve_ptr,
   10335                 :            :                                     DLIList<RefVertex*> &corner_vertex_list,
   10336                 :            :                                     DLIList<RefVertex*> &through_vertex_list,
   10337                 :            :                                     RefEdge *curve_dir_ptr,
   10338                 :            :                                     CubitBoolean preview_flg,
   10339                 :            :                                     CubitBoolean create_ref_edges_flg )
   10340                 :            : {
   10341                 :            :   // Get parent bodies - all surfs must be from same body
   10342                 :            :   int i;
   10343         [ #  # ]:          0 :   DLIList<Body*> old_body_list;
   10344                 :            :   RefFace *ref_face_ptr;
   10345         [ #  # ]:          0 :   ref_face_list.reset();
   10346 [ #  # ][ #  # ]:          0 :   for( i=ref_face_list.size(); i--; )
   10347                 :            :   {
   10348         [ #  # ]:          0 :     ref_face_ptr = ref_face_list.get_and_step();
   10349                 :            : 
   10350         [ #  # ]:          0 :     DLIList<Body*> body_list;
   10351         [ #  # ]:          0 :     ref_face_ptr->bodies( body_list );
   10352         [ #  # ]:          0 :     old_body_list.merge_unique( body_list );
   10353         [ #  # ]:          0 :   }
   10354                 :            : 
   10355 [ #  # ][ #  # ]:          0 :   if( old_body_list.size() > 1 )
   10356                 :            :   {
   10357 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "This operation requires all surfaces to be from the same volume\n" );
         [ #  # ][ #  # ]
   10358                 :            :     // Note: this restriction could be pretty easily lifted by sorting the
   10359                 :            :     //       input lists and calling the SplitSurfaceTool separately for each set of
   10360                 :            :     //       surfaces on each body.
   10361                 :          0 :     return CUBIT_FAILURE;
   10362                 :            :   }
   10363                 :            : 
   10364                 :            :   //bad geom with no body -- dont try to imprint this...
   10365                 :            :   //quick and dirty fix by (aga@cat|1/7/04)
   10366 [ #  # ][ #  # ]:          0 :   if( old_body_list.size() < 1 )
   10367                 :            :   {
   10368 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "A surface is not contained within a parent body.\n"
                 [ #  # ]
   10369         [ #  # ]:          0 :       "       It cannot be split.\n");
   10370                 :          0 :     return CUBIT_FAILURE;
   10371                 :            :   }
   10372                 :            : 
   10373                 :            :   // Check for virtual geometry
   10374 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> ref_ent_list;
   10375 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10376 [ #  # ][ #  # ]:          0 :   if ( GeometryQueryTool::instance()->contains_intermediate_geometry(ref_ent_list) )
                 [ #  # ]
   10377                 :            :   {
   10378 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("SPLITTING surfaces containing virtual geometry is not\n"
                 [ #  # ]
   10379                 :            :       "       allowed. Delete virtual geometry on these surfaces\n"
   10380         [ #  # ]:          0 :       "       before operation.\n" );
   10381                 :          0 :     return CUBIT_FAILURE;
   10382                 :            :   }
   10383                 :            : 
   10384                 :            :   // Make sure all surfaces are from same geometry engine
   10385 [ #  # ][ #  # ]:          0 :   if ( !same_modify_engine(ref_ent_list, CUBIT_TRUE) )
   10386                 :            :   {
   10387 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing SPLIT with surfaces containing geometry from\n"
                 [ #  # ]
   10388                 :            :       "different modeling engines is not allowed.\n"
   10389         [ #  # ]:          0 :       "Delete uncommon geometry on these surfaces before operation.\n\n");
   10390                 :          0 :     return CUBIT_FAILURE;
   10391                 :            :   }
   10392                 :            : 
   10393 [ #  # ][ #  # ]:          0 :   SplitSurfaceTool split_tool;
   10394                 :            :   return split_tool.split_surfaces( ref_face_list, num_segs, fraction,
   10395                 :            :     distance, from_curve_ptr, corner_vertex_list, through_vertex_list,
   10396 [ #  # ][ #  # ]:          0 :     curve_dir_ptr, preview_flg, create_ref_edges_flg );
   10397                 :            : }
   10398                 :            : 
   10399                 :            : //===============================================================================
   10400                 :            : // Function   : split_surfaces_offset
   10401                 :            : // Member Type: PUBLIC
   10402                 :            : // Description: Split a list of surface offset from a curve
   10403                 :            : // Author     : Sam Showman (CAT)
   10404                 :            : // Date       : 05/05
   10405                 :            : //===============================================================================
   10406                 :            : CubitStatus
   10407                 :          0 : GeometryModifyTool::split_surfaces_offset(DLIList<RefFace*> &ref_face_list,
   10408                 :            :                                           DLIList<RefEdge*> &edge_list,
   10409                 :            :                                           int num_segs,
   10410                 :            :                                           double distance,
   10411                 :            :                                           CubitBoolean partition_flg,
   10412                 :            :                                           CubitBoolean blunt_flg,
   10413                 :            :                                           CubitBoolean preview_flg,
   10414                 :            :                                           CubitBoolean create_ref_edges_flg)
   10415                 :            : {
   10416                 :            :   int i;
   10417         [ #  # ]:          0 :   DLIList<Body*> old_body_list;
   10418                 :            :   RefFace *ref_face_ptr;
   10419         [ #  # ]:          0 :   ref_face_list.reset();
   10420 [ #  # ][ #  # ]:          0 :   for( i=ref_face_list.size(); i--; )
   10421                 :            :   {
   10422         [ #  # ]:          0 :     ref_face_ptr = ref_face_list.get_and_step();
   10423                 :            : 
   10424         [ #  # ]:          0 :     DLIList<Body*> body_list;
   10425         [ #  # ]:          0 :     ref_face_ptr->bodies( body_list );
   10426         [ #  # ]:          0 :     old_body_list.merge_unique( body_list );
   10427         [ #  # ]:          0 :   }
   10428                 :            : 
   10429                 :            :   //check for geometry with no body
   10430 [ #  # ][ #  # ]:          0 :   if( old_body_list.size() < 1 )
   10431                 :            :   {
   10432 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "A surface is not contained within a parent body.\n"
                 [ #  # ]
   10433         [ #  # ]:          0 :       "       It cannot be split.\n");
   10434                 :          0 :     return CUBIT_FAILURE;
   10435                 :            :   }
   10436                 :            : 
   10437                 :            :   // Check for virtual geometry
   10438 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> ref_ent_list;
   10439 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10440 [ #  # ][ #  # ]:          0 :   if ( GeometryQueryTool::instance()->contains_intermediate_geometry(ref_ent_list) )
                 [ #  # ]
   10441                 :            :   {
   10442 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("SPLITTING surfaces containing virtual geometry is not\n"
                 [ #  # ]
   10443                 :            :       "       allowed. Delete virtual geometry on these surfaces\n"
   10444         [ #  # ]:          0 :       "       before operation.\n" );
   10445                 :          0 :     return CUBIT_FAILURE;
   10446                 :            :   }
   10447                 :            : 
   10448                 :            :   // Make sure all surfaces are from same geometry engine
   10449                 :            :   // Make sure all curves are from same geometry engine
   10450 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(edge_list, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10451 [ #  # ][ #  # ]:          0 :   if ( !same_modify_engine(ref_ent_list, CUBIT_TRUE) )
   10452                 :            :   {
   10453 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing SPLIT with geometry from\n"
                 [ #  # ]
   10454         [ #  # ]:          0 :       "different modeling engines is not allowed.\n");
   10455                 :          0 :     return CUBIT_FAILURE;
   10456                 :            :   }
   10457                 :            : 
   10458 [ #  # ][ #  # ]:          0 :   OffsetSplitTool split_tool;
   10459                 :            :   return split_tool.split_surfaces_offset(
   10460                 :            :       ref_face_list,
   10461                 :            :       edge_list,
   10462                 :            :       num_segs,
   10463                 :            :       distance,
   10464                 :            :       partition_flg,
   10465                 :            :       blunt_flg,
   10466                 :            :       preview_flg,
   10467 [ #  # ][ #  # ]:          0 :       create_ref_edges_flg);
   10468                 :            : }
   10469                 :            : 
   10470                 :            : //===============================================================================
   10471                 :            : // Function   : auto_mid_surface
   10472                 :            : // Member Type: PUBLIC
   10473                 :            : // Description: Automatically midsurface a volume
   10474                 :            : // Author     : Sam Showman (CAT)
   10475                 :            : // Date       : 12/07
   10476                 :            : //===============================================================================
   10477                 :            : CubitStatus
   10478                 :          0 : GeometryModifyTool::auto_mid_surface(DLIList<Body*> &body_list_in,
   10479                 :            :                                      DLIList<Body*> &body_list_out,
   10480                 :            :                                      DLIList<Body*> &old_bodies_midsurfaced,
   10481                 :            :                                      DLIList<double> &thickness_list,
   10482                 :            :                                      double lower_tol,
   10483                 :            :                                      double upper_tol,
   10484                 :            :                                      CubitBoolean delete_midsurfaced,
   10485                 :            : 
   10486                 :            :                                      CubitBoolean preview)
   10487                 :            : {
   10488                 :            :         // Check for virtual geometry
   10489         [ #  # ]:          0 :         DLIList<RefEntity*> ref_ent_list;
   10490 [ #  # ][ #  # ]:          0 :         CAST_LIST_TO_PARENT(body_list_in, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10491 [ #  # ][ #  # ]:          0 :         if ( GeometryQueryTool::instance()->contains_intermediate_geometry(ref_ent_list) )
                 [ #  # ]
   10492                 :            :         {
   10493 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR("Midsurfacing volumes containing virtual geometry is not\n"
                 [ #  # ]
   10494                 :            :                         "       allowed. Delete virtual geometry on these surfaces\n"
   10495         [ #  # ]:          0 :                         "       before operation.\n" );
   10496                 :          0 :                 return CUBIT_FAILURE;
   10497                 :            :         }
   10498                 :            : 
   10499                 :            :         // Make sure all surfaces are from same geometry engine
   10500 [ #  # ][ #  # ]:          0 :         if ( !same_modify_engine(ref_ent_list, CUBIT_TRUE) )
   10501                 :            :         {
   10502 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR("Performing Midsurface with geometry from\n"
                 [ #  # ]
   10503         [ #  # ]:          0 :                         "different modeling engines is not allowed.\n");
   10504                 :          0 :                 return CUBIT_FAILURE;
   10505                 :            :         }
   10506                 :            : 
   10507 [ #  # ][ #  # ]:          0 :         AutoMidsurfaceTool mid_tool;
   10508 [ #  # ][ #  # ]:          0 :         DLIList<BodySM*> bodysm_list_out;
   10509                 :            : 
   10510 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled() && delete_midsurfaced && !preview)
         [ #  # ][ #  # ]
                 [ #  # ]
   10511         [ #  # ]:          0 :         CubitUndo::save_state_with_cubit_file(body_list_in);
   10512                 :            : 
   10513                 :            :     CubitStatus result = mid_tool.midsurface(
   10514                 :            :         body_list_in,
   10515                 :            :         bodysm_list_out,
   10516                 :            :         old_bodies_midsurfaced,
   10517                 :            :         thickness_list,
   10518                 :            :         lower_tol,
   10519                 :            :         upper_tol,
   10520                 :            :         delete_midsurfaced,
   10521         [ #  # ]:          0 :         preview);
   10522                 :            : 
   10523                 :            : 
   10524 [ #  # ][ #  # ]:          0 :         if (result == CUBIT_SUCCESS &&
   10525 [ #  # ][ #  # ]:          0 :                 bodysm_list_out.size() > 0 &&
                 [ #  # ]
   10526                 :          0 :                 !preview)
   10527                 :            :         {
   10528 [ #  # ][ #  # ]:          0 :                 if(CubitUndo::get_undo_enabled())
   10529         [ #  # ]:          0 :                         CubitUndo::save_state();
   10530                 :            : 
   10531 [ #  # ][ #  # ]:          0 :                 for( int i=0; i<bodysm_list_out.size(); i++ )
   10532                 :            :                 {
   10533 [ #  # ][ #  # ]:          0 :                         body_list_out.append(GeometryQueryTool::instance()->make_Body(bodysm_list_out[i]));
         [ #  # ][ #  # ]
   10534                 :            :                 }
   10535                 :            : 
   10536 [ #  # ][ #  # ]:          0 :                 if( CubitUndo::get_undo_enabled() )
   10537                 :            :                 {
   10538 [ #  # ][ #  # ]:          0 :                         if( body_list_out.size() )
   10539         [ #  # ]:          0 :                                 CubitUndo::note_result_bodies( body_list_out );
   10540                 :            :                         else
   10541         [ #  # ]:          0 :                                 CubitUndo::remove_last_undo();
   10542                 :            :                 }
   10543                 :            :         }
   10544                 :            : 
   10545         [ #  # ]:          0 :         return result;
   10546                 :            : }
   10547                 :            : 
   10548                 :            : //-------------------------------------------------------------------------
   10549                 :            : // Purpose       : clean RefEntity
   10550                 :            : //
   10551                 :            : // Special Notes :
   10552                 :            : //
   10553                 :            : // Creator       : Lingyun Pan (CAT)
   10554                 :            : //
   10555                 :            : // Creation Date : 07/15/01
   10556                 :            : //-------------------------------------------------------------------------
   10557                 :            : 
   10558                 :            : CubitStatus
   10559                 :          0 : GeometryModifyTool::regularize_refentity(RefEntity *old_entity_ptr, Body *&new_body_ptr)
   10560                 :            : {
   10561         [ #  # ]:          0 :   BasicTopologyEntity* bte_ptr = dynamic_cast<BasicTopologyEntity*>(old_entity_ptr);
   10562         [ #  # ]:          0 :   if (!bte_ptr)
   10563                 :            :   {
   10564 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Invalid entity passed to regularize_refentity(..)\n");
         [ #  # ][ #  # ]
   10565                 :          0 :     return CUBIT_FAILURE;
   10566                 :            :   }
   10567                 :            : 
   10568         [ #  # ]:          0 :   DLIList<Body*> body_list;
   10569         [ #  # ]:          0 :   bte_ptr->bodies(body_list);
   10570                 :            : 
   10571                 :            :   //ignore free entities
   10572 [ #  # ][ #  # ]:          0 :   if( body_list.size() == 0 )
   10573                 :            :   {
   10574 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("%s %d is a free entity.  Cannot regularize it.\n", old_entity_ptr->class_name(),
         [ #  # ][ #  # ]
                 [ #  # ]
   10575         [ #  # ]:          0 :                                                                     old_entity_ptr->id() );
   10576                 :          0 :     new_body_ptr = NULL;
   10577                 :          0 :     return CUBIT_FAILURE;
   10578                 :            :   }
   10579                 :            : 
   10580 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( body_list, "REGULARIZE" ))
   10581                 :          0 :     return CUBIT_FAILURE;
   10582                 :            : 
   10583 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list;
   10584                 :            :   // For curves we can try to handle composite curves.
   10585 [ #  # ][ #  # ]:          0 :   if(dynamic_cast<RefEdge*>(old_entity_ptr))
                 [ #  # ]
   10586                 :            :   {
   10587 [ #  # ][ #  # ]:          0 :     TopologyBridge *first_bridge = bte_ptr->bridge_manager()->topology_bridge();
   10588         [ #  # ]:          0 :     GeometryQueryEngine *gqe = first_bridge->get_geometry_query_engine();
   10589         [ #  # ]:          0 :     gqe->get_underlying_bridges(first_bridge, bridge_list);
   10590 [ #  # ][ #  # ]:          0 :     if(bridge_list.size() == 0)
   10591         [ #  # ]:          0 :       bridge_list.append(first_bridge);
   10592                 :            :   }
   10593                 :            :   else
   10594                 :            :   {
   10595 [ #  # ][ #  # ]:          0 :     bte_ptr->bridge_manager()->get_bridge_list(bridge_list);
   10596                 :            :   }
   10597                 :            : 
   10598                 :            :   //bte_ptr->bridge_manager()->get_bridge_list(bridge_list);
   10599         [ #  # ]:          0 :   bridge_list.reset();
   10600                 :            : 
   10601 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_sm_list;
   10602 [ #  # ][ #  # ]:          0 :   DLIList<Body*> new_body_list;
   10603                 :          0 :   CubitStatus stat = CUBIT_SUCCESS;
   10604                 :            : 
   10605         [ #  # ]:          0 :   do_attribute_setup();
   10606                 :            : 
   10607                 :          0 :   GeometryModifyEngine *save_gme = NULL;
   10608 [ #  # ][ #  # ]:          0 :   for (int i = bridge_list.size(); i--; )
   10609                 :            :   {
   10610         [ #  # ]:          0 :     TopologyBridge* bridge = bridge_list.get_and_step();
   10611         [ #  # ]:          0 :     GeometryEntity* geom_ptr = dynamic_cast<GeometryEntity*>(bridge);
   10612         [ #  # ]:          0 :     GeometryModifyEngine* gme = get_engine(geom_ptr);
   10613         [ #  # ]:          0 :     if(!save_gme)
   10614                 :          0 :       save_gme = gme;
   10615         [ #  # ]:          0 :     if (!gme) continue;
   10616                 :            : 
   10617         [ #  # ]:          0 :     DLIList<BodySM*> body_sm_list;
   10618         [ #  # ]:          0 :     geom_ptr->bodysms(body_sm_list);
   10619         [ #  # ]:          0 :     push_attributes_before_modify(body_sm_list);
   10620                 :            : 
   10621                 :          0 :     BodySM *new_body_sm = NULL;
   10622 [ #  # ][ #  # ]:          0 :     if (!gme->regularize_entity( geom_ptr, new_body_sm ))
   10623                 :          0 :       stat = CUBIT_FAILURE;
   10624                 :            : 
   10625         [ #  # ]:          0 :     if (new_body_sm)
   10626         [ #  # ]:          0 :       new_sm_list.append(new_body_sm);
   10627         [ #  # ]:          0 :   }
   10628                 :            : 
   10629         [ #  # ]:          0 :   new_sm_list.uniquify_ordered();
   10630                 :            : 
   10631                 :            :   // This is bad in that it assumes all of the gmes will be the
   10632                 :            :   // same but I don't know that we truly support the other case
   10633                 :            :   // anyway.
   10634 [ #  # ][ #  # ]:          0 :   if(new_sm_list.size())
   10635                 :            :   {
   10636         [ #  # ]:          0 :     restore_vg_after_modify(new_sm_list, body_list, save_gme);
   10637         [ #  # ]:          0 :     remove_pushed_attributes(new_sm_list, body_list);
   10638                 :            :   }
   10639                 :            : 
   10640 [ #  # ][ #  # ]:          0 :   if (!finish_sm_op(body_list, new_sm_list, new_body_list))
   10641                 :          0 :     stat = CUBIT_FAILURE;
   10642                 :            : 
   10643         [ #  # ]:          0 :   do_attribute_cleanup();
   10644                 :            : 
   10645 [ #  # ][ #  # ]:          0 :   new_body_ptr = new_body_list.size() ? new_body_list.get() : 0;
                 [ #  # ]
   10646         [ #  # ]:          0 :   return stat;
   10647                 :            : }
   10648                 :            : 
   10649                 :          0 : CubitStatus GeometryModifyTool::test_regularize_refentity(RefEntity *old_entity_ptr)
   10650                 :            : {
   10651         [ #  # ]:          0 :    DLIList<RefEntity*> tmp_ref_ent_list(1);
   10652         [ #  # ]:          0 :    tmp_ref_ent_list.append( old_entity_ptr );
   10653 [ #  # ][ #  # ]:          0 :    if( GeometryQueryTool::instance()->contains_intermediate_geometry(tmp_ref_ent_list) )
                 [ #  # ]
   10654                 :            :    {
   10655                 :          0 :      return CUBIT_FAILURE;
   10656                 :            :    }
   10657                 :            : 
   10658         [ #  # ]:          0 :    BasicTopologyEntity* bte_ptr = dynamic_cast<BasicTopologyEntity*>(old_entity_ptr);
   10659         [ #  # ]:          0 :    if (!bte_ptr)
   10660                 :            :    {
   10661                 :          0 :      return CUBIT_FAILURE;
   10662                 :            :    }
   10663                 :            : 
   10664 [ #  # ][ #  # ]:          0 :    DLIList<TopologyBridge*> bridge_list;
   10665 [ #  # ][ #  # ]:          0 :    bte_ptr->bridge_manager()->get_bridge_list(bridge_list);
   10666         [ #  # ]:          0 :    bridge_list.reset();
   10667                 :            : 
   10668                 :          0 :    CubitStatus stat = CUBIT_SUCCESS;
   10669                 :            : 
   10670 [ #  # ][ #  # ]:          0 :    for (int i = bridge_list.size(); i--; )
   10671                 :            :    {
   10672         [ #  # ]:          0 :      TopologyBridge* bridge = bridge_list.get_and_step();
   10673         [ #  # ]:          0 :      GeometryEntity* geom_ptr = dynamic_cast<GeometryEntity*>(bridge);
   10674         [ #  # ]:          0 :      GeometryModifyEngine* gme = get_engine(geom_ptr);
   10675         [ #  # ]:          0 :      if (!gme) continue;
   10676                 :            : 
   10677 [ #  # ][ #  # ]:          0 :      if (!gme->test_regularize_entity( geom_ptr ))
   10678                 :          0 :        stat = CUBIT_FAILURE;
   10679                 :            :    }
   10680                 :            : 
   10681         [ #  # ]:          0 :    return stat;
   10682                 :            : }
   10683                 :            : 
   10684                 :            : //-------------------------------------------------------------------------
   10685                 :            : // Purpose       : split a multiple volume body into several bodies
   10686                 :            : //                 each containing a single volume.
   10687                 :            : //
   10688                 :            : // Special Notes :
   10689                 :            : //
   10690                 :            : // Creator       : David White
   10691                 :            : //
   10692                 :            : // Creation Date : 09/26/97
   10693                 :            : //-------------------------------------------------------------------------
   10694                 :            : 
   10695                 :          0 : CubitStatus GeometryModifyTool::regularize_body(Body *body_ptr,
   10696                 :            :                                                 Body *&new_body )
   10697                 :            : {
   10698         [ #  # ]:          0 :    DLIList<Body*> b_list;
   10699         [ #  # ]:          0 :    b_list.append(body_ptr);
   10700 [ #  # ][ #  # ]:          0 :    if (!okay_to_modify( b_list, "REGULARIZE" ))
   10701                 :          0 :      return CUBIT_FAILURE;   
   10702                 :            : 
   10703         [ #  # ]:          0 :    BodySM* body_sm = body_ptr->get_body_sm_ptr(), *new_sm = 0;
   10704         [ #  # ]:          0 :    GeometryModifyEngine* gme = get_engine(body_sm);
   10705         [ #  # ]:          0 :    if (!gme) {
   10706 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Volume does not have a modify engine.\n" );
         [ #  # ][ #  # ]
   10707                 :          0 :      return CUBIT_FAILURE;
   10708                 :            :   }
   10709                 :            : 
   10710         [ #  # ]:          0 :    do_attribute_setup();
   10711 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sm_list, new_bodysm_list;
         [ #  # ][ #  # ]
   10712         [ #  # ]:          0 :    body_sm_list.append(body_sm);
   10713         [ #  # ]:          0 :    push_attributes_before_modify(body_sm_list);
   10714                 :            : 
   10715         [ #  # ]:          0 :    CubitStatus stat = gme->regularize_body( body_sm, new_sm );
   10716         [ #  # ]:          0 :    if ( new_sm == NULL )
   10717                 :            :    {
   10718 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("REGULARIZATION failure.\n");
         [ #  # ][ #  # ]
   10719                 :          0 :       return CUBIT_FAILURE;
   10720                 :            :    }
   10721                 :            : 
   10722                 :            :    // remove mesh from modified body
   10723 [ #  # ][ #  # ]:          0 :    AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_MODIFIED, body_ptr));
         [ #  # ][ #  # ]
                 [ #  # ]
   10724                 :            : 
   10725         [ #  # ]:          0 :    new_bodysm_list.append(new_sm);
   10726         [ #  # ]:          0 :    restore_vg_after_modify(new_bodysm_list, b_list, gme);
   10727         [ #  # ]:          0 :    remove_pushed_attributes(new_bodysm_list, b_list);
   10728                 :            : 
   10729         [ #  # ]:          0 :    body_sm = body_ptr->get_body_sm_ptr();
   10730         [ #  # ]:          0 :    update_body(body_ptr);
   10731                 :            : 
   10732 [ #  # ][ #  # ]:          0 :    new_body = GeometryQueryTool::instance()->make_Body(new_sm);
   10733 [ #  # ][ #  # ]:          0 :    GeometryQueryTool::instance()->cleanout_deactivated_geometry();
   10734                 :            : 
   10735         [ #  # ]:          0 :    do_attribute_cleanup();
   10736                 :            : 
   10737         [ #  # ]:          0 :    return stat;
   10738                 :            : }
   10739                 :            : 
   10740                 :            : CubitStatus
   10741                 :          0 : GeometryModifyTool::create_solid_bodies_from_surfs( DLIList<RefFace*> &ref_face_list,
   10742                 :            :                                             DLIList<Body*> &new_bodies,
   10743                 :            :                                             CubitBoolean keep_old,
   10744                 :            :                                             CubitBoolean heal,
   10745                 :            :                                             CubitBoolean sheet ) const
   10746                 :            : {
   10747                 :            :     //First check to make sure the data is all here.
   10748 [ #  # ][ #  # ]:          0 :   for ( int ii = ref_face_list.size(); ii > 0; ii-- )
   10749                 :            :   {
   10750         [ #  # ]:          0 :     RefFace *ref_face = ref_face_list.get_and_step();
   10751         [ #  # ]:          0 :     DLIList<Body*> bodies;
   10752         [ #  # ]:          0 :     ref_face->bodies(bodies);
   10753 [ #  # ][ #  # ]:          0 :     if ( bodies.size() > 1 )
   10754                 :            :     {
   10755 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Can't create a volume with %s (surface %d) is attached to more\n"
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10756                 :            :                   "than one volume, or if the attached body is not a sheet body.\n",
   10757                 :            :                   ref_face->entity_name().c_str(),
   10758         [ #  # ]:          0 :                   ref_face->id());
   10759                 :          0 :       return CUBIT_FAILURE;
   10760                 :            :     }
   10761 [ #  # ][ #  # ]:          0 :     else if ( bodies.size() == 1 )
   10762                 :            :     {
   10763 [ #  # ][ #  # ]:          0 :       if (!bodies.get()->is_sheet_body())
                 [ #  # ]
   10764                 :            :       {
   10765 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Can't create a volume with %s (surface %d), it is\n"
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10766                 :            :                     "attached to a body that is not a sheet body.\n",
   10767                 :            :                     ref_face->entity_name().c_str(),
   10768         [ #  # ]:          0 :                     ref_face->id());
   10769 [ #  # ][ #  # ]:          0 :         return CUBIT_FAILURE;
   10770                 :            :       }
   10771                 :            :     }
   10772                 :          0 :   }
   10773                 :            : 
   10774 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(ref_face_list.size());
   10775 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(ref_face_list.size());
                 [ #  # ]
   10776 [ #  # ][ #  # ]:          0 :   DLIList<Surface*>       surface_list(ref_face_list.size());
                 [ #  # ]
   10777                 :            :   GeometryModifyEngine* gme;
   10778                 :            : 
   10779 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, entity_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   10780         [ #  # ]:          0 :   gme = common_modify_engine(entity_list, bridge_list);
   10781 [ #  # ][ #  # ]:          0 :   CAST_LIST(bridge_list, surface_list, Surface);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10782                 :            : 
   10783         [ #  # ]:          0 :   if (!gme) {
   10784 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Surfaces do not share a common modify engine.\n");
         [ #  # ][ #  # ]
   10785                 :          0 :     return CUBIT_FAILURE;
   10786                 :            :   }
   10787                 :            : 
   10788 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> query_output, query_input(ref_face_list.size());
         [ #  # ][ #  # ]
                 [ #  # ]
   10789 [ #  # ][ #  # ]:          0 :   DLIList<Body*> body_list;
   10790                 :            : 
   10791 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(ref_face_list, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   10792                 :            :   ModelQueryEngine::instance()->
   10793 [ #  # ][ #  # ]:          0 :     query_model( query_input, DagType::body_type(), query_output );
                 [ #  # ]
   10794 [ #  # ][ #  # ]:          0 :   CAST_LIST( query_output, body_list, Body );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   10795                 :            : 
   10796                 :            :   int i;
   10797 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> free_face_list;
   10798 [ #  # ][ #  # ]:          0 :   for ( i=ref_face_list.size(); i--; )
   10799                 :            :   {
   10800         [ #  # ]:          0 :     RefFace* ref_face = ref_face_list.get_and_step();
   10801         [ #  # ]:          0 :     query_output.clean_out();
   10802                 :            :     ModelQueryEngine::instance()->
   10803 [ #  # ][ #  # ]:          0 :       query_model( *ref_face, DagType::body_type(), query_output );
                 [ #  # ]
   10804 [ #  # ][ #  # ]:          0 :     if (!query_output.size())
   10805         [ #  # ]:          0 :       free_face_list.append(ref_face);
   10806                 :            :   }
   10807                 :            : 
   10808 [ #  # ][ #  # ]:          0 :   if (CubitUndo::get_undo_enabled())
   10809         [ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file(ref_face_list);
   10810                 :            : 
   10811                 :            :   //get all the bodysm's
   10812 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> old_body_sm_list;
   10813 [ #  # ][ #  # ]:          0 :   for( i=body_list.size(); i--; )
   10814                 :            :   {
   10815         [ #  # ]:          0 :     Body *tmp_body = body_list.get_and_step();
   10816 [ #  # ][ #  # ]:          0 :     TopologyBridge *tb = tmp_body->bridge_manager()->topology_bridge();
   10817         [ #  # ]:          0 :     BodySM *tmp_body_sm = CAST_TO(tb, BodySM);
   10818         [ #  # ]:          0 :     if( tmp_body_sm )
   10819         [ #  # ]:          0 :       old_body_sm_list.append( tmp_body_sm );
   10820                 :            :   }
   10821                 :            : 
   10822                 :            :   // TODO: do I need a clear and a flush here? --KGM
   10823 [ #  # ][ #  # ]:          0 :   GeometryModifyTool::instance()->do_attribute_setup();
   10824 [ #  # ][ #  # ]:          0 :   GeometryModifyTool::instance()->push_attributes_before_modify(old_body_sm_list);
   10825                 :            : 
   10826 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodies_sm;
   10827         [ #  # ]:          0 :   CubitStatus stat = gme->create_solid_bodies_from_surfs( surface_list, new_bodies_sm, keep_old, heal, sheet );
   10828 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sm_list;
   10829 [ #  # ][ #  # ]:          0 :   for ( i=new_bodies_sm.size(); i--; )
   10830 [ #  # ][ #  # ]:          0 :     body_sm_list.append( new_bodies_sm.get_and_step() );
   10831                 :            : 
   10832 [ #  # ][ #  # ]:          0 :   GeometryModifyTool::instance()->restore_vg_after_modify(new_bodies_sm, body_list, gme);
   10833 [ #  # ][ #  # ]:          0 :   GeometryModifyTool::instance()->remove_pushed_attributes(new_bodies_sm, body_list);
   10834                 :            : 
   10835 [ #  # ][ #  # ]:          0 :   if (!finish_sm_op( body_list, body_sm_list, new_bodies))
   10836                 :            :   {
   10837                 :          0 :     stat = CUBIT_FAILURE;
   10838 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   10839         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   10840                 :            :   }
   10841                 :            :   else
   10842                 :            :   {
   10843 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   10844         [ #  # ]:          0 :       CubitUndo::note_result_bodies(new_bodies);
   10845                 :            :   }
   10846                 :            : 
   10847 [ #  # ][ #  # ]:          0 :   GeometryModifyTool::instance()->do_attribute_cleanup();
   10848                 :            : 
   10849 [ #  # ][ #  # ]:          0 :   DLIList<int> id_list (free_face_list.size());
                 [ #  # ]
   10850 [ #  # ][ #  # ]:          0 :   while (free_face_list.size())
   10851                 :            :   {
   10852         [ #  # ]:          0 :     RefFace* ref_face = free_face_list.pop();
   10853 [ #  # ][ #  # ]:          0 :     if (!ref_face->get_surface_ptr())
   10854                 :            :     {
   10855 [ #  # ][ #  # ]:          0 :       id_list.append(ref_face->id());
   10856                 :            :       GeometryQueryTool::instance()->
   10857 [ #  # ][ #  # ]:          0 :         destroy_dead_entity( ref_face );
   10858                 :            :     }
   10859                 :            :   }
   10860                 :            : 
   10861 [ #  # ][ #  # ]:          0 :   GeometryQueryTool::instance()->cleanout_deactivated_geometry();
   10862 [ #  # ][ #  # ]:          0 :   if (id_list.size())
   10863         [ #  # ]:          0 :     CubitUtil::list_entity_ids( "Destroyed surface(s) ", id_list );
   10864                 :            : 
   10865                 :            :   //new_body = new_body_list.size() ? new_body_list.get() : 0;
   10866         [ #  # ]:          0 :   return stat;
   10867                 :            : }
   10868                 :            : 
   10869                 :            : //-------------------------------------------------------------------------
   10870                 :            : // Purpose       : Check for virtual geometry
   10871                 :            : //
   10872                 :            : // Special Notes :
   10873                 :            : //
   10874                 :            : // Creator       : Jason Kraftcheck
   10875                 :            : //
   10876                 :            : // Creation Date : 10/10/03
   10877                 :            : //-------------------------------------------------------------------------
   10878                 :         97 : bool GeometryModifyTool::contains_intermediate_geom( DLIList<Body*>& list ) const
   10879                 :            : {
   10880         [ +  - ]:         97 :   DLIList<TopologyBridge*> bridges;
   10881         [ +  - ]:         97 :   list.reset();
   10882 [ +  - ][ +  + ]:        280 :   for (int i = list.size(); i--; )
   10883 [ +  - ][ +  - ]:        183 :     bridges.append(list.get_and_step()->get_body_sm_ptr());
                 [ +  - ]
   10884 [ +  - ][ +  - ]:         97 :   return contains_intermediate_geom(bridges);
   10885                 :            : }
   10886                 :            : 
   10887                 :            : //-------------------------------------------------------------------------
   10888                 :            : // Purpose       : Check for virtual geometry
   10889                 :            : //
   10890                 :            : // Special Notes :
   10891                 :            : //
   10892                 :            : // Creator       : Jason Kraftcheck
   10893                 :            : //
   10894                 :            : // Creation Date : 10/10/03
   10895                 :            : //-------------------------------------------------------------------------
   10896                 :         97 : bool GeometryModifyTool::contains_intermediate_geom(
   10897                 :            :                            DLIList<TopologyBridge*>& bridge_list ) const
   10898                 :            : {
   10899         [ +  - ]:         97 :   DLIList<TopologyBridge*> child_list;
   10900 [ +  - ][ +  + ]:      19166 :   while (bridge_list.size())
   10901                 :            :   {
   10902         [ +  - ]:      19069 :     TopologyBridge* bridge = bridge_list.pop();
   10903         [ +  - ]:      19069 :     TBOwner* bridge_owner = bridge->owner();
   10904 [ +  - ][ +  - ]:      19069 :     if (bridge_owner && !dynamic_cast<BridgeManager*>(bridge_owner))
         [ -  + ][ -  + ]
   10905                 :          0 :       return true;
   10906                 :            : 
   10907         [ +  - ]:      19069 :     child_list.clean_out();
   10908         [ +  - ]:      19069 :     bridge->get_children_virt(child_list);
   10909         [ +  - ]:      19069 :     bridge_list += child_list;
   10910                 :            :   }
   10911         [ +  - ]:         97 :   return false;
   10912                 :            : }
   10913                 :            : 
   10914                 :        162 : bool GeometryModifyTool::contains_partitions( DLIList<Body*>& list ) const
   10915                 :            : {
   10916         [ +  - ]:        162 :   DLIList<TopologyBridge*> bridges;
   10917         [ +  - ]:        162 :   list.reset();
   10918 [ +  - ][ +  + ]:        583 :   for (int i = list.size(); i--; )
   10919 [ +  - ][ +  - ]:        421 :     bridges.append(list.get_and_step()->get_body_sm_ptr());
                 [ +  - ]
   10920 [ +  - ][ +  - ]:        162 :   return contains_partitions(bridges);
   10921                 :            : }
   10922                 :            : 
   10923                 :         31 : bool GeometryModifyTool::contains_composites( DLIList<Body*>& list ) const
   10924                 :            : {
   10925         [ +  - ]:         31 :   DLIList<TopologyBridge*> bridges;
   10926         [ +  - ]:         31 :   list.reset();
   10927 [ +  - ][ +  + ]:        124 :   for (int i = list.size(); i--; )
   10928 [ +  - ][ +  - ]:         93 :     bridges.append(list.get_and_step()->get_body_sm_ptr());
                 [ +  - ]
   10929 [ +  - ][ +  - ]:         31 :   return contains_composites(bridges);
   10930                 :            : }
   10931                 :            : 
   10932                 :        185 : bool GeometryModifyTool::contains_composites(
   10933                 :            :                            DLIList<TopologyBridge*>& bridge_list ) const
   10934                 :            : {
   10935         [ +  - ]:        185 :   DLIList<TopologyBridge*> child_list;
   10936 [ +  - ][ +  + ]:      43958 :   while (bridge_list.size())
   10937                 :            :   {
   10938         [ +  - ]:      43773 :     TopologyBridge* bridge = bridge_list.pop();
   10939         [ +  - ]:      43773 :     TBOwner* bridge_owner = bridge->owner();
   10940 [ +  + ][ +  - ]:      43773 :     if (bridge_owner && !dynamic_cast<BridgeManager*>(bridge_owner) &&
         [ -  + ][ #  # ]
                 [ -  + ]
   10941 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->ige_is_composite(bridge_owner))
   10942                 :          0 :       return true;
   10943                 :            : 
   10944         [ +  - ]:      43773 :     child_list.clean_out();
   10945         [ +  - ]:      43773 :     bridge->get_children_virt(child_list);
   10946         [ +  - ]:      43773 :     bridge_list += child_list;
   10947                 :            :   }
   10948         [ +  - ]:        185 :   return false;
   10949                 :            : }
   10950                 :            : 
   10951                 :        162 : bool GeometryModifyTool::contains_partitions(
   10952                 :            :                            DLIList<TopologyBridge*>& bridge_list ) const
   10953                 :            : {
   10954         [ +  - ]:        162 :   DLIList<TopologyBridge*> child_list;
   10955 [ +  - ][ +  + ]:      36859 :   while (bridge_list.size())
   10956                 :            :   {
   10957         [ +  - ]:      36697 :     TopologyBridge* bridge = bridge_list.pop();
   10958         [ +  - ]:      36697 :     TBOwner* bridge_owner = bridge->owner();
   10959 [ +  - ][ +  - ]:      36697 :     if (bridge_owner && !dynamic_cast<BridgeManager*>(bridge_owner) &&
         [ -  + ][ #  # ]
                 [ -  + ]
   10960 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->ige_is_partition(bridge_owner))
   10961                 :          0 :       return true;
   10962                 :            : 
   10963         [ +  - ]:      36697 :     child_list.clean_out();
   10964         [ +  - ]:      36697 :     bridge->get_children_virt(child_list);
   10965         [ +  - ]:      36697 :     bridge_list += child_list;
   10966                 :            :   }
   10967         [ +  - ]:        162 :   return false;
   10968                 :            : }
   10969                 :            : 
   10970                 :            : 
   10971                 :          0 : CubitBoolean GeometryModifyTool::same_modify_engine(DLIList<TopologyEntity*> &topo_list) const
   10972                 :            : {
   10973                 :          0 :   GeometryModifyEngine *gePtr1 = get_engine(topo_list.get_and_step());
   10974                 :            :   GeometryModifyEngine *gePtr2;
   10975         [ #  # ]:          0 :   for( int i = 1; i < topo_list.size(); i++)
   10976                 :            :   {
   10977                 :          0 :     gePtr2 = get_engine(topo_list.get_and_step());
   10978         [ #  # ]:          0 :     if(gePtr1 != gePtr2)
   10979                 :            :     {
   10980                 :          0 :       return CUBIT_FALSE;
   10981                 :            :     }
   10982                 :            :   }
   10983                 :          0 :   return CUBIT_TRUE;
   10984                 :            : }
   10985                 :            : 
   10986                 :          0 : CubitBoolean GeometryModifyTool::same_modify_engine(DLIList<RefEntity*> &ref_entity_list,
   10987                 :            :                                                     CubitBoolean check_children) const
   10988                 :            : {
   10989                 :            : 
   10990         [ #  # ]:          0 :   DLIList<RefEntity*> complete_entity_list;
   10991                 :            : 
   10992                 :            :   //Check the check_children option and check all the children if necessary
   10993         [ #  # ]:          0 :   if (check_children)
   10994                 :            :   {
   10995                 :            :     //Make a complete list of all the RefEntitys and their children
   10996         [ #  # ]:          0 :     DLIList<RefEntity*> temp = ref_entity_list;
   10997                 :            :     RefEntity* ref_entity_ptr;
   10998                 :            :     int i;
   10999 [ #  # ][ #  # ]:          0 :     for (i = 0; i < ref_entity_list.size(); i++)
   11000                 :            :     {
   11001         [ #  # ]:          0 :       ref_entity_ptr = ref_entity_list.get_and_step();
   11002         [ #  # ]:          0 :       complete_entity_list.clean_out();
   11003         [ #  # ]:          0 :       ref_entity_ptr->get_all_child_ref_entities(complete_entity_list);
   11004         [ #  # ]:          0 :       temp += complete_entity_list;
   11005                 :            :     }
   11006         [ #  # ]:          0 :     complete_entity_list.clean_out();
   11007 [ #  # ][ #  # ]:          0 :     complete_entity_list.merge_unique(temp);
   11008                 :            :   }
   11009                 :            :   else
   11010         [ #  # ]:          0 :     complete_entity_list = ref_entity_list;
   11011                 :            : 
   11012                 :            :   //Now make sure all the RefEntitys are from the same geometry engine
   11013 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> te_list;
   11014 [ #  # ][ #  # ]:          0 :   CAST_LIST(complete_entity_list, te_list, TopologyEntity);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   11015 [ #  # ][ #  # ]:          0 :   return same_modify_engine(te_list);
   11016                 :            : 
   11017                 :            : }
   11018                 :            : 
   11019                 :            : CubitStatus
   11020                 :          0 : GeometryModifyTool::trim_curve( RefEdge* trim_curve,
   11021                 :            :                                 const CubitVector& trim_vector,
   11022                 :            :                                 const CubitVector& keep_vector )
   11023                 :            : {
   11024                 :            :   // Use geometry engine to find intersections
   11025                 :          0 :   TopologyBridge* bridge = 0;
   11026         [ #  # ]:          0 :   GeometryModifyEngine* gme_ptr = get_engine(trim_curve, &bridge);
   11027         [ #  # ]:          0 :   Curve *new_curve = 0, *curve = dynamic_cast<Curve*>(bridge);
   11028                 :            : 
   11029 [ #  # ][ #  # ]:          0 :   if (!gme_ptr || !curve)
   11030                 :          0 :     return CUBIT_FAILURE;
   11031                 :            : 
   11032 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   11033                 :            :   {
   11034         [ #  # ]:          0 :     DLIList<RefEdge*> tmp_ents(1);
   11035         [ #  # ]:          0 :     tmp_ents.append( trim_curve );
   11036 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( tmp_ents );
   11037                 :            :   }
   11038                 :            : 
   11039         [ #  # ]:          0 :   new_curve = gme_ptr->trim_curve( curve, trim_vector, keep_vector );
   11040         [ #  # ]:          0 :   if (!new_curve)
   11041                 :            :   {
   11042 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   11043         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   11044                 :          0 :     return CUBIT_FAILURE;
   11045                 :            :   }
   11046                 :            : 
   11047 [ #  # ][ #  # ]:          0 :   GeometryQueryTool::instance()->destroy_dead_entity( trim_curve );
   11048                 :            : 
   11049 [ #  # ][ #  # ]:          0 :   RefEdge* new_edge = GeometryQueryTool::instance()->make_free_RefEdge(new_curve);
   11050                 :            : 
   11051 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   11052 [ #  # ][ #  # ]:          0 :     CubitUndo::note_result_entity( new_edge );
   11053                 :            : 
   11054 [ #  # ][ #  # ]:          0 :   PRINT_INFO("Created curve %d\n", new_edge->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   11055                 :            : 
   11056                 :          0 :   return CUBIT_SUCCESS;
   11057                 :            : }
   11058                 :            : 
   11059                 :            : CubitStatus
   11060                 :          0 : GeometryModifyTool::surface_intersection( RefFace *ref_face1,
   11061                 :            :                                           RefFace *ref_face2,
   11062                 :            :                                           DLIList<RefEdge*> &ref_edge_list )
   11063                 :            : {
   11064         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(2);
   11065 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(2);
   11066         [ #  # ]:          0 :   entity_list.append(ref_face1);
   11067         [ #  # ]:          0 :   entity_list.append(ref_face2);
   11068         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine(entity_list, bridge_list);
   11069         [ #  # ]:          0 :   if (!gme)
   11070                 :            :   {
   11071 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Surfaces %d and %d do not share a common solid modeller.\n",
         [ #  # ][ #  # ]
                 [ #  # ]
   11072         [ #  # ]:          0 :       ref_face1->id(), ref_face2->id() );
   11073                 :          0 :     return CUBIT_FAILURE;
   11074                 :            :   }
   11075                 :            : 
   11076         [ #  # ]:          0 :   bridge_list.reset();
   11077 [ #  # ][ #  # ]:          0 :   Surface* surf0 = dynamic_cast<Surface*>(bridge_list.get_and_step());
   11078 [ #  # ][ #  # ]:          0 :   Surface* surf1 = dynamic_cast<Surface*>(bridge_list.get());
   11079                 :            : 
   11080         [ #  # ]:          0 :   GeometryQueryEngine* gqe = surf0->get_geometry_query_engine();
   11081                 :            :   // Note the user can set the following value through
   11082                 :            :   //  set geometry accuracy <val>
   11083         [ #  # ]:          0 :   double resabs = gqe->get_sme_resabs_tolerance();
   11084                 :            : 
   11085 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list;
   11086         [ #  # ]:          0 :   CubitStatus status = gme->surface_intersection( surf0, surf1, curve_list, resabs );
   11087                 :            : 
   11088         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   11089                 :          0 :     return CUBIT_FAILURE;
   11090                 :            : 
   11091 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && curve_list.size() )
         [ #  # ][ #  # ]
                 [ #  # ]
   11092         [ #  # ]:          0 :     CubitUndo::save_state();
   11093                 :            : 
   11094                 :            :   int i;
   11095                 :            :   Curve *curve_ptr;
   11096                 :            :   RefEdge *ref_edge_ptr;
   11097         [ #  # ]:          0 :   curve_list.reset();
   11098 [ #  # ][ #  # ]:          0 :   for( i=curve_list.size(); i--; )
   11099                 :            :   {
   11100         [ #  # ]:          0 :     curve_ptr = curve_list.get_and_step();
   11101                 :            :     ref_edge_ptr = GeometryQueryTool::instance()->
   11102 [ #  # ][ #  # ]:          0 :       make_free_RefEdge( curve_ptr );
   11103         [ #  # ]:          0 :     if( ref_edge_ptr )
   11104         [ #  # ]:          0 :       ref_edge_list.append( ref_edge_ptr );
   11105                 :            :     else
   11106 [ #  # ][ #  # ]:          0 :       delete curve_ptr;
   11107                 :            :   }
   11108                 :            : 
   11109 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   11110                 :            :   {
   11111         [ #  # ]:          0 :     DLIList<RefEntity*> tmp_list;
   11112 [ #  # ][ #  # ]:          0 :     for( i=ref_edge_list.size(); i--; )
   11113 [ #  # ][ #  # ]:          0 :       tmp_list.append( ref_edge_list.get_and_step() );
                 [ #  # ]
   11114 [ #  # ][ #  # ]:          0 :     CubitUndo::note_result_entities( tmp_list );
   11115                 :            :   }
   11116                 :            : 
   11117         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   11118                 :            : }
   11119                 :            : 
   11120                 :            : 
   11121                 :            : RefEdge*
   11122                 :         11 : GeometryModifyTool::create_arc(const CubitVector& position,
   11123                 :            :                                double radius,
   11124                 :            :                                double start_angle,
   11125                 :            :                                double end_angle,
   11126                 :            :                                CubitVector plane,
   11127                 :            :                                CubitBoolean preview)
   11128                 :            : {
   11129         [ -  + ]:         11 :   if(0 == gmeList.size())
   11130                 :            :   {
   11131 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
   11132                 :          0 :     return NULL;
   11133                 :            :   }
   11134                 :            : 
   11135         [ -  + ]:         11 :   if( radius <= GEOMETRY_RESABS )
   11136                 :            :   {
   11137 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Values must be positive\n");
   11138                 :          0 :     return NULL;
   11139                 :            :   }
   11140                 :            : 
   11141         [ -  + ]:         11 :   if(preview)
   11142                 :            :   {
   11143         [ #  # ]:          0 :     gmeList.get()->create_arc(position,radius,start_angle,end_angle, plane, preview);
   11144                 :          0 :     return NULL;
   11145                 :            :   }
   11146                 :            : 
   11147         [ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
   11148                 :          0 :     CubitUndo::save_state();
   11149                 :            : 
   11150         [ +  - ]:         11 :   Curve* curve = gmeList.get()->create_arc(position,radius,start_angle,end_angle, plane,preview);
   11151         [ -  + ]:         11 :   if (!curve)
   11152                 :            :   {
   11153         [ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   11154                 :          0 :       CubitUndo::remove_last_undo();
   11155                 :          0 :     return 0;
   11156                 :            :   }
   11157                 :            : 
   11158                 :         11 :   RefEdge* result = GeometryQueryTool::instance()->make_free_RefEdge(curve);
   11159 [ +  - ][ +  - ]:         11 :   PRINT_INFO("Created curve %d\n", result->id());
   11160                 :            : 
   11161         [ -  + ]:         11 :   if( CubitUndo::get_undo_enabled() )
   11162         [ #  # ]:          0 :     CubitUndo::note_result_entity( result );
   11163                 :         11 :   return result;
   11164                 :            : }
   11165                 :            : 
   11166                 :            : 
   11167                 :            : 
   11168                 :            : 
   11169                 :            : RefEdge*
   11170                 :         22 : GeometryModifyTool::create_arc_three( RefVertex* ref_vertex1,
   11171                 :            :                                       RefVertex* ref_vertex2,
   11172                 :            :                                       RefVertex* ref_vertex3,
   11173                 :            :                                       CubitBoolean full,
   11174                 :            :                                       CubitBoolean preview )
   11175                 :            : {
   11176         [ +  - ]:         22 :   DLIList<TopologyEntity*> entity_list(3);
   11177 [ +  - ][ +  - ]:         44 :   DLIList<TopologyBridge*> bridge_list(3);
   11178         [ +  - ]:         22 :   entity_list.append(ref_vertex1);
   11179         [ +  - ]:         22 :   entity_list.append(ref_vertex2);
   11180         [ +  - ]:         22 :   entity_list.append(ref_vertex3);
   11181         [ +  - ]:         22 :   GeometryModifyEngine* gme = common_modify_engine(entity_list, bridge_list);
   11182         [ -  + ]:         22 :   if (!gme)
   11183                 :            :   {
   11184 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Vertices do not share a common solid modeller.\n");
         [ #  # ][ #  # ]
   11185                 :          0 :     return 0;
   11186                 :            :   }
   11187                 :            : 
   11188         [ -  + ]:         22 :   if(preview)
   11189                 :            :   {
   11190         [ #  # ]:          0 :     bridge_list.reset();
   11191 [ #  # ][ #  # ]:          0 :     TBPoint* point0 = dynamic_cast<TBPoint*>(bridge_list.next(0));
   11192 [ #  # ][ #  # ]:          0 :     TBPoint* point1 = dynamic_cast<TBPoint*>(bridge_list.next(1));
   11193 [ #  # ][ #  # ]:          0 :     TBPoint* point2 = dynamic_cast<TBPoint*>(bridge_list.next(2));
   11194         [ #  # ]:          0 :     gme->create_arc_three( point0, point1, point2, full,preview );
   11195                 :          0 :     return NULL;
   11196                 :            :   }
   11197                 :            : 
   11198                 :            :   //if we can reuse vertices, we decide here
   11199                 :         22 :   bool need_new_start_point = false;
   11200                 :         22 :   bool need_new_end_point = false;
   11201         [ +  + ]:         22 :   if( full )
   11202                 :            :   {
   11203         [ +  - ]:         11 :     need_new_start_point = ref_vertex1->get_parents() > 0;
   11204         [ +  - ]:         11 :     if (need_new_start_point)
   11205                 :            :     {
   11206         [ +  - ]:         11 :       bridge_list.reset();
   11207 [ +  - ][ +  - ]:         11 :       TBPoint *start_point = gme->make_Point( ref_vertex1->coordinates() );
   11208         [ +  - ]:         11 :       bridge_list.change_to( start_point );
   11209                 :            :     }
   11210                 :            :   }
   11211                 :            :   else
   11212                 :            :   {
   11213         [ +  - ]:         11 :     need_new_start_point = ref_vertex1->get_parents() > 0;
   11214         [ +  - ]:         11 :     need_new_end_point = ref_vertex3->get_parents() > 0;
   11215                 :            : 
   11216         [ -  + ]:         11 :     if (need_new_start_point)
   11217                 :            :     {
   11218         [ #  # ]:          0 :       bridge_list.reset();
   11219 [ #  # ][ #  # ]:          0 :       TBPoint *start_point = gme->make_Point( ref_vertex1->coordinates() );
   11220         [ #  # ]:          0 :       bridge_list.change_to( start_point );
   11221                 :            :     }
   11222         [ -  + ]:         11 :     if (need_new_end_point)
   11223                 :            :     {
   11224         [ #  # ]:          0 :       bridge_list.reset();
   11225         [ #  # ]:          0 :       bridge_list.last();
   11226 [ #  # ][ #  # ]:          0 :       TBPoint *end_point = gme->make_Point( ref_vertex3->coordinates());
   11227         [ #  # ]:          0 :       bridge_list.change_to( end_point );
   11228                 :            :     }
   11229                 :            :   }
   11230                 :            : 
   11231 [ +  - ][ -  + ]:         22 :   if( CubitUndo::get_undo_enabled() )
   11232                 :            :   {
   11233         [ #  # ]:          0 :     DLIList<RefVertex*> vertices_to_save;
   11234         [ #  # ]:          0 :     if( !need_new_start_point )
   11235         [ #  # ]:          0 :       vertices_to_save.append( ref_vertex1 );
   11236         [ #  # ]:          0 :     if( !need_new_end_point )
   11237         [ #  # ]:          0 :       vertices_to_save.append( ref_vertex3 );
   11238                 :            : 
   11239 [ #  # ][ #  # ]:          0 :     if( vertices_to_save.size() )
   11240         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( vertices_to_save, true );
   11241                 :            :     else
   11242 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state();
   11243                 :            :   }
   11244                 :            : 
   11245         [ +  - ]:         22 :   bridge_list.reset();
   11246 [ +  - ][ -  + ]:         22 :   TBPoint* point0 = dynamic_cast<TBPoint*>(bridge_list.next(0));
   11247 [ +  - ][ -  + ]:         22 :   TBPoint* point1 = dynamic_cast<TBPoint*>(bridge_list.next(1));
   11248 [ +  - ][ -  + ]:         22 :   TBPoint* point2 = dynamic_cast<TBPoint*>(bridge_list.next(2));
   11249         [ +  - ]:         22 :   Curve* curve = gme->create_arc_three( point0, point1, point2, full,preview );
   11250         [ -  + ]:         22 :   if (!curve)
   11251                 :            :   {
   11252 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   11253         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   11254                 :          0 :     return 0;
   11255                 :            :   }
   11256                 :            : 
   11257 [ +  - ][ +  - ]:         22 :   RefEdge* result = GeometryQueryTool::instance()->make_free_RefEdge(curve);
   11258 [ +  - ][ +  - ]:         22 :   PRINT_INFO("Created curve %d\n", result->id());
         [ +  - ][ +  - ]
                 [ +  - ]
   11259                 :            : 
   11260 [ +  - ][ -  + ]:         22 :   if( CubitUndo::get_undo_enabled() )
   11261 [ #  # ][ #  # ]:          0 :     CubitUndo::note_result_entity( result );
   11262         [ +  - ]:         44 :   return result;
   11263                 :            : 
   11264                 :            : }
   11265                 :            : 
   11266                 :            : RefEdge*
   11267                 :          0 : GeometryModifyTool::create_arc_three( RefEdge* ref_edge1,
   11268                 :            :                                       RefEdge* ref_edge2,
   11269                 :            :                                       RefEdge* ref_edge3,
   11270                 :            :                                       CubitBoolean full,
   11271                 :            :                                       CubitBoolean preview )
   11272                 :            : {
   11273         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(3);
   11274 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(3);
   11275         [ #  # ]:          0 :   entity_list.append(ref_edge1);
   11276         [ #  # ]:          0 :   entity_list.append(ref_edge2);
   11277         [ #  # ]:          0 :   entity_list.append(ref_edge3);
   11278         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine(entity_list, bridge_list);
   11279         [ #  # ]:          0 :   if (!gme)
   11280                 :            :   {
   11281 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("The input curves must be associated with a common solid modeller.\n");
         [ #  # ][ #  # ]
   11282                 :          0 :     return NULL;
   11283                 :            :   }
   11284                 :            : 
   11285         [ #  # ]:          0 :   bridge_list.reset();
   11286 [ #  # ][ #  # ]:          0 :   Curve* curve0 = dynamic_cast<Curve*>(bridge_list.next(0));
   11287 [ #  # ][ #  # ]:          0 :   Curve* curve1 = dynamic_cast<Curve*>(bridge_list.next(1));
   11288 [ #  # ][ #  # ]:          0 :   Curve* curve2 = dynamic_cast<Curve*>(bridge_list.next(2));
   11289         [ #  # ]:          0 :   Curve* curve = gme->create_arc_three( curve0, curve1, curve2, full,preview );
   11290         [ #  # ]:          0 :   if (!curve)
   11291                 :          0 :     return 0;
   11292                 :            : 
   11293 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   11294         [ #  # ]:          0 :     CubitUndo::save_state();
   11295                 :            : 
   11296 [ #  # ][ #  # ]:          0 :   RefEdge* result = GeometryQueryTool::instance()->make_free_RefEdge(curve);
   11297                 :            : 
   11298 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   11299 [ #  # ][ #  # ]:          0 :     CubitUndo::note_result_entity( result );
   11300                 :            : 
   11301 [ #  # ][ #  # ]:          0 :   PRINT_INFO("Created curve %d\n", result->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   11302         [ #  # ]:          0 :   return result;
   11303                 :            : }
   11304                 :            : RefEdge*
   11305                 :          0 : GeometryModifyTool::create_arc_radius( RefVertex* ref_vertex1,
   11306                 :            :                                             RefVertex* ref_vertex2,
   11307                 :            :                                             const CubitVector &normal,
   11308                 :            :                                             double radius,
   11309                 :            :                                             CubitBoolean other_arc,
   11310                 :            :                                             CubitBoolean full,
   11311                 :            :                                             CubitBoolean preview)
   11312                 :            : {
   11313         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(2);
   11314 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(2);
   11315         [ #  # ]:          0 :   entity_list.append(ref_vertex1);
   11316         [ #  # ]:          0 :   entity_list.append(ref_vertex2);
   11317         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine(entity_list, bridge_list);
   11318         [ #  # ]:          0 :   if (!gme)
   11319                 :            :   {
   11320 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Vertices do not share a common modify engine.\n");
         [ #  # ][ #  # ]
   11321                 :          0 :     return 0;
   11322                 :            :   }
   11323                 :            : 
   11324                 :            : 
   11325                 :            : 
   11326         [ #  # ]:          0 :   CubitVector start = ref_vertex1->coordinates(); // Position on arc
   11327         [ #  # ]:          0 :   CubitVector end = ref_vertex2->coordinates(); // Position on arc
   11328                 :            : 
   11329         [ #  # ]:          0 :   CubitVector center_vec=end-start;
   11330                 :            : 
   11331         [ #  # ]:          0 :   CubitVector perp_vec=normal*center_vec;
   11332         [ #  # ]:          0 :   center_vec*=0.5;
   11333         [ #  # ]:          0 :   double b=radius*radius-center_vec.length_squared();
   11334         [ #  # ]:          0 :   if(b>=0)
   11335                 :            :   {
   11336                 :          0 :     b=sqrt(b);
   11337                 :            :   }
   11338                 :            :   else
   11339                 :            :   {
   11340 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Radius must be greater than half the distance between the end vertices.\n");
         [ #  # ][ #  # ]
   11341                 :          0 :     return 0;
   11342                 :            :   }
   11343         [ #  # ]:          0 :   if(other_arc)
   11344                 :          0 :     b*=-1;
   11345                 :            : 
   11346                 :            : 
   11347         [ #  # ]:          0 :   perp_vec.normalize();
   11348         [ #  # ]:          0 :   perp_vec*=b;
   11349                 :            : 
   11350                 :            : 
   11351 [ #  # ][ #  # ]:          0 :   center_vec=center_vec+perp_vec;
   11352                 :            : 
   11353         [ #  # ]:          0 :   CubitVector center=start+center_vec;
   11354                 :            : 
   11355         [ #  # ]:          0 :   if(preview)
   11356                 :            :   {
   11357         [ #  # ]:          0 :     bridge_list.reset();
   11358 [ #  # ][ #  # ]:          0 :     TBPoint* point1 = dynamic_cast<TBPoint*>(bridge_list.next(0));
   11359 [ #  # ][ #  # ]:          0 :     TBPoint* point2 = dynamic_cast<TBPoint*>(bridge_list.next(1));
   11360                 :            :      gme->create_arc_radius(center,point1, point2,
   11361         [ #  # ]:          0 :       normal, radius, full,preview );
   11362                 :          0 :      return NULL;
   11363                 :            :   }
   11364                 :            :   else
   11365                 :            :   {
   11366                 :            : 
   11367                 :            :     //if we can reuse vertices, we decide here
   11368                 :          0 :     bool need_new_start_point=false, need_new_end_point=false;
   11369         [ #  # ]:          0 :     if( full )
   11370                 :            :     {
   11371         [ #  # ]:          0 :       need_new_start_point = ref_vertex1->get_parents() > 0;
   11372         [ #  # ]:          0 :       if (need_new_start_point)
   11373                 :            :       {
   11374         [ #  # ]:          0 :         bridge_list.reset();
   11375 [ #  # ][ #  # ]:          0 :         TBPoint *start_point = gme->make_Point( ref_vertex1->coordinates() );
   11376         [ #  # ]:          0 :         bridge_list.change_to( start_point );
   11377                 :            :       }
   11378                 :            :     }
   11379                 :            :     else
   11380                 :            :     {
   11381         [ #  # ]:          0 :       need_new_start_point = ref_vertex1->get_parents() > 0;
   11382         [ #  # ]:          0 :       need_new_end_point = ref_vertex2->get_parents() > 0;
   11383                 :            : 
   11384         [ #  # ]:          0 :       if (need_new_start_point)
   11385                 :            :       {
   11386         [ #  # ]:          0 :         bridge_list.reset();
   11387 [ #  # ][ #  # ]:          0 :         TBPoint *start_point = gme->make_Point( ref_vertex1->coordinates() );
   11388         [ #  # ]:          0 :         bridge_list.change_to( start_point );
   11389                 :            :       }
   11390         [ #  # ]:          0 :       if (need_new_end_point)
   11391                 :            :       {
   11392         [ #  # ]:          0 :         bridge_list.last();
   11393 [ #  # ][ #  # ]:          0 :         TBPoint *end_point = gme->make_Point( ref_vertex2->coordinates());
   11394         [ #  # ]:          0 :         bridge_list.change_to( end_point );
   11395                 :            :       }
   11396                 :            :     }
   11397                 :            : 
   11398 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   11399                 :            :     {
   11400         [ #  # ]:          0 :       DLIList<RefVertex*> vertices_to_save;
   11401         [ #  # ]:          0 :       if( !need_new_start_point )
   11402         [ #  # ]:          0 :         vertices_to_save.append( ref_vertex1 );
   11403         [ #  # ]:          0 :       if( !need_new_end_point )
   11404         [ #  # ]:          0 :         vertices_to_save.append( ref_vertex2 );
   11405                 :            : 
   11406 [ #  # ][ #  # ]:          0 :       if( vertices_to_save.size() )
   11407         [ #  # ]:          0 :         CubitUndo::save_state_with_cubit_file( vertices_to_save, true );
   11408                 :            :       else
   11409 [ #  # ][ #  # ]:          0 :         CubitUndo::save_state();
   11410                 :            :     }
   11411                 :            : 
   11412         [ #  # ]:          0 :     bridge_list.reset();
   11413 [ #  # ][ #  # ]:          0 :     TBPoint* point1 = dynamic_cast<TBPoint*>(bridge_list.next(0));
   11414 [ #  # ][ #  # ]:          0 :     TBPoint* point2 = dynamic_cast<TBPoint*>(bridge_list.next(1));
   11415                 :            :     Curve* curve = gme->create_arc_radius(center,point1, point2,
   11416         [ #  # ]:          0 :       normal, radius, full,preview );
   11417         [ #  # ]:          0 :     if (!curve)
   11418                 :            :     {
   11419 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   11420         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   11421                 :          0 :       return 0;
   11422                 :            :     }
   11423                 :            : 
   11424 [ #  # ][ #  # ]:          0 :     RefEdge* result = GeometryQueryTool::instance()->make_free_RefEdge(curve);
   11425 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Created curve %d\n", result->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   11426                 :            : 
   11427 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   11428 [ #  # ][ #  # ]:          0 :       CubitUndo::note_result_entity( result );
   11429                 :            : 
   11430                 :          0 :     return result;
   11431                 :            :   }
   11432         [ #  # ]:          0 :   return 0;
   11433                 :            : }
   11434                 :            : 
   11435                 :            : RefEdge*
   11436                 :          0 : GeometryModifyTool::create_arc_center_edge( RefVertex* ref_vertex1,
   11437                 :            :                                             RefVertex* ref_vertex2,
   11438                 :            :                                             RefVertex* ref_vertex3,
   11439                 :            :                                             const CubitVector &normal,
   11440                 :            :                                             double radius,
   11441                 :            :                                             CubitBoolean full,
   11442                 :            :                                             CubitBoolean preview )
   11443                 :            : {
   11444         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(3);
   11445 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(3);
   11446         [ #  # ]:          0 :   entity_list.append(ref_vertex1);
   11447         [ #  # ]:          0 :   entity_list.append(ref_vertex2);
   11448         [ #  # ]:          0 :   entity_list.append(ref_vertex3);
   11449         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine(entity_list, bridge_list);
   11450         [ #  # ]:          0 :   if (!gme)
   11451                 :            :   {
   11452 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Vertices do not share a common modify engine.\n");
         [ #  # ][ #  # ]
   11453                 :          0 :     return 0;
   11454                 :            :   }
   11455                 :            : 
   11456         [ #  # ]:          0 :   if(preview)
   11457                 :            :   {
   11458 [ #  # ][ #  # ]:          0 :     TBPoint* point0 = dynamic_cast<TBPoint*>(bridge_list.next(0));
   11459 [ #  # ][ #  # ]:          0 :     TBPoint* point1 = dynamic_cast<TBPoint*>(bridge_list.next(1));
   11460 [ #  # ][ #  # ]:          0 :     TBPoint* point2 = dynamic_cast<TBPoint*>(bridge_list.next(2));
   11461                 :            :     gme->create_arc_center_edge( point0, point1, point2,
   11462         [ #  # ]:          0 :       normal, radius, full,preview );
   11463                 :          0 :     return NULL;
   11464                 :            : 
   11465                 :            :   }
   11466                 :            : 
   11467                 :            :   //if we can reuse vertices, we decide here
   11468                 :          0 :   bool need_new_start_point=false, need_new_end_point=false;
   11469         [ #  # ]:          0 :   if( full )
   11470                 :            :   {
   11471         [ #  # ]:          0 :     need_new_start_point = ref_vertex2->get_parents() > 0;
   11472         [ #  # ]:          0 :     if (need_new_start_point)
   11473                 :            :     {
   11474         [ #  # ]:          0 :       bridge_list.reset();
   11475         [ #  # ]:          0 :       bridge_list.step(1);
   11476 [ #  # ][ #  # ]:          0 :       TBPoint *start_point = gme->make_Point( ref_vertex2->coordinates() );
   11477         [ #  # ]:          0 :       bridge_list.change_to( start_point );
   11478                 :            :     }
   11479                 :            :   }
   11480                 :            :   else
   11481                 :            :   {
   11482         [ #  # ]:          0 :     need_new_start_point = ref_vertex2->get_parents() > 0;
   11483         [ #  # ]:          0 :     need_new_end_point = ref_vertex3->get_parents() > 0;
   11484                 :            : 
   11485         [ #  # ]:          0 :     if (need_new_start_point)
   11486                 :            :     {
   11487         [ #  # ]:          0 :       bridge_list.reset();
   11488         [ #  # ]:          0 :       bridge_list.step();
   11489 [ #  # ][ #  # ]:          0 :       TBPoint *start_point = gme->make_Point( ref_vertex2->coordinates() );
   11490         [ #  # ]:          0 :       bridge_list.change_to( start_point );
   11491                 :            :     }
   11492         [ #  # ]:          0 :     if (need_new_end_point)
   11493                 :            :     {
   11494         [ #  # ]:          0 :       bridge_list.last();
   11495 [ #  # ][ #  # ]:          0 :       TBPoint *end_point = gme->make_Point( ref_vertex3->coordinates());
   11496         [ #  # ]:          0 :       bridge_list.change_to( end_point );
   11497                 :            :     }
   11498                 :            :   }
   11499                 :            : 
   11500 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   11501                 :            :   {
   11502         [ #  # ]:          0 :     DLIList<RefVertex*> vertices_to_save;
   11503         [ #  # ]:          0 :     if( !need_new_start_point )
   11504         [ #  # ]:          0 :       vertices_to_save.append( ref_vertex2 );
   11505         [ #  # ]:          0 :     if( !need_new_end_point )
   11506         [ #  # ]:          0 :       vertices_to_save.append( ref_vertex3 );
   11507                 :            : 
   11508 [ #  # ][ #  # ]:          0 :     if( vertices_to_save.size() )
   11509         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( vertices_to_save, true );
   11510                 :            :     else
   11511 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state();
   11512                 :            :   }
   11513                 :            : 
   11514         [ #  # ]:          0 :   bridge_list.reset();
   11515 [ #  # ][ #  # ]:          0 :   TBPoint* point0 = dynamic_cast<TBPoint*>(bridge_list.next(0));
   11516 [ #  # ][ #  # ]:          0 :   TBPoint* point1 = dynamic_cast<TBPoint*>(bridge_list.next(1));
   11517 [ #  # ][ #  # ]:          0 :   TBPoint* point2 = dynamic_cast<TBPoint*>(bridge_list.next(2));
   11518                 :            :   Curve* curve = gme->create_arc_center_edge( point0, point1, point2,
   11519         [ #  # ]:          0 :     normal, radius, full );
   11520         [ #  # ]:          0 :   if (!curve)
   11521                 :            :   {
   11522 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   11523         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   11524                 :          0 :     return 0;
   11525                 :            :   }
   11526                 :            : 
   11527 [ #  # ][ #  # ]:          0 :   RefEdge* result = GeometryQueryTool::instance()->make_free_RefEdge(curve);
   11528 [ #  # ][ #  # ]:          0 :   PRINT_INFO("Created curve %d\n", result->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   11529                 :            : 
   11530 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   11531 [ #  # ][ #  # ]:          0 :     CubitUndo::note_result_entity( result );
   11532                 :            : 
   11533         [ #  # ]:          0 :   return result;
   11534                 :            : 
   11535                 :            : }
   11536                 :            : 
   11537                 :            : CubitStatus
   11538                 :          0 : GeometryModifyTool::create_curve_combine( DLIList<RefEdge*>& ref_edge_list,
   11539                 :            :                                     RefEdge *&new_ref_edge_ptr )
   11540                 :            : {
   11541 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(ref_edge_list.size());
   11542                 :          0 :   CubitStatus result = CUBIT_FAILURE;
   11543                 :            : 
   11544         [ #  # ]:          0 :   int count = ref_edge_list.size();
   11545         [ #  # ]:          0 :   if (count == 0)
   11546                 :            :   {
   11547 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("No edges to combine.\n");
         [ #  # ][ #  # ]
   11548                 :          0 :     return result;
   11549                 :            :   }
   11550                 :            : 
   11551 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
   11552 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( ref_edge_list, entity_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   11553         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine(entity_list, bridge_list);
   11554         [ #  # ]:          0 :   if (!gme)
   11555                 :            :   {
   11556 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Edges do not share a common modify engine.\n");
         [ #  # ][ #  # ]
   11557                 :          0 :     return result;
   11558                 :            :   }
   11559                 :            : 
   11560                 :            :   Curve* new_curve_ptr;
   11561 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(count);
   11562 [ #  # ][ #  # ]:          0 :   CAST_LIST( bridge_list, curve_list, Curve );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   11563         [ #  # ]:          0 :   result = gme->create_curve_combine(curve_list, new_curve_ptr);
   11564         [ #  # ]:          0 :   if (new_curve_ptr)
   11565 [ #  # ][ #  # ]:          0 :       new_ref_edge_ptr = CAST_TO(new_curve_ptr->topology_entity(), RefEdge);
   11566                 :            : 
   11567                 :            : 
   11568         [ #  # ]:          0 :   return result;
   11569                 :            : }
   11570                 :            : 
   11571                 :            : //-------------------------------------------------------------------------
   11572                 :            : // Purpose       : Find a common geometry engine
   11573                 :            : //
   11574                 :            : // Special Notes :
   11575                 :            : //
   11576                 :            : // Creator       : Jason Kraftcheck
   11577                 :            : //
   11578                 :            : // Creation Date : 02/28/00
   11579                 :            : //-------------------------------------------------------------------------
   11580                 :            : GeometryModifyEngine*
   11581                 :        383 : GeometryModifyTool::common_modify_engine( DLIList<TopologyEntity*>& topology_list,
   11582                 :            :                                           DLIList<TopologyBridge*>& engine_bridges,
   11583                 :            :                                           CubitBoolean allow_composites ) const
   11584                 :            : {
   11585                 :        383 :   GeometryModifyEngine* gme_ptr = 0;
   11586         [ -  + ]:        383 :   if(allow_composites)
   11587                 :            :   {
   11588                 :            :     int i;
   11589                 :          0 :     engine_bridges.clean_out();
   11590         [ #  # ]:          0 :     for(i=topology_list.size(); i--;)
   11591                 :            :     {
   11592         [ #  # ]:          0 :       TopologyEntity* topo_ptr = topology_list.get_and_step();
   11593         [ #  # ]:          0 :       if (!topo_ptr)
   11594                 :          0 :         return (GeometryModifyEngine*)NULL;
   11595 [ #  # ][ #  # ]:          0 :       TopologyBridge *first_bridge = topo_ptr->bridge_manager()->topology_bridge();
   11596         [ #  # ]:          0 :       GeometryQueryEngine *gqe = first_bridge->get_geometry_query_engine();
   11597         [ #  # ]:          0 :       DLIList<TopologyBridge*> underlying_bridge_list;
   11598         [ #  # ]:          0 :       gqe->get_underlying_bridges(first_bridge, underlying_bridge_list);
   11599 [ #  # ][ #  # ]:          0 :       if(underlying_bridge_list.size() == 0)
   11600         [ #  # ]:          0 :         underlying_bridge_list.append(first_bridge);
   11601                 :            :       int k;
   11602 [ #  # ][ #  # ]:          0 :       for(k=underlying_bridge_list.size(); k--;)
   11603                 :            :       {
   11604         [ #  # ]:          0 :         TopologyBridge *bridge_ptr = underlying_bridge_list.get_and_step();
   11605         [ #  # ]:          0 :         engine_bridges.append( bridge_ptr );
   11606         [ #  # ]:          0 :         GeometryModifyEngine *cur_gme = get_engine(bridge_ptr);
   11607         [ #  # ]:          0 :         if(!gme_ptr)
   11608                 :          0 :           gme_ptr = cur_gme;
   11609                 :            :         else
   11610                 :            :         {
   11611         [ #  # ]:          0 :           if(gme_ptr != cur_gme)
   11612                 :            :           {
   11613                 :          0 :             gme_ptr = NULL;
   11614                 :          0 :             k=0;
   11615                 :          0 :             i=0;
   11616                 :            :           }
   11617                 :            :         }
   11618                 :            :       }
   11619         [ #  # ]:          0 :     }
   11620                 :            :   }
   11621                 :            :   else
   11622                 :            :   {
   11623         [ +  - ]:        383 :     topology_list.reset();
   11624                 :            : 
   11625         [ +  - ]:        383 :     TopologyEntity* topo_ptr = topology_list.get_and_step();
   11626         [ -  + ]:        383 :     if (!topo_ptr)
   11627                 :          0 :       return (GeometryModifyEngine*)NULL;
   11628         [ +  - ]:        383 :     DLIList<TopologyBridge*> first_bridge_list;
   11629 [ +  - ][ +  - ]:        383 :     topo_ptr->bridge_manager()->get_bridge_list( first_bridge_list );
   11630                 :            : 
   11631         [ +  - ]:        383 :     first_bridge_list.reset();
   11632 [ +  - ][ +  - ]:        766 :     for( int i = first_bridge_list.size(); i > 0; i-- )
         [ +  - ][ +  - ]
   11633                 :            :     {
   11634         [ +  - ]:        383 :       TopologyBridge* bridge_ptr = first_bridge_list.get_and_step();
   11635         [ +  - ]:        383 :       engine_bridges.clean_out();
   11636         [ +  - ]:        383 :       engine_bridges.append( bridge_ptr );
   11637         [ +  - ]:        383 :       gme_ptr = get_engine(bridge_ptr);
   11638                 :            : 
   11639         [ -  + ]:        383 :       if( !gme_ptr )
   11640                 :          0 :       return (GeometryModifyEngine*)NULL;
   11641                 :            : 
   11642         [ +  - ]:        383 :       topology_list.reset();
   11643         [ +  - ]:        383 :       topology_list.step(); //skip first entry
   11644 [ +  - ][ +  + ]:        887 :       for( int j = topology_list.size(); j > 1; j-- )
   11645                 :            :       {
   11646         [ +  - ]:        504 :         topo_ptr = topology_list.get_and_step();
   11647 [ +  - ][ +  - ]:        504 :         bridge_ptr = topo_ptr->bridge_manager()->topology_bridge(gme_ptr->get_gqe());
                 [ +  - ]
   11648 [ +  - ][ +  - ]:        504 :         if( bridge_ptr ) engine_bridges.append( bridge_ptr );
   11649                 :          0 :         else break;
   11650                 :            :       }
   11651                 :            : 
   11652 [ +  - ][ +  - ]:        383 :       if( engine_bridges.size() == topology_list.size() )
                 [ +  - ]
   11653                 :        383 :         break;
   11654                 :            : 
   11655                 :          0 :       gme_ptr = 0;
   11656                 :        383 :     }
   11657                 :            :   }
   11658         [ -  + ]:        383 :   if( !gme_ptr )
   11659                 :            :   {
   11660                 :          0 :     engine_bridges.clean_out();
   11661 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Entities do not belong to the same geometry engine.\n");
   11662                 :            :   }
   11663                 :        383 :   return gme_ptr;
   11664                 :            : }
   11665                 :            : 
   11666                 :            : //-------------------------------------------------------------------------
   11667                 :            : // Purpose       : Find common modify engine for Bodies
   11668                 :            : //
   11669                 :            : // Special Notes :
   11670                 :            : //
   11671                 :            : // Creator       : Jason Kraftcheck
   11672                 :            : //
   11673                 :            : // Creation Date : 09/26/03
   11674                 :            : //-------------------------------------------------------------------------
   11675                 :            : GeometryModifyEngine*
   11676                 :        203 : GeometryModifyTool::common_modify_engine( DLIList<Body*>& input,
   11677                 :            :                                           DLIList<BodySM*>& output) const
   11678                 :            : {
   11679         [ +  - ]:        203 :   input.reset();
   11680         [ +  - ]:        203 :   Body* body_ptr = input.get();
   11681         [ +  - ]:        203 :   BodySM* body_sm_ptr = body_ptr->get_body_sm_ptr();
   11682         [ +  - ]:        203 :   GeometryModifyEngine* engine = get_engine(body_sm_ptr);
   11683                 :            : 
   11684 [ +  - ][ +  + ]:        468 :   for (int i = input.size(); i--; )
   11685                 :            :   {
   11686         [ +  - ]:        265 :     body_ptr = input.get_and_step();
   11687         [ +  - ]:        265 :     body_sm_ptr = body_ptr->get_body_sm_ptr();
   11688         [ +  - ]:        265 :     output.append(body_sm_ptr);
   11689                 :            : 
   11690         [ -  + ]:        265 :     if (!body_sm_ptr)
   11691                 :            :     {
   11692 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Body %d is invalid -- no attached BodySM.\n", body_ptr->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   11693         [ #  # ]:          0 :       output.clean_out();
   11694                 :          0 :       return 0;
   11695                 :            :     }
   11696                 :            : 
   11697 [ +  - ][ -  + ]:        265 :     if (get_engine(body_sm_ptr) != engine)
   11698                 :            :     {
   11699         [ #  # ]:          0 :       output.clean_out();
   11700                 :          0 :       return 0;
   11701                 :            :     }
   11702                 :            :   }
   11703                 :            : 
   11704                 :        203 :   return engine;
   11705                 :            : }
   11706                 :            : 
   11707                 :            : //-------------------------------------------------------------------------
   11708                 :            : // Purpose       : Get modify engine common to input RefFaces and RefEdges.
   11709                 :            : //
   11710                 :            : // Special Notes : Wrapper around the TopologyEntity/TopologyBridge form.
   11711                 :            : //
   11712                 :            : // Creator       : Jason Kraftcheck
   11713                 :            : //
   11714                 :            : // Creation Date : 09/26/03
   11715                 :            : //-------------------------------------------------------------------------
   11716                 :            : GeometryModifyEngine*
   11717                 :          0 : GeometryModifyTool::common_modify_engine( DLIList<RefFace*>& face_list,
   11718                 :            :                                           DLIList<RefEdge*>& edge_list,
   11719                 :            :                                           DLIList<Surface*>& surf_list,
   11720                 :            :                                           DLIList<Curve*>& curv_list,
   11721                 :            :                                           CubitBoolean allow_composites) const
   11722                 :            : {
   11723                 :            :   int i;
   11724 [ #  # ][ #  # ]:          0 :   const int count = face_list.size() + edge_list.size();
   11725         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
   11726 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(count);
   11727                 :            : 
   11728         [ #  # ]:          0 :   face_list.reset();
   11729         [ #  # ]:          0 :   edge_list.reset();
   11730 [ #  # ][ #  # ]:          0 :   for (i = face_list.size(); i--; )
   11731 [ #  # ][ #  # ]:          0 :     entity_list.append(face_list.get_and_step());
   11732 [ #  # ][ #  # ]:          0 :   for (i = edge_list.size(); i--; )
   11733 [ #  # ][ #  # ]:          0 :     entity_list.append(edge_list.get_and_step());
   11734                 :            : 
   11735         [ #  # ]:          0 :   GeometryModifyEngine* engine = common_modify_engine(entity_list, bridge_list, allow_composites);
   11736         [ #  # ]:          0 :   if (!engine)
   11737                 :          0 :     return 0;
   11738                 :            : 
   11739         [ #  # ]:          0 :   entity_list.reset();
   11740 [ #  # ][ #  # ]:          0 :   CAST_LIST(bridge_list, surf_list, Surface);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   11741 [ #  # ][ #  # ]:          0 :   CAST_LIST(bridge_list, curv_list, Curve  );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   11742         [ #  # ]:          0 :   if(allow_composites)
   11743                 :            :   {
   11744 [ #  # ][ #  # ]:          0 :     if(surf_list.size() >= face_list.size() && curv_list.size() >= edge_list.size())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   11745                 :          0 :       return engine;
   11746                 :            :     else
   11747                 :          0 :       return 0;
   11748                 :            :   }
   11749                 :            :   else
   11750                 :            :   {
   11751 [ #  # ][ #  # ]:          0 :     if (surf_list.size() != face_list.size() || curv_list.size() != edge_list.size())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   11752                 :          0 :       return 0;
   11753                 :            :     else
   11754                 :          0 :       return engine;
   11755         [ #  # ]:          0 :   }
   11756                 :            : }
   11757                 :            : 
   11758                 :            : //-------------------------------------------------------------------------
   11759                 :            : // Purpose       : Get modify engine common to input RefFaces.
   11760                 :            : //
   11761                 :            : // Special Notes : Wrapper around the TopologyEntity/TopologyBridge form.
   11762                 :            : //
   11763                 :            : // Creator       : Jason Kraftcheck
   11764                 :            : //
   11765                 :            : // Creation Date : 11/05/03
   11766                 :            : //-------------------------------------------------------------------------
   11767                 :            : GeometryModifyEngine*
   11768                 :         11 : GeometryModifyTool::common_modify_engine( DLIList<RefFace*>& face_list,
   11769                 :            :                                           DLIList<Surface*>& surf_list,
   11770                 :            :                                           CubitBoolean allow_composites) const
   11771                 :            : {
   11772         [ +  - ]:         11 :   const int size = face_list.size();
   11773         [ +  - ]:         11 :   DLIList<TopologyEntity*> topo_list(size);
   11774 [ +  - ][ +  - ]:         22 :   DLIList<TopologyBridge*> geom_list(size);
   11775                 :            :   GeometryModifyEngine* result;
   11776                 :            : 
   11777 [ +  - ][ +  - ]:         33 :   CAST_LIST_TO_PARENT( face_list, topo_list );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
   11778         [ +  - ]:         11 :   result = common_modify_engine( topo_list, geom_list, allow_composites );
   11779                 :            : 
   11780 [ +  - ][ +  - ]:         33 :   CAST_LIST( geom_list, surf_list, Surface );
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
   11781         [ +  - ]:         11 :   return result;
   11782                 :            : }
   11783                 :            : 
   11784                 :            : //-------------------------------------------------------------------------
   11785                 :            : // Purpose       : Get modify engine common to input RefEdges.
   11786                 :            : //
   11787                 :            : // Special Notes : Wrapper around the TopologyEntity/TopologyBridge form.
   11788                 :            : //
   11789                 :            : // Creator       : Steve Storm
   11790                 :            : //
   11791                 :            : // Creation Date : 03/09/05
   11792                 :            : //-------------------------------------------------------------------------
   11793                 :          0 : GeometryModifyEngine* GeometryModifyTool::common_modify_engine(
   11794                 :            :                                       DLIList<RefEdge*>& edge_list,
   11795                 :            :                                       DLIList<Curve*>& curve_list,
   11796                 :            :                                       CubitBoolean allow_composites) const
   11797                 :            : {
   11798         [ #  # ]:          0 :   const int size = edge_list.size();
   11799         [ #  # ]:          0 :   DLIList<TopologyEntity*> topo_list(size);
   11800 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> geom_list(size);
   11801                 :            :   GeometryModifyEngine* result;
   11802                 :            : 
   11803 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( edge_list, topo_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   11804         [ #  # ]:          0 :   result = common_modify_engine( topo_list, geom_list, allow_composites );
   11805                 :            : 
   11806 [ #  # ][ #  # ]:          0 :   CAST_LIST( geom_list, curve_list, Curve );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   11807         [ #  # ]:          0 :   return result;
   11808                 :            : }
   11809                 :            : 
   11810                 :            : //-------------------------------------------------------------------------
   11811                 :            : // Purpose       : Get modify engine common to input RefVertices.
   11812                 :            : //
   11813                 :            : // Special Notes : Wrapper around the TopologyEntity/TopologyBridge form.
   11814                 :            : //
   11815                 :            : // Creator       : Steve Storm
   11816                 :            : //
   11817                 :            : // Creation Date : 03/25/05
   11818                 :            : //-------------------------------------------------------------------------
   11819                 :            : GeometryModifyEngine*
   11820                 :          0 : GeometryModifyTool::common_modify_engine( DLIList<RefVertex*>& vertex_list,
   11821                 :            :                                           DLIList<TBPoint*>& point_list,
   11822                 :            :                                           CubitBoolean allow_composites) const
   11823                 :            : {
   11824         [ #  # ]:          0 :   const int size = vertex_list.size();
   11825         [ #  # ]:          0 :   DLIList<TopologyEntity*> topo_list(size);
   11826 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> geom_list(size);
   11827                 :            :   GeometryModifyEngine* result;
   11828                 :            : 
   11829 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( vertex_list, topo_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   11830         [ #  # ]:          0 :   result = common_modify_engine( topo_list, geom_list, allow_composites );
   11831                 :            : 
   11832 [ #  # ][ #  # ]:          0 :   CAST_LIST( geom_list, point_list, TBPoint );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   11833         [ #  # ]:          0 :   return result;
   11834                 :            : }
   11835                 :            : 
   11836                 :            : //-------------------------------------------------------------------------
   11837                 :            : // Purpose       : Pull RefFaces with a common GeometryModifyEngine out of
   11838                 :            : //                 the input ref_face_list.  Place their surfaces in the
   11839                 :            : //                 output surf_list, and return the common modify engine.
   11840                 :            : //
   11841                 :            : // Special Notes : the function returns a NULL pointer if a RefFace without
   11842                 :            : //                 a modify engine is found in the input list.
   11843                 :            : //
   11844                 :            : // Creator       : Steve Storm
   11845                 :            : //
   11846                 :            : // Creation Date : 03/02/08
   11847                 :            : //-------------------------------------------------------------------------
   11848                 :            : GeometryModifyEngine*
   11849                 :          0 : GeometryModifyTool::pull_common_surfs( DLIList<RefFace*> &ref_face_list,
   11850                 :            :                                        DLIList<RefFace*> &common_face_list,
   11851                 :            :                                        DLIList<Surface*> &common_surf_list )
   11852                 :            : {
   11853                 :            :   int i;
   11854                 :            :   RefFace *ref_face_ptr;
   11855                 :            :   Surface *surf_ptr;
   11856                 :            : 
   11857                 :          0 :   GeometryModifyEngine *gme1 = 0, *gme2 = 0;
   11858                 :            : 
   11859         [ #  # ]:          0 :   ref_face_list.reset();
   11860 [ #  # ][ #  # ]:          0 :   for( i=0; i<ref_face_list.size(); i++ )
   11861                 :            :   {
   11862         [ #  # ]:          0 :     ref_face_ptr = ref_face_list.get();
   11863         [ #  # ]:          0 :     surf_ptr = ref_face_ptr->get_surface_ptr();
   11864                 :            : 
   11865         [ #  # ]:          0 :     if( i==0 )
   11866                 :            :     {
   11867         [ #  # ]:          0 :       common_face_list.append( ref_face_ptr );
   11868         [ #  # ]:          0 :       common_surf_list.append( surf_ptr );
   11869         [ #  # ]:          0 :       gme1 = get_engine( surf_ptr );
   11870         [ #  # ]:          0 :       if (!gme1)
   11871                 :            :       {
   11872 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Surface %d does not have a modify engine.\n", ref_face_ptr->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   11873                 :          0 :         return 0;
   11874                 :            :       }
   11875         [ #  # ]:          0 :       ref_face_list.change_to( NULL );
   11876         [ #  # ]:          0 :       ref_face_list.step();
   11877                 :          0 :       continue;
   11878                 :            :     }
   11879                 :            : 
   11880         [ #  # ]:          0 :     gme2 = get_engine( surf_ptr );
   11881         [ #  # ]:          0 :     if (!gme2)
   11882                 :            :     {
   11883 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Surface %d does not have a modify engine.\n", ref_face_ptr->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   11884                 :          0 :       return 0;
   11885                 :            :     }
   11886                 :            : 
   11887         [ #  # ]:          0 :     if( gme2 == gme1 )
   11888                 :            :     {
   11889         [ #  # ]:          0 :       common_face_list.append( ref_face_ptr );
   11890         [ #  # ]:          0 :       common_surf_list.append( surf_ptr );
   11891         [ #  # ]:          0 :       ref_face_list.change_to( NULL );
   11892                 :            :     }
   11893                 :            : 
   11894         [ #  # ]:          0 :     ref_face_list.step();
   11895                 :            :   }
   11896                 :            : 
   11897         [ #  # ]:          0 :   ref_face_list.remove_all_with_value( NULL );
   11898                 :            : 
   11899                 :          0 :   return gme1;
   11900                 :            : }
   11901                 :            : 
   11902                 :            : // Separates the list of bodies so that there is one body per volume
   11903                 :            : // after a webcut.  Checks the sepAfterWebcut flag.
   11904                 :         22 : CubitStatus GeometryModifyTool::separate_body_after_webcut( DLIList<Body*> &input_list,
   11905                 :            :                                               DLIList<Body*> &output_list) const
   11906                 :            : {
   11907                 :            :     //First see if we should spearate.
   11908         [ -  + ]:         22 :   if ( !sepAfterWebcut )
   11909                 :            :   {
   11910         [ #  # ]:          0 :     output_list = input_list;
   11911                 :          0 :     return CUBIT_SUCCESS;
   11912                 :            :   }
   11913         [ +  - ]:         22 :   DLIList<Body*> temp_body_list;
   11914 [ +  - ][ +  + ]:         66 :   for ( int ii = input_list.size(); ii > 0; ii-- )
   11915                 :            :   {
   11916         [ +  - ]:         44 :     Body *body_ptr = input_list.get_and_step();
   11917         [ +  - ]:         44 :     temp_body_list.clean_out();
   11918                 :            : 
   11919         [ +  - ]:         44 :     bool undo_setting = CubitUndo::get_undo_enabled();
   11920         [ -  + ]:         44 :     if( undo_setting == true )
   11921         [ #  # ]:          0 :       CubitUndo::set_undo_enabled( false );
   11922                 :            : 
   11923         [ +  - ]:         44 :     split_body(body_ptr, temp_body_list);
   11924                 :            : 
   11925         [ -  + ]:         44 :     if( undo_setting == true )
   11926         [ #  # ]:          0 :       CubitUndo::set_undo_enabled( true );
   11927                 :            : 
   11928         [ +  - ]:         44 :     output_list += temp_body_list;
   11929                 :            :   }
   11930         [ +  - ]:         22 :   return CUBIT_SUCCESS;
   11931                 :            : }
   11932                 :            : 
   11933                 :       1637 : GeometryModifyEngine *GeometryModifyTool::get_engine(TopologyBridge *tb_ptr) const
   11934                 :            : {
   11935                 :            :   int i;
   11936                 :            :   GeometryModifyEngine *gme;
   11937         [ +  - ]:       1637 :   for (i = 0; i < gmeList.size(); i++) {
   11938                 :       1637 :     gme = gmeList.next(i);
   11939         [ +  - ]:       1637 :     if (gme->is_modify_engine(tb_ptr)) return gme;
   11940                 :            :   }
   11941                 :          0 :   return NULL;
   11942                 :            : }
   11943                 :            : 
   11944                 :        314 : GeometryModifyEngine *GeometryModifyTool::get_engine(TopologyEntity *te_ptr,
   11945                 :            :                                                      TopologyBridge **bridge) const
   11946                 :            : {
   11947                 :            :   int i;
   11948                 :        314 :   GeometryModifyEngine *gme = 0;
   11949                 :        314 :   TopologyBridge* tb_ptr = NULL;
   11950         [ +  - ]:        314 :   BridgeManager* bm = te_ptr->bridge_manager();
   11951 [ +  - ][ +  - ]:        314 :   DLIList<TopologyBridge*> bridges(bm->number_of_bridges());
   11952         [ +  - ]:        314 :   bm->get_bridge_list(bridges);
   11953         [ +  - ]:        314 :   bridges.reset();
   11954 [ +  - ][ +  + ]:        628 :   for (i = bridges.size(); !gme && i--; )
         [ +  - ][ +  + ]
   11955                 :            :   {
   11956         [ +  - ]:        314 :     tb_ptr = bridges.get_and_step();
   11957         [ +  - ]:        314 :     gme = get_engine(tb_ptr);
   11958                 :            :   }
   11959                 :            : 
   11960 [ +  + ][ +  - ]:        314 :   if (bridge && gme)
   11961                 :         44 :     *bridge = tb_ptr;
   11962                 :            : 
   11963         [ +  - ]:        314 :   return gme;
   11964                 :            : }
   11965                 :            : 
   11966                 :          0 : CubitStatus GeometryModifyTool::get_offset_intersections( RefEdge* ref_edge1, RefEdge* ref_edge2,
   11967                 :            :                                                           DLIList<CubitVector>& intersection_list,
   11968                 :            :                                                           double offset, CubitBoolean ext_first )
   11969                 :            : {
   11970         [ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(2);
   11971 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(2);
   11972         [ #  # ]:          0 :   entity_list.append(ref_edge1);
   11973         [ #  # ]:          0 :   entity_list.append(ref_edge2);
   11974         [ #  # ]:          0 :   GeometryModifyEngine* gme_ptr1 = common_modify_engine(entity_list,bridge_list);
   11975                 :            : 
   11976         [ #  # ]:          0 :   if( gme_ptr1 == 0 )
   11977                 :            :   {
   11978 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Curves %d and %d do not have the same underlying geometry modeling engine\n"
         [ #  # ][ #  # ]
                 [ #  # ]
   11979                 :            :                    "      For intersection calculations, they must be the same\n",
   11980         [ #  # ]:          0 :          ref_edge1->id(), ref_edge2->id() );
   11981                 :          0 :       return CUBIT_FAILURE;
   11982                 :            :    }
   11983                 :            : 
   11984         [ #  # ]:          0 :    bridge_list.reset();
   11985 [ #  # ][ #  # ]:          0 :    Curve* curve0 = dynamic_cast<Curve*>(bridge_list.next(0));
   11986 [ #  # ][ #  # ]:          0 :    Curve* curve1 = dynamic_cast<Curve*>(bridge_list.next(1));
   11987                 :            : 
   11988                 :            :    return gme_ptr1->get_offset_intersections( curve0, curve1, intersection_list,
   11989 [ #  # ][ #  # ]:          0 :                                               offset, ext_first );
   11990                 :            : }
   11991                 :            : 
   11992                 :          0 : CubitStatus GeometryModifyTool::get_offset_intersections(RefEdge* ref_edge_ptr,
   11993                 :            :                                                           RefFace* ref_face_ptr,
   11994                 :            :                                                           DLIList<CubitVector> &intersection_list,
   11995                 :            :                                                           double offset,
   11996                 :            :                                                           CubitBoolean ext_surf )
   11997                 :            : {
   11998                 :            :   // If curve is straight and surface is planar, compute their intersection;
   11999                 :            :   // otherwise use the geometry engine to do it.
   12000                 :            : 
   12001         [ #  # ]:          0 :   Curve* curve_ptr = ref_edge_ptr->get_curve_ptr();
   12002         [ #  # ]:          0 :   Surface* surface_ptr = ref_face_ptr->get_surface_ptr();
   12003                 :            : 
   12004         [ #  # ]:          0 :   if( curve_ptr == NULL )
   12005                 :            :   {
   12006 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Unable to retrieve underlying geometric entity of Curve %d\n"
         [ #  # ][ #  # ]
   12007         [ #  # ]:          0 :       "       This is a bug - please report it\n", ref_edge_ptr->id() );
   12008                 :          0 :     return CUBIT_FAILURE;
   12009                 :            :   }
   12010                 :            : 
   12011         [ #  # ]:          0 :   if( surface_ptr == NULL )
   12012                 :            :   {
   12013 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Unable to retrieve underlying geometric entity of Surface %d\n"
         [ #  # ][ #  # ]
   12014         [ #  # ]:          0 :       "       This is a bug - please report it\n", ref_face_ptr->id() );
   12015                 :          0 :     return CUBIT_FAILURE;
   12016                 :            :   }
   12017                 :            : 
   12018                 :            :   // If straight line and plane, find location right here analytically.
   12019 [ #  # ][ #  # ]:          0 :   CubitVector pln_origin, pln_normal;
   12020 [ #  # ][ #  # ]:          0 :   CubitVector crv_origin, crv_direction;
   12021 [ #  # ][ #  # ]:          0 :   if( ref_face_ptr->get_point_normal( pln_origin, pln_normal ) &&
         [ #  # ][ #  # ]
   12022         [ #  # ]:          0 :      ref_edge_ptr->get_point_direction( crv_origin, crv_direction ) )
   12023                 :            :   {
   12024                 :            :      double pln_orig[3], pln_norm[3];
   12025 [ #  # ][ #  # ]:          0 :      pln_orig[0]=pln_origin.x(); pln_orig[1]=pln_origin.y(); pln_orig[2]=pln_origin.z();
                 [ #  # ]
   12026 [ #  # ][ #  # ]:          0 :      pln_norm[0]=pln_normal.x(); pln_norm[1]=pln_normal.y(); pln_norm[2]=pln_normal.z();
                 [ #  # ]
   12027                 :            : 
   12028                 :            :      double crv_orig[3], crv_dir[3];
   12029 [ #  # ][ #  # ]:          0 :      crv_orig[0]=crv_origin.x(); crv_orig[1]=crv_origin.y(); crv_orig[2]=crv_origin.z();
                 [ #  # ]
   12030 [ #  # ][ #  # ]:          0 :      crv_dir[0]=crv_direction.x(); crv_dir[1]=crv_direction.y(); crv_dir[2]=crv_direction.z();
                 [ #  # ]
   12031                 :            : 
   12032         [ #  # ]:          0 :      AnalyticGeometryTool *agt = AnalyticGeometryTool::instance();
   12033                 :            : 
   12034 [ #  # ][ #  # ]:          0 :      if( agt->is_vec_perp( pln_norm, crv_dir ) )
   12035                 :            :      {
   12036 [ #  # ][ #  # ]:          0 :         PRINT_ERROR( "Line is parallel to the plane - intersection not possible\n" );
         [ #  # ][ #  # ]
   12037                 :          0 :         return CUBIT_FAILURE;
   12038                 :            :      }
   12039                 :            : 
   12040         [ #  # ]:          0 :      double ang = agt->angle_vec_vec( pln_norm, crv_dir );
   12041         [ #  # ]:          0 :      if( ang > AGT_PI_DIV_2 )
   12042                 :          0 :         ang = AGT_PI - ang;
   12043                 :            : 
   12044                 :            :      double int_pnt[3];
   12045         [ #  # ]:          0 :      agt->int_ln_pln( crv_orig, crv_dir, pln_orig, pln_norm, int_pnt );
   12046                 :            : 
   12047                 :            :      // ang2 is angle between line and plane
   12048                 :          0 :      double ang2 = AGT_PI_DIV_2 - ang;
   12049                 :            : 
   12050                 :          0 :      double hypotenuse = offset/sin(ang2);
   12051                 :            : 
   12052                 :            :      double final_pnt[3];
   12053                 :            : 
   12054         [ #  # ]:          0 :      agt->next_pnt( int_pnt, crv_dir, hypotenuse, final_pnt );
   12055                 :            : 
   12056                 :            :      double end1[3], end2[3];
   12057 [ #  # ][ #  # ]:          0 :      CubitVector start, end;
   12058 [ #  # ][ #  # ]:          0 :      start = ref_edge_ptr->start_coordinates();
   12059 [ #  # ][ #  # ]:          0 :      end = ref_edge_ptr->end_coordinates();
   12060 [ #  # ][ #  # ]:          0 :      end1[0]=start.x(); end1[1]=start.y(); end1[2]=start.z();
                 [ #  # ]
   12061 [ #  # ][ #  # ]:          0 :      end2[0]=end.x(); end2[1]=end.y(); end2[2]=end.z();
                 [ #  # ]
   12062                 :            : 
   12063         [ #  # ]:          0 :      CubitVector curve_position;
   12064 [ #  # ][ #  # ]:          0 :      if( agt->is_pnt_on_ln_seg( final_pnt, end1, end2 ) )
   12065                 :            :      {
   12066         [ #  # ]:          0 :         curve_position.x( final_pnt[0] );
   12067         [ #  # ]:          0 :         curve_position.y( final_pnt[1] );
   12068         [ #  # ]:          0 :         curve_position.z( final_pnt[2] );
   12069                 :            :      }
   12070                 :            :      else
   12071                 :            :      {
   12072         [ #  # ]:          0 :         agt->reverse_vec( crv_dir, crv_dir );
   12073                 :            : 
   12074         [ #  # ]:          0 :         agt->next_pnt( int_pnt, crv_dir, hypotenuse, final_pnt );
   12075                 :            : 
   12076 [ #  # ][ #  # ]:          0 :         if( agt->is_pnt_on_ln_seg( final_pnt, end1, end2 ) )
   12077                 :            :         {
   12078         [ #  # ]:          0 :            curve_position.x( final_pnt[0] );
   12079         [ #  # ]:          0 :            curve_position.y( final_pnt[1] );
   12080         [ #  # ]:          0 :            curve_position.z( final_pnt[2] );
   12081                 :            :         }
   12082                 :            :         else
   12083                 :            :         {
   12084 [ #  # ][ #  # ]:          0 :            PRINT_ERROR( "Resultant point does not lie on bounded curve\n" );
         [ #  # ][ #  # ]
   12085                 :          0 :            return CUBIT_FAILURE;
   12086                 :            :         }
   12087                 :            :      }
   12088         [ #  # ]:          0 :      intersection_list.append( curve_position );
   12089                 :            :   }
   12090                 :            :   else
   12091                 :            :   {
   12092         [ #  # ]:          0 :      DLIList<TopologyEntity*> entity_list(2);
   12093 [ #  # ][ #  # ]:          0 :      DLIList<TopologyBridge*> bridge_list(2);
   12094         [ #  # ]:          0 :      entity_list.append(ref_edge_ptr);
   12095         [ #  # ]:          0 :      entity_list.append(ref_face_ptr);
   12096         [ #  # ]:          0 :      GeometryModifyEngine* gme_ptr1 = common_modify_engine(entity_list,bridge_list);
   12097                 :            : 
   12098         [ #  # ]:          0 :      if( gme_ptr1 == 0 )
   12099                 :            :      {
   12100 [ #  # ][ #  # ]:          0 :         PRINT_ERROR( "Curve %d and Surface %d do not have the same underlying geometry modeling engine\n"
         [ #  # ][ #  # ]
                 [ #  # ]
   12101                 :            :            "       For intersection calculations, they must be the same\n",
   12102         [ #  # ]:          0 :            ref_edge_ptr->id(), ref_face_ptr->id() );
   12103                 :          0 :         return CUBIT_FAILURE;
   12104                 :            :      }
   12105                 :            : 
   12106         [ #  # ]:          0 :      bridge_list.reset();
   12107 [ #  # ][ #  # ]:          0 :      curve_ptr = dynamic_cast<Curve*>(bridge_list.next(0));
   12108 [ #  # ][ #  # ]:          0 :      surface_ptr = dynamic_cast<Surface*>(bridge_list.next(1));
   12109                 :            : 
   12110                 :            :      // Use geometry engine to find intersections
   12111                 :            :      return gme_ptr1->get_offset_intersections( curve_ptr, surface_ptr,
   12112 [ #  # ][ #  # ]:          0 :                                                 intersection_list, offset, ext_surf );
   12113                 :            : 
   12114                 :            :   }
   12115                 :            : 
   12116                 :          0 :   return CUBIT_FAILURE;
   12117                 :            : }
   12118                 :            : 
   12119                 :          0 : CubitStatus GeometryModifyTool::get_mid_plane( RefFace *ref_face1,
   12120                 :            :                                                RefFace *ref_face2,
   12121                 :            :                                                Body *body_to_trim_to,
   12122                 :            :                                                DLIList<RefFace*> &mid_plane_surfs ) const
   12123                 :            : {
   12124         [ #  # ]:          0 :   if( ref_face1 == ref_face2 )
   12125                 :            :   {
   12126 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot create midplane between the same surface.\n"
         [ #  # ][ #  # ]
   12127         [ #  # ]:          0 :                 "       Surface %d was entered twice\n",  ref_face1->id() );
   12128                 :          0 :     return CUBIT_FAILURE;
   12129                 :            :   }
   12130                 :            : 
   12131         [ #  # ]:          0 :   BodySM* body_sm_to_trim_to = body_to_trim_to->get_body_sm_ptr();
   12132         [ #  # ]:          0 :   GeometryModifyEngine *gme1_ptr = get_engine(body_sm_to_trim_to);
   12133         [ #  # ]:          0 :   if ( !gme1_ptr )
   12134                 :            :   {
   12135 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Geometry can't be modified, no associated modify engine.\n");
         [ #  # ][ #  # ]
   12136                 :          0 :     return CUBIT_FAILURE;
   12137                 :            :   }
   12138                 :            : 
   12139 [ #  # ][ #  # ]:          0 :   CubitVector normal_1, normal_2, point_1, point_2, point_3;
         [ #  # ][ #  # ]
                 [ #  # ]
   12140 [ #  # ][ #  # ]:          0 :   CubitPlane plane_1, plane_2;
   12141 [ #  # ][ #  # ]:          0 :   CubitVector p_mid, n_mid;
   12142                 :            : 
   12143 [ #  # ][ #  # ]:          0 :   point_1 = ref_face1->center_point();
   12144 [ #  # ][ #  # ]:          0 :   point_2 = ref_face2->center_point();
   12145                 :            : 
   12146 [ #  # ][ #  # ]:          0 :   normal_1 = ref_face1->normal_at(point_1);
   12147 [ #  # ][ #  # ]:          0 :   normal_2 = ref_face2->normal_at(point_2);
   12148                 :            : 
   12149 [ #  # ][ #  # ]:          0 :   plane_1 = CubitPlane(normal_1,point_1);
   12150 [ #  # ][ #  # ]:          0 :   plane_2 = CubitPlane(normal_2,point_2);
   12151                 :            : 
   12152 [ #  # ][ #  # ]:          0 :   if(point_1 == point_2)
   12153                 :            :   {
   12154 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Since both surfaces share the same point, the midplane is not well-defined\n");
         [ #  # ][ #  # ]
   12155                 :          0 :     return CUBIT_FAILURE;
   12156                 :            :   }
   12157                 :            :   else
   12158                 :            :   {
   12159         [ #  # ]:          0 :     CubitVector temp1 = point_2;
   12160 [ #  # ][ #  # ]:          0 :     temp1 = plane_1.project(temp1);
   12161         [ #  # ]:          0 :     temp1 -= point_2;
   12162 [ #  # ][ #  # ]:          0 :     if ( temp1.length_squared() < GEOMETRY_RESABS*GEOMETRY_RESABS )
   12163                 :            :     {
   12164 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Since both planes are the same, the mid-plane is not well-defined.\n");
         [ #  # ][ #  # ]
   12165                 :          0 :       return CUBIT_FAILURE;
   12166                 :            :     }
   12167                 :            :   }
   12168                 :            : 
   12169 [ #  # ][ #  # ]:          0 :   if(plane_1.normal()==plane_2.normal() || plane_1.normal()==-plane_2.normal())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
   12170                 :            :   {
   12171 [ #  # ][ #  # ]:          0 :     p_mid = (point_1+point_2)/2;
                 [ #  # ]
   12172 [ #  # ][ #  # ]:          0 :     n_mid = plane_1.normal();
   12173                 :            :   }
   12174                 :            :   else
   12175                 :            :   {
   12176                 :            : 
   12177         [ #  # ]:          0 :     CubitVector direction_of_line;
   12178         [ #  # ]:          0 :     plane_1.intersect(plane_2,p_mid,direction_of_line);
   12179         [ #  # ]:          0 :     direction_of_line.normalize();
   12180                 :            : 
   12181                 :            :     // Find if point_1 and point_2 are on the line of intersection
   12182                 :            :     // If they are, then the mid-plane is not well-defined
   12183         [ #  # ]:          0 :     CubitVector p1 = point_1-p_mid;
   12184         [ #  # ]:          0 :     CubitVector p2 = point_2-p_mid;
   12185         [ #  # ]:          0 :     p1.normalize();
   12186         [ #  # ]:          0 :     p2.normalize();
   12187                 :            : 
   12188 [ #  # ][ #  # ]:          0 :     if(p1==direction_of_line || p1==-direction_of_line)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
   12189                 :            :     {
   12190 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("P1 is on the line of intersection.\n");
         [ #  # ][ #  # ]
   12191                 :          0 :       return CUBIT_FAILURE;
   12192                 :            :     }
   12193                 :            : 
   12194 [ #  # ][ #  # ]:          0 :     if(p2==direction_of_line || p2==-direction_of_line)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
   12195                 :            :     {
   12196 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("P2 is on the line of intersection.\n");
         [ #  # ][ #  # ]
   12197                 :          0 :       return CUBIT_FAILURE;
   12198                 :            :     }
   12199                 :            : 
   12200 [ #  # ][ #  # ]:          0 :     CubitVector v1 = p1 - (p1%direction_of_line)*direction_of_line;
                 [ #  # ]
   12201         [ #  # ]:          0 :     v1.normalize();
   12202                 :            : 
   12203 [ #  # ][ #  # ]:          0 :     CubitVector v2 = p2 - (p2%direction_of_line)*direction_of_line;
                 [ #  # ]
   12204         [ #  # ]:          0 :     v2.normalize();
   12205                 :            : 
   12206 [ #  # ][ #  # ]:          0 :     n_mid = v1 - v2;
   12207         [ #  # ]:          0 :     n_mid.normalize();
   12208                 :            :   }
   12209                 :            : 
   12210         [ #  # ]:          0 :   CubitPlane mid_plane(n_mid, p_mid);
   12211         [ #  # ]:          0 :   point_1 = p_mid;
   12212                 :            :     //find three points that will define the infinite plane from the
   12213                 :            :     //mid plane.
   12214 [ #  # ][ #  # ]:          0 :   CubitVector test1(1,0,0), test1n(-1,0,0),test2(0,1,0);
                 [ #  # ]
   12215         [ #  # ]:          0 :   CubitVector direction1;
   12216                 :            :     //through the point in any direction just not along the
   12217                 :            :     //normal direction.
   12218 [ #  # ][ #  # ]:          0 :   if(n_mid != test1 && n_mid != test1n )
         [ #  # ][ #  # ]
                 [ #  # ]
   12219 [ #  # ][ #  # ]:          0 :     direction1 = test1 + n_mid;
   12220                 :            :   else
   12221 [ #  # ][ #  # ]:          0 :     direction1 = test2 + n_mid;
   12222                 :            : 
   12223 [ #  # ][ #  # ]:          0 :   point_2 = p_mid + direction1;
   12224 [ #  # ][ #  # ]:          0 :   point_2 = mid_plane.project(point_2);
   12225                 :            : 
   12226 [ #  # ][ #  # ]:          0 :   direction1 = point_2-point_1;
   12227         [ #  # ]:          0 :   CubitVector direction2 = direction1*n_mid;
   12228 [ #  # ][ #  # ]:          0 :   point_3 = point_1 + direction2;
   12229                 :            : 
   12230                 :          0 :   BodySM* midplane_body_sm = NULL;
   12231                 :            :   CubitStatus ret = gme1_ptr->get_mid_plane(point_1, point_2, point_3,
   12232         [ #  # ]:          0 :                                             body_sm_to_trim_to, midplane_body_sm );
   12233                 :            : 
   12234         [ #  # ]:          0 :   if (midplane_body_sm)
   12235                 :            :   {
   12236                 :            :     Body *midplane_body;
   12237                 :            : 
   12238 [ #  # ][ #  # ]:          0 :     midplane_body = GeometryQueryTool::instance()->make_Body(midplane_body_sm);
   12239                 :            : 
   12240         [ #  # ]:          0 :     DLIList<RefFace*> ref_faces;
   12241         [ #  # ]:          0 :     midplane_body->ref_faces( ref_faces );
   12242                 :            : 
   12243                 :            :     //make each surface of the body into its own body
   12244                 :            :     int i;
   12245 [ #  # ][ #  # ]:          0 :     for( i=0; i<ref_faces.size(); i++ )
   12246                 :            :     {
   12247                 :            :       RefEntity *new_entity_ptr;
   12248 [ #  # ][ #  # ]:          0 :       new_entity_ptr = GeometryModifyTool::instance()->copy_refentity(ref_faces.get_and_step());
         [ #  # ][ #  # ]
   12249         [ #  # ]:          0 :       RefFace *ref_face_ptr = CAST_TO(new_entity_ptr, RefFace);
   12250         [ #  # ]:          0 :       mid_plane_surfs.append( ref_face_ptr );
   12251                 :            :     }
   12252 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->delete_Body( midplane_body );
                 [ #  # ]
   12253                 :            :   }
   12254                 :            :   else
   12255                 :          0 :     return CUBIT_FAILURE;
   12256                 :            : 
   12257                 :          0 :   return ret;
   12258                 :            : }
   12259                 :            : 
   12260                 :            : //=============================================================================
   12261                 :            : // Function   : get_planar_mid_surface
   12262                 :            : // Member Type: LOCAL
   12263                 :            : // Description: Calculates a mid-surface between 2 planar surfaces.
   12264                 :            : // Author     : Philippe Pebay
   12265                 :            : // Date       : 05/15/06
   12266                 :            : //=============================================================================
   12267                 :          0 : CubitStatus get_planar_mid_surface( RefFace* ref_face1,
   12268                 :            :                                     RefFace* ref_face2,
   12269                 :            :                                     BodySM* body_sm_to_trim_to,
   12270                 :            :                                     BodySM*& midsurface_body_sm,
   12271                 :            :                                     GeometryModifyEngine *gme_ptr )
   12272                 :            : {
   12273 [ #  # ][ #  # ]:          0 :     CubitVector normal_1, normal_2, point_1, point_2, point_3;
         [ #  # ][ #  # ]
                 [ #  # ]
   12274 [ #  # ][ #  # ]:          0 :     CubitPlane plane_1, plane_2;
   12275 [ #  # ][ #  # ]:          0 :     CubitVector p_mid, n_mid;
   12276                 :            : 
   12277 [ #  # ][ #  # ]:          0 :     point_1 = ref_face1->center_point();
   12278 [ #  # ][ #  # ]:          0 :     point_2 = ref_face2->center_point();
   12279                 :            : 
   12280 [ #  # ][ #  # ]:          0 :     normal_1 = ref_face1->normal_at(point_1);
   12281 [ #  # ][ #  # ]:          0 :     normal_2 = ref_face2->normal_at(point_2);
   12282                 :            : 
   12283 [ #  # ][ #  # ]:          0 :     plane_1 = CubitPlane(normal_1,point_1);
   12284 [ #  # ][ #  # ]:          0 :     plane_2 = CubitPlane(normal_2,point_2);
   12285                 :            : 
   12286 [ #  # ][ #  # ]:          0 :     if(point_1 == point_2)
   12287                 :            :     {
   12288 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "In GeometryModifyTool:: get_planar_mid_surface\n"
                 [ #  # ]
   12289         [ #  # ]:          0 :                    "       Since both surfaces share the same point, the midsurface is not well-defined\n");
   12290                 :          0 :       return CUBIT_FAILURE;
   12291                 :            :     }
   12292                 :            :     else
   12293                 :            :     {
   12294         [ #  # ]:          0 :       CubitVector temp1 = point_2;
   12295 [ #  # ][ #  # ]:          0 :       temp1 = plane_1.project(temp1);
   12296         [ #  # ]:          0 :       temp1 -= point_2;
   12297 [ #  # ][ #  # ]:          0 :       if ( temp1.length_squared() < GEOMETRY_RESABS*GEOMETRY_RESABS )
   12298                 :            :         {
   12299 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("In GeometryModifyTool:: get_planar_mid_surface\n"
                 [ #  # ]
   12300         [ #  # ]:          0 :                     "       Since both planes are the same, the midsurface is not well-defined.\n");
   12301                 :          0 :         return CUBIT_FAILURE;
   12302                 :            :         }
   12303                 :            :     }
   12304                 :            : 
   12305 [ #  # ][ #  # ]:          0 :     if ( ( normal_1.about_equal( normal_2 ) ) || ( (-normal_1).about_equal( normal_2 ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
   12306                 :            :     {
   12307 [ #  # ][ #  # ]:          0 :       p_mid = (point_1+point_2)/2;
                 [ #  # ]
   12308 [ #  # ][ #  # ]:          0 :       n_mid = plane_1.normal();
   12309                 :            :     }
   12310                 :            :     else
   12311                 :            :     {
   12312         [ #  # ]:          0 :       CubitVector direction_of_line;
   12313         [ #  # ]:          0 :       plane_1.intersect(plane_2,p_mid,direction_of_line);
   12314         [ #  # ]:          0 :       direction_of_line.normalize();
   12315                 :            : 
   12316                 :            :       // Find if point_1 and point_2 are on the line of intersection
   12317                 :            :       // If they are, then the mid-plane is not well-defined
   12318         [ #  # ]:          0 :       CubitVector p1 = point_1-p_mid;
   12319         [ #  # ]:          0 :       CubitVector p2 = point_2-p_mid;
   12320         [ #  # ]:          0 :       p1.normalize();
   12321         [ #  # ]:          0 :       p2.normalize();
   12322                 :            : 
   12323 [ #  # ][ #  # ]:          0 :       if(p1==direction_of_line || p1==-direction_of_line)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
   12324                 :            :       {
   12325 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("In GeometryModifyTool:: get_planar_mid_surface\n"
                 [ #  # ]
   12326         [ #  # ]:          0 :                     "       P1 is on the line of intersection.\n");
   12327                 :          0 :         return CUBIT_FAILURE;
   12328                 :            :       }
   12329                 :            : 
   12330 [ #  # ][ #  # ]:          0 :       if(p2==direction_of_line || p2==-direction_of_line)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
   12331                 :            :       {
   12332 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("In GeometryModifyTool:: get_planar_mid_surface\n"
                 [ #  # ]
   12333         [ #  # ]:          0 :                     "       P2 is on the line of intersection.\n");
   12334                 :          0 :         return CUBIT_FAILURE;
   12335                 :            :       }
   12336                 :            : 
   12337 [ #  # ][ #  # ]:          0 :       CubitVector v1 = p1 - (p1%direction_of_line)*direction_of_line;
                 [ #  # ]
   12338         [ #  # ]:          0 :       v1.normalize();
   12339                 :            : 
   12340 [ #  # ][ #  # ]:          0 :       CubitVector v2 = p2 - (p2%direction_of_line)*direction_of_line;
                 [ #  # ]
   12341         [ #  # ]:          0 :       v2.normalize();
   12342                 :            : 
   12343 [ #  # ][ #  # ]:          0 :       n_mid = v1 - v2;
   12344         [ #  # ]:          0 :       n_mid.normalize();
   12345                 :            :     }
   12346                 :            : 
   12347         [ #  # ]:          0 :     CubitPlane mid_plane(n_mid, p_mid);
   12348         [ #  # ]:          0 :     point_1 = p_mid;
   12349                 :            : 
   12350                 :            :     //find three points that will define the infinite plane from the
   12351                 :            :     //mid plane.through the point in any direction just not along the
   12352                 :            :     //normal direction
   12353 [ #  # ][ #  # ]:          0 :     CubitVector Xdir(1,0,0), Ydir(0,1,0);
   12354         [ #  # ]:          0 :     CubitVector direction1;
   12355                 :            : 
   12356 [ #  # ][ #  # ]:          0 :     if ( ( ! n_mid.about_equal( Xdir ) ) && ( ! (-n_mid).about_equal( Xdir ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
   12357 [ #  # ][ #  # ]:          0 :       direction1 = Xdir + n_mid;
   12358                 :            :     else
   12359 [ #  # ][ #  # ]:          0 :       direction1 = Ydir + n_mid;
   12360                 :            : 
   12361 [ #  # ][ #  # ]:          0 :     point_2 = p_mid + direction1;
   12362 [ #  # ][ #  # ]:          0 :     point_2 = mid_plane.project(point_2);
   12363                 :            : 
   12364 [ #  # ][ #  # ]:          0 :     direction1 = point_2-point_1;
   12365         [ #  # ]:          0 :     CubitVector direction2 = direction1*n_mid;
   12366 [ #  # ][ #  # ]:          0 :     point_3 = point_1 + direction2;
   12367                 :            : 
   12368                 :            :     CubitStatus ret = gme_ptr->get_mid_plane(point_1, point_2, point_3,
   12369         [ #  # ]:          0 :                                               body_sm_to_trim_to, midsurface_body_sm );
   12370                 :          0 :     return ret;
   12371                 :            : }
   12372                 :            : 
   12373                 :            : //=============================================================================
   12374                 :            : // Function   : get_mid_surface
   12375                 :            : // Member Type: PUBLIC
   12376                 :            : // Description: Calculates a mid-surface between 2 surfaces (calls appropriate
   12377                 :            : //              specialized methods if needed).
   12378                 :            : // Author     : Philippe Pebay
   12379                 :            : // Date       : 03/07/06
   12380                 :            : //=============================================================================
   12381                 :          0 : CubitStatus GeometryModifyTool::get_mid_surface( RefFace *ref_face1,
   12382                 :            :                                                RefFace *ref_face2,
   12383                 :            :                                                Body *body_to_trim_to,
   12384                 :            :                                                DLIList<RefFace*> &mid_surface_surfs ) const
   12385                 :            : {
   12386         [ #  # ]:          0 :   if( ref_face1 == ref_face2 )
   12387                 :            :   {
   12388 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot create midplane between the same surface.\n"
         [ #  # ][ #  # ]
   12389         [ #  # ]:          0 :                 "       Surface %d was entered twice\n",  ref_face1->id() );
   12390                 :          0 :     return CUBIT_FAILURE;
   12391                 :            :   }
   12392                 :            : 
   12393         [ #  # ]:          0 :   BodySM *body_sm_to_trim_to = body_to_trim_to->get_body_sm_ptr();
   12394         [ #  # ]:          0 :   GeometryModifyEngine *gme1_ptr = get_engine(body_sm_to_trim_to);
   12395         [ #  # ]:          0 :   if ( !gme1_ptr )
   12396                 :            :   {
   12397 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("In GeometryModifyTool::get_mid_surface\n"
                 [ #  # ]
   12398         [ #  # ]:          0 :                 "       Geometry can't be modified, no associated modify engine.\n");
   12399                 :          0 :     return CUBIT_FAILURE;
   12400                 :            :   }
   12401                 :            : 
   12402                 :          0 :   bool found_case = false;
   12403                 :          0 :   CubitStatus ret = CUBIT_SUCCESS;
   12404                 :          0 :   BodySM* midsurface_body_sm = NULL;
   12405                 :            : 
   12406                 :            :   // Plane to plane case
   12407 [ #  # ][ #  # ]:          0 :   if ( ( ref_face1->geometry_type() == PLANE_SURFACE_TYPE ) && ( ref_face2->geometry_type() == PLANE_SURFACE_TYPE ) )
         [ #  # ][ #  # ]
                 [ #  # ]
   12408                 :            :   {
   12409                 :          0 :     found_case = true;
   12410         [ #  # ]:          0 :     ret = get_planar_mid_surface( ref_face1, ref_face2, body_sm_to_trim_to, midsurface_body_sm, gme1_ptr );
   12411                 :            :   }
   12412                 :            : 
   12413                 :            :   // Quadric to quadric cases
   12414 [ #  # ][ #  # ]:          0 :   if ( ( ( ref_face1->geometry_type() == SPHERE_SURFACE_TYPE ) && ( ref_face2->geometry_type() == SPHERE_SURFACE_TYPE ) )
         [ #  # ][ #  # ]
   12415         [ #  # ]:          0 :        ||
   12416 [ #  # ][ #  # ]:          0 :        ( ( ref_face1->geometry_type() == CONE_SURFACE_TYPE ) && ( ref_face2->geometry_type() == CONE_SURFACE_TYPE ) )
                 [ #  # ]
   12417 [ #  # ][ #  # ]:          0 :        ||
   12418 [ #  # ][ #  # ]:          0 :        ( ( ref_face1->geometry_type() == TORUS_SURFACE_TYPE ) && ( ref_face2->geometry_type() == TORUS_SURFACE_TYPE ) ) )
                 [ #  # ]
   12419                 :            :   {
   12420                 :          0 :     found_case = true;
   12421         [ #  # ]:          0 :     DLIList<TopologyEntity*> entity_list(2);
   12422 [ #  # ][ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list(2);
                 [ #  # ]
   12423                 :            : 
   12424         [ #  # ]:          0 :     entity_list.append(ref_face1);
   12425         [ #  # ]:          0 :     entity_list.append(ref_face2);
   12426         [ #  # ]:          0 :     GeometryModifyEngine* gme2_ptr = common_modify_engine(entity_list,bridge_list);
   12427                 :            : 
   12428         [ #  # ]:          0 :     if( gme2_ptr == 0 )
   12429                 :            :     {
   12430 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "In GeometryModifyTool::get_mid_surface\n"
         [ #  # ][ #  # ]
                 [ #  # ]
   12431                 :            :                    "       Surfaces %d and %d do not have the same underlying geometry modeling engine.\n"
   12432                 :            :                    "       For midsurface calculations, they must be the same\n",
   12433         [ #  # ]:          0 :                    ref_face1->id(), ref_face2->id() );
   12434                 :          0 :       return CUBIT_FAILURE;
   12435                 :            :     }
   12436                 :            : 
   12437         [ #  # ]:          0 :     if( gme1_ptr != gme2_ptr )
   12438                 :            :     {
   12439 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "In GeometryModifyTool::get_mid_surface\n"
                 [ #  # ]
   12440                 :            :                    "       Body and surfaces do not have the same underlying geometry modeling engine.\n"
   12441         [ #  # ]:          0 :                    "       For midsurface calculations, they must be the same\n");
   12442                 :          0 :       return CUBIT_FAILURE;
   12443                 :            :     }
   12444                 :            : 
   12445         [ #  # ]:          0 :     bridge_list.reset();
   12446 [ #  # ][ #  # ]:          0 :     Surface* surface1_ptr = dynamic_cast<Surface*>(bridge_list.next(0));
   12447 [ #  # ][ #  # ]:          0 :     Surface* surface2_ptr = dynamic_cast<Surface*>(bridge_list.next(1));
   12448                 :            : 
   12449                 :            :     // Sphere to sphere case
   12450 [ #  # ][ #  # ]:          0 :     if ( ( ref_face1->geometry_type() == SPHERE_SURFACE_TYPE ) && ( ref_face2->geometry_type() == SPHERE_SURFACE_TYPE ) )
         [ #  # ][ #  # ]
                 [ #  # ]
   12451                 :            :     {
   12452         [ #  # ]:          0 :       ret = gme2_ptr->get_spheric_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurface_body_sm );
   12453                 :            :     }
   12454                 :            : 
   12455                 :            :     // Cone to cone case
   12456 [ #  # ][ #  # ]:          0 :     if ( ( ref_face1->geometry_type() == CONE_SURFACE_TYPE ) && ( ref_face2->geometry_type() == CONE_SURFACE_TYPE ) )
         [ #  # ][ #  # ]
                 [ #  # ]
   12457                 :            :     {
   12458         [ #  # ]:          0 :       ret = gme2_ptr->get_conic_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurface_body_sm );
   12459                 :            :     }
   12460                 :            : 
   12461                 :            :     // Torus to torus case
   12462 [ #  # ][ #  # ]:          0 :     if ( ( ref_face1->geometry_type() == TORUS_SURFACE_TYPE ) && ( ref_face2->geometry_type() == TORUS_SURFACE_TYPE ) )
         [ #  # ][ #  # ]
                 [ #  # ]
   12463                 :            :     {
   12464 [ #  # ][ #  # ]:          0 :       ret = gme2_ptr->get_toric_mid_surface( surface1_ptr, surface2_ptr, body_sm_to_trim_to, midsurface_body_sm );
                 [ #  # ]
   12465                 :          0 :     }
   12466                 :            :   }
   12467                 :            : 
   12468                 :            :   // Unsupported pair of surfaces
   12469         [ #  # ]:          0 :   if ( ! found_case )
   12470                 :            :   {
   12471 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("In GeometryModifyTool::get_mid_surface\n"
                 [ #  # ]
   12472         [ #  # ]:          0 :                 "       Midsurface calculation not yet supported for such a pair of surfaces.\n");
   12473                 :          0 :     return CUBIT_FAILURE;
   12474                 :            :   }
   12475                 :            : 
   12476         [ #  # ]:          0 :   if ( midsurface_body_sm )
   12477                 :            :   {
   12478 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   12479         [ #  # ]:          0 :       CubitUndo::save_state();
   12480                 :            : 
   12481         [ #  # ]:          0 :     DLIList<Surface*> mid_surfaces;
   12482 [ #  # ][ #  # ]:          0 :     DLIList<Body*> new_bodies;
   12483         [ #  # ]:          0 :     midsurface_body_sm->surfaces( mid_surfaces);
   12484                 :            :     //make each surface of the body into its own body
   12485                 :            :     int i;
   12486 [ #  # ][ #  # ]:          0 :     for( i=0; i<mid_surfaces.size(); i++ )
   12487                 :            :     {
   12488         [ #  # ]:          0 :       Surface *tmp_surface = mid_surfaces.get_and_step();
   12489         [ #  # ]:          0 :       Surface* new_surface_ptr = gme1_ptr->make_Surface( tmp_surface );
   12490                 :            : 
   12491         [ #  # ]:          0 :       Body *new_Body = make_Body(new_surface_ptr);
   12492         [ #  # ]:          0 :       new_bodies.append( new_Body );
   12493         [ #  # ]:          0 :       DLIList<RefFace*> ref_faces;
   12494         [ #  # ]:          0 :       new_Body->ref_faces(ref_faces);
   12495         [ #  # ]:          0 :       RefFace *ref_face_ptr = ref_faces.get();
   12496         [ #  # ]:          0 :       mid_surface_surfs.append( ref_face_ptr );
   12497         [ #  # ]:          0 :     }
   12498 [ #  # ][ #  # ]:          0 :     gme1_ptr->get_gqe()->delete_solid_model_entities( midsurface_body_sm );
   12499                 :            : 
   12500 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   12501                 :            :     {
   12502 [ #  # ][ #  # ]:          0 :       if( new_bodies.size() )
   12503         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_bodies );
   12504                 :            :       else
   12505         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   12506                 :            :     }
   12507                 :            : 
   12508         [ #  # ]:          0 :     return ret;
   12509                 :            :   }
   12510                 :            :   else
   12511                 :          0 :     return CUBIT_FAILURE;
   12512                 :            : }
   12513                 :            : 
   12514                 :        253 : CubitStatus GeometryModifyTool::set_default_gme(GeometryModifyEngine* GMEPtr)
   12515                 :            : {
   12516         [ -  + ]:        253 :     if(!GMEPtr)
   12517                 :          0 :         return CUBIT_FAILURE;
   12518                 :            : 
   12519                 :            :     int i;
   12520         [ +  - ]:        275 :     for (i = 0; i < gmeList.size(); i++)
   12521                 :            :     {
   12522         [ +  + ]:        275 :         if(GMEPtr == gmeList.get())
   12523                 :        253 :             break;
   12524                 :            : 
   12525                 :         22 :         gmeList.step();
   12526                 :            :     }
   12527                 :            : 
   12528         [ -  + ]:        253 :     if(i == gmeList.size())
   12529                 :          0 :         return CUBIT_FAILURE;
   12530                 :            : 
   12531                 :        253 :     GeometryModifyEngine* temp_ptr = gmeList.get();
   12532                 :        253 :     gmeList.remove();
   12533                 :        253 :     gmeList.insert_first(temp_ptr);
   12534                 :        253 :     return CUBIT_SUCCESS;
   12535                 :            : }
   12536                 :            : 
   12537                 :            : //=============================================================================
   12538                 :            : // Description: Consolidate common setup code for tweak surface operations
   12539                 :            : // Author     : Jason Kraftcheck
   12540                 :            : // Date       : 11/05/03
   12541                 :            : //=============================================================================
   12542                 :            : GeometryModifyEngine*
   12543                 :          0 : GeometryModifyTool::tweak_setup( DLIList<RefFace*> &input_faces,
   12544                 :            :                                  const char* name,
   12545                 :            :                                  DLIList<Body*> &output_bodies,
   12546                 :            :                                  DLIList<Surface*> &output_surfaces,
   12547                 :            :                                  CubitBoolean allow_composites)
   12548                 :            : {
   12549 [ #  # ][ #  # ]:          0 :   if( input_faces.size() == 0 )
   12550                 :            :   {
   12551 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "No surfaces specified\n" );
         [ #  # ][ #  # ]
   12552                 :          0 :     return 0;
   12553                 :            :   }
   12554                 :            : 
   12555                 :            :   //are any of the input faces merged? ...disallow that
   12556                 :            :   int i;
   12557 [ #  # ][ #  # ]:          0 :   for( i=input_faces.size(); i--; )
   12558                 :            :   {
   12559         [ #  # ]:          0 :     RefFace *tmp_face = input_faces.get();
   12560 [ #  # ][ #  # ]:          0 :     if( tmp_face->is_merged() )
   12561                 :            :     {
   12562         [ #  # ]:          0 :       input_faces.change_to( NULL );
   12563 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Surface %d is a merged surface.  Cannot perform %s operation on it.\n"
         [ #  # ][ #  # ]
   12564         [ #  # ]:          0 :                   "       Unmerge it first\n",  tmp_face->id(), name );
   12565                 :            :     }
   12566         [ #  # ]:          0 :     input_faces.step();
   12567                 :            :   }
   12568         [ #  # ]:          0 :   input_faces.remove_all_with_value( NULL );
   12569 [ #  # ][ #  # ]:          0 :   if( input_faces.size() == 0 )
   12570                 :          0 :     return 0;
   12571                 :            : 
   12572                 :            :   // Get parent bodies
   12573 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> query_input(input_faces.size()), query_output;
         [ #  # ][ #  # ]
   12574 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(input_faces, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   12575                 :            :   ModelQueryEngine::instance()
   12576 [ #  # ][ #  # ]:          0 :     ->query_model( query_input, DagType::body_type(), query_output );
                 [ #  # ]
   12577 [ #  # ][ #  # ]:          0 :   CAST_LIST(query_output, output_bodies, Body);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   12578                 :            : 
   12579         [ #  # ]:          0 :   if(allow_composites)
   12580                 :            :   {
   12581 [ #  # ][ #  # ]:          0 :     if (!okay_to_modify( output_bodies, "TWEAK" ))
   12582                 :          0 :       return 0;
   12583                 :            :   }
   12584                 :            :   else
   12585                 :            :   {
   12586 [ #  # ][ #  # ]:          0 :     if ( contains_intermediate_geom(output_bodies))
   12587                 :            :     {
   12588 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("%s surfaces on volumes containing virtual geometry\n"
                 [ #  # ]
   12589                 :            :         "       is not allowed.\n"
   12590                 :            :         "       Delete virtual geometry on these volumes before operation.\n",
   12591         [ #  # ]:          0 :         name);
   12592                 :          0 :       return 0;
   12593                 :            :     }
   12594                 :            :   }
   12595                 :            : 
   12596                 :            :   // Get engine and corresponding geom entities
   12597                 :            :   GeometryModifyEngine* gme_ptr;
   12598         [ #  # ]:          0 :   gme_ptr = common_modify_engine( input_faces, output_surfaces, allow_composites );
   12599         [ #  # ]:          0 :   if (!gme_ptr)
   12600                 :            :   {
   12601 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("%s surfaces on volumes containing surfaces from different\n"
                 [ #  # ]
   12602         [ #  # ]:          0 :       "       geometry engines is not allowed.\n", name);
   12603                 :            :   }
   12604                 :            : 
   12605         [ #  # ]:          0 :   return gme_ptr;
   12606                 :            : }
   12607                 :            : 
   12608                 :            : //=============================================================================
   12609                 :            : // Description: Consolidate common setup code for tweak curve operations
   12610                 :            : // Author     : Steve Storm
   12611                 :            : // Date       : 03/25/05
   12612                 :            : //=============================================================================
   12613                 :            : GeometryModifyEngine*
   12614                 :          0 : GeometryModifyTool::tweak_setup( DLIList<RefEdge*> &input_curves,
   12615                 :            :                                  const char* name,
   12616                 :            :                                  DLIList<Body*> &output_bodies,
   12617                 :            :                                  DLIList<Curve*> &output_curves,
   12618                 :            :                                  CubitBoolean allow_composites )
   12619                 :            : {
   12620 [ #  # ][ #  # ]:          0 :   if( input_curves.size() == 0 )
   12621                 :            :   {
   12622 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "No curves specified\n" );
         [ #  # ][ #  # ]
   12623                 :          0 :     return 0;
   12624                 :            :   }
   12625                 :            : 
   12626                 :            :   //are any of the input curves merged? ...disallow that
   12627                 :            :   int i;
   12628 [ #  # ][ #  # ]:          0 :   for( i=input_curves.size(); i--; )
   12629                 :            :   {
   12630         [ #  # ]:          0 :     RefEdge *tmp_edge = input_curves.get();
   12631 [ #  # ][ #  # ]:          0 :     if( tmp_edge->is_merged() )
   12632                 :            :     {
   12633         [ #  # ]:          0 :       input_curves.change_to( NULL );
   12634 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Curve %d is a merged curve.  Cannot perform %s operation on it.\n"
         [ #  # ][ #  # ]
   12635         [ #  # ]:          0 :                   "       Unmerge it first\n",  tmp_edge->id(), name );
   12636                 :            :     }
   12637         [ #  # ]:          0 :     input_curves.step();
   12638                 :            :   }
   12639         [ #  # ]:          0 :   input_curves.remove_all_with_value( NULL );
   12640 [ #  # ][ #  # ]:          0 :   if( input_curves.size() == 0 )
   12641                 :          0 :     return 0;
   12642                 :            : 
   12643                 :            :   // Get parent bodies
   12644 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> query_input(input_curves.size()), query_output;
         [ #  # ][ #  # ]
   12645 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(input_curves, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   12646                 :            :   ModelQueryEngine::instance()
   12647 [ #  # ][ #  # ]:          0 :     ->query_model( query_input, DagType::body_type(), query_output );
                 [ #  # ]
   12648 [ #  # ][ #  # ]:          0 :   CAST_LIST(query_output, output_bodies, Body);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   12649                 :            : 
   12650         [ #  # ]:          0 :   if(allow_composites)
   12651                 :            :   {
   12652 [ #  # ][ #  # ]:          0 :     if (!okay_to_modify( output_bodies, "TWEAK" ))
   12653                 :          0 :       return 0;
   12654                 :            :   }
   12655                 :            :   else
   12656                 :            :   {
   12657 [ #  # ][ #  # ]:          0 :     if ( contains_intermediate_geom(output_bodies))
   12658                 :            :     {
   12659 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("%s surfaces on volumes containing virtual geometry\n"
                 [ #  # ]
   12660                 :            :                   "       is not allowed.\n"
   12661                 :            :                   "       Delete virtual geometry on these volumes before operation.\n",
   12662         [ #  # ]:          0 :                   name);
   12663                 :          0 :       return 0;
   12664                 :            :     }
   12665                 :            :   }
   12666                 :            : 
   12667                 :            :   // Get engine and corresponding geom entities
   12668                 :            :   GeometryModifyEngine* gme_ptr;
   12669         [ #  # ]:          0 :   gme_ptr = common_modify_engine( input_curves, output_curves );
   12670         [ #  # ]:          0 :   if (!gme_ptr)
   12671                 :            :   {
   12672 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("%s curves on entities containing surfaces from different\n"
                 [ #  # ]
   12673         [ #  # ]:          0 :       "       geometry engines is not allowed.\n", name);
   12674                 :            :   }
   12675                 :            : 
   12676         [ #  # ]:          0 :   return gme_ptr;
   12677                 :            : }
   12678                 :            : 
   12679                 :            : //=============================================================================
   12680                 :            : // Description: Consolidate common setup code for tweak vertex operations
   12681                 :            : // Author     : Steve Storm
   12682                 :            : // Date       : 03/25/05
   12683                 :            : //=============================================================================
   12684                 :            : GeometryModifyEngine*
   12685                 :          0 : GeometryModifyTool::tweak_setup( DLIList<RefVertex*> &input_vertices,
   12686                 :            :                                  const char* name,
   12687                 :            :                                  DLIList<Body*> &output_bodies,
   12688                 :            :                                  DLIList<TBPoint*> &output_points,
   12689                 :            :                                  CubitBoolean allow_composites )
   12690                 :            : {
   12691 [ #  # ][ #  # ]:          0 :   if( input_vertices.size() == 0 )
   12692                 :            :   {
   12693 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "No vertices specified\n" );
         [ #  # ][ #  # ]
   12694                 :          0 :     return 0;
   12695                 :            :   }
   12696                 :            : 
   12697                 :            :   //are any of the input vertices merged? ...disallow that
   12698                 :            :   int i;
   12699 [ #  # ][ #  # ]:          0 :   for( i=input_vertices.size(); i--; )
   12700                 :            :   {
   12701         [ #  # ]:          0 :     RefVertex *tmp_vert = input_vertices.get();
   12702 [ #  # ][ #  # ]:          0 :     if( tmp_vert->is_merged() )
   12703                 :            :     {
   12704         [ #  # ]:          0 :       input_vertices.change_to( NULL );
   12705 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Vertex %d is a merged vertex.  Cannot perform %s operation on it.\n"
         [ #  # ][ #  # ]
   12706         [ #  # ]:          0 :                   "       Unmerge it first\n",  tmp_vert->id(), name );
   12707                 :            :     }
   12708         [ #  # ]:          0 :     input_vertices.step();
   12709                 :            :   }
   12710         [ #  # ]:          0 :   input_vertices.remove_all_with_value( NULL );
   12711 [ #  # ][ #  # ]:          0 :   if( input_vertices.size() == 0 )
   12712                 :          0 :     return 0;
   12713                 :            : 
   12714                 :            :   // Get parent bodies
   12715 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> query_input(input_vertices.size()), query_output;
         [ #  # ][ #  # ]
   12716 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(input_vertices, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   12717                 :            :   ModelQueryEngine::instance()
   12718 [ #  # ][ #  # ]:          0 :     ->query_model( query_input, DagType::body_type(), query_output );
                 [ #  # ]
   12719 [ #  # ][ #  # ]:          0 :   CAST_LIST(query_output, output_bodies, Body);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   12720                 :            : 
   12721         [ #  # ]:          0 :   if(allow_composites)
   12722                 :            :   {
   12723 [ #  # ][ #  # ]:          0 :     if (!okay_to_modify( output_bodies, "TWEAK" ))
   12724                 :          0 :       return 0;
   12725                 :            :   }
   12726                 :            :   else
   12727                 :            :   {
   12728 [ #  # ][ #  # ]:          0 :     if ( contains_intermediate_geom(output_bodies))
   12729                 :            :     {
   12730 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("%s surfaces on volumes containing virtual geometry\n"
                 [ #  # ]
   12731                 :            :                   "       is not allowed.\n"
   12732                 :            :                   "       Delete virtual geometry on these volumes before operation.\n",
   12733         [ #  # ]:          0 :                   name);
   12734                 :          0 :       return 0;
   12735                 :            :     }
   12736                 :            :   }
   12737                 :            : 
   12738                 :            :   // Get engine and corresponding geom entities
   12739                 :            :   GeometryModifyEngine* gme_ptr;
   12740         [ #  # ]:          0 :   gme_ptr = common_modify_engine( input_vertices, output_points, allow_composites );
   12741         [ #  # ]:          0 :   if (!gme_ptr)
   12742                 :            :   {
   12743 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("%s vertices on entities containing surfaces from different\n"
                 [ #  # ]
   12744         [ #  # ]:          0 :       "       geometry engines is not allowed.\n", name);
   12745                 :            :   }
   12746                 :            : 
   12747         [ #  # ]:          0 :   return gme_ptr;
   12748                 :            : }
   12749                 :            : 
   12750                 :            : //=============================================================================
   12751                 :            : // Description: The user selects a surface they would like to idealize and also selects a radius
   12752                 :            : //                              size for fillets.  The user also specifies whether to consider internal and/or external fillets.
   12753                 :            : //              The program will identify fillets which meet the users criteria and tweak remove them automatically.
   12754                 :            : //              There is also a preview and exclude curve capability.
   12755                 :            : // Author     : Jonathan Bugman
   12756                 :            : // Date       : 10/23/2008
   12757                 :            : //=============================================================================
   12758                 :          0 : CubitStatus GeometryModifyTool::idealize_fillet_geometry(DLIList<RefEntity*> idealize_entity,
   12759                 :            :                                                          DLIList<RefEntity*> exclude_entity,
   12760                 :            :                                                          double fillet_rad,
   12761                 :            :                                                          CubitBoolean internal_flg,
   12762                 :            :                                                          CubitBoolean external_flg,
   12763                 :            :                                                                                                              CubitBoolean preview)
   12764                 :            : {
   12765                 :            :     //cast the DLIList<RefEntity> to a DLIList<RefFace>
   12766         [ #  # ]:          0 :     DLIList<RefFace*> face_to_idealize;
   12767 [ #  # ][ #  # ]:          0 :     CAST_LIST(idealize_entity, face_to_idealize, RefFace);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   12768                 :            : 
   12769                 :            :     //grabbing geometry tolerance
   12770 [ #  # ][ #  # ]:          0 :     double geo_tol = GeometryQueryTool::instance()->get_sme_resabs_tolerance(),temp_fillet_radius;
   12771                 :            : 
   12772                 :            :     //grabbing all the curve loops ONLY from surfaces which are a sheet body
   12773                 :            :     int y, i, j, z;
   12774 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> sheet_body_idealize_face;
   12775                 :            : 
   12776 [ #  # ][ #  # ]:          0 :     for(i=0; i<face_to_idealize.size(); i++)
   12777                 :            :     {
   12778         [ #  # ]:          0 :         RefFace* target_face = face_to_idealize.get_and_step();
   12779         [ #  # ]:          0 :         DLIList<Shell*> shell_list;
   12780         [ #  # ]:          0 :         target_face->shells(shell_list);
   12781 [ #  # ][ #  # ]:          0 :         for(j=0; j<shell_list.size(); j++)
   12782                 :            :         {
   12783         [ #  # ]:          0 :             Shell* target_shell = shell_list.get_and_step();
   12784 [ #  # ][ #  # ]:          0 :             if(target_face->is_nonmanifold( (GroupingEntity*)target_shell ) )
   12785                 :            :             {
   12786 [ #  # ][ #  # ]:          0 :                 sheet_body_idealize_face.append(face_to_idealize[i]);
   12787                 :            :             }
   12788                 :            :         }
   12789         [ #  # ]:          0 :     }
   12790                 :            : 
   12791         [ #  # ]:          0 :     face_to_idealize.clean_out();
   12792                 :            : 
   12793                 :            :     //this section is going to remove all excluded curves loopsm from the 'master' loopsm list
   12794 [ #  # ][ #  # ]:          0 :     DLIList<Curve*> exclude_cuves;
   12795 [ #  # ][ #  # ]:          0 :     DLIList <Body*> old_body_list;
   12796 [ #  # ][ #  # ]:          0 :     if(exclude_entity.size()>0)
   12797                 :            :     {
   12798                 :            :         //cast the exclude DLIList<RefEntity> to DLIList<RefEdge>
   12799         [ #  # ]:          0 :         DLIList<RefEdge*> exclude_edge;
   12800 [ #  # ][ #  # ]:          0 :         CAST_LIST(exclude_entity, exclude_edge, RefEdge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   12801                 :            : 
   12802                 :            :         //switching the DLIList<RefEdge> to DLIList<Curve>
   12803                 :            :         GeometryModifyEngine* gme_ptr1;
   12804         [ #  # ]:          0 :         gme_ptr1 = tweak_setup(exclude_edge,"idealize",old_body_list,exclude_cuves);
   12805         [ #  # ]:          0 :         if (NULL == gme_ptr1) {
   12806 [ #  # ][ #  # ]:          0 :           PRINT_ERROR("Unexpected NULL GeometryModifyEngine pointer.\n");
         [ #  # ][ #  # ]
   12807                 :          0 :           return CUBIT_FAILURE;
   12808                 :            :         }
   12809 [ #  # ][ #  # ]:          0 :         exclude_edge.clean_out();
                 [ #  # ]
   12810                 :            :     }
   12811                 :            : 
   12812                 :            :     //switching the DLIList<RefFace> to DLIList<Surface>
   12813                 :            :     GeometryModifyEngine* gme_ptr;
   12814 [ #  # ][ #  # ]:          0 :     DLIList<Surface*> sheet_body_idealize_surface;
   12815         [ #  # ]:          0 :     gme_ptr = tweak_setup(sheet_body_idealize_face,"idealize",old_body_list,sheet_body_idealize_surface);
   12816         [ #  # ]:          0 :     sheet_body_idealize_face.clean_out();
   12817                 :            : 
   12818                 :            :     //grab all the loops from each sheet body surface
   12819 [ #  # ][ #  # ]:          0 :     DLIList <LoopSM*> idealize_loopSM_list;
   12820 [ #  # ][ #  # ]:          0 :     for(y=0;y<sheet_body_idealize_surface.size();y++)
   12821                 :            :     {
   12822 [ #  # ][ #  # ]:          0 :         sheet_body_idealize_surface[y]->loopsms(idealize_loopSM_list);
   12823                 :            :     }
   12824         [ #  # ]:          0 :     sheet_body_idealize_surface.clean_out();
   12825                 :            : 
   12826                 :            :     //search through possible fillet curves filtering only for curves of type arc
   12827                 :            :     //if it is an arc, does it have a straight line on both sides of it, if so'
   12828                 :            :     //check the radius of the arc and if it passes test add it to the list of curves to be tweaked removed
   12829 [ #  # ][ #  # ]:          0 :     DLIList <Curve*> master_curve_remove_list,possible_fillet_arcs,potential_fillet,internal_fillet, external_fillet, attached_curves;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   12830 [ #  # ][ #  # ]:          0 :     CubitVector fillet_center_point, intersection_pt,arc_mid,test_point;
         [ #  # ][ #  # ]
   12831 [ #  # ][ #  # ]:          0 :     DLIList <TBPoint*> arc_vertices;
   12832 [ #  # ][ #  # ]:          0 :     for(y=0;y<idealize_loopSM_list.size();y++)
   12833                 :            :     {
   12834 [ #  # ][ #  # ]:          0 :         idealize_loopSM_list[y]->curves(possible_fillet_arcs);
   12835                 :            :         //doing this as a performance boost, it'll keep the code out of the next couple of for loops for situations
   12836                 :            :         //where there is no fillet possible, for instance, a hole with 2 curves will never be a fillet
   12837 [ #  # ][ #  # ]:          0 :         if(possible_fillet_arcs.size()>3)
   12838                 :            :         {
   12839 [ #  # ][ #  # ]:          0 :             for(i=0;i<possible_fillet_arcs.size();i++)
   12840                 :            :             {
   12841 [ #  # ][ #  # ]:          0 :                 if(possible_fillet_arcs[i]->geometry_type() == ARC_CURVE_TYPE &&
         [ #  # ][ #  # ]
                 [ #  # ]
   12842 [ #  # ][ #  # ]:          0 :                     exclude_cuves.is_in_list(possible_fillet_arcs[i])==CUBIT_FALSE)
   12843                 :            :                 {
   12844 [ #  # ][ #  # ]:          0 :                     possible_fillet_arcs[i]->points(arc_vertices);
   12845                 :            :                     //don't need to check for one point as in a hole because I have a check that there needs to be
   12846                 :            :                     //at least 3 curves in the loop
   12847                 :            : 
   12848                 :            :                     //this is to check that there is only one curve attached to the arc
   12849 [ #  # ][ #  # ]:          0 :                     for(z=0;z<arc_vertices.size();z++)
   12850                 :            :                     {
   12851 [ #  # ][ #  # ]:          0 :                         arc_vertices[z]->curves(attached_curves);
   12852 [ #  # ][ #  # ]:          0 :                         if(attached_curves.size()!=2)
   12853                 :            :                         {
   12854                 :            :                             //I dont' think this break point is going to kick me far enough out of the for loop
   12855                 :          0 :                             break;
   12856                 :            :                         }
   12857                 :            :                     }
   12858                 :            : 
   12859 [ #  # ][ #  # ]:          0 :                     possible_fillet_arcs[i]->mid_point(arc_mid);
   12860 [ #  # ][ #  # ]:          0 :                     possible_fillet_arcs[i]->get_center_radius(fillet_center_point,temp_fillet_radius);
   12861 [ #  # ][ #  # ]:          0 :                     test_point = arc_mid + geo_tol * (fillet_center_point-arc_mid);
         [ #  # ][ #  # ]
   12862         [ #  # ]:          0 :                     DLIList<Surface*> test_surf;
   12863 [ #  # ][ #  # ]:          0 :                     idealize_loopSM_list[y]->surfaces(test_surf);
   12864                 :            : 
   12865                 :            :                     //this may be dangerous but I'm assuming that a loop is on only one surface
   12866 [ #  # ][ #  # ]:          0 :                     CubitPointContainment cpc = test_surf[0]->point_containment(test_point);
   12867 [ #  # ][ #  # ]:          0 :                     if(temp_fillet_radius <= fillet_rad && cpc==CUBIT_PNT_INSIDE)
   12868                 :            :                     {
   12869 [ #  # ][ #  # ]:          0 :                         external_fillet.append(possible_fillet_arcs[i]);
   12870                 :            :                     }
   12871 [ #  # ][ #  # ]:          0 :                     else if(temp_fillet_radius <= fillet_rad && cpc==CUBIT_PNT_OUTSIDE)
   12872                 :            :                     {
   12873 [ #  # ][ #  # ]:          0 :                         internal_fillet.append(possible_fillet_arcs[i]);
   12874         [ #  # ]:          0 :                     }
   12875                 :            :                 }
   12876                 :            :             }
   12877                 :            :         }
   12878         [ #  # ]:          0 :         possible_fillet_arcs.clean_out();
   12879                 :            :     }
   12880                 :            : 
   12881         [ #  # ]:          0 :     if(internal_flg==CUBIT_TRUE)
   12882                 :            :     {
   12883         [ #  # ]:          0 :         master_curve_remove_list+=internal_fillet;
   12884                 :            :     }
   12885         [ #  # ]:          0 :     if(external_flg==CUBIT_TRUE)
   12886                 :            :     {
   12887         [ #  # ]:          0 :         master_curve_remove_list+=external_fillet;
   12888                 :            :     }
   12889                 :            : 
   12890                 :            :     //if no arcs are found to be removed, warn the user.
   12891 [ #  # ][ #  # ]:          0 :     if(master_curve_remove_list.size()==0)
   12892                 :            :     {
   12893 [ #  # ][ #  # ]:          0 :         PRINT_INFO( "Failed to find any fillets which met users requirements\n\n" );
         [ #  # ][ #  # ]
   12894                 :            :         //I'm returning success here even though no curves were found
   12895                 :          0 :         return CUBIT_SUCCESS;
   12896                 :            :     }
   12897         [ #  # ]:          0 :     else if(preview == CUBIT_TRUE)
   12898                 :            :     {
   12899         [ #  # ]:          0 :         DLIList<BodySM*> new_bodysm_list;
   12900 [ #  # ][ #  # ]:          0 :         bool old_error_flag = GET_ERROR_FLAG();
   12901 [ #  # ][ #  # ]:          0 :         SET_ERROR_FLAG(false); // don't throw any tweak_remove errors
   12902                 :            : 
   12903         [ #  # ]:          0 :         CubitStatus stat = gme_ptr->tweak_remove(master_curve_remove_list, new_bodysm_list,CUBIT_FALSE, CUBIT_TRUE );
   12904                 :            : 
   12905 [ #  # ][ #  # ]:          0 :         SET_ERROR_FLAG(old_error_flag); // turn errors back on
   12906         [ #  # ]:          0 :         if(stat==CUBIT_FAILURE)
   12907                 :            :         {
   12908 [ #  # ][ #  # ]:          0 :             PRINT_WARNING("At least one of the fillets which met your requirements \n"
                 [ #  # ]
   12909         [ #  # ]:          0 :                 "           can't be preview due to the curve's geometry\n");
   12910                 :            :         }
   12911                 :            : 
   12912                 :            :         //output the number of holes or slots which were found
   12913 [ #  # ][ #  # ]:          0 :         PRINT_INFO("Found %d fillets which met idealization parameters\n\n", master_curve_remove_list.size());
         [ #  # ][ #  # ]
                 [ #  # ]
   12914         [ #  # ]:          0 :         return CUBIT_SUCCESS;
   12915                 :            :     }
   12916                 :            :     else
   12917                 :            :     {
   12918         [ #  # ]:          0 :         DLIList<BodySM*> new_bodysm_list;
   12919 [ #  # ][ #  # ]:          0 :         bool old_error_flag = GET_ERROR_FLAG();
   12920 [ #  # ][ #  # ]:          0 :         SET_ERROR_FLAG(false); // don't throw any tweak_remove errors
   12921                 :            : 
   12922                 :            :         //pass master_curve_remove_list to the tweak_remove command
   12923         [ #  # ]:          0 :         CubitStatus stat = gme_ptr->tweak_remove(master_curve_remove_list, new_bodysm_list,CUBIT_FALSE, CUBIT_FALSE );
   12924         [ #  # ]:          0 :         if(stat==CUBIT_FAILURE)
   12925                 :            :         {
   12926 [ #  # ][ #  # ]:          0 :             PRINT_WARNING("At least one of the fillets which met your requirements \n"
                 [ #  # ]
   12927         [ #  # ]:          0 :                 "           can't be tweaked due to the curve's geometry\n");
   12928                 :            :         }
   12929 [ #  # ][ #  # ]:          0 :         SET_ERROR_FLAG(old_error_flag); // turn errors back on
   12930                 :            : 
   12931                 :            :         //update DAG
   12932 [ #  # ][ #  # ]:          0 :         DLIList<Body*> new_body_list;
   12933         [ #  # ]:          0 :         stat = finish_sm_op( old_body_list, new_bodysm_list ,new_body_list );
   12934                 :            :         //output the number of holes or slots which were found
   12935 [ #  # ][ #  # ]:          0 :         PRINT_INFO("Found %d fillets which met idealization parameters\n\n", master_curve_remove_list.size());
         [ #  # ][ #  # ]
                 [ #  # ]
   12936         [ #  # ]:          0 :         return CUBIT_SUCCESS;
   12937         [ #  # ]:          0 :     }
   12938                 :            : }
   12939                 :            : 
   12940                 :            : //=============================================================================
   12941                 :            : // Description: The user selects a surface they would like to idealize and also selects a radius
   12942                 :            : //                              size for holes and or selects a radius and length for slots.  The program will identify
   12943                 :            : //              'holes' and 'slots' which meet the users criteria and tweak remove them automatically.
   12944                 :            : //              There is also a preview and exclude curve capability.
   12945                 :            : // Author     : Jonathan Bugman
   12946                 :            : // Date       : 10/23/2008
   12947                 :            : //=============================================================================
   12948                 :          0 : CubitStatus GeometryModifyTool::idealize_hole_slot_geometry(DLIList<RefEntity*> idealize_entity,
   12949                 :            :                                                             DLIList<RefEntity*> exclude_entity,
   12950                 :            :                                                             double arc_radius,
   12951                 :            :                                                             double slot_arc_radius,
   12952                 :            :                                                             double slot_length,
   12953                 :            :                                                                                                                 CubitBoolean preview)
   12954                 :            : {
   12955                 :            :     //cast the DLIList<RefEntity> to a DLIList<RefFace>
   12956         [ #  # ]:          0 :     DLIList<RefFace*> face_to_idealize;
   12957 [ #  # ][ #  # ]:          0 :     CAST_LIST(idealize_entity, face_to_idealize, RefFace);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   12958                 :            : 
   12959                 :            :     //grabbing geometry tolerance
   12960 [ #  # ][ #  # ]:          0 :     double geo_tol = GeometryQueryTool::instance()->get_sme_resabs_tolerance();
   12961                 :            : 
   12962                 :            :     //grabbing all the curve loops ONLY from surfaces which are a sheet body
   12963                 :          0 :     int y=0, i=0, j=0;
   12964 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> sheet_body_idealize_face;
   12965                 :            : 
   12966 [ #  # ][ #  # ]:          0 :     for(i=0; i<face_to_idealize.size(); i++)
   12967                 :            :     {
   12968         [ #  # ]:          0 :         RefFace* target_face = face_to_idealize.get_and_step();
   12969         [ #  # ]:          0 :         DLIList<Shell*> shell_list;
   12970         [ #  # ]:          0 :         target_face->shells(shell_list);
   12971 [ #  # ][ #  # ]:          0 :         for(j=0; j<shell_list.size(); j++)
   12972                 :            :         {
   12973         [ #  # ]:          0 :             Shell* target_shell = shell_list.get_and_step();
   12974 [ #  # ][ #  # ]:          0 :             if(target_face->is_nonmanifold( (GroupingEntity*)target_shell ) )
   12975                 :            :             {
   12976 [ #  # ][ #  # ]:          0 :                 sheet_body_idealize_face.append(face_to_idealize[i]);
   12977                 :            :             }
   12978                 :            :         }
   12979         [ #  # ]:          0 :     }
   12980                 :            : 
   12981                 :            :     //if no faces to idealize that pass requirements, error out a warning message
   12982 [ #  # ][ #  # ]:          0 :     if(sheet_body_idealize_face.size()==0)
   12983                 :            :     {
   12984                 :            :         //I'm returning success here even though no surfaces found that meet shell requirements set above
   12985                 :            :         {
   12986 [ #  # ][ #  # ]:          0 :             PRINT_INFO( "Failed to find any feature(s) which met user requirements\n\n" );
         [ #  # ][ #  # ]
   12987                 :            :         }
   12988                 :          0 :         return CUBIT_SUCCESS;
   12989                 :            :     }
   12990                 :            : 
   12991                 :            :     //temp_body_ptr = face_to_idealize[y]->body();
   12992                 :            :     //if(temp_body_ptr->is_sheet_body())
   12993                 :            :     //{
   12994                 :            :     //    sheet_body_idealize_face.append(face_to_idealize[y]);
   12995                 :            :     //}
   12996                 :            : 
   12997         [ #  # ]:          0 :     face_to_idealize.clean_out();
   12998                 :            : 
   12999                 :            :     //switching the DLIList<RefFace> to DLIList<Surface>
   13000                 :            :     GeometryModifyEngine* gme_ptr;
   13001 [ #  # ][ #  # ]:          0 :     DLIList <Body*> old_body_list;
   13002 [ #  # ][ #  # ]:          0 :     DLIList<Surface*> sheet_body_idealize_surface;
   13003         [ #  # ]:          0 :     gme_ptr = tweak_setup(sheet_body_idealize_face,"idealize",old_body_list,sheet_body_idealize_surface);
   13004         [ #  # ]:          0 :     sheet_body_idealize_face.clean_out();
   13005                 :            : 
   13006                 :            :     //grab all the loops from each sheet body surface
   13007 [ #  # ][ #  # ]:          0 :     DLIList <LoopSM*> idealize_loopSM_list;
   13008 [ #  # ][ #  # ]:          0 :     for(y=0;y<sheet_body_idealize_surface.size();y++)
   13009                 :            :     {
   13010 [ #  # ][ #  # ]:          0 :             sheet_body_idealize_surface[y]->loopsms(idealize_loopSM_list);
   13011                 :            :     }
   13012         [ #  # ]:          0 :     sheet_body_idealize_surface.clean_out();
   13013                 :            : 
   13014                 :            :     //this section is going to remove all excluded curves loopsm from the 'master' loopsm list
   13015 [ #  # ][ #  # ]:          0 :     if(exclude_entity.size()>0)
   13016                 :            :     {
   13017                 :            :         //cast the exclude DLIList<RefEntity> to DLIList<RefEdge>
   13018         [ #  # ]:          0 :         DLIList<RefEdge*> exclude_edge;
   13019 [ #  # ][ #  # ]:          0 :         CAST_LIST(exclude_entity, exclude_edge, RefEdge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   13020                 :            : 
   13021                 :            :         //switching the DLIList<RefEdge> to DLIList<Curve>
   13022 [ #  # ][ #  # ]:          0 :         DLIList<Curve*> exclude_cuves;
                 [ #  # ]
   13023                 :            :         GeometryModifyEngine* gme_ptr1;
   13024         [ #  # ]:          0 :         gme_ptr1 = tweak_setup(exclude_edge,"idealize",old_body_list,exclude_cuves);
   13025         [ #  # ]:          0 :         if (NULL == gme_ptr1) {
   13026 [ #  # ][ #  # ]:          0 :           PRINT_ERROR("Unexpected NULL GeometryModifyEngine pointer.\n");
         [ #  # ][ #  # ]
   13027                 :          0 :           return CUBIT_FAILURE;
   13028                 :            :         }
   13029         [ #  # ]:          0 :         exclude_edge.clean_out();
   13030                 :            : 
   13031                 :            :         //grabbing all the curve loops from the given excluded curves
   13032 [ #  # ][ #  # ]:          0 :         DLIList <LoopSM*> exclude_loops;
         [ #  # ][ #  # ]
   13033 [ #  # ][ #  # ]:          0 :         for(y=0;y<exclude_cuves.size();y++)
   13034                 :            :         {
   13035 [ #  # ][ #  # ]:          0 :             exclude_cuves[y]->loopsms(exclude_loops);
   13036                 :            :         }
   13037         [ #  # ]:          0 :         exclude_cuves.clean_out();
   13038                 :            : 
   13039                 :            :         //remove the excluded loops from the list of sheet body loopsms
   13040         [ #  # ]:          0 :         idealize_loopSM_list -= exclude_loops;
   13041                 :            :     }
   13042                 :            : 
   13043                 :            :     //removing all the external loops from the list as they will not be tweak removed
   13044 [ #  # ][ #  # ]:          0 :     DLIList <LoopSM*> possible_internal_LoopSM_list;
   13045 [ #  # ][ #  # ]:          0 :     for(y=0;y<idealize_loopSM_list.size();y++)
   13046                 :            :     {
   13047 [ #  # ][ #  # ]:          0 :         if(idealize_loopSM_list[y]->loop_type() == LOOP_TYPE_HOLE)
                 [ #  # ]
   13048                 :            :         {
   13049 [ #  # ][ #  # ]:          0 :             possible_internal_LoopSM_list.append(idealize_loopSM_list[y]);
   13050                 :            :         }
   13051                 :            :     }
   13052         [ #  # ]:          0 :     idealize_loopSM_list.clean_out();
   13053 [ #  # ][ #  # ]:          0 :     DLIList <Curve*> hole_curves_to_remove;          //hole_curves_to_remove is the curves selected for removal out of the 'hole' search algorithm
   13054 [ #  # ][ #  # ]:          0 :     DLIList <Curve*> master_curve_remove_list;
   13055 [ #  # ][ #  # ]:          0 :     DLIList <LoopSM*> arc_LoopSM_list;
   13056 [ #  # ][ #  # ]:          0 :     DLIList <Surface*> temp_list;
   13057                 :            : 
   13058                 :            :     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   13059                 :            :     //this begins the hole search algorithm
   13060                 :            :     //if no arc radius given, skip hole search algorithm
   13061         [ #  # ]:          0 :     if(arc_radius!=CUBIT_DBL_MAX)
   13062                 :            :     {
   13063         [ #  # ]:          0 :         DLIList <LoopSM*> not_hole_loop;        //loops which don't meet the all curves are arc type filter
   13064 [ #  # ][ #  # ]:          0 :         DLIList <Curve*> possible_internal_arcs;
   13065                 :            : 
   13066                 :            :         //search through possible internal curves filtering only for curves of type arc
   13067                 :            :         //if one of the curves in a loop is not an arc, add that loop to the not_hole_loop list
   13068 [ #  # ][ #  # ]:          0 :         for(y=0;y<possible_internal_LoopSM_list.size();y++)
   13069                 :            :         {
   13070         [ #  # ]:          0 :             possible_internal_arcs.clean_out();
   13071 [ #  # ][ #  # ]:          0 :             possible_internal_LoopSM_list[y]->curves(possible_internal_arcs);
   13072 [ #  # ][ #  # ]:          0 :             for(i=0;i<possible_internal_arcs.size();i++)
   13073                 :            :             {
   13074         [ #  # ]:          0 :                 temp_list.clean_out();
   13075 [ #  # ][ #  # ]:          0 :                 possible_internal_arcs[i]->surfaces(temp_list);
   13076                 :            :                 //check whether or not curve is of arc type and whether it is attached to more than one surface
   13077 [ #  # ][ #  # ]:          0 :                 if( possible_internal_arcs[i]->geometry_type() != ARC_CURVE_TYPE || temp_list.size() != 1)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   13078                 :            :                 {
   13079 [ #  # ][ #  # ]:          0 :                     not_hole_loop.append(possible_internal_LoopSM_list[y]);
   13080                 :          0 :                     break;
   13081                 :            :                 }
   13082                 :            :             }
   13083                 :            :         }
   13084                 :            : 
   13085                 :            :         //change name of possible_internal_LoopSM_list to arc_LoopSM_list
   13086         [ #  # ]:          0 :         arc_LoopSM_list = possible_internal_LoopSM_list;
   13087                 :            :         //subtract from the possible loops the loops which don't have curves which are all arcs or are attached to more than two surfaces
   13088         [ #  # ]:          0 :         arc_LoopSM_list-=not_hole_loop;
   13089         [ #  # ]:          0 :         not_hole_loop.clean_out();
   13090                 :            : 
   13091                 :            :         //this next filter checks to make sure that all arcs of the same loop share the same
   13092                 :            :         //radius center within the geometry tolerance
   13093 [ #  # ][ #  # ]:          0 :         CubitVector arc_center_point, arc_center_point1;
   13094 [ #  # ][ #  # ]:          0 :         DLIList <LoopSM*> not_center_arc_loop;
   13095                 :            :         double rad_distance, temp_arc_radius , temp_arc_radius1;
   13096                 :            : 
   13097                 :            :         //this for loop is going to check that each loops arc curves have the same center radius point
   13098                 :            :         //if not you can remove that loop as a possibility for being added to the tweak_remove command
   13099 [ #  # ][ #  # ]:          0 :         for(y=0;y<arc_LoopSM_list.size();y++)
   13100                 :            :         {
   13101                 :            :             //clean out curve list before grabbing a new loop
   13102         [ #  # ]:          0 :             hole_curves_to_remove.clean_out();
   13103 [ #  # ][ #  # ]:          0 :             arc_LoopSM_list[y]->curves(hole_curves_to_remove);
   13104                 :            :             //iterate across the hole_curves_to_remove size
   13105 [ #  # ][ #  # ]:          0 :             for (i=0;i<hole_curves_to_remove.size();i++)
   13106                 :            :             {
   13107                 :            :                 //if you are on the first index, we need to set a baseline radius point
   13108         [ #  # ]:          0 :                 if(i==0)
   13109                 :            :                 {
   13110 [ #  # ][ #  # ]:          0 :                     hole_curves_to_remove[i]->get_center_radius(arc_center_point,temp_arc_radius);
   13111                 :            :                     //if this is the only arc in the loop go ahead and check if it meets specified arc parameter
   13112                 :            :                     //if it doesn't meet the users parameter add the loop to the not_center_arc_loop list
   13113 [ #  # ][ #  # ]:          0 :                     if(temp_arc_radius >= arc_radius && hole_curves_to_remove.size()==1)
         [ #  # ][ #  # ]
   13114                 :            :                     {
   13115 [ #  # ][ #  # ]:          0 :                         not_center_arc_loop.append(arc_LoopSM_list[y]);
   13116                 :          0 :                         break;
   13117                 :            :                     }
   13118                 :            :                 }
   13119                 :            :                 //now compare the other arc center points to the baseline, if it ever fails the users parameter
   13120                 :            :                 //add the loop to the not_center_arc_loop list
   13121                 :            :                 else
   13122                 :            :                 {
   13123 [ #  # ][ #  # ]:          0 :                     hole_curves_to_remove[i]->get_center_radius(arc_center_point1,temp_arc_radius1);
   13124         [ #  # ]:          0 :                     rad_distance = arc_center_point.distance_between_squared(arc_center_point1);
   13125 [ #  # ][ #  # ]:          0 :                     if(rad_distance > geo_tol || temp_arc_radius >= arc_radius)
   13126                 :            :                     {
   13127 [ #  # ][ #  # ]:          0 :                         not_center_arc_loop.append(arc_LoopSM_list[y]);
   13128                 :          0 :                         break;
   13129                 :            :                     }
   13130                 :            :                 }
   13131                 :            :             }
   13132                 :            :         }
   13133                 :            : 
   13134                 :            :         //remove loops which didn't have perfect circular holes from the arc_loopsm_list
   13135         [ #  # ]:          0 :         arc_LoopSM_list -= not_center_arc_loop;
   13136 [ #  # ][ #  # ]:          0 :         for(y=0;y<arc_LoopSM_list.size();y++)
   13137                 :            :         {
   13138 [ #  # ][ #  # ]:          0 :             arc_LoopSM_list[y]->curves(hole_curves_to_remove);
   13139                 :            :         }
   13140 [ #  # ][ #  # ]:          0 :         master_curve_remove_list+=hole_curves_to_remove;
   13141                 :            :     }
   13142                 :            : 
   13143                 :            :     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   13144                 :            :     //this begins the slot search algorithm
   13145 [ #  # ][ #  # ]:          0 :     DLIList<LoopSM*> removable_slot_loop;
   13146 [ #  # ][ #  # ]:          0 :     if(slot_arc_radius!=CUBIT_DBL_MAX || slot_length!=CUBIT_DBL_MAX)
   13147                 :            :     {
   13148         [ #  # ]:          0 :         DLIList<LoopSM*> four_curve_possible_slot;
   13149 [ #  # ][ #  # ]:          0 :         DLIList<LoopSM*> possible_slot;
   13150 [ #  # ][ #  # ]:          0 :         DLIList<Curve*> internal_curves_in_loop;
   13151                 :            : 
   13152                 :            :         //checks to make sure the loop has only four curves - may want to expand this in the future
   13153 [ #  # ][ #  # ]:          0 :         for(y=0;y<possible_internal_LoopSM_list.size();y++)
   13154                 :            :         {
   13155 [ #  # ][ #  # ]:          0 :             possible_internal_LoopSM_list[y]->curves(internal_curves_in_loop);
   13156 [ #  # ][ #  # ]:          0 :             if(internal_curves_in_loop.size()==4)
   13157                 :            :             {
   13158 [ #  # ][ #  # ]:          0 :                 four_curve_possible_slot.append(possible_internal_LoopSM_list[y]);
   13159                 :            :             }
   13160         [ #  # ]:          0 :             internal_curves_in_loop.clean_out();
   13161                 :            :         }
   13162                 :            : 
   13163                 :            : 
   13164                 :            :         //check to make sure it alternates straight line, arc, etc...
   13165 [ #  # ][ #  # ]:          0 :         for(y=0;y<four_curve_possible_slot.size();y++)
   13166                 :            :         {
   13167 [ #  # ][ #  # ]:          0 :             four_curve_possible_slot[y]->curves(internal_curves_in_loop);
   13168                 :            : 
   13169 [ #  # ][ #  # ]:          0 :             if(internal_curves_in_loop[0]->geometry_type() == ARC_CURVE_TYPE &&
         [ #  # ][ #  # ]
   13170 [ #  # ][ #  # ]:          0 :                 internal_curves_in_loop[1]->geometry_type() == STRAIGHT_CURVE_TYPE &&
                 [ #  # ]
   13171 [ #  # ][ #  # ]:          0 :                 internal_curves_in_loop[2]->geometry_type() == ARC_CURVE_TYPE &&
         [ #  # ][ #  # ]
   13172 [ #  # ][ #  # ]:          0 :                 internal_curves_in_loop[3]->geometry_type() == STRAIGHT_CURVE_TYPE)
   13173                 :            :             {
   13174                 :          0 :                 int num_of_surfs=0;
   13175 [ #  # ][ #  # ]:          0 :                 for(i=0;i<internal_curves_in_loop.size();i++)
   13176                 :            :                 {
   13177         [ #  # ]:          0 :                     temp_list.clean_out();
   13178 [ #  # ][ #  # ]:          0 :                     internal_curves_in_loop[i]->surfaces(temp_list);
   13179         [ #  # ]:          0 :                     num_of_surfs=num_of_surfs + temp_list.size();
   13180                 :            :                 }
   13181         [ #  # ]:          0 :                 if(num_of_surfs==4)
   13182                 :            :                 {
   13183 [ #  # ][ #  # ]:          0 :                     possible_slot.append(four_curve_possible_slot[y]);
   13184                 :            :                 }
   13185                 :            :             }
   13186 [ #  # ][ #  # ]:          0 :             else if(internal_curves_in_loop[0]->geometry_type() == STRAIGHT_CURVE_TYPE &&
         [ #  # ][ #  # ]
   13187 [ #  # ][ #  # ]:          0 :                 internal_curves_in_loop[1]->geometry_type() == ARC_CURVE_TYPE &&
                 [ #  # ]
   13188 [ #  # ][ #  # ]:          0 :                 internal_curves_in_loop[2]->geometry_type() == STRAIGHT_CURVE_TYPE &&
         [ #  # ][ #  # ]
   13189 [ #  # ][ #  # ]:          0 :                 internal_curves_in_loop[3]->geometry_type() == ARC_CURVE_TYPE)
   13190                 :            :             {
   13191                 :          0 :                 int num_of_surfs=0;
   13192 [ #  # ][ #  # ]:          0 :                 for(i=0;i<internal_curves_in_loop.size();i++)
   13193                 :            :                 {
   13194         [ #  # ]:          0 :                     temp_list.clean_out();
   13195 [ #  # ][ #  # ]:          0 :                     internal_curves_in_loop[i]->surfaces(temp_list);
   13196         [ #  # ]:          0 :                     num_of_surfs=num_of_surfs + temp_list.size();
   13197                 :            :                 }
   13198         [ #  # ]:          0 :                 if(num_of_surfs==4)
   13199                 :            :                 {
   13200 [ #  # ][ #  # ]:          0 :                     possible_slot.append(four_curve_possible_slot[y]);
   13201                 :            :                 }
   13202                 :            :             }
   13203         [ #  # ]:          0 :             internal_curves_in_loop.clean_out();
   13204                 :            :         }
   13205                 :            : 
   13206         [ #  # ]:          0 :         CubitVector arc_center_point;
   13207                 :          0 :         double temp_arc_radius = CUBIT_DBL_MAX, curve_length = CUBIT_DBL_MAX;
   13208                 :            : 
   13209                 :            :         //check to make sure that the rad and/or length meet users parameters
   13210 [ #  # ][ #  # ]:          0 :         for(y=0;y<possible_slot.size();y++)
   13211                 :            :         {
   13212 [ #  # ][ #  # ]:          0 :             possible_slot[y]->curves(internal_curves_in_loop);
   13213                 :            :             //if user specified rad, then passed rad_counter should = 2 after for loop completes
   13214                 :            :             //if length specified, length_counter should =2 after for loop completes
   13215                 :          0 :             int rad_counter = 0, length_counter = 0;
   13216 [ #  # ][ #  # ]:          0 :             for(i=0;i<internal_curves_in_loop.size();i++)
   13217                 :            :             {
   13218                 :            :                 //if curve is an arc and user specified a radius enter if statement
   13219 [ #  # ][ #  # ]:          0 :                 if( internal_curves_in_loop[i]->geometry_type() == ARC_CURVE_TYPE && slot_arc_radius!=CUBIT_DBL_MAX )
         [ #  # ][ #  # ]
                 [ #  # ]
   13220                 :            :                 {
   13221                 :            :                     //check the radius against the user inputed value
   13222 [ #  # ][ #  # ]:          0 :                     internal_curves_in_loop[i]->get_center_radius(arc_center_point,temp_arc_radius);
   13223         [ #  # ]:          0 :                     if(temp_arc_radius <= slot_arc_radius)
   13224                 :            :                     {
   13225                 :            :                         //if it passes rad test, add to rad_counter
   13226                 :          0 :                         rad_counter++;
   13227                 :            :                     }
   13228                 :            :                 }
   13229 [ #  # ][ #  # ]:          0 :                 else if(internal_curves_in_loop[i]->geometry_type() == STRAIGHT_CURVE_TYPE && slot_length!=CUBIT_DBL_MAX )
         [ #  # ][ #  # ]
                 [ #  # ]
   13230                 :            :                 {
   13231                 :            :                     //check the length against the user inputed value
   13232 [ #  # ][ #  # ]:          0 :                     curve_length = internal_curves_in_loop[i]->get_arc_length();
   13233         [ #  # ]:          0 :                     if(curve_length <= slot_length)
   13234                 :            :                     {
   13235                 :            :                         //if it passes rad test, add to length_counter
   13236                 :          0 :                         length_counter++;
   13237                 :            :                     }
   13238                 :            :                 }
   13239                 :            :             }
   13240                 :            : 
   13241                 :            :             //checks that if user specified length and radius constraint that its parameter passes for all four curves
   13242 [ #  # ][ #  # ]:          0 :             if(slot_length!=CUBIT_DBL_MAX && slot_arc_radius!=CUBIT_DBL_MAX  && rad_counter==2 && length_counter==2)
         [ #  # ][ #  # ]
   13243                 :            :             {
   13244 [ #  # ][ #  # ]:          0 :                 removable_slot_loop.append(possible_slot[y]);
   13245                 :            :             }
   13246                 :            : 
   13247                 :            :             //if user only specified one length or arc parameter, it only needs to meet 2 criteria
   13248 [ #  # ][ #  # ]:          0 :             else if((slot_length!=CUBIT_DBL_MAX  && length_counter==2) || (slot_arc_radius!=CUBIT_DBL_MAX  && rad_counter==2))
         [ #  # ][ #  # ]
   13249                 :            :             {
   13250 [ #  # ][ #  # ]:          0 :                 removable_slot_loop.append(possible_slot[y]);
   13251                 :            :             }
   13252         [ #  # ]:          0 :             internal_curves_in_loop.clean_out();
   13253                 :            :         }
   13254                 :            :         //add removable loops curves to the master_curve_remove_list list
   13255 [ #  # ][ #  # ]:          0 :         for(y=0;y<removable_slot_loop.size();y++)
   13256                 :            :         {
   13257 [ #  # ][ #  # ]:          0 :             removable_slot_loop[y]->curves(master_curve_remove_list);
   13258         [ #  # ]:          0 :         }
   13259                 :            :     }
   13260                 :            : 
   13261                 :            :     //if no arcs are found to be removed, warn the user.
   13262 [ #  # ][ #  # ]:          0 :     if(master_curve_remove_list.size()==0)
   13263                 :            :     {
   13264                 :            :         //I'm returning success here even though no curves were found
   13265                 :            :         {
   13266 [ #  # ][ #  # ]:          0 :             PRINT_INFO( "Failed to find any feature(s) which met user requirements\n\n" );
         [ #  # ][ #  # ]
   13267                 :            :         }
   13268                 :          0 :         return CUBIT_SUCCESS;
   13269                 :            :     }
   13270         [ #  # ]:          0 :     else if(preview == CUBIT_TRUE)
   13271                 :            :     {
   13272         [ #  # ]:          0 :         GfxPreview::clear();
   13273                 :            : 
   13274 [ #  # ][ #  # ]:          0 :         for(i=0; i<master_curve_remove_list.size();i++)
   13275                 :            :         {
   13276                 :            :             CubitStatus result;
   13277         [ #  # ]:          0 :             GMem g_mem;
   13278                 :            : 
   13279                 :            :             // get the graphics
   13280 [ #  # ][ #  # ]:          0 :             result = master_curve_remove_list[i]->get_geometry_query_engine()->
   13281 [ #  # ][ #  # ]:          0 :                 get_graphics( master_curve_remove_list[i], &g_mem );
   13282                 :            : 
   13283 [ #  # ][ #  # ]:          0 :             if (result==CUBIT_FAILURE || g_mem.pointListCount == 0)
   13284                 :            :             {
   13285 [ #  # ][ #  # ]:          0 :                 PRINT_WARNING("Unable to preview a curve\n" );
         [ #  # ][ #  # ]
   13286         [ #  # ]:          0 :                 double len = master_curve_remove_list[i]->
   13287 [ #  # ][ #  # ]:          0 :                     length_from_u(master_curve_remove_list[i]->start_param(),master_curve_remove_list[i]->end_param());
         [ #  # ][ #  # ]
                 [ #  # ]
   13288                 :            : 
   13289 [ #  # ][ #  # ]:          0 :                 PRINT_WARNING("Curve len: %f\n",len);
         [ #  # ][ #  # ]
   13290                 :            :             }
   13291                 :            : 
   13292                 :            :             // Draw the polyline
   13293 [ #  # ][ #  # ]:          0 :             GfxPreview::draw_polyline( g_mem.point_list(), g_mem.pointListCount, CUBIT_BLUE_INDEX );
   13294                 :            : 
   13295         [ #  # ]:          0 :         }
   13296                 :            : 
   13297                 :            :         //output the number of holes or slots which were found
   13298 [ #  # ][ #  # ]:          0 :         PRINT_INFO("Found %d holes and %d slots which met idealization parameters\n\n", arc_LoopSM_list.size(),removable_slot_loop.size());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   13299         [ #  # ]:          0 :         GfxPreview::flush();
   13300                 :          0 :         return CUBIT_SUCCESS;
   13301                 :            :     }
   13302                 :            :     else
   13303                 :            :     {
   13304         [ #  # ]:          0 :         DLIList<BodySM*> new_bodysm_list;
   13305                 :            :         //pass master_curve_remove_list to the tweak_remove command
   13306         [ #  # ]:          0 :         CubitStatus stat = gme_ptr->tweak_remove(master_curve_remove_list, new_bodysm_list,CUBIT_FALSE, CUBIT_FALSE );
   13307         [ #  # ]:          0 :         if (CUBIT_SUCCESS != stat) {
   13308 [ #  # ][ #  # ]:          0 :           PRINT_ERROR("GeometryModifyEngine::tweak_remove failed.\n");
         [ #  # ][ #  # ]
   13309                 :          0 :           return stat;
   13310                 :            :         }
   13311                 :            : 
   13312                 :            :         //update DAG
   13313 [ #  # ][ #  # ]:          0 :         DLIList<Body*> new_body_list;
   13314         [ #  # ]:          0 :         stat = finish_sm_op( old_body_list, new_bodysm_list ,new_body_list );
   13315                 :            :         //output the number of holes or slots which were found
   13316 [ #  # ][ #  # ]:          0 :         PRINT_INFO("Found %d holes, and %d slots which met idealization parameters\n\n", arc_LoopSM_list.size(), removable_slot_loop.size());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   13317         [ #  # ]:          0 :         return CUBIT_SUCCESS;
   13318         [ #  # ]:          0 :     }
   13319                 :            : }
   13320                 :            : 
   13321                 :            : //=============================================================================
   13322                 :            : // Description: Create drop down surfaces from the external edges of a surface to another surface with options
   13323                 :            : //              Use it primarially when you have a doubler plate situation and you need
   13324                 :            : //              to connect them together with surfaces to represent a weld
   13325                 :            : // Author     : Jonathan Bugman
   13326                 :            : // Date       : 02/07/2008
   13327                 :            : //=============================================================================
   13328                 :          0 : CubitStatus GeometryModifyTool::create_surface_doubler(DLIList<RefEntity*> doubler_entity,
   13329                 :            :                                                        DLIList<RefEntity*> target_entity,
   13330                 :            :                                                        DLIList<Body*> &body_list_out,
   13331                 :            :                                                        CubitBoolean internal_flg,
   13332                 :            :                                                        CubitBoolean extend_flg,
   13333                 :            :                                                        CubitPlane *limit_plane,
   13334                 :            :                                                        CubitVector sweep_direction,
   13335                 :            :                                                        CubitBoolean preview)
   13336                 :            : {
   13337                 :            :         //need to switch the DLIList<RefEntity> to a DLIList<RefFace>
   13338         [ #  # ]:          0 :         DLIList<RefFace*> doubler_face;
   13339 [ #  # ][ #  # ]:          0 :         DLIList<RefFace*> target_face;
   13340 [ #  # ][ #  # ]:          0 :         CAST_LIST( doubler_entity, doubler_face, RefFace);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   13341 [ #  # ][ #  # ]:          0 :         CAST_LIST( target_entity, target_face, RefFace);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   13342                 :            : 
   13343 [ #  # ][ #  # ]:          0 :   bool enable_undo = CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE;
                 [ #  # ]
   13344         [ #  # ]:          0 :   if(enable_undo)
   13345                 :            :   {
   13346         [ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file(doubler_face);
   13347                 :            :   }
   13348                 :            : 
   13349 [ #  # ][ #  # ]:          0 :         DLIList <Surface*> doubler_surface;
   13350 [ #  # ][ #  # ]:          0 :         DLIList <Surface*> target_surface;
   13351 [ #  # ][ #  # ]:          0 :         DLIList <Body*> old_body_list;
   13352 [ #  # ][ #  # ]:          0 :         DLIList<RefFace*> tweak_face;
   13353 [ #  # ][ #  # ]:          0 :         DLIList<Surface*> tweak_surface;
   13354         [ #  # ]:          0 :         tweak_face+=doubler_face;
   13355         [ #  # ]:          0 :         tweak_face+=target_face;
   13356                 :            :         GeometryModifyEngine* gme_ptr;
   13357                 :          0 :     int ii=0, i=0;
   13358                 :            : 
   13359         [ #  # ]:          0 :         gme_ptr = tweak_setup(tweak_face,"doubler",old_body_list,tweak_surface);
   13360                 :            :     int z;
   13361 [ #  # ][ #  # ]:          0 :         for(z=0;z<doubler_face.size();z++)
   13362                 :            :         {
   13363 [ #  # ][ #  # ]:          0 :                 doubler_surface.append(tweak_surface[z]);
   13364                 :            :         }
   13365 [ #  # ][ #  # ]:          0 :   for(z=doubler_face.size();z<tweak_face.size();z++)
                 [ #  # ]
   13366                 :            :     {
   13367 [ #  # ][ #  # ]:          0 :         target_surface.append(tweak_surface[z]);
   13368                 :            :     }
   13369                 :            : 
   13370 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> all_kept_bodies;
   13371 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> body_convert;
   13372 [ #  # ][ #  # ]:          0 :     DLIList<Surface*> copied_doubler_surface;
   13373 [ #  # ][ #  # ]:          0 :     DLIList <BodySM*> tweak_target_bodySM;
   13374                 :            : 
   13375 [ #  # ][ #  # ]:          0 :     for(z=0;z<doubler_surface.size();z++)
   13376                 :            :     {
   13377 [ #  # ][ #  # ]:          0 :         copied_doubler_surface.append(gme_ptr->make_Surface(doubler_surface[z]));
                 [ #  # ]
   13378 [ #  # ][ #  # ]:          0 :         body_convert.append(copied_doubler_surface[z]->bodysm());
                 [ #  # ]
   13379                 :            :     }
   13380                 :            : 
   13381                 :            :     //each workflow is dependent on whether or not a sweep_direction is specified
   13382 [ #  # ][ #  # ]:          0 :     if(sweep_direction == CubitVector(0,0,0))
                 [ #  # ]
   13383                 :            :     {
   13384         [ #  # ]:          0 :                 DLIList<BodySM*> united_bodies;
   13385 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> separate_bodies;
                 [ #  # ]
   13386                 :            :                 //this section takes all the doublers, unites them, and then splits them.  If only one body
   13387                 :            :                 //then skip the aforementioned two steps.
   13388 [ #  # ][ #  # ]:          0 :                 if(doubler_surface.size()==1)
   13389                 :            :                 {
   13390         [ #  # ]:          0 :                         separate_bodies=body_convert;
   13391                 :            :                 }
   13392                 :            :                 else
   13393                 :            :                 {
   13394 [ #  # ][ #  # ]:          0 :                         if(gme_ptr->unite(body_convert,united_bodies) == CUBIT_FAILURE || united_bodies.size()==0 )
         [ #  # ][ #  # ]
                 [ #  # ]
   13395                 :            :                         {
   13396 [ #  # ][ #  # ]:          0 :                                 PRINT_ERROR( "Command failed at unite command\n" );
         [ #  # ][ #  # ]
   13397                 :            : 
   13398         [ #  # ]:          0 :         if(enable_undo)
   13399         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   13400                 :            : 
   13401                 :          0 :                                 return CUBIT_FAILURE;
   13402                 :            :                         }
   13403                 :            : 
   13404 [ #  # ][ #  # ]:          0 :                         if(gme_ptr->split_body(united_bodies[0],separate_bodies) == CUBIT_FAILURE || separate_bodies.size()==0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   13405                 :            :                         {
   13406 [ #  # ][ #  # ]:          0 :                                 PRINT_ERROR( "Command failed at separate command\n" );
         [ #  # ][ #  # ]
   13407                 :            : 
   13408         [ #  # ]:          0 :         if(enable_undo)
   13409         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   13410                 :            : 
   13411                 :          0 :                                 return CUBIT_FAILURE;
   13412                 :            :                         }
   13413                 :            :                 }
   13414 [ #  # ][ #  # ]:          0 :                 for(z=0; z<separate_bodies.size();z++)
         [ #  # ][ #  # ]
   13415                 :            :                 {
   13416         [ #  # ]:          0 :                         DLIList<Surface*> body_surface;
   13417 [ #  # ][ #  # ]:          0 :                         separate_bodies[z]->surfaces(body_surface);
   13418                 :            : 
   13419 [ #  # ][ #  # ]:          0 :                         DLIList<CubitVector> doubler_surface_center_points;
                 [ #  # ]
   13420                 :          0 :                         int d=0;
   13421 [ #  # ][ #  # ]:          0 :                         for(d=0;d<body_surface.size();d++)
   13422                 :            :                         {
   13423 [ #  # ][ #  # ]:          0 :                                 doubler_surface_center_points.append(body_surface[d]->bounding_box().center());
         [ #  # ][ #  # ]
                 [ #  # ]
   13424                 :            :                         }
   13425 [ #  # ][ #  # ]:          0 :                         CubitVector doubler_normal,doubler_center_pt,doubler_to_target_vector,target_center_pt;
         [ #  # ][ #  # ]
   13426                 :          0 :                         double extrude_distance = 0.0;
   13427                 :            : 
   13428                 :            :                         //make sure that the normal of the surface is pointing towards the target surface
   13429                 :            :                         //the thicken command thickens in the direction of the surface normal, normals are checked using dot product check
   13430 [ #  # ][ #  # ]:          0 :                         CubitVector center_pt = body_surface[0]->bounding_box().center();
         [ #  # ][ #  # ]
   13431 [ #  # ][ #  # ]:          0 :                         body_surface[0]->closest_point(center_pt,&doubler_center_pt,&doubler_normal);
   13432                 :            :             //adding this for loop because of l bracket doublers may have the first target surface perpendicular to an opposite side doubler surface
   13433                 :            :             //resulting in the code erroneously failing
   13434                 :          0 :             double dot=0.0;
   13435                 :            :             int mm;
   13436 [ #  # ][ #  # ]:          0 :             for(mm=0; mm<target_surface.size();mm++)
   13437                 :            :             {
   13438 [ #  # ][ #  # ]:          0 :                 target_surface[mm]->closest_point_trimmed(doubler_center_pt, target_center_pt);
                 [ #  # ]
   13439 [ #  # ][ #  # ]:          0 :                 doubler_to_target_vector = target_center_pt - doubler_center_pt;
   13440 [ #  # ][ #  # ]:          0 :                 dot = doubler_to_target_vector.x()*doubler_normal.x()+doubler_to_target_vector.y()*doubler_normal.y()+doubler_to_target_vector.z()*doubler_normal.z();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   13441         [ #  # ]:          0 :                 if(fabs(dot)>1E-6)
   13442                 :            :                 {
   13443         [ #  # ]:          0 :                     mm=target_surface.size();
   13444                 :            :                 }
   13445                 :            :             }
   13446         [ #  # ]:          0 :             if(fabs(dot)<1E-6)
   13447                 :            :             {
   13448 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Doubler and target surface are touching or are perpendicular to each other\n" );
         [ #  # ][ #  # ]
   13449 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<separate_bodies.size();ii++)
   13450                 :            :                 {
   13451 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = separate_bodies[ii]->get_geometry_query_engine();
   13452 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(separate_bodies[ii]);
   13453                 :            :                 }
   13454                 :            : 
   13455         [ #  # ]:          0 :                 if(enable_undo)
   13456         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   13457                 :            : 
   13458                 :          0 :                 return CUBIT_FAILURE;
   13459                 :            :             }
   13460         [ #  # ]:          0 :             else if(dot < 0)
   13461                 :            :             {
   13462 [ #  # ][ #  # ]:          0 :                 if(gme_ptr->reverse_body(separate_bodies[z])==CUBIT_FAILURE)
                 [ #  # ]
   13463                 :            :                 {
   13464 [ #  # ][ #  # ]:          0 :                     PRINT_ERROR( "Command failed at reverse body command.\n" );
         [ #  # ][ #  # ]
   13465 [ #  # ][ #  # ]:          0 :                     for(ii =0;ii<separate_bodies.size();ii++)
   13466                 :            :                     {
   13467 [ #  # ][ #  # ]:          0 :                         GeometryQueryEngine* gqe = separate_bodies[ii]->get_geometry_query_engine();
   13468 [ #  # ][ #  # ]:          0 :                         gqe->delete_solid_model_entities(separate_bodies[ii]);
   13469                 :            :                     }
   13470                 :            : 
   13471         [ #  # ]:          0 :                     if(enable_undo)
   13472         [ #  # ]:          0 :                       CubitUndo::remove_last_undo();
   13473                 :            : 
   13474                 :          0 :                     return CUBIT_FAILURE;
   13475                 :            :                 }
   13476                 :          0 :                 extrude_distance = 0.0001;
   13477                 :            :             }
   13478                 :            :             else
   13479                 :            :                         {
   13480                 :          0 :                                 extrude_distance = 0.0001;
   13481                 :            :                         }
   13482                 :            : 
   13483 [ #  # ][ #  # ]:          0 :                         DLIList<BodySM*> thickened_doubler_bodySM;
                 [ #  # ]
   13484 [ #  # ][ #  # ]:          0 :                         DLIList<BodySM*> current_body;
                 [ #  # ]
   13485 [ #  # ][ #  # ]:          0 :                         current_body.append(separate_bodies[z]);
   13486                 :            : 
   13487 [ #  # ][ #  # ]:          0 :             if(gme_ptr->thicken(current_body,thickened_doubler_bodySM,extrude_distance,CUBIT_FALSE) == CUBIT_FAILURE || thickened_doubler_bodySM.size()==0)
         [ #  # ][ #  # ]
                 [ #  # ]
   13488                 :            :             {
   13489 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Command failed at thicken command, this may be due to using a non-OCC geometry engine\n" );
         [ #  # ][ #  # ]
   13490 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<separate_bodies.size();ii++)
   13491                 :            :                 {
   13492 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = separate_bodies[ii]->get_geometry_query_engine();
   13493 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(separate_bodies[ii]);
   13494                 :            :                 }
   13495                 :            : 
   13496         [ #  # ]:          0 :                 if(enable_undo)
   13497         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   13498                 :            : 
   13499                 :          0 :                 return CUBIT_FAILURE;
   13500                 :            :             }
   13501                 :            : 
   13502                 :            :                         //need to grab the newly created surface opposite the user selected one from the thicken function to carry it through for the tweak target
   13503 [ #  # ][ #  # ]:          0 :                         DLIList<Surface*> thicken_surfaces;
                 [ #  # ]
   13504 [ #  # ][ #  # ]:          0 :                         thickened_doubler_bodySM[0]->surfaces(thicken_surfaces);
   13505 [ #  # ][ #  # ]:          0 :                         DLIList <Surface*> post_thicken_doublers;
                 [ #  # ]
   13506                 :            : 
   13507                 :          0 :                         int y=0;
   13508 [ #  # ][ #  # ]:          0 :                         for(y=0;y<doubler_surface_center_points.size();y++)
   13509                 :            :                         {
   13510 [ #  # ][ #  # ]:          0 :                                 doubler_center_pt = doubler_surface_center_points[y];
   13511                 :          0 :                                 int r=0;
   13512 [ #  # ][ #  # ]:          0 :                                 for(r=0;r<thicken_surfaces.size();r++)
   13513                 :            :                                 {
   13514 [ #  # ][ #  # ]:          0 :                                         CubitVector test_center_pt = thicken_surfaces[r]->bounding_box().center();
         [ #  # ][ #  # ]
   13515 [ #  # ][ #  # ]:          0 :                                         if((test_center_pt-doubler_center_pt).length()<=.000001)
                 [ #  # ]
   13516                 :            :                                         {
   13517 [ #  # ][ #  # ]:          0 :                                                 post_thicken_doublers.append(thicken_surfaces[r]);
   13518                 :            :                                         }
   13519                 :            :                                 }
   13520                 :            :                         }
   13521                 :            : 
   13522 [ #  # ][ #  # ]:          0 :                         DLIList <LoopSM*> doubler_loopSM_list;
                 [ #  # ]
   13523 [ #  # ][ #  # ]:          0 :                         DLIList <Curve*> doubler_external_curves;
                 [ #  # ]
   13524                 :          0 :                         Curve* test_external_curves1 = NULL;
   13525                 :          0 :                         Curve* test_external_curves2 = NULL;
   13526                 :            : 
   13527                 :            :                         //need to do this in order to grab all curves, not just external IMPORTANT:THIS HAS TO BE DONE BEFORE THE tweak? COMMAND!
   13528 [ #  # ][ #  # ]:          0 :                         for(y=0;y<post_thicken_doublers.size();y++)
   13529                 :            :                         {
   13530 [ #  # ][ #  # ]:          0 :                                 post_thicken_doublers[y]->loopsms(doubler_loopSM_list);
   13531                 :            :                         }
   13532 [ #  # ][ #  # ]:          0 :                         for(i=0;i<doubler_loopSM_list.size();i++)
   13533                 :            :                         {
   13534 [ #  # ][ #  # ]:          0 :                                 doubler_loopSM_list[i]->curves(doubler_external_curves);
   13535                 :            :                         }
   13536                 :            : 
   13537         [ #  # ]:          0 :                         doubler_loopSM_list.clean_out();
   13538         [ #  # ]:          0 :             tweak_target_bodySM.clean_out();
   13539 [ #  # ][ #  # ]:          0 :                         DLIList <LoopSM*> test_loopSM_list;
                 [ #  # ]
   13540 [ #  # ][ #  # ]:          0 :                         DLIList <Curve*> thicken_external_curves;
                 [ #  # ]
   13541 [ #  # ][ #  # ]:          0 :                         DLIList <Surface*> tweak_target_surface = thicken_surfaces;
                 [ #  # ]
   13542                 :            : 
   13543                 :            :             //stepping through the surfaces from the thicken body
   13544 [ #  # ][ #  # ]:          0 :             for(i=0; i < thicken_surfaces.size(); i++)
   13545                 :            :             {
   13546 [ #  # ][ #  # ]:          0 :                 thicken_surfaces[i]->loopsms(test_loopSM_list);
   13547                 :            :                 //grabbing the external curves from the current thicken_surface
   13548 [ #  # ][ #  # ]:          0 :                 test_loopSM_list[0]->curves(thicken_external_curves);
   13549         [ #  # ]:          0 :                 test_loopSM_list.clean_out();
   13550                 :          0 :                 int j=0;
   13551 [ #  # ][ #  # ]:          0 :                 for(j=0;j<thicken_external_curves.size();j++)
   13552                 :            :                 {
   13553                 :            :                     //step through the first curve
   13554         [ #  # ]:          0 :                     test_external_curves1 = thicken_external_curves[j];
   13555                 :          0 :                     int k=0;
   13556 [ #  # ][ #  # ]:          0 :                     for(k=0; k<doubler_external_curves.size();k++)
   13557                 :            :                     {
   13558                 :            :                         //while stepping through the doubler plate curves, compare them to the test_test_surface curves
   13559         [ #  # ]:          0 :                         test_external_curves2 = doubler_external_curves[k];
   13560                 :            : 
   13561                 :            :                                                 //if the two are equal, they are touching the doulber and therefore are either the side surfaces or the doubler
   13562         [ #  # ]:          0 :                                                 if(test_external_curves2 == test_external_curves1)
   13563                 :            :                                                 {
   13564                 :            :                                                         //remove the surface from the tweak_target_surface list
   13565 [ #  # ][ #  # ]:          0 :                                                         tweak_target_surface.remove_all_with_value(thicken_surfaces[i]);
   13566                 :          0 :                                                         break;
   13567                 :            :                                                 }
   13568                 :            :                                         }
   13569         [ #  # ]:          0 :                                         if(test_external_curves2 == test_external_curves1)
   13570                 :            :                                         {
   13571                 :          0 :                                                 break;
   13572                 :            :                                         }
   13573                 :            : 
   13574                 :            :                                 }
   13575         [ #  # ]:          0 :                                 thicken_external_curves.clean_out();
   13576                 :            :             }
   13577                 :            : 
   13578                 :            :             //pass the found opposite surface into the tweak_target routine
   13579 [ #  # ][ #  # ]:          0 :             if(gme_ptr->tweak_target(tweak_target_surface,target_surface,tweak_target_bodySM,extend_flg,limit_plane) == CUBIT_FAILURE || tweak_target_bodySM.size()==0)
         [ #  # ][ #  # ]
                 [ #  # ]
   13580                 :            :             {
   13581 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Command failed at Tweak_Target routine\n" );
         [ #  # ][ #  # ]
   13582 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<thickened_doubler_bodySM.size();ii++)
   13583                 :            :                 {
   13584 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = thickened_doubler_bodySM[ii]->get_geometry_query_engine();
   13585 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(thickened_doubler_bodySM[ii]);
   13586                 :            :                 }
   13587                 :            : 
   13588         [ #  # ]:          0 :                 if(enable_undo)
   13589         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   13590                 :            : 
   13591                 :          0 :                 return CUBIT_FAILURE;
   13592                 :            :             }
   13593                 :            : 
   13594                 :            :                         //fill out a tweak_body_surface list from tweak_target routine
   13595 [ #  # ][ #  # ]:          0 :                         DLIList<Surface*> tweak_body_surfaces;
                 [ #  # ]
   13596 [ #  # ][ #  # ]:          0 :                         tweak_target_bodySM[0]->surfaces(tweak_body_surfaces);
   13597 [ #  # ][ #  # ]:          0 :                         DLIList <Curve*> tweak_external_curves;
                 [ #  # ]
   13598         [ #  # ]:          0 :                         doubler_external_curves.clean_out();
   13599                 :            : 
   13600                 :            :                         //refilling DLIList's as needed based on internal_flg
   13601                 :            :                         //if we are not keeping internal surfaces we do not want it's curves in the doubler_external_curves list
   13602                 :            :                         //otherwise if we are, we do want the curves in the list for the following sections for loop
   13603         [ #  # ]:          0 :             if(internal_flg==CUBIT_FALSE)
   13604                 :            :             {
   13605                 :          0 :                 int j=0;
   13606 [ #  # ][ #  # ]:          0 :                 for(i=0;i<post_thicken_doublers.size();i++)
   13607                 :            :                 {
   13608 [ #  # ][ #  # ]:          0 :                     post_thicken_doublers[i]->loopsms(doubler_loopSM_list);
   13609 [ #  # ][ #  # ]:          0 :                     for(j=0;j<doubler_loopSM_list.size();j++)
   13610                 :            :                     {
   13611 [ #  # ][ #  # ]:          0 :                       LoopType loop_type = doubler_loopSM_list[j]->loop_type();
   13612 [ #  # ][ #  # ]:          0 :                       if(loop_type == LOOP_TYPE_EXTERNAL ||
   13613         [ #  # ]:          0 :                          loop_type == LOOP_TYPE_U_PERIODIC ||
   13614                 :            :                          loop_type == LOOP_TYPE_V_PERIODIC)
   13615                 :            :                       {
   13616 [ #  # ][ #  # ]:          0 :                           doubler_loopSM_list[j]->curves(doubler_external_curves);
   13617                 :          0 :                           break;
   13618                 :            :                       }
   13619                 :            :                     }
   13620         [ #  # ]:          0 :                     doubler_loopSM_list.clean_out();
   13621                 :            :                 }
   13622                 :            :             }
   13623                 :            :                         else
   13624                 :            :                         {
   13625 [ #  # ][ #  # ]:          0 :                                 for(i=0;i<post_thicken_doublers.size();i++)
   13626                 :            :                                 {
   13627 [ #  # ][ #  # ]:          0 :                                         post_thicken_doublers[i]->loopsms(doubler_loopSM_list);
   13628                 :            :                                 }
   13629 [ #  # ][ #  # ]:          0 :                                 for(i=0;i<doubler_loopSM_list.size();i++)
   13630                 :            :                                 {
   13631 [ #  # ][ #  # ]:          0 :                                         doubler_loopSM_list[i]->curves(doubler_external_curves);
   13632                 :            :                                 }
   13633                 :            : 
   13634                 :            :                         }
   13635                 :            : 
   13636 [ #  # ][ #  # ]:          0 :             DLIList <Surface*> surfaces_to_keep;
                 [ #  # ]
   13637 [ #  # ][ #  # ]:          0 :             for(i=0;i<tweak_body_surfaces.size();i++)
   13638                 :            :             {
   13639 [ #  # ][ #  # ]:          0 :                 tweak_body_surfaces[i]->loopsms(test_loopSM_list);
   13640                 :            : 
   13641 [ #  # ][ #  # ]:          0 :                 if(test_loopSM_list.size()==0)
   13642                 :            :                 {
   13643 [ #  # ][ #  # ]:          0 :                     PRINT_ERROR( "Command failed to find any doubler drop down curves\n" );
         [ #  # ][ #  # ]
   13644 [ #  # ][ #  # ]:          0 :                     for(ii =0;ii<thickened_doubler_bodySM.size();ii++)
   13645                 :            :                     {
   13646 [ #  # ][ #  # ]:          0 :                         GeometryQueryEngine* gqe = thickened_doubler_bodySM[ii]->get_geometry_query_engine();
   13647 [ #  # ][ #  # ]:          0 :                         gqe->delete_solid_model_entities(thickened_doubler_bodySM[ii]);
   13648                 :            :                     }
   13649                 :            : 
   13650         [ #  # ]:          0 :                     if(enable_undo)
   13651         [ #  # ]:          0 :                       CubitUndo::remove_last_undo();
   13652                 :            : 
   13653                 :          0 :                     return CUBIT_FAILURE;
   13654                 :            :                 }
   13655                 :            : 
   13656 [ #  # ][ #  # ]:          0 :                 test_loopSM_list[0]->curves(tweak_external_curves);
   13657         [ #  # ]:          0 :                 test_loopSM_list.clean_out();
   13658                 :            : 
   13659                 :          0 :                                 int j=0;
   13660 [ #  # ][ #  # ]:          0 :                                 for(j=0;j<tweak_external_curves.size();j++)
   13661                 :            :                                 {
   13662         [ #  # ]:          0 :                                         test_external_curves1 = tweak_external_curves[j];
   13663                 :            : 
   13664                 :          0 :                                         int k=0;
   13665 [ #  # ][ #  # ]:          0 :                                         for(k=0; k<doubler_external_curves.size();k++)
   13666                 :            :                                         {
   13667                 :            :                                                 //while stepping through the doubler plate curves, compare them to the test_loop_list
   13668         [ #  # ]:          0 :                                                 test_external_curves2 = doubler_external_curves[k];
   13669                 :            : 
   13670         [ #  # ]:          0 :                                                 if(test_external_curves2 == test_external_curves1)
   13671                 :            :                                                 {
   13672 [ #  # ][ #  # ]:          0 :                                                         surfaces_to_keep.append(tweak_body_surfaces[i]);
   13673                 :          0 :                                                         break;
   13674                 :            :                                                 }
   13675                 :            :                                         }
   13676         [ #  # ]:          0 :                                         if(test_external_curves2 == test_external_curves1)
   13677                 :            :                                         {
   13678                 :          0 :                                                 break;
   13679                 :            :                                         }
   13680                 :            :                                 }
   13681         [ #  # ]:          0 :                                 tweak_external_curves.clean_out();
   13682                 :            :                         }
   13683                 :            : 
   13684 [ #  # ][ #  # ]:          0 :             if(surfaces_to_keep.size()==0)
   13685                 :            :             {
   13686 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Failed to find and keep surfaces\n" );
         [ #  # ][ #  # ]
   13687 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<tweak_target_bodySM.size();ii++)
   13688                 :            :                 {
   13689 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = tweak_target_bodySM[ii]->get_geometry_query_engine();
   13690 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(tweak_target_bodySM[ii]);
   13691                 :            :                 }
   13692                 :            : 
   13693         [ #  # ]:          0 :                 if(enable_undo)
   13694         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   13695                 :            : 
   13696                 :          0 :                 return CUBIT_FAILURE;
   13697                 :            :             }
   13698                 :            : 
   13699                 :            :                         //do this to remove the copied_doubler_surface since we no longer need the surface anymore
   13700                 :          0 :                         int c=0;
   13701 [ #  # ][ #  # ]:          0 :                         for(c=0;c<post_thicken_doublers.size();c++)
   13702                 :            :                         {
   13703 [ #  # ][ #  # ]:          0 :                                 surfaces_to_keep.remove_all_with_value(post_thicken_doublers[c]);
   13704                 :            :                         }
   13705                 :            : 
   13706 [ #  # ][ #  # ]:          0 :                         DLIList <Surface*> surfaces_to_remove = tweak_body_surfaces;
                 [ #  # ]
   13707         [ #  # ]:          0 :                         surfaces_to_remove -= surfaces_to_keep;
   13708 [ #  # ][ #  # ]:          0 :                         DLIList<BodySM*> resulting_bodies;
                 [ #  # ]
   13709                 :            : 
   13710                 :            :                         //remove all surfaces in the surfaces_to_remove list
   13711 [ #  # ][ #  # ]:          0 :             if(gme_ptr->tweak_remove(surfaces_to_remove,resulting_bodies,CUBIT_FALSE) == CUBIT_FAILURE || resulting_bodies.size()==0)
         [ #  # ][ #  # ]
                 [ #  # ]
   13712                 :            :             {
   13713 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Command failed at Tweak_Remove routine\n" );
         [ #  # ][ #  # ]
   13714 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<tweak_target_bodySM.size();ii++)
   13715                 :            :                 {
   13716 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = tweak_target_bodySM[ii]->get_geometry_query_engine();
   13717 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(tweak_target_bodySM[ii]);
   13718                 :            :                 }
   13719                 :            : 
   13720         [ #  # ]:          0 :                 if(enable_undo)
   13721         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   13722                 :            : 
   13723                 :          0 :                 return CUBIT_FAILURE;
   13724                 :            :             }
   13725 [ #  # ][ #  # ]:          0 :             all_kept_bodies+=resulting_bodies;
                 [ #  # ]
   13726                 :          0 :         }
   13727                 :            :     }
   13728                 :            :         else
   13729                 :            :         {
   13730         [ #  # ]:          0 :                 DLIList<BodySM*> swept_bodies;
   13731 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> swept_doubler_bodySM;
                 [ #  # ]
   13732                 :            : 
   13733                 :            :                 //take the copied_doubler_surface and extrude it along the sweep_direction to create a body
   13734 [ #  # ][ #  # ]:          0 :                 for(z=0;z<copied_doubler_surface.size();z++)
   13735                 :            :                 {
   13736         [ #  # ]:          0 :                         DLIList<GeometryEntity*> DLIList_copied_doubler_surface;
   13737 [ #  # ][ #  # ]:          0 :             DLIList_copied_doubler_surface.append(copied_doubler_surface[z]);
   13738 [ #  # ][ #  # ]:          0 :             if(gme_ptr->sweep_translational(DLIList_copied_doubler_surface,swept_doubler_bodySM,sweep_direction*0.0001,0.0,0,CUBIT_FALSE,CUBIT_FALSE) == CUBIT_FAILURE || swept_doubler_bodySM.size()==0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
   13739                 :            :             {
   13740 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Command failed at sweep->extrude command\n" );
         [ #  # ][ #  # ]
   13741 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<body_convert.size();ii++)
   13742                 :            :                 {
   13743 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = body_convert[ii]->get_geometry_query_engine();
   13744 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(body_convert[ii]);
   13745                 :            :                 }
   13746                 :            : 
   13747         [ #  # ]:          0 :                 if(enable_undo)
   13748         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   13749                 :            : 
   13750                 :          0 :                 return CUBIT_FAILURE;
   13751                 :            :             }
   13752         [ #  # ]:          0 :                         swept_bodies+=swept_doubler_bodySM;
   13753 [ #  # ][ #  # ]:          0 :                         swept_doubler_bodySM.clean_out();
                 [ #  # ]
   13754                 :          0 :                 }
   13755                 :            : 
   13756 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> united_bodies;
                 [ #  # ]
   13757 [ #  # ][ #  # ]:          0 :                 DLIList<BodySM*> separate_bodies;
                 [ #  # ]
   13758                 :            :                 //if more than one body, unite and split the newly created bodies, if only one body skip this step
   13759                 :            :                 //as the unite will fail
   13760 [ #  # ][ #  # ]:          0 :                 if(swept_bodies.size()==1)
   13761                 :            :                 {
   13762         [ #  # ]:          0 :                         separate_bodies=swept_bodies;
   13763                 :            :                 }
   13764                 :            :                 else
   13765                 :            :                 {
   13766 [ #  # ][ #  # ]:          0 :                         if(gme_ptr->unite(swept_bodies,united_bodies) == CUBIT_FAILURE || united_bodies.size()==0 )
         [ #  # ][ #  # ]
                 [ #  # ]
   13767                 :            :                         {
   13768 [ #  # ][ #  # ]:          0 :                                 PRINT_ERROR( "Command failed at unite command\n" );
         [ #  # ][ #  # ]
   13769                 :            : 
   13770         [ #  # ]:          0 :         if(enable_undo)
   13771         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   13772                 :            : 
   13773                 :          0 :                                 return CUBIT_FAILURE;
   13774                 :            :                         }
   13775                 :            : 
   13776 [ #  # ][ #  # ]:          0 :                         if(gme_ptr->split_body(united_bodies[0],separate_bodies) == CUBIT_FAILURE || separate_bodies.size()==0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   13777                 :            :                         {
   13778 [ #  # ][ #  # ]:          0 :                                 PRINT_ERROR( "Command failed at separate command\n" );
         [ #  # ][ #  # ]
   13779                 :            : 
   13780         [ #  # ]:          0 :         if(enable_undo)
   13781         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   13782                 :            : 
   13783                 :          0 :                                 return CUBIT_FAILURE;
   13784                 :            :                         }
   13785                 :            :                 }
   13786                 :            : 
   13787                 :            :                 //create another copy of copied_doubler_surface since copied_doubler_surface is going to be manipulated
   13788 [ #  # ][ #  # ]:          0 :                 DLIList<Surface*> temp_copied_doubler_surface=copied_doubler_surface;
                 [ #  # ]
   13789 [ #  # ][ #  # ]:          0 :                 for(z=0;z<separate_bodies.size();z++)
         [ #  # ][ #  # ]
   13790                 :            :                 {
   13791                 :            :                         //need to grab the newly created surface opposite the user selected one from the thicken function to carry it through for the tweak target
   13792                 :            :                         //this will need to be changed to a for loop to account for multiple thickened bodies if we impliment multiple doubler surfaces
   13793         [ #  # ]:          0 :                         DLIList<Surface*> thicken_surfaces;
   13794 [ #  # ][ #  # ]:          0 :                         separate_bodies[z]->surfaces(thicken_surfaces);
   13795                 :            : 
   13796                 :            :                         //initializing a lot of variables to be used in the next few steps
   13797 [ #  # ][ #  # ]:          0 :                         DLIList<Surface*> master_surface_remove_list;
                 [ #  # ]
   13798 [ #  # ][ #  # ]:          0 :                         DLIList <Curve*> thicken_external_curves;
                 [ #  # ]
   13799 [ #  # ][ #  # ]:          0 :                         DLIList<Surface*> tweak_target_surface;
                 [ #  # ]
   13800 [ #  # ][ #  # ]:          0 :                         DLIList<Surface*> surfaces_to_remove;
                 [ #  # ]
   13801                 :            : 
   13802                 :            :                         //using a centerpoint of the surfaces, I want to find out which surface from the recently swept bodies corresponds to the surface of the body closest the target
   13803                 :            :                         //this has to be done because sweep_translational moves the source surface.  Thicken on the otherhand does and doesn't based on number of surfaces being thickened.
   13804                 :          0 :                         int y=0;
   13805 [ #  # ][ #  # ]:          0 :                         for(y=0;y<temp_copied_doubler_surface.size();y++)
   13806                 :            :                         {
   13807 [ #  # ][ #  # ]:          0 :                                 CubitVector doubler_center_pt = temp_copied_doubler_surface[y]->bounding_box().center();
         [ #  # ][ #  # ]
   13808                 :          0 :                                 int r=0;
   13809 [ #  # ][ #  # ]:          0 :                                 for(r=0;r<thicken_surfaces.size();r++)
   13810                 :            :                                 {
   13811 [ #  # ][ #  # ]:          0 :                                         CubitVector test_center_pt = thicken_surfaces[r]->bounding_box().center();
         [ #  # ][ #  # ]
   13812 [ #  # ][ #  # ]:          0 :                                         if((test_center_pt-doubler_center_pt).length()<=.000001)
                 [ #  # ]
   13813                 :            :                                         {
   13814 [ #  # ][ #  # ]:          0 :                                                 tweak_target_surface.append(thicken_surfaces[r]);
   13815 [ #  # ][ #  # ]:          0 :                                                 surfaces_to_remove.append(temp_copied_doubler_surface[y]);
   13816                 :            :                                         }
   13817                 :            :                                 }
   13818                 :            :                         }
   13819                 :            :                         //remove the manipulated surfaces from the temp_copied_doubler_surface list
   13820         [ #  # ]:          0 :                         temp_copied_doubler_surface-=surfaces_to_remove;
   13821         [ #  # ]:          0 :                         surfaces_to_remove.clean_out();
   13822                 :            : 
   13823                 :            :                         //grab all the curves of the doubler
   13824 [ #  # ][ #  # ]:          0 :                         DLIList <Curve*> doubler_external_curves;
                 [ #  # ]
   13825 [ #  # ][ #  # ]:          0 :                         DLIList <LoopSM*> doubler_loopSM_list;
                 [ #  # ]
   13826 [ #  # ][ #  # ]:          0 :                         for(y=0;y<tweak_target_surface.size();y++)
   13827                 :            :                         {
   13828 [ #  # ][ #  # ]:          0 :                                 tweak_target_surface[y]->loopsms(doubler_loopSM_list);
   13829                 :            :                         }
   13830                 :            : 
   13831 [ #  # ][ #  # ]:          0 :                         for(i=0;i<doubler_loopSM_list.size();i++)
   13832                 :            :                         {
   13833 [ #  # ][ #  # ]:          0 :                                 doubler_loopSM_list[i]->curves(doubler_external_curves);
   13834                 :            :                         }
   13835                 :            : 
   13836 [ #  # ][ #  # ]:          0 :                         DLIList <Surface*> doubler_surface_for_this_body = thicken_surfaces;
                 [ #  # ]
   13837                 :          0 :                         Curve* test_external_curves1 = NULL;
   13838                 :          0 :                         Curve* test_external_curves2 = NULL;
   13839 [ #  # ][ #  # ]:          0 :                         DLIList <LoopSM*> test_loopSM_list;
                 [ #  # ]
   13840                 :            : 
   13841 [ #  # ][ #  # ]:          0 :                         for(i=0; i < thicken_surfaces.size(); i++)
   13842                 :            :                         {
   13843                 :            :                                 //step through the thickened bodies surfaces
   13844 [ #  # ][ #  # ]:          0 :                                 thicken_surfaces[i]->loopsms(test_loopSM_list);
   13845                 :            :                                 //grabbing the external curve loop from the face and making it a DLIList <RefEdge*>
   13846 [ #  # ][ #  # ]:          0 :                                 test_loopSM_list[0]->curves(thicken_external_curves);
   13847                 :            : 
   13848                 :          0 :                                 int j=0;
   13849 [ #  # ][ #  # ]:          0 :                                 for(j=0;j<thicken_external_curves.size();j++)
   13850                 :            :                                 {
   13851                 :            :                                         //step through the loop list
   13852         [ #  # ]:          0 :                                         test_external_curves1 = thicken_external_curves[j];
   13853                 :            : 
   13854                 :          0 :                                         int k=0;
   13855 [ #  # ][ #  # ]:          0 :                                         for(k=0; k<doubler_external_curves.size();k++)
   13856                 :            :                                         {
   13857                 :            :                                                 //while stepping through the doubler plate curves, compare them to the test_loop_list
   13858         [ #  # ]:          0 :                                                 test_external_curves2 = doubler_external_curves[k];
   13859                 :            : 
   13860         [ #  # ]:          0 :                                                 if(test_external_curves2 == test_external_curves1)
   13861                 :            :                                                 {
   13862 [ #  # ][ #  # ]:          0 :                                                         doubler_surface_for_this_body.remove_all_with_value(thicken_surfaces[i]);
   13863                 :          0 :                                                         break;
   13864                 :            :                                                 }
   13865                 :            :                                         }
   13866         [ #  # ]:          0 :                                         if(test_external_curves2 == test_external_curves1)
   13867                 :            :                                         {
   13868                 :          0 :                                                 break;
   13869                 :            :                                         }
   13870                 :            :                                 }
   13871                 :            : 
   13872         [ #  # ]:          0 :                                 thicken_external_curves.clean_out();
   13873         [ #  # ]:          0 :                                 thicken_external_curves.reset();
   13874         [ #  # ]:          0 :                 test_loopSM_list.clean_out();
   13875                 :            :             }
   13876                 :            : 
   13877                 :            :             //DLIList <BodySM*> tweak_target_bodySM
   13878         [ #  # ]:          0 :             tweak_target_bodySM.clean_out();
   13879 [ #  # ][ #  # ]:          0 :             if(gme_ptr->tweak_target(tweak_target_surface,target_surface,tweak_target_bodySM,extend_flg,limit_plane) == CUBIT_FAILURE || tweak_target_bodySM.size()==0)
         [ #  # ][ #  # ]
                 [ #  # ]
   13880                 :            :             {
   13881 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Command failed at Tweak_Target routine\n" );
         [ #  # ][ #  # ]
   13882 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<body_convert.size();ii++)
   13883                 :            :                 {
   13884 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = body_convert[ii]->get_geometry_query_engine();
   13885 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(body_convert[ii]);
   13886                 :            :                 }
   13887                 :            : 
   13888         [ #  # ]:          0 :                 if(enable_undo)
   13889         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   13890                 :            : 
   13891                 :          0 :                 return CUBIT_FAILURE;
   13892                 :            :             }
   13893                 :            : 
   13894                 :            :                         //make note of the doubler_surface and add it to the delete list
   13895         [ #  # ]:          0 :                         master_surface_remove_list+=doubler_surface_for_this_body;
   13896                 :            : 
   13897                 :            :                         //clean out these DLIList's as they will be used later on
   13898         [ #  # ]:          0 :                         doubler_loopSM_list.clean_out();
   13899         [ #  # ]:          0 :                         doubler_external_curves.clean_out();
   13900                 :            : 
   13901                 :            :                         //refilling DLIList's as needed based on internal_flg
   13902                 :            :                         //basically if surfaces share a curve, that surface will be kept so if you don't want the internal surfaces
   13903                 :            :                         //create the list without the internal curves and they'll be removed
   13904         [ #  # ]:          0 :             if(internal_flg==CUBIT_FALSE)
   13905                 :            :             {
   13906                 :          0 :                 int j=0;
   13907 [ #  # ][ #  # ]:          0 :                 for(i=0;i<doubler_surface_for_this_body.size();i++)
   13908                 :            :                 {
   13909 [ #  # ][ #  # ]:          0 :                     doubler_surface_for_this_body[i]->loopsms(doubler_loopSM_list);
   13910 [ #  # ][ #  # ]:          0 :                     for(j=0;j<doubler_loopSM_list.size();j++)
   13911                 :            :                     {
   13912 [ #  # ][ #  # ]:          0 :                       LoopType loop_type = doubler_loopSM_list[j]->loop_type();
   13913 [ #  # ][ #  # ]:          0 :                       if(loop_type == LOOP_TYPE_EXTERNAL ||
   13914         [ #  # ]:          0 :                          loop_type == LOOP_TYPE_U_PERIODIC ||
   13915                 :            :                          loop_type == LOOP_TYPE_V_PERIODIC)
   13916                 :            :                       {
   13917 [ #  # ][ #  # ]:          0 :                           doubler_loopSM_list[j]->curves(doubler_external_curves);
   13918                 :          0 :                           break;
   13919                 :            :                       }
   13920                 :            : 
   13921                 :            :                     }
   13922         [ #  # ]:          0 :                     doubler_loopSM_list.clean_out();
   13923                 :            :                 }
   13924                 :            :             }
   13925                 :            :             else
   13926                 :            :                         {
   13927 [ #  # ][ #  # ]:          0 :                                 for(i=0;i<doubler_surface_for_this_body.size();i++)
   13928                 :            :                                 {
   13929 [ #  # ][ #  # ]:          0 :                                         doubler_surface_for_this_body[i]->loopsms(doubler_loopSM_list);
   13930                 :            :                                 }
   13931 [ #  # ][ #  # ]:          0 :                                 for(i=0;i<doubler_loopSM_list.size();i++)
   13932                 :            :                                 {
   13933 [ #  # ][ #  # ]:          0 :                                         doubler_loopSM_list[i]->curves(doubler_external_curves);
   13934                 :            :                                 }
   13935                 :            :                         }
   13936                 :            : 
   13937                 :            :                         //recreate the thicken_surfaces list based now on the bodies after the tweak_target command
   13938         [ #  # ]:          0 :                         thicken_surfaces.clean_out();
   13939 [ #  # ][ #  # ]:          0 :                         tweak_target_bodySM[0]->surfaces(thicken_surfaces);
   13940                 :            : 
   13941 [ #  # ][ #  # ]:          0 :                         DLIList <Surface*> surfaces_to_keep;
                 [ #  # ]
   13942         [ #  # ]:          0 :                         surfaces_to_remove = thicken_surfaces;
   13943 [ #  # ][ #  # ]:          0 :                         DLIList <Curve*> tweak_external_curves;
                 [ #  # ]
   13944                 :            : 
   13945 [ #  # ][ #  # ]:          0 :                         for(i=0;i<thicken_surfaces.size();i++)
   13946                 :            :                         {
   13947 [ #  # ][ #  # ]:          0 :                                 thicken_surfaces[i]->loopsms(test_loopSM_list);
   13948                 :            :                                 //grabs the external curves from face
   13949 [ #  # ][ #  # ]:          0 :                                 test_loopSM_list[0]->curves(tweak_external_curves);
   13950                 :            : 
   13951                 :          0 :                                 int j=0;
   13952 [ #  # ][ #  # ]:          0 :                                 for(j=0;j<tweak_external_curves.size();j++)
   13953                 :            :                                 {
   13954                 :            :                                         //step through the loop list
   13955         [ #  # ]:          0 :                                         test_external_curves1 = tweak_external_curves[j];
   13956                 :            : 
   13957                 :          0 :                                         int k=0;
   13958 [ #  # ][ #  # ]:          0 :                                         for(k=0; k<doubler_external_curves.size();k++)
   13959                 :            :                                         {
   13960                 :            :                                                 //while stepping through the doubler plate curves, compare them to the test_loop_list
   13961         [ #  # ]:          0 :                                                 test_external_curves2 = doubler_external_curves[k];
   13962                 :            : 
   13963         [ #  # ]:          0 :                                                 if(test_external_curves2 == test_external_curves1)
   13964                 :            :                                                 {
   13965 [ #  # ][ #  # ]:          0 :                                                         surfaces_to_keep.append(thicken_surfaces[i]);
   13966                 :          0 :                                                         break;
   13967                 :            :                                                 }
   13968                 :            :                                         }
   13969         [ #  # ]:          0 :                                         if(test_external_curves2 == test_external_curves1)
   13970                 :            :                                         {
   13971                 :          0 :                                                 break;
   13972                 :            :                                         }
   13973                 :            :                                 }
   13974         [ #  # ]:          0 :                                 test_loopSM_list.clean_out();
   13975         [ #  # ]:          0 :                                 tweak_external_curves.clean_out();
   13976                 :            :                         }
   13977                 :            : 
   13978 [ #  # ][ #  # ]:          0 :                         if(surfaces_to_keep.size()==0)
   13979                 :            :                         {
   13980 [ #  # ][ #  # ]:          0 :                                 PRINT_ERROR( "Failed to find and keep tweak_target surfaces\n" );
         [ #  # ][ #  # ]
   13981 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<tweak_target_bodySM.size();ii++)
   13982                 :            :                 {
   13983 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = tweak_target_bodySM[ii]->get_geometry_query_engine();
   13984 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(tweak_target_bodySM[ii]);
   13985                 :            :                 }
   13986                 :            : 
   13987         [ #  # ]:          0 :         if(enable_undo)
   13988         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   13989                 :            : 
   13990                 :          0 :                                 return CUBIT_FAILURE;
   13991                 :            :                         }
   13992                 :            : 
   13993                 :            :                         //subtract surfaces
   13994         [ #  # ]:          0 :                         surfaces_to_remove -= surfaces_to_keep;
   13995         [ #  # ]:          0 :                         master_surface_remove_list+=surfaces_to_remove;
   13996                 :            : 
   13997 [ #  # ][ #  # ]:          0 :                         DLIList<BodySM*> resulting_bodies;
                 [ #  # ]
   13998                 :            : 
   13999 [ #  # ][ #  # ]:          0 :                         if(gme_ptr->tweak_remove(master_surface_remove_list,resulting_bodies,CUBIT_FALSE) == CUBIT_FAILURE || resulting_bodies.size()==0)
         [ #  # ][ #  # ]
                 [ #  # ]
   14000                 :            :                         {
   14001 [ #  # ][ #  # ]:          0 :                                 PRINT_ERROR( "Command failed at Tweak_Remove routine\n" );
         [ #  # ][ #  # ]
   14002 [ #  # ][ #  # ]:          0 :                 for(ii =0;ii<tweak_target_bodySM.size();ii++)
   14003                 :            :                 {
   14004 [ #  # ][ #  # ]:          0 :                     GeometryQueryEngine* gqe = tweak_target_bodySM[ii]->get_geometry_query_engine();
   14005 [ #  # ][ #  # ]:          0 :                     gqe->delete_solid_model_entities(tweak_target_bodySM[ii]);
   14006                 :            :                 }
   14007                 :            : 
   14008         [ #  # ]:          0 :         if(enable_undo)
   14009         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   14010                 :            : 
   14011                 :          0 :                                 return CUBIT_FAILURE;
   14012                 :            :                         }
   14013                 :            : 
   14014                 :            :                         //all_kept_bodies is a list of bodies that will eventually be passed into finish_sm_op at the end
   14015 [ #  # ][ #  # ]:          0 :                         all_kept_bodies+=resulting_bodies;
                 [ #  # ]
   14016                 :          0 :                 }
   14017                 :            :     }
   14018                 :            : 
   14019         [ #  # ]:          0 :     if(preview==CUBIT_FALSE)
   14020                 :            :     {
   14021         [ #  # ]:          0 :         DLIList<BodySM*> bodies_to_unite;
   14022                 :            :         //check to see if their is only one body.  If only one body skip over the unite and split because
   14023                 :            :         //the unite command will fail (there is a check at the beginning to return cubit_failure)
   14024                 :            :         //append the original doubler surfaces to the resulting body list
   14025                 :            : 
   14026 [ #  # ][ #  # ]:          0 :         for(i=0;i<doubler_surface.size();i++)
   14027                 :            :         {
   14028 [ #  # ][ #  # ]:          0 :             all_kept_bodies.insert_first(doubler_surface[i]->bodysm());
                 [ #  # ]
   14029                 :            :         }
   14030 [ #  # ][ #  # ]:          0 :         if(all_kept_bodies.size()!=1)
   14031                 :            :         {
   14032 [ #  # ][ #  # ]:          0 :             if(gme_ptr->unite(all_kept_bodies,bodies_to_unite) == CUBIT_FAILURE || bodies_to_unite.size()==0 )
         [ #  # ][ #  # ]
                 [ #  # ]
   14033                 :            :             {
   14034 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Command failed at unite command\n" );
         [ #  # ][ #  # ]
   14035                 :            : 
   14036         [ #  # ]:          0 :                 if(enable_undo)
   14037         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   14038                 :            : 
   14039                 :          0 :                 return CUBIT_FAILURE;
   14040                 :            :             }
   14041         [ #  # ]:          0 :             all_kept_bodies.clean_out();
   14042 [ #  # ][ #  # ]:          0 :             if(gme_ptr->split_body(bodies_to_unite[0],all_kept_bodies) == CUBIT_FAILURE || all_kept_bodies.size()==0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   14043                 :            :             {
   14044 [ #  # ][ #  # ]:          0 :                 PRINT_ERROR( "Command failed at separate command\n" );
         [ #  # ][ #  # ]
   14045                 :            : 
   14046         [ #  # ]:          0 :                 if(enable_undo)
   14047         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   14048                 :            : 
   14049                 :          0 :                 return CUBIT_FAILURE;
   14050                 :            :             }
   14051                 :            :         }
   14052                 :            :         else
   14053                 :            :         {
   14054 [ #  # ][ #  # ]:          0 :                 PRINT_WARNING( "Command may have failed at finding doubler surface(s) and appending them to the drop-down surfaces\n" );
         [ #  # ][ #  # ]
   14055                 :            : 
   14056         [ #  # ]:          0 :                 if(enable_undo)
   14057         [ #  # ]:          0 :                   CubitUndo::remove_last_undo();
   14058                 :            : 
   14059                 :          0 :                 return CUBIT_FAILURE;
   14060                 :            :         }
   14061                 :            : 
   14062                 :            :         //update DAG
   14063                 :            :                 CubitStatus stat;
   14064         [ #  # ]:          0 :                 stat = finish_sm_op( old_body_list, all_kept_bodies ,body_list_out );
   14065         [ #  # ]:          0 :     if (CUBIT_SUCCESS != stat) {
   14066 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("GeometryModifyTool::finish_sm_op failed.\n");
         [ #  # ][ #  # ]
   14067                 :          0 :       return stat;
   14068                 :            :     }
   14069         [ #  # ]:          0 :     if(enable_undo)
   14070         [ #  # ]:          0 :       CubitUndo::note_result_bodies(body_list_out);
   14071                 :            : 
   14072         [ #  # ]:          0 :                 return CUBIT_SUCCESS;
   14073                 :            :         }
   14074                 :            :         else
   14075                 :            :         {
   14076         [ #  # ]:          0 :                 DLIList<Curve*> kept_curves;
   14077 [ #  # ][ #  # ]:          0 :                 for(i =0;i<all_kept_bodies.size();i++)
   14078                 :            :                 {
   14079 [ #  # ][ #  # ]:          0 :                         all_kept_bodies[i]->curves(kept_curves);
   14080                 :            :                 }
   14081                 :            : 
   14082         [ #  # ]:          0 :         GfxPreview::clear();
   14083                 :            : 
   14084 [ #  # ][ #  # ]:          0 :         for(i=0; i<kept_curves.size();i++)
   14085                 :            :         {
   14086                 :            :             CubitStatus result;
   14087         [ #  # ]:          0 :             GMem g_mem;
   14088                 :            : 
   14089                 :            :             // get the graphics
   14090 [ #  # ][ #  # ]:          0 :             result = kept_curves[i]->get_geometry_query_engine()->
   14091 [ #  # ][ #  # ]:          0 :                 get_graphics( kept_curves[i], &g_mem );
   14092                 :            : 
   14093 [ #  # ][ #  # ]:          0 :             if (result==CUBIT_FAILURE || g_mem.pointListCount == 0)
   14094                 :            :             {
   14095 [ #  # ][ #  # ]:          0 :                 PRINT_WARNING("Unable to preview a curve\n" );;
         [ #  # ][ #  # ]
   14096         [ #  # ]:          0 :                 double len = kept_curves[i]->
   14097 [ #  # ][ #  # ]:          0 :                     length_from_u(kept_curves[i]->start_param(),kept_curves[i]->end_param());
         [ #  # ][ #  # ]
                 [ #  # ]
   14098                 :            : 
   14099 [ #  # ][ #  # ]:          0 :                 PRINT_WARNING("Curve len: %f\n",len);
         [ #  # ][ #  # ]
   14100                 :            :             }
   14101                 :            : 
   14102                 :            :             // Draw the polyline
   14103 [ #  # ][ #  # ]:          0 :             GfxPreview::draw_polyline( g_mem.point_list(), g_mem.pointListCount, CUBIT_BLUE_INDEX );
   14104         [ #  # ]:          0 :         }
   14105         [ #  # ]:          0 :         GfxPreview::flush();
   14106 [ #  # ][ #  # ]:          0 :         for(ii =0;ii<tweak_target_bodySM.size();ii++)
   14107                 :            :         {
   14108 [ #  # ][ #  # ]:          0 :             GeometryQueryEngine* gqe = tweak_target_bodySM[ii]->get_geometry_query_engine();
   14109 [ #  # ][ #  # ]:          0 :             gqe->delete_solid_model_entities(tweak_target_bodySM[ii]);
   14110                 :            :         }
   14111                 :            : 
   14112         [ #  # ]:          0 :         if(enable_undo)
   14113         [ #  # ]:          0 :           CubitUndo::note_result_bodies(body_list_out);
   14114                 :            : 
   14115         [ #  # ]:          0 :         return CUBIT_SUCCESS;
   14116         [ #  # ]:          0 :     }
   14117                 :            : }
   14118                 :            : 
   14119                 :            : //=============================================================================
   14120                 :            : // Function   : tweak_bend
   14121                 :            : // Member Type: PUBLIC
   14122                 :            : // Description: Bend solid bodies based on a bend radius and angle
   14123                 :            : // Author     : Sam Showman
   14124                 :            : // Date       : 06/23/08
   14125                 :            : //=============================================================================
   14126                 :          0 : CubitStatus GeometryModifyTool::tweak_bend( DLIList<Body*> &bend_bodies,
   14127                 :            :                                             DLIList<Body*> &new_body_list,
   14128                 :            :                                             CubitVector& neutral_root,
   14129                 :            :                                             CubitVector& bend_axis,
   14130                 :            :                                             CubitVector& bend_direction,
   14131                 :            :                                             double radius,
   14132                 :            :                                             double angle,
   14133                 :            :                                             DLIList<CubitVector>& bend_regions,
   14134                 :            :                                             double width,
   14135                 :            :                                             CubitBoolean center_bend,
   14136                 :            :                                             int num_points,
   14137                 :            :                                             CubitBoolean keep_old_body,
   14138                 :            :                                             CubitBoolean preview )
   14139                 :            : {
   14140 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE)
         [ #  # ][ #  # ]
   14141                 :            :         {
   14142         [ #  # ]:          0 :                 if (keep_old_body)
   14143         [ #  # ]:          0 :                         CubitUndo::save_state();
   14144                 :            :                 else
   14145         [ #  # ]:          0 :                         CubitUndo::save_state_with_cubit_file( bend_bodies );
   14146                 :            :     }
   14147                 :            : 
   14148         [ #  # ]:          0 :     DLIList<BodySM*> new_body_sm_list;
   14149 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> bend_bodies_sm;
   14150                 :            :     GeometryModifyEngine* engine;
   14151         [ #  # ]:          0 :     engine = common_modify_engine(bend_bodies, bend_bodies_sm);
   14152                 :            : 
   14153                 :          0 :     if (!preview)
   14154                 :            :     {
   14155                 :            :         //do_attribute_setup();
   14156                 :            :         //push_attributes_before_modify(bend_bodies_sm);
   14157                 :            :     }
   14158                 :            : 
   14159                 :            :     CubitStatus result = engine->tweak_bend(
   14160                 :            :             bend_bodies_sm,
   14161                 :            :             new_body_sm_list,
   14162                 :            :             neutral_root,
   14163                 :            :             bend_axis,
   14164                 :            :             bend_direction,
   14165                 :            :             radius,
   14166                 :            :             angle,
   14167                 :            :             bend_regions,
   14168                 :            :             width,
   14169                 :            :             center_bend,
   14170                 :            :             num_points,
   14171                 :            :             keep_old_body,
   14172         [ #  # ]:          0 :             preview);
   14173                 :            : 
   14174         [ #  # ]:          0 :     if (result == CUBIT_FAILURE)
   14175                 :            :     {
   14176                 :          0 :         if (!preview)
   14177                 :            :         {
   14178                 :            :             //remove_pushed_attributes(bend_bodies_sm, bend_bodies);
   14179                 :            :             //do_attribute_cleanup();
   14180                 :            :         }
   14181 [ #  # ][ #  # ]:          0 :         if (CubitUndo::get_undo_enabled())
   14182         [ #  # ]:          0 :             CubitUndo::remove_last_undo();
   14183                 :          0 :         return CUBIT_FAILURE;
   14184                 :            :     }
   14185                 :            : 
   14186         [ #  # ]:          0 :     if (preview == CUBIT_FALSE)
   14187                 :            :     {
   14188                 :            :         //restore_vg_after_modify(new_body_sm_list, bend_bodies, engine);
   14189                 :            :         //remove_pushed_attributes(new_body_sm_list, bend_bodies);
   14190                 :            : 
   14191                 :            :         // Update DAG
   14192         [ #  # ]:          0 :         CubitStatus stat = finish_sm_op( bend_bodies, new_body_sm_list, new_body_list );
   14193 [ #  # ][ #  # ]:          0 :         if (CubitUndo::get_undo_enabled())
   14194                 :            :         {
   14195         [ #  # ]:          0 :             if (stat == CUBIT_SUCCESS)
   14196         [ #  # ]:          0 :                 CubitUndo::note_result_bodies( new_body_list );
   14197                 :            :             else
   14198         [ #  # ]:          0 :                 CubitUndo::remove_last_undo();
   14199                 :            :         }
   14200                 :            : 
   14201                 :            :         //do_attribute_cleanup();
   14202                 :            : 
   14203                 :            :         // Update graphics
   14204                 :            :         /*
   14205                 :            :         bend_bodies.reset();
   14206                 :            :         int i = 0;
   14207                 :            :         for (i = 0; i < bend_bodies.size(); i++)
   14208                 :            :         {
   14209                 :            :             Body* body_ptr = bend_bodies.get_and_step();
   14210                 :            :             body_ptr->notify_all_observers( GEOMETRY_MODIFIED );
   14211                 :            :         }//*/
   14212                 :            : 
   14213                 :            :         // get list of entities to update
   14214         [ #  # ]:          0 :         DLIList<RefEntity*> entities_to_update;
   14215                 :            :         int i;
   14216 [ #  # ][ #  # ]:          0 :         for(i=0; i < new_body_sm_list.size(); i++)
   14217                 :            :         {
   14218         [ #  # ]:          0 :             BodySM* bodysm = new_body_sm_list.get_and_step();
   14219         [ #  # ]:          0 :             DLIList<TopologyBridge*> to_check;
   14220 [ #  # ][ #  # ]:          0 :             DLIList<TopologyBridge*> tmp;
   14221 [ #  # ][ #  # ]:          0 :             DLIList<Surface*> surfs;
   14222         [ #  # ]:          0 :             bodysm->surfaces(surfs);
   14223 [ #  # ][ #  # ]:          0 :             DLIList<Curve*> curves;
   14224         [ #  # ]:          0 :             bodysm->curves(curves);
   14225 [ #  # ][ #  # ]:          0 :             DLIList<TBPoint*> points;
   14226         [ #  # ]:          0 :             bodysm->points(points);
   14227         [ #  # ]:          0 :             to_check.append(bodysm);
   14228 [ #  # ][ #  # ]:          0 :             to_check.append(bodysm->lump());
   14229 [ #  # ][ #  # ]:          0 :             CAST_LIST_TO_PARENT(surfs, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   14230         [ #  # ]:          0 :             to_check += tmp;
   14231 [ #  # ][ #  # ]:          0 :             CAST_LIST_TO_PARENT(curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   14232         [ #  # ]:          0 :             to_check += tmp;
   14233 [ #  # ][ #  # ]:          0 :             CAST_LIST_TO_PARENT(points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   14234         [ #  # ]:          0 :             to_check += tmp;
   14235                 :            : 
   14236                 :            :             int k;
   14237 [ #  # ][ #  # ]:          0 :             for(k=0; k<to_check.size(); k++)
   14238 [ #  # ][ #  # ]:          0 :                 if(BridgeManager* m = to_check.get_and_step()->bridge_manager())
                 [ #  # ]
   14239 [ #  # ][ #  # ]:          0 :                     if(TopologyEntity* t = m->topology_entity())
   14240 [ #  # ][ #  # ]:          0 :                         entities_to_update.append(CAST_TO(t, RefEntity));
   14241                 :            : 
   14242         [ #  # ]:          0 :         }
   14243                 :            :         // Update graphics
   14244 [ #  # ][ #  # ]:          0 :         while (entities_to_update.size())
   14245 [ #  # ][ #  # ]:          0 :             AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entities_to_update.pop()));
         [ #  # ][ #  # ]
                 [ #  # ]
   14246                 :            : 
   14247         [ #  # ]:          0 :         return stat;
   14248                 :            :     }
   14249                 :            : 
   14250         [ #  # ]:          0 :     return CUBIT_SUCCESS;
   14251                 :            : }
   14252                 :            : 
   14253                 :            : 
   14254                 :            : 
   14255                 :            : //=============================================================================
   14256                 :            : // Description: Chamfer curves on solid and sheet bodies.  The left and right
   14257                 :            : //              offsets are with respect to the curve direction.  If the given
   14258                 :            : //              right offset is negative, the left offset is used.  Users can
   14259                 :            : //              preview to clarify the meaning of left and right.
   14260                 :            : // Author     : Steve Storm
   14261                 :            : // Date       : 03/25/05
   14262                 :            : //=============================================================================
   14263                 :          0 : CubitStatus GeometryModifyTool::tweak_chamfer( DLIList<RefEdge*> &ref_edge_list,
   14264                 :            :                                                double left_offset,
   14265                 :            :                                                DLIList<Body*> &new_body_list,
   14266                 :            :                                                double right_offset,
   14267                 :            :                                                CubitBoolean keep_old_body,
   14268                 :            :                                                CubitBoolean preview )
   14269                 :            : {
   14270 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
   14271 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   14272                 :            :   GeometryModifyEngine* gme_ptr;
   14273                 :            : 
   14274         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_edge_list, "Chamfering", old_body_list, curve_list, CUBIT_TRUE );
   14275         [ #  # ]:          0 :   if( !gme_ptr )
   14276                 :          0 :     return CUBIT_FAILURE;
   14277                 :            : 
   14278 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   14279                 :            :   {
   14280         [ #  # ]:          0 :     if( keep_old_body )
   14281         [ #  # ]:          0 :       CubitUndo::save_state();
   14282                 :            :     else
   14283         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edge_list );
   14284                 :            :   }
   14285                 :            : 
   14286 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms;
   14287 [ #  # ][ #  # ]:          0 :   for(int i=old_body_list.size(); i--;)
   14288                 :            :   {
   14289 [ #  # ][ #  # ]:          0 :     BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   14290         [ #  # ]:          0 :     if(bsm)
   14291         [ #  # ]:          0 :       body_sms.append_unique(bsm);
   14292                 :            :   }
   14293                 :            : 
   14294         [ #  # ]:          0 :   if(!preview)
   14295                 :            :   {
   14296         [ #  # ]:          0 :     do_attribute_setup();
   14297         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   14298                 :            :   }
   14299                 :            : 
   14300                 :            :   // Do chamfering
   14301 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   14302                 :            :   CubitStatus stat = gme_ptr->tweak_chamfer( curve_list, left_offset, new_bodysm_list,
   14303         [ #  # ]:          0 :                                             right_offset, keep_old_body, preview );
   14304         [ #  # ]:          0 :   if(stat == CUBIT_FAILURE )
   14305                 :            :   {
   14306         [ #  # ]:          0 :     if(!preview)
   14307                 :            :     {
   14308 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   14309         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   14310         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   14311         [ #  # ]:          0 :       do_attribute_cleanup();
   14312                 :            :     }
   14313                 :          0 :     return stat;
   14314                 :            :   }
   14315                 :            :   else
   14316                 :            :   {
   14317         [ #  # ]:          0 :     if(!preview)
   14318                 :            :     {
   14319         [ #  # ]:          0 :       restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   14320         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   14321                 :            :     }
   14322                 :            :   }
   14323                 :            : 
   14324         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   14325                 :            :   {
   14326                 :            :     // Update DAG
   14327         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   14328                 :            : 
   14329 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   14330                 :            :     {
   14331         [ #  # ]:          0 :       if( stat == CUBIT_SUCCESS )
   14332         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   14333                 :            :       else
   14334         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   14335                 :            :     }
   14336         [ #  # ]:          0 :     do_attribute_cleanup();
   14337                 :            : 
   14338                 :          0 :     return stat;
   14339                 :            :   }
   14340         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   14341                 :            : }
   14342                 :            : 
   14343                 :          0 : void GeometryModifyTool::propagate_from_small_edge(RefEdge *edge,
   14344                 :            :                                                  DLIList<RefEdge*> &small_edges,
   14345                 :            :                                                  DLIList<RefFace*> &narrow_faces,
   14346                 :            :                                                  DLIList<RefFace*> &processed_faces,
   14347                 :            :                                                  double small_edge_length)
   14348                 :            : {
   14349                 :            :   int i, j;
   14350                 :            :   // First find any small edges connected to this edge.
   14351         [ #  # ]:          0 :   DLIList<RefVertex*> edge_verts;
   14352         [ #  # ]:          0 :   edge->ref_vertices(edge_verts);
   14353 [ #  # ][ #  # ]:          0 :   for(i=edge_verts.size(); i--;)
   14354                 :            :   {
   14355         [ #  # ]:          0 :     RefVertex *vert = edge_verts.get_and_step();
   14356         [ #  # ]:          0 :     DLIList<RefEdge*> vert_edges;
   14357         [ #  # ]:          0 :     vert->ref_edges(vert_edges);
   14358 [ #  # ][ #  # ]:          0 :     for(j=vert_edges.size(); j--;)
   14359                 :            :     {
   14360         [ #  # ]:          0 :       RefEdge *cur_edge = vert_edges.get_and_step();
   14361 [ #  # ][ #  # ]:          0 :       if(cur_edge != edge && !cur_edge->marked())
         [ #  # ][ #  # ]
   14362                 :            :       {
   14363                 :            :         // Mark of > 0 means it has been processed.
   14364         [ #  # ]:          0 :         cur_edge->marked(1);
   14365 [ #  # ][ #  # ]:          0 :         if(cur_edge->get_arc_length() < small_edge_length)
   14366                 :            :         {
   14367         [ #  # ]:          0 :           small_edges.append(cur_edge);
   14368                 :            :           // Mark of 2 means it is a small edge.
   14369         [ #  # ]:          0 :           cur_edge->marked(2);
   14370                 :            :           propagate_from_small_edge(cur_edge, small_edges, narrow_faces,
   14371         [ #  # ]:          0 :             processed_faces, small_edge_length);
   14372                 :            :         }
   14373                 :            :       }
   14374                 :            :     }
   14375         [ #  # ]:          0 :   }
   14376                 :            :   // Now look at adjacent narrow faces and recursively process them.
   14377 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> edge_faces;
   14378         [ #  # ]:          0 :   edge->ref_faces(edge_faces);
   14379 [ #  # ][ #  # ]:          0 :   for(i=edge_faces.size(); i--;)
   14380                 :            :   {
   14381         [ #  # ]:          0 :     RefFace *cur_face = edge_faces.get_and_step();
   14382 [ #  # ][ #  # ]:          0 :     if(!cur_face->marked())
   14383                 :            :     {
   14384         [ #  # ]:          0 :       cur_face->marked(1);
   14385 [ #  # ][ #  # ]:          0 :       if(GeomMeasureTool::narrow_region_exists(cur_face, small_edge_length))
   14386                 :            :       {
   14387         [ #  # ]:          0 :         DLIList<CubitVector> split_pos1_list;
   14388 [ #  # ][ #  # ]:          0 :         DLIList<CubitVector> split_pos2_list;
   14389                 :            :         GeomMeasureTool::find_split_points_for_narrow_regions(cur_face,
   14390         [ #  # ]:          0 :           small_edge_length, split_pos1_list, split_pos2_list);
   14391 [ #  # ][ #  # ]:          0 :         if(split_pos1_list.size() == 0)
   14392                 :            :         {
   14393         [ #  # ]:          0 :           narrow_faces.append_unique(cur_face);
   14394                 :            :           propagate_over_narrow_face(cur_face, edge, processed_faces,
   14395         [ #  # ]:          0 :             small_edges, narrow_faces, small_edge_length);
   14396         [ #  # ]:          0 :         }
   14397                 :            :       }
   14398                 :            :     }
   14399         [ #  # ]:          0 :   }
   14400                 :          0 : }
   14401                 :            : 
   14402                 :          0 : void GeometryModifyTool::propagate_over_narrow_face(RefFace *narrow_face,
   14403                 :            :                                                   RefEdge *edge,
   14404                 :            :                                                   DLIList<RefFace*> &processed_faces,
   14405                 :            :                                                   DLIList<RefEdge*> &small_edges,
   14406                 :            :                                                   DLIList<RefFace*> &narrow_faces,
   14407                 :            :                                                   double small_edge_length)
   14408                 :            : {
   14409                 :            :   int i, j;
   14410         [ #  # ]:          0 :   processed_faces.append(narrow_face);
   14411         [ #  # ]:          0 :   DLIList<RefEdge*> face_edges;
   14412         [ #  # ]:          0 :   narrow_face->ref_edges(face_edges);
   14413 [ #  # ][ #  # ]:          0 :   for(i=face_edges.size(); i--;)
   14414                 :            :   {
   14415         [ #  # ]:          0 :     RefEdge *cur_edge = face_edges.get_and_step();
   14416 [ #  # ][ #  # ]:          0 :     if(cur_edge != edge && !cur_edge->marked())
         [ #  # ][ #  # ]
   14417                 :            :     {
   14418         [ #  # ]:          0 :       cur_edge->marked(1);
   14419 [ #  # ][ #  # ]:          0 :       if(cur_edge->get_arc_length() < small_edge_length)
   14420                 :            :       {
   14421         [ #  # ]:          0 :         cur_edge->marked(2);
   14422         [ #  # ]:          0 :         small_edges.append(cur_edge);
   14423                 :            :         propagate_from_small_edge(cur_edge, small_edges,
   14424         [ #  # ]:          0 :                 narrow_faces, processed_faces, small_edge_length);
   14425                 :            :       }
   14426                 :            :       else
   14427                 :            :       {
   14428         [ #  # ]:          0 :         DLIList<RefFace*> edge_faces;
   14429         [ #  # ]:          0 :         cur_edge->ref_faces(edge_faces);
   14430 [ #  # ][ #  # ]:          0 :         for(j=edge_faces.size(); j--;)
   14431                 :            :         {
   14432         [ #  # ]:          0 :           RefFace *cur_face = edge_faces.get_and_step();
   14433         [ #  # ]:          0 :           if(cur_face != narrow_face)
   14434                 :            :           {
   14435 [ #  # ][ #  # ]:          0 :             if(!cur_face->marked())
   14436                 :            :             {
   14437         [ #  # ]:          0 :               cur_face->marked(1);
   14438 [ #  # ][ #  # ]:          0 :               if(GeomMeasureTool::narrow_region_exists(cur_face, small_edge_length))
   14439                 :            :               {
   14440         [ #  # ]:          0 :                 DLIList<CubitVector> split_pos1_list;
   14441 [ #  # ][ #  # ]:          0 :                 DLIList<CubitVector> split_pos2_list;
   14442                 :            :                 GeomMeasureTool::find_split_points_for_narrow_regions(cur_face,
   14443         [ #  # ]:          0 :                   small_edge_length, split_pos1_list, split_pos2_list);
   14444 [ #  # ][ #  # ]:          0 :                 if(split_pos1_list.size() == 0)
   14445                 :            :                 {
   14446         [ #  # ]:          0 :                   narrow_faces.append_unique(cur_face);
   14447                 :            :                   propagate_over_narrow_face(cur_face, edge, processed_faces,
   14448         [ #  # ]:          0 :                     small_edges, narrow_faces, small_edge_length);
   14449         [ #  # ]:          0 :                 }
   14450                 :            :               }
   14451                 :            :             }
   14452                 :            :           }
   14453         [ #  # ]:          0 :         }
   14454                 :            :       }
   14455                 :            :     }
   14456         [ #  # ]:          0 :   }
   14457                 :          0 : }
   14458                 :            : 
   14459                 :          0 : void GeometryModifyTool::push_tolerance_attribute(DLIList<Body*> &body_list)
   14460                 :            : {
   14461                 :            :   Body* local_body;
   14462         [ #  # ]:          0 :   DLIList<RefEntity*> child_list;
   14463                 :            : 
   14464                 :            :   //save attribute settings
   14465 [ #  # ][ #  # ]:          0 :   CGMApp::instance()->save_current_attribute_states();
   14466                 :            : 
   14467 [ #  # ][ #  # ]:          0 :   CGMApp::instance()->attrib_manager()->auto_flag(0);
                 [ #  # ]
   14468 [ #  # ][ #  # ]:          0 :   CGMApp::instance()->attrib_manager()->set_auto_update_flag(CA_ENTITY_TOL, CUBIT_TRUE);
                 [ #  # ]
   14469                 :            : 
   14470 [ #  # ][ #  # ]:          0 :   for (int i = body_list.size(); i--;)
   14471                 :            :   {
   14472         [ #  # ]:          0 :     child_list.clean_out();
   14473                 :            : 
   14474         [ #  # ]:          0 :     local_body = body_list.get_and_step();
   14475         [ #  # ]:          0 :     local_body->get_all_child_ref_entities( child_list);
   14476 [ #  # ][ #  # ]:          0 :     child_list.append(local_body);
   14477         [ #  # ]:          0 :     CubitAttribUser::auto_update_cubit_attrib( child_list );
   14478         [ #  # ]:          0 :   }
   14479                 :          0 : }
   14480                 :            : 
   14481                 :          0 : void GeometryModifyTool::propagate_merge_tolerance(DLIList<Body*> &body_list)
   14482                 :            : {
   14483                 :            :   // For each body
   14484                 :            :   //  get a list of all children that have a local tolerance
   14485                 :            :   //  iterate over that list
   14486                 :            :   //    for each entity, get a list of all of its children
   14487                 :            :   //    if the parent's tolerance is > child tolerance && the child isn't in the owner_set list
   14488                 :            :   //     then set the child's tolerance to the parent's tolerance
   14489                 :            : 
   14490         [ #  # ]:          0 :   DLIList<RefEntity*> owner_set_tolerance_list;
   14491 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entity_list;
   14492                 :            : 
   14493                 :          0 :   double parent_tolerance = 0.0;
   14494                 :            : 
   14495 [ #  # ][ #  # ]:          0 :   for (int i=body_list.size(); i--;)
   14496                 :            :   {
   14497         [ #  # ]:          0 :     Body* local_body = body_list.get_and_step();
   14498                 :            : 
   14499                 :            :     // First, get all the children for this body. Save those that already have
   14500                 :            :     // a local tolerance set
   14501         [ #  # ]:          0 :     local_body->get_all_child_ref_entities(entity_list);
   14502 [ #  # ][ #  # ]:          0 :     for (int i = entity_list.size(); i--;)
   14503                 :            :     {
   14504         [ #  # ]:          0 :       RefEntity* local_entity = entity_list.get_and_step();
   14505 [ #  # ][ #  # ]:          0 :       if (local_entity->local_tolerance() > 0.0)
   14506         [ #  # ]:          0 :         owner_set_tolerance_list.append(local_entity);
   14507                 :            :     }
   14508                 :            : 
   14509                 :            :     // for each entity in the owner_set list, get all of its children
   14510 [ #  # ][ #  # ]:          0 :     for (int i = owner_set_tolerance_list.size(); i--;)
   14511                 :            :     {
   14512         [ #  # ]:          0 :       RefEntity* local_entity = owner_set_tolerance_list.get_and_step();
   14513         [ #  # ]:          0 :       parent_tolerance = local_entity->local_tolerance();
   14514                 :            : 
   14515         [ #  # ]:          0 :       entity_list.clean_out();
   14516         [ #  # ]:          0 :       local_entity->get_all_child_ref_entities(entity_list);
   14517 [ #  # ][ #  # ]:          0 :       for (int j = entity_list.size(); j--;)
   14518                 :            :       {
   14519         [ #  # ]:          0 :         RefEntity* child_entity = entity_list.get_and_step();
   14520 [ #  # ][ #  # ]:          0 :         if (!owner_set_tolerance_list.is_in_list(child_entity))
   14521                 :            :         {
   14522 [ #  # ][ #  # ]:          0 :           if (child_entity->local_tolerance() < parent_tolerance)
   14523         [ #  # ]:          0 :             child_entity->local_tolerance(parent_tolerance);
   14524                 :            :         }
   14525                 :            :       }
   14526                 :            :     }
   14527         [ #  # ]:          0 :   }
   14528                 :          0 : }
   14529                 :            : 
   14530                 :          0 : CubitStatus GeometryModifyTool::remove_topology( DLIList<RefEdge*> &ref_edge_list,
   14531                 :            :                                                   DLIList<RefFace*> &ref_face_list,
   14532                 :            :                                                   double backoff_distance,
   14533                 :            :                                                   double small_curve_size,
   14534                 :            :                                                   DLIList<Body*> &new_body_list,
   14535                 :            :                                                   CubitBoolean propagate,
   14536                 :            :                                                   CubitBoolean preview)
   14537                 :            : {
   14538                 :            :   int i, j;
   14539                 :          0 :   CubitStatus ret = CUBIT_SUCCESS;
   14540         [ #  # ]:          0 :   DLIList<Surface*> surf_list;
   14541 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list;
   14542 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   14543                 :          0 :   GeometryModifyEngine *gme_ptr1=NULL, *gme_ptr2=NULL, *gme_ptr=NULL;
   14544                 :          0 :   Body *b1=NULL, *b2=NULL, *b=NULL;
   14545                 :            : 
   14546 [ #  # ][ #  # ]:          0 :   if(ref_edge_list.size())
   14547 [ #  # ][ #  # ]:          0 :     b1 = ref_edge_list.get()->body();
   14548 [ #  # ][ #  # ]:          0 :   if(ref_face_list.size())
   14549 [ #  # ][ #  # ]:          0 :     b2 = ref_face_list.get()->body();
   14550                 :            : 
   14551 [ #  # ][ #  # ]:          0 :   if(b1 && b2)
   14552                 :            :   {
   14553         [ #  # ]:          0 :     if(b1 == b2)
   14554                 :          0 :       b = b1;
   14555                 :            :   }
   14556         [ #  # ]:          0 :   else if(b1)
   14557                 :          0 :     b = b1;
   14558         [ #  # ]:          0 :   else if(b2)
   14559                 :          0 :     b = b2;
   14560                 :            : 
   14561         [ #  # ]:          0 :   if(b)
   14562         [ #  # ]:          0 :     old_body_list.append(b);
   14563                 :            :   else
   14564                 :            :   {
   14565 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Failed to find an owning body for the topology being removed.\n");
         [ #  # ][ #  # ]
   14566                 :          0 :     ret = CUBIT_FAILURE;
   14567                 :            :   }
   14568                 :            : 
   14569         [ #  # ]:          0 :   if(ret == CUBIT_SUCCESS)
   14570                 :            :   {
   14571 [ #  # ][ #  # ]:          0 :     if (!okay_to_modify( old_body_list, "REMOVE_TOPOLOGY" ))
   14572                 :          0 :       ret = CUBIT_FAILURE;
   14573                 :            :     else
   14574                 :            :     {
   14575                 :            :       // Remove any edges from the list that aren't small enough.
   14576         [ #  # ]:          0 :       DLIList<RefEdge*> edges_to_remove;
   14577 [ #  # ][ #  # ]:          0 :       for(i=ref_edge_list.size(); i--;)
   14578                 :            :       {
   14579         [ #  # ]:          0 :         RefEdge* re = ref_edge_list.get_and_step();
   14580 [ #  # ][ #  # ]:          0 :         if(re->get_arc_length() > small_curve_size)
   14581                 :            :         {
   14582         [ #  # ]:          0 :           edges_to_remove.append(re);
   14583 [ #  # ][ #  # ]:          0 :           PRINT_INFO("Ignoring curve %d as it is not a small curve based on the input. "
         [ #  # ][ #  # ]
   14584         [ #  # ]:          0 :             "Try a larger small_curve_size value.\n", re->id());
   14585                 :            :         }
   14586                 :            :       }
   14587         [ #  # ]:          0 :       ref_edge_list -= edges_to_remove;
   14588                 :            : 
   14589                 :            :       // Remove any faces from the list that don't have at least one small edge.
   14590 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> faces_to_remove;
   14591 [ #  # ][ #  # ]:          0 :       for(i=ref_face_list.size(); i--;)
   14592                 :            :       {
   14593         [ #  # ]:          0 :         DLIList<RefEdge*> face_edges;
   14594         [ #  # ]:          0 :         RefFace* rf = ref_face_list.get_and_step();
   14595         [ #  # ]:          0 :         rf->ref_edges(face_edges);
   14596                 :          0 :         int face_ok = 0;
   14597 [ #  # ][ #  # ]:          0 :         for(j=face_edges.size(); j && !face_ok; j--)
                 [ #  # ]
   14598                 :            :         {
   14599         [ #  # ]:          0 :           RefEdge* cur_edge = face_edges.get_and_step();
   14600 [ #  # ][ #  # ]:          0 :           if(cur_edge->get_arc_length() <= small_curve_size)
   14601                 :          0 :             face_ok = 1;
   14602                 :            :         }
   14603         [ #  # ]:          0 :         if(!face_ok)
   14604                 :            :         {
   14605         [ #  # ]:          0 :           faces_to_remove.append(rf);
   14606 [ #  # ][ #  # ]:          0 :           PRINT_INFO("Ignoring surface %d as it does not have at least one small curve in it based on the input. "
         [ #  # ][ #  # ]
   14607         [ #  # ]:          0 :             "Try a larger small_curve_size value.\n", rf->id());
   14608                 :            :         }
   14609         [ #  # ]:          0 :       }
   14610 [ #  # ][ #  # ]:          0 :       ref_face_list -= faces_to_remove;
   14611                 :            :     }
   14612                 :            : 
   14613 [ #  # ][ #  # ]:          0 :     if(ref_face_list.size() > 0 || ref_edge_list.size() > 0)
         [ #  # ][ #  # ]
                 [ #  # ]
   14614                 :            :     {
   14615                 :            :       // If told to do so propagate the topology to be removed to include
   14616                 :            :       // other narrow surfaces and small edges.
   14617         [ #  # ]:          0 :       if(propagate)
   14618                 :            :       {
   14619                 :            :         // Get all of the small edges into a single list.
   14620         [ #  # ]:          0 :         DLIList<RefEdge*> small_edges = ref_edge_list;
   14621 [ #  # ][ #  # ]:          0 :         for(i=ref_face_list.size(); i--;)
   14622                 :            :         {
   14623         [ #  # ]:          0 :           RefFace *face = ref_face_list.get_and_step();
   14624         [ #  # ]:          0 :           DLIList<RefEdge*> edges;
   14625         [ #  # ]:          0 :           face->ref_edges(edges);
   14626 [ #  # ][ #  # ]:          0 :           for(j=edges.size(); j--;)
   14627                 :            :           {
   14628         [ #  # ]:          0 :             RefEdge *edge = edges.get_and_step();
   14629 [ #  # ][ #  # ]:          0 :             if(edge->get_arc_length() < small_curve_size)
   14630         [ #  # ]:          0 :               small_edges.append(edge);
   14631                 :            :           }
   14632         [ #  # ]:          0 :         }
   14633         [ #  # ]:          0 :         small_edges.uniquify_ordered();
   14634                 :            : 
   14635 [ #  # ][ #  # ]:          0 :         DLIList<RefFace*> processed_faces;
   14636 [ #  # ][ #  # ]:          0 :         DLIList<RefEdge*> copy_of_small_edges = small_edges;
   14637 [ #  # ][ #  # ]:          0 :         DLIList<RefFace*> narrow_faces;
   14638                 :            : 
   14639 [ #  # ][ #  # ]:          0 :         DLIList<RefFace*> all_faces;
   14640 [ #  # ][ #  # ]:          0 :         DLIList<RefEdge*> all_edges;
   14641                 :            : 
   14642                 :            :         // Set all of the marked flags to 0.
   14643         [ #  # ]:          0 :         b->ref_faces(all_faces);
   14644 [ #  # ][ #  # ]:          0 :         for(i=all_faces.size(); i>0; i--)
   14645 [ #  # ][ #  # ]:          0 :           all_faces.get_and_step()->marked(0);
   14646                 :            : 
   14647         [ #  # ]:          0 :         b->ref_edges(all_edges);
   14648 [ #  # ][ #  # ]:          0 :         for(i=all_edges.size(); i>0; i--)
   14649 [ #  # ][ #  # ]:          0 :           all_edges.get_and_step()->marked(0);
   14650                 :            : 
   14651                 :            :         // Mark of >0 means it has been processed.
   14652                 :            :         // Mark of 2 means it is a small edge.
   14653 [ #  # ][ #  # ]:          0 :         for(i=small_edges.size(); i>0; i--)
   14654 [ #  # ][ #  # ]:          0 :           small_edges.get_and_step()->marked(2);
   14655                 :            : 
   14656                 :            :         // First look at all of the edges connected to small edges
   14657                 :            :         // to see if there are other small edges.
   14658 [ #  # ][ #  # ]:          0 :         while(copy_of_small_edges.size())
   14659                 :            :         {
   14660         [ #  # ]:          0 :           RefEdge *edge = copy_of_small_edges.extract();
   14661                 :            :           propagate_from_small_edge(edge, small_edges,
   14662         [ #  # ]:          0 :                   narrow_faces, processed_faces, small_curve_size);
   14663                 :            :         }
   14664                 :            : 
   14665         [ #  # ]:          0 :         ref_face_list += narrow_faces;
   14666         [ #  # ]:          0 :         ref_face_list.uniquify_ordered();
   14667                 :            : 
   14668         [ #  # ]:          0 :         ref_edge_list = small_edges;
   14669 [ #  # ][ #  # ]:          0 :         ref_edge_list.uniquify_ordered();
   14670                 :            :         // Append to face list here so we don't lose the ones that were passed in.
   14671                 :            :       }
   14672                 :            :     }
   14673                 :            :     else
   14674                 :            :     {
   14675 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("No entities to remove.\n");
         [ #  # ][ #  # ]
   14676                 :          0 :       ret = CUBIT_FAILURE;
   14677                 :            :     }
   14678                 :            :   }
   14679                 :            : 
   14680         [ #  # ]:          0 :   if(ret == CUBIT_SUCCESS)
   14681                 :            :   {
   14682 [ #  # ][ #  # ]:          0 :     if(ref_edge_list.size())
   14683                 :            :     {
   14684 [ #  # ][ #  # ]:          0 :       for(i=ref_edge_list.size(); i--;)
   14685                 :            :       {
   14686         [ #  # ]:          0 :         RefEdge *re = ref_edge_list.get_and_step();
   14687         [ #  # ]:          0 :         Curve *cur = re->get_curve_ptr();
   14688         [ #  # ]:          0 :         DLIList<TopologyBridge*> tmp_curve_list;
   14689         [ #  # ]:          0 :         GeometryQueryEngine *gqe = cur->get_geometry_query_engine();
   14690         [ #  # ]:          0 :         gqe->get_underlying_curves(cur, tmp_curve_list);
   14691 [ #  # ][ #  # ]:          0 :         if(tmp_curve_list.size() == 0)
   14692         [ #  # ]:          0 :           tmp_curve_list.append(cur);
   14693 [ #  # ][ #  # ]:          0 :         for(int p=tmp_curve_list.size(); p--;)
   14694                 :            :         {
   14695 [ #  # ][ #  # ]:          0 :           Curve *crv = dynamic_cast<Curve*>(tmp_curve_list.get_and_step());
   14696         [ #  # ]:          0 :           if(!gme_ptr1)
   14697         [ #  # ]:          0 :             gme_ptr1 = get_engine(crv);
   14698         [ #  # ]:          0 :           curve_list.append(crv);
   14699                 :            :         }
   14700         [ #  # ]:          0 :       }
   14701                 :            :     }
   14702 [ #  # ][ #  # ]:          0 :     if(ref_face_list.size())
   14703                 :            :     {
   14704 [ #  # ][ #  # ]:          0 :       for(i=ref_face_list.size(); i--;)
   14705                 :            :       {
   14706         [ #  # ]:          0 :         RefFace *rf = ref_face_list.get_and_step();
   14707         [ #  # ]:          0 :         Surface *sur = rf->get_surface_ptr();
   14708         [ #  # ]:          0 :         DLIList<TopologyBridge*> tmp_surf_list;
   14709         [ #  # ]:          0 :         GeometryQueryEngine *gqe = sur->get_geometry_query_engine();
   14710         [ #  # ]:          0 :         gqe->get_underlying_surfaces(sur, tmp_surf_list);
   14711 [ #  # ][ #  # ]:          0 :         if(tmp_surf_list.size() == 0)
   14712         [ #  # ]:          0 :           tmp_surf_list.append(sur);
   14713 [ #  # ][ #  # ]:          0 :         for(int p=tmp_surf_list.size(); p--;)
   14714                 :            :         {
   14715 [ #  # ][ #  # ]:          0 :           Surface *srf = dynamic_cast<Surface*>(tmp_surf_list.get_and_step());
   14716         [ #  # ]:          0 :           if(!gme_ptr2)
   14717         [ #  # ]:          0 :             gme_ptr2 = get_engine(srf);
   14718         [ #  # ]:          0 :           surf_list.append(srf);
   14719                 :            :         }
   14720         [ #  # ]:          0 :       }
   14721                 :            :     }
   14722 [ #  # ][ #  # ]:          0 :     if(gme_ptr1 && gme_ptr2)
   14723                 :            :     {
   14724         [ #  # ]:          0 :       if(gme_ptr1 == gme_ptr2)
   14725                 :          0 :         gme_ptr = gme_ptr1;
   14726                 :            :     }
   14727         [ #  # ]:          0 :     else if(gme_ptr1)
   14728                 :          0 :       gme_ptr = gme_ptr1;
   14729         [ #  # ]:          0 :     else if(gme_ptr2)
   14730                 :          0 :       gme_ptr = gme_ptr2;
   14731                 :            : 
   14732         [ #  # ]:          0 :     if(!gme_ptr)
   14733                 :            :     {
   14734 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Failed to find a geometry modify engine.\n");
         [ #  # ][ #  # ]
   14735                 :          0 :       ret = CUBIT_FAILURE;
   14736                 :            :     }
   14737                 :            :   }
   14738                 :            : 
   14739         [ #  # ]:          0 :   if(ret == CUBIT_SUCCESS)
   14740                 :            :   {
   14741 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   14742                 :            :     {
   14743         [ #  # ]:          0 :       DLIList<Body*> bodies;
   14744                 :            :       int i;
   14745 [ #  # ][ #  # ]:          0 :       for( i=ref_face_list.size(); i--; )
   14746                 :            :       {
   14747         [ #  # ]:          0 :         RefFace* ref_face = ref_face_list.get_and_step();
   14748 [ #  # ][ #  # ]:          0 :         bodies.append( ref_face->body() );
   14749                 :            :       }
   14750 [ #  # ][ #  # ]:          0 :       for( i=ref_edge_list.size(); i--; )
   14751                 :            :       {
   14752         [ #  # ]:          0 :         RefEdge* ref_edge = ref_edge_list.get_and_step();
   14753 [ #  # ][ #  # ]:          0 :         bodies.append( ref_edge->body() );
   14754                 :            :       }
   14755         [ #  # ]:          0 :       bodies.uniquify_ordered();
   14756 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( bodies );
   14757                 :            :     }
   14758                 :            : 
   14759         [ #  # ]:          0 :     if(preview == CUBIT_FALSE)
   14760         [ #  # ]:          0 :       do_attribute_setup();
   14761                 :            : 
   14762 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> body_sm_list(old_body_list.size());
   14763         [ #  # ]:          0 :     GeometryModifyEngine* gme = common_modify_engine(old_body_list, body_sm_list);
   14764                 :            : 
   14765         [ #  # ]:          0 :     if(preview == CUBIT_FALSE)
   14766         [ #  # ]:          0 :       push_attributes_before_modify(body_sm_list);
   14767                 :            : 
   14768 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> new_bodysm_list;
   14769         [ #  # ]:          0 :     if(gme_ptr->remove_topology(curve_list, surf_list, backoff_distance, small_curve_size,
   14770         [ #  # ]:          0 :         new_bodysm_list, preview) == CUBIT_FAILURE)
   14771                 :            :     {
   14772 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   14773         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   14774                 :            : 
   14775         [ #  # ]:          0 :       if(!preview)
   14776         [ #  # ]:          0 :         remove_pushed_attributes(new_bodysm_list, old_body_list);
   14777                 :            : 
   14778                 :          0 :       ret = CUBIT_FAILURE;
   14779                 :            :     }
   14780                 :            :     else
   14781                 :            :     {
   14782         [ #  # ]:          0 :       if( preview == CUBIT_FALSE )
   14783                 :            :       {
   14784         [ #  # ]:          0 :         restore_vg_after_modify(new_bodysm_list, old_body_list, gme);
   14785         [ #  # ]:          0 :         remove_pushed_attributes(new_bodysm_list, old_body_list);
   14786                 :            : 
   14787                 :            :         // Update DAG
   14788         [ #  # ]:          0 :         ret = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   14789                 :            : 
   14790 [ #  # ][ #  # ]:          0 :         if( CubitUndo::get_undo_enabled() )
   14791                 :            :         {
   14792         [ #  # ]:          0 :           if( ret == CUBIT_FAILURE)
   14793         [ #  # ]:          0 :             CubitUndo::remove_last_undo();
   14794                 :            :           else
   14795         [ #  # ]:          0 :             CubitUndo::note_result_bodies( new_body_list );
   14796                 :            :         }
   14797                 :            :       }
   14798                 :            :     }
   14799                 :            : 
   14800         [ #  # ]:          0 :     if(preview == CUBIT_FALSE)
   14801 [ #  # ][ #  # ]:          0 :       do_attribute_cleanup();
   14802                 :            :   }
   14803                 :            : 
   14804         [ #  # ]:          0 :   return ret;
   14805                 :            : }
   14806                 :            : 
   14807                 :            : //=============================================================================
   14808                 :            : // Description: Chamfer vertices on solid or sheet bodies.  On a solid body
   14809                 :            : //              there can be up to 3 offsets; on a sheet body up to 2 offsets.
   14810                 :            : //              The offsets are in the direction of the supplied edges.  If
   14811                 :            : //              multiple vertices are supplied, only one offset value is
   14812                 :            : //              allowed and the edges are not used.
   14813                 :            : // Author     : Steve Storm
   14814                 :            : // Date       : 03/25/05
   14815                 :            : //=============================================================================
   14816                 :            : CubitStatus
   14817                 :          0 : GeometryModifyTool::tweak_chamfer( DLIList<RefVertex*> &ref_vertex_list,
   14818                 :            :                                    double offset1,
   14819                 :            :                                    DLIList<Body*> &new_body_list,
   14820                 :            :                                    RefEdge *edge1,
   14821                 :            :                                    double offset2,
   14822                 :            :                                    RefEdge *edge2,
   14823                 :            :                                    double offset3,
   14824                 :            :                                    RefEdge *edge3,
   14825                 :            :                                    CubitBoolean keep_old_body,
   14826                 :            :                                    CubitBoolean preview )
   14827                 :            : {
   14828         [ #  # ]:          0 :   if( offset1 <= 0.0 )
   14829                 :            :   {
   14830 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Chamfer radius not specified.\n" );
         [ #  # ][ #  # ]
   14831                 :          0 :     return CUBIT_FAILURE;
   14832                 :            :   }
   14833                 :            : 
   14834 [ #  # ][ #  # ]:          0 :   DLIList<TBPoint*> point_list(ref_vertex_list.size());
   14835 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   14836                 :            :   GeometryModifyEngine* gme_ptr;
   14837                 :            : 
   14838         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_vertex_list, "Chamfering", old_body_list, point_list, CUBIT_TRUE );
   14839         [ #  # ]:          0 :   if( !gme_ptr )
   14840                 :          0 :     return CUBIT_FAILURE;
   14841                 :            : 
   14842         [ #  # ]:          0 :   RefVertex *ref_vertex_ptr = ref_vertex_list.get();
   14843 [ #  # ][ #  # ]:          0 :   if( ref_vertex_list.size() == 1 && (edge1 || edge2 || edge3) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   14844                 :            :   {
   14845                 :            :     // Make sure input edges are attached to the input vertex
   14846         [ #  # ]:          0 :     DLIList<RefEdge*> ref_edge_list;
   14847         [ #  # ]:          0 :     ref_vertex_ptr->ref_edges( ref_edge_list );
   14848                 :            : 
   14849 [ #  # ][ #  # ]:          0 :     if( edge1 && !ref_edge_list.is_in_list( edge1 ) )
         [ #  # ][ #  # ]
   14850                 :            :     {
   14851 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Specified curve %d not attached to vertex %d\n", edge1->id(),
         [ #  # ][ #  # ]
                 [ #  # ]
   14852         [ #  # ]:          0 :         ref_vertex_ptr->id() );
   14853                 :          0 :       return CUBIT_FAILURE;
   14854                 :            :     }
   14855                 :            : 
   14856 [ #  # ][ #  # ]:          0 :     if( edge2 && !ref_edge_list.is_in_list( edge2 ) )
         [ #  # ][ #  # ]
   14857                 :            :     {
   14858 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Specified curve %d not attached to vertex %d\n", edge1->id(),
         [ #  # ][ #  # ]
                 [ #  # ]
   14859         [ #  # ]:          0 :         ref_vertex_ptr->id() );
   14860                 :          0 :       return CUBIT_FAILURE;
   14861                 :            :     }
   14862                 :            : 
   14863 [ #  # ][ #  # ]:          0 :     if( edge3 && !ref_edge_list.is_in_list( edge3 ) )
         [ #  # ][ #  # ]
   14864                 :            :     {
   14865 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Specified curve %d not attached to vertex %d\n", edge1->id(),
         [ #  # ][ #  # ]
                 [ #  # ]
   14866         [ #  # ]:          0 :         ref_vertex_ptr->id() );
   14867                 :          0 :       return CUBIT_FAILURE;
   14868                 :            :     }
   14869                 :            : 
   14870                 :            :     // Make sure offsets supplied
   14871 [ #  # ][ #  # ]:          0 :     if( edge1 && offset1 < 0.0 )
   14872                 :            :     {
   14873 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Offset for curve %d specified incorrectly.\n", edge1->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   14874                 :          0 :       return CUBIT_FAILURE;
   14875                 :            :     }
   14876                 :            : 
   14877 [ #  # ][ #  # ]:          0 :     if( edge2 && offset2 < 0.0 )
   14878                 :            :     {
   14879 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Offset for curve %d specified incorrectly.\n", edge2->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   14880                 :          0 :       return CUBIT_FAILURE;
   14881                 :            :     }
   14882                 :            : 
   14883 [ #  # ][ #  # ]:          0 :     if( edge3 && offset3 < 0.0 )
   14884                 :            :     {
   14885 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Offset for curve %d specified incorrectly.\n", edge3->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   14886 [ #  # ][ #  # ]:          0 :       return CUBIT_FAILURE;
   14887                 :          0 :     }
   14888                 :            :   }
   14889                 :            : 
   14890 [ #  # ][ #  # ]:          0 :   if( point_list.size() > 1 && offset2 > 0.0 )
         [ #  # ][ #  # ]
   14891                 :            :   {
   14892 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Cannot supply multiple radii when chamfering multiple vertices.\n" );
         [ #  # ][ #  # ]
   14893                 :          0 :     return CUBIT_FAILURE;
   14894                 :            :   }
   14895                 :            : 
   14896                 :          0 :   Curve *curve1 = NULL;
   14897                 :          0 :   Curve *curve2 = NULL;
   14898                 :          0 :   Curve *curve3 = NULL;
   14899                 :            : 
   14900         [ #  # ]:          0 :   if( edge1 )
   14901                 :            :   {
   14902                 :          0 :     TopologyBridge* bridge = 0;
   14903         [ #  # ]:          0 :     GeometryModifyEngine* edge_gme = get_engine(edge1, &bridge);
   14904         [ #  # ]:          0 :     if( gme_ptr != edge_gme )
   14905                 :            :     {
   14906 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Specified curve %d must belong to same geometry engine as vertex %d.\n",
         [ #  # ][ #  # ]
                 [ #  # ]
   14907         [ #  # ]:          0 :         edge1->id(), ref_vertex_ptr->id()  );
   14908                 :          0 :       return CUBIT_FAILURE;
   14909                 :            :     }
   14910         [ #  # ]:          0 :     curve1 = dynamic_cast<Curve*>(bridge);
   14911                 :            :   }
   14912                 :            : 
   14913         [ #  # ]:          0 :   if( edge2 )
   14914                 :            :   {
   14915                 :          0 :     TopologyBridge* bridge = 0;
   14916         [ #  # ]:          0 :     GeometryModifyEngine* edge_gme = get_engine(edge2, &bridge);
   14917         [ #  # ]:          0 :     if( gme_ptr != edge_gme )
   14918                 :            :     {
   14919 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Specified curve %d must belong to same geometry engine as vertex %d.\n",
         [ #  # ][ #  # ]
                 [ #  # ]
   14920         [ #  # ]:          0 :         edge2->id(), ref_vertex_ptr->id()  );
   14921                 :          0 :       return CUBIT_FAILURE;
   14922                 :            :     }
   14923         [ #  # ]:          0 :     curve2 = dynamic_cast<Curve*>(bridge);
   14924                 :            :   }
   14925                 :            : 
   14926         [ #  # ]:          0 :   if( edge3 )
   14927                 :            :   {
   14928                 :          0 :     TopologyBridge* bridge = 0;
   14929         [ #  # ]:          0 :     GeometryModifyEngine* edge_gme = get_engine(edge3, &bridge);
   14930         [ #  # ]:          0 :     if( gme_ptr != edge_gme )
   14931                 :            :     {
   14932 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Specified curve %d must belong to same geometry engine as vertex %d.\n",
         [ #  # ][ #  # ]
                 [ #  # ]
   14933         [ #  # ]:          0 :         edge3->id(), ref_vertex_ptr->id()  );
   14934                 :          0 :       return CUBIT_FAILURE;
   14935                 :            :     }
   14936         [ #  # ]:          0 :     curve3 = dynamic_cast<Curve*>(bridge);
   14937                 :            :   }
   14938                 :            : 
   14939 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   14940                 :            :   {
   14941         [ #  # ]:          0 :     if( keep_old_body )
   14942         [ #  # ]:          0 :       CubitUndo::save_state();
   14943                 :            :     else
   14944         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_vertex_list );
   14945                 :            :   }
   14946                 :            : 
   14947 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms;
   14948 [ #  # ][ #  # ]:          0 :   for(int i=old_body_list.size(); i--;)
   14949                 :            :   {
   14950 [ #  # ][ #  # ]:          0 :     BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   14951         [ #  # ]:          0 :     if(bsm)
   14952         [ #  # ]:          0 :       body_sms.append_unique(bsm);
   14953                 :            :   }
   14954                 :            :   
   14955         [ #  # ]:          0 :   if(!preview)
   14956                 :            :   {
   14957         [ #  # ]:          0 :     do_attribute_setup();
   14958         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   14959                 :            :   }
   14960                 :            : 
   14961                 :            :   // Do chamfering
   14962 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   14963                 :            :   CubitStatus stat = gme_ptr->tweak_chamfer( point_list, offset1, new_bodysm_list, curve1, offset2,
   14964         [ #  # ]:          0 :                                             curve2, offset3, curve3, keep_old_body, preview );
   14965                 :            :   
   14966         [ #  # ]:          0 :   if(stat == CUBIT_FAILURE)
   14967                 :            :   {
   14968 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   14969         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   14970         [ #  # ]:          0 :     if(!preview)
   14971                 :            :     {
   14972         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   14973         [ #  # ]:          0 :       do_attribute_cleanup();
   14974                 :            :     }
   14975                 :          0 :     return stat;
   14976                 :            :   }
   14977                 :            :   else
   14978                 :            :   {
   14979         [ #  # ]:          0 :     if(!preview)
   14980                 :            :     {
   14981         [ #  # ]:          0 :       restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   14982         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   14983                 :            :     }
   14984                 :            :   }
   14985                 :            :   
   14986         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   14987                 :            :   {
   14988                 :            :     // Update DAG
   14989         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   14990                 :            : 
   14991 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   14992                 :            :     {
   14993         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   14994         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   14995         [ #  # ]:          0 :       else if( keep_old_body )
   14996         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   14997                 :            :     }
   14998         [ #  # ]:          0 :     do_attribute_cleanup();
   14999                 :          0 :     return stat;
   15000                 :            :   }
   15001                 :            : 
   15002         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   15003                 :            : }
   15004                 :            : 
   15005                 :            : //=============================================================================
   15006                 :            : // Description: Create a round fillet (or blend) at the given curves on solid
   15007                 :            : //              or sheet bodies.
   15008                 :            : // Author     : Steve Storm
   15009                 :            : // Date       : 03/25/05
   15010                 :            : //=============================================================================
   15011                 :          0 : CubitStatus GeometryModifyTool::tweak_fillet( DLIList<RefEdge*> &ref_edge_list,
   15012                 :            :                                               double radius,
   15013                 :            :                                               DLIList<Body*> &new_body_list,
   15014                 :            :                                               CubitBoolean keep_old_body,
   15015                 :            :                                               CubitBoolean preview )
   15016                 :            : {
   15017 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
   15018 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   15019                 :            :   GeometryModifyEngine* gme_ptr;
   15020                 :            : 
   15021         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_edge_list, "Filleting", old_body_list, curve_list, CUBIT_TRUE );
   15022         [ #  # ]:          0 :   if( !gme_ptr )
   15023                 :          0 :     return CUBIT_FAILURE;
   15024                 :            : 
   15025 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15026                 :            :   {
   15027         [ #  # ]:          0 :     if( keep_old_body )
   15028         [ #  # ]:          0 :       CubitUndo::save_state();
   15029                 :            :     else
   15030         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edge_list );
   15031                 :            :   }
   15032                 :            : 
   15033 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms;
   15034 [ #  # ][ #  # ]:          0 :   for(int i=old_body_list.size(); i--;)
   15035                 :            :   {
   15036 [ #  # ][ #  # ]:          0 :     BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   15037         [ #  # ]:          0 :     if(bsm)
   15038         [ #  # ]:          0 :       body_sms.append_unique(bsm);
   15039                 :            :   }
   15040                 :            :   
   15041         [ #  # ]:          0 :   if(!preview)
   15042                 :            :   {
   15043         [ #  # ]:          0 :     do_attribute_setup();
   15044         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   15045                 :            :   }
   15046                 :            : 
   15047                 :            :   // Do filleting
   15048 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   15049                 :            :   CubitStatus stat = gme_ptr->tweak_fillet(curve_list, radius, new_bodysm_list, keep_old_body,
   15050         [ #  # ]:          0 :                                            preview );
   15051                 :            :   
   15052         [ #  # ]:          0 :   if(stat == CUBIT_FAILURE )
   15053                 :            :   {
   15054         [ #  # ]:          0 :     if(!preview)
   15055                 :            :     {
   15056 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   15057         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15058         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   15059         [ #  # ]:          0 :       do_attribute_cleanup();
   15060                 :            :     }
   15061                 :          0 :     return stat;
   15062                 :            :   }
   15063                 :            :   else
   15064                 :            :   {
   15065         [ #  # ]:          0 :     if(!preview)
   15066                 :            :     {
   15067         [ #  # ]:          0 :       restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   15068         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   15069                 :            :     }
   15070                 :            :   }
   15071                 :            :   
   15072         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   15073                 :            :   {
   15074                 :            :     // Update DAG
   15075         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   15076                 :            : 
   15077 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   15078                 :            :     {
   15079         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   15080         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15081         [ #  # ]:          0 :       else if( keep_old_body )
   15082         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   15083                 :            :     }
   15084         [ #  # ]:          0 :     do_attribute_cleanup();
   15085                 :            : 
   15086                 :          0 :     return stat;
   15087                 :            :   }
   15088         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   15089                 :            : }
   15090                 :            : 
   15091                 :            : //=============================================================================
   15092                 :            : // Description: Create a round fillet (or blend) at the given curves on a solid
   15093                 :            : //              or sheet body.  The fillet has a variable radius from the start
   15094                 :            : //              to the end of the curve.
   15095                 :            : // Author     : Steve Storm
   15096                 :            : // Date       : 03/25/05
   15097                 :            : //=============================================================================
   15098                 :          0 : CubitStatus GeometryModifyTool::tweak_fillet( RefEdge *ref_edge_ptr,
   15099                 :            :                                               double start_radius,
   15100                 :            :                                               double end_radius,
   15101                 :            :                                               Body *&new_body_ptr,
   15102                 :            :                                               CubitBoolean keep_old_body,
   15103                 :            :                                               CubitBoolean preview )
   15104                 :            : {
   15105         [ #  # ]:          0 :   DLIList<Curve*> curve_list(1);
   15106 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   15107                 :            :   GeometryModifyEngine* gme_ptr;
   15108                 :            : 
   15109 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> ref_edge_list(1);
   15110         [ #  # ]:          0 :   ref_edge_list.append( ref_edge_ptr );
   15111                 :            : 
   15112         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_edge_list, "Filleting", old_body_list, curve_list, CUBIT_TRUE );
   15113         [ #  # ]:          0 :   if( !gme_ptr )
   15114                 :          0 :     return CUBIT_FAILURE;
   15115                 :            : 
   15116 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15117                 :            :   {
   15118         [ #  # ]:          0 :     if( keep_old_body )
   15119         [ #  # ]:          0 :       CubitUndo::save_state();
   15120                 :            :     else
   15121                 :            :     {
   15122         [ #  # ]:          0 :       DLIList<RefEdge*> edges(1);
   15123         [ #  # ]:          0 :       edges.append( ref_edge_ptr );
   15124 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( edges );
   15125                 :            :     }
   15126                 :            :   }
   15127                 :            :   
   15128 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms;
   15129 [ #  # ][ #  # ]:          0 :   for(int i=old_body_list.size(); i--;)
   15130                 :            :   {
   15131 [ #  # ][ #  # ]:          0 :     BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   15132         [ #  # ]:          0 :     if(bsm)
   15133         [ #  # ]:          0 :       body_sms.append_unique(bsm);
   15134                 :            :   }
   15135                 :            :   
   15136         [ #  # ]:          0 :   if(!preview)
   15137                 :            :   {
   15138         [ #  # ]:          0 :     do_attribute_setup();
   15139         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   15140                 :            :   }
   15141                 :            : 
   15142                 :            :   // Do filleting
   15143                 :            :   BodySM *new_bodysm_ptr;
   15144         [ #  # ]:          0 :   Curve *curve_ptr = curve_list.get();
   15145                 :            :   CubitStatus stat = gme_ptr->tweak_fillet( curve_ptr, start_radius,
   15146                 :            :                                             end_radius, new_bodysm_ptr,
   15147         [ #  # ]:          0 :                                             keep_old_body, preview );
   15148                 :            : 
   15149 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   15150         [ #  # ]:          0 :     if( stat == CUBIT_FAILURE)
   15151         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   15152                 :            : 
   15153 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   15154         [ #  # ]:          0 :   new_bodysm_list.append(new_bodysm_ptr);
   15155         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   15156                 :            :   {
   15157         [ #  # ]:          0 :     remove_pushed_attributes(new_bodysm_list, old_body_list);
   15158         [ #  # ]:          0 :     do_attribute_cleanup();
   15159                 :          0 :     return stat;
   15160                 :            :   }
   15161                 :            :   else
   15162                 :            :   {
   15163         [ #  # ]:          0 :     restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   15164         [ #  # ]:          0 :     remove_pushed_attributes(new_bodysm_list, old_body_list);
   15165                 :            :   }
   15166                 :            : 
   15167         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   15168                 :            :   {
   15169                 :            :     // Update DAG
   15170         [ #  # ]:          0 :     DLIList<BodySM*> new_bodysm_list;
   15171         [ #  # ]:          0 :     new_bodysm_list.append( new_bodysm_ptr );
   15172 [ #  # ][ #  # ]:          0 :     DLIList<Body*> new_body_list;
   15173         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   15174                 :            : 
   15175 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   15176                 :            :     {
   15177         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   15178         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15179         [ #  # ]:          0 :       else if( keep_old_body )
   15180         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   15181                 :            :     }
   15182                 :            : 
   15183         [ #  # ]:          0 :     new_body_ptr = new_body_list.get();
   15184                 :            : 
   15185         [ #  # ]:          0 :     do_attribute_cleanup();
   15186                 :            : 
   15187         [ #  # ]:          0 :     return stat;
   15188                 :            :   }
   15189         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   15190                 :            : }
   15191                 :            : 
   15192                 :            : //=============================================================================
   15193                 :            : // Description: Create a round fillet (or blend) at the given vertices on sheet
   15194                 :            : //              bodies.
   15195                 :            : // Author     : Steve Storm
   15196                 :            : // Date       : 03/25/05
   15197                 :            : //=============================================================================
   15198                 :            : CubitStatus
   15199                 :          0 : GeometryModifyTool::tweak_fillet( DLIList<RefVertex*> &ref_vertex_list,
   15200                 :            :                                   double radius,
   15201                 :            :                                   DLIList<Body*> &new_body_list,
   15202                 :            :                                   CubitBoolean keep_old_body,
   15203                 :            :                                   CubitBoolean preview )
   15204                 :            : {
   15205 [ #  # ][ #  # ]:          0 :   DLIList<TBPoint*> point_list(ref_vertex_list.size());
   15206 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   15207                 :            :   GeometryModifyEngine* gme_ptr;
   15208                 :            : 
   15209         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_vertex_list, "Filleting", old_body_list, point_list, CUBIT_TRUE );
   15210         [ #  # ]:          0 :   if( !gme_ptr )
   15211                 :          0 :     return CUBIT_FAILURE;
   15212                 :            : 
   15213 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15214                 :            :   {
   15215         [ #  # ]:          0 :     if( keep_old_body )
   15216         [ #  # ]:          0 :       CubitUndo::save_state();
   15217                 :            :     else
   15218         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_vertex_list );
   15219                 :            :   }
   15220                 :            :   
   15221 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms;
   15222 [ #  # ][ #  # ]:          0 :   for(int i=old_body_list.size(); i--;)
   15223                 :            :   {
   15224 [ #  # ][ #  # ]:          0 :     BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   15225         [ #  # ]:          0 :     if(bsm)
   15226         [ #  # ]:          0 :       body_sms.append_unique(bsm);
   15227                 :            :   }
   15228                 :            :   
   15229         [ #  # ]:          0 :   if(!preview)
   15230                 :            :   {
   15231         [ #  # ]:          0 :     do_attribute_setup();
   15232         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   15233                 :            :   }
   15234                 :            : 
   15235                 :            :   // Do filleting
   15236 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   15237                 :            :   CubitStatus stat = gme_ptr->tweak_fillet( point_list, radius,
   15238                 :            :                                             new_bodysm_list, keep_old_body,
   15239         [ #  # ]:          0 :                                             preview );
   15240         [ #  # ]:          0 :   if(stat == CUBIT_FAILURE )
   15241                 :            :   {
   15242         [ #  # ]:          0 :     if(!preview)
   15243                 :            :     {
   15244 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   15245         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15246         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   15247         [ #  # ]:          0 :       do_attribute_cleanup();
   15248                 :            :     }
   15249                 :          0 :     return stat;
   15250                 :            :   }
   15251                 :            :   else
   15252                 :            :   {
   15253         [ #  # ]:          0 :     if(!preview)
   15254                 :            :     {
   15255         [ #  # ]:          0 :       restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   15256         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   15257                 :            :     }
   15258                 :            :   }
   15259                 :            : 
   15260         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   15261                 :            :   {
   15262                 :            :     // Update DAG
   15263         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   15264                 :            : 
   15265 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   15266                 :            :     {
   15267         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   15268         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15269         [ #  # ]:          0 :       else if( keep_old_body )
   15270         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   15271                 :            :     }
   15272                 :            :     
   15273         [ #  # ]:          0 :     do_attribute_cleanup();
   15274                 :            : 
   15275                 :          0 :     return stat;
   15276                 :            :   }
   15277         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   15278                 :            : }
   15279                 :            : 
   15280                 :            : //=============================================================================
   15281                 :            : // Description: Tweak specified faces of a volume or volumes along a vector.
   15282                 :            : // Author     : Steve Storm
   15283                 :            : // Date       : 03/25/05
   15284                 :            : //=============================================================================
   15285                 :          0 : CubitStatus GeometryModifyTool::tweak_move( DLIList<RefFace*>& ref_face_list,
   15286                 :            :                                             const CubitVector &delta,
   15287                 :            :                                             DLIList<Body*>& new_body_list,
   15288                 :            :                                             CubitBoolean keep_old_body,
   15289                 :            :                                             CubitBoolean preview )
   15290                 :            : {
   15291 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list(ref_face_list.size());
   15292 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   15293                 :            :   GeometryModifyEngine* gme_ptr;
   15294                 :            : 
   15295         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_face_list, "Moving", old_body_list, surface_list, CUBIT_TRUE );
   15296         [ #  # ]:          0 :   if (!gme_ptr)
   15297                 :          0 :     return CUBIT_FAILURE;
   15298                 :            : 
   15299 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15300                 :            :   {
   15301         [ #  # ]:          0 :     if( keep_old_body )
   15302         [ #  # ]:          0 :       CubitUndo::save_state();
   15303                 :            :     else
   15304                 :            :     {
   15305                 :            :       int i;
   15306         [ #  # ]:          0 :       DLIList<RefEdge*> ref_edges;
   15307 [ #  # ][ #  # ]:          0 :       for( i=ref_face_list.size(); i--; )
   15308 [ #  # ][ #  # ]:          0 :         ref_face_list.get_and_step()->ref_edges( ref_edges );
   15309         [ #  # ]:          0 :       ref_edges.uniquify_unordered();
   15310 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edges );
   15311                 :            :     }
   15312                 :            :   }
   15313                 :            : 
   15314                 :            :   int i;
   15315 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms;
   15316 [ #  # ][ #  # ]:          0 :   for(i=old_body_list.size(); i--;)
   15317                 :            :   {
   15318 [ #  # ][ #  # ]:          0 :     BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   15319         [ #  # ]:          0 :     if(bsm)
   15320         [ #  # ]:          0 :       body_sms.append_unique(bsm);
   15321                 :            :   }
   15322                 :            : 
   15323         [ #  # ]:          0 :   if(!preview)
   15324                 :            :   {
   15325         [ #  # ]:          0 :     do_attribute_setup();
   15326         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   15327                 :            :   }
   15328                 :            : 
   15329                 :            :   // Do move
   15330 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   15331                 :            :   CubitStatus stat = gme_ptr->tweak_move( surface_list, delta,
   15332                 :            :                                           new_bodysm_list, keep_old_body,
   15333         [ #  # ]:          0 :                                           preview );
   15334                 :            : 
   15335                 :            : 
   15336 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   15337         [ #  # ]:          0 :     if( stat == CUBIT_FAILURE)
   15338         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   15339                 :            : 
   15340         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   15341                 :            :   {
   15342         [ #  # ]:          0 :     if(!preview)
   15343                 :            :     {
   15344         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   15345         [ #  # ]:          0 :       do_attribute_cleanup();
   15346                 :            :     }
   15347                 :          0 :     return stat;
   15348                 :            :   }
   15349                 :            :   else
   15350                 :            :   {
   15351         [ #  # ]:          0 :     if(!preview)
   15352                 :            :     {
   15353         [ #  # ]:          0 :       restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   15354         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   15355                 :            :     }
   15356                 :            :   }
   15357                 :            : 
   15358                 :            :   // loop body sm list and find surfaces that need updating.
   15359                 :            :   // this is to account for some cases where the topology doesn't change, but the geometry does.
   15360 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
   15361 [ #  # ][ #  # ]:          0 :   for(i=0; i<new_bodysm_list.size(); i++)
   15362                 :            :   {
   15363         [ #  # ]:          0 :     BodySM* bodysm = new_bodysm_list.get_and_step();
   15364         [ #  # ]:          0 :     DLIList<Surface*> surfs;
   15365         [ #  # ]:          0 :     bodysm->surfaces(surfs);
   15366                 :            :     int j;
   15367                 :            :     // find a surface that is also found in our input list
   15368 [ #  # ][ #  # ]:          0 :     for(j=0; j<surfs.size(); j++, surfs.step())
                 [ #  # ]
   15369                 :            :     {
   15370 [ #  # ][ #  # ]:          0 :       BridgeManager* man = surfs.get()->bridge_manager();
   15371         [ #  # ]:          0 :       if(man)
   15372                 :            :       {
   15373 [ #  # ][ #  # ]:          0 :         RefFace* ref_face = CAST_TO(man->topology_entity(), RefFace);
   15374 [ #  # ][ #  # ]:          0 :         if(ref_face && ref_face_list.is_in_list(ref_face))
         [ #  # ][ #  # ]
   15375                 :            :         {
   15376                 :            :           // get neighbors
   15377         [ #  # ]:          0 :           DLIList<TBPoint*> neighbor_points;
   15378 [ #  # ][ #  # ]:          0 :           surfs.get()->points(neighbor_points);
   15379 [ #  # ][ #  # ]:          0 :           DLIList<Curve*> neighbor_curves;
   15380 [ #  # ][ #  # ]:          0 :           DLIList<Surface*> neighbor_surfaces;
   15381 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> neighbors;
   15382 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> tmp;
   15383                 :            :           int k;
   15384 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   15385 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->surfaces(neighbor_surfaces);
   15386 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   15387 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->curves(neighbor_curves);
   15388                 :            : 
   15389 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15390         [ #  # ]:          0 :           neighbors += tmp;
   15391         [ #  # ]:          0 :           neighbor_curves.uniquify_ordered();
   15392 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15393         [ #  # ]:          0 :           neighbors += tmp;
   15394         [ #  # ]:          0 :           neighbor_surfaces.uniquify_ordered();
   15395 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_surfaces, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15396         [ #  # ]:          0 :           neighbors += tmp;
   15397 [ #  # ][ #  # ]:          0 :           neighbors.append(surfs.get()->lump());
                 [ #  # ]
   15398 [ #  # ][ #  # ]:          0 :           neighbors.append(surfs.get()->bodysm());
                 [ #  # ]
   15399                 :            : 
   15400 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbors.size(); k++)
   15401 [ #  # ][ #  # ]:          0 :             if(BridgeManager* m = neighbors.get_and_step()->bridge_manager())
                 [ #  # ]
   15402 [ #  # ][ #  # ]:          0 :               if(TopologyEntity* t = m->topology_entity())
   15403 [ #  # ][ #  # ]:          0 :                 entities_to_update.append(CAST_TO(t, RefEntity));
                 [ #  # ]
   15404                 :            :         }
   15405                 :            :       }
   15406                 :            :     }
   15407         [ #  # ]:          0 :   }
   15408                 :            : 
   15409         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   15410                 :            :   {
   15411                 :            :     // Update DAG
   15412         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   15413                 :            : 
   15414 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   15415                 :            :     {
   15416         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   15417         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15418         [ #  # ]:          0 :       else if( keep_old_body )
   15419         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   15420                 :            :     }
   15421                 :            : 
   15422                 :            :     // Update graphics
   15423 [ #  # ][ #  # ]:          0 :     while (entities_to_update.size())
   15424 [ #  # ][ #  # ]:          0 :       AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entities_to_update.pop()));
         [ #  # ][ #  # ]
                 [ #  # ]
   15425                 :            : 
   15426         [ #  # ]:          0 :     do_attribute_cleanup();
   15427                 :            :   }
   15428                 :            : 
   15429                 :            : 
   15430                 :            :   //collect all the new faces
   15431 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> new_faces;
   15432 [ #  # ][ #  # ]:          0 :   for( i=new_body_list.size(); i--; )
   15433                 :            :   {
   15434         [ #  # ]:          0 :     Body *new_body = new_body_list.get_and_step();
   15435         [ #  # ]:          0 :     DLIList<RefFace*> tmp_faces;
   15436         [ #  # ]:          0 :     new_body->ref_faces( tmp_faces );
   15437         [ #  # ]:          0 :     new_faces += tmp_faces;
   15438         [ #  # ]:          0 :   }
   15439                 :            : 
   15440                 :            :   //unmerge any merged adjacent surfaces or
   15441                 :            :   //merged curves in unmerged adjacent surfaces
   15442 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> adjacent_faces_to_unmerge;
   15443 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> adjacent_edges_to_unmerge;
   15444 [ #  # ][ #  # ]:          0 :   for(i=ref_face_list.size(); i--;)
   15445                 :            :   {
   15446         [ #  # ]:          0 :     RefFace *tweaked_face = ref_face_list.get_and_step();
   15447 [ #  # ][ #  # ]:          0 :     if( !new_faces.move_to( tweaked_face ) )
   15448                 :          0 :       continue;
   15449                 :            : 
   15450                 :            :     //get all the edges of the face you tweaked
   15451         [ #  # ]:          0 :     DLIList<RefEdge*> tweaked_face_edges;
   15452         [ #  # ]:          0 :     tweaked_face->ref_edges( tweaked_face_edges );
   15453         [ #  # ]:          0 :     adjacent_edges_to_unmerge += tweaked_face_edges;
   15454                 :            : 
   15455                 :            :     //get all the adjacent faces to this edge
   15456                 :            :     int j;
   15457 [ #  # ][ #  # ]:          0 :     for( j=tweaked_face_edges.size(); j--; )
   15458                 :            :     {
   15459         [ #  # ]:          0 :       RefEdge *tmp_edge = tweaked_face_edges.get_and_step();
   15460         [ #  # ]:          0 :       DLIList<RefFace*> tmp_faces;
   15461         [ #  # ]:          0 :       tmp_edge->ref_faces( tmp_faces );
   15462         [ #  # ]:          0 :       tmp_faces.remove( tweaked_face );
   15463         [ #  # ]:          0 :       adjacent_faces_to_unmerge += tmp_faces;
   15464         [ #  # ]:          0 :     }
   15465                 :            : 
   15466                 :            :     //get all edges not in the surface,
   15467                 :            :     //sharing vertices with the surface
   15468 [ #  # ][ #  # ]:          0 :     DLIList<RefVertex*> ref_vertices;
   15469         [ #  # ]:          0 :     tweaked_face->ref_vertices( ref_vertices );
   15470 [ #  # ][ #  # ]:          0 :     for( j=ref_vertices.size(); j--; )
   15471                 :            :     {
   15472         [ #  # ]:          0 :       RefVertex *tmp_vert = ref_vertices.get_and_step();
   15473         [ #  # ]:          0 :       DLIList<RefEdge*>  ref_edges;
   15474         [ #  # ]:          0 :       tmp_vert->ref_edges( ref_edges );
   15475                 :            : 
   15476                 :            :       int k;
   15477 [ #  # ][ #  # ]:          0 :       for( k=ref_edges.size(); k--; )
   15478                 :            :       {
   15479         [ #  # ]:          0 :         RefEdge *tmp_edge = ref_edges.get_and_step();
   15480 [ #  # ][ #  # ]:          0 :         if( !tweaked_face_edges.move_to( tmp_edge ) )
   15481         [ #  # ]:          0 :           adjacent_edges_to_unmerge.append( tmp_edge );
   15482                 :            :       }
   15483         [ #  # ]:          0 :     }
   15484         [ #  # ]:          0 :   }
   15485                 :            : 
   15486                 :            :   //unmerge any adjacent faces
   15487         [ #  # ]:          0 :   adjacent_faces_to_unmerge.uniquify_unordered();
   15488 [ #  # ][ #  # ]:          0 :   for( i=adjacent_faces_to_unmerge.size(); i--; )
   15489                 :            :   {
   15490         [ #  # ]:          0 :     RefFace *ref_face = adjacent_faces_to_unmerge.get_and_step();
   15491                 :            : 
   15492         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
   15493 [ #  # ][ #  # ]:          0 :     ref_face->bridge_manager()->get_bridge_list(bridge_list);
   15494 [ #  # ][ #  # ]:          0 :     if (bridge_list.size() > 1)
   15495                 :            :     {
   15496 [ #  # ][ #  # ]:          0 :       if( MergeTool::instance()->unmerge( ref_face ) )
                 [ #  # ]
   15497 [ #  # ][ #  # ]:          0 :         PRINT_WARNING("Unmerging Surface %d\n", ref_face->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   15498                 :            :     }
   15499         [ #  # ]:          0 :   }
   15500                 :            : 
   15501                 :            :   //unmerge any adjacent edges
   15502         [ #  # ]:          0 :   adjacent_edges_to_unmerge.uniquify_unordered();
   15503 [ #  # ][ #  # ]:          0 :   for( i=adjacent_edges_to_unmerge.size(); i--; )
   15504                 :            :   {
   15505         [ #  # ]:          0 :     RefEdge *ref_edge = adjacent_edges_to_unmerge.get_and_step();
   15506         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
   15507 [ #  # ][ #  # ]:          0 :     ref_edge->bridge_manager()->get_bridge_list(bridge_list);
   15508 [ #  # ][ #  # ]:          0 :     if (bridge_list.size() > 1)
   15509                 :            :     {
   15510 [ #  # ][ #  # ]:          0 :       if( MergeTool::instance()->unmerge( ref_edge) )
                 [ #  # ]
   15511 [ #  # ][ #  # ]:          0 :         PRINT_WARNING("Unmerging Curve %d\n", ref_edge->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   15512                 :            :     }
   15513         [ #  # ]:          0 :   }
   15514                 :            : 
   15515                 :            : 
   15516         [ #  # ]:          0 :   return stat;
   15517                 :            : }
   15518                 :            : 
   15519                 :            : //=============================================================================
   15520                 :            : // Description: Tweak specified curves of a sheet body along a vector.
   15521                 :            : // Author     : Steve Storm
   15522                 :            : // Date       : 03/25/05
   15523                 :            : //=============================================================================
   15524                 :          0 : CubitStatus GeometryModifyTool::tweak_move( DLIList<RefEdge*>& ref_edge_list,
   15525                 :            :                                             const CubitVector &delta,
   15526                 :            :                                             DLIList<Body*>& new_body_list,
   15527                 :            :                                             CubitBoolean keep_old_body,
   15528                 :            :                                             CubitBoolean preview )
   15529                 :            : {
   15530 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
   15531 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   15532                 :            :   GeometryModifyEngine* gme_ptr;
   15533                 :            : 
   15534         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_edge_list, "Moving", old_body_list, curve_list );
   15535         [ #  # ]:          0 :   if (!gme_ptr)
   15536                 :          0 :     return CUBIT_FAILURE;
   15537                 :            : 
   15538 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15539                 :            :   {
   15540         [ #  # ]:          0 :     if( keep_old_body )
   15541         [ #  # ]:          0 :       CubitUndo::save_state();
   15542                 :            :     else
   15543         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edge_list );
   15544                 :            :   }
   15545                 :            : 
   15546                 :            :   // Do move
   15547 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   15548                 :            :   CubitStatus stat = gme_ptr->tweak_move( curve_list, delta,
   15549                 :            :                                           new_bodysm_list, keep_old_body,
   15550         [ #  # ]:          0 :                                           preview );
   15551                 :            : 
   15552 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   15553         [ #  # ]:          0 :     if( stat == CUBIT_FAILURE)
   15554         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   15555                 :            : 
   15556         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   15557                 :          0 :     return stat;
   15558                 :            : 
   15559         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   15560                 :            :   {
   15561                 :            :     // Update DAG
   15562         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   15563                 :            : 
   15564 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   15565                 :            :     {
   15566         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   15567         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15568         [ #  # ]:          0 :       else if( keep_old_body )
   15569         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   15570                 :            :     }
   15571                 :            :   }
   15572                 :            : 
   15573                 :            :   // Update graphics
   15574 [ #  # ][ #  # ]:          0 :   DLIList<Body*> moved_bodies(new_body_list);
   15575         [ #  # ]:          0 :   moved_bodies.intersect(old_body_list);
   15576 [ #  # ][ #  # ]:          0 :   while (moved_bodies.size())
   15577 [ #  # ][ #  # ]:          0 :     moved_bodies.pop()->notify_sub_all_observers( GeometryEvent::GEOMETRY_MODIFIED );
   15578                 :            : 
   15579         [ #  # ]:          0 :   return stat;
   15580                 :            : }
   15581                 :            : 
   15582                 :            : //=============================================================================
   15583                 :            : // Description: Tweak specified faces of a volume or volumes by offsetting
   15584                 :            : //              those faces by the offset distance.
   15585                 :            : // Author     : Steve Storm
   15586                 :            : // Date       : 03/25/05
   15587                 :            : //=============================================================================
   15588                 :          0 : CubitStatus GeometryModifyTool::tweak_offset( DLIList<RefFace*> &ref_face_list,
   15589                 :            :                                               double offset_distance,
   15590                 :            :                                               DLIList<RefFace*> *add_ref_face_list_ptr,
   15591                 :            :                                               DLIList<double> *add_offset_list_ptr,
   15592                 :            :                                               DLIList<Body*> &new_body_list,
   15593                 :            :                                               CubitBoolean keep_old_body,
   15594                 :            :                                               CubitBoolean preview )
   15595                 :            : {
   15596 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> all_ref_face_list(ref_face_list.size());
   15597         [ #  # ]:          0 :   all_ref_face_list = ref_face_list;
   15598 [ #  # ][ #  # ]:          0 :   if( add_ref_face_list_ptr->size() )
   15599         [ #  # ]:          0 :     all_ref_face_list += *add_ref_face_list_ptr;
   15600                 :            : 
   15601 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list(ref_face_list.size());
                 [ #  # ]
   15602 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   15603                 :            :   GeometryModifyEngine* gme_ptr;
   15604                 :            : 
   15605         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_face_list, "Offsetting", old_body_list, surface_list, CUBIT_TRUE );
   15606         [ #  # ]:          0 :   if (!gme_ptr)
   15607                 :          0 :     return CUBIT_FAILURE;
   15608                 :            : 
   15609 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> add_surface_list;
   15610 [ #  # ][ #  # ]:          0 :   if( add_ref_face_list_ptr && add_ref_face_list_ptr->size() )
         [ #  # ][ #  # ]
   15611                 :            :   {
   15612         [ #  # ]:          0 :     DLIList<Body*> old_body_list2;
   15613                 :            :     GeometryModifyEngine* gme_ptr2 = tweak_setup( *add_ref_face_list_ptr, "Offsetting",
   15614         [ #  # ]:          0 :       old_body_list2, add_surface_list, CUBIT_TRUE );
   15615         [ #  # ]:          0 :     if (!gme_ptr2)
   15616                 :          0 :       return CUBIT_FAILURE;
   15617         [ #  # ]:          0 :     if( gme_ptr != gme_ptr2 )
   15618                 :            :     {
   15619 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Offsetting surfaces on volumes containing surfaces from different\n"
                 [ #  # ]
   15620         [ #  # ]:          0 :         "       geometry engines is not allowed.\n");
   15621                 :          0 :       return CUBIT_FAILURE;
   15622                 :            :     }
   15623 [ #  # ][ #  # ]:          0 :     old_body_list.merge_unique( old_body_list2 );
                 [ #  # ]
   15624                 :            :   }
   15625                 :            : 
   15626 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15627                 :            :   {
   15628         [ #  # ]:          0 :     if( keep_old_body )
   15629         [ #  # ]:          0 :       CubitUndo::save_state();
   15630                 :            :     else
   15631                 :            :     {
   15632                 :            :       int i;
   15633         [ #  # ]:          0 :       DLIList<RefEdge*> ref_edges;
   15634 [ #  # ][ #  # ]:          0 :       for( i=ref_face_list.size(); i--; )
   15635 [ #  # ][ #  # ]:          0 :         all_ref_face_list.get_and_step()->ref_edges( ref_edges );
   15636         [ #  # ]:          0 :       ref_edges.uniquify_unordered();
   15637 [ #  # ][ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edges );
   15638                 :            :     }
   15639                 :            :   }
   15640                 :            : 
   15641                 :            :   int i;
   15642         [ #  # ]:          0 :   if(!preview)
   15643                 :            :   {
   15644         [ #  # ]:          0 :     DLIList<BodySM*> body_sms;
   15645 [ #  # ][ #  # ]:          0 :     for(i=old_body_list.size(); i--;)
   15646                 :            :     {
   15647 [ #  # ][ #  # ]:          0 :       BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   15648         [ #  # ]:          0 :       if(bsm)
   15649         [ #  # ]:          0 :         body_sms.append_unique(bsm);
   15650                 :            :     }
   15651                 :            : 
   15652         [ #  # ]:          0 :     do_attribute_setup();
   15653 [ #  # ][ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   15654                 :            :   }
   15655                 :            : 
   15656                 :            :   // Do offset
   15657 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   15658                 :            :   CubitStatus stat;
   15659 [ #  # ][ #  # ]:          0 :   if( add_surface_list.size() )
   15660                 :            :     stat = gme_ptr->tweak_offset( surface_list, offset_distance,
   15661                 :            :                                   &add_surface_list, add_offset_list_ptr,
   15662         [ #  # ]:          0 :                                   new_bodysm_list, keep_old_body, preview );
   15663                 :            :   else
   15664                 :            :     stat = gme_ptr->tweak_offset( surface_list, offset_distance, NULL, NULL,
   15665         [ #  # ]:          0 :                                   new_bodysm_list, keep_old_body, preview );
   15666                 :            : 
   15667 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   15668         [ #  # ]:          0 :     if( stat == CUBIT_FAILURE)
   15669         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   15670                 :            : 
   15671         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   15672                 :            :   {
   15673         [ #  # ]:          0 :     if(!preview)
   15674                 :            :     {
   15675         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   15676         [ #  # ]:          0 :       do_attribute_cleanup();
   15677                 :            :     }
   15678                 :          0 :     return stat;
   15679                 :            :   }
   15680                 :            :   else
   15681                 :            :   {
   15682         [ #  # ]:          0 :     if(!preview)
   15683                 :            :     {
   15684         [ #  # ]:          0 :       restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   15685         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   15686                 :            :     }
   15687                 :            :   }
   15688                 :            : 
   15689                 :            :   // Collect all of the old faces to be compared later with the new faces...DJQ
   15690 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> old_faces;
   15691 [ #  # ][ #  # ]:          0 :   for (i = 0; i < old_body_list.size(); i++)
   15692                 :            :   {
   15693         [ #  # ]:          0 :       Body *old_body = old_body_list.get_and_step();
   15694         [ #  # ]:          0 :       DLIList<RefFace*> tmp_faces;
   15695         [ #  # ]:          0 :       old_body->ref_faces(tmp_faces);
   15696         [ #  # ]:          0 :       old_faces +=tmp_faces;
   15697         [ #  # ]:          0 :   }
   15698                 :            : 
   15699         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   15700                 :            :   {
   15701                 :            :     // Update DAG
   15702         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   15703                 :            : 
   15704 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   15705                 :            :     {
   15706         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   15707         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15708         [ #  # ]:          0 :       else if( keep_old_body )
   15709         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   15710                 :            :     }
   15711         [ #  # ]:          0 :     do_attribute_cleanup();
   15712                 :            :   }
   15713                 :            : 
   15714                 :            :   //collect all the new faces
   15715 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> new_faces;
   15716 [ #  # ][ #  # ]:          0 :   for( i=new_body_list.size(); i--; )
   15717                 :            :   {
   15718         [ #  # ]:          0 :     Body *new_body = new_body_list.get_and_step();
   15719         [ #  # ]:          0 :     DLIList<RefFace*> tmp_faces;
   15720         [ #  # ]:          0 :     new_body->ref_faces( tmp_faces );
   15721         [ #  # ]:          0 :     new_faces += tmp_faces;
   15722         [ #  # ]:          0 :   }
   15723                 :            : 
   15724                 :            :   // Compare the new_faces list with the old_faces list to determine which faces are created
   15725                 :            :   // Add these faces to the all_ref_face_list to check for its neighbors...DJQ
   15726 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> difference = new_faces;
   15727         [ #  # ]:          0 :   difference -= old_faces;
   15728         [ #  # ]:          0 :   all_ref_face_list += difference;
   15729                 :            : 
   15730                 :            :   // loop body sm list and find surfaces that need updating.
   15731                 :            :   // this is to account for some cases where the topology
   15732                 :            :   //doesn't change, but the geometry does.
   15733                 :            : 
   15734 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
   15735 [ #  # ][ #  # ]:          0 :   for(i=0; i<new_bodysm_list.size(); i++)
   15736                 :            :   {
   15737         [ #  # ]:          0 :     BodySM* bodysm = new_bodysm_list.get_and_step();
   15738         [ #  # ]:          0 :     DLIList<Surface*> surfs;
   15739         [ #  # ]:          0 :     bodysm->surfaces(surfs);
   15740                 :            :     int j;
   15741                 :            :     // find a surface that is also found in our input list
   15742 [ #  # ][ #  # ]:          0 :     for(j=0; j<surfs.size(); j++, surfs.step())
                 [ #  # ]
   15743                 :            :     {
   15744 [ #  # ][ #  # ]:          0 :       BridgeManager* man = surfs.get()->bridge_manager();
   15745         [ #  # ]:          0 :       if(man)
   15746                 :            :       {
   15747 [ #  # ][ #  # ]:          0 :         RefFace* ref_face = CAST_TO(man->topology_entity(), RefFace);
   15748 [ #  # ][ #  # ]:          0 :         if(ref_face && all_ref_face_list.is_in_list(ref_face))
         [ #  # ][ #  # ]
   15749                 :            :         {
   15750                 :            :           // get neighbors
   15751         [ #  # ]:          0 :           DLIList<TBPoint*> neighbor_points;
   15752 [ #  # ][ #  # ]:          0 :           surfs.get()->points(neighbor_points);
   15753 [ #  # ][ #  # ]:          0 :           DLIList<Curve*> neighbor_curves;
   15754 [ #  # ][ #  # ]:          0 :           DLIList<Surface*> neighbor_surfaces;
   15755 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> neighbors;
   15756 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> tmp;
   15757                 :            :           int k;
   15758 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   15759 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->surfaces(neighbor_surfaces);
   15760 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   15761 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->curves(neighbor_curves);
   15762                 :            : 
   15763 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15764         [ #  # ]:          0 :           neighbors += tmp;
   15765         [ #  # ]:          0 :           neighbor_curves.uniquify_ordered();
   15766 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15767         [ #  # ]:          0 :           neighbors += tmp;
   15768         [ #  # ]:          0 :           neighbor_surfaces.uniquify_ordered();
   15769 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_surfaces, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15770         [ #  # ]:          0 :           neighbors += tmp;
   15771 [ #  # ][ #  # ]:          0 :           neighbors.append(surfs.get()->lump());
                 [ #  # ]
   15772 [ #  # ][ #  # ]:          0 :           neighbors.append(surfs.get()->bodysm());
                 [ #  # ]
   15773                 :            : 
   15774 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbors.size(); k++)
   15775 [ #  # ][ #  # ]:          0 :             if(BridgeManager* m = neighbors.get_and_step()->bridge_manager())
                 [ #  # ]
   15776 [ #  # ][ #  # ]:          0 :               if(TopologyEntity* t = m->topology_entity())
   15777 [ #  # ][ #  # ]:          0 :                 entities_to_update.append(CAST_TO(t, RefEntity));
                 [ #  # ]
   15778                 :            :         }
   15779                 :            :       }
   15780                 :            :     }
   15781         [ #  # ]:          0 :   }
   15782                 :            : 
   15783                 :            : 
   15784                 :            :   //unmerge any merged adjacent surfaces or
   15785                 :            :   //merged curves in unmerged adjacent surfaces
   15786 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> adjacent_faces_to_unmerge;
   15787 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> adjacent_edges_to_unmerge;
   15788 [ #  # ][ #  # ]:          0 :   for(i=ref_face_list.size(); i--;)
   15789                 :            :   {
   15790         [ #  # ]:          0 :     RefFace *tweaked_face = ref_face_list.get_and_step();
   15791 [ #  # ][ #  # ]:          0 :     if( !new_faces.move_to( tweaked_face ) )
   15792                 :          0 :       continue;
   15793                 :            : 
   15794                 :            :     //get all the edges of the face you tweaked
   15795         [ #  # ]:          0 :     DLIList<RefEdge*> tweaked_face_edges;
   15796         [ #  # ]:          0 :     tweaked_face->ref_edges( tweaked_face_edges );
   15797         [ #  # ]:          0 :     adjacent_edges_to_unmerge += tweaked_face_edges;
   15798                 :            : 
   15799                 :            :     //get all the adjacent faces to this edge
   15800                 :            :     int j;
   15801 [ #  # ][ #  # ]:          0 :     for( j=tweaked_face_edges.size(); j--; )
   15802                 :            :     {
   15803         [ #  # ]:          0 :       RefEdge *tmp_edge = tweaked_face_edges.get_and_step();
   15804         [ #  # ]:          0 :       DLIList<RefFace*> tmp_faces;
   15805         [ #  # ]:          0 :       tmp_edge->ref_faces( tmp_faces );
   15806         [ #  # ]:          0 :       tmp_faces.remove( tweaked_face );
   15807         [ #  # ]:          0 :       adjacent_faces_to_unmerge += tmp_faces;
   15808         [ #  # ]:          0 :     }
   15809                 :            : 
   15810                 :            :     //get all edges not in the surface,
   15811                 :            :     //sharing vertices with the surface
   15812 [ #  # ][ #  # ]:          0 :     DLIList<RefVertex*> ref_vertices;
   15813         [ #  # ]:          0 :     tweaked_face->ref_vertices( ref_vertices );
   15814 [ #  # ][ #  # ]:          0 :     for( j=ref_vertices.size(); j--; )
   15815                 :            :     {
   15816         [ #  # ]:          0 :       RefVertex *tmp_vert = ref_vertices.get_and_step();
   15817         [ #  # ]:          0 :       DLIList<RefEdge*>  ref_edges;
   15818         [ #  # ]:          0 :       tmp_vert->ref_edges( ref_edges );
   15819                 :            : 
   15820                 :            :       int k;
   15821 [ #  # ][ #  # ]:          0 :       for( k=ref_edges.size(); k--; )
   15822                 :            :       {
   15823         [ #  # ]:          0 :         RefEdge *tmp_edge = ref_edges.get_and_step();
   15824 [ #  # ][ #  # ]:          0 :         if( !tweaked_face_edges.move_to( tmp_edge ) )
   15825         [ #  # ]:          0 :           adjacent_edges_to_unmerge.append( tmp_edge );
   15826                 :            :       }
   15827         [ #  # ]:          0 :     }
   15828         [ #  # ]:          0 :   }
   15829                 :            : 
   15830                 :            :   //unmerge any adjacent faces
   15831         [ #  # ]:          0 :   adjacent_faces_to_unmerge.uniquify_unordered();
   15832 [ #  # ][ #  # ]:          0 :   for( i=adjacent_faces_to_unmerge.size(); i--; )
   15833                 :            :   {
   15834         [ #  # ]:          0 :     RefFace *ref_face = adjacent_faces_to_unmerge.get_and_step();
   15835                 :            : 
   15836         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
   15837 [ #  # ][ #  # ]:          0 :     ref_face->bridge_manager()->get_bridge_list(bridge_list);
   15838 [ #  # ][ #  # ]:          0 :     if (bridge_list.size() > 1)
   15839                 :            :     {
   15840 [ #  # ][ #  # ]:          0 :       if( MergeTool::instance()->unmerge( ref_face ) )
                 [ #  # ]
   15841 [ #  # ][ #  # ]:          0 :         PRINT_WARNING("Unmerging Surface %d\n", ref_face->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   15842                 :            :     }
   15843         [ #  # ]:          0 :   }
   15844                 :            : 
   15845                 :            :   //unmerge any adjacent edges
   15846         [ #  # ]:          0 :   adjacent_edges_to_unmerge.uniquify_unordered();
   15847 [ #  # ][ #  # ]:          0 :   for( i=adjacent_edges_to_unmerge.size(); i--; )
   15848                 :            :   {
   15849         [ #  # ]:          0 :     RefEdge *ref_edge = adjacent_edges_to_unmerge.get_and_step();
   15850         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
   15851 [ #  # ][ #  # ]:          0 :     ref_edge->bridge_manager()->get_bridge_list(bridge_list);
   15852 [ #  # ][ #  # ]:          0 :     if (bridge_list.size() > 1)
   15853                 :            :     {
   15854 [ #  # ][ #  # ]:          0 :       if( MergeTool::instance()->unmerge( ref_edge) )
                 [ #  # ]
   15855 [ #  # ][ #  # ]:          0 :         PRINT_WARNING("Unmerging Curve %d\n", ref_edge->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   15856                 :            :     }
   15857         [ #  # ]:          0 :   }
   15858                 :            : 
   15859                 :            :   // Update graphics
   15860 [ #  # ][ #  # ]:          0 :   while (entities_to_update.size())
   15861 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entities_to_update.pop()));
         [ #  # ][ #  # ]
                 [ #  # ]
   15862                 :            : 
   15863         [ #  # ]:          0 :   return stat;
   15864                 :            : }
   15865                 :            : 
   15866                 :            : //=============================================================================
   15867                 :            : // Description: Tweak specified curves of a sheet body or bodies by offsetting
   15868                 :            : //              those curves by the offset distance.
   15869                 :            : // Author     : Steve Storm
   15870                 :            : // Date       : 03/25/05
   15871                 :            : //=============================================================================
   15872                 :          0 : CubitStatus GeometryModifyTool::tweak_offset( DLIList<RefEdge*> &ref_edge_list,
   15873                 :            :                                               double offset_distance,
   15874                 :            :                                               DLIList<RefEdge*> *add_ref_edge_list_ptr,
   15875                 :            :                                               DLIList<double> *add_offset_list_ptr,
   15876                 :            :                                               DLIList<Body*> &new_body_list,
   15877                 :            :                                               CubitBoolean keep_old_body,
   15878                 :            :                                               CubitBoolean preview )
   15879                 :            : {
   15880 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> all_ref_edge_list(ref_edge_list.size());
   15881         [ #  # ]:          0 :   all_ref_edge_list = ref_edge_list;
   15882         [ #  # ]:          0 :   if( add_ref_edge_list_ptr )
   15883         [ #  # ]:          0 :     all_ref_edge_list += *add_ref_edge_list_ptr;
   15884                 :            : 
   15885 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
                 [ #  # ]
   15886 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   15887                 :            :   GeometryModifyEngine* gme_ptr;
   15888                 :            : 
   15889         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_edge_list, "Offsetting", old_body_list, curve_list );
   15890         [ #  # ]:          0 :   if (!gme_ptr)
   15891                 :          0 :     return CUBIT_FAILURE;
   15892                 :            : 
   15893 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> add_curve_list;
   15894 [ #  # ][ #  # ]:          0 :   if( add_ref_edge_list_ptr && add_ref_edge_list_ptr->size() )
         [ #  # ][ #  # ]
   15895                 :            :   {
   15896         [ #  # ]:          0 :     DLIList<Body*> old_body_list2;
   15897                 :            :     GeometryModifyEngine* gme_ptr2 = tweak_setup( *add_ref_edge_list_ptr, "Offsetting",
   15898         [ #  # ]:          0 :       old_body_list2, add_curve_list );
   15899         [ #  # ]:          0 :     if (!gme_ptr2)
   15900                 :          0 :       return CUBIT_FAILURE;
   15901         [ #  # ]:          0 :     if( gme_ptr != gme_ptr2 )
   15902                 :            :     {
   15903 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Offsetting curves on entities containing surfaces from different\n"
                 [ #  # ]
   15904         [ #  # ]:          0 :       "       geometry engines is not allowed.\n");
   15905                 :          0 :       return CUBIT_FAILURE;
   15906                 :            :     }
   15907 [ #  # ][ #  # ]:          0 :     old_body_list.merge_unique( old_body_list2 );
                 [ #  # ]
   15908                 :            :   }
   15909                 :            : 
   15910 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15911                 :            :   {
   15912         [ #  # ]:          0 :     if( keep_old_body )
   15913         [ #  # ]:          0 :       CubitUndo::save_state();
   15914                 :            :     else
   15915         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( all_ref_edge_list );
   15916                 :            :   }
   15917                 :            : 
   15918                 :            :   // Do offset
   15919 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   15920                 :            :   CubitStatus stat;
   15921 [ #  # ][ #  # ]:          0 :   if( add_curve_list.size() )
   15922                 :            :     stat = gme_ptr->tweak_offset( curve_list, offset_distance, &add_curve_list,
   15923         [ #  # ]:          0 :     add_offset_list_ptr, new_bodysm_list, keep_old_body, preview );
   15924                 :            :   else
   15925                 :            :     stat = gme_ptr->tweak_offset( curve_list, offset_distance, NULL, NULL,
   15926         [ #  # ]:          0 :     new_bodysm_list, keep_old_body, preview );
   15927                 :            : 
   15928 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15929         [ #  # ]:          0 :     if( stat == CUBIT_FAILURE)
   15930         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   15931                 :            : 
   15932         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   15933                 :          0 :     return CUBIT_FAILURE;
   15934                 :            : 
   15935 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
   15936         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   15937                 :            :   {
   15938                 :            :     // check for resued entities, they have been moved and we need to notify observers
   15939 [ #  # ][ #  # ]:          0 :     for(int i=0; i<new_bodysm_list.size(); i++)
   15940                 :            :     {
   15941         [ #  # ]:          0 :       BodySM* bodysm = new_bodysm_list.get_and_step();
   15942         [ #  # ]:          0 :       DLIList<TopologyBridge*> to_check;
   15943 [ #  # ][ #  # ]:          0 :       DLIList<TopologyBridge*> tmp;
   15944 [ #  # ][ #  # ]:          0 :       DLIList<Surface*> surfs;
   15945         [ #  # ]:          0 :       bodysm->surfaces(surfs);
   15946 [ #  # ][ #  # ]:          0 :       DLIList<Curve*> curves;
   15947         [ #  # ]:          0 :       bodysm->curves(curves);
   15948 [ #  # ][ #  # ]:          0 :       DLIList<TBPoint*> points;
   15949         [ #  # ]:          0 :       bodysm->points(points);
   15950         [ #  # ]:          0 :       to_check.append(bodysm);
   15951 [ #  # ][ #  # ]:          0 :       to_check.append(bodysm->lump());
   15952 [ #  # ][ #  # ]:          0 :       CAST_LIST_TO_PARENT(surfs, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15953         [ #  # ]:          0 :       to_check += tmp;
   15954 [ #  # ][ #  # ]:          0 :       CAST_LIST_TO_PARENT(curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15955         [ #  # ]:          0 :       to_check += tmp;
   15956 [ #  # ][ #  # ]:          0 :       CAST_LIST_TO_PARENT(points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   15957         [ #  # ]:          0 :       to_check += tmp;
   15958                 :            : 
   15959                 :            :       int k;
   15960 [ #  # ][ #  # ]:          0 :       for(k=0; k<to_check.size(); k++)
   15961 [ #  # ][ #  # ]:          0 :         if(BridgeManager* m = to_check.get_and_step()->bridge_manager())
                 [ #  # ]
   15962 [ #  # ][ #  # ]:          0 :           if(TopologyEntity* t = m->topology_entity())
   15963 [ #  # ][ #  # ]:          0 :             entities_to_update.append(CAST_TO(t, RefEntity));
   15964         [ #  # ]:          0 :     }
   15965                 :            : 
   15966         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   15967                 :            : 
   15968 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   15969                 :            :     {
   15970         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   15971         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   15972         [ #  # ]:          0 :       else if( keep_old_body )
   15973         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   15974                 :            :     }
   15975                 :            :   }
   15976                 :            : 
   15977                 :            :   // Update graphics
   15978 [ #  # ][ #  # ]:          0 :   while (entities_to_update.size())
   15979 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entities_to_update.pop()));
         [ #  # ][ #  # ]
                 [ #  # ]
   15980                 :            : 
   15981                 :            :   // Update graphics
   15982 [ #  # ][ #  # ]:          0 :   DLIList<Body*> moved_bodies(new_body_list);
   15983         [ #  # ]:          0 :   moved_bodies.intersect(old_body_list);
   15984 [ #  # ][ #  # ]:          0 :   while (moved_bodies.size())
   15985 [ #  # ][ #  # ]:          0 :     moved_bodies.pop()->notify_sub_all_observers( GeometryEvent::GEOMETRY_MODIFIED );
   15986                 :            : 
   15987         [ #  # ]:          0 :   return stat;
   15988                 :            : }
   15989                 :            : 
   15990                 :            : 
   15991                 :          0 : CubitStatus GeometryModifyTool::tweak_remove_individually(
   15992                 :            :                                               DLIList<RefFace*> &ref_face_list,
   15993                 :            :                                               DLIList<Body*> &new_body_list,
   15994                 :            :                                               CubitBoolean keep_surface,
   15995                 :            :                                               CubitBoolean keep_old_body,
   15996                 :            :                                               CubitBoolean preview )
   15997                 :            : {
   15998 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   15999                 :            :   {
   16000         [ #  # ]:          0 :     if( keep_old_body )
   16001         [ #  # ]:          0 :       CubitUndo::save_state();
   16002                 :            :     else
   16003         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_face_list );
   16004                 :            :   }
   16005                 :            : 
   16006                 :            :   // Split things up if individual
   16007                 :            :   //build a surfae to volume map
   16008         [ #  # ]:          0 :   std::map<RefFace*, RefVolume*> surface_to_volume_map;
   16009                 :            : 
   16010                 :            :   int i;
   16011 [ #  # ][ #  # ]:          0 :   for (i = ref_face_list.size(); i--; )
   16012                 :            :   {
   16013         [ #  # ]:          0 :     RefFace *tmp_face = ref_face_list.get_and_step();
   16014         [ #  # ]:          0 :     RefVolume *tmp_vol = tmp_face->ref_volume();
   16015 [ #  # ][ #  # ]:          0 :     surface_to_volume_map.insert( std::map<RefFace*, RefVolume*>::value_type( tmp_face, tmp_vol));
   16016                 :            :   }
   16017                 :            : 
   16018 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> one_ref_face;
   16019 [ #  # ][ #  # ]:          0 :   DLIList<Body*> tmp_new_body_list;
   16020                 :          0 :   CubitStatus total_rv = CUBIT_FAILURE;
   16021                 :          0 :   bool extend = true;
   16022                 :            : 
   16023                 :            :   // Succeed if any one surface succeeds.
   16024 [ #  # ][ #  # ]:          0 :   for (i = ref_face_list.size(); i--; )
   16025                 :            :   {
   16026                 :            :     //make sure that the surface to remove is still in the body...
   16027                 :            :     //that it hasn't been removed from a previous tweak operation
   16028         [ #  # ]:          0 :     RefFace *tmp_face = ref_face_list.get_and_step();
   16029         [ #  # ]:          0 :     std::map<RefFace*, RefVolume*>::iterator tmp_iter;
   16030         [ #  # ]:          0 :     tmp_iter = surface_to_volume_map.find( tmp_face );
   16031         [ #  # ]:          0 :     RefVolume *tmp_vol = tmp_iter->second;
   16032         [ #  # ]:          0 :     DLIList<RefFace*> ref_face_list;
   16033         [ #  # ]:          0 :     tmp_vol->ref_faces( ref_face_list );
   16034 [ #  # ][ #  # ]:          0 :     if( !ref_face_list.move_to( tmp_face ) )
   16035                 :          0 :       continue;
   16036                 :            : 
   16037         [ #  # ]:          0 :     one_ref_face.clean_out();
   16038         [ #  # ]:          0 :     one_ref_face.append( tmp_face );
   16039 [ #  # ][ #  # ]:          0 :     int id = one_ref_face.get()->id();
   16040                 :            : 
   16041                 :            :     //See if the owning body of the face is a multi-volume body
   16042 [ #  # ][ #  # ]:          0 :     Body *owning_body = one_ref_face.get()->body();
   16043         [ #  # ]:          0 :     int number_volumes_before = owning_body->num_ref_volumes();
   16044                 :            : 
   16045         [ #  # ]:          0 :     tmp_new_body_list.clean_out();
   16046                 :            : 
   16047                 :            :     CubitStatus rv = this->tweak_remove(one_ref_face, tmp_new_body_list,
   16048         [ #  # ]:          0 :       extend, keep_surface, keep_old_body, preview );
   16049         [ #  # ]:          0 :     if (rv)
   16050                 :            :     {
   16051                 :          0 :       total_rv = CUBIT_SUCCESS;
   16052         [ #  # ]:          0 :       if( !preview )
   16053 [ #  # ][ #  # ]:          0 :         PRINT_INFO("Successfully removed Surface %d\n\n", id);
         [ #  # ][ #  # ]
   16054                 :            :       else
   16055 [ #  # ][ #  # ]:          0 :         PRINT_INFO("Successfully removed Surface %d in preview\n\n", id);
         [ #  # ][ #  # ]
   16056                 :            : 
   16057                 :            :       //see if we have a multi-volume body or multiple bodies
   16058                 :            :       //if so, we know the original volume was destroyed, so we
   16059                 :            :       //cannot remove any more surfaces because the check above is
   16060                 :            :       //highly likely to crash
   16061                 :          0 :       bool volume_destroyed = false;
   16062 [ #  # ][ #  # ]:          0 :       int number_volumes_after = tmp_new_body_list.get()->num_ref_volumes();
   16063         [ #  # ]:          0 :       if( number_volumes_after > number_volumes_before  )
   16064                 :          0 :         volume_destroyed = true;
   16065                 :            : 
   16066         [ #  # ]:          0 :       new_body_list += tmp_new_body_list;
   16067                 :            : 
   16068         [ #  # ]:          0 :       if( volume_destroyed == true )
   16069                 :            :       {
   16070 [ #  # ][ #  # ]:          0 :         PRINT_WARNING("Unable to remove more surfaces because multiple bodies\n"
                 [ #  # ]
   16071         [ #  # ]:          0 :                       "       have been produced from removing surfaces individually\n" );
   16072 [ #  # ][ #  # ]:          0 :         if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16073                 :            :         {
   16074         [ #  # ]:          0 :           if( total_rv == CUBIT_FAILURE )  //didn't remove any surfaces
   16075         [ #  # ]:          0 :             CubitUndo::remove_last_undo();
   16076                 :            :           else
   16077         [ #  # ]:          0 :             CubitUndo::note_result_bodies( new_body_list );
   16078                 :            :         }
   16079                 :            : 
   16080                 :          0 :         return total_rv;
   16081                 :            :       }
   16082                 :            :     }
   16083                 :            :     else
   16084                 :            :     {
   16085         [ #  # ]:          0 :       if( !preview )
   16086 [ #  # ][ #  # ]:          0 :         PRINT_INFO("Unable to remove Surface %d\n\n", id);
         [ #  # ][ #  # ]
   16087                 :            :       else
   16088 [ #  # ][ #  # ]:          0 :         PRINT_INFO("Unable to remove Surface %d in preview\n\n", id);
         [ #  # ][ #  # ]
                 [ #  # ]
              [ #  #  # ]
   16089                 :            :     }
   16090                 :          0 :   }
   16091                 :            : 
   16092 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16093                 :            :   {
   16094         [ #  # ]:          0 :     if( total_rv == CUBIT_FAILURE)
   16095         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   16096 [ #  # ][ #  # ]:          0 :     else if( keep_old_body || keep_surface )
   16097         [ #  # ]:          0 :       CubitUndo::note_result_bodies( new_body_list );
   16098                 :            :   }
   16099                 :            : 
   16100         [ #  # ]:          0 :   return total_rv;
   16101                 :            : }
   16102                 :            : 
   16103                 :            : 
   16104                 :            : //=============================================================================
   16105                 :            : // Description: Function to remove surfaces from a body and then extend the
   16106                 :            : //              remaining surfaces to fill the gap or hole.
   16107                 :            : // Author     : Steve Storm
   16108                 :            : // Date       : 03/25/05
   16109                 :            : //=============================================================================
   16110                 :          0 : CubitStatus GeometryModifyTool::tweak_remove_together(
   16111                 :            :                                               DLIList<RefFace*> &ref_face_list,
   16112                 :            :                                               DLIList<Body*> &new_body_list,
   16113                 :            :                                               CubitBoolean extend_adjoining,
   16114                 :            :                                               CubitBoolean keep_surface,
   16115                 :            :                                               CubitBoolean keep_old_body,
   16116                 :            :                                               CubitBoolean preview )
   16117                 :            : {
   16118                 :            : 
   16119 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
                 [ #  # ]
   16120                 :            :   {
   16121         [ #  # ]:          0 :     if( keep_old_body )
   16122                 :          0 :       CubitUndo::save_state();
   16123                 :            :     else
   16124                 :          0 :       CubitUndo::save_state_with_cubit_file( ref_face_list );
   16125                 :            :   }
   16126                 :            : 
   16127                 :            :   CubitStatus stat = tweak_remove( ref_face_list, new_body_list,
   16128                 :            :                                    extend_adjoining, keep_surface,
   16129                 :          0 :                                    keep_old_body, preview );
   16130                 :            : 
   16131         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   16132                 :            :   {
   16133 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
                 [ #  # ]
   16134                 :          0 :       CubitUndo::remove_last_undo();
   16135                 :            : 
   16136                 :          0 :     return CUBIT_FAILURE;
   16137                 :            :   }
   16138                 :            : 
   16139                 :            : 
   16140         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   16141                 :            :   {
   16142         [ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   16143                 :            :     {
   16144         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   16145                 :          0 :         CubitUndo::remove_last_undo();
   16146 [ #  # ][ #  # ]:          0 :       else if( keep_old_body || keep_surface )
   16147                 :          0 :         CubitUndo::note_result_bodies( new_body_list );
   16148                 :            :     }
   16149                 :            :   }
   16150                 :            : 
   16151                 :          0 :   return CUBIT_SUCCESS;
   16152                 :            : }
   16153                 :            : 
   16154                 :            : //private funcion...should not be called from outside this class
   16155                 :          0 : CubitStatus GeometryModifyTool::tweak_remove( DLIList<RefFace*> &ref_face_list,
   16156                 :            :                                               DLIList<Body*> &new_body_list,
   16157                 :            :                                               CubitBoolean extend_adjoining,
   16158                 :            :                                               CubitBoolean keep_surface,
   16159                 :            :                                               CubitBoolean keep_old_body,
   16160                 :            :                                               CubitBoolean preview )
   16161                 :            : {
   16162 [ #  # ][ #  # ]:          0 :    DLIList<Surface*> surface_list(ref_face_list.size());
   16163 [ #  # ][ #  # ]:          0 :    DLIList<Body*> old_body_list;
   16164                 :            :    GeometryModifyEngine* gme_ptr;
   16165                 :            : 
   16166                 :            :    // clear any preview previews
   16167         [ #  # ]:          0 :    GfxPreview::clear();
   16168                 :            : 
   16169                 :            :    //collect all neighboring surfaces to those in the list
   16170                 :            :    int i,j;
   16171 [ #  # ][ #  # ]:          0 :    DLIList<RefFace*> neighboring_surfaces;
   16172 [ #  # ][ #  # ]:          0 :    DLIList<RefEdge*> merged_ref_edges_before;
   16173 [ #  # ][ #  # ]:          0 :    for( i=ref_face_list.size(); i--; )
   16174                 :            :    {
   16175         [ #  # ]:          0 :      RefFace *tmp_face = ref_face_list.get_and_step();
   16176         [ #  # ]:          0 :      DLIList<RefEdge*> ref_edge_list;
   16177         [ #  # ]:          0 :      tmp_face->ref_edges( ref_edge_list );
   16178 [ #  # ][ #  # ]:          0 :      for( j=ref_edge_list.size(); j--; )
   16179 [ #  # ][ #  # ]:          0 :        ref_edge_list.get_and_step()->ref_faces( neighboring_surfaces );
   16180                 :            : 
   16181 [ #  # ][ #  # ]:          0 :      DLIList<RefVertex*> tmp_verts;
   16182         [ #  # ]:          0 :      tmp_face->ref_vertices( tmp_verts );
   16183 [ #  # ][ #  # ]:          0 :      for( j=tmp_verts.size(); j--; )
   16184                 :            :      {
   16185         [ #  # ]:          0 :        RefVertex *tmp_vert = tmp_verts.get_and_step();
   16186         [ #  # ]:          0 :        DLIList<RefEdge*> tmp_edges;
   16187         [ #  # ]:          0 :        tmp_vert->ref_edges( tmp_edges );
   16188                 :            :        int kk;
   16189 [ #  # ][ #  # ]:          0 :        for( kk=tmp_edges.size(); kk--; )
   16190                 :            :        {
   16191         [ #  # ]:          0 :          RefEdge *tmp_edge = tmp_edges.get_and_step();
   16192 [ #  # ][ #  # ]:          0 :          if( tmp_edge->is_merged() )
   16193         [ #  # ]:          0 :            merged_ref_edges_before.append( tmp_edge);
   16194                 :            :        }
   16195         [ #  # ]:          0 :      }
   16196         [ #  # ]:          0 :    }
   16197                 :            : 
   16198                 :            :   //uniquify and add other surfaces
   16199         [ #  # ]:          0 :   neighboring_surfaces.uniquify_unordered();
   16200         [ #  # ]:          0 :   neighboring_surfaces += ref_face_list;
   16201                 :            : 
   16202         [ #  # ]:          0 :    gme_ptr = tweak_setup( ref_face_list, "Removing", old_body_list, surface_list, CUBIT_TRUE );
   16203         [ #  # ]:          0 :    if (!gme_ptr)
   16204                 :          0 :      return CUBIT_FAILURE;
   16205                 :            : 
   16206 [ #  # ][ #  # ]:          0 :    DLIList<Surface*> kept_surface_list;
   16207         [ #  # ]:          0 :    if( keep_surface )
   16208                 :            :    {
   16209                 :            :      int kk;
   16210 [ #  # ][ #  # ]:          0 :      for( kk=surface_list.size(); kk--; )
   16211                 :            :      {
   16212 [ #  # ][ #  # ]:          0 :        Surface *new_surf = gme_ptr->make_Surface( surface_list.get_and_step() );
   16213         [ #  # ]:          0 :        kept_surface_list.append( new_surf );
   16214                 :            :      }
   16215                 :            :    }
   16216                 :            : 
   16217 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> body_sms;
   16218 [ #  # ][ #  # ]:          0 :    for(i=old_body_list.size(); i--;)
   16219                 :            :    {
   16220 [ #  # ][ #  # ]:          0 :      BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   16221         [ #  # ]:          0 :      if(bsm)
   16222         [ #  # ]:          0 :        body_sms.append_unique(bsm);
   16223                 :            :    }
   16224                 :            : 
   16225         [ #  # ]:          0 :    if(!preview)
   16226                 :            :    {
   16227         [ #  # ]:          0 :     do_attribute_setup();
   16228         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   16229                 :            :    }
   16230                 :            : 
   16231                 :            :    // Do remove
   16232 [ #  # ][ #  # ]:          0 :    DLIList<BodySM*> new_bodysm_list;
   16233                 :            :    CubitStatus removal_status =
   16234                 :            :        gme_ptr->tweak_remove( surface_list,
   16235                 :            :                               new_bodysm_list,
   16236                 :            :                               extend_adjoining,
   16237                 :            :                               keep_old_body,
   16238         [ #  # ]:          0 :                               preview );
   16239                 :            : 
   16240                 :            : 
   16241         [ #  # ]:          0 :    if( removal_status == CUBIT_FAILURE )
   16242                 :            :    {
   16243         [ #  # ]:          0 :      if(!preview)
   16244         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   16245         [ #  # ]:          0 :      if( keep_surface )
   16246                 :            :      {
   16247                 :            :        int kk;
   16248 [ #  # ][ #  # ]:          0 :        for( kk=kept_surface_list.size(); kk--; )
   16249                 :            :        {
   16250         [ #  # ]:          0 :          Surface *surf = kept_surface_list.get_and_step();
   16251 [ #  # ][ #  # ]:          0 :          gme_ptr->get_gqe()->delete_solid_model_entities( surf );
   16252                 :            :        }
   16253                 :            :      }
   16254         [ #  # ]:          0 :      if(!preview)
   16255         [ #  # ]:          0 :       do_attribute_cleanup();
   16256                 :          0 :      return CUBIT_FAILURE;
   16257                 :            :    }
   16258                 :            :    else
   16259                 :            :    {
   16260         [ #  # ]:          0 :      if(!preview)
   16261                 :            :      {
   16262         [ #  # ]:          0 :         restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   16263         [ #  # ]:          0 :         remove_pushed_attributes(new_bodysm_list, old_body_list);
   16264                 :            :      }
   16265                 :            :    }
   16266                 :            : 
   16267                 :            :   // for each new bodysm, find surfaces that need updating.
   16268                 :            :   // this is to account for some cases where the topology doesn't change, but the geometry does.
   16269 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
   16270 [ #  # ][ #  # ]:          0 :   for(i=0; i<new_bodysm_list.size(); i++)
   16271                 :            :   {
   16272         [ #  # ]:          0 :     BodySM* bodysm = new_bodysm_list.get_and_step();
   16273         [ #  # ]:          0 :     DLIList<Surface*> surfs;
   16274         [ #  # ]:          0 :     bodysm->surfaces(surfs);
   16275                 :            :     int j;
   16276                 :            :     // find a surface that is also found in our input list
   16277 [ #  # ][ #  # ]:          0 :     for(j=0; j<surfs.size(); j++, surfs.step())
                 [ #  # ]
   16278                 :            :     {
   16279 [ #  # ][ #  # ]:          0 :       BridgeManager* man = surfs.get()->bridge_manager();
   16280         [ #  # ]:          0 :       if(man)
   16281                 :            :       {
   16282 [ #  # ][ #  # ]:          0 :         RefFace* ref_face = CAST_TO(man->topology_entity(), RefFace);
   16283 [ #  # ][ #  # ]:          0 :         if( ref_face && neighboring_surfaces.is_in_list(ref_face) )
         [ #  # ][ #  # ]
   16284                 :            :         {
   16285                 :            :           // get neighbors
   16286         [ #  # ]:          0 :           DLIList<TBPoint*> neighbor_points;
   16287 [ #  # ][ #  # ]:          0 :           surfs.get()->points(neighbor_points);
   16288 [ #  # ][ #  # ]:          0 :           DLIList<Curve*> neighbor_curves;
   16289 [ #  # ][ #  # ]:          0 :           DLIList<Surface*> neighbor_surfaces;
   16290 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> neighbors;
   16291 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> tmp;
   16292                 :            :           int k;
   16293 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   16294 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->surfaces(neighbor_surfaces);
   16295 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   16296 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->curves(neighbor_curves);
   16297                 :            : 
   16298 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16299         [ #  # ]:          0 :           neighbors += tmp;
   16300         [ #  # ]:          0 :           neighbor_curves.uniquify_ordered();
   16301 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16302         [ #  # ]:          0 :           neighbors += tmp;
   16303         [ #  # ]:          0 :           neighbor_surfaces.uniquify_ordered();
   16304 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_surfaces, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16305         [ #  # ]:          0 :           neighbors += tmp;
   16306 [ #  # ][ #  # ]:          0 :           neighbors.append(surfs.get()->lump());
                 [ #  # ]
   16307 [ #  # ][ #  # ]:          0 :           neighbors.append(surfs.get()->bodysm());
                 [ #  # ]
   16308                 :            : 
   16309 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbors.size(); k++)
   16310                 :            :           {
   16311 [ #  # ][ #  # ]:          0 :             if(BridgeManager* m = neighbors.get_and_step()->bridge_manager())
                 [ #  # ]
   16312                 :            :             {
   16313 [ #  # ][ #  # ]:          0 :               if(TopologyEntity* t = m->topology_entity())
   16314                 :            :               {
   16315         [ #  # ]:          0 :                 RefEntity *ref_ent = CAST_TO(t, RefEntity );
   16316         [ #  # ]:          0 :                 entities_to_update.append(ref_ent);
   16317                 :            :               }
   16318                 :            :             }
   16319         [ #  # ]:          0 :           }
   16320                 :            :         }
   16321                 :            :       }
   16322                 :            :     }
   16323         [ #  # ]:          0 :   }
   16324                 :            : 
   16325                 :            : 
   16326 [ #  # ][ #  # ]:          0 :   DLIList<Body*> kept_surface_bodies;
   16327 [ #  # ][ #  # ]:          0 :   if( preview == CUBIT_FALSE && keep_surface )
   16328                 :            :   {
   16329                 :            :     int kk;
   16330 [ #  # ][ #  # ]:          0 :     for( kk=kept_surface_list.size(); kk--; )
   16331                 :            :     {
   16332         [ #  # ]:          0 :       Surface *surf = kept_surface_list.get_and_step();
   16333         [ #  # ]:          0 :       Body *new_body = make_Body( surf );
   16334         [ #  # ]:          0 :       kept_surface_bodies.append( new_body );
   16335                 :            :     }
   16336                 :            :   }
   16337                 :            : 
   16338                 :            :     // Update DAG
   16339         [ #  # ]:          0 :   CubitStatus stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   16340                 :            : 
   16341         [ #  # ]:          0 :   if(!preview)
   16342         [ #  # ]:          0 :     do_attribute_cleanup();
   16343                 :            : 
   16344         [ #  # ]:          0 :   if( keep_surface )
   16345         [ #  # ]:          0 :     new_body_list += kept_surface_bodies;
   16346                 :            : 
   16347         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE)
   16348                 :          0 :       return CUBIT_FAILURE;
   16349                 :            : 
   16350                 :            :     // Update graphics
   16351 [ #  # ][ #  # ]:          0 :   while (entities_to_update.size())
   16352 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entities_to_update.pop()));
         [ #  # ][ #  # ]
                 [ #  # ]
   16353                 :            : 
   16354                 :            : 
   16355                 :            :   //unmerge all curves attached to these vertices after
   16356 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> merged_ref_edges_after;
   16357 [ #  # ][ #  # ]:          0 :   for( i=new_body_list.size(); i--; )
   16358                 :            :   {
   16359         [ #  # ]:          0 :     Body *new_body = new_body_list.get_and_step();
   16360         [ #  # ]:          0 :     DLIList<RefVertex*> tmp_verts;
   16361         [ #  # ]:          0 :     new_body->ref_vertices( tmp_verts);
   16362                 :            : 
   16363 [ #  # ][ #  # ]:          0 :     for( j=tmp_verts.size(); j--; )
   16364                 :            :     {
   16365         [ #  # ]:          0 :       RefVertex *tmp_vert = tmp_verts.get_and_step();
   16366         [ #  # ]:          0 :       DLIList<RefEdge*> tmp_edges;
   16367 [ #  # ][ #  # ]:          0 :       if( tmp_vert->is_merged() )
   16368                 :            :       {
   16369         [ #  # ]:          0 :         tmp_vert->ref_edges( tmp_edges );
   16370                 :            :         int k;
   16371 [ #  # ][ #  # ]:          0 :         for( k=tmp_edges.size(); k--; )
   16372                 :            :         {
   16373         [ #  # ]:          0 :           RefEdge *tmp_edge = tmp_edges.get_and_step();
   16374 [ #  # ][ #  # ]:          0 :           if( tmp_edge->is_merged() )
   16375         [ #  # ]:          0 :             merged_ref_edges_after.append( tmp_edge );
   16376                 :            :         }
   16377                 :            :       }
   16378         [ #  # ]:          0 :     }
   16379         [ #  # ]:          0 :   }
   16380                 :            : 
   16381         [ #  # ]:          0 :   merged_ref_edges_before.uniquify_unordered();
   16382 [ #  # ][ #  # ]:          0 :   for( i=merged_ref_edges_before.size(); i--; )
   16383                 :            :   {
   16384         [ #  # ]:          0 :     RefEdge *tmp_edge = merged_ref_edges_before.get_and_step();
   16385 [ #  # ][ #  # ]:          0 :     if( merged_ref_edges_after.is_in_list( tmp_edge ) )
   16386 [ #  # ][ #  # ]:          0 :       MergeTool::instance()->unmerge( tmp_edge );
   16387                 :            :   }
   16388                 :            : 
   16389         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   16390                 :            : }
   16391                 :            : 
   16392                 :            : 
   16393                 :            : //=============================================================================
   16394                 :            : // Description: Function to remove curves from a sheet body and then extend the
   16395                 :            : //              remaining curves or fill the gap or hole.
   16396                 :            : // Author     : Steve Storm
   16397                 :            : // Date       : 03/25/05
   16398                 :            : //=============================================================================
   16399                 :          0 : CubitStatus GeometryModifyTool::tweak_remove( DLIList<RefEdge*> &ref_edge_list,
   16400                 :            :                                               DLIList<Body*> &new_body_list,
   16401                 :            :                                               CubitBoolean keep_old_body,
   16402                 :            :                                               CubitBoolean preview )
   16403                 :            : {
   16404 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
   16405 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   16406                 :            :   GeometryModifyEngine* gme_ptr;
   16407                 :            : 
   16408                 :            :   // clear any preview previews
   16409         [ #  # ]:          0 :   GfxPreview::clear();
   16410                 :            : 
   16411         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_edge_list, "Removing", old_body_list, curve_list );
   16412         [ #  # ]:          0 :   if( !gme_ptr )
   16413                 :          0 :     return CUBIT_FAILURE;
   16414                 :            : 
   16415 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16416                 :            :   {
   16417         [ #  # ]:          0 :     if( keep_old_body )
   16418         [ #  # ]:          0 :       CubitUndo::save_state();
   16419                 :            :     else
   16420         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edge_list );
   16421                 :            :   }
   16422                 :            : 
   16423                 :            :   // Do remove
   16424 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   16425                 :            :   CubitStatus stat = gme_ptr->tweak_remove( curve_list, new_bodysm_list,
   16426         [ #  # ]:          0 :                                             keep_old_body, preview );
   16427                 :            :   //collect all neighboring curves to those in the list
   16428                 :            :    int i, j;
   16429 [ #  # ][ #  # ]:          0 :    DLIList<RefEdge*> neighboring_curves;
   16430 [ #  # ][ #  # ]:          0 :    for( i=ref_edge_list.size(); i--; )
   16431                 :            :    {
   16432         [ #  # ]:          0 :      RefEdge *tmp_edge = ref_edge_list.get_and_step();
   16433         [ #  # ]:          0 :      DLIList<RefVertex*> tmp_ref_vertex_list;
   16434         [ #  # ]:          0 :      tmp_edge->ref_vertices( tmp_ref_vertex_list );
   16435 [ #  # ][ #  # ]:          0 :      for( j=tmp_ref_vertex_list.size(); j--; )
   16436 [ #  # ][ #  # ]:          0 :        tmp_ref_vertex_list.get_and_step()->ref_edges( neighboring_curves );
   16437         [ #  # ]:          0 :    }
   16438                 :            : 
   16439                 :            :   //uniquify and add other curves
   16440         [ #  # ]:          0 :   neighboring_curves.uniquify_unordered();
   16441                 :            :   //neighboring_curves += ref_edge_list;
   16442                 :            : 
   16443 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16444         [ #  # ]:          0 :     if( stat == CUBIT_FAILURE )
   16445         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   16446                 :            : 
   16447         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE)
   16448                 :          0 :     return stat;
   16449                 :            : 
   16450                 :            :   // loop body sm list and find curves that need updating.
   16451                 :            :   // this is to account for some cases where the topology doesn't change, but the geometry does.
   16452 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
   16453 [ #  # ][ #  # ]:          0 :   for(i=0; i<new_bodysm_list.size(); i++)
   16454                 :            :   {
   16455         [ #  # ]:          0 :     BodySM* bodysm = new_bodysm_list.get_and_step();
   16456         [ #  # ]:          0 :     DLIList<Curve*> curves;
   16457         [ #  # ]:          0 :     bodysm->curves(curves);
   16458                 :            :     int j;
   16459                 :            :     // find a surface that is also found in our input list
   16460 [ #  # ][ #  # ]:          0 :     for(j=0; j<curves.size(); j++, curves.step())
                 [ #  # ]
   16461                 :            :     {
   16462 [ #  # ][ #  # ]:          0 :       BridgeManager* man = curves.get()->bridge_manager();
   16463         [ #  # ]:          0 :       if(man)
   16464                 :            :       {
   16465 [ #  # ][ #  # ]:          0 :         RefEdge* ref_edge = CAST_TO(man->topology_entity(), RefEdge);
   16466 [ #  # ][ #  # ]:          0 :         if( ref_edge && neighboring_curves.is_in_list(ref_edge) )
         [ #  # ][ #  # ]
   16467                 :            :         {
   16468                 :            :           // get neighbors
   16469         [ #  # ]:          0 :           DLIList<TBPoint*> neighbor_points;
   16470 [ #  # ][ #  # ]:          0 :           curves.get()->points(neighbor_points);
   16471 [ #  # ][ #  # ]:          0 :           DLIList<Curve*> neighbor_curves;
   16472 [ #  # ][ #  # ]:          0 :           DLIList<Surface*> neighbor_surfaces;
   16473 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> neighbors;
   16474 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> tmp;
   16475                 :            :           int k;
   16476 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   16477 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->surfaces(neighbor_surfaces);
   16478 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   16479 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->curves(neighbor_curves);
   16480                 :            : 
   16481 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16482         [ #  # ]:          0 :           neighbors += tmp;
   16483         [ #  # ]:          0 :           neighbor_curves.uniquify_ordered();
   16484 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16485         [ #  # ]:          0 :           neighbors += tmp;
   16486         [ #  # ]:          0 :           neighbor_surfaces.uniquify_ordered();
   16487 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_surfaces, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16488         [ #  # ]:          0 :           neighbors += tmp;
   16489                 :            :           //neighbors.append(curves.get()->lump());
   16490                 :            :           //neighbors.append(curves.get()->bodysm());
   16491                 :            : 
   16492 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbors.size(); k++)
   16493                 :            :           {
   16494 [ #  # ][ #  # ]:          0 :             if(BridgeManager* m = neighbors.get_and_step()->bridge_manager())
                 [ #  # ]
   16495                 :            :             {
   16496 [ #  # ][ #  # ]:          0 :               if(TopologyEntity* t = m->topology_entity())
   16497                 :            :               {
   16498         [ #  # ]:          0 :                 RefEntity *ref_ent = CAST_TO(t, RefEntity );
   16499         [ #  # ]:          0 :                 entities_to_update.append(ref_ent);
   16500                 :            :               }
   16501                 :            :             }
   16502         [ #  # ]:          0 :           }
   16503                 :            :         }
   16504                 :            :       }
   16505                 :            :     }
   16506         [ #  # ]:          0 :   }
   16507                 :            : 
   16508         [ #  # ]:          0 :   if(preview == CUBIT_FALSE )
   16509                 :            :   {
   16510                 :            :     // Update DAG
   16511         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   16512                 :            : 
   16513                 :            :     // Update graphics
   16514 [ #  # ][ #  # ]:          0 :     while (entities_to_update.size())
   16515 [ #  # ][ #  # ]:          0 :       AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entities_to_update.pop()));
         [ #  # ][ #  # ]
                 [ #  # ]
   16516                 :            : 
   16517 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   16518                 :            :     {
   16519         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   16520         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   16521         [ #  # ]:          0 :       else if( keep_old_body )
   16522         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   16523                 :            :     }
   16524                 :            :   }
   16525                 :            : 
   16526         [ #  # ]:          0 :   return stat;
   16527                 :            : }
   16528                 :            : 
   16529                 :            : 
   16530                 :            : //=============================================================================
   16531                 :            : // Description: Tweak specified faces of a volume or volumes up to a target
   16532                 :            : //              surface or set of connected target surfaces.
   16533                 :            : // Author     : Steve Storm
   16534                 :            : // Date       : 03/25/05
   16535                 :            : //=============================================================================
   16536                 :          0 : CubitStatus GeometryModifyTool::tweak_target( DLIList<RefFace*> &ref_face_list,
   16537                 :            :                                               DLIList<RefFace*> &target_face_list,
   16538                 :            :                                               DLIList<Body*> &new_body_list,
   16539                 :            :                                               CubitBoolean extend_flg,
   16540                 :            :                                               CubitPlane *limit_plane,
   16541                 :            :                                               CubitBoolean reverse_flg,
   16542                 :            :                                               CubitBoolean keep_old_body,
   16543                 :            :                                               CubitBoolean preview )
   16544                 :            : {
   16545 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list(ref_face_list.size());
   16546 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> target_surf_list(target_face_list.size());
                 [ #  # ]
   16547 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   16548                 :            :   GeometryModifyEngine *gme_ptr1, *gme_ptr2;
   16549                 :            : 
   16550         [ #  # ]:          0 :   gme_ptr1 = tweak_setup( ref_face_list, "Tweaking", old_body_list, surface_list, CUBIT_TRUE );
   16551         [ #  # ]:          0 :   if (!gme_ptr1)
   16552                 :          0 :     return CUBIT_FAILURE;
   16553                 :            : 
   16554 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list2;
   16555         [ #  # ]:          0 :   gme_ptr2 = tweak_setup( target_face_list, "Tweaking", old_body_list2, target_surf_list, CUBIT_TRUE );
   16556         [ #  # ]:          0 :   if (!gme_ptr2)
   16557                 :          0 :     return CUBIT_FAILURE;
   16558                 :            : 
   16559         [ #  # ]:          0 :   if( gme_ptr1 != gme_ptr2 )
   16560                 :            :   {
   16561 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Target surfaces must belong to same geometry engine as tweaked surfaces.\n" );
         [ #  # ][ #  # ]
   16562                 :          0 :     return CUBIT_FAILURE;
   16563                 :            :   }
   16564                 :            : 
   16565 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16566                 :            :   {
   16567         [ #  # ]:          0 :     if( keep_old_body )
   16568         [ #  # ]:          0 :       CubitUndo::save_state();
   16569                 :            :     else
   16570         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_face_list );
   16571                 :            :   }
   16572                 :            : 
   16573                 :            :   int i;
   16574 [ #  # ][ #  # ]:          0 :   DLIList<Body*> all_bodies = old_body_list;
   16575         [ #  # ]:          0 :   all_bodies += old_body_list2;
   16576 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms;
   16577 [ #  # ][ #  # ]:          0 :   for(i=all_bodies.size(); i--;)
   16578                 :            :   {
   16579 [ #  # ][ #  # ]:          0 :     BodySM* bsm = all_bodies.get_and_step()->get_body_sm_ptr();
   16580         [ #  # ]:          0 :     if(bsm)
   16581         [ #  # ]:          0 :       body_sms.append_unique(bsm);
   16582                 :            :   }
   16583                 :            : 
   16584         [ #  # ]:          0 :   if(!preview)
   16585                 :            :   {
   16586         [ #  # ]:          0 :     do_attribute_setup();
   16587         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   16588                 :            :   }
   16589                 :            : 
   16590                 :            :   // Do tweak to target
   16591 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   16592                 :            :   CubitStatus stat = gme_ptr1->tweak_target( surface_list, target_surf_list,
   16593                 :            :                                              new_bodysm_list, extend_flg,
   16594                 :            :                                              limit_plane, reverse_flg,
   16595         [ #  # ]:          0 :                                              keep_old_body, preview );
   16596                 :            : 
   16597                 :            : 
   16598         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   16599                 :            :   {
   16600         [ #  # ]:          0 :     if(!preview)
   16601         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, all_bodies);
   16602 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16603         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   16604         [ #  # ]:          0 :     if(!preview)
   16605         [ #  # ]:          0 :       do_attribute_cleanup();
   16606                 :          0 :     return CUBIT_FAILURE;
   16607                 :            :   }
   16608                 :            :   else
   16609                 :            :   {
   16610         [ #  # ]:          0 :     if(!preview)
   16611                 :            :     {
   16612         [ #  # ]:          0 :       restore_vg_after_modify(new_bodysm_list, all_bodies, gme_ptr1);
   16613         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, all_bodies);
   16614                 :            :     }
   16615                 :            :   }
   16616                 :            : 
   16617                 :            :   // Collect all the old_faces to be compared against new_faces later...DJQ
   16618 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> old_faces;
   16619 [ #  # ][ #  # ]:          0 :   for (i = 0; i < old_body_list.size(); i++)
   16620                 :            :   {
   16621         [ #  # ]:          0 :       Body *old_body = old_body_list.get_and_step();
   16622         [ #  # ]:          0 :       DLIList<RefFace*> tmp_faces;
   16623         [ #  # ]:          0 :       old_body->ref_faces(tmp_faces);
   16624         [ #  # ]:          0 :       old_faces +=tmp_faces;
   16625         [ #  # ]:          0 :   }
   16626                 :            : 
   16627                 :            :   // Update DAG
   16628         [ #  # ]:          0 :   stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   16629                 :            : 
   16630         [ #  # ]:          0 :   if(!preview)
   16631         [ #  # ]:          0 :     do_attribute_cleanup();
   16632                 :            : 
   16633         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   16634                 :            :   {
   16635 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16636         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   16637                 :          0 :     return CUBIT_FAILURE;
   16638                 :            :   }
   16639                 :            : 
   16640                 :            :   //collect all the new faces
   16641 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> new_faces;
   16642 [ #  # ][ #  # ]:          0 :   for( i=new_body_list.size(); i--; )
   16643                 :            :   {
   16644         [ #  # ]:          0 :     Body *new_body = new_body_list.get_and_step();
   16645         [ #  # ]:          0 :     DLIList<RefFace*> tmp_faces;
   16646         [ #  # ]:          0 :     new_body->ref_faces( tmp_faces );
   16647         [ #  # ]:          0 :     new_faces += tmp_faces;
   16648         [ #  # ]:          0 :   }
   16649                 :            : 
   16650                 :            :   // Compare the new_faces list with the old_faces list to determine which faces are created
   16651                 :            :   // Add these faces to the all_ref_face_list to check for its neighbors...DJQ
   16652 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> difference = new_faces;
   16653         [ #  # ]:          0 :   difference -= old_faces;
   16654         [ #  # ]:          0 :   ref_face_list += difference;
   16655                 :            : 
   16656                 :            : 
   16657                 :            :   // loop body sm list and find surfaces that need updating.
   16658                 :            :   // this is to account for some cases where the topology doesn't change, but the geometry does.
   16659 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
   16660 [ #  # ][ #  # ]:          0 :   for(i=0; i<new_bodysm_list.size(); i++)
   16661                 :            :   {
   16662         [ #  # ]:          0 :     BodySM* bodysm = new_bodysm_list.get_and_step();
   16663         [ #  # ]:          0 :     DLIList<Surface*> surfs;
   16664         [ #  # ]:          0 :     bodysm->surfaces(surfs);
   16665                 :            :     int j;
   16666                 :            :     // find a surface that is also found in our input list
   16667                 :            :     // some times the target surface gets modified
   16668 [ #  # ][ #  # ]:          0 :     for(j=0; j<surfs.size(); j++, surfs.step())
                 [ #  # ]
   16669                 :            :     {
   16670 [ #  # ][ #  # ]:          0 :       BridgeManager* man = surfs.get()->bridge_manager();
   16671         [ #  # ]:          0 :       if(man)
   16672                 :            :       {
   16673 [ #  # ][ #  # ]:          0 :         RefFace* ref_face = CAST_TO(man->topology_entity(), RefFace);
   16674 [ #  # ][ #  # ]:          0 :         if(ref_face && (ref_face_list.is_in_list(ref_face) ||
         [ #  # ][ #  # ]
                 [ #  # ]
   16675         [ #  # ]:          0 :             target_face_list.is_in_list(ref_face)))
   16676                 :            :         {
   16677                 :            :           // get neighbors
   16678         [ #  # ]:          0 :           DLIList<TBPoint*> neighbor_points;
   16679 [ #  # ][ #  # ]:          0 :           surfs.get()->points(neighbor_points);
   16680 [ #  # ][ #  # ]:          0 :           DLIList<Curve*> neighbor_curves;
   16681 [ #  # ][ #  # ]:          0 :           DLIList<Surface*> neighbor_surfaces;
   16682 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> neighbors;
   16683 [ #  # ][ #  # ]:          0 :           DLIList<TopologyBridge*> tmp;
   16684                 :            :           int k;
   16685 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   16686 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->surfaces(neighbor_surfaces);
   16687 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbor_points.size(); k++)
   16688 [ #  # ][ #  # ]:          0 :             neighbor_points.get_and_step()->curves(neighbor_curves);
   16689                 :            : 
   16690 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16691         [ #  # ]:          0 :           neighbors += tmp;
   16692         [ #  # ]:          0 :           neighbor_curves.uniquify_ordered();
   16693 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16694         [ #  # ]:          0 :           neighbors += tmp;
   16695         [ #  # ]:          0 :           neighbor_surfaces.uniquify_ordered();
   16696 [ #  # ][ #  # ]:          0 :           CAST_LIST_TO_PARENT(neighbor_surfaces, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   16697         [ #  # ]:          0 :           neighbors += tmp;
   16698 [ #  # ][ #  # ]:          0 :           neighbors.append(surfs.get()->lump());
                 [ #  # ]
   16699 [ #  # ][ #  # ]:          0 :           neighbors.append(surfs.get()->bodysm());
                 [ #  # ]
   16700                 :            : 
   16701 [ #  # ][ #  # ]:          0 :           for(k=0; k<neighbors.size(); k++)
   16702 [ #  # ][ #  # ]:          0 :             if(BridgeManager* m = neighbors.get_and_step()->bridge_manager())
                 [ #  # ]
   16703 [ #  # ][ #  # ]:          0 :               if(TopologyEntity* t = m->topology_entity())
   16704 [ #  # ][ #  # ]:          0 :                 entities_to_update.append(CAST_TO(t, RefEntity));
                 [ #  # ]
   16705                 :            :         }
   16706                 :            :       }
   16707                 :            :     }
   16708         [ #  # ]:          0 :   }
   16709                 :            : 
   16710                 :            :   //unmerge any merged adjacent surfaces or
   16711                 :            :   //merged curves in unmerged adjacent surfaces
   16712 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> adjacent_faces_to_unmerge;
   16713 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> adjacent_edges_to_unmerge;
   16714 [ #  # ][ #  # ]:          0 :   for(i=ref_face_list.size(); i--;)
   16715                 :            :   {
   16716         [ #  # ]:          0 :     RefFace *tweaked_face = ref_face_list.get_and_step();
   16717 [ #  # ][ #  # ]:          0 :     if( !new_faces.move_to( tweaked_face ) )
   16718                 :          0 :       continue;
   16719                 :            : 
   16720                 :            :     //get all the edges of the face you tweaked
   16721         [ #  # ]:          0 :     DLIList<RefEdge*> tweaked_face_edges;
   16722         [ #  # ]:          0 :     tweaked_face->ref_edges( tweaked_face_edges );
   16723         [ #  # ]:          0 :     adjacent_edges_to_unmerge += tweaked_face_edges;
   16724                 :            : 
   16725                 :            :     //get all the adjacent faces to this edge
   16726                 :            :     int j;
   16727 [ #  # ][ #  # ]:          0 :     for( j=tweaked_face_edges.size(); j--; )
   16728                 :            :     {
   16729         [ #  # ]:          0 :       RefEdge *tmp_edge = tweaked_face_edges.get_and_step();
   16730         [ #  # ]:          0 :       DLIList<RefFace*> tmp_faces;
   16731         [ #  # ]:          0 :       tmp_edge->ref_faces( tmp_faces );
   16732         [ #  # ]:          0 :       tmp_faces.remove( tweaked_face );
   16733         [ #  # ]:          0 :       adjacent_faces_to_unmerge += tmp_faces;
   16734         [ #  # ]:          0 :     }
   16735                 :            : 
   16736                 :            :     //get all edges not in the surface,
   16737                 :            :     //sharing vertices with the surface
   16738 [ #  # ][ #  # ]:          0 :     DLIList<RefVertex*> ref_vertices;
   16739         [ #  # ]:          0 :     tweaked_face->ref_vertices( ref_vertices );
   16740 [ #  # ][ #  # ]:          0 :     for( j=ref_vertices.size(); j--; )
   16741                 :            :     {
   16742         [ #  # ]:          0 :       RefVertex *tmp_vert = ref_vertices.get_and_step();
   16743         [ #  # ]:          0 :       DLIList<RefEdge*>  ref_edges;
   16744         [ #  # ]:          0 :       tmp_vert->ref_edges( ref_edges );
   16745                 :            : 
   16746                 :            :       int k;
   16747 [ #  # ][ #  # ]:          0 :       for( k=ref_edges.size(); k--; )
   16748                 :            :       {
   16749         [ #  # ]:          0 :         RefEdge *tmp_edge = ref_edges.get_and_step();
   16750 [ #  # ][ #  # ]:          0 :         if( !tweaked_face_edges.move_to( tmp_edge ) )
   16751         [ #  # ]:          0 :           adjacent_edges_to_unmerge.append( tmp_edge );
   16752                 :            :       }
   16753         [ #  # ]:          0 :     }
   16754         [ #  # ]:          0 :   }
   16755                 :            : 
   16756                 :            :   //unmerge any adjacent faces
   16757         [ #  # ]:          0 :   adjacent_faces_to_unmerge.uniquify_unordered();
   16758 [ #  # ][ #  # ]:          0 :   for( i=adjacent_faces_to_unmerge.size(); i--; )
   16759                 :            :   {
   16760         [ #  # ]:          0 :     RefFace *ref_face = adjacent_faces_to_unmerge.get_and_step();
   16761                 :            : 
   16762         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
   16763 [ #  # ][ #  # ]:          0 :     ref_face->bridge_manager()->get_bridge_list(bridge_list);
   16764 [ #  # ][ #  # ]:          0 :     if (bridge_list.size() > 1)
   16765                 :            :     {
   16766 [ #  # ][ #  # ]:          0 :       if( MergeTool::instance()->unmerge( ref_face ) )
                 [ #  # ]
   16767 [ #  # ][ #  # ]:          0 :         PRINT_WARNING("Unmerging Surface %d\n", ref_face->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   16768                 :            :     }
   16769         [ #  # ]:          0 :   }
   16770                 :            : 
   16771                 :            :   //unmerge any adjacent edges
   16772         [ #  # ]:          0 :   adjacent_edges_to_unmerge.uniquify_unordered();
   16773 [ #  # ][ #  # ]:          0 :   for( i=adjacent_edges_to_unmerge.size(); i--; )
   16774                 :            :   {
   16775         [ #  # ]:          0 :     RefEdge *ref_edge = adjacent_edges_to_unmerge.get_and_step();
   16776         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
   16777 [ #  # ][ #  # ]:          0 :     ref_edge->bridge_manager()->get_bridge_list(bridge_list);
   16778 [ #  # ][ #  # ]:          0 :     if (bridge_list.size() > 1)
   16779                 :            :     {
   16780 [ #  # ][ #  # ]:          0 :       if( MergeTool::instance()->unmerge( ref_edge) )
                 [ #  # ]
   16781 [ #  # ][ #  # ]:          0 :         PRINT_WARNING("Unmerging Curve %d\n", ref_edge->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   16782                 :            :     }
   16783         [ #  # ]:          0 :   }
   16784                 :            : 
   16785 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && keep_old_body )
         [ #  # ][ #  # ]
   16786         [ #  # ]:          0 :     CubitUndo::note_result_bodies( new_body_list );
   16787                 :            : 
   16788                 :            :   // Update graphics
   16789 [ #  # ][ #  # ]:          0 :   while (entities_to_update.size())
   16790 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entities_to_update.pop()));
         [ #  # ][ #  # ]
                 [ #  # ]
   16791                 :            : 
   16792                 :            : 
   16793         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   16794                 :            : }
   16795                 :            : 
   16796                 :            : //=============================================================================
   16797                 :            : // Description: Tweak specified faces of a volume or volumes up to a target
   16798                 :            : //              plane.
   16799                 :            : // Author     : Steve Storm
   16800                 :            : // Date       : 05/10/05
   16801                 :            : //=============================================================================
   16802                 :          0 : CubitStatus GeometryModifyTool::tweak_target( DLIList<RefFace*> &ref_face_list,
   16803                 :            :                                               CubitPlane &plane,
   16804                 :            :                                               DLIList<Body*> &new_body_list,
   16805                 :            :                                               CubitBoolean reverse_flg,
   16806                 :            :                                               CubitBoolean keep_old_body,
   16807                 :            :                                               CubitBoolean preview )
   16808                 :            : {
   16809 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list(ref_face_list.size()+1);
   16810 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   16811                 :            :   GeometryModifyEngine* gme_ptr;
   16812                 :            : 
   16813         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_face_list, "Tweaking", old_body_list, surface_list, CUBIT_TRUE );
   16814         [ #  # ]:          0 :   if (!gme_ptr)
   16815                 :          0 :     return CUBIT_FAILURE;
   16816                 :            : 
   16817                 :            :   // Create a target Surface from the plane (arbitrarily 10.0 X 10.0 in size)
   16818                 :            : 
   16819                 :            :   // Get corners of the surface
   16820 [ #  # ][ #  # ]:          0 :   CubitVector normal = plane.normal();
   16821 [ #  # ][ #  # ]:          0 :   CubitVector x, y;
   16822         [ #  # ]:          0 :   normal.orthogonal_vectors( x, y );
   16823         [ #  # ]:          0 :   CubitVector p1 = plane.point_on_plane();
   16824 [ #  # ][ #  # ]:          0 :   CubitVector p2, p3, p4;
                 [ #  # ]
   16825         [ #  # ]:          0 :   p1.next_point( x, 5.0, p1 );
   16826         [ #  # ]:          0 :   p1.next_point( y, 5.0, p1 );
   16827 [ #  # ][ #  # ]:          0 :   p1.next_point( -x, 10.0, p2 );
   16828 [ #  # ][ #  # ]:          0 :   p2.next_point( -y, 10.0, p3 );
   16829         [ #  # ]:          0 :   p3.next_point( x, 10.0, p4 );
   16830                 :            : 
   16831         [ #  # ]:          0 :   BodySM* bodysm_ptr = gme_ptr->planar_sheet( p1, p2, p3, p4 );
   16832         [ #  # ]:          0 :   if( !bodysm_ptr )
   16833                 :            :   {
   16834 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "unable to create target surface from plane\n" );
         [ #  # ][ #  # ]
   16835                 :          0 :     return CUBIT_FAILURE;
   16836                 :            :   }
   16837                 :            : 
   16838 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> target_surf_list;
   16839         [ #  # ]:          0 :   bodysm_ptr->surfaces( target_surf_list );
   16840 [ #  # ][ #  # ]:          0 :   if( !target_surf_list.size() )
   16841                 :            :   {
   16842 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "unable to create target surface from plane\n" );
         [ #  # ][ #  # ]
   16843                 :          0 :     return CUBIT_FAILURE;
   16844                 :            :   }
   16845                 :            : 
   16846                 :            :   int i;
   16847 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sms;
   16848 [ #  # ][ #  # ]:          0 :   for(i=old_body_list.size(); i--;)
   16849                 :            :   {
   16850 [ #  # ][ #  # ]:          0 :     BodySM* bsm = old_body_list.get_and_step()->get_body_sm_ptr();
   16851         [ #  # ]:          0 :     if(bsm)
   16852         [ #  # ]:          0 :       body_sms.append_unique(bsm);
   16853                 :            :   }
   16854                 :            : 
   16855         [ #  # ]:          0 :   if(!preview)
   16856                 :            :   {
   16857         [ #  # ]:          0 :     do_attribute_setup();
   16858         [ #  # ]:          0 :     push_attributes_before_modify(body_sms);
   16859                 :            :   }
   16860                 :            : 
   16861                 :            :   // Do tweak to target
   16862 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   16863                 :            :   CubitStatus stat = gme_ptr->tweak_target( surface_list, target_surf_list,
   16864                 :            :                                             new_bodysm_list, CUBIT_TRUE,
   16865                 :            :                                             NULL, reverse_flg, keep_old_body,
   16866         [ #  # ]:          0 :                                             preview );
   16867                 :            : 
   16868                 :            : 
   16869         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   16870                 :            :   {
   16871         [ #  # ]:          0 :     if(!preview)
   16872         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   16873 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16874         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   16875         [ #  # ]:          0 :     if(!preview)
   16876         [ #  # ]:          0 :       do_attribute_cleanup();
   16877                 :          0 :     return CUBIT_FAILURE;
   16878                 :            :   }
   16879                 :            :   else
   16880                 :            :   {
   16881         [ #  # ]:          0 :     if(!preview)
   16882                 :            :     {
   16883         [ #  # ]:          0 :       restore_vg_after_modify(new_bodysm_list, old_body_list, gme_ptr);
   16884         [ #  # ]:          0 :       remove_pushed_attributes(new_bodysm_list, old_body_list);
   16885                 :            :     }
   16886                 :            :   }
   16887                 :            : 
   16888                 :            :   // Delete temporary sheet body
   16889 [ #  # ][ #  # ]:          0 :   bodysm_ptr->get_geometry_query_engine()->delete_solid_model_entities( bodysm_ptr );
   16890                 :            : 
   16891                 :            :   // Update DAG
   16892         [ #  # ]:          0 :   stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   16893                 :            : 
   16894         [ #  # ]:          0 :   if(!preview)
   16895         [ #  # ]:          0 :     do_attribute_cleanup();
   16896                 :            : 
   16897         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   16898                 :            :   {
   16899 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16900         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   16901                 :          0 :     return CUBIT_FAILURE;
   16902                 :            :   }
   16903                 :            : 
   16904                 :            :   // Update graphics
   16905 [ #  # ][ #  # ]:          0 :   DLIList<Body*> moved_bodies(new_body_list);
   16906         [ #  # ]:          0 :   moved_bodies.intersect(old_body_list);
   16907 [ #  # ][ #  # ]:          0 :   while (moved_bodies.size())
   16908 [ #  # ][ #  # ]:          0 :     moved_bodies.pop()->notify_sub_all_observers( GeometryEvent::GEOMETRY_MODIFIED );
   16909                 :            : 
   16910         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   16911                 :            : }
   16912                 :            : 
   16913                 :            : //=============================================================================
   16914                 :            : // Description: Tweak specified edges of a surface or set of surfaces (in sheet
   16915                 :            : //              bodies) up to a target surface or set of target surfaces.
   16916                 :            : // Author     : Steve Storm
   16917                 :            : // Date       : 03/25/05
   16918                 :            : //=============================================================================
   16919                 :          0 : CubitStatus GeometryModifyTool::tweak_target( DLIList<RefEdge*> &ref_edge_list,
   16920                 :            :                                               DLIList<RefFace*> &target_face_list,
   16921                 :            :                                               DLIList<Body*> &new_body_list,
   16922                 :            :                                               CubitBoolean extend_flg,
   16923                 :            :                                               CubitPlane *limit_plane,
   16924                 :            :                                               CubitBoolean reverse_flg,
   16925                 :            :                                               CubitBoolean keep_old,
   16926                 :            :                                               CubitBoolean preview,
   16927                 :            :                                               double max_area_increase /*= 0%*/ )
   16928                 :            : {
   16929 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
   16930 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> target_surf_list(target_face_list.size());
                 [ #  # ]
   16931 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   16932                 :            :   GeometryModifyEngine *gme_ptr1, *gme_ptr2;
   16933                 :            : 
   16934         [ #  # ]:          0 :   gme_ptr1 = tweak_setup( ref_edge_list, "Tweaking", old_body_list, curve_list );
   16935         [ #  # ]:          0 :   if( !gme_ptr1 )
   16936                 :          0 :     return CUBIT_FAILURE;
   16937                 :            : 
   16938 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list2;
   16939         [ #  # ]:          0 :   gme_ptr2 = tweak_setup( target_face_list, "Tweaking", old_body_list2, target_surf_list );
   16940         [ #  # ]:          0 :   if( !gme_ptr2 )
   16941                 :          0 :     return CUBIT_FAILURE;
   16942                 :            : 
   16943         [ #  # ]:          0 :   if( gme_ptr1 != gme_ptr2 )
   16944                 :            :   {
   16945 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Target surface(s) must belong to same geometry engine as tweaked curves.\n" );
         [ #  # ][ #  # ]
   16946                 :          0 :     return CUBIT_FAILURE;
   16947                 :            :   }
   16948                 :            : 
   16949 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16950                 :            :   {
   16951         [ #  # ]:          0 :     if( keep_old )
   16952         [ #  # ]:          0 :       CubitUndo::save_state();
   16953                 :            :     else
   16954         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edge_list );
   16955                 :            :   }
   16956                 :            : 
   16957                 :            :   // Do tweak to target
   16958 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   16959                 :            :   CubitStatus stat = gme_ptr1->tweak_target( curve_list, target_surf_list,
   16960                 :            :                                              new_bodysm_list, extend_flg,
   16961                 :            :                                              limit_plane, reverse_flg,
   16962         [ #  # ]:          0 :                                              keep_old, preview, max_area_increase );
   16963                 :            : 
   16964         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   16965                 :            :   {
   16966 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16967         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   16968                 :          0 :     return CUBIT_FAILURE;
   16969                 :            :   }
   16970                 :            : 
   16971                 :            :   // Update DAG
   16972         [ #  # ]:          0 :   stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   16973                 :            : 
   16974                 :            : 
   16975         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   16976                 :            :   {
   16977 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16978         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   16979                 :          0 :     return CUBIT_FAILURE;
   16980                 :            :   }
   16981                 :            : 
   16982 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   16983                 :            :   {
   16984         [ #  # ]:          0 :     if( keep_old )
   16985         [ #  # ]:          0 :       CubitUndo::note_result_bodies( new_body_list );
   16986                 :            :   }
   16987                 :            : 
   16988                 :            :   // Update graphics
   16989 [ #  # ][ #  # ]:          0 :   DLIList<Body*> moved_bodies(new_body_list);
   16990         [ #  # ]:          0 :   moved_bodies.intersect(old_body_list);
   16991 [ #  # ][ #  # ]:          0 :   while (moved_bodies.size())
   16992 [ #  # ][ #  # ]:          0 :   moved_bodies.pop()->notify_sub_all_observers( GeometryEvent::GEOMETRY_MODIFIED );
   16993                 :            : 
   16994         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   16995                 :            : }
   16996                 :            : 
   16997                 :            : //=============================================================================
   16998                 :            : // Description: Tweak specified edges of a surface or set of surfaces (in sheet
   16999                 :            : //              bodies) up to a target plane.
   17000                 :            : // Author     : Steve Storm
   17001                 :            : // Date       : 03/25/05
   17002                 :            : //=============================================================================
   17003                 :          0 : CubitStatus GeometryModifyTool::tweak_target( DLIList<RefEdge*> &ref_edge_list,
   17004                 :            :                                               CubitPlane &plane,
   17005                 :            :                                               DLIList<Body*> &new_body_list,
   17006                 :            :                                               CubitBoolean reverse_flg,
   17007                 :            :                                               CubitBoolean keep_old,
   17008                 :            :                                               CubitBoolean preview )
   17009                 :            : {
   17010 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
   17011 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   17012                 :            :   GeometryModifyEngine* gme_ptr;
   17013                 :            : 
   17014         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_edge_list, "Tweaking", old_body_list, curve_list );
   17015         [ #  # ]:          0 :   if( !gme_ptr )
   17016                 :          0 :     return CUBIT_FAILURE;
   17017                 :            : 
   17018                 :            :   // Create a target Surface from the plane (arbitrarily 10.0 X 10.0 in size)
   17019                 :            : 
   17020                 :            :   // Get corners of the surface
   17021 [ #  # ][ #  # ]:          0 :   CubitVector normal = plane.normal();
   17022 [ #  # ][ #  # ]:          0 :   CubitVector x, y;
   17023         [ #  # ]:          0 :   normal.orthogonal_vectors( x, y );
   17024         [ #  # ]:          0 :   CubitVector p1 = plane.point_on_plane();
   17025 [ #  # ][ #  # ]:          0 :   CubitVector p2, p3, p4;
                 [ #  # ]
   17026         [ #  # ]:          0 :   p1.next_point( x, 5.0, p1 );
   17027         [ #  # ]:          0 :   p1.next_point( y, 5.0, p1 );
   17028 [ #  # ][ #  # ]:          0 :   p1.next_point( -x, 10.0, p2 );
   17029 [ #  # ][ #  # ]:          0 :   p2.next_point( -y, 10.0, p3 );
   17030         [ #  # ]:          0 :   p3.next_point( x, 10.0, p4 );
   17031                 :            : 
   17032         [ #  # ]:          0 :   BodySM* bodysm_ptr = gme_ptr->planar_sheet( p1, p2, p3, p4 );
   17033         [ #  # ]:          0 :   if( !bodysm_ptr )
   17034                 :            :   {
   17035 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "unable to create target surface from plane\n" );
         [ #  # ][ #  # ]
   17036                 :          0 :     return CUBIT_FAILURE;
   17037                 :            :   }
   17038                 :            : 
   17039 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> target_surf_list;
   17040         [ #  # ]:          0 :   bodysm_ptr->surfaces( target_surf_list );
   17041 [ #  # ][ #  # ]:          0 :   if( !target_surf_list.size() )
   17042                 :            :   {
   17043 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "unable to create target surface from plane\n" );
         [ #  # ][ #  # ]
   17044                 :          0 :     return CUBIT_FAILURE;
   17045                 :            :   }
   17046                 :            : 
   17047 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   17048                 :            :   {
   17049         [ #  # ]:          0 :     if( keep_old )
   17050         [ #  # ]:          0 :       CubitUndo::save_state();
   17051                 :            :     else
   17052         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edge_list );
   17053                 :            :   }
   17054                 :            : 
   17055                 :            :   // Do tweak to target
   17056 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   17057                 :            :   CubitStatus stat = gme_ptr->tweak_target( curve_list, target_surf_list,
   17058                 :            :                                             new_bodysm_list, CUBIT_TRUE,
   17059                 :            :                                             NULL, reverse_flg, keep_old,
   17060         [ #  # ]:          0 :                                             preview );
   17061                 :            : 
   17062         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   17063                 :            :   {
   17064 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   17065         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17066                 :          0 :     return CUBIT_FAILURE;
   17067                 :            :   }
   17068                 :            : 
   17069                 :            :   // Delete temporary sheet body
   17070 [ #  # ][ #  # ]:          0 :   bodysm_ptr->get_geometry_query_engine()->delete_solid_model_entities( bodysm_ptr );
   17071                 :            : 
   17072                 :            :   // Update DAG
   17073         [ #  # ]:          0 :   stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   17074                 :            : 
   17075         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE )
   17076                 :            :   {
   17077 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   17078         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17079                 :          0 :     return CUBIT_FAILURE;
   17080                 :            :   }
   17081                 :            : 
   17082 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && keep_old )
         [ #  # ][ #  # ]
   17083         [ #  # ]:          0 :     CubitUndo::note_result_bodies( new_body_list );
   17084                 :            : 
   17085                 :            :   // Update graphics
   17086 [ #  # ][ #  # ]:          0 :   DLIList<Body*> moved_bodies(new_body_list);
   17087         [ #  # ]:          0 :   moved_bodies.intersect(old_body_list);
   17088 [ #  # ][ #  # ]:          0 :   while (moved_bodies.size())
   17089 [ #  # ][ #  # ]:          0 :     moved_bodies.pop()->notify_sub_all_observers( GeometryEvent::GEOMETRY_MODIFIED );
   17090                 :            : 
   17091         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   17092                 :            : }
   17093                 :            : 
   17094                 :            : //=============================================================================
   17095                 :            : // Description: Tweak specified edges of a sheet body or bodies up to target
   17096                 :            : //              curves that are part of a sheet body.  The target is a surface
   17097                 :            : //              created by thickening the owning surface of the target curves.
   17098                 :            : // Author     : Steve Storm
   17099                 :            : // Date       : 03/25/05
   17100                 :            : //=============================================================================
   17101                 :          0 : CubitStatus GeometryModifyTool::tweak_target( DLIList<RefEdge*> &ref_edge_list,
   17102                 :            :                                               DLIList<RefEdge*> &target_edge_list,
   17103                 :            :                                               DLIList<Body*> &new_body_list,
   17104                 :            :                                               CubitBoolean extend_flg,
   17105                 :            :                                               CubitPlane *limit_plane,
   17106                 :            :                                               CubitBoolean reverse_flg,
   17107                 :            :                                               CubitBoolean keep_old,
   17108                 :            :                                               CubitBoolean preview,
   17109                 :            :                                               double max_area_increase /*= 0*/ )
   17110                 :            : {
   17111 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
   17112 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> target_curve_list(target_edge_list.size());
                 [ #  # ]
   17113 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   17114                 :            :   GeometryModifyEngine *gme_ptr1, *gme_ptr2;
   17115                 :            : 
   17116         [ #  # ]:          0 :   gme_ptr1 = tweak_setup( ref_edge_list, "Tweaking", old_body_list, curve_list );
   17117         [ #  # ]:          0 :   if( !gme_ptr1 )
   17118                 :          0 :     return CUBIT_FAILURE;
   17119                 :            : 
   17120 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list2;
   17121         [ #  # ]:          0 :   gme_ptr2 = tweak_setup( target_edge_list, "Tweaking", old_body_list2, target_curve_list );
   17122         [ #  # ]:          0 :   if( !gme_ptr2 )
   17123                 :          0 :     return CUBIT_FAILURE;
   17124                 :            : 
   17125         [ #  # ]:          0 :   if( gme_ptr1 != gme_ptr2 )
   17126                 :            :   {
   17127 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Target curves must belong to same geometry engine as tweaked curves.\n" );
         [ #  # ][ #  # ]
   17128                 :          0 :     return CUBIT_FAILURE;
   17129                 :            :   }
   17130                 :            : 
   17131 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   17132                 :            :   {
   17133         [ #  # ]:          0 :     if( keep_old )
   17134         [ #  # ]:          0 :       CubitUndo::save_state();
   17135                 :            :     else
   17136         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_edge_list );
   17137                 :            :   }
   17138                 :            : 
   17139                 :            :   // Do tweak to target
   17140 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   17141                 :            :   CubitStatus stat = gme_ptr1->tweak_target( curve_list, target_curve_list,
   17142                 :            :                                              new_bodysm_list, extend_flg,
   17143                 :            :                                              limit_plane, reverse_flg,
   17144         [ #  # ]:          0 :                                              keep_old, preview, max_area_increase );
   17145                 :            : 
   17146 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   17147         [ #  # ]:          0 :     if( stat == CUBIT_FAILURE )
   17148         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17149                 :            : 
   17150         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE)
   17151                 :          0 :     return stat;
   17152                 :            : 
   17153 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> entities_to_update;
   17154         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   17155                 :            :   {
   17156                 :            :     // check for resued entities, they have been moved and we need to notify observers
   17157                 :            :     int i;
   17158 [ #  # ][ #  # ]:          0 :     for(i=0; i<new_bodysm_list.size(); i++)
   17159                 :            :     {
   17160         [ #  # ]:          0 :       BodySM* bodysm = new_bodysm_list.get_and_step();
   17161         [ #  # ]:          0 :       DLIList<TopologyBridge*> to_check;
   17162 [ #  # ][ #  # ]:          0 :       DLIList<TopologyBridge*> tmp;
   17163 [ #  # ][ #  # ]:          0 :       DLIList<Surface*> surfs;
   17164         [ #  # ]:          0 :       bodysm->surfaces(surfs);
   17165 [ #  # ][ #  # ]:          0 :       DLIList<Curve*> curves;
   17166         [ #  # ]:          0 :       bodysm->curves(curves);
   17167 [ #  # ][ #  # ]:          0 :       DLIList<TBPoint*> points;
   17168         [ #  # ]:          0 :       bodysm->points(points);
   17169         [ #  # ]:          0 :       to_check.append(bodysm);
   17170 [ #  # ][ #  # ]:          0 :       to_check.append(bodysm->lump());
   17171 [ #  # ][ #  # ]:          0 :       CAST_LIST_TO_PARENT(surfs, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   17172         [ #  # ]:          0 :       to_check += tmp;
   17173 [ #  # ][ #  # ]:          0 :       CAST_LIST_TO_PARENT(curves, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   17174         [ #  # ]:          0 :       to_check += tmp;
   17175 [ #  # ][ #  # ]:          0 :       CAST_LIST_TO_PARENT(points, tmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   17176         [ #  # ]:          0 :       to_check += tmp;
   17177                 :            : 
   17178                 :            :       int k;
   17179 [ #  # ][ #  # ]:          0 :       for(k=0; k<to_check.size(); k++)
   17180 [ #  # ][ #  # ]:          0 :         if(BridgeManager* m = to_check.get_and_step()->bridge_manager())
                 [ #  # ]
   17181 [ #  # ][ #  # ]:          0 :           if(TopologyEntity* t = m->topology_entity())
   17182 [ #  # ][ #  # ]:          0 :             entities_to_update.append(CAST_TO(t, RefEntity));
   17183         [ #  # ]:          0 :     }
   17184                 :            : 
   17185                 :            :     // Update DAG
   17186         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   17187                 :            : 
   17188 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled()  )
   17189                 :            :     {
   17190         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   17191         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   17192         [ #  # ]:          0 :       else if( keep_old )
   17193         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   17194                 :            :     }
   17195                 :            :   }
   17196                 :            : 
   17197                 :            :   // Update graphics
   17198 [ #  # ][ #  # ]:          0 :   while (entities_to_update.size())
   17199 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, entities_to_update.pop()));
         [ #  # ][ #  # ]
                 [ #  # ]
   17200                 :            : 
   17201                 :            :   // Update graphics
   17202 [ #  # ][ #  # ]:          0 :   DLIList<Body*> moved_bodies(new_body_list);
   17203         [ #  # ]:          0 :   moved_bodies.intersect(old_body_list);
   17204 [ #  # ][ #  # ]:          0 :   while (moved_bodies.size())
   17205 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GEOMETRY_MODIFIED, moved_bodies.pop()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   17206                 :            : 
   17207         [ #  # ]:          0 :   return stat;
   17208                 :            : }
   17209                 :            : 
   17210                 :            : //=============================================================================
   17211                 :            : // Description: Tweak specified vertex of a sheet body to a given location.
   17212                 :            : //              The given vertex must be part of a planar surface or surfaces
   17213                 :            : //              attached to linear curves only.  The given location will be
   17214                 :            : //              projected to be on the planar surface(s) before being used.
   17215                 :            : // Author     : Steve Storm
   17216                 :            : // Date       : 09/09/08
   17217                 :            : //=============================================================================
   17218                 :            : CubitStatus
   17219                 :          0 : GeometryModifyTool::tweak_target( RefVertex *ref_vertex_ptr,
   17220                 :            :                                   DLIList<RefFace*> &modify_ref_face_list,
   17221                 :            :                                   CubitVector &target_loc,
   17222                 :            :                                   Body *&new_Body_ptr,
   17223                 :            :                                   CubitBoolean keep_old,
   17224                 :            :                                   CubitBoolean preview )
   17225                 :            : {
   17226 [ #  # ][ #  # ]:          0 :   if( modify_ref_face_list.size() == 0 )
   17227                 :            :   {
   17228 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "No surfaces found to modify\n" );
         [ #  # ][ #  # ]
   17229                 :          0 :     return CUBIT_FAILURE;
   17230                 :            :   }
   17231                 :            : 
   17232                 :            :   int i;
   17233                 :            :   RefFace *ref_face_ptr;
   17234                 :            : 
   17235                 :            :   // Check to make sure vertex is part of all given surfaces
   17236         [ #  # ]:          0 :   modify_ref_face_list.reset();
   17237 [ #  # ][ #  # ]:          0 :   for( i=modify_ref_face_list.size(); i--; )
   17238                 :            :   {
   17239         [ #  # ]:          0 :     ref_face_ptr = modify_ref_face_list.get_and_step();
   17240                 :            : 
   17241 [ #  # ][ #  # ]:          0 :     if( !ref_face_ptr->is_directly_related( ref_vertex_ptr ) )
   17242                 :            :     {
   17243 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Vertex %d is not part of 'modify' Surface %d\n",
         [ #  # ][ #  # ]
                 [ #  # ]
   17244         [ #  # ]:          0 :         ref_vertex_ptr->id(), ref_face_ptr->id() );
   17245                 :          0 :       return CUBIT_FAILURE;
   17246                 :            :     }
   17247                 :            :   }
   17248                 :            : 
   17249                 :            :   GeometryModifyEngine *gme_ptr;
   17250         [ #  # ]:          0 :   DLIList<RefVertex*> ref_vertex_list(1);
   17251         [ #  # ]:          0 :   ref_vertex_list.append( ref_vertex_ptr );
   17252 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   17253 [ #  # ][ #  # ]:          0 :   DLIList<TBPoint*> point_list(1);
   17254         [ #  # ]:          0 :   gme_ptr = tweak_setup( ref_vertex_list, "Tweaking", old_body_list, point_list );
   17255         [ #  # ]:          0 :   if( !gme_ptr )
   17256                 :          0 :     return CUBIT_FAILURE;
   17257                 :            : 
   17258                 :            :   // We already made sure the vertex is part of all of the modify faces, so
   17259                 :            :   // just use the common_modify_engine function to get the surface_list
   17260 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list;
   17261 [ #  # ][ #  # ]:          0 :   if( !common_modify_engine( modify_ref_face_list, surface_list ) )
   17262                 :          0 :     return CUBIT_FAILURE;
   17263                 :            : 
   17264                 :            :   // Make sure part of a sheet body, not a solid body
   17265         [ #  # ]:          0 :   Body *body_ptr = ref_vertex_ptr->body();
   17266 [ #  # ][ #  # ]:          0 :   if( !body_ptr->is_sheet_body() )
   17267                 :            :   {
   17268 [ #  # ][ #  # ]:          0 :     PRINT_ERROR( "Vertex %d is not in a sheet body - Body %d is solid.\n"
         [ #  # ][ #  # ]
                 [ #  # ]
   17269                 :            :       "       Tweaking a vertex to a target currently not possible on solid bodies.\n",
   17270         [ #  # ]:          0 :       ref_vertex_ptr->id(), body_ptr->id() );
   17271                 :          0 :     return CUBIT_FAILURE;
   17272                 :            :   }
   17273                 :            : 
   17274                 :            :   // Make sure all the given surfaces are planar
   17275         [ #  # ]:          0 :   modify_ref_face_list.reset();
   17276 [ #  # ][ #  # ]:          0 :   for( i=modify_ref_face_list.size(); i--; )
   17277                 :            :   {
   17278         [ #  # ]:          0 :     ref_face_ptr = modify_ref_face_list.get_and_step();
   17279                 :            : 
   17280 [ #  # ][ #  # ]:          0 :     if( !ref_face_ptr->is_planar() )
   17281                 :            :     {
   17282 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Surfaces to modify must be planar - Surface %d is not planar\n", ref_face_ptr->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   17283                 :          0 :       return CUBIT_FAILURE;
   17284                 :            :     }
   17285                 :            :   }
   17286                 :            : 
   17287                 :            :   // Make sure all curves (on modify surfaces) attached to the given vertex are linear
   17288                 :            :   // Get all attached curves
   17289                 :            :   int j;
   17290 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> ref_edge_list;
   17291         [ #  # ]:          0 :   ref_vertex_ptr->ref_edges( ref_edge_list );
   17292                 :            :   RefEdge *ref_edge_ptr;
   17293 [ #  # ][ #  # ]:          0 :   for( i=ref_edge_list.size(); i--; )
   17294                 :            :   {
   17295         [ #  # ]:          0 :     ref_edge_ptr = ref_edge_list.get_and_step();
   17296                 :            : 
   17297                 :            :     // Check to see if this edge is linear, if it is in one of the modify surfaces
   17298         [ #  # ]:          0 :     modify_ref_face_list.reset();
   17299 [ #  # ][ #  # ]:          0 :     for( j=modify_ref_face_list.size(); j--; )
   17300                 :            :     {
   17301         [ #  # ]:          0 :       ref_face_ptr = modify_ref_face_list.get_and_step();
   17302 [ #  # ][ #  # ]:          0 :       if( ref_face_ptr->is_directly_related( ref_edge_ptr ) )
   17303                 :            :       {
   17304         [ #  # ]:          0 :         Curve *curve_ptr = ref_edge_ptr->get_curve_ptr();
   17305         [ #  # ]:          0 :         GeometryType curve_type = curve_ptr->geometry_type();
   17306         [ #  # ]:          0 :         if( curve_type != STRAIGHT_CURVE_TYPE )
   17307                 :            :         {
   17308 [ #  # ][ #  # ]:          0 :           PRINT_ERROR( "Curve %d is not linear. Curves that are in the 'modify'\n"
         [ #  # ][ #  # ]
   17309                 :            :             "       surfaces attached to the tweak vertex must be linear.\n",
   17310         [ #  # ]:          0 :             ref_edge_ptr->id() );
   17311                 :          0 :           return CUBIT_FAILURE;
   17312                 :            :         }
   17313                 :            :         else
   17314                 :          0 :           break;
   17315                 :            :       }
   17316                 :            :     }
   17317                 :            :   }
   17318                 :            : 
   17319                 :            :   // Project the location to the given surfaces and make sure all of these locations
   17320                 :            :   // are the same
   17321         [ #  # ]:          0 :   modify_ref_face_list.reset();
   17322                 :            : 
   17323         [ #  # ]:          0 :   CubitVector ref_loc( target_loc ); // Reference location
   17324         [ #  # ]:          0 :   ref_face_ptr = modify_ref_face_list.get_and_step();
   17325         [ #  # ]:          0 :   ref_face_ptr->move_to_surface( ref_loc );
   17326         [ #  # ]:          0 :   int ref_surf_id = ref_face_ptr->id();
   17327                 :            : 
   17328 [ #  # ][ #  # ]:          0 :   for( i=modify_ref_face_list.size()-1; i--; )
   17329                 :            :   {
   17330         [ #  # ]:          0 :     ref_face_ptr = modify_ref_face_list.get_and_step();
   17331                 :            : 
   17332         [ #  # ]:          0 :     CubitVector proj_loc( target_loc );
   17333         [ #  # ]:          0 :     ref_face_ptr->move_to_surface( proj_loc );
   17334                 :            : 
   17335 [ #  # ][ #  # ]:          0 :     if( !ref_loc.about_equal( proj_loc ) )
   17336                 :            :     {
   17337 [ #  # ][ #  # ]:          0 :       PRINT_ERROR( "Target location must project to all of the 'modify' surfaces at\n"
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   17338                 :            :         "       exactly the same location - the tweaked Vertex %d will move to this\n"
   17339                 :            :         "       common (same) projected location, tweaking the modify surfaces with it.\n"
   17340                 :            :         "       Given target location = %f, %f, %f\n"
   17341                 :            :         "       Projected location on Surface %d = %f, %f, %f\n"
   17342                 :            :         "       Projected location on Surface %d = %f, %f, %f\n",
   17343                 :            :         ref_vertex_ptr->id(),
   17344                 :            :         target_loc.x(), target_loc.y(), target_loc.z(),
   17345                 :            :         ref_surf_id, ref_loc.x(), ref_loc.y(), ref_loc.z(),
   17346         [ #  # ]:          0 :         ref_face_ptr->id(), proj_loc.x(), proj_loc.y(), proj_loc.z() );
   17347                 :            : 
   17348                 :          0 :       return CUBIT_FAILURE;
   17349                 :            :     }
   17350                 :            :   }
   17351                 :            : 
   17352                 :            :   // It looks like the inputs are valid so get ready to do the tweak
   17353 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   17354                 :            :   {
   17355         [ #  # ]:          0 :     if( keep_old )
   17356         [ #  # ]:          0 :       CubitUndo::save_state();
   17357                 :            :     else
   17358         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_vertex_list );
   17359                 :            :   }
   17360                 :            : 
   17361         [ #  # ]:          0 :   TBPoint *point_ptr = point_list.get();
   17362                 :            : 
   17363                 :            :   // Do tweak to target
   17364                 :            :   BodySM *new_bodysm_ptr;
   17365                 :            :   CubitStatus stat = gme_ptr->tweak_target( point_ptr, surface_list,
   17366                 :            :                                             ref_loc,
   17367                 :            :                                             new_bodysm_ptr,
   17368         [ #  # ]:          0 :                                             keep_old, preview );
   17369                 :            : 
   17370 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() && preview == CUBIT_FALSE )
         [ #  # ][ #  # ]
   17371         [ #  # ]:          0 :     if( stat == CUBIT_FAILURE )
   17372         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17373                 :            : 
   17374         [ #  # ]:          0 :   if( stat == CUBIT_FAILURE)
   17375                 :          0 :     return stat;
   17376                 :            : 
   17377 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodysm_list;
   17378         [ #  # ]:          0 :   new_bodysm_list.append( new_bodysm_ptr );
   17379 [ #  # ][ #  # ]:          0 :   DLIList<Body*> new_body_list;
   17380                 :            : 
   17381         [ #  # ]:          0 :   if( preview == CUBIT_FALSE )
   17382                 :            :   {
   17383                 :            :     // Update DAG
   17384         [ #  # ]:          0 :     stat = finish_sm_op( old_body_list, new_bodysm_list, new_body_list );
   17385                 :            : 
   17386 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   17387                 :            :     {
   17388         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   17389         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   17390         [ #  # ]:          0 :       else if( keep_old )
   17391         [ #  # ]:          0 :         CubitUndo::note_result_bodies( new_body_list );
   17392                 :            :     }
   17393                 :            :   }
   17394                 :            : 
   17395                 :            :   // Update graphics
   17396 [ #  # ][ #  # ]:          0 :   DLIList<Body*> moved_bodies(new_body_list);
   17397         [ #  # ]:          0 :   moved_bodies.intersect(old_body_list);
   17398 [ #  # ][ #  # ]:          0 :   while (moved_bodies.size())
   17399 [ #  # ][ #  # ]:          0 :     moved_bodies.pop()->notify_sub_all_observers( GeometryEvent::GEOMETRY_MODIFIED );
   17400                 :            : 
   17401         [ #  # ]:          0 :   return stat;
   17402                 :            : }
   17403                 :            : 
   17404                 :            : // KGM
   17405                 :            : #if 0
   17406                 :            : bool GeometryModifyTool::contains_intermediate_geometry(DLIList<RefFace*>& ref_face_list) const
   17407                 :            : {
   17408                 :            :   for (int i = 0; i < ref_face_list.size(); i++)
   17409                 :            :     if (GeometryQueryTool::instance()->
   17410                 :            :         contains_intermediate_geometry(ref_face_list.next(i)))
   17411                 :            :       return true;
   17412                 :            : 
   17413                 :            :   return false;
   17414                 :            : }
   17415                 :            : #endif
   17416                 :            : 
   17417                 :            : /*
   17418                 :            : //the following surface tool operations added by Tyronne Lim (CAT) ********************
   17419                 :            : CubitStatus GeometryModifyTool::create_net_surface( DLIList<Surface*>& ref_face_list, BodySM *& new_body,
   17420                 :            :                                                     DLIList<DLIList<CubitVector*>*> &vec_lists_u,
   17421                 :            :                                                     DLIList<DLIList<CubitVector*>*> &vec_lists_v,
   17422                 :            :                                                     double net_tol, CubitBoolean heal )
   17423                 :            : {
   17424                 :            :    GeometryModifyEngine* GMEPtr = get_engine(ref_face_list.get());
   17425                 :            :    return GMEPtr->create_net_surface( ref_face_list, new_body, vec_lists_u, vec_lists_v, net_tol, heal );
   17426                 :            : } */
   17427                 :            : 
   17428                 :          0 : CubitStatus GeometryModifyTool::create_net_surface( DLIList<RefEdge*>& u_curves, DLIList<RefEdge*>& v_curves,
   17429                 :            :                                                     double net_tol, CubitBoolean heal )
   17430                 :            : {
   17431         [ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list;
   17432 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list;
   17433 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( u_curves, entity_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   17434                 :            : 
   17435                 :            :   GeometryModifyEngine* GME_ptr =
   17436         [ #  # ]:          0 :     common_modify_engine( entity_list, bridge_list );
   17437         [ #  # ]:          0 :   if(! GME_ptr )
   17438                 :            :   {
   17439 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Cannot construct a Surface using entities that do "
                 [ #  # ]
   17440         [ #  # ]:          0 :                  "not share a common GeometryModifyEngine.\n");
   17441                 :          0 :      return CUBIT_FAILURE;
   17442                 :            :   }
   17443                 :            : 
   17444 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curves_in_u(bridge_list.size());
                 [ #  # ]
   17445 [ #  # ][ #  # ]:          0 :   CAST_LIST( bridge_list, curves_in_u, Curve );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   17446                 :            : 
   17447         [ #  # ]:          0 :   bridge_list.clean_out();
   17448         [ #  # ]:          0 :   entity_list.clean_out();
   17449 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( v_curves, entity_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   17450                 :            : 
   17451                 :            :   GeometryModifyEngine* dummy_GME_ptr =
   17452         [ #  # ]:          0 :     common_modify_engine( entity_list, bridge_list );
   17453 [ #  # ][ #  # ]:          0 :   if(! dummy_GME_ptr || dummy_GME_ptr != GME_ptr )
   17454                 :            :   {
   17455 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Cannot construct a Surface using entities that do "
                 [ #  # ]
   17456         [ #  # ]:          0 :                  "not share a common GeometryModifyEngine.\n");
   17457                 :          0 :      return CUBIT_FAILURE;
   17458                 :            :   }
   17459                 :            : 
   17460 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curves_in_v(bridge_list.size());
                 [ #  # ]
   17461 [ #  # ][ #  # ]:          0 :   CAST_LIST( bridge_list, curves_in_v, Curve );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   17462                 :            : 
   17463                 :          0 :   BodySM *new_smbody = NULL;
   17464 [ #  # ][ #  # ]:          0 :   if( !GME_ptr->create_net_surface( curves_in_u, curves_in_v, new_smbody, net_tol, heal ) )
   17465                 :          0 :     return CUBIT_FAILURE;
   17466                 :            : 
   17467 [ #  # ][ #  # ]:          0 :   if (CubitUndo::get_undo_enabled())
   17468         [ #  # ]:          0 :     CubitUndo::save_state();
   17469                 :            : 
   17470                 :          0 :   Body* new_body = NULL;
   17471 [ #  # ][ #  # ]:          0 :   new_body = GeometryQueryTool::instance()->make_Body( new_smbody );
   17472         [ #  # ]:          0 :   if( new_body )
   17473                 :            :   {
   17474 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   17475         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);
   17476                 :            : 
   17477                 :          0 :     return CUBIT_SUCCESS;
   17478                 :            :   }
   17479                 :            :   else
   17480                 :            :   {
   17481 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   17482         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17483                 :            : 
   17484                 :          0 :     return CUBIT_FAILURE;
   17485         [ #  # ]:          0 :   }
   17486                 :            : }
   17487                 :            : 
   17488                 :          0 : CubitStatus GeometryModifyTool::create_offset_surface( RefFace* ref_face_ptr, double offset_distance )
   17489                 :            : {
   17490                 :          0 :   TopologyBridge *bridge_ptr = NULL;
   17491         [ #  # ]:          0 :   GeometryModifyEngine* GMEPtr = get_engine(ref_face_ptr, &bridge_ptr );
   17492                 :            : 
   17493                 :          0 :   Surface *tmp_surf = NULL;
   17494         [ #  # ]:          0 :   tmp_surf = CAST_TO( bridge_ptr, Surface );
   17495                 :            : 
   17496                 :            :   BodySM *new_smbody;
   17497 [ #  # ][ #  # ]:          0 :   if( !GMEPtr->create_offset_surface( tmp_surf, new_smbody, offset_distance ) )
   17498                 :          0 :     return CUBIT_FAILURE;
   17499                 :            : 
   17500 [ #  # ][ #  # ]:          0 :   if (CubitUndo::get_undo_enabled())
   17501         [ #  # ]:          0 :     CubitUndo::save_state();
   17502                 :            : 
   17503                 :          0 :   Body* new_body = NULL;
   17504 [ #  # ][ #  # ]:          0 :   new_body = GeometryQueryTool::instance()->make_Body( new_smbody );
   17505         [ #  # ]:          0 :   if( new_body )
   17506                 :            :   {
   17507 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   17508         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);
   17509                 :            : 
   17510                 :          0 :     return CUBIT_SUCCESS;
   17511                 :            :   }
   17512                 :            :   else
   17513                 :            :   {
   17514 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   17515         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17516                 :            : 
   17517                 :          0 :     return CUBIT_FAILURE;
   17518                 :            :   }
   17519                 :            : }
   17520                 :            : 
   17521                 :            : //-----------------------------------------------------------------------------
   17522                 :            : // Purpose       : This function creates a sheet body or bodies by offsetting
   17523                 :            : //                 the given faces. An optional additional face list and double
   17524                 :            : //                 list (must be same length) allow different offset distances
   17525                 :            : //                 for different faces. Adjoining faces are extended or trimmed
   17526                 :            : //                 to remain joined in the new sheet body.  Radial faces that
   17527                 :            : //                 cannot be so offset are removed and the resulting wound
   17528                 :            : //                 healed by the surrounding faces.
   17529                 :            : //
   17530                 :            : // Special Notes :
   17531                 :            : //
   17532                 :            : // Creator       : Steve Storm
   17533                 :            : //
   17534                 :            : // Creation Date : 05/04/08
   17535                 :            : //-----------------------------------------------------------------------------
   17536                 :            : CubitStatus
   17537                 :          0 : GeometryModifyTool::create_offset_sheet( DLIList<RefFace*> &ref_face_list,
   17538                 :            :                                          double offset_distance,
   17539                 :            :                                          DLIList<RefFace*> *add_ref_face_list_ptr,
   17540                 :            :                                          DLIList<double> *add_offset_list_ptr,
   17541                 :            :                                          DLIList<Body*> &new_body_list,
   17542                 :            :                                          CubitBoolean preview )
   17543                 :            : {
   17544 [ #  # ][ #  # ]:          0 :   if( !ref_face_list.size() )
   17545                 :            :   {
   17546                 :          0 :     return CUBIT_SUCCESS;
   17547                 :            :   }
   17548                 :            :   else
   17549                 :            :   {
   17550 [ #  # ][ #  # ]:          0 :     for (int i = 0; i < ref_face_list.size(); i++)
   17551                 :            :     {
   17552         [ #  # ]:          0 :       RefFace *temp = ref_face_list.get_and_step();
   17553 [ #  # ][ #  # ]:          0 :       if (temp->get_surface_ptr()->is_cylindrical() == 16)
                 [ #  # ]
   17554                 :            :       {
   17555         [ #  # ]:          0 :         DLIList<Curve*> curves;
   17556         [ #  # ]:          0 :         CubitVector loc;
   17557                 :            :         double rad;
   17558 [ #  # ][ #  # ]:          0 :         temp->get_surface_ptr()->curves(curves);
   17559         [ #  # ]:          0 :         curves.reset();
   17560                 :          0 :         int j = 0;
   17561 [ #  # ][ #  # ]:          0 :         while (curves.get()->geometry_type() != ELLIPSE_CURVE_TYPE && curves.get()->geometry_type() != ARC_CURVE_TYPE)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   17562                 :            :         {
   17563         [ #  # ]:          0 :           curves.step();
   17564 [ #  # ][ #  # ]:          0 :           if (j == curves.size())
   17565                 :            :           {
   17566                 :          0 :               break;
   17567                 :            :           }
   17568                 :          0 :           j++;
   17569                 :            :         }
   17570 [ #  # ][ #  # ]:          0 :         curves.get()->get_center_radius(loc, rad);
   17571         [ #  # ]:          0 :         if (offset_distance >= rad)
   17572                 :            :         {
   17573 [ #  # ][ #  # ]:          0 :           CubitVector norm, close, result;
                 [ #  # ]
   17574                 :            :           double angle;
   17575 [ #  # ][ #  # ]:          0 :           temp->get_surface_ptr()->closest_point(loc, &close, &norm);
   17576 [ #  # ][ #  # ]:          0 :           result.set(loc.x()-close.x(), loc.y()-close.y(), loc.z()-close.z());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   17577         [ #  # ]:          0 :           angle = result.interior_angle(norm);
   17578 [ #  # ][ #  # ]:          0 :           if (angle < GEOMETRY_RESABS && angle > -GEOMETRY_RESABS)
   17579                 :            :           {
   17580 [ #  # ][ #  # ]:          0 :             PRINT_ERROR("Offset is greater than the radius of curvature for surface %i.\n", temp->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   17581 [ #  # ][ #  # ]:          0 :             PRINT_WARNING("No body will be created for surface %i.\n", temp->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   17582 [ #  # ][ #  # ]:          0 :             if (ref_face_list.size() > 1)
   17583                 :            :             {
   17584         [ #  # ]:          0 :               ref_face_list.remove_all_with_value(temp);
   17585                 :            :             }
   17586                 :            :             else
   17587                 :            :             {
   17588 [ #  # ][ #  # ]:          0 :               return CUBIT_FAILURE;
   17589                 :            :             }
   17590                 :            :           }
   17591                 :          0 :         }
   17592                 :            :       }
   17593                 :            :     }
   17594 [ #  # ][ #  # ]:          0 :     for (int i = 0; i < add_ref_face_list_ptr->size(); i++)
   17595                 :            :     {
   17596         [ #  # ]:          0 :       RefFace *temp = ref_face_list.get_and_step();
   17597 [ #  # ][ #  # ]:          0 :       if (temp->get_surface_ptr()->is_cylindrical() == 16)
                 [ #  # ]
   17598                 :            :       {
   17599         [ #  # ]:          0 :         DLIList<Curve*> curves;
   17600         [ #  # ]:          0 :         CubitVector loc;
   17601                 :            :         double rad;
   17602 [ #  # ][ #  # ]:          0 :         temp->get_surface_ptr()->curves(curves);
   17603         [ #  # ]:          0 :         curves.reset();
   17604 [ #  # ][ #  # ]:          0 :         while (curves.get()->geometry_type() != ELLIPSE_CURVE_TYPE && curves.get()->geometry_type() != ARC_CURVE_TYPE)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   17605                 :            :         {
   17606         [ #  # ]:          0 :           curves.step();
   17607                 :            :         }
   17608 [ #  # ][ #  # ]:          0 :         curves.get()->get_center_radius(loc, rad);
   17609         [ #  # ]:          0 :         if (offset_distance >= rad)
   17610                 :            :         {
   17611 [ #  # ][ #  # ]:          0 :           CubitVector norm, close, result;
                 [ #  # ]
   17612                 :            :           double angle;
   17613 [ #  # ][ #  # ]:          0 :           temp->get_surface_ptr()->closest_point(loc, &close, &norm);
   17614 [ #  # ][ #  # ]:          0 :           result.set(loc.x()-close.x(), loc.y()-close.y(), loc.z()-close.z());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   17615         [ #  # ]:          0 :           angle = result.interior_angle(norm);
   17616 [ #  # ][ #  # ]:          0 :           if (angle < GEOMETRY_RESABS && angle > -GEOMETRY_RESABS)
   17617                 :            :           {
   17618 [ #  # ][ #  # ]:          0 :             PRINT_ERROR("Offset is greater than the radius of curvature for surface %i.\n", temp->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   17619 [ #  # ][ #  # ]:          0 :             PRINT_WARNING("No body will be created for surface %i.\n", temp->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   17620         [ #  # ]:          0 :             add_ref_face_list_ptr->remove_all_with_value(temp);
   17621                 :            :           }
   17622         [ #  # ]:          0 :         }
   17623                 :            :       }
   17624                 :            :     }
   17625                 :            :   }
   17626                 :            : 
   17627 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> all_ref_face_list(ref_face_list.size());
   17628         [ #  # ]:          0 :   all_ref_face_list = ref_face_list;
   17629 [ #  # ][ #  # ]:          0 :   if( add_ref_face_list_ptr->size() )
   17630         [ #  # ]:          0 :     all_ref_face_list += *add_ref_face_list_ptr;
   17631                 :            : 
   17632                 :            :   // Check for virtual geometry
   17633 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> ref_ent_list;
   17634 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(all_ref_face_list, ref_ent_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   17635 [ #  # ][ #  # ]:          0 :   if ( GeometryQueryTool::instance()->contains_intermediate_geometry(ref_ent_list) )
                 [ #  # ]
   17636                 :            :   {
   17637 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("OFFSETTING surfaces containing virtual geometry is not\n"
                 [ #  # ]
   17638                 :            :       "       allowed. Delete virtual geometry on these surfaces\n"
   17639         [ #  # ]:          0 :       "       before operation.\n" );
   17640                 :          0 :     return CUBIT_FAILURE;
   17641                 :            :   }
   17642                 :            : 
   17643                 :            :   // Look for a common GeometryModifyEngine for all of the RefFaces
   17644         [ #  # ]:          0 :   int count = all_ref_face_list.size();
   17645 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(count);
   17646 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(count);
   17647 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( all_ref_face_list, entity_list );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   17648                 :            : 
   17649                 :            :   GeometryModifyEngine* GME_ptr =
   17650         [ #  # ]:          0 :     common_modify_engine( entity_list, bridge_list );
   17651         [ #  # ]:          0 :   if(! GME_ptr )
   17652                 :            :   {
   17653 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Cannot construct offset sheet(s) using surfaces that\n"
                 [ #  # ]
   17654         [ #  # ]:          0 :                  "       do not share a common geometry engine.\n");
   17655                 :          0 :      return CUBIT_FAILURE;
   17656                 :            :   }
   17657                 :            : 
   17658                 :            :   // Get Surfaces from the RefFaces
   17659 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list(ref_face_list.size());
                 [ #  # ]
   17660                 :            :   int i;
   17661                 :            :   RefFace *ref_face_ptr;
   17662 [ #  # ][ #  # ]:          0 :   for( i=ref_face_list.size(); i--; )
   17663                 :            :   {
   17664         [ #  # ]:          0 :     ref_face_ptr = ref_face_list.get_and_step();
   17665 [ #  # ][ #  # ]:          0 :     surface_list.append( ref_face_ptr->get_surface_ptr() );
   17666                 :            :   }
   17667                 :            : 
   17668 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> add_surf_list;
   17669 [ #  # ][ #  # ]:          0 :   if( add_ref_face_list_ptr->size() )
   17670                 :            :   {
   17671 [ #  # ][ #  # ]:          0 :     for( i=add_ref_face_list_ptr->size(); i--; )
   17672                 :            :     {
   17673         [ #  # ]:          0 :       ref_face_ptr = add_ref_face_list_ptr->get_and_step();
   17674 [ #  # ][ #  # ]:          0 :       add_surf_list.append( ref_face_ptr->get_surface_ptr() );
   17675                 :            :     }
   17676                 :            :   }
   17677                 :            :   
   17678 [ #  # ][ #  # ]:          0 :   if (CubitUndo::get_undo_enabled() && !preview )
         [ #  # ][ #  # ]
   17679         [ #  # ]:          0 :     CubitUndo::save_state();
   17680                 :            : 
   17681                 :            :   CubitStatus status;
   17682 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> BodySM_list;
   17683 [ #  # ][ #  # ]:          0 :   if( add_surf_list.size() )
   17684                 :            :   {
   17685                 :            :     status = GME_ptr->create_offset_sheet( surface_list, offset_distance, &add_surf_list,
   17686         [ #  # ]:          0 :       add_offset_list_ptr, BodySM_list, preview );      
   17687                 :            :   }
   17688                 :            :   else
   17689                 :            :   {
   17690                 :            :     status = GME_ptr->create_offset_sheet( surface_list, offset_distance, NULL,
   17691         [ #  # ]:          0 :       NULL, BodySM_list, preview );      
   17692                 :            :   }
   17693                 :            : 
   17694 [ #  # ][ #  # ]:          0 :   if( status == CUBIT_FAILURE || !BodySM_list.size() )
         [ #  # ][ #  # ]
   17695                 :            :   {
   17696 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled() && !preview )
         [ #  # ][ #  # ]
   17697         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17698                 :          0 :     return CUBIT_FAILURE;
   17699                 :            :   }
   17700                 :            : 
   17701                 :            :   BodySM *bodysm_ptr;
   17702                 :            :   Body* body_ptr;
   17703 [ #  # ][ #  # ]:          0 :   for( i=BodySM_list.size(); i--; )
   17704                 :            :   {
   17705         [ #  # ]:          0 :     DLIList<Surface*> surfs;
   17706         [ #  # ]:          0 :     bodysm_ptr = BodySM_list.get_and_step();
   17707         [ #  # ]:          0 :     bodysm_ptr->surfaces(surfs);
   17708 [ #  # ][ #  # ]:          0 :     if (!surfs.size())
   17709                 :            :     {
   17710 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("Empty body created.  Body deleted.\n");
         [ #  # ][ #  # ]
   17711 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("Empty body likely due to an offset larger than the radius of curvature of a surface.\n");
         [ #  # ][ #  # ]
   17712 [ #  # ][ #  # ]:          0 :       bodysm_ptr->get_geometry_query_engine()->delete_solid_model_entities(bodysm_ptr);
   17713                 :          0 :       break;
   17714                 :            :     }
   17715                 :            : 
   17716 [ #  # ][ #  # ]:          0 :     body_ptr = GeometryQueryTool::instance()->make_Body( bodysm_ptr );
   17717         [ #  # ]:          0 :     if( body_ptr )
   17718 [ #  # ][ #  # ]:          0 :       new_body_list.append( body_ptr );
                 [ #  # ]
   17719                 :          0 :   }
   17720                 :            : 
   17721 [ #  # ][ #  # ]:          0 :   if( new_body_list.size() )
   17722                 :            :   {
   17723 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled() && !preview )
         [ #  # ][ #  # ]
   17724         [ #  # ]:          0 :       CubitUndo::note_result_bodies(new_body_list);
   17725                 :          0 :     return CUBIT_SUCCESS;
   17726                 :            :   }
   17727                 :            :   else
   17728                 :            :   {
   17729 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled() && !preview )
         [ #  # ][ #  # ]
   17730         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17731                 :          0 :     return CUBIT_FAILURE;
   17732         [ #  # ]:          0 :   }
   17733                 :            : }
   17734                 :            : 
   17735                 :            : CubitStatus
   17736                 :          0 : GeometryModifyTool::create_offset_body( Body *body_ptr, Body *&new_body,
   17737                 :            :                                         double offset_distance )
   17738                 :            : {
   17739         [ #  # ]:          0 :   GeometryModifyEngine* GMEPtr = get_engine(body_ptr);
   17740                 :            : 
   17741         [ #  # ]:          0 :   BodySM *body_sm = body_ptr->get_body_sm_ptr();
   17742         [ #  # ]:          0 :   if (!body_sm)
   17743                 :            :   {
   17744 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Body %d is invalid -- no attached BodySM.\n", body_ptr->id());
         [ #  # ][ #  # ]
                 [ #  # ]
   17745                 :          0 :     return CUBIT_FAILURE;
   17746                 :            :   }
   17747                 :            : 
   17748                 :            :   BodySM *new_body_sm;
   17749 [ #  # ][ #  # ]:          0 :   if( !GMEPtr->create_offset_body( body_sm, new_body_sm, offset_distance ) )
   17750                 :          0 :     return CUBIT_FAILURE;
   17751                 :            : 
   17752 [ #  # ][ #  # ]:          0 :   if (CubitUndo::get_undo_enabled())
   17753         [ #  # ]:          0 :     CubitUndo::save_state();
   17754                 :            : 
   17755 [ #  # ][ #  # ]:          0 :   new_body = GeometryQueryTool::instance()->make_Body( new_body_sm );
   17756                 :            : 
   17757         [ #  # ]:          0 :   if( new_body )
   17758                 :            :   {
   17759 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   17760         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);
   17761                 :            : 
   17762                 :          0 :     return CUBIT_SUCCESS;
   17763                 :            :   }
   17764                 :            :   else
   17765                 :            :   {
   17766 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   17767         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17768                 :            : 
   17769                 :          0 :     return CUBIT_FAILURE;
   17770                 :            :   }
   17771                 :            : }
   17772                 :            : 
   17773                 :         11 : CubitStatus GeometryModifyTool::create_skin_surface( DLIList<RefEdge*>& ref_edges, Body*& new_body,
   17774                 :            :                                                      DLIList<RefEdge*>& guides)
   17775                 :            : {
   17776         [ +  - ]:         11 :   DLIList<TopologyBridge*> bridge_list;
   17777 [ +  - ][ +  - ]:         22 :   DLIList<TopologyEntity*> entity_list;
   17778 [ +  - ][ +  - ]:         33 :   CAST_LIST_TO_PARENT( ref_edges, entity_list );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
   17779                 :            : 
   17780 [ +  - ][ +  - ]:         22 :   DLIList<TopologyBridge*> guide_bridge_list;
   17781 [ +  - ][ +  - ]:         22 :   DLIList<TopologyEntity*> guide_entity_list;
   17782 [ +  - ][ +  - ]:         11 :   CAST_LIST_TO_PARENT(guides, guide_entity_list);
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
         [ #  # ][ -  + ]
   17783                 :            : 
   17784 [ +  - ][ -  + ]:         11 :   if (ref_edges.size() < 2)
   17785                 :            :   {
   17786 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Must specify at least 2 curves to create a skinned surface.\n");
         [ #  # ][ #  # ]
   17787                 :          0 :      return CUBIT_FAILURE;
   17788                 :            :   }
   17789                 :            : 
   17790                 :            :   GeometryModifyEngine* GME_ptr =
   17791         [ +  - ]:         11 :     common_modify_engine( entity_list, bridge_list );
   17792         [ -  + ]:         11 :   if(! GME_ptr )
   17793                 :            :   {
   17794 [ #  # ][ #  # ]:          0 :      PRINT_ERROR("Cannot construct a Surface using entities that do "
                 [ #  # ]
   17795         [ #  # ]:          0 :                  "not share a common GeometryModifyEngine.\n");
   17796                 :          0 :      return CUBIT_FAILURE;
   17797                 :            :   }
   17798                 :            : 
   17799 [ +  - ][ -  + ]:         11 :   if (guides.size() > 0)
   17800                 :            :   {
   17801                 :            :       GeometryModifyEngine* GME_ptr2 =
   17802         [ #  # ]:          0 :           common_modify_engine( guide_entity_list, guide_bridge_list );
   17803         [ #  # ]:          0 :       if (GME_ptr != GME_ptr2)
   17804                 :            :       {
   17805 [ #  # ][ #  # ]:          0 :           PRINT_ERROR("Performing create skin with geometry from\n"
                 [ #  # ]
   17806         [ #  # ]:          0 :                         "different modeling engines is not allowed.\n");
   17807                 :          0 :                   return CUBIT_FAILURE;
   17808                 :            :       }
   17809                 :            :   }
   17810                 :            : 
   17811 [ +  - ][ +  - ]:         22 :   DLIList<Curve*> curves_to_skin(bridge_list.size());
                 [ +  - ]
   17812 [ +  - ][ +  - ]:         33 :   CAST_LIST( bridge_list, curves_to_skin, Curve );
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
                 [ +  + ]
   17813                 :            : 
   17814 [ +  - ][ +  - ]:         22 :   DLIList<Curve*> guide_curves(guide_bridge_list.size());
                 [ +  - ]
   17815 [ +  - ][ +  - ]:         11 :   CAST_LIST(guide_bridge_list, guide_curves, Curve);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ -  + ]
   17816                 :            : 
   17817                 :         11 :   BodySM *new_body_sm = NULL;
   17818 [ +  - ][ -  + ]:         11 :   if( !GME_ptr->create_skin_surface( curves_to_skin, new_body_sm, guide_curves ) )
   17819                 :          0 :     return CUBIT_FAILURE;
   17820                 :            : 
   17821 [ +  - ][ -  + ]:         11 :   if (CubitUndo::get_undo_enabled())
   17822         [ #  # ]:          0 :     CubitUndo::save_state();
   17823                 :            : 
   17824                 :         11 :   new_body = NULL;
   17825 [ +  - ][ +  - ]:         11 :   new_body = GeometryQueryTool::instance()->make_Body( new_body_sm );
   17826                 :            : 
   17827         [ +  - ]:         11 :   if( new_body )
   17828                 :            :   {
   17829 [ +  - ][ -  + ]:         11 :     if (CubitUndo::get_undo_enabled())
   17830         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);
   17831                 :            : 
   17832                 :         11 :     return CUBIT_SUCCESS;
   17833                 :            :   }
   17834                 :            :   else
   17835                 :            :   {
   17836 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   17837         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   17838                 :            : 
   17839                 :          0 :     return CUBIT_FAILURE;
   17840         [ +  - ]:         11 :   }
   17841                 :            : }
   17842                 :         11 : CubitStatus GeometryModifyTool::loft_surfaces_to_body(DLIList<RefFace*> &surfaces,
   17843                 :            :                                                       DLIList<double> &takeoff_factor_list,
   17844                 :            :                                                       DLIList<RefFace*> &takeoff_vector_surface_list,
   17845                 :            :                                                       DLIList<CubitVector> &surface_takeoff_vector_list,
   17846                 :            :                                                       DLIList<RefEdge*> &takeoff_vector_curve_list,
   17847                 :            :                                                       DLIList<CubitVector> &curve_takeoff_vector_list,
   17848                 :            :                                                       DLIList<RefEdge*> &guides,
   17849                 :            :                                                       DLIList<RefVertex*> &match_vertices_list,
   17850                 :            :                                                       Body*& new_body,
   17851                 :            :                                                       CubitBoolean global_guides,
   17852                 :            :                                                       CubitBoolean closed,
   17853                 :            :                                                       CubitBoolean show_matching_curves,
   17854                 :            :                                                       CubitBoolean preview
   17855                 :            :                                                       )
   17856                 :            : {
   17857         [ +  - ]:         11 :     DLIList<Surface*> loft_surfaces;
   17858                 :            : 
   17859                 :            :     // Get engine and correspoding geom entities
   17860                 :            :     GeometryModifyEngine* result_ptr;
   17861         [ +  - ]:         11 :     result_ptr = common_modify_engine( surfaces, loft_surfaces );
   17862         [ -  + ]:         11 :     if (!result_ptr)
   17863                 :            :     {
   17864 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Loft surfaces on volumes containing surfaces from different\n"
                 [ #  # ]
   17865         [ #  # ]:          0 :             "       geometry engines is not allowed.\n");
   17866                 :          0 :         return CUBIT_FAILURE;
   17867                 :            :     }
   17868                 :            : 
   17869                 :            : 
   17870 [ +  - ][ +  - ]:         22 :     DLIList<Curve*> loft_guide_curves;
   17871                 :            :     // Get engine and correspoding geom entities
   17872 [ +  - ][ -  + ]:         11 :     if(guides.size())
   17873                 :            :     {
   17874         [ #  # ]:          0 :       result_ptr = common_modify_engine( guides, loft_guide_curves );
   17875         [ #  # ]:          0 :       if (!result_ptr)
   17876                 :            :       {
   17877 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Loft guide curves containing curves from different\n"
                 [ #  # ]
   17878         [ #  # ]:          0 :           "       geometry engines is not allowed.\n");
   17879                 :          0 :         return CUBIT_FAILURE;
   17880                 :            :       }
   17881                 :            :     }
   17882                 :            : 
   17883                 :            : 
   17884                 :            : 
   17885 [ +  - ][ +  - ]:         22 :     DLIList<TBPoint*> loft_matched_points;
   17886                 :            :     // Get engine and correspoding geom entities
   17887 [ +  - ][ -  + ]:         11 :     if(match_vertices_list.size())
   17888                 :            :     {
   17889         [ #  # ]:          0 :       result_ptr = common_modify_engine( match_vertices_list, loft_matched_points );
   17890         [ #  # ]:          0 :       if (!result_ptr)
   17891                 :            :       {
   17892 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Loft matched vertices containing points from different\n"
                 [ #  # ]
   17893         [ #  # ]:          0 :           "       geometry engines is not allowed.\n");
   17894                 :          0 :         return CUBIT_FAILURE;
   17895                 :            :       }
   17896                 :            :     }
   17897                 :            : 
   17898 [ +  - ][ +  - ]:         22 :     DLIList<Surface*> loft_takeoff_surfaces;
   17899                 :            : 
   17900 [ +  - ][ -  + ]:         11 :     if(takeoff_vector_surface_list.size())
   17901                 :            :     {
   17902                 :            :       // Get engine and correspoding geom entities
   17903                 :            :       GeometryModifyEngine* result_ptr;
   17904         [ #  # ]:          0 :       result_ptr = common_modify_engine( takeoff_vector_surface_list, loft_takeoff_surfaces );
   17905         [ #  # ]:          0 :       if (!result_ptr)
   17906                 :            :       {
   17907 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Loft takeoff surfaces on volumes containing surfaces from different\n"
                 [ #  # ]
   17908         [ #  # ]:          0 :           "       geometry engines is not allowed.\n");
   17909                 :          0 :         return CUBIT_FAILURE;
   17910                 :            :       }
   17911                 :            :     }
   17912                 :            : 
   17913 [ +  - ][ +  - ]:         22 :     DLIList<Curve*> loft_takeoff_curves;
   17914                 :            : 
   17915 [ +  - ][ -  + ]:         11 :     if(takeoff_vector_curve_list.size())
   17916                 :            :     {
   17917                 :            :       // Get engine and correspoding geom entities
   17918                 :            :       GeometryModifyEngine* result_ptr;
   17919         [ #  # ]:          0 :       result_ptr = common_modify_engine( takeoff_vector_curve_list, loft_takeoff_curves );
   17920         [ #  # ]:          0 :       if (!result_ptr)
   17921                 :            :       {
   17922 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Loft takeoff surfaces on volumes containing surfaces from different\n"
                 [ #  # ]
   17923         [ #  # ]:          0 :           "       geometry engines is not allowed.\n");
   17924                 :          0 :         return CUBIT_FAILURE;
   17925                 :            :       }
   17926                 :            :     }
   17927                 :            : 
   17928                 :            : 
   17929                 :         11 :     BodySM* new_body_sm = 0;
   17930                 :            : 
   17931 [ +  - ][ -  + ]:         11 :     if( CubitUndo::get_undo_enabled() )
   17932         [ #  # ]:          0 :       CubitUndo::save_state();
   17933                 :            : 
   17934                 :            :     CubitStatus result = result_ptr->loft_surfaces_to_body(
   17935                 :            :         loft_surfaces,
   17936                 :            :         takeoff_factor_list,
   17937                 :            :         loft_takeoff_surfaces,
   17938                 :            :         surface_takeoff_vector_list,
   17939                 :            :         loft_takeoff_curves,
   17940                 :            :         curve_takeoff_vector_list,
   17941                 :            :         loft_guide_curves,
   17942                 :            :         loft_matched_points,
   17943                 :            :         new_body_sm,
   17944                 :            :         global_guides,
   17945                 :            :         closed,
   17946                 :            :         show_matching_curves,
   17947         [ +  - ]:         11 :         preview);
   17948                 :            : 
   17949 [ +  - ][ +  - ]:         11 :     if(result && new_body_sm)
   17950                 :            :     {
   17951 [ +  - ][ +  - ]:         11 :         new_body = GeometryQueryTool::instance()->make_Body(new_body_sm);
   17952                 :            : 
   17953 [ +  - ][ -  + ]:         11 :         if( CubitUndo::get_undo_enabled() )
   17954         [ #  # ]:          0 :           CubitUndo::note_result_body(new_body);
   17955                 :            :     }
   17956                 :            :     else
   17957                 :            :     {
   17958 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   17959         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   17960                 :            :     }
   17961         [ +  - ]:         22 :    return result;
   17962                 :            : }
   17963                 :            : 
   17964                 :            : 
   17965                 :            : //CubitStatus GeometryModifyTool::loft_surfaces_to_body( RefFace *face1, const double &takeoff1,
   17966                 :            : //                                                      RefFace *face2, const double &takeoff2,
   17967                 :            : //                                                      DLIList<RefEdge*> &guides,
   17968                 :            : //                                                      Body*& new_body,
   17969                 :            : //                                                      CubitBoolean arc_length_option, CubitBoolean twist_option,
   17970                 :            : //                                                      CubitBoolean align_direction, CubitBoolean perpendicular,
   17971                 :            : //                                                      CubitBoolean simplify_option)
   17972                 :            : //{
   17973                 :            : //
   17974                 :            : //    DLIList<RefFace*> loft_faces;
   17975                 :            : //    loft_faces.append(face1);
   17976                 :            : //    loft_faces.append(face2);
   17977                 :            : //    DLIList<Surface*> loft_surfaces;
   17978                 :            : //
   17979                 :            : //    // Get engine and correspoding geom entities
   17980                 :            : //    GeometryModifyEngine* result_ptr;
   17981                 :            : //    result_ptr = common_modify_engine( loft_faces, loft_surfaces );
   17982                 :            : //    if (!result_ptr)
   17983                 :            : //    {
   17984                 :            : //        PRINT_ERROR("Loft surfaces on volumes containing surfaces from different\n"
   17985                 :            : //            "       geometry engines is not allowed.\n");
   17986                 :            : //        return CUBIT_FAILURE;
   17987                 :            : //    }
   17988                 :            : //
   17989                 :            : //    if(2!=loft_surfaces.size())
   17990                 :            : //        return CUBIT_FAILURE;
   17991                 :            : //
   17992                 :            : //
   17993                 :            : //
   17994                 :            : //    DLIList<Curve*> loft_curves;
   17995                 :            : //
   17996                 :            : //    // Get engine and correspoding geom entities
   17997                 :            : //    result_ptr = common_modify_engine( guides, loft_curves );
   17998                 :            : //    if (!result_ptr)
   17999                 :            : //    {
   18000                 :            : //        PRINT_ERROR("Loft surfaces on volumes containing surfaces from different\n"
   18001                 :            : //            "       geometry engines is not allowed.\n");
   18002                 :            : //        return CUBIT_FAILURE;
   18003                 :            : //    }
   18004                 :            : //
   18005                 :            : //
   18006                 :            : //    std::vector<Curve*> guide_edges;
   18007                 :            : //    for(int i=0;i<loft_curves.size();i++)
   18008                 :            : //    {
   18009                 :            : //      guide_edges.push_back(loft_curves[i]);
   18010                 :            : //    }
   18011                 :            : //
   18012                 :            : //
   18013                 :            : //
   18014                 :            : //
   18015                 :            : //    loft_surfaces.reset();
   18016                 :            : //    BodySM* new_body_sm = 0;
   18017                 :            : //
   18018                 :            : //    if( CubitUndo::get_undo_enabled() )
   18019                 :            : //      CubitUndo::save_state();
   18020                 :            : //
   18021                 :            : //    CubitStatus result = result_ptr->loft_surfaces_to_body(
   18022                 :            : //        loft_surfaces.get_and_step(),
   18023                 :            : //        takeoff1,
   18024                 :            : //        loft_surfaces.get_and_step(),
   18025                 :            : //        takeoff2,
   18026                 :            : //        guide_edges,
   18027                 :            : //        new_body_sm,
   18028                 :            : //        arc_length_option,
   18029                 :            : //        twist_option,
   18030                 :            : //        align_direction,
   18031                 :            : //        perpendicular,
   18032                 :            : //        simplify_option);
   18033                 :            : //
   18034                 :            : //    if(result && new_body_sm)
   18035                 :            : //    {
   18036                 :            : //        new_body = GeometryQueryTool::instance()->make_Body(new_body_sm);
   18037                 :            : //
   18038                 :            : //        if( CubitUndo::get_undo_enabled() )
   18039                 :            : //          CubitUndo::note_result_body(new_body);
   18040                 :            : //    }
   18041                 :            : //    else
   18042                 :            : //    {
   18043                 :            : //      if( CubitUndo::get_undo_enabled() )
   18044                 :            : //        CubitUndo::remove_last_undo();
   18045                 :            : //    }
   18046                 :            : //   return result;
   18047                 :            : //}
   18048                 :            : //
   18049                 :            : //
   18050                 :            : 
   18051                 :            : //CubitStatus GeometryModifyTool::loft_surfaces_to_body( RefFace *face1, const double &takeoff1,
   18052                 :            : //                                                      RefFace *face2, const double &takeoff2,
   18053                 :            : //                                                      Body*& new_body,
   18054                 :            : //                                                      CubitBoolean arc_length_option, CubitBoolean twist_option,
   18055                 :            : //                                                      CubitBoolean align_direction, CubitBoolean perpendicular,
   18056                 :            : //                                                      CubitBoolean simplify_option)
   18057                 :            : //{
   18058                 :            : //
   18059                 :            : //    DLIList<RefFace*> loft_faces;
   18060                 :            : //    loft_faces.append(face1);
   18061                 :            : //    loft_faces.append(face2);
   18062                 :            : //    DLIList<Surface*> loft_surfaces;
   18063                 :            : //
   18064                 :            : //    // Get engine and correspoding geom entities
   18065                 :            : //    GeometryModifyEngine* result_ptr;
   18066                 :            : //    result_ptr = common_modify_engine( loft_faces, loft_surfaces );
   18067                 :            : //    if (!result_ptr)
   18068                 :            : //    {
   18069                 :            : //        PRINT_ERROR("Loft surfaces on volumes containing surfaces from different\n"
   18070                 :            : //            "       geometry engines is not allowed.\n");
   18071                 :            : //        return CUBIT_FAILURE;
   18072                 :            : //    }
   18073                 :            : //
   18074                 :            : //    if(2!=loft_surfaces.size())
   18075                 :            : //        return CUBIT_FAILURE;
   18076                 :            : //
   18077                 :            : //    loft_surfaces.reset();
   18078                 :            : //    BodySM* new_body_sm = 0;
   18079                 :            : //
   18080                 :            : //    if( CubitUndo::get_undo_enabled() )
   18081                 :            : //      CubitUndo::save_state();
   18082                 :            : //
   18083                 :            : //
   18084                 :            : //  CubitStatus result = result_ptr->loft_surfaces_to_body(
   18085                 :            : //        loft_surfaces[0],
   18086                 :            : //        takeoff1,
   18087                 :            : //        loft_surfaces[1],
   18088                 :            : //        takeoff2,
   18089                 :            : //        new_body_sm,
   18090                 :            : //        arc_length_option,
   18091                 :            : //        twist_option,
   18092                 :            : //        align_direction,
   18093                 :            : //        perpendicular,
   18094                 :            : //        simplify_option);
   18095                 :            : //
   18096                 :            : //
   18097                 :            : //
   18098                 :            : //    if(result && new_body_sm)
   18099                 :            : //    {
   18100                 :            : //        new_body = GeometryQueryTool::instance()->make_Body(new_body_sm);
   18101                 :            : //
   18102                 :            : //        if( CubitUndo::get_undo_enabled() )
   18103                 :            : //          CubitUndo::note_result_body(new_body);
   18104                 :            : //    }
   18105                 :            : //    else
   18106                 :            : //    {
   18107                 :            : //      if( CubitUndo::get_undo_enabled() )
   18108                 :            : //        CubitUndo::remove_last_undo();
   18109                 :            : //    }
   18110                 :            : //   return result;
   18111                 :            : //}
   18112                 :            : 
   18113                 :          0 : CubitStatus GeometryModifyTool::create_surface( DLIList<RefVertex*> &vert_list,
   18114                 :            :                                                 Body *&new_body, RefFace *on_surface )
   18115                 :            : {
   18116                 :            :    //determine which vertices are free and which are not...
   18117                 :            :    //copy ones that are not
   18118         [ #  # ]:          0 :    vert_list.reset();
   18119         [ #  # ]:          0 :    DLIList<TBPoint*> points;
   18120 [ #  # ][ #  # ]:          0 :    GeometryModifyEngine *GMEPtr = get_engine( vert_list.get()->get_point_ptr() );
                 [ #  # ]
   18121                 :            : 
   18122 [ #  # ][ #  # ]:          0 :    DLIList<RefVertex*> free_ref_vertices;
   18123                 :            :    int i;
   18124 [ #  # ][ #  # ]:          0 :    for( i=vert_list.size(); i--; )
   18125                 :            :    {
   18126         [ #  # ]:          0 :      RefVertex *tmp_vert = vert_list.get_and_step();
   18127                 :            : 
   18128 [ #  # ][ #  # ]:          0 :      if( tmp_vert->num_parent_ref_entities() == 0 )
   18129         [ #  # ]:          0 :        free_ref_vertices.append( tmp_vert );
   18130                 :            : 
   18131         [ #  # ]:          0 :      TBPoint *tmp_point = tmp_vert->get_point_ptr();
   18132 [ #  # ][ #  # ]:          0 :      if( GMEPtr != get_engine( tmp_point ) )
   18133                 :            :      {
   18134 [ #  # ][ #  # ]:          0 :        PRINT_INFO("Vertices are not from same modeling engine.\n");
         [ #  # ][ #  # ]
   18135                 :          0 :        return CUBIT_FAILURE;
   18136                 :            :      }
   18137                 :            : 
   18138 [ #  # ][ #  # ]:          0 :      if( tmp_vert->get_parents() == 0 )
   18139                 :            :      {
   18140         [ #  # ]:          0 :        points.append( tmp_point );
   18141                 :            :      }
   18142                 :            :      else
   18143                 :            :      {
   18144 [ #  # ][ #  # ]:          0 :        TBPoint *new_point = GMEPtr->make_Point( tmp_vert->coordinates() );
   18145         [ #  # ]:          0 :        points.append( new_point );
   18146                 :            :      }
   18147                 :            :    }
   18148                 :            : 
   18149         [ #  # ]:          0 :    if( on_surface )
   18150                 :            :    {
   18151 [ #  # ][ #  # ]:          0 :      if( GMEPtr != get_engine( on_surface->get_surface_ptr() ) )
                 [ #  # ]
   18152                 :            :      {
   18153 [ #  # ][ #  # ]:          0 :        PRINT_INFO("Surface and Vertices are not from same modeling engine.\n");
         [ #  # ][ #  # ]
   18154                 :          0 :        return CUBIT_FAILURE;
   18155                 :            :      }
   18156                 :            :    }
   18157                 :            : 
   18158 [ #  # ][ #  # ]:          0 :    if(CubitUndo::get_undo_enabled())
   18159                 :            :    {
   18160 [ #  # ][ #  # ]:          0 :      if( free_ref_vertices.size() )
   18161         [ #  # ]:          0 :        CubitUndo::save_state_with_cubit_file( free_ref_vertices );
   18162                 :            :      else
   18163         [ #  # ]:          0 :        CubitUndo::save_state();
   18164                 :            :    }
   18165                 :            : 
   18166                 :            : 
   18167                 :          0 :    BodySM* body_sm = NULL;
   18168                 :          0 :    Surface *on_surf = NULL;
   18169                 :            : 
   18170         [ #  # ]:          0 :    if( on_surface )
   18171         [ #  # ]:          0 :      on_surf = on_surface->get_surface_ptr();
   18172                 :            : 
   18173         [ #  # ]:          0 :    CubitStatus stat = GMEPtr->create_surface( points, body_sm, on_surf );
   18174                 :            : 
   18175         [ #  # ]:          0 :    if( stat == CUBIT_FAILURE )
   18176                 :            :    {
   18177 [ #  # ][ #  # ]:          0 :      if (CubitUndo::get_undo_enabled())
   18178         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
   18179                 :          0 :      return stat;
   18180                 :            :    }
   18181                 :            : 
   18182         [ #  # ]:          0 :    if( body_sm )
   18183 [ #  # ][ #  # ]:          0 :      new_body = GeometryQueryTool::instance()->make_Body(body_sm);
   18184                 :            : 
   18185         [ #  # ]:          0 :    if (new_body)
   18186                 :            :    {
   18187 [ #  # ][ #  # ]:          0 :      if (CubitUndo::get_undo_enabled())
   18188         [ #  # ]:          0 :        CubitUndo::note_result_body(new_body);
   18189                 :            : 
   18190                 :          0 :      stat = CUBIT_SUCCESS;
   18191                 :            :    }
   18192                 :            :    else
   18193                 :            :    {
   18194 [ #  # ][ #  # ]:          0 :      if (CubitUndo::get_undo_enabled())
   18195         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
   18196                 :            : 
   18197                 :          0 :      stat = CUBIT_FAILURE;
   18198                 :            :    }
   18199                 :            : 
   18200 [ #  # ][ #  # ]:          0 :    for( i=free_ref_vertices.size(); i--; )
   18201                 :            :    {
   18202         [ #  # ]:          0 :      RefVertex *free_vertex = free_ref_vertices.get_and_step();
   18203 [ #  # ][ #  # ]:          0 :      AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOP_LEVEL_ENTITY_DESTRUCTED, free_vertex));
         [ #  # ][ #  # ]
                 [ #  # ]
   18204 [ #  # ][ #  # ]:          0 :      CGMHistory::Event evt(CGMHistory::TOP_LEVEL_ENTITY_DELETED, free_vertex );
   18205 [ #  # ][ #  # ]:          0 :      GeometryQueryTool::instance()->history().add_event(evt);
                 [ #  # ]
   18206         [ #  # ]:          0 :    }
   18207                 :            : 
   18208         [ #  # ]:          0 :    return stat;
   18209                 :            : }
   18210                 :            : 
   18211                 :          0 : CubitStatus GeometryModifyTool::create_surface( DLIList<CubitVector*>& vec_list,
   18212                 :            :                                                 Body *&new_body,
   18213                 :            :                                                 RefFace *ref_face_ptr,
   18214                 :            :                                                 CubitBoolean project_points )
   18215                 :            : {
   18216         [ #  # ]:          0 :    GeometryModifyEngine* GMEPtr = gmeList.get();
   18217         [ #  # ]:          0 :    if( ref_face_ptr )
   18218                 :            :    {
   18219 [ #  # ][ #  # ]:          0 :      if( GMEPtr != get_engine(ref_face_ptr) )
   18220                 :            :      {
   18221 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Geometry engine of Surface %d is not the active geometry engine.\n", ref_face_ptr->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   18222 [ #  # ][ #  # ]:          0 :        PRINT_INFO("      Use command \"Set Geometry Engine ...\" to set to correct engine.\n");
         [ #  # ][ #  # ]
   18223                 :          0 :        return CUBIT_FAILURE;
   18224                 :            :      }
   18225                 :            :    }
   18226                 :          0 :    BodySM* body_sm = NULL;
   18227                 :          0 :    Surface *project_to_surface = NULL;
   18228         [ #  # ]:          0 :    if( ref_face_ptr )
   18229         [ #  # ]:          0 :      project_to_surface = ref_face_ptr->get_surface_ptr();
   18230         [ #  # ]:          0 :    CubitStatus stat = GMEPtr->create_surface( vec_list, body_sm, project_to_surface, project_points );
   18231                 :            : 
   18232         [ #  # ]:          0 :    if( stat == CUBIT_FAILURE )
   18233                 :          0 :      return stat;
   18234                 :            : 
   18235 [ #  # ][ #  # ]:          0 :    if (CubitUndo::get_undo_enabled())
   18236         [ #  # ]:          0 :      CubitUndo::save_state();
   18237                 :            : 
   18238         [ #  # ]:          0 :    if( body_sm )
   18239 [ #  # ][ #  # ]:          0 :      new_body = GeometryQueryTool::instance()->make_Body(body_sm);
   18240                 :            : 
   18241         [ #  # ]:          0 :    if (new_body)
   18242                 :            :    {
   18243 [ #  # ][ #  # ]:          0 :      if (CubitUndo::get_undo_enabled())
   18244         [ #  # ]:          0 :        CubitUndo::note_result_body(new_body);
   18245                 :            : 
   18246                 :          0 :      stat = CUBIT_SUCCESS;
   18247                 :            :    }
   18248                 :            :    else
   18249                 :            :    {
   18250 [ #  # ][ #  # ]:          0 :      if (CubitUndo::get_undo_enabled())
   18251         [ #  # ]:          0 :        CubitUndo::remove_last_undo();
   18252                 :            : 
   18253                 :          0 :      stat = CUBIT_FAILURE;
   18254                 :            :    }
   18255                 :          0 :    return stat;
   18256                 :            : }
   18257                 :            : 
   18258                 :          0 : CubitStatus GeometryModifyTool::create_weld_surface( CubitVector &root,
   18259                 :            :                                                     RefFace *ref_face1,
   18260                 :            :                                                     double leg1,
   18261                 :            :                                                     RefFace *ref_face2,
   18262                 :            :                                                     double leg2,
   18263                 :            :                                                     Body *&new_body )
   18264                 :            : {
   18265                 :            :     GeometryModifyEngine* GMEPtr;
   18266         [ #  # ]:          0 :     DLIList<RefFace*> ref_faces;
   18267         [ #  # ]:          0 :     ref_faces.append(ref_face1);
   18268         [ #  # ]:          0 :     ref_faces.append(ref_face2);
   18269 [ #  # ][ #  # ]:          0 :     DLIList<Surface*> surfaces;
   18270                 :            : 
   18271         [ #  # ]:          0 :     GMEPtr = common_modify_engine(ref_faces, surfaces);
   18272         [ #  # ]:          0 :     if (!GMEPtr)
   18273                 :            :     {
   18274 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Loft surfaces on volumes containing surfaces from different\n"
                 [ #  # ]
   18275         [ #  # ]:          0 :             "       geometry engines is not allowed.\n");
   18276                 :          0 :         return CUBIT_FAILURE;
   18277                 :            :     }
   18278                 :            : 
   18279 [ #  # ][ #  # ]:          0 :     if (CubitUndo::get_undo_enabled())
   18280         [ #  # ]:          0 :       CubitUndo::save_state();
   18281                 :            : 
   18282         [ #  # ]:          0 :     surfaces.reset();
   18283                 :          0 :     BodySM* new_body_sm = 0;
   18284                 :            :     CubitStatus result = GMEPtr->create_weld_surface(
   18285                 :            :         root,
   18286         [ #  # ]:          0 :         surfaces.get_and_step(),
   18287                 :            :         leg1,
   18288         [ #  # ]:          0 :         surfaces.get_and_step(),
   18289                 :            :         leg2,
   18290         [ #  # ]:          0 :         new_body_sm );
   18291                 :            : 
   18292 [ #  # ][ #  # ]:          0 :     if(result && new_body_sm)
   18293                 :            :     {
   18294 [ #  # ][ #  # ]:          0 :         new_body = GeometryQueryTool::instance()->make_Body(new_body_sm);
   18295         [ #  # ]:          0 :         if (new_body)
   18296                 :            :         {
   18297 [ #  # ][ #  # ]:          0 :           if (CubitUndo::get_undo_enabled())
   18298         [ #  # ]:          0 :             CubitUndo::note_result_body(new_body);
   18299                 :            :         }
   18300                 :            :         else
   18301                 :            :         {
   18302 [ #  # ][ #  # ]:          0 :           if (CubitUndo::get_undo_enabled())
   18303         [ #  # ]:          0 :             CubitUndo::remove_last_undo();
   18304                 :            :         }
   18305                 :            :     }
   18306         [ #  # ]:          0 :     return result;
   18307                 :            : }
   18308                 :            : //end of surface tool operations ******************************************************
   18309                 :            : 
   18310                 :            : //-------------------------------------------------------------------------
   18311                 :            : // Purpose       : Remove entity names from dead entities.
   18312                 :            : //
   18313                 :            : // Special Notes :
   18314                 :            : //
   18315                 :            : // Creator       : Jason Kraftcheck
   18316                 :            : //
   18317                 :            : // Creation Date : 12/08/03
   18318                 :            : //-------------------------------------------------------------------------
   18319                 :      20233 : void GeometryModifyTool::remove_dead_entity_names( RefEntity* entity ) const
   18320                 :            : {
   18321         [ -  + ]:      20233 :   TopologyEntity* topo_ent = dynamic_cast<TopologyEntity*>(entity);
   18322 [ +  - ][ +  - ]:      20233 :   if (topo_ent->bridge_manager()->topology_bridge() == NULL)
                 [ +  + ]
   18323 [ +  - ][ +  - ]:       2101 :     RefEntityName::instance()->remove_refentity_name( entity, CUBIT_TRUE );
   18324                 :            : 
   18325         [ +  - ]:      20233 :   DLIList<RefEntity*> children;
   18326         [ +  - ]:      20233 :   entity->get_child_ref_entities(children);
   18327         [ +  - ]:      20233 :   children.last();
   18328 [ +  - ][ +  + ]:      40221 :   for (int i = children.size(); i--; )
   18329                 :            :   {
   18330                 :            :     //PRINT_INFO("Removing dead entity on %s %d\n", children.get()->class_name(), children.get()->id() );
   18331 [ +  - ][ +  - ]:      19988 :     remove_dead_entity_names( children.step_and_get() );
   18332         [ +  - ]:      20233 :   }
   18333                 :      20233 : }
   18334                 :            : 
   18335                 :            : //-------------------------------------------------------------------------
   18336                 :            : // Purpose       : Destroy or update modified body, as appropriate.
   18337                 :            : //
   18338                 :            : // Special Notes :
   18339                 :            : //
   18340                 :            : // Creator       : Jason Kraftcheck
   18341                 :            : //
   18342                 :            : // Creation Date : 12/08/03
   18343                 :            : //-------------------------------------------------------------------------
   18344                 :          0 : Body* GeometryModifyTool::update_body( Body* body ) const
   18345                 :            : {
   18346                 :          0 :   BodySM* body_sm = body->get_body_sm_ptr();
   18347         [ #  # ]:          0 :   if (body_sm)
   18348                 :          0 :     return GeometryQueryTool::instance()->make_Body(body_sm);
   18349                 :            : 
   18350                 :          0 :   GeometryQueryTool::instance()->destroy_dead_entity(body);
   18351                 :          0 :   return 0;
   18352                 :            : }
   18353                 :            : 
   18354                 :          0 : CubitStatus GeometryModifyTool::tolerant_imprint( DLIList<RefFace*> &ref_faces,
   18355                 :            :                                                   DLIList<RefEdge*> &ref_edge_list,
   18356                 :            :                                                   DLIList<Body*> &new_bodies,
   18357                 :            :                                                   bool merge )
   18358                 :            : {
   18359 [ #  # ][ #  # ]:          0 :   if( ref_faces.size() > 2 )
   18360                 :          0 :     return CUBIT_FAILURE;
   18361                 :            : 
   18362         [ #  # ]:          0 :   ref_faces.reset();
   18363         [ #  # ]:          0 :   RefFace *face1 = ref_faces.get_and_step();
   18364         [ #  # ]:          0 :   RefFace *face2 = ref_faces.get_and_step();
   18365                 :            : 
   18366 [ #  # ][ #  # ]:          0 :   if(ref_edge_list.size() > 0)
   18367                 :            :   {
   18368                 :            :     //collect all the bodies containing any edge on these 2 surfaces
   18369                 :            :     //so you can merge them afterward
   18370         [ #  # ]:          0 :     DLIList<Body*> bodies_to_merge;
   18371         [ #  # ]:          0 :     if( merge )
   18372                 :            :     {
   18373         [ #  # ]:          0 :       DLIList<RefEdge*> tmp_edges;
   18374         [ #  # ]:          0 :       face1->ref_edges( tmp_edges);
   18375                 :            : 
   18376                 :            :       int j;
   18377 [ #  # ][ #  # ]:          0 :       for( j=tmp_edges.size(); j--; )
   18378                 :            :       {
   18379         [ #  # ]:          0 :         RefEdge *tmp_edge = tmp_edges.get_and_step();
   18380         [ #  # ]:          0 :         DLIList<Body*> body_list;
   18381         [ #  # ]:          0 :         tmp_edge->bodies( body_list );
   18382         [ #  # ]:          0 :         bodies_to_merge += body_list;
   18383         [ #  # ]:          0 :       }
   18384                 :            : 
   18385 [ #  # ][ #  # ]:          0 :       for( j=ref_edge_list.size(); j--; )
   18386                 :            :       {
   18387         [ #  # ]:          0 :         RefEdge *tmp_edge = ref_edge_list.get_and_step();
   18388         [ #  # ]:          0 :         DLIList<Body*> body_list;
   18389         [ #  # ]:          0 :         tmp_edge->bodies( body_list );
   18390         [ #  # ]:          0 :         bodies_to_merge += body_list;
   18391         [ #  # ]:          0 :       }
   18392                 :            : 
   18393         [ #  # ]:          0 :       tmp_edges.clean_out();
   18394         [ #  # ]:          0 :       face2->ref_edges( tmp_edges );
   18395                 :            : 
   18396 [ #  # ][ #  # ]:          0 :       for( j=tmp_edges.size(); j--; )
   18397                 :            :       {
   18398         [ #  # ]:          0 :         RefEdge *tmp_edge = tmp_edges.get_and_step();
   18399         [ #  # ]:          0 :         DLIList<Body*> body_list;
   18400         [ #  # ]:          0 :         tmp_edge->bodies( body_list );
   18401         [ #  # ]:          0 :         bodies_to_merge += body_list;
   18402         [ #  # ]:          0 :       }
   18403 [ #  # ][ #  # ]:          0 :       bodies_to_merge.uniquify_ordered();
   18404                 :            :     }
   18405                 :            : 
   18406 [ #  # ][ #  # ]:          0 :     DLIList<RefEdge*> edges_to_imprint_onto_face1;
                 [ #  # ]
   18407 [ #  # ][ #  # ]:          0 :     DLIList<RefEdge*> edges_to_imprint_onto_face2;
                 [ #  # ]
   18408                 :            : 
   18409                 :            :     //sort edges...
   18410                 :            :     //edges on face1 and not on face2 will be imprinted on face2
   18411                 :            :     //edges on face2 and not on face1 will be imprinted on face1
   18412                 :            :     int i;
   18413 [ #  # ][ #  # ]:          0 :     for(i=ref_edge_list.size(); i--; )
   18414                 :            :     {
   18415         [ #  # ]:          0 :       RefEdge *tmp_edge = ref_edge_list.get_and_step();
   18416         [ #  # ]:          0 :       DLIList<RefFace*> tmp_faces;
   18417         [ #  # ]:          0 :       tmp_edge->ref_faces( tmp_faces );
   18418                 :            : 
   18419 [ #  # ][ #  # ]:          0 :       if( tmp_faces.move_to( face1 ) && !tmp_faces.move_to( face2 ) )
         [ #  # ][ #  # ]
                 [ #  # ]
   18420         [ #  # ]:          0 :         edges_to_imprint_onto_face2.append( tmp_edge );
   18421 [ #  # ][ #  # ]:          0 :       else if( tmp_faces.move_to( face2 ) && !tmp_faces.move_to( face1 ) )
         [ #  # ][ #  # ]
                 [ #  # ]
   18422         [ #  # ]:          0 :         edges_to_imprint_onto_face1.append( tmp_edge );
   18423                 :            :       else
   18424 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Will not imprint curve %d onto either surface.\n", tmp_edge->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   18425         [ #  # ]:          0 :     }
   18426                 :            : 
   18427                 :            :     //if there are edges to impint onto both surfaces
   18428 [ #  # ][ #  # ]:          0 :     if( edges_to_imprint_onto_face1.size() &&
         [ #  # ][ #  # ]
   18429         [ #  # ]:          0 :         edges_to_imprint_onto_face2.size() )
   18430                 :            :     {
   18431                 :            :       //get the modify engine
   18432         [ #  # ]:          0 :       DLIList<Surface*> surf_list( 1 );
   18433 [ #  # ][ #  # ]:          0 :       DLIList<Curve*> curve_list( edges_to_imprint_onto_face2.size() );
         [ #  # ][ #  # ]
   18434 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> ref_face_list( 1 );
                 [ #  # ]
   18435         [ #  # ]:          0 :       ref_face_list.append( face2 );
   18436                 :            :       GeometryModifyEngine* gme = common_modify_engine( ref_face_list,
   18437                 :            :                                                         edges_to_imprint_onto_face2,
   18438                 :            :                                                         surf_list,
   18439         [ #  # ]:          0 :                                                         curve_list );
   18440         [ #  # ]:          0 :       if ( !gme )
   18441                 :            :       {
   18442 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Performing IMPRINT with entities containing geometry from\n"
                 [ #  # ]
   18443         [ #  # ]:          0 :                     "different modeling engines is not allowed.\n" );
   18444                 :          0 :         return CUBIT_FAILURE;
   18445                 :            :       }
   18446                 :            : 
   18447                 :            :       //copy the specified boundary curves of face1 to imprint onto face2...
   18448                 :            :       //these could be stale after we imprint face1
   18449 [ #  # ][ #  # ]:          0 :       DLIList<Curve*> copied_curves;
                 [ #  # ]
   18450 [ #  # ][ #  # ]:          0 :       for(i=curve_list.size(); i--; )
   18451                 :            :       {
   18452 [ #  # ][ #  # ]:          0 :         Curve *copied_curve = gme->make_Curve( curve_list.get_and_step() );
   18453         [ #  # ]:          0 :         copied_curves.append( copied_curve );
   18454                 :            :       }
   18455                 :            : 
   18456 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   18457         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_faces );
   18458                 :            : 
   18459                 :            :       //do the imprint onto face1
   18460                 :          0 :       Body *new_body = NULL;
   18461                 :            :       CubitStatus status;
   18462         [ #  # ]:          0 :       status = tolerant_imprint( face1, edges_to_imprint_onto_face1, new_body );
   18463                 :            : 
   18464                 :            :       //if we failed...get out
   18465         [ #  # ]:          0 :       if( status == CUBIT_FAILURE )
   18466                 :            :       {
   18467                 :            :         //delete the copied curves
   18468 [ #  # ][ #  # ]:          0 :         for( i=copied_curves.size(); i--; )
   18469 [ #  # ][ #  # ]:          0 :           gme->get_gqe()->delete_solid_model_entities( copied_curves.get_and_step() );
                 [ #  # ]
   18470                 :            : 
   18471 [ #  # ][ #  # ]:          0 :         if( CubitUndo::get_undo_enabled() )
   18472         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   18473                 :            : 
   18474                 :          0 :         return CUBIT_FAILURE;
   18475                 :            :       }
   18476                 :            : 
   18477 [ #  # ][ #  # ]:          0 :       DLIList<Body*> original_body_list;
                 [ #  # ]
   18478         [ #  # ]:          0 :       face2->bodies( original_body_list );
   18479                 :            : 
   18480                 :            :       //get the Surface* ptr
   18481         [ #  # ]:          0 :       Surface *surface2 = face2->get_surface_ptr();
   18482                 :            : 
   18483 [ #  # ][ #  # ]:          0 :       DLIList<BodySM*> body_sm_list;
                 [ #  # ]
   18484 [ #  # ][ #  # ]:          0 :       for(i=original_body_list.size(); i--;)
   18485 [ #  # ][ #  # ]:          0 :         body_sm_list.append(original_body_list.get_and_step()->get_body_sm_ptr());
                 [ #  # ]
   18486                 :            : 
   18487                 :          0 :       int process_composites = 0;
   18488 [ #  # ][ #  # ]:          0 :       if(contains_composites(original_body_list))
   18489                 :          0 :         process_composites = 1;
   18490                 :            : 
   18491         [ #  # ]:          0 :       if(process_composites)
   18492                 :            :       {
   18493                 :            :         // Push virtual attributes down to solid model topology before
   18494                 :            :         // doing the imprint.
   18495         [ #  # ]:          0 :         do_attribute_setup();
   18496         [ #  # ]:          0 :         push_attributes_before_modify(body_sm_list);
   18497                 :            :         // This must be done after pushing the vg atts because it uses them.
   18498         [ #  # ]:          0 :         push_imprint_attributes_before_modify(body_sm_list);
   18499                 :            :       }
   18500                 :            : 
   18501                 :            :       //do the imprint onto face2
   18502                 :          0 :       BodySM *new_bodysm = NULL;
   18503 [ #  # ][ #  # ]:          0 :       DLIList<TopologyBridge*> temporary_bridges;
                 [ #  # ]
   18504         [ #  # ]:          0 :       status = gme->tolerant_imprint_surface_with_curves( surface2, copied_curves, temporary_bridges, new_bodysm);
   18505         [ #  # ]:          0 :       temporary_bridges.uniquify_ordered();
   18506 [ #  # ][ #  # ]:          0 :       while(temporary_bridges.size())
   18507                 :            :       {
   18508         [ #  # ]:          0 :         TopologyBridge* bridge = temporary_bridges.pop();
   18509 [ #  # ][ #  # ]:          0 :         bridge->get_geometry_query_engine()->delete_topology_bridge(bridge);
   18510                 :            :       }
   18511                 :            : 
   18512 [ #  # ][ #  # ]:          0 :       DLIList<BodySM*> new_body_list;
                 [ #  # ]
   18513         [ #  # ]:          0 :       if(new_bodysm)
   18514         [ #  # ]:          0 :         new_body_list.append(new_bodysm);
   18515                 :            : 
   18516                 :            : 
   18517                 :            :       //delete the copied curves
   18518 [ #  # ][ #  # ]:          0 :       for( i=copied_curves.size(); i--; )
   18519 [ #  # ][ #  # ]:          0 :         gme->get_gqe()->delete_solid_model_entities( copied_curves.get_and_step() );
                 [ #  # ]
   18520                 :            : 
   18521         [ #  # ]:          0 :       if( status == CUBIT_FAILURE )
   18522                 :            :       {
   18523 [ #  # ][ #  # ]:          0 :         if( CubitUndo::get_undo_enabled() )
   18524         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   18525                 :            : 
   18526         [ #  # ]:          0 :         if(process_composites)
   18527                 :            :         {
   18528         [ #  # ]:          0 :           remove_pushed_attributes(new_body_list, original_body_list);
   18529         [ #  # ]:          0 :           do_attribute_cleanup();
   18530                 :            :         }
   18531                 :            : 
   18532                 :          0 :         return CUBIT_FAILURE;
   18533                 :            :       }
   18534                 :            :       else
   18535                 :            :       {
   18536         [ #  # ]:          0 :         if(process_composites)
   18537                 :            :         {
   18538                 :            :           // Analyze the results and adjust virtual attributes as necessary.
   18539         [ #  # ]:          0 :         DLIList<TopologyBridge*> tb_list;
   18540 [ #  # ][ #  # ]:          0 :         CAST_LIST(new_body_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   18541 [ #  # ][ #  # ]:          0 :           GeometryQueryTool::instance()->ige_attribute_after_imprinting(tb_list, original_body_list);
   18542                 :            : 
   18543                 :            :           // Clean up attributes.
   18544         [ #  # ]:          0 :           remove_imprint_attributes_after_modify(body_sm_list, new_body_list);
   18545                 :            : 
   18546                 :            :           // Restore the virtual geometry.
   18547         [ #  # ]:          0 :           restore_vg_after_modify(new_body_list, original_body_list, gme);
   18548 [ #  # ][ #  # ]:          0 :           remove_pushed_attributes(new_body_list, original_body_list);
   18549                 :            :         }
   18550                 :            :       }
   18551                 :            : 
   18552 [ #  # ][ #  # ]:          0 :       DLIList<BodySM*> new_bodies;
                 [ #  # ]
   18553         [ #  # ]:          0 :       new_bodies.append( new_bodysm );
   18554 [ #  # ][ #  # ]:          0 :       DLIList<Body*> result_bodies;
                 [ #  # ]
   18555         [ #  # ]:          0 :       status = finish_sm_op( original_body_list, new_bodies, result_bodies );
   18556                 :            : 
   18557         [ #  # ]:          0 :       if(process_composites)
   18558         [ #  # ]:          0 :         do_attribute_cleanup();
   18559                 :            : 
   18560         [ #  # ]:          0 :       if( status == CUBIT_FAILURE )
   18561                 :            :       {
   18562 [ #  # ][ #  # ]:          0 :         if( CubitUndo::get_undo_enabled() )
   18563         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   18564 [ #  # ][ #  # ]:          0 :         return CUBIT_FAILURE;
   18565                 :          0 :       }
   18566                 :            :     }
   18567                 :            :     //user specified edges that will only imprint onto face1...do it anyway
   18568 [ #  # ][ #  # ]:          0 :     else if( edges_to_imprint_onto_face1.size() )
   18569                 :            :     {
   18570 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   18571                 :            :       {
   18572         [ #  # ]:          0 :         DLIList<RefFace*> tmp_faces(1);
   18573         [ #  # ]:          0 :         tmp_faces.append( face1 );
   18574 [ #  # ][ #  # ]:          0 :         CubitUndo::save_state_with_cubit_file( tmp_faces );
   18575                 :            :       }
   18576                 :            : 
   18577         [ #  # ]:          0 :       bool undo_enabled = CubitUndo::get_undo_enabled();
   18578         [ #  # ]:          0 :       CubitUndo::set_undo_enabled( false );
   18579                 :            : 
   18580                 :          0 :       Body *new_body = NULL;
   18581                 :            :       CubitStatus stat = tolerant_imprint( face1, edges_to_imprint_onto_face1,
   18582         [ #  # ]:          0 :                                           new_body, merge );
   18583                 :            : 
   18584         [ #  # ]:          0 :     if( undo_enabled )
   18585         [ #  # ]:          0 :       CubitUndo::set_undo_enabled( true );
   18586                 :            : 
   18587 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   18588                 :            :     {
   18589         [ #  # ]:          0 :       if( stat == CUBIT_FAILURE )
   18590         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   18591                 :            :     }
   18592                 :            : 
   18593                 :          0 :       return stat;
   18594                 :            :     }
   18595                 :            :     //user specified edges that will only imprint onto face2...do it anyway
   18596 [ #  # ][ #  # ]:          0 :     else if( edges_to_imprint_onto_face2.size() )
   18597                 :            :     {
   18598 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   18599                 :            :       {
   18600         [ #  # ]:          0 :         DLIList<RefFace*> tmp_faces(1);
   18601         [ #  # ]:          0 :         tmp_faces.append( face2 );
   18602 [ #  # ][ #  # ]:          0 :         CubitUndo::save_state_with_cubit_file( tmp_faces );
   18603                 :            :       }
   18604                 :            : 
   18605         [ #  # ]:          0 :       bool undo_enabled = CubitUndo::get_undo_enabled();
   18606         [ #  # ]:          0 :       CubitUndo::set_undo_enabled( false );
   18607                 :            : 
   18608                 :          0 :       Body *new_body = NULL;
   18609                 :            :       CubitStatus stat = tolerant_imprint( face2, edges_to_imprint_onto_face2,
   18610         [ #  # ]:          0 :                                           new_body, merge );
   18611                 :            : 
   18612         [ #  # ]:          0 :       if( undo_enabled )
   18613         [ #  # ]:          0 :         CubitUndo::set_undo_enabled( true );
   18614                 :            : 
   18615 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   18616                 :            :       {
   18617         [ #  # ]:          0 :         if( stat == CUBIT_FAILURE )
   18618         [ #  # ]:          0 :           CubitUndo::remove_last_undo();
   18619                 :            :       }
   18620                 :            : 
   18621                 :          0 :       return stat;
   18622                 :            :     }
   18623                 :            : 
   18624         [ #  # ]:          0 :     if( merge )
   18625 [ #  # ][ #  # ]:          0 :       MergeTool::instance()->merge_bodies( bodies_to_merge );
         [ #  # ][ #  # ]
   18626                 :            :   }
   18627                 :            :   else
   18628                 :            :   {
   18629         [ #  # ]:          0 :     DLIList<RefFace*> faces_not_to_merge;
   18630         [ #  # ]:          0 :     Body *body1 = face1->body();
   18631         [ #  # ]:          0 :     Body *body2 = face2->body();
   18632                 :            : 
   18633         [ #  # ]:          0 :     if(merge)
   18634                 :            :     {
   18635         [ #  # ]:          0 :       DLIList<RefFace*> tmp_faces;
   18636         [ #  # ]:          0 :       body1->ref_faces(tmp_faces);
   18637 [ #  # ][ #  # ]:          0 :       if(tmp_faces.move_to(face1))
   18638         [ #  # ]:          0 :         tmp_faces.extract();
   18639         [ #  # ]:          0 :       faces_not_to_merge = tmp_faces;
   18640                 :            : 
   18641         [ #  # ]:          0 :       tmp_faces.clean_out();
   18642         [ #  # ]:          0 :       body2->ref_faces(tmp_faces);
   18643 [ #  # ][ #  # ]:          0 :       if(tmp_faces.move_to(face2))
   18644         [ #  # ]:          0 :         tmp_faces.extract();
   18645 [ #  # ][ #  # ]:          0 :       faces_not_to_merge += tmp_faces;
   18646                 :            :     }
   18647                 :            : 
   18648                 :            :     //get the modify engine
   18649 [ #  # ][ #  # ]:          0 :     DLIList<Surface*> surf_list( 1 );
                 [ #  # ]
   18650 [ #  # ][ #  # ]:          0 :     DLIList<RefFace*> ref_face_list( 2 );
                 [ #  # ]
   18651         [ #  # ]:          0 :     ref_face_list.append( face1 );
   18652         [ #  # ]:          0 :     ref_face_list.append( face2 );
   18653         [ #  # ]:          0 :     GeometryModifyEngine* gme = common_modify_engine( ref_face_list, surf_list);
   18654                 :            : 
   18655         [ #  # ]:          0 :     if ( !gme )
   18656                 :            :     {
   18657 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Performing IMPRINT with entities containing geometry from\n"
                 [ #  # ]
   18658         [ #  # ]:          0 :                   "different modeling engines is not allowed.\n" );
   18659                 :          0 :       return CUBIT_FAILURE;
   18660                 :            :     }
   18661                 :            : 
   18662 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   18663         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( ref_faces );
   18664                 :            : 
   18665                 :            :     //do the imprint onto face1
   18666 [ #  # ][ #  # ]:          0 :     DLIList<BodySM*> new_bodysm_list;
                 [ #  # ]
   18667         [ #  # ]:          0 :     CubitStatus status = gme->tolerant_imprint(surf_list, new_bodysm_list);
   18668                 :            : 
   18669                 :            :     //if we failed...get out
   18670         [ #  # ]:          0 :     if( status == CUBIT_FAILURE )
   18671                 :            :     {
   18672 [ #  # ][ #  # ]:          0 :       if( CubitUndo::get_undo_enabled() )
   18673         [ #  # ]:          0 :         CubitUndo::remove_last_undo();
   18674                 :            : 
   18675                 :          0 :       return CUBIT_FAILURE;
   18676                 :            :     }
   18677                 :            : 
   18678 [ #  # ][ #  # ]:          0 :     DLIList<Body*> result_bodies;
         [ #  # ][ #  # ]
   18679 [ #  # ][ #  # ]:          0 :     DLIList<Body*> original_body_list;
   18680         [ #  # ]:          0 :     original_body_list.append(body1);
   18681         [ #  # ]:          0 :     original_body_list.append(body2);
   18682         [ #  # ]:          0 :     status = finish_sm_op( original_body_list, new_bodysm_list, result_bodies );
   18683                 :            : 
   18684                 :            : 
   18685         [ #  # ]:          0 :     if( merge )
   18686                 :            :     {
   18687 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> faces_to_merge, tmp_faces;
                 [ #  # ]
   18688         [ #  # ]:          0 :       body1->ref_faces(faces_to_merge);
   18689         [ #  # ]:          0 :       body2->ref_faces(tmp_faces);
   18690         [ #  # ]:          0 :       faces_to_merge += tmp_faces;
   18691         [ #  # ]:          0 :       faces_to_merge -= faces_not_to_merge;
   18692 [ #  # ][ #  # ]:          0 :       if(faces_to_merge.size() > 1)
   18693                 :            :       {
   18694 [ #  # ][ #  # ]:          0 :         MergeTool::instance()->merge_reffaces(faces_to_merge);
   18695         [ #  # ]:          0 :       }
   18696                 :          0 :     }
   18697                 :            :   }
   18698                 :            : 
   18699                 :          0 :   return CUBIT_SUCCESS;
   18700                 :            : }
   18701                 :            : 
   18702                 :            : 
   18703                 :          0 : CubitStatus GeometryModifyTool::tolerant_imprint( RefFace *ref_face,
   18704                 :            :                                                   DLIList<RefEdge*> &ref_edge_list,
   18705                 :            :                                                   Body *&new_body,
   18706                 :            :                                                   bool merge )
   18707                 :            : {
   18708                 :            :   int i;
   18709         [ #  # ]:          0 :   DLIList<Body*> bodies_to_merge;
   18710 [ #  # ][ #  # ]:          0 :   DLIList<Body*> blank_bodies;
   18711                 :            :   
   18712 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> tmp_edges;
   18713         [ #  # ]:          0 :   ref_face->ref_edges( tmp_edges );
   18714                 :            : 
   18715 [ #  # ][ #  # ]:          0 :   for( i=tmp_edges.size(); i--; )
   18716                 :            :   {
   18717         [ #  # ]:          0 :     RefEdge *tmp_edge = tmp_edges.get_and_step();
   18718         [ #  # ]:          0 :     DLIList<Body*> body_list;
   18719         [ #  # ]:          0 :     tmp_edge->bodies( body_list );    
   18720         [ #  # ]:          0 :     blank_bodies += body_list;
   18721         [ #  # ]:          0 :   }
   18722                 :            : 
   18723         [ #  # ]:          0 :   if( merge )
   18724                 :            :   {
   18725         [ #  # ]:          0 :     bodies_to_merge += blank_bodies;
   18726                 :            :   
   18727 [ #  # ][ #  # ]:          0 :     for( i=ref_edge_list.size(); i--; )
   18728                 :            :     {
   18729         [ #  # ]:          0 :       RefEdge *tmp_edge = ref_edge_list.get_and_step();
   18730         [ #  # ]:          0 :       DLIList<Body*> body_list;
   18731         [ #  # ]:          0 :       tmp_edge->bodies( body_list );
   18732         [ #  # ]:          0 :       bodies_to_merge += body_list;
   18733         [ #  # ]:          0 :     }
   18734                 :            : 
   18735         [ #  # ]:          0 :     bodies_to_merge.uniquify_ordered();
   18736                 :            :   }  
   18737                 :            : 
   18738 [ #  # ][ #  # ]:          0 :   DLIList<Body*> original_body_list;
   18739         [ #  # ]:          0 :   ref_face->bodies( original_body_list );
   18740                 :            : 
   18741 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surf_list( 1 );
   18742 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list(ref_edge_list.size());
                 [ #  # ]
   18743 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> ref_face_list( 1 );
   18744         [ #  # ]:          0 :   ref_face_list.append( ref_face );
   18745                 :            : 
   18746                 :            :   //prohibit imprinting on partition bodies
   18747 [ #  # ][ #  # ]:          0 :   for( int k=0; k<blank_bodies.size(); k++ )  
   18748                 :            :   {
   18749 [ #  # ][ #  # ]:          0 :     if( NULL == get_engine( blank_bodies[k]->bridge_manager()->topology_bridge() ) )
         [ #  # ][ #  # ]
                 [ #  # ]
   18750                 :            :     {
   18751 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("Performing IMPRINT on entities with partitions\n"
                 [ #  # ]
   18752         [ #  # ]:          0 :                    "       is not allowed.\n" );
   18753                 :          0 :        return CUBIT_FAILURE;
   18754                 :            :     }
   18755                 :            :   } 
   18756                 :            : 
   18757                 :            :   GeometryModifyEngine* gme = common_modify_engine( ref_face_list,
   18758                 :            :                                                     ref_edge_list,
   18759                 :            :                                                     surf_list,
   18760                 :            :                                                     curve_list,
   18761         [ #  # ]:          0 :                                                     true);
   18762         [ #  # ]:          0 :   if ( !gme )
   18763                 :            :   {
   18764 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing IMPRINT with entities containing geometry from\n"
                 [ #  # ]
   18765         [ #  # ]:          0 :                 "different modeling engines is not allowed.\n" );
   18766                 :          0 :     return CUBIT_FAILURE;
   18767                 :            :   }
   18768                 :            : 
   18769                 :            : 
   18770 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   18771                 :            :   {
   18772         [ #  # ]:          0 :     DLIList<RefFace*> ref_faces(1);
   18773         [ #  # ]:          0 :     ref_faces.append( ref_face );
   18774 [ #  # ][ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( ref_faces );
   18775                 :            :   }
   18776                 :            : 
   18777 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> body_sm_list;
   18778 [ #  # ][ #  # ]:          0 :   for(i=original_body_list.size(); i--;)
   18779 [ #  # ][ #  # ]:          0 :     body_sm_list.append(original_body_list.get_and_step()->get_body_sm_ptr());
                 [ #  # ]
   18780                 :            : 
   18781                 :          0 :   int process_composites = 0;
   18782 [ #  # ][ #  # ]:          0 :   if(contains_composites(original_body_list))
   18783                 :          0 :     process_composites = 1;
   18784                 :            : 
   18785 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> tb_list;
   18786         [ #  # ]:          0 :   if(process_composites)
   18787                 :            :   {
   18788                 :            :     // Turn certain attributes on.
   18789         [ #  # ]:          0 :     do_attribute_setup();
   18790                 :            :     // Push virtual attributes down to solid model topology before
   18791                 :            :     // doing the imprint.
   18792         [ #  # ]:          0 :     push_attributes_before_modify(body_sm_list);
   18793         [ #  # ]:          0 :     DLIList<TopologyBridge*> tmp_tb_list;
   18794 [ #  # ][ #  # ]:          0 :     CAST_LIST(surf_list, tmp_tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   18795                 :            :     // Put "ORIGINAL" attributes on the bodies being imprinted and
   18796                 :            :     // the curves as these originally existed.
   18797         [ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tmp_tb_list, "ORIGINAL");
   18798 [ #  # ][ #  # ]:          0 :     CAST_LIST(curve_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   18799         [ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tb_list, "ORIGINAL");
   18800 [ #  # ][ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tb_list, "IMPRINTER");
   18801                 :            :   }
   18802                 :            : 
   18803                 :          0 :   CubitStatus status = CUBIT_FAILURE;
   18804 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_body_list;
   18805                 :            :   // The bridges doing the imprinting often get split during the process but
   18806                 :            :   // because of the way we are making copies, the IMPRINTER attribute doesn't
   18807                 :            :   // get propagated to them.  temporary_bridges will be filled in with any
   18808                 :            :   // additional IMPRINTER bridges we need to consider below when deciding whether to
   18809                 :            :   // keep composite attributes.
   18810 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> temporary_bridges;
   18811 [ #  # ][ #  # ]:          0 :   for(i=surf_list.size(); i>0; i--)
   18812                 :            :   {
   18813         [ #  # ]:          0 :     Surface *cur_surf = surf_list.get_and_step();
   18814                 :          0 :     BodySM *new_body_sm = NULL;
   18815                 :            :     CubitStatus tmp_status = gme->tolerant_imprint_surface_with_curves(
   18816                 :            :                                                 cur_surf, curve_list,
   18817                 :            :                                                 temporary_bridges,
   18818         [ #  # ]:          0 :                                                 new_body_sm);
   18819         [ #  # ]:          0 :     if(new_body_sm)
   18820         [ #  # ]:          0 :       new_body_list.append(new_body_sm);
   18821         [ #  # ]:          0 :     if(tmp_status == CUBIT_SUCCESS)
   18822                 :          0 :       status = tmp_status;
   18823                 :            :   }
   18824                 :            : 
   18825         [ #  # ]:          0 :   temporary_bridges.uniquify_ordered();
   18826                 :            : 
   18827         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   18828                 :            :   {
   18829 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   18830         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   18831                 :            : 
   18832         [ #  # ]:          0 :     if(process_composites)
   18833                 :            :     {
   18834         [ #  # ]:          0 :       remove_pushed_attributes(new_body_list, original_body_list);
   18835         [ #  # ]:          0 :       do_attribute_cleanup();
   18836                 :            :     }
   18837                 :            : 
   18838 [ #  # ][ #  # ]:          0 :     while(temporary_bridges.size())
   18839                 :            :     {
   18840         [ #  # ]:          0 :       TopologyBridge* bridge = temporary_bridges.pop();
   18841 [ #  # ][ #  # ]:          0 :       bridge->get_geometry_query_engine()->delete_topology_bridge(bridge);
   18842                 :            :     }
   18843                 :            : 
   18844                 :          0 :     return CUBIT_FAILURE;
   18845                 :            :   }
   18846                 :            :   else
   18847                 :            :   {
   18848         [ #  # ]:          0 :     if(process_composites)
   18849                 :            :     {
   18850                 :            :       // Analyze the results and adjust virtual attributes as necessary.
   18851         [ #  # ]:          0 :       DLIList<TopologyBridge*> tmp_tb_list;
   18852 [ #  # ][ #  # ]:          0 :       CAST_LIST(new_body_list, tmp_tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   18853         [ #  # ]:          0 :       tb_list.merge_unique(tmp_tb_list);
   18854                 :            :       // The bridges coming back in temporary_bridges may not have IMPRINTER
   18855                 :            :       // attributes on them becuase of the way they were generated below.  Make
   18856                 :            :       // sure they get IMPRINTER attributes.
   18857         [ #  # ]:          0 :       push_named_attributes_to_curves_and_points(temporary_bridges, "IMPRINTER");
   18858         [ #  # ]:          0 :       tb_list += temporary_bridges;
   18859 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->ige_attribute_after_imprinting(tb_list, original_body_list);
   18860                 :            : 
   18861                 :            : 
   18862                 :            :       // Clean up attributes.
   18863         [ #  # ]:          0 :       remove_imprint_attributes_after_modify(body_sm_list, new_body_list);
   18864                 :            : 
   18865                 :            :       // Restore the virtual geometry.
   18866         [ #  # ]:          0 :       restore_vg_after_modify(new_body_list, original_body_list, gme);
   18867 [ #  # ][ #  # ]:          0 :       remove_pushed_attributes(new_body_list, original_body_list);
   18868                 :            :     }
   18869                 :            :   }
   18870                 :            :   // cleanup temp bridges
   18871 [ #  # ][ #  # ]:          0 :   while(temporary_bridges.size())
   18872                 :            :   {
   18873         [ #  # ]:          0 :     TopologyBridge* bridge = temporary_bridges.pop();
   18874 [ #  # ][ #  # ]:          0 :     bridge->get_geometry_query_engine()->delete_topology_bridge(bridge);
   18875                 :            :   }
   18876                 :            : 
   18877 [ #  # ][ #  # ]:          0 :   DLIList<Body*> result_bodies;
   18878         [ #  # ]:          0 :   status = finish_sm_op( original_body_list, new_body_list, result_bodies );
   18879                 :            : 
   18880         [ #  # ]:          0 :   if(process_composites)
   18881         [ #  # ]:          0 :     do_attribute_cleanup();
   18882                 :            : 
   18883         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   18884                 :            :   {
   18885 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   18886         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   18887                 :          0 :     return CUBIT_FAILURE;
   18888                 :            :   }
   18889                 :            : 
   18890         [ #  # ]:          0 :   if( merge )
   18891 [ #  # ][ #  # ]:          0 :     MergeTool::instance()->merge_bodies( bodies_to_merge );
   18892                 :            : 
   18893 [ #  # ][ #  # ]:          0 :   if( result_bodies.size() == 1 )
   18894         [ #  # ]:          0 :     new_body = result_bodies.get();
   18895                 :            :   else
   18896                 :          0 :     return CUBIT_FAILURE;
   18897                 :            : 
   18898         [ #  # ]:          0 :   return status;
   18899                 :            : }
   18900                 :            : 
   18901                 :          0 : CubitStatus GeometryModifyTool::unmerge_and_return_merge_partners(RefEdge *input_curve,
   18902                 :            :                                                                   DLIList<DLIList<RefEdge*>*> &curve_merge_lists,
   18903                 :            :                                                                   DLIList<DLIList<RefFace*>*> &surf_merge_lists)
   18904                 :            : {
   18905 [ #  # ][ #  # ]:          0 :   if(!input_curve->is_merged())
   18906                 :          0 :     return CUBIT_FAILURE;
   18907                 :            : 
   18908         [ #  # ]:          0 :   DLIList<RefFace*> vert_surfs;
   18909 [ #  # ][ #  # ]:          0 :   input_curve->start_vertex()->ref_faces(vert_surfs);
   18910 [ #  # ][ #  # ]:          0 :   input_curve->end_vertex()->ref_faces(vert_surfs);
   18911         [ #  # ]:          0 :   vert_surfs.uniquify_unordered();
   18912 [ #  # ][ #  # ]:          0 :   for(int i=vert_surfs.size(); i>0; i--)
   18913                 :            :   {
   18914         [ #  # ]:          0 :     RefFace *cur_surf = vert_surfs.get_and_step();
   18915 [ #  # ][ #  # ]:          0 :     if(cur_surf->is_merged())
   18916                 :            :     {
   18917         [ #  # ]:          0 :       DLIList<RefVolume*> surf_vols;
   18918 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> all_surfs_on_both_vols;
                 [ #  # ]
   18919         [ #  # ]:          0 :       cur_surf->ref_volumes(surf_vols);
   18920 [ #  # ][ #  # ]:          0 :       for(int j=surf_vols.size(); j>0; j--)
   18921                 :            :       {
   18922         [ #  # ]:          0 :         RefVolume *cur_vol = surf_vols.get_and_step();
   18923         [ #  # ]:          0 :         cur_vol->ref_faces(all_surfs_on_both_vols);
   18924                 :            :       }
   18925         [ #  # ]:          0 :       all_surfs_on_both_vols.uniquify_unordered();
   18926 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> all_surfs_on_both_vols_after_unmerge;
                 [ #  # ]
   18927 [ #  # ][ #  # ]:          0 :       OldUnmergeCode::instance().unmerge(cur_surf, false);
   18928 [ #  # ][ #  # ]:          0 :       for(int j=surf_vols.size(); j>0; j--)
   18929                 :            :       {
   18930         [ #  # ]:          0 :         RefVolume *cur_vol = surf_vols.get_and_step();
   18931         [ #  # ]:          0 :         cur_vol->ref_faces(all_surfs_on_both_vols_after_unmerge);
   18932                 :            :       }
   18933         [ #  # ]:          0 :       all_surfs_on_both_vols_after_unmerge.uniquify_unordered();
   18934         [ #  # ]:          0 :       all_surfs_on_both_vols_after_unmerge -= all_surfs_on_both_vols;
   18935 [ #  # ][ #  # ]:          0 :       if(all_surfs_on_both_vols_after_unmerge.size() != 1)
   18936                 :          0 :         return CUBIT_FAILURE;
   18937         [ #  # ]:          0 :       all_surfs_on_both_vols_after_unmerge.append(cur_surf);
   18938 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> *new_list = new DLIList<RefFace*>();
   18939 [ #  # ][ #  # ]:          0 :       for(int r=all_surfs_on_both_vols_after_unmerge.size(); r>0; r--)
   18940                 :            :       {
   18941         [ #  # ]:          0 :         RefFace *cur_surf = all_surfs_on_both_vols_after_unmerge.get_and_step();
   18942         [ #  # ]:          0 :         new_list->append(cur_surf);
   18943                 :            :       }
   18944 [ #  # ][ #  # ]:          0 :       surf_merge_lists.append(new_list);
                 [ #  # ]
   18945                 :            :     }
   18946                 :            :   }
   18947 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> vert_curves;
   18948 [ #  # ][ #  # ]:          0 :   input_curve->start_vertex()->ref_edges(vert_curves);
   18949 [ #  # ][ #  # ]:          0 :   input_curve->end_vertex()->ref_edges(vert_curves);
   18950         [ #  # ]:          0 :   vert_curves.uniquify_unordered();
   18951 [ #  # ][ #  # ]:          0 :   for(int i=vert_curves.size(); i>0; i--)
   18952                 :            :   {
   18953         [ #  # ]:          0 :     RefEdge *cur_curve = vert_curves.get_and_step();
   18954 [ #  # ][ #  # ]:          0 :     if(cur_curve->is_merged())
   18955                 :            :     {
   18956         [ #  # ]:          0 :       DLIList<RefFace*> curve_surfs;
   18957 [ #  # ][ #  # ]:          0 :       DLIList<RefEdge*> all_curves_on_all_surfs;
                 [ #  # ]
   18958         [ #  # ]:          0 :       cur_curve->ref_faces(curve_surfs);
   18959 [ #  # ][ #  # ]:          0 :       for(int j=curve_surfs.size(); j>0; j--)
   18960                 :            :       {
   18961         [ #  # ]:          0 :         RefFace *cur_surf = curve_surfs.get_and_step();
   18962         [ #  # ]:          0 :         cur_surf->ref_edges(all_curves_on_all_surfs);
   18963                 :            :       }
   18964         [ #  # ]:          0 :       all_curves_on_all_surfs.uniquify_unordered();
   18965 [ #  # ][ #  # ]:          0 :       DLIList<RefEdge*> all_curves_on_all_surfs_after_unmerge;
                 [ #  # ]
   18966 [ #  # ][ #  # ]:          0 :       OldUnmergeCode::instance().unmerge(cur_curve, true);
   18967 [ #  # ][ #  # ]:          0 :       for(int j=curve_surfs.size(); j>0; j--)
   18968                 :            :       {
   18969         [ #  # ]:          0 :         RefFace *cur_surf = curve_surfs.get_and_step();
   18970         [ #  # ]:          0 :         cur_surf->ref_edges(all_curves_on_all_surfs_after_unmerge);
   18971                 :            :       }
   18972         [ #  # ]:          0 :       all_curves_on_all_surfs_after_unmerge.uniquify_unordered();
   18973         [ #  # ]:          0 :       all_curves_on_all_surfs_after_unmerge -= all_curves_on_all_surfs;
   18974 [ #  # ][ #  # ]:          0 :       if(all_curves_on_all_surfs_after_unmerge.size() < 1)
   18975                 :          0 :         return CUBIT_FAILURE;
   18976         [ #  # ]:          0 :       all_curves_on_all_surfs_after_unmerge.append_unique(cur_curve);
   18977 [ #  # ][ #  # ]:          0 :       DLIList<RefEdge*> *new_list = new DLIList<RefEdge*>();
   18978 [ #  # ][ #  # ]:          0 :       for(int r=all_curves_on_all_surfs_after_unmerge.size(); r>0; r--)
   18979                 :            :       {
   18980         [ #  # ]:          0 :         RefEdge *cur_edge = all_curves_on_all_surfs_after_unmerge.get_and_step();
   18981         [ #  # ]:          0 :         new_list->append(cur_edge);
   18982                 :            :       }
   18983 [ #  # ][ #  # ]:          0 :       curve_merge_lists.append(new_list);
                 [ #  # ]
   18984                 :            :     }
   18985                 :            :   }
   18986         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   18987                 :            : }
   18988                 :            : 
   18989                 :          0 : CubitStatus GeometryModifyTool::unmerge_and_return_merge_partners(RefVertex *input_vertex,
   18990                 :            :                                                                   DLIList<DLIList<RefVertex*>*> &vert_merge_lists,
   18991                 :            :                                                                   DLIList<DLIList<RefEdge*>*> &curve_merge_lists,
   18992                 :            :                                                                   DLIList<DLIList<RefFace*>*> &surf_merge_lists)
   18993                 :            : {
   18994 [ #  # ][ #  # ]:          0 :   if(!input_vertex->is_merged())
   18995                 :          0 :     return CUBIT_FAILURE;
   18996                 :            : 
   18997         [ #  # ]:          0 :   DLIList<RefFace*> vert_surfs;
   18998         [ #  # ]:          0 :   input_vertex->ref_faces(vert_surfs);
   18999 [ #  # ][ #  # ]:          0 :   for(int i=vert_surfs.size(); i>0; i--)
   19000                 :            :   {
   19001         [ #  # ]:          0 :     RefFace *cur_surf = vert_surfs.get_and_step();
   19002 [ #  # ][ #  # ]:          0 :     if(cur_surf->is_merged())
   19003                 :            :     {
   19004         [ #  # ]:          0 :       DLIList<RefVolume*> surf_vols;
   19005 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> all_surfs_on_both_vols;
                 [ #  # ]
   19006         [ #  # ]:          0 :       cur_surf->ref_volumes(surf_vols);
   19007 [ #  # ][ #  # ]:          0 :       for(int j=surf_vols.size(); j>0; j--)
   19008                 :            :       {
   19009         [ #  # ]:          0 :         RefVolume *cur_vol = surf_vols.get_and_step();
   19010         [ #  # ]:          0 :         cur_vol->ref_faces(all_surfs_on_both_vols);
   19011                 :            :       }
   19012         [ #  # ]:          0 :       all_surfs_on_both_vols.uniquify_unordered();
   19013 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> all_surfs_on_both_vols_after_unmerge;
                 [ #  # ]
   19014 [ #  # ][ #  # ]:          0 :       OldUnmergeCode::instance().unmerge(cur_surf, false);
   19015 [ #  # ][ #  # ]:          0 :       for(int j=surf_vols.size(); j>0; j--)
   19016                 :            :       {
   19017         [ #  # ]:          0 :         RefVolume *cur_vol = surf_vols.get_and_step();
   19018         [ #  # ]:          0 :         cur_vol->ref_faces(all_surfs_on_both_vols_after_unmerge);
   19019                 :            :       }
   19020         [ #  # ]:          0 :       all_surfs_on_both_vols_after_unmerge.uniquify_unordered();
   19021         [ #  # ]:          0 :       all_surfs_on_both_vols_after_unmerge -= all_surfs_on_both_vols;
   19022 [ #  # ][ #  # ]:          0 :       if(all_surfs_on_both_vols_after_unmerge.size() != 1)
   19023                 :          0 :         return CUBIT_FAILURE;
   19024         [ #  # ]:          0 :       all_surfs_on_both_vols_after_unmerge.append(cur_surf);
   19025 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> *new_list = new DLIList<RefFace*>();
   19026 [ #  # ][ #  # ]:          0 :       for(int r=all_surfs_on_both_vols_after_unmerge.size(); r>0; r--)
   19027                 :            :       {
   19028         [ #  # ]:          0 :         RefFace *cur_surf = all_surfs_on_both_vols_after_unmerge.get_and_step();
   19029         [ #  # ]:          0 :         new_list->append(cur_surf);
   19030                 :            :       }
   19031 [ #  # ][ #  # ]:          0 :       surf_merge_lists.append(new_list);
                 [ #  # ]
   19032                 :            :     }
   19033                 :            :   }
   19034 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> vert_curves;
   19035         [ #  # ]:          0 :   input_vertex->ref_edges(vert_curves);
   19036 [ #  # ][ #  # ]:          0 :   for(int i=vert_curves.size(); i>0; i--)
   19037                 :            :   {
   19038         [ #  # ]:          0 :     RefEdge *cur_curve = vert_curves.get_and_step();
   19039 [ #  # ][ #  # ]:          0 :     if(cur_curve->is_merged())
   19040                 :            :     {
   19041         [ #  # ]:          0 :       DLIList<RefFace*> curve_surfs;
   19042 [ #  # ][ #  # ]:          0 :       DLIList<RefEdge*> all_curves_on_all_surfs;
                 [ #  # ]
   19043         [ #  # ]:          0 :       cur_curve->ref_faces(curve_surfs);
   19044 [ #  # ][ #  # ]:          0 :       for(int j=curve_surfs.size(); j>0; j--)
   19045                 :            :       {
   19046         [ #  # ]:          0 :         RefFace *cur_surf = curve_surfs.get_and_step();
   19047         [ #  # ]:          0 :         cur_surf->ref_edges(all_curves_on_all_surfs);
   19048                 :            :       }
   19049         [ #  # ]:          0 :       all_curves_on_all_surfs.uniquify_unordered();
   19050 [ #  # ][ #  # ]:          0 :       DLIList<RefEdge*> all_curves_on_all_surfs_after_unmerge;
                 [ #  # ]
   19051 [ #  # ][ #  # ]:          0 :       OldUnmergeCode::instance().unmerge(cur_curve, false);
   19052 [ #  # ][ #  # ]:          0 :       for(int j=curve_surfs.size(); j>0; j--)
   19053                 :            :       {
   19054         [ #  # ]:          0 :         RefFace *cur_surf = curve_surfs.get_and_step();
   19055         [ #  # ]:          0 :         cur_surf->ref_edges(all_curves_on_all_surfs_after_unmerge);
   19056                 :            :       }
   19057         [ #  # ]:          0 :       all_curves_on_all_surfs_after_unmerge.uniquify_unordered();
   19058         [ #  # ]:          0 :       all_curves_on_all_surfs_after_unmerge -= all_curves_on_all_surfs;
   19059 [ #  # ][ #  # ]:          0 :       if(all_curves_on_all_surfs_after_unmerge.size() < 1)
   19060                 :          0 :         return CUBIT_FAILURE;
   19061         [ #  # ]:          0 :       all_curves_on_all_surfs_after_unmerge.append_unique(cur_curve);
   19062 [ #  # ][ #  # ]:          0 :       DLIList<RefEdge*> *new_list = new DLIList<RefEdge*>();
   19063 [ #  # ][ #  # ]:          0 :       for(int r=all_curves_on_all_surfs_after_unmerge.size(); r>0; r--)
   19064                 :            :       {
   19065         [ #  # ]:          0 :         RefEdge *cur_edge = all_curves_on_all_surfs_after_unmerge.get_and_step();
   19066         [ #  # ]:          0 :         new_list->append(cur_edge);
   19067                 :            :       }
   19068 [ #  # ][ #  # ]:          0 :       curve_merge_lists.append(new_list);
                 [ #  # ]
   19069                 :            :     }
   19070                 :            :   }
   19071         [ #  # ]:          0 :   vert_curves.clean_out();
   19072         [ #  # ]:          0 :   input_vertex->ref_edges(vert_curves);
   19073 [ #  # ][ #  # ]:          0 :   DLIList<RefVertex*> curve_verts;
   19074 [ #  # ][ #  # ]:          0 :   for(int i=vert_curves.size(); i>0; i--)
   19075                 :            :   {
   19076         [ #  # ]:          0 :     RefEdge *cur_curve = vert_curves.get_and_step();
   19077         [ #  # ]:          0 :     cur_curve->ref_vertices(curve_verts);
   19078                 :            :   }
   19079         [ #  # ]:          0 :   curve_verts.uniquify_unordered();
   19080 [ #  # ][ #  # ]:          0 :   DLIList<RefVertex*> verts_after_unmerge;
   19081 [ #  # ][ #  # ]:          0 :   OldUnmergeCode::instance().unmerge(input_vertex);
   19082 [ #  # ][ #  # ]:          0 :   for(int j=vert_curves.size(); j>0; j--)
   19083                 :            :   {
   19084         [ #  # ]:          0 :     RefEdge *cur_curve = vert_curves.get_and_step();
   19085         [ #  # ]:          0 :     cur_curve->ref_vertices(verts_after_unmerge);
   19086                 :            :   }
   19087         [ #  # ]:          0 :   verts_after_unmerge.uniquify_unordered();
   19088         [ #  # ]:          0 :   verts_after_unmerge -= curve_verts;
   19089 [ #  # ][ #  # ]:          0 :   if(verts_after_unmerge.size() < 1)
   19090                 :          0 :     return CUBIT_FAILURE;
   19091         [ #  # ]:          0 :   verts_after_unmerge.append_unique(input_vertex);
   19092 [ #  # ][ #  # ]:          0 :   DLIList<RefVertex*> *new_list = new DLIList<RefVertex*>();
   19093 [ #  # ][ #  # ]:          0 :   for(int r=verts_after_unmerge.size(); r>0; r--)
   19094                 :            :   {
   19095         [ #  # ]:          0 :     RefVertex *cur_vert = verts_after_unmerge.get_and_step();
   19096         [ #  # ]:          0 :     new_list->append(cur_vert);
   19097                 :            :   }
   19098         [ #  # ]:          0 :   vert_merge_lists.append(new_list);
   19099                 :            : 
   19100         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   19101                 :            : }
   19102                 :            : 
   19103                 :          0 : CubitStatus GeometryModifyTool::unmerge_input(RefEdge *curve1,
   19104                 :            :                                               RefEdge *curve2,
   19105                 :            :                                               DLIList<DLIList<RefEdge*>*> &curve_merge_lists,
   19106                 :            :                                               DLIList<DLIList<RefFace*>*> &surf_merge_lists)
   19107                 :            : {
   19108         [ #  # ]:          0 :   if(curve1->is_merged())
   19109                 :            :   {
   19110                 :          0 :     this->unmerge_and_return_merge_partners(curve1, curve_merge_lists, surf_merge_lists);
   19111                 :            :   }
   19112         [ #  # ]:          0 :   if(curve2->is_merged())
   19113                 :            :   {
   19114                 :          0 :     this->unmerge_and_return_merge_partners(curve2, curve_merge_lists, surf_merge_lists);
   19115                 :            :   }
   19116                 :          0 :   return CUBIT_SUCCESS;
   19117                 :            : }
   19118                 :            : 
   19119                 :          0 : CubitStatus GeometryModifyTool::find_best_curves_to_merge(DLIList<RefEdge*> *&curves_from_curve1,
   19120                 :            :                                                           DLIList<RefEdge*> *&curves_from_curve2,
   19121                 :            :                                                           RefEdge *&curve1,
   19122                 :            :                                                           RefEdge *&curve2)
   19123                 :            : {
   19124                 :            :   /*
   19125                 :            :   for(int i=curves_from_curve1.size(); i>0; i--)
   19126                 :            :   {
   19127                 :            :      if found better curve than curve1 set curve1 to be this curve
   19128                 :            :   }
   19129                 :            :   for(int i=curves_from_curve2.size(); i>0; i--)
   19130                 :            :   {
   19131                 :            :      if found better curve than curve2 set curve2 to be this curve
   19132                 :            :   }
   19133                 :            :   */
   19134                 :          0 :   return CUBIT_SUCCESS;
   19135                 :            : }
   19136                 :            : 
   19137                 :          0 : CubitStatus GeometryModifyTool::imprint_and_merge_curves(RefEdge *input_curve1,
   19138                 :            :                                                          RefEdge *input_curve2,
   19139                 :            :                                                          DLIList<RefVertex*> &vert_list,
   19140                 :            :                                                          double divergence_angle,
   19141                 :            :                                                          DLIList<DLIList<RefEdge*>*> &curves_to_merge1,
   19142                 :            :                                                          DLIList<DLIList<RefEdge*>*> &curves_to_merge2,
   19143                 :            :                                                          DLIList<DLIList<RefEdge*>*> &prev_curve_merge_lists,
   19144                 :            :                                                          DLIList<DLIList<RefFace*>*> &prev_surf_merge_lists)
   19145                 :            : {
   19146                 :            :   CubitStatus status;
   19147         [ #  # ]:          0 :   status = this->unmerge_input(input_curve1, input_curve2, prev_curve_merge_lists, prev_surf_merge_lists);
   19148         [ #  # ]:          0 :   if(status == CUBIT_FAILURE)
   19149                 :          0 :     return status;
   19150                 :            :   RefEdge *curve1, *curve2;
   19151 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> *curves_from_curve1 = new DLIList<RefEdge*>();
   19152 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> *curves_from_curve2 = new DLIList<RefEdge*>();
   19153 [ #  # ][ #  # ]:          0 :   for(int i=prev_curve_merge_lists.size(); i>0; i--)
   19154                 :            :   {
   19155         [ #  # ]:          0 :     DLIList<RefEdge*> *cur_list = prev_curve_merge_lists.get_and_step();
   19156                 :            : //    DLIList<RefEdge*> cur_list = prev_curve_merge_lists.get();
   19157 [ #  # ][ #  # ]:          0 :     if(cur_list->move_to(input_curve1))
   19158                 :            :     {
   19159         [ #  # ]:          0 :       *curves_from_curve1 = *cur_list;
   19160                 :            :      // prev_curve_merge_lists.remove();
   19161                 :            :     }
   19162 [ #  # ][ #  # ]:          0 :     else if(cur_list->move_to(input_curve2))
   19163                 :            :     {
   19164         [ #  # ]:          0 :       *curves_from_curve2 = *cur_list;
   19165                 :            :      // prev_curve_merge_lists.remove();
   19166                 :            :     }
   19167                 :            : //    else
   19168                 :            :  //     prev_curve_merge_lists.step();
   19169                 :            :   }
   19170                 :            :   // Make sure at least the input curves are in the lists.
   19171 [ #  # ][ #  # ]:          0 :   if(curves_from_curve1->size() == 0)
   19172         [ #  # ]:          0 :     curves_from_curve1->append(input_curve1);
   19173 [ #  # ][ #  # ]:          0 :   if(curves_from_curve2->size() == 0)
   19174         [ #  # ]:          0 :     curves_from_curve2->append(input_curve2);
   19175                 :            : 
   19176                 :          0 :   curve1 = input_curve1;
   19177                 :          0 :   curve2 = input_curve2;
   19178         [ #  # ]:          0 :   status = this->find_best_curves_to_merge(curves_from_curve1, curves_from_curve2, curve1, curve2);
   19179         [ #  # ]:          0 :   if(CUBIT_FAILURE == status)
   19180                 :          0 :     return status;
   19181                 :            : 
   19182 [ #  # ][ #  # ]:          0 :   DLIList<CubitVector> merge_end_points_on_curve1, merge_end_points_on_curve2;
                 [ #  # ]
   19183 [ #  # ][ #  # ]:          0 :   DLIList<CubitBoolean> split_flags1, split_flags2;
         [ #  # ][ #  # ]
   19184                 :            :   this->calculate_split_points_for_merge(curve1, curve2, vert_list, NULL,
   19185         [ #  # ]:          0 :     merge_end_points_on_curve1, merge_end_points_on_curve2, split_flags1, split_flags2, divergence_angle);
   19186                 :            : 
   19187         [ #  # ]:          0 :   merge_end_points_on_curve1.reset();
   19188         [ #  # ]:          0 :   split_flags1.reset();
   19189 [ #  # ][ #  # ]:          0 :   for(int k=merge_end_points_on_curve1.size(); k>0; k=k-2)
   19190                 :            :   {
   19191 [ #  # ][ #  # ]:          0 :     CubitVector end_point1 = merge_end_points_on_curve1.get_and_step();
   19192 [ #  # ][ #  # ]:          0 :     CubitVector end_point2 = merge_end_points_on_curve1.get_and_step();
   19193 [ #  # ][ #  # ]:          0 :     bool split_flag_end = split_flags1.get_and_step();
   19194         [ #  # ]:          0 :     if(split_flag_end)
   19195                 :            :     {
   19196 [ #  # ][ #  # ]:          0 :       DLIList<RefEdge*> *cur_merge_list = new DLIList<RefEdge*>();
   19197 [ #  # ][ #  # ]:          0 :       for(int n=curves_from_curve1->size(); n>0; n--)
   19198                 :            :       {
   19199         [ #  # ]:          0 :         RefEdge *curve_to_split = curves_from_curve1->get();
   19200 [ #  # ][ #  # ]:          0 :         CubitVector mid = (end_point1 + end_point2)/2.0;
   19201         [ #  # ]:          0 :         CubitVector pos_for_identifying;
   19202         [ #  # ]:          0 :         curve_to_split->closest_point_trimmed(mid, pos_for_identifying);
   19203                 :            : 
   19204         [ #  # ]:          0 :         DLIList<CubitVector> loc_list;
   19205         [ #  # ]:          0 :         loc_list.append(end_point2);
   19206                 :            :         CubitStatus loc_status;
   19207                 :            : 
   19208 [ #  # ][ #  # ]:          0 :         int expected_edge_id_1 = RefEntityFactory::instance()->current_edge_id() + 1;
   19209                 :          0 :         int expected_edge_id_2 = expected_edge_id_1 + 1;
   19210                 :            : 
   19211 [ #  # ][ #  # ]:          0 :         if(curve_to_split->body())
   19212                 :            :         {
   19213 [ #  # ][ #  # ]:          0 :           DLIList<Body*> edge_bodies, new_bodies;
                 [ #  # ]
   19214 [ #  # ][ #  # ]:          0 :           edge_bodies.append(curve_to_split->body());  // for now just handle single body case
   19215                 :            : 
   19216 [ #  # ][ #  # ]:          0 :           loc_status = this->imprint( edge_bodies, loc_list, new_bodies );
   19217                 :            :         }
   19218                 :            :         else
   19219                 :            :         {
   19220         [ #  # ]:          0 :           DLIList<RefEdge*> new_ref_edges;
   19221 [ #  # ][ #  # ]:          0 :           loc_status = this->split_free_curve( curve_to_split, loc_list, new_ref_edges );
   19222                 :            :         }
   19223                 :            : 
   19224         [ #  # ]:          0 :         if(loc_status == CUBIT_FAILURE)
   19225                 :            :         {
   19226                 :          0 :           return CUBIT_FAILURE;
   19227                 :            :         }
   19228                 :            : 
   19229 [ #  # ][ #  # ]:          0 :         RefEdge *new_edge_1 = RefEntityFactory::instance()->get_ref_edge(expected_edge_id_1);
   19230 [ #  # ][ #  # ]:          0 :         RefEdge *new_edge_2 = RefEntityFactory::instance()->get_ref_edge(expected_edge_id_2);
   19231                 :            : 
   19232 [ #  # ][ #  # ]:          0 :         if(!new_edge_1 || !new_edge_2)
   19233                 :            :         {
   19234                 :          0 :           return CUBIT_FAILURE;
   19235                 :            :         }
   19236                 :            : 
   19237         [ #  # ]:          0 :         CubitVector closest;
   19238         [ #  # ]:          0 :         new_edge_1->closest_point_trimmed(pos_for_identifying, closest);
   19239 [ #  # ][ #  # ]:          0 :         if(closest.about_equal(pos_for_identifying))
   19240                 :            :         {
   19241         [ #  # ]:          0 :           cur_merge_list->append(new_edge_1);
   19242         [ #  # ]:          0 :           RefEdge *edge_that_was_split = curves_from_curve1->get();
   19243         [ #  # ]:          0 :           curves_from_curve1->change_to(new_edge_2);
   19244 [ #  # ][ #  # ]:          0 :           for(int w=prev_curve_merge_lists.size(); w>0; w--)
   19245                 :            :           {
   19246         [ #  # ]:          0 :             DLIList<RefEdge*> *cur_list = prev_curve_merge_lists.get_and_step();
   19247 [ #  # ][ #  # ]:          0 :             if(cur_list->move_to(edge_that_was_split))
   19248                 :            :             {
   19249         [ #  # ]:          0 :               cur_list->change_to(new_edge_2);
   19250                 :          0 :               w=0;
   19251                 :            :             }
   19252                 :            :           }
   19253                 :            :         }
   19254                 :            :         else
   19255                 :            :         {
   19256         [ #  # ]:          0 :           cur_merge_list->append(new_edge_2);
   19257         [ #  # ]:          0 :           RefEdge *edge_that_was_split = curves_from_curve1->get();
   19258         [ #  # ]:          0 :           curves_from_curve1->change_to(new_edge_1);
   19259 [ #  # ][ #  # ]:          0 :           for(int w=prev_curve_merge_lists.size(); w>0; w--)
   19260                 :            :           {
   19261         [ #  # ]:          0 :             DLIList<RefEdge*> *cur_list = prev_curve_merge_lists.get_and_step();
   19262 [ #  # ][ #  # ]:          0 :             if(cur_list->move_to(edge_that_was_split))
   19263                 :            :             {
   19264         [ #  # ]:          0 :               cur_list->change_to(new_edge_1);
   19265                 :          0 :               w=0;
   19266                 :            :             }
   19267                 :            :           }
   19268                 :            :         }
   19269 [ #  # ][ #  # ]:          0 :         curves_from_curve1->step();
                 [ #  # ]
   19270                 :          0 :       }
   19271         [ #  # ]:          0 :       curves_to_merge1.append(cur_merge_list);
   19272                 :            :     }
   19273                 :            :     else
   19274                 :            :     {
   19275         [ #  # ]:          0 :       curves_to_merge1.append(curves_from_curve1);
   19276                 :            :     }
   19277                 :            :   }
   19278                 :            : 
   19279         [ #  # ]:          0 :   merge_end_points_on_curve2.reset();
   19280         [ #  # ]:          0 :   split_flags2.reset();
   19281 [ #  # ][ #  # ]:          0 :   for(int k=merge_end_points_on_curve2.size(); k>0; k=k-2)
   19282                 :            :   {
   19283 [ #  # ][ #  # ]:          0 :     CubitVector end_point1 = merge_end_points_on_curve2.get_and_step();
   19284 [ #  # ][ #  # ]:          0 :     CubitVector end_point2 = merge_end_points_on_curve2.get_and_step();
   19285 [ #  # ][ #  # ]:          0 :     bool split_flag_end = split_flags2.get_and_step();
   19286         [ #  # ]:          0 :     if(split_flag_end)
   19287                 :            :     {
   19288 [ #  # ][ #  # ]:          0 :       DLIList<RefEdge*> *cur_merge_list = new DLIList<RefEdge*>();
   19289 [ #  # ][ #  # ]:          0 :       for(int n=curves_from_curve2->size(); n>0; n--)
   19290                 :            :       {
   19291         [ #  # ]:          0 :         RefEdge *curve_to_split = curves_from_curve2->get();
   19292 [ #  # ][ #  # ]:          0 :         CubitVector mid = (end_point1 + end_point2)/2.0;
   19293         [ #  # ]:          0 :         CubitVector pos_for_identifying;
   19294         [ #  # ]:          0 :         curve_to_split->closest_point_trimmed(mid, pos_for_identifying);
   19295                 :            : 
   19296         [ #  # ]:          0 :         DLIList<CubitVector> loc_list;
   19297         [ #  # ]:          0 :         loc_list.append(end_point2);
   19298                 :            :         CubitStatus loc_status;
   19299                 :            : 
   19300 [ #  # ][ #  # ]:          0 :         int expected_edge_id_1 = RefEntityFactory::instance()->current_edge_id() + 1;
   19301                 :          0 :         int expected_edge_id_2 = expected_edge_id_1 + 1;
   19302                 :            : 
   19303 [ #  # ][ #  # ]:          0 :         if(curve_to_split->body())
   19304                 :            :         {
   19305 [ #  # ][ #  # ]:          0 :           DLIList<Body*> edge_bodies, new_bodies;
                 [ #  # ]
   19306 [ #  # ][ #  # ]:          0 :           edge_bodies.append(curve_to_split->body());  // for now just handle single body case
   19307                 :            : 
   19308 [ #  # ][ #  # ]:          0 :           loc_status = this->imprint( edge_bodies, loc_list, new_bodies );
   19309                 :            :         }
   19310                 :            :         else
   19311                 :            :         {
   19312         [ #  # ]:          0 :           DLIList<RefEdge*> new_ref_edges;
   19313 [ #  # ][ #  # ]:          0 :           loc_status = this->split_free_curve( curve_to_split, loc_list, new_ref_edges );
   19314                 :            :         }
   19315                 :            : 
   19316         [ #  # ]:          0 :         if(loc_status == CUBIT_FAILURE)
   19317                 :            :         {
   19318                 :          0 :           return CUBIT_FAILURE;
   19319                 :            :         }
   19320                 :            : 
   19321 [ #  # ][ #  # ]:          0 :         RefEdge *new_edge_1 = RefEntityFactory::instance()->get_ref_edge(expected_edge_id_1);
   19322 [ #  # ][ #  # ]:          0 :         RefEdge *new_edge_2 = RefEntityFactory::instance()->get_ref_edge(expected_edge_id_2);
   19323                 :            : 
   19324 [ #  # ][ #  # ]:          0 :         if(!new_edge_1 || !new_edge_2)
   19325                 :            :         {
   19326                 :          0 :           return CUBIT_FAILURE;
   19327                 :            :         }
   19328                 :            : 
   19329         [ #  # ]:          0 :         CubitVector closest;
   19330         [ #  # ]:          0 :         new_edge_1->closest_point_trimmed(pos_for_identifying, closest);
   19331 [ #  # ][ #  # ]:          0 :         if(closest.about_equal(pos_for_identifying))
   19332                 :            :         {
   19333         [ #  # ]:          0 :           cur_merge_list->append(new_edge_1);
   19334         [ #  # ]:          0 :           RefEdge *edge_that_was_split = curves_from_curve2->get();
   19335         [ #  # ]:          0 :           curves_from_curve2->change_to(new_edge_2);
   19336 [ #  # ][ #  # ]:          0 :           for(int w=prev_curve_merge_lists.size(); w>0; w--)
   19337                 :            :           {
   19338         [ #  # ]:          0 :             DLIList<RefEdge*> *cur_list = prev_curve_merge_lists.get_and_step();
   19339 [ #  # ][ #  # ]:          0 :             if(cur_list->move_to(edge_that_was_split))
   19340                 :            :             {
   19341         [ #  # ]:          0 :               cur_list->change_to(new_edge_2);
   19342                 :          0 :               w=0;
   19343                 :            :             }
   19344                 :            :           }
   19345                 :            :         }
   19346                 :            :         else
   19347                 :            :         {
   19348         [ #  # ]:          0 :           cur_merge_list->append(new_edge_2);
   19349         [ #  # ]:          0 :           RefEdge *edge_that_was_split = curves_from_curve2->get();
   19350         [ #  # ]:          0 :           curves_from_curve2->change_to(new_edge_1);
   19351 [ #  # ][ #  # ]:          0 :           for(int w=prev_curve_merge_lists.size(); w>0; w--)
   19352                 :            :           {
   19353         [ #  # ]:          0 :             DLIList<RefEdge*> *cur_list = prev_curve_merge_lists.get_and_step();
   19354 [ #  # ][ #  # ]:          0 :             if(cur_list->move_to(edge_that_was_split))
   19355                 :            :             {
   19356         [ #  # ]:          0 :               cur_list->change_to(new_edge_1);
   19357                 :          0 :               w=0;
   19358                 :            :             }
   19359                 :            :           }
   19360                 :            :         }
   19361 [ #  # ][ #  # ]:          0 :         curves_from_curve2->step();
                 [ #  # ]
   19362                 :          0 :       }
   19363         [ #  # ]:          0 :       curves_to_merge2.append(cur_merge_list);
   19364                 :            :     }
   19365                 :            :     else
   19366                 :            :     {
   19367         [ #  # ]:          0 :       curves_to_merge2.append(curves_from_curve2);
   19368                 :            :     }
   19369                 :            :   }
   19370         [ #  # ]:          0 :   return status;
   19371                 :            : }
   19372                 :            : 
   19373                 :            : 
   19374                 :          0 : CubitStatus GeometryModifyTool::find_overlap_region(RefEdge *c1,
   19375                 :            :                                                   RefEdge *c2,
   19376                 :            :                                                   RefVertex *v1,
   19377                 :            :                                                   RefVertex *v2,
   19378                 :            :                                                   bool forward_c1,
   19379                 :            :                                                   bool forward_c2,
   19380                 :            :                                                   bool &full_c1,
   19381                 :            :                                                   bool &full_c2,
   19382                 :            :                                                   double &c1_stop_param,
   19383                 :            :                                                   double &c2_stop_param,
   19384                 :            :                                                   double divergence_angle)
   19385                 :            : {
   19386                 :          0 :   CubitStatus status = CUBIT_SUCCESS;
   19387                 :            :   double start_t, end_t, dt, cur_t;
   19388                 :          0 :   int num_segments = 20;
   19389                 :            :   double reverse_multiplier;
   19390                 :          0 :   double divergence_tol = cos(divergence_angle*CUBIT_PI/180.0);
   19391                 :            :   int i;
   19392                 :            : 
   19393         [ #  # ]:          0 :   if(forward_c1 != forward_c2)
   19394                 :          0 :     reverse_multiplier = -1.0;
   19395                 :            :   else
   19396                 :          0 :     reverse_multiplier = 1.0;
   19397                 :            : 
   19398                 :            :   // Start from the projection of v2 onto c1.
   19399         [ #  # ]:          0 :   CubitVector tmp_pos;
   19400 [ #  # ][ #  # ]:          0 :   c1->closest_point_trimmed(v2->coordinates(), tmp_pos);
   19401         [ #  # ]:          0 :   start_t = c1->u_from_position(tmp_pos);
   19402         [ #  # ]:          0 :   if(forward_c1)
   19403                 :            :   {
   19404         [ #  # ]:          0 :     end_t = c1->end_param();
   19405                 :          0 :     dt = (end_t-start_t)/(double)num_segments;
   19406                 :          0 :     cur_t = start_t + dt;
   19407                 :            :   }
   19408                 :            :   else
   19409                 :            :   {
   19410         [ #  # ]:          0 :     end_t = c1->start_param();
   19411                 :          0 :     dt = (end_t-start_t)/(double)num_segments;
   19412                 :          0 :     cur_t = start_t + dt;
   19413                 :            :   }
   19414                 :            :   // Check all of the interior points to see if the tangents
   19415                 :            :   // of the two curves are within tolerance.
   19416                 :          0 :   bool went_past_end_of_c2 = false;
   19417                 :          0 :   bool went_out_of_angle_tolerance = false;
   19418         [ #  # ]:          0 :   for(i=num_segments; i>0; i--)
   19419                 :            : //  for(i=num_segments-1; i>0; i--)
   19420                 :            :   {
   19421         [ #  # ]:          0 :     if(i==1)
   19422                 :            :     {
   19423                 :          0 :       cur_t = end_t;
   19424                 :            :     }
   19425                 :            :     // Evaluate curve 1.
   19426 [ #  # ][ #  # ]:          0 :     CubitVector vec1, vec2, tangent1, tangent2;
         [ #  # ][ #  # ]
   19427         [ #  # ]:          0 :     c1->position_from_u(cur_t, vec1);
   19428         [ #  # ]:          0 :     c1->tangent(vec1, tangent1);
   19429         [ #  # ]:          0 :     tangent1.normalize();
   19430                 :            :     // Project the point to curve 2 and get the tangent.
   19431         [ #  # ]:          0 :     c2->closest_point_trimmed(vec1, vec2);
   19432         [ #  # ]:          0 :     c2->tangent(vec2, tangent2);
   19433         [ #  # ]:          0 :     tangent2.normalize();
   19434 [ #  # ][ #  # ]:          0 :     if(((tangent1 % tangent2) * reverse_multiplier) > divergence_tol)
   19435                 :            :     {
   19436         [ #  # ]:          0 :       CubitVector check_vec = vec2-vec1;
   19437                 :          0 :       double dot_val = 0.0;
   19438 [ #  # ][ #  # ]:          0 :       if(check_vec.length() > 1e-6)
   19439                 :            :       {
   19440         [ #  # ]:          0 :         check_vec.normalize();
   19441         [ #  # ]:          0 :         dot_val = check_vec % tangent2;
   19442                 :            :       }
   19443 [ #  # ][ #  # ]:          0 :       if(dot_val > .001 || dot_val < -.001)
   19444                 :            :       {
   19445                 :          0 :         went_past_end_of_c2 = true;
   19446                 :            :       }
   19447                 :            :       else
   19448                 :            :       {
   19449                 :            :         // If we made it to the end of curve 1 check to see
   19450                 :            :         // if the end of curve 2 is within some tolerance of
   19451                 :            :         // the endpoint of curve 1 and if so set the
   19452                 :            :         // full_c2 flag to true.
   19453         [ #  # ]:          0 :         if(i==1)
   19454                 :            :         {
   19455                 :            :           RefVertex *c1_end, *c2_end;
   19456         [ #  # ]:          0 :           if(forward_c1)
   19457         [ #  # ]:          0 :             c1_end = c1->end_vertex();
   19458                 :            :           else
   19459         [ #  # ]:          0 :             c1_end = c1->start_vertex();
   19460         [ #  # ]:          0 :           if(forward_c2)
   19461         [ #  # ]:          0 :             c2_end = c2->end_vertex();
   19462                 :            :           else
   19463         [ #  # ]:          0 :             c2_end = c2->start_vertex();
   19464         [ #  # ]:          0 :           if(c1_end == c2_end) // verts are already merged
   19465                 :          0 :             full_c2 = true;
   19466                 :            :           else
   19467                 :            :           {
   19468         [ #  # ]:          0 :             CubitVector c2_end_pos;
   19469         [ #  # ]:          0 :             if(forward_c2)
   19470 [ #  # ][ #  # ]:          0 :               c2_end_pos = c2->end_coordinates();
   19471                 :            :             else
   19472 [ #  # ][ #  # ]:          0 :               c2_end_pos = c2->start_coordinates();
   19473 [ #  # ][ #  # ]:          0 :             double dist_sq_1 = (vec1-vec2).length_squared();
   19474 [ #  # ][ #  # ]:          0 :             double dist_sq_2 = (vec1-c2_end_pos).length_squared();
   19475         [ #  # ]:          0 :             if(dist_sq_2 < 2.25*dist_sq_1)
   19476                 :          0 :               full_c2 = true;
   19477                 :            :           }
   19478                 :            :         }
   19479                 :            :       }
   19480                 :            :     }
   19481                 :            :     else
   19482                 :            :     {
   19483                 :          0 :       went_out_of_angle_tolerance = true;
   19484                 :            :     }
   19485         [ #  # ]:          0 :     if(went_past_end_of_c2)
   19486                 :            :     {
   19487                 :          0 :       i=0;
   19488                 :          0 :       full_c2 = true;
   19489                 :          0 :       c1_stop_param = cur_t;
   19490                 :            :       // calculate split point on curve 1
   19491                 :            :     }
   19492         [ #  # ]:          0 :     else if(went_out_of_angle_tolerance)
   19493                 :            :     {
   19494         [ #  # ]:          0 :       if(i==num_segments)
   19495                 :          0 :         status = CUBIT_FAILURE;
   19496                 :          0 :       i=0;
   19497                 :          0 :       c1_stop_param = cur_t;
   19498         [ #  # ]:          0 :       c2_stop_param = c2->u_from_position(vec2);
   19499                 :            :     }
   19500                 :            : 
   19501                 :          0 :     cur_t += dt;
   19502                 :            :   }
   19503                 :            : 
   19504         [ #  # ]:          0 :   if(i==0)
   19505                 :            :   {
   19506                 :          0 :     full_c1 = true;
   19507                 :            :   }
   19508                 :            : 
   19509                 :          0 :   return status;
   19510                 :            : }
   19511                 :            : 
   19512                 :          0 : CubitStatus GeometryModifyTool::match_v1_to_c1(RefVertex *&v1,
   19513                 :            :                                              RefVertex *&v2,
   19514                 :            :                                              RefVertex *c1_v1,
   19515                 :            :                                              RefVertex *c1_v2,
   19516                 :            :                                              RefVertex *c2_v1,
   19517                 :            :                                              RefVertex *c2_v2)
   19518                 :            : {
   19519                 :          0 :   CubitStatus status = CUBIT_SUCCESS;
   19520                 :            : 
   19521 [ #  # ][ #  # ]:          0 :   if(v1 == c1_v1 || v1 == c1_v2)
   19522                 :            :   {
   19523 [ #  # ][ #  # ]:          0 :     if(v2 == c2_v1 || v2 == c2_v2)
   19524                 :            :     {
   19525                 :            :       // everything is fine
   19526                 :            :     }
   19527                 :            :     else
   19528                 :          0 :       status = CUBIT_FAILURE;
   19529                 :            :   }
   19530 [ #  # ][ #  # ]:          0 :   else if(v1 == c2_v1 || v1 == c2_v2)
   19531                 :            :   {
   19532 [ #  # ][ #  # ]:          0 :     if(v2 == c1_v1 || v2 == c1_v2)
   19533                 :            :     {
   19534                 :          0 :       RefVertex *tmp = v1;
   19535                 :          0 :       v1 = v2;
   19536                 :          0 :       v2 = tmp;
   19537                 :            :     }
   19538                 :            :     else
   19539                 :          0 :       status = CUBIT_FAILURE;
   19540                 :            :   }
   19541                 :            :   else
   19542                 :          0 :     status = CUBIT_FAILURE;
   19543                 :            : 
   19544                 :          0 :   return status;
   19545                 :            : }
   19546                 :            : 
   19547                 :          0 : CubitStatus GeometryModifyTool::calculate_split_points_for_merge(RefEdge* c1,
   19548                 :            :                                                                RefEdge* c2,
   19549                 :            :                                                                DLIList<RefVertex*> &verts_to_merge,
   19550                 :            :                                                                double *merge_tolerance,
   19551                 :            :                                                                DLIList<CubitVector> &merge_end_points_on_curve1,
   19552                 :            :                                                                DLIList<CubitVector> &merge_end_points_on_curve2,
   19553                 :            :                                                                DLIList<CubitBoolean> &split_flags_for_curve1,
   19554                 :            :                                                                DLIList<CubitBoolean> &split_flags_for_curve2,
   19555                 :            :                                                                double divergence_angle)
   19556                 :            : {
   19557                 :            : 
   19558                 :          0 :   CubitStatus status = CUBIT_SUCCESS;
   19559                 :          0 :   bool all_done = false;
   19560                 :            : 
   19561                 :            :   // Get the vertices of the two curves.
   19562         [ #  # ]:          0 :   RefVertex *c1_v1 = c1->start_vertex();
   19563         [ #  # ]:          0 :   RefVertex *c1_v2 = c1->end_vertex();
   19564         [ #  # ]:          0 :   RefVertex *c2_v1 = c2->start_vertex();
   19565         [ #  # ]:          0 :   RefVertex *c2_v2 = c2->end_vertex();
   19566                 :            : 
   19567                 :            :   // Check for closed curves.
   19568                 :          0 :   bool c1_closed = false;
   19569         [ #  # ]:          0 :   if(c1_v1 == c1_v2)
   19570                 :          0 :     c1_closed = true;
   19571                 :          0 :   bool merge_verts_at_both_ends = false;
   19572                 :            : 
   19573                 :            :   // If we are told that certain vertices need to merge
   19574                 :            :   // we will know that we do not need to split the curves there.
   19575                 :          0 :   bool full_c1=false, full_c2=false;
   19576         [ #  # ]:          0 :   int verts_to_merge_size = verts_to_merge.size();
   19577                 :            :   RefVertex *v1, *v2;
   19578         [ #  # ]:          0 :   if(verts_to_merge_size > 0)
   19579                 :            :   {
   19580                 :            :     // Verts to merge should always come in pairs.
   19581         [ #  # ]:          0 :     if(verts_to_merge_size % 2 != 0)
   19582                 :            :     {
   19583                 :          0 :       status = CUBIT_FAILURE;
   19584                 :            :     }
   19585                 :            :     else
   19586                 :            :     {
   19587 [ #  # ][ #  # ]:          0 :       if(verts_to_merge_size > 2 || c1_closed)
   19588                 :          0 :         merge_verts_at_both_ends = true;
   19589                 :            : 
   19590         [ #  # ]:          0 :       verts_to_merge.reset();
   19591                 :            :       // Process the first set of verts to merge.
   19592         [ #  # ]:          0 :       v1 = verts_to_merge.get_and_step();
   19593         [ #  # ]:          0 :       v2 = verts_to_merge.get_and_step();
   19594                 :            :       // Make sure v1 corresponds to c1 and v2 to c2.
   19595         [ #  # ]:          0 :       status = match_v1_to_c1(v1, v2, c1_v1, c1_v2, c2_v1, c2_v2);
   19596                 :            :     }
   19597         [ #  # ]:          0 :     if(status == CUBIT_SUCCESS)
   19598                 :            :     {
   19599                 :            :       // Determine whether the verts are at the
   19600                 :            :       // beginning or end of curves.
   19601                 :            :       bool forward_c1, forward_c2;
   19602         [ #  # ]:          0 :       if(v1 == c1_v1)
   19603                 :          0 :         forward_c1 = true;
   19604                 :            :       else
   19605                 :          0 :         forward_c1 = false;
   19606         [ #  # ]:          0 :       if(v2 == c2_v1)
   19607                 :          0 :         forward_c2 = true;
   19608                 :            :       else
   19609                 :          0 :         forward_c2 = false;
   19610                 :            : 
   19611                 :            :       double c1_stop_param, c2_stop_param;
   19612                 :            : 
   19613                 :            :       status = find_overlap_region(c1, c2, v1, v2, forward_c1, forward_c2, full_c1, full_c2,
   19614         [ #  # ]:          0 :         c1_stop_param, c2_stop_param, divergence_angle);
   19615                 :            : 
   19616         [ #  # ]:          0 :       if(status == CUBIT_SUCCESS)
   19617                 :            :       {
   19618 [ #  # ][ #  # ]:          0 :         merge_end_points_on_curve1.append(v1->coordinates());
   19619 [ #  # ][ #  # ]:          0 :         merge_end_points_on_curve2.append(v2->coordinates());
   19620         [ #  # ]:          0 :         split_flags_for_curve1.append(CUBIT_FALSE);
   19621         [ #  # ]:          0 :         split_flags_for_curve2.append(CUBIT_FALSE);
   19622                 :            : 
   19623                 :            :         // If we traversed the whole length of either curve and
   19624                 :            :         // we are told to merge the verts at both ends then
   19625                 :            :         // just add the verts at the other end and be done.
   19626 [ #  # ][ #  # ]:          0 :         if((full_c1 || full_c2) && merge_verts_at_both_ends)
                 [ #  # ]
   19627                 :            :         {
   19628         [ #  # ]:          0 :           split_flags_for_curve1.append(CUBIT_FALSE);
   19629         [ #  # ]:          0 :           split_flags_for_curve2.append(CUBIT_FALSE);
   19630         [ #  # ]:          0 :           if(c1_v1 == v1)
   19631 [ #  # ][ #  # ]:          0 :             merge_end_points_on_curve1.append(c1_v2->coordinates());
   19632                 :            :           else
   19633 [ #  # ][ #  # ]:          0 :             merge_end_points_on_curve1.append(c1_v1->coordinates());
   19634         [ #  # ]:          0 :           if(c2_v1 == v2)
   19635 [ #  # ][ #  # ]:          0 :             merge_end_points_on_curve2.append(c2_v2->coordinates());
   19636                 :            :           else
   19637 [ #  # ][ #  # ]:          0 :             merge_end_points_on_curve2.append(c2_v1->coordinates());
   19638                 :          0 :           all_done = true;
   19639                 :            :         }
   19640                 :            :         else
   19641                 :            :         {
   19642         [ #  # ]:          0 :           if(full_c2)
   19643                 :            :           {
   19644                 :            :             RefVertex *tmp_vert;
   19645         [ #  # ]:          0 :             if(c2_v1 == v2)
   19646                 :          0 :               tmp_vert = c2_v2;
   19647                 :            :             else
   19648                 :          0 :               tmp_vert = c2_v1;
   19649 [ #  # ][ #  # ]:          0 :             merge_end_points_on_curve2.append(tmp_vert->coordinates());
   19650         [ #  # ]:          0 :             split_flags_for_curve2.append(CUBIT_FALSE);
   19651         [ #  # ]:          0 :             if(!full_c1)
   19652                 :            :             {
   19653         [ #  # ]:          0 :               CubitVector pos1;
   19654 [ #  # ][ #  # ]:          0 :               c1->closest_point_trimmed(tmp_vert->coordinates(), pos1);
   19655         [ #  # ]:          0 :               merge_end_points_on_curve1.append(pos1);
   19656         [ #  # ]:          0 :               split_flags_for_curve1.append(CUBIT_TRUE);
   19657                 :            :             }
   19658                 :            :             else
   19659                 :            :             {
   19660         [ #  # ]:          0 :               if(c1_v1 == v1)
   19661 [ #  # ][ #  # ]:          0 :                 merge_end_points_on_curve1.append(c1_v2->coordinates());
   19662                 :            :               else
   19663 [ #  # ][ #  # ]:          0 :                 merge_end_points_on_curve1.append(c1_v1->coordinates());
   19664         [ #  # ]:          0 :               split_flags_for_curve1.append(CUBIT_FALSE);
   19665                 :            :             }
   19666                 :            :           }
   19667                 :            :           else
   19668                 :            :           {
   19669         [ #  # ]:          0 :             split_flags_for_curve2.append(CUBIT_TRUE);
   19670         [ #  # ]:          0 :             if(full_c1)
   19671                 :            :             {
   19672         [ #  # ]:          0 :               split_flags_for_curve1.append(CUBIT_FALSE);
   19673         [ #  # ]:          0 :               if(c1_v1 == v1)
   19674                 :            :               {
   19675 [ #  # ][ #  # ]:          0 :                 merge_end_points_on_curve1.append(c1_v2->coordinates());
   19676                 :            :                 // we need to imprint the end of c1 onto c2.
   19677         [ #  # ]:          0 :                 CubitVector pos2;
   19678 [ #  # ][ #  # ]:          0 :                 c2->closest_point_trimmed(c1_v2->coordinates(), pos2);
   19679         [ #  # ]:          0 :                 merge_end_points_on_curve2.append(pos2);
   19680                 :            :               }
   19681                 :            :               else
   19682                 :            :               {
   19683 [ #  # ][ #  # ]:          0 :                 merge_end_points_on_curve1.append(c1_v1->coordinates());
   19684                 :            :                 // we need to imprint the end of c1 onto c2.
   19685         [ #  # ]:          0 :                 CubitVector pos2;
   19686 [ #  # ][ #  # ]:          0 :                 c2->closest_point_trimmed(c1_v1->coordinates(), pos2);
   19687         [ #  # ]:          0 :                 merge_end_points_on_curve2.append(pos2);
   19688                 :            :               }
   19689                 :            :             }
   19690                 :            :             else
   19691                 :            :             {
   19692         [ #  # ]:          0 :               split_flags_for_curve1.append(CUBIT_TRUE);
   19693                 :            :               // we need to imprint the end of c2 onto c1.
   19694         [ #  # ]:          0 :               CubitVector pos1;
   19695         [ #  # ]:          0 :               c1->position_from_u(c1_stop_param, pos1);
   19696         [ #  # ]:          0 :               merge_end_points_on_curve1.append(pos1);
   19697                 :            :               // we need to imprint the end of c1 onto c2.
   19698         [ #  # ]:          0 :               CubitVector pos2;
   19699         [ #  # ]:          0 :               c2->closest_point_trimmed(pos1, pos2);
   19700         [ #  # ]:          0 :               merge_end_points_on_curve2.append(pos2);
   19701                 :            :             }
   19702                 :            :           }
   19703                 :            :         }
   19704                 :            :       }
   19705                 :            :     }
   19706 [ #  # ][ #  # ]:          0 :     if(status == CUBIT_SUCCESS && !all_done)
   19707                 :            :     {
   19708         [ #  # ]:          0 :       if(merge_verts_at_both_ends)
   19709                 :            :       {
   19710                 :            :         // Process the next set of verts to merge.
   19711         [ #  # ]:          0 :         v1 = verts_to_merge.get_and_step();
   19712         [ #  # ]:          0 :         v2 = verts_to_merge.get_and_step();
   19713                 :            :         // Make sure v1 corresponds to c1 and v2 to c2.
   19714         [ #  # ]:          0 :         status = match_v1_to_c1(v1, v2, c1_v1, c1_v2, c2_v1, c2_v2);
   19715         [ #  # ]:          0 :         if(status == CUBIT_SUCCESS)
   19716                 :            :         {
   19717                 :            :           // Determine whether the verts are at the
   19718                 :            :           // beginning or end of curves.
   19719                 :            :           bool forward_c1, forward_c2;
   19720         [ #  # ]:          0 :           if(v1 == c1_v1)
   19721                 :          0 :             forward_c1 = true;
   19722                 :            :           else
   19723                 :          0 :             forward_c1 = false;
   19724         [ #  # ]:          0 :           if(v2 == c2_v1)
   19725                 :          0 :             forward_c2 = true;
   19726                 :            :           else
   19727                 :          0 :             forward_c2 = false;
   19728                 :            : 
   19729                 :            :           double c1_stop_param, c2_stop_param;
   19730                 :          0 :           bool full_c1=false, full_c2=false;
   19731                 :            : 
   19732                 :            :           status = find_overlap_region(c1, c2, v1, v2, forward_c1, forward_c2, full_c1, full_c2,
   19733         [ #  # ]:          0 :             c1_stop_param, c2_stop_param, divergence_angle);
   19734         [ #  # ]:          0 :           if(status == CUBIT_SUCCESS)
   19735                 :            :           {
   19736 [ #  # ][ #  # ]:          0 :             merge_end_points_on_curve1.append(v1->coordinates());
   19737 [ #  # ][ #  # ]:          0 :             merge_end_points_on_curve2.append(v2->coordinates());
   19738         [ #  # ]:          0 :             split_flags_for_curve1.append(CUBIT_FALSE);
   19739         [ #  # ]:          0 :             split_flags_for_curve2.append(CUBIT_FALSE);
   19740         [ #  # ]:          0 :             split_flags_for_curve1.append(CUBIT_TRUE);
   19741         [ #  # ]:          0 :             split_flags_for_curve2.append(CUBIT_TRUE);
   19742                 :            :             // we need to imprint the end of c2 onto c1.
   19743         [ #  # ]:          0 :             CubitVector pos1;
   19744         [ #  # ]:          0 :             c1->position_from_u(c1_stop_param, pos1);
   19745         [ #  # ]:          0 :             merge_end_points_on_curve1.append(pos1);
   19746                 :            :             // we need to imprint the end of c1 onto c2.
   19747         [ #  # ]:          0 :             CubitVector pos2;
   19748         [ #  # ]:          0 :             c2->position_from_u(c2_stop_param, pos2);
   19749         [ #  # ]:          0 :             merge_end_points_on_curve2.append(pos2);
   19750                 :            :           }
   19751                 :            :         }
   19752                 :            :       }
   19753                 :            :     }
   19754                 :            :   }
   19755                 :            : 
   19756                 :            :   if(status == CUBIT_SUCCESS)
   19757                 :            :   {
   19758                 :            :   }
   19759                 :            : 
   19760                 :          0 :   return status;
   19761                 :            : }
   19762                 :            : 
   19763                 :          0 : CubitStatus GeometryModifyTool::tolerant_imprint( DLIList<Body*> &bodies,
   19764                 :            :                                       DLIList<Body*> &new_bodies, double overlap_tol,
   19765                 :            :                                       double imprint_tol, bool merge )
   19766                 :            : {
   19767                 :            :   //make sure all bodies are from the same modify engine
   19768         [ #  # ]:          0 :   DLIList<BodySM*> body_sm_list;
   19769         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine(bodies, body_sm_list);
   19770         [ #  # ]:          0 :   if ( !gme )
   19771                 :            :   {
   19772 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Performing IMPRINT with volumes containing geometry\n"
                 [ #  # ]
   19773                 :            :                 "from different modeling engines is not allowed.\n"
   19774         [ #  # ]:          0 :                 "Delete uncommon geometry on these volumes before operation.\n\n");
   19775                 :          0 :     return CUBIT_FAILURE;
   19776                 :            :   }
   19777                 :            : 
   19778                 :            : 
   19779                 :            :   //make sure that merge tolerance is not inapproiate for model
   19780                 :            :   int i;
   19781                 :            :   CubitBox bounding_box( CubitVector(0,0,0),
   19782                 :            :                          CubitVector(CUBIT_DBL_MAX,
   19783                 :            :                                      CUBIT_DBL_MAX,
   19784 [ #  # ][ #  # ]:          0 :                                      CUBIT_DBL_MAX ) );
         [ #  # ][ #  # ]
   19785 [ #  # ][ #  # ]:          0 :   for( i=bodies.size(); i--; )
   19786                 :            :   {
   19787 [ #  # ][ #  # ]:          0 :     CubitBox tmp_box = bodies.get_and_step()->bounding_box();
   19788 [ #  # ][ #  # ]:          0 :     if(bounding_box.max_x() == CUBIT_DBL_MAX)
   19789         [ #  # ]:          0 :       bounding_box = tmp_box;
   19790 [ #  # ][ #  # ]:          0 :     else if( tmp_box.diagonal().length_squared() <
                 [ #  # ]
   19791 [ #  # ][ #  # ]:          0 :         bounding_box.diagonal().length_squared() )
   19792         [ #  # ]:          0 :       bounding_box = tmp_box;
   19793         [ #  # ]:          0 :   }
   19794                 :            : 
   19795                 :            :   //get the merge tolerance
   19796         [ #  # ]:          0 :   double tolerance = GeometryQueryTool::get_geometry_factor()*GEOMETRY_RESABS;
   19797                 :            : 
   19798                 :            :   //if the merge tolerance is greater than 1/10th the length of the
   19799                 :            :   //diagonal of the bounding box of the smallest volume, fail!
   19800 [ #  # ][ #  # ]:          0 :   double tenth_smallest_bbox = 0.1*(bounding_box.diagonal().length());
   19801         [ #  # ]:          0 :   if( tolerance > tenth_smallest_bbox )
   19802                 :            :   {
   19803 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Merge tolerance is set excessively high.  Must be lower than %f\n",
                 [ #  # ]
   19804         [ #  # ]:          0 :                  tenth_smallest_bbox );
   19805 [ #  # ][ #  # ]:          0 :     PRINT_INFO("       (Merge tolerance must be less than than 1/10th of the diagonal\n"
                 [ #  # ]
   19806         [ #  # ]:          0 :                         "of the bounding box of the smallest volume)\n");
   19807                 :          0 :     return CUBIT_FAILURE;
   19808                 :            :   }
   19809                 :            : 
   19810 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   19811         [ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies );
   19812                 :            : 
   19813                 :            :   // Propagate any merge tolerances on the bodies
   19814                 :            : //  propagate_merge_tolerance(bodies);
   19815                 :            : 
   19816                 :            :   // Push the tolerance attributes
   19817                 :            : //  push_tolerance_attribute(bodies);
   19818                 :            : 
   19819         [ #  # ]:          0 :   body_sm_list.clean_out();
   19820 [ #  # ][ #  # ]:          0 :   DLIList<Body*> old_body_list;
   19821         [ #  # ]:          0 :   old_body_list += bodies;
   19822         [ #  # ]:          0 :   bodies.reset();
   19823 [ #  # ][ #  # ]:          0 :   for( i=bodies.size(); i--; )
   19824 [ #  # ][ #  # ]:          0 :     body_sm_list.append( bodies.get_and_step()->get_body_sm_ptr() );
                 [ #  # ]
   19825                 :            : 
   19826                 :          0 :   int process_composites = 0;
   19827 [ #  # ][ #  # ]:          0 :   if(contains_composites(bodies))
   19828                 :          0 :     process_composites = 1;
   19829                 :            : 
   19830         [ #  # ]:          0 :   if(process_composites)
   19831                 :            :   {
   19832                 :            :     // Push virtual attributes down to solid model topology before
   19833                 :            :     // doing the imprint.
   19834         [ #  # ]:          0 :     do_attribute_setup();
   19835         [ #  # ]:          0 :     push_attributes_before_modify(body_sm_list);
   19836                 :            :     // This must be done after pushing the vg atts because it uses them.
   19837         [ #  # ]:          0 :     DLIList<TopologyBridge*> tb_list;
   19838 [ #  # ][ #  # ]:          0 :     CAST_LIST(body_sm_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   19839         [ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tb_list, "IMPRINTER");
   19840 [ #  # ][ #  # ]:          0 :     push_named_attributes_to_curves_and_points(tb_list, "ORIGINAL");
   19841                 :            :   }
   19842                 :            : 
   19843 [ #  # ][ #  # ]:          0 :   if (DEBUG_FLAG(95))
                 [ #  # ]
   19844                 :            :   {
   19845 [ #  # ][ #  # ]:          0 :     PRINT_DEBUG_95( "Calculating local tolerances for tolerant imprinting.\n");
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   19846                 :            : 
   19847                 :            : //#ifndef _NDEBUG
   19848                 :            : //    LocalToleranceTool::instance()->print_local_tolerances( body_sm_list );
   19849                 :            : //#endif
   19850                 :            : 
   19851                 :            :     // Calculate local tolerances at ref entities
   19852 [ #  # ][ #  # ]:          0 :     LocalToleranceTool::instance()->calculate_local_tolerances( body_sm_list );
         [ #  # ][ #  # ]
   19853                 :            : 
   19854                 :            : //#ifndef _NDEBUG
   19855                 :            : //    LocalToleranceTool::instance()->print_local_tolerances( body_sm_list );
   19856                 :            : //#endif
   19857                 :            :   }
   19858                 :            : 
   19859                 :            :   // Call tolerant imprint
   19860 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_body_list;
   19861         [ #  # ]:          0 :   CubitStatus result = gme->tolerant_imprint( body_sm_list, new_body_list, overlap_tol, imprint_tol);
   19862                 :            : 
   19863                 :            : 
   19864         [ #  # ]:          0 :   if(result == CUBIT_FAILURE)
   19865                 :            :   {
   19866         [ #  # ]:          0 :     if(process_composites)
   19867                 :            :     {
   19868         [ #  # ]:          0 :       remove_pushed_attributes(new_body_list, bodies);
   19869         [ #  # ]:          0 :       do_attribute_cleanup();
   19870                 :            :     }
   19871                 :          0 :     return result;
   19872                 :            :   }
   19873                 :            :   else
   19874                 :            :   {
   19875         [ #  # ]:          0 :     if(process_composites)
   19876                 :            :     {
   19877                 :            :       // Analyze the results and adjust virtual attributes as necessary.
   19878         [ #  # ]:          0 :        DLIList<TopologyBridge*> tb_list;
   19879 [ #  # ][ #  # ]:          0 :        CAST_LIST(new_body_list, tb_list, TopologyBridge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   19880 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->ige_attribute_after_imprinting(tb_list, bodies);
   19881                 :            : 
   19882                 :            :       // Clean up attributes.
   19883         [ #  # ]:          0 :       remove_imprint_attributes_after_modify(body_sm_list, new_body_list);
   19884                 :            : 
   19885                 :            :       // Restore the virtual geometry.
   19886         [ #  # ]:          0 :       restore_vg_after_modify(new_body_list, bodies, gme);
   19887 [ #  # ][ #  # ]:          0 :       remove_pushed_attributes(new_body_list, bodies);
   19888                 :            :     }
   19889                 :            :   }
   19890                 :            : 
   19891                 :            :   // RANDY - HACK!!
   19892                 :            :   //for (int i = new_body_list.size(); i--;)
   19893                 :            :   //{
   19894                 :            :   //  clean_up_from_copy_failure(new_body_list.get_and_step());
   19895                 :            :   //}
   19896                 :            : 
   19897         [ #  # ]:          0 :   result = finish_sm_op( bodies, body_sm_list, new_bodies );
   19898                 :            : 
   19899         [ #  # ]:          0 :   if(process_composites)
   19900         [ #  # ]:          0 :     do_attribute_cleanup();
   19901                 :            : 
   19902         [ #  # ]:          0 :   if(result == CUBIT_FAILURE)
   19903                 :            :   {
   19904 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   19905         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   19906                 :          0 :     return CUBIT_FAILURE;
   19907                 :            :   }
   19908                 :            : 
   19909         [ #  # ]:          0 :   if( merge )
   19910 [ #  # ][ #  # ]:          0 :     MergeTool::instance()->merge_bodies( bodies );
   19911                 :            : 
   19912         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   19913                 :            : }
   19914                 :            : 
   19915                 :          0 : CubitStatus GeometryModifyTool::remove_curve_slivers( DLIList<Body*> &bodies,
   19916                 :            :                                               double lengthlimit )
   19917                 :            : {
   19918         [ #  # ]:          0 :   DLIList<BodySM*> body_sm_list;
   19919         [ #  # ]:          0 :   GeometryModifyEngine* gme = common_modify_engine(bodies, body_sm_list);
   19920         [ #  # ]:          0 :   if ( !gme )
   19921                 :            :   {
   19922 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Curve sliver removal only supported on  geometry\n");
         [ #  # ][ #  # ]
   19923                 :          0 :     return CUBIT_FAILURE;
   19924                 :            :   }
   19925                 :            : 
   19926 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   19927         [ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies );
   19928                 :            : 
   19929                 :          0 :   CubitStatus status = CUBIT_FAILURE;
   19930 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> modified_bodies;
   19931                 :            :   int i;
   19932 [ #  # ][ #  # ]:          0 :   for( i=body_sm_list.size(); i--; )
   19933                 :            :   {
   19934         [ #  # ]:          0 :     BodySM *tmp_body_sm = body_sm_list.get_and_step();
   19935 [ #  # ][ #  # ]:          0 :     if( gme->remove_curve_slivers( tmp_body_sm, lengthlimit ) == CUBIT_SUCCESS )
   19936                 :            :     {
   19937         [ #  # ]:          0 :       modified_bodies.append( tmp_body_sm );
   19938                 :          0 :       status = CUBIT_SUCCESS;
   19939                 :            :     }
   19940                 :            :   }
   19941                 :            : 
   19942         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   19943                 :            :   {
   19944 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("Did not remove any sliver curves\n");
         [ #  # ][ #  # ]
   19945 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   19946         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   19947                 :          0 :     return CUBIT_FAILURE;
   19948                 :            :   }
   19949                 :            : 
   19950 [ #  # ][ #  # ]:          0 :   DLIList<Body*> dummy_list;
   19951         [ #  # ]:          0 :   status = finish_sm_op( bodies, modified_bodies, dummy_list );
   19952         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   19953                 :            :   {
   19954 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("Did not remove any sliver curves\n");
         [ #  # ][ #  # ]
   19955 [ #  # ][ #  # ]:          0 :     if( CubitUndo::get_undo_enabled() )
   19956         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   19957                 :          0 :     return CUBIT_SUCCESS;
   19958                 :            :   }
   19959                 :            : 
   19960         [ #  # ]:          0 :   return status;
   19961                 :            : }
   19962                 :            : 
   19963                 :          0 : void GeometryModifyTool::split_surface_with_narrow_region(RefFace *face,
   19964                 :            :                                                       DLIList<CubitVector> &split_pos1_list,
   19965                 :            :                                                       DLIList<CubitVector> &split_pos2_list)
   19966                 :            : {
   19967                 :            :   int k;
   19968         [ #  # ]:          0 :   if(split_pos1_list.size() > 0)
   19969                 :            :   {
   19970         [ #  # ]:          0 :     DLIList<DLIList<CubitVector*>*> vec_lists;
   19971 [ #  # ][ #  # ]:          0 :     DLIList<CubitVector*> pt_list;
   19972 [ #  # ][ #  # ]:          0 :     for(k=split_pos1_list.size(); k--;)
   19973                 :            :     {
   19974 [ #  # ][ #  # ]:          0 :       CubitVector split_pos1 = split_pos1_list.get_and_step();
   19975 [ #  # ][ #  # ]:          0 :       CubitVector split_pos2 = split_pos2_list.get_and_step();
   19976         [ #  # ]:          0 :       face->move_to_surface(split_pos1);
   19977         [ #  # ]:          0 :       face->move_to_surface(split_pos2);
   19978 [ #  # ][ #  # ]:          0 :       DLIList<CubitVector*> *vec_list = new DLIList<CubitVector*>;
   19979 [ #  # ][ #  # ]:          0 :       vec_list->append( new CubitVector(split_pos1));
                 [ #  # ]
   19980 [ #  # ][ #  # ]:          0 :       vec_list->append( new CubitVector(split_pos2));
                 [ #  # ]
   19981         [ #  # ]:          0 :       vec_lists.append( vec_list );
   19982                 :            :     }
   19983                 :            : 
   19984                 :            :     GeometryModifyTool::instance()->split_surface(face,
   19985 [ #  # ][ #  # ]:          0 :       pt_list, vec_lists );
   19986                 :            : 
   19987 [ #  # ][ #  # ]:          0 :     while( vec_lists.size() )
   19988                 :            :     {
   19989         [ #  # ]:          0 :       DLIList<CubitVector*> *vec_list = vec_lists.pop();
   19990 [ #  # ][ #  # ]:          0 :       while( vec_list->size() ) delete vec_list->pop();
                 [ #  # ]
   19991 [ #  # ][ #  # ]:          0 :       delete vec_list;
   19992         [ #  # ]:          0 :     }
   19993                 :            :     /*
   19994                 :            :     while( pt_list.size() )
   19995                 :            :       delete( pt_list.pop() );
   19996                 :            :       */
   19997                 :            :   }
   19998                 :          0 : }
   19999                 :            : 
   20000                 :        195 : void GeometryModifyTool::fixup_merged_entities( DLIList<int> &merged_surface_ids,
   20001                 :            :                                                 DLIList<int> &merged_curve_ids ) const
   20002                 :            : {
   20003                 :            :   //use ids to find surviving merged entities
   20004         [ +  - ]:        195 :   DLIList<RefFace*> ref_face_list;
   20005 [ +  - ][ +  - ]:        390 :   DLIList<RefEdge*> ref_edge_list;
   20006                 :            : 
   20007                 :            :   int i;
   20008                 :            :   //see what merged survived operation
   20009 [ +  - ][ -  + ]:        195 :   for( i=merged_surface_ids.size(); i--; )
   20010                 :            :   {
   20011         [ #  # ]:          0 :     int face_id = merged_surface_ids.get_and_step();
   20012 [ #  # ][ #  # ]:          0 :     RefFace *surviving_merged_face = RefEntityFactory::instance()->get_ref_face( face_id );
   20013         [ #  # ]:          0 :     if( surviving_merged_face )
   20014         [ #  # ]:          0 :       ref_face_list.append( surviving_merged_face );
   20015                 :            :   }
   20016                 :            : 
   20017                 :            :   //see what merged survived operation
   20018 [ +  - ][ -  + ]:        195 :   for( i=merged_curve_ids.size(); i--; )
   20019                 :            :   {
   20020         [ #  # ]:          0 :     int edge_id = merged_curve_ids.get_and_step();
   20021 [ #  # ][ #  # ]:          0 :     RefEdge *surviving_merged_edge = RefEntityFactory::instance()->get_ref_edge( edge_id );
   20022         [ #  # ]:          0 :     if( surviving_merged_edge )
   20023         [ #  # ]:          0 :       ref_edge_list.append( surviving_merged_edge );
   20024                 :            :   }
   20025                 :            : 
   20026                 :            :   //fix up merged faces -- some might need to be reversed
   20027 [ +  - ][ -  + ]:        195 :   for(i=ref_face_list.size(); i--; )
   20028                 :            :   {
   20029         [ #  # ]:          0 :     RefFace *merged_face = ref_face_list.get_and_step();
   20030                 :          0 :     BasicTopologyEntity *bte = static_cast<BasicTopologyEntity*>(merged_face);
   20031                 :            : 
   20032                 :            :     //get the first bridge of the entity
   20033         [ #  # ]:          0 :     DLIList<TopologyBridge*> face_bridge_list;
   20034 [ #  # ][ #  # ]:          0 :     bte->bridge_manager()->get_bridge_list( face_bridge_list );
   20035                 :            : 
   20036                 :            :     //if there are 2 bridges in the list, it's still merged...do nothing
   20037 [ #  # ][ #  # ]:          0 :     if( face_bridge_list.size() > 1 )
   20038                 :          0 :       continue;
   20039                 :            : 
   20040                 :            :     //get the center of the RefFace
   20041         [ #  # ]:          0 :     CubitVector center = merged_face->center_point();
   20042                 :            : 
   20043                 :            :     //get the normal according to the RefFace
   20044         [ #  # ]:          0 :     CubitVector ref_face_normal = merged_face->normal_at( center );
   20045                 :            : 
   20046                 :            :     //get the normal at the center from the underlying Surface
   20047 [ #  # ][ #  # ]:          0 :     Surface *surface_ptr = CAST_TO( face_bridge_list.get(), Surface );
   20048         [ #  # ]:          0 :     CubitVector surface_normal;
   20049         [ #  # ]:          0 :     surface_ptr->closest_point( center, NULL, &surface_normal );
   20050                 :            : 
   20051                 :            :     //if normals are opposite, flip sense of surface_ptr
   20052 [ #  # ][ #  # ]:          0 :     if( fabs(ref_face_normal.interior_angle( surface_normal ) - 180 ) < 0.1  )
   20053         [ #  # ]:          0 :       merged_face->reverse_normal();
   20054                 :            : 
   20055                 :            :     //One more thing.....if surface is a composite, update the graphics
   20056                 :            :     //on the hidden curve...could have been deleted.
   20057 [ #  # ][ #  # ]:          0 :     if ( GeometryQueryTool::instance()->ige_is_composite( surface_ptr ) )
                 [ #  # ]
   20058 [ #  # ][ #  # ]:          0 :       AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_MODIFIED, merged_face));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   20059                 :          0 :   }
   20060                 :            : 
   20061                 :            :   //fix up merged edges -- some might need to be reversed
   20062 [ +  - ][ -  + ]:        195 :   for(i=ref_edge_list.size(); i--; )
   20063                 :            :   {
   20064         [ #  # ]:          0 :     RefEdge *merged_edge = ref_edge_list.get_and_step();
   20065                 :          0 :     BasicTopologyEntity *bte = static_cast<BasicTopologyEntity*>(merged_edge);
   20066                 :            : 
   20067                 :            :     //get the first bridge of the entity
   20068         [ #  # ]:          0 :     DLIList<TopologyBridge*> edge_bridge_list;
   20069 [ #  # ][ #  # ]:          0 :     bte->bridge_manager()->get_bridge_list( edge_bridge_list );
   20070                 :            : 
   20071                 :            :     //get start/end points of the edge
   20072 [ #  # ][ #  # ]:          0 :     CubitVector edge_start_point = merged_edge->start_vertex()->coordinates();
   20073 [ #  # ][ #  # ]:          0 :     CubitVector edge_end_point = merged_edge->end_vertex()->coordinates();
   20074                 :            : 
   20075                 :            :     //get start/end point of the curve
   20076         [ #  # ]:          0 :     edge_bridge_list.reset();
   20077 [ #  # ][ #  # ]:          0 :     Curve *curve_ptr = CAST_TO( edge_bridge_list.get(), Curve);
   20078 [ #  # ][ #  # ]:          0 :     DLIList<TBPoint*> tmp_points;
                 [ #  # ]
   20079         [ #  # ]:          0 :     curve_ptr->points( tmp_points );
   20080 [ #  # ][ #  # ]:          0 :     CubitVector curve_start_point = tmp_points.get_and_step()->coordinates();
   20081 [ #  # ][ #  # ]:          0 :     CubitVector curve_end_point = tmp_points.get_and_step()->coordinates();
   20082                 :            : 
   20083                 :            :     //check to see if curve sense needs to be reversed
   20084 [ #  # ][ #  # ]:          0 :     if( edge_start_point.distance_between( curve_start_point ) < GEOMETRY_RESABS &&
         [ #  # ][ #  # ]
   20085         [ #  # ]:          0 :           edge_end_point.distance_between( curve_end_point ) < GEOMETRY_RESABS )
   20086                 :            :     {
   20087                 :            :       //do nothing...everything is fine
   20088                 :          0 :       continue;
   20089                 :            :     }
   20090                 :            :     else
   20091                 :            :     {
   20092 [ #  # ][ #  # ]:          0 :       if( edge_start_point.distance_between( curve_end_point ) < GEOMETRY_RESABS &&
         [ #  # ][ #  # ]
   20093         [ #  # ]:          0 :             edge_end_point.distance_between( curve_start_point ) < GEOMETRY_RESABS )
   20094                 :            :       {
   20095                 :            :         //switch sense of ref entity
   20096 [ #  # ][ #  # ]:          0 :         merged_edge->reverse_tangent();
                 [ #  # ]
   20097                 :            :       }
   20098                 :            :     }
   20099         [ +  - ]:        195 :   }
   20100                 :        195 : }
   20101                 :            : 
   20102                 :        206 : void GeometryModifyTool::get_merged_curve_and_surface_ids(
   20103                 :            :                                           DLIList<Body*> &bodies,
   20104                 :            :                                           DLIList<int> &merged_surface_ids,
   20105                 :            :                                           DLIList<int> &merged_curve_ids ) const
   20106                 :            : {
   20107                 :            :   int i;
   20108         [ +  + ]:        609 :   for( i=bodies.size(); i--; )
   20109                 :            :   {
   20110         [ +  - ]:        403 :     DLIList<RefEntity*> merged_children;
   20111                 :            : 
   20112         [ +  - ]:        403 :     MergeTool::instance()->contains_merged_children( bodies.get_and_step(),
   20113 [ +  - ][ +  - ]:        403 :                                                      merged_children );
   20114                 :            : 
   20115                 :            :     int j;
   20116 [ +  - ][ -  + ]:        403 :     for( j=merged_children.size(); j--; )
   20117                 :            :     {
   20118         [ #  # ]:          0 :       RefEntity *ref_ent = merged_children.get_and_step();
   20119                 :            : 
   20120         [ #  # ]:          0 :       RefFace *ref_face = CAST_TO( ref_ent, RefFace );
   20121                 :            : 
   20122         [ #  # ]:          0 :       if( ref_face )
   20123 [ #  # ][ #  # ]:          0 :         merged_surface_ids.append( ref_face->id() );
   20124                 :            :       else
   20125                 :            :       {
   20126         [ #  # ]:          0 :         RefEdge *ref_edge = CAST_TO( ref_ent, RefEdge );
   20127                 :            : 
   20128         [ #  # ]:          0 :         if( ref_edge )
   20129 [ #  # ][ #  # ]:          0 :           merged_curve_ids.append( ref_edge->id() );
   20130                 :            :       }
   20131                 :            :     }
   20132         [ +  - ]:        403 :   }
   20133                 :        206 : }
   20134                 :            : 
   20135                 :          0 : void GeometryModifyTool::plane_preview(DLIList<Body*>& body_list,
   20136                 :            :                                        const CubitVector &pt1,
   20137                 :            :                                        const CubitVector &pt2,
   20138                 :            :                                        const CubitVector &pt3)
   20139                 :            : {
   20140         [ #  # ]:          0 :   CubitPlane plane;
   20141 [ #  # ][ #  # ]:          0 :   if( plane.mk_plane_with_points( pt1, pt2, pt3) == CUBIT_FAILURE)
   20142                 :            :   {
   20143 [ #  # ][ #  # ]:          0 :        PRINT_INFO( "Unable to create plane from given information.\n" );
         [ #  # ][ #  # ]
   20144                 :          0 :        return ;
   20145                 :            :   }
   20146                 :            : 
   20147         [ #  # ]:          0 :   CubitBox bounding_box;
   20148         [ #  # ]:          0 :   Body* body_ptr = body_list.get_and_step();
   20149 [ #  # ][ #  # ]:          0 :   bounding_box = body_ptr->bounding_box();
                 [ #  # ]
   20150                 :            : 
   20151                 :            :   int i;
   20152 [ #  # ][ #  # ]:          0 :   for( i=1; i<body_list.size(); i++ )
   20153                 :            :   {
   20154         [ #  # ]:          0 :      body_ptr = body_list.get_and_step();
   20155 [ #  # ][ #  # ]:          0 :      bounding_box |= body_ptr->bounding_box();
                 [ #  # ]
   20156                 :            :   }
   20157                 :            : 
   20158                 :          0 :   int extension_type = 1;
   20159                 :          0 :   double extension = 10; //10%
   20160 [ #  # ][ #  # ]:          0 :   CubitVector p1, p2, p3, p4;
         [ #  # ][ #  # ]
   20161                 :            : 
   20162         [ #  # ]:          0 :   if( AnalyticGeometryTool::instance()->
   20163                 :            :          min_pln_box_int_corners( plane, bounding_box, extension_type,
   20164 [ #  # ][ #  # ]:          0 :          extension, p1, p2, p3, p4 ) == CUBIT_FAILURE )
   20165                 :            :   {
   20166 [ #  # ][ #  # ]:          0 :      PRINT_INFO( "Unable to create plane from given information.\n" );
         [ #  # ][ #  # ]
   20167                 :          0 :      return ;
   20168                 :            :   }
   20169                 :            : 
   20170                 :            :   GPoint gp[4];
   20171 [ #  # ][ #  # ]:          0 :   gp[0].x=p1.x(); gp[0].y=p1.y(); gp[0].z=p1.z();
                 [ #  # ]
   20172 [ #  # ][ #  # ]:          0 :   gp[1].x=p2.x(); gp[1].y=p2.y(); gp[1].z=p2.z();
                 [ #  # ]
   20173 [ #  # ][ #  # ]:          0 :   gp[2].x=p3.x(); gp[2].y=p3.y(); gp[2].z=p3.z();
                 [ #  # ]
   20174 [ #  # ][ #  # ]:          0 :   gp[3].x=p4.x(); gp[3].y=p4.y(); gp[3].z=p4.z();
                 [ #  # ]
   20175                 :            : 
   20176                 :            :   // clear previous previews
   20177         [ #  # ]:          0 :   GfxPreview::clear();
   20178                 :            : 
   20179                 :            :   // Get the color to draw in
   20180                 :          0 :   int color = CUBIT_BLUE_INDEX;
   20181         [ #  # ]:          0 :   GfxPreview::draw_quad(gp, color);
   20182         [ #  # ]:          0 :   GfxPreview::flush();
   20183         [ #  # ]:          0 :   return;
   20184                 :            : }
   20185                 :            : 
   20186                 :          0 : void GeometryModifyTool::march_using_planes(CubitVector &point_on_surf,
   20187                 :            :                                             RefFace *surf,
   20188                 :            :                                             CubitVector &march_dir,
   20189                 :            :                                             double step_size,
   20190                 :            :                                             DLIList<CubitVector> &horizontal_points,
   20191                 :            :                                             DLIList<CubitVector> &vertical_points)
   20192                 :            : {
   20193         [ #  # ]:          0 :   CubitVector surf_norm = surf->normal_at(point_on_surf);
   20194         [ #  # ]:          0 :   CubitVector plane_norm = march_dir * surf_norm;
   20195 [ #  # ][ #  # ]:          0 :   GeometryModifyEngine *gme = get_engine((TopologyBridge*)surf->get_surface_ptr());
   20196         [ #  # ]:          0 :   if(gme)
   20197                 :            :   {
   20198         [ #  # ]:          0 :     CubitPlane plane(plane_norm, point_on_surf);
   20199 [ #  # ][ #  # ]:          0 :     CubitBox bbox = surf->ref_volume()->bounding_box();
   20200 [ #  # ][ #  # ]:          0 :     CubitVector p1, p2, p3, p4;
         [ #  # ][ #  # ]
   20201                 :            :     AnalyticGeometryTool::instance()->min_pln_box_int_corners( plane, bbox, 1,
   20202 [ #  # ][ #  # ]:          0 :                                     10.0, p1, p2, p3, p4, CUBIT_TRUE );
   20203 [ #  # ][ #  # ]:          0 :     Body *plane_body = GeometryModifyTool::instance()->planar_sheet( p1, p2, p3, p4 );
   20204 [ #  # ][ #  # ]:          0 :     Body *model_body_copy = GeometryModifyTool::instance()->copy_body(surf->body());
                 [ #  # ]
   20205 [ #  # ][ #  # ]:          0 :     DLIList<Body*> from_body_list, new_body_list;
         [ #  # ][ #  # ]
   20206         [ #  # ]:          0 :     from_body_list.append(plane_body);
   20207         [ #  # ]:          0 :     from_body_list.append(model_body_copy);
   20208         [ #  # ]:          0 :     GeometryModifyTool::imprint(from_body_list, new_body_list, CUBIT_FALSE);
   20209 [ #  # ][ #  # ]:          0 :     for(int i=0; i<new_body_list.size(); i++)
   20210                 :            :     {
   20211 [ #  # ][ #  # ]:          0 :       if(new_body_list[i] == plane_body)
   20212                 :            :       {
   20213                 :            :         trace_out_curves(plane_body, point_on_surf, march_dir,
   20214         [ #  # ]:          0 :                          step_size, horizontal_points, vertical_points);
   20215                 :            :         /*
   20216                 :            :         GfxDebug::clear();
   20217                 :            :         DLIList<RefEdge*> plane_curves;
   20218                 :            :         plane_body->ref_edges(plane_curves);
   20219                 :            :         for(int j=0; j<plane_curves.size(); j++)
   20220                 :            :         {
   20221                 :            :           GfxDebug::draw_ref_edge(plane_curves[j], CUBIT_RED_INDEX);
   20222                 :            :         }
   20223                 :            :         GfxDebug::flush();
   20224                 :            :         GfxDebug::mouse_xforms();
   20225                 :            :          */
   20226                 :            :       }
   20227                 :            :       else
   20228 [ #  # ][ #  # ]:          0 :         GeometryQueryTool::instance()->delete_single_Body(new_body_list[i]);
                 [ #  # ]
   20229         [ #  # ]:          0 :     }
   20230                 :            :   }
   20231                 :          0 : }
   20232                 :            : 
   20233                 :          0 : void GeometryModifyTool::trace_out_curves(Body *plane_body,
   20234                 :            :                                           CubitVector &start_point,
   20235                 :            :                                           CubitVector &march_dir,
   20236                 :            :                                           double step_size,
   20237                 :            :                                           DLIList<CubitVector> &horizontal_points,
   20238                 :            :                                           DLIList<CubitVector> &vertical_points)
   20239                 :            : {
   20240                 :            :   // Find a curve that the start point is on.
   20241         [ #  # ]:          0 :   DLIList<RefEdge*> curves;
   20242         [ #  # ]:          0 :   plane_body->ref_edges(curves);
   20243 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> interior_curves;
   20244 [ #  # ][ #  # ]:          0 :   for(int i=0; i<curves.size(); i++)
   20245                 :            :   {
   20246         [ #  # ]:          0 :     RefEdge *cur_curve = curves[i];
   20247         [ #  # ]:          0 :     DLIList<RefFace*> curve_surfs;
   20248         [ #  # ]:          0 :     cur_curve->ref_faces(curve_surfs);
   20249 [ #  # ][ #  # ]:          0 :     if(curve_surfs.size() == 2)
   20250         [ #  # ]:          0 :       interior_curves.append(cur_curve);
   20251         [ #  # ]:          0 :   }
   20252                 :          0 :   RefEdge *start_curve = NULL;
   20253 [ #  # ][ #  # ]:          0 :   for(int i=0; i<interior_curves.size(); i++)
   20254                 :            :   {
   20255         [ #  # ]:          0 :     CubitVector closest;
   20256         [ #  # ]:          0 :     RefEdge *cur_curve = interior_curves[i];
   20257         [ #  # ]:          0 :     cur_curve->closest_point_trimmed(start_point, closest);
   20258 [ #  # ][ #  # ]:          0 :     if(start_point.about_equal(closest))
   20259                 :            :     {
   20260                 :          0 :       start_curve = cur_curve;
   20261                 :          0 :       break;
   20262                 :            :     }
   20263                 :            :   }
   20264                 :            :   if(start_curve)
   20265                 :            :   {
   20266                 :            :     
   20267         [ #  # ]:          0 :   }
   20268                 :          0 : }
   20269                 :            : 
   20270                 :          0 : void GeometryModifyTool::march_path_to_discover_horizontal(CubitVector &start_pos,
   20271                 :            :                                     CubitVector &sweep_dir,
   20272                 :            :                                     RefFace *start_face,
   20273                 :            :                                     CubitVector &march_dir,  // should be normalized
   20274                 :            :                                     double &step_size,
   20275                 :            :                                     DLIList<CubitVector> &final_points,
   20276                 :            :                                     DLIList<RefFace*> &ending_faces)
   20277                 :            : {
   20278                 :          0 :   double cos_45 = 0.70710678118654752440084436210485;
   20279 [ #  # ][ #  # ]:          0 :   double geo_tol = GeometryQueryTool::instance()->get_sme_resabs_tolerance();
   20280         [ #  # ]:          0 :   CubitVector point_on_surf = start_pos;
   20281         [ #  # ]:          0 :   RefVolume *v = start_face->ref_volume();
   20282                 :          0 :   RefFace *cur_face = start_face;
   20283                 :            : 
   20284                 :          0 :   RefEdge *snap_edge = NULL;
   20285                 :          0 :   bool snapped_to_edge_last_time = false;
   20286                 :          0 :   bool turned = false;
   20287         [ #  # ]:          0 :   CubitVector old_pos = point_on_surf;
   20288         [ #  # ]:          0 :   while(!turned)
   20289                 :            :   {
   20290         [ #  # ]:          0 :     CubitVector new_pos;
   20291         [ #  # ]:          0 :     if(snapped_to_edge_last_time)
   20292                 :            :     {
   20293                 :            :       // Just set the new position to the position on the
   20294                 :            :       // edge.  This will force us to jump out without doing
   20295                 :            :       // anything and then on the next loop we will start
   20296                 :            :       // onto the new face.
   20297         [ #  # ]:          0 :       new_pos = old_pos;
   20298                 :          0 :       snapped_to_edge_last_time = false;
   20299                 :          0 :       continue;
   20300                 :            :     }
   20301                 :            :     else
   20302                 :            :     {
   20303                 :            :       // Calculate a new step along the vector.
   20304 [ #  # ][ #  # ]:          0 :       new_pos = old_pos + step_size * march_dir;
                 [ #  # ]
   20305                 :            :     }
   20306                 :            : 
   20307 [ #  # ][ #  # ]:          0 :     cur_face->get_surface_ptr()->closest_point_trimmed(new_pos, point_on_surf);
                 [ #  # ]
   20308                 :            : 
   20309         [ #  # ]:          0 :     CubitVector norm = cur_face->normal_at(point_on_surf, v);
   20310 [ #  # ][ #  # ]:          0 :     if(sweep_dir % norm < cos_45)
   20311                 :            :     {
   20312                 :          0 :       turned = true;
   20313                 :            :     }
   20314                 :            :     else
   20315                 :            :     {
   20316                 :          0 :       bool snapping_to_edge = true;
   20317         [ #  # ]:          0 :       CubitVector proj_dir = point_on_surf - new_pos;
   20318         [ #  # ]:          0 :       double proj_dist = proj_dir.length();
   20319         [ #  # ]:          0 :       if(proj_dist < geo_tol)
   20320                 :          0 :         snapping_to_edge = false;
   20321                 :            :       else
   20322                 :            :       {
   20323         [ #  # ]:          0 :         proj_dir /= proj_dist;
   20324         [ #  # ]:          0 :         double dot = proj_dir % norm;
   20325 [ #  # ][ #  # ]:          0 :         if(dot > .99 || dot < -.99)
   20326                 :          0 :           snapping_to_edge = false;
   20327                 :            :       }
   20328         [ #  # ]:          0 :       if(!snapping_to_edge)
   20329                 :            :       {
   20330                 :          0 :         snap_edge = NULL;
   20331                 :            :         // didn't snap to boundary
   20332         [ #  # ]:          0 :         old_pos = point_on_surf;
   20333         [ #  # ]:          0 :         final_points.append(point_on_surf);
   20334                 :            :       }
   20335                 :            :       else
   20336                 :            :       {
   20337                 :            :         // probably snapped to the boundary of this face
   20338         [ #  # ]:          0 :         DLIList<RefEdge*> face_edges;
   20339                 :          0 :         RefEdge *best_edge = NULL;
   20340         [ #  # ]:          0 :         cur_face->ref_edges(face_edges);
   20341                 :            :         int i;
   20342 [ #  # ][ #  # ]:          0 :         DLIList<RefEdge*> possible_edges;
   20343         [ #  # ]:          0 :         CubitVector closest;
   20344 [ #  # ][ #  # ]:          0 :         for(i=face_edges.size(); i>0; i--)
   20345                 :            :         {
   20346         [ #  # ]:          0 :           RefEdge *e = face_edges.get_and_step();
   20347         [ #  # ]:          0 :           e->closest_point_trimmed(point_on_surf, closest);
   20348 [ #  # ][ #  # ]:          0 :           double cur_dist = (closest - point_on_surf).length();
   20349         [ #  # ]:          0 :           if(cur_dist < geo_tol)
   20350                 :            :           {
   20351         [ #  # ]:          0 :             possible_edges.append(e);
   20352                 :            :           }
   20353                 :            :         }
   20354 [ #  # ][ #  # ]:          0 :         if(possible_edges.size() == 1)
   20355         [ #  # ]:          0 :           best_edge = possible_edges.get();
   20356 [ #  # ][ #  # ]:          0 :         else if(possible_edges.size() > 1)
   20357                 :            :         {
   20358                 :            :           int h;
   20359                 :          0 :           double smallest_dist = CUBIT_DBL_MAX;
   20360 [ #  # ][ #  # ]:          0 :           for(h=possible_edges.size(); h>0; h--)
   20361                 :            :           {
   20362         [ #  # ]:          0 :             RefEdge *ce = possible_edges.get_and_step();
   20363         [ #  # ]:          0 :             ce->closest_point_trimmed(old_pos, closest);
   20364 [ #  # ][ #  # ]:          0 :             double cur_dist = (old_pos-closest).length();
   20365         [ #  # ]:          0 :             if(cur_dist < smallest_dist)
   20366                 :            :             {
   20367                 :          0 :               smallest_dist = cur_dist;
   20368                 :          0 :               best_edge = ce;
   20369                 :            :             }
   20370                 :            :           }
   20371                 :            :         }
   20372         [ #  # ]:          0 :         if(best_edge)
   20373                 :            :         {
   20374 [ #  # ][ #  # ]:          0 :           if(snap_edge && snap_edge == best_edge)
   20375                 :            :           {
   20376         [ #  # ]:          0 :             final_points.append(point_on_surf);
   20377         [ #  # ]:          0 :             old_pos = point_on_surf;
   20378                 :          0 :             snapped_to_edge_last_time = true;
   20379                 :            :           }
   20380                 :            :           else
   20381                 :            :           {
   20382                 :          0 :             snap_edge = best_edge;
   20383         [ #  # ]:          0 :             cur_face = best_edge->other_face(cur_face, v);
   20384         [ #  # ]:          0 :             CubitVector old_pos_save = old_pos;
   20385         [ #  # ]:          0 :             old_pos = closest;
   20386                 :          0 :             i = 0;
   20387                 :          0 :             snapped_to_edge_last_time = true;
   20388                 :            : 
   20389 [ #  # ][ #  # ]:          0 :             GeometryModifyEngine *gme = get_engine((TopologyBridge*)best_edge->get_curve_ptr());
   20390         [ #  # ]:          0 :             if(gme)
   20391                 :            :             {
   20392         [ #  # ]:          0 :               TBPoint *pt1 = gme->make_Point(old_pos_save);
   20393         [ #  # ]:          0 :               TBPoint *pt2 = gme->make_Point(new_pos);
   20394                 :          0 :               CubitVector const* pt3 = NULL;
   20395         [ #  # ]:          0 :               Curve *crv = gme->make_Curve(STRAIGHT_CURVE_TYPE, pt1, pt2, pt3 );
   20396         [ #  # ]:          0 :               if(crv)
   20397                 :            :               {
   20398 [ #  # ][ #  # ]:          0 :                 CubitVector pos1, pos2;
   20399                 :            :                 double dist;
   20400         [ #  # ]:          0 :                 GeometryQueryTool::instance()->entity_entity_distance(crv, best_edge->get_curve_ptr(), pos1,
   20401 [ #  # ][ #  # ]:          0 :                   pos2, dist);
   20402         [ #  # ]:          0 :                 old_pos = pos2;
   20403 [ #  # ][ #  # ]:          0 :                 delete crv;
   20404 [ #  # ][ #  # ]:          0 :                 delete pt1;
   20405 [ #  # ][ #  # ]:          0 :                 delete pt2;
   20406         [ #  # ]:          0 :                 final_points.append(old_pos);
   20407                 :            :               }
   20408                 :            :             }
   20409                 :            :           }
   20410         [ #  # ]:          0 :         }
   20411                 :            :       }
   20412                 :            :     }
   20413                 :            :   }
   20414         [ #  # ]:          0 :   ending_faces.append(cur_face);
   20415                 :          0 : }
   20416                 :            : 
   20417                 :          0 : void GeometryModifyTool::march_path_to_discover_vertical(CubitVector &start_pos,
   20418                 :            :                                                          CubitVector &sweep_dir,
   20419                 :            :                                                            RefFace *start_face,
   20420                 :            :                                                            CubitVector &march_dir,  // should be normalized
   20421                 :            :                                                            double &step_size,
   20422                 :            :                                                            DLIList<CubitVector> &final_points,
   20423                 :            :                                                            DLIList<RefFace*> &ending_faces)
   20424                 :            : {
   20425                 :          0 :   double cos_45 = 0.70710678118654752440084436210485;
   20426 [ #  # ][ #  # ]:          0 :   double geo_tol = GeometryQueryTool::instance()->get_sme_resabs_tolerance();
   20427         [ #  # ]:          0 :   CubitVector point_on_surf = start_pos;
   20428         [ #  # ]:          0 :   RefVolume *v = start_face->ref_volume();
   20429                 :          0 :   RefFace *cur_face = start_face;
   20430                 :            :   
   20431                 :          0 :   RefEdge *snap_edge = NULL;
   20432                 :          0 :   bool snapped_to_edge_last_time = false;
   20433                 :          0 :   bool turned = false;
   20434         [ #  # ]:          0 :   CubitVector old_pos = point_on_surf;
   20435         [ #  # ]:          0 :   while(!turned)
   20436                 :            :   {
   20437         [ #  # ]:          0 :     CubitVector new_pos;
   20438         [ #  # ]:          0 :     if(snapped_to_edge_last_time)
   20439                 :            :     {
   20440                 :            :       // Just set the new position to the position on the
   20441                 :            :       // edge.  This will force us to jump out without doing
   20442                 :            :       // anything and then on the next loop we will start
   20443                 :            :       // onto the new face.
   20444         [ #  # ]:          0 :       new_pos = old_pos;
   20445                 :          0 :       snapped_to_edge_last_time = false;
   20446                 :            :       //snap_edge = NULL;
   20447                 :          0 :       continue;
   20448                 :            :     }
   20449                 :            :     else
   20450                 :            :     {
   20451                 :            :       // Calculate a new step along the vector.
   20452 [ #  # ][ #  # ]:          0 :       new_pos = old_pos + step_size * march_dir;
                 [ #  # ]
   20453                 :            :     }
   20454                 :            :     
   20455 [ #  # ][ #  # ]:          0 :     cur_face->get_surface_ptr()->closest_point_trimmed(new_pos, point_on_surf);
                 [ #  # ]
   20456                 :            : 
   20457                 :          0 :     int d = 0;
   20458         [ #  # ]:          0 :     if(d)
   20459                 :            :     {
   20460         [ #  # ]:          0 :       GfxDebug::draw_point(new_pos, CUBIT_BLUE_INDEX);
   20461         [ #  # ]:          0 :       GfxDebug::draw_point(point_on_surf, CUBIT_RED_INDEX);
   20462         [ #  # ]:          0 :       GfxDebug::flush();
   20463         [ #  # ]:          0 :       GfxDebug::mouse_xforms();
   20464                 :            :     }
   20465                 :            :     
   20466         [ #  # ]:          0 :     CubitVector norm = cur_face->normal_at(point_on_surf, v);
   20467         [ #  # ]:          0 :     double tmp_dot = sweep_dir % norm;
   20468 [ #  # ][ #  # ]:          0 :     if(tmp_dot > cos_45 || tmp_dot < -cos_45)
   20469                 :            :     {
   20470                 :          0 :       turned = true;
   20471                 :            :     }
   20472                 :            :     else
   20473                 :            :     {
   20474                 :          0 :       bool snapping_to_edge = true;
   20475         [ #  # ]:          0 :       CubitVector proj_dir = point_on_surf - new_pos;
   20476         [ #  # ]:          0 :       double proj_dist = proj_dir.length();
   20477         [ #  # ]:          0 :       if(proj_dist < geo_tol)
   20478                 :          0 :         snapping_to_edge = false;
   20479                 :            :       else
   20480                 :            :       {
   20481         [ #  # ]:          0 :         proj_dir /= proj_dist;
   20482         [ #  # ]:          0 :         double dot = proj_dir % norm;
   20483 [ #  # ][ #  # ]:          0 :         if(dot > .99 || dot < -.99)
   20484                 :          0 :           snapping_to_edge = false;
   20485                 :            :       }
   20486         [ #  # ]:          0 :       if(!snapping_to_edge)
   20487                 :            :       {
   20488                 :          0 :         snap_edge = NULL;
   20489                 :            :         // didn't snap to boundary
   20490         [ #  # ]:          0 :         old_pos = point_on_surf;
   20491         [ #  # ]:          0 :         final_points.append(point_on_surf);
   20492                 :            :       }
   20493                 :            :       else
   20494                 :            :       {
   20495                 :            :         // probably snapped to the boundary of this face
   20496         [ #  # ]:          0 :         DLIList<RefEdge*> face_edges;
   20497                 :          0 :         RefEdge *best_edge = NULL;
   20498         [ #  # ]:          0 :         CubitVector best_pos;
   20499         [ #  # ]:          0 :         cur_face->ref_edges(face_edges);
   20500 [ #  # ][ #  # ]:          0 :         DLIList<RefEdge*> possible_edges;
   20501         [ #  # ]:          0 :         CubitVector closest;
   20502 [ #  # ][ #  # ]:          0 :         for(int i=face_edges.size(); i>0; i--)
   20503                 :            :         {
   20504         [ #  # ]:          0 :           RefEdge *e = face_edges.get_and_step();
   20505         [ #  # ]:          0 :           e->closest_point_trimmed(point_on_surf, closest);
   20506 [ #  # ][ #  # ]:          0 :           double cur_dist = (closest - point_on_surf).length();
   20507         [ #  # ]:          0 :           if(cur_dist < geo_tol)
   20508                 :            :           {
   20509                 :            :             // If there are more than one edge that are coincident with the point
   20510                 :            :             // choose the one whose tangent is most normal to the direction we are
   20511                 :            :             // marching.  Switching onto the corresponding face should be best.
   20512         [ #  # ]:          0 :             if(best_edge)
   20513                 :            :             {
   20514 [ #  # ][ #  # ]:          0 :               CubitVector best_edge_tan, cur_edge_tan;
   20515         [ #  # ]:          0 :               best_edge->tangent(point_on_surf, best_edge_tan);
   20516         [ #  # ]:          0 :               e->tangent(point_on_surf, cur_edge_tan);
   20517 [ #  # ][ #  # ]:          0 :               if(fabs(best_edge_tan % march_dir) > fabs(cur_edge_tan % march_dir))
                 [ #  # ]
   20518                 :          0 :                 best_edge = e;
   20519                 :            :             }
   20520                 :            :             else
   20521                 :          0 :               best_edge = e;
   20522                 :            :           }
   20523                 :            :         }
   20524         [ #  # ]:          0 :         if(best_edge)
   20525                 :            :         {
   20526 [ #  # ][ #  # ]:          0 :           if(snap_edge && snap_edge == best_edge)
   20527                 :            :           {
   20528         [ #  # ]:          0 :             final_points.append(point_on_surf);
   20529         [ #  # ]:          0 :             old_pos = point_on_surf;
   20530                 :          0 :             snapped_to_edge_last_time = true;
   20531                 :            :           }
   20532                 :            :           else
   20533                 :            :           {
   20534                 :          0 :             snap_edge = best_edge;
   20535         [ #  # ]:          0 :             cur_face = best_edge->other_face(cur_face, v);
   20536         [ #  # ]:          0 :             CubitVector old_pos_save = old_pos;
   20537         [ #  # ]:          0 :             old_pos = best_pos;
   20538                 :          0 :             snapped_to_edge_last_time = true;
   20539                 :            :             
   20540 [ #  # ][ #  # ]:          0 :             GeometryModifyEngine *gme = get_engine((TopologyBridge*)best_edge->get_curve_ptr());
   20541         [ #  # ]:          0 :             if(gme)
   20542                 :            :             {
   20543         [ #  # ]:          0 :               TBPoint *pt1 = gme->make_Point(old_pos_save);
   20544         [ #  # ]:          0 :               TBPoint *pt2 = gme->make_Point(new_pos);
   20545                 :          0 :               CubitVector const* pt3 = NULL;
   20546         [ #  # ]:          0 :               Curve *crv = gme->make_Curve(STRAIGHT_CURVE_TYPE, pt1, pt2, pt3 );
   20547         [ #  # ]:          0 :               if(crv)
   20548                 :            :               {
   20549 [ #  # ][ #  # ]:          0 :                 CubitVector pos1, pos2;
   20550                 :            :                 double dist;
   20551         [ #  # ]:          0 :                 GeometryQueryTool::instance()->entity_entity_distance(crv, best_edge->get_curve_ptr(), pos1,
   20552 [ #  # ][ #  # ]:          0 :                                                                       pos2, dist);
   20553         [ #  # ]:          0 :                 old_pos = pos2;
   20554 [ #  # ][ #  # ]:          0 :                 delete crv;
   20555 [ #  # ][ #  # ]:          0 :                 delete pt1;
   20556 [ #  # ][ #  # ]:          0 :                 delete pt2;
   20557         [ #  # ]:          0 :                 final_points.append(old_pos);
   20558                 :            :               }
   20559                 :            :             }
   20560                 :            :           }
   20561         [ #  # ]:          0 :         }
   20562                 :            :       }
   20563                 :            :     }
   20564                 :            :   }
   20565         [ #  # ]:          0 :   ending_faces.append(cur_face);
   20566                 :          0 : }
   20567                 :            : 
   20568                 :          0 : CubitStatus GeometryModifyTool::stitch( DLIList<Body*> &bodies_to_stitch,
   20569                 :            :                                         DLIList<Body*> &result_list,
   20570                 :            :                                         bool tighten_gaps,
   20571                 :            :                                         double tolerance )
   20572                 :            : {
   20573 [ #  # ][ #  # ]:          0 :   if (!okay_to_modify( bodies_to_stitch, "STITCH" ))
   20574                 :          0 :     return CUBIT_FAILURE;
   20575                 :            : 
   20576                 :            :   //get all the BodySMs from 'bodies_to_stitch'
   20577                 :            :   int i;
   20578 [ #  # ][ #  # ]:          0 :   for( i=bodies_to_stitch.size(); i--; )
   20579                 :            :   {
   20580         [ #  # ]:          0 :     Body *tmp_body = bodies_to_stitch.get_and_step();
   20581 [ #  # ][ #  # ]:          0 :     if( !tmp_body->is_sheet_body() )
   20582                 :            :     {
   20583 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Can't stitch body %d.  It's a solid body\n", tmp_body->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
   20584                 :          0 :       return CUBIT_FAILURE;
   20585                 :            :     }
   20586                 :            :   }
   20587                 :            : 
   20588 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> entity_list(bodies_to_stitch.size());
   20589 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list(bodies_to_stitch.size());
                 [ #  # ]
   20590 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*>         bodysm_list(bodies_to_stitch.size());
                 [ #  # ]
   20591 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(bodies_to_stitch, entity_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   20592         [ #  # ]:          0 :   GeometryModifyEngine *gme = common_modify_engine(entity_list, bridge_list);
   20593                 :            : 
   20594 [ #  # ][ #  # ]:          0 :   if( entity_list.size() != bridge_list.size() )
                 [ #  # ]
   20595                 :            :   {
   20596 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot stitch entities of different geometry engines.\n");
         [ #  # ][ #  # ]
   20597                 :          0 :     return CUBIT_FAILURE;
   20598                 :            :   }
   20599                 :            : 
   20600 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   20601         [ #  # ]:          0 :     CubitUndo::save_state_with_cubit_file( bodies_to_stitch );
   20602                 :            : 
   20603 [ #  # ][ #  # ]:          0 :   CAST_LIST(bridge_list, bodysm_list, BodySM);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   20604 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> new_bodies;
   20605         [ #  # ]:          0 :   CubitStatus result = gme->stitch( bodysm_list, new_bodies, tighten_gaps, tolerance );
   20606                 :            : 
   20607 [ #  # ][ #  # ]:          0 :   if( result == CUBIT_FAILURE && CubitUndo::get_undo_enabled() )
         [ #  # ][ #  # ]
   20608         [ #  # ]:          0 :     CubitUndo::remove_last_undo();
   20609                 :            : 
   20610 [ #  # ][ #  # ]:          0 :   if (!finish_sm_op(bodies_to_stitch, new_bodies, result_list))
   20611                 :            :   {
   20612                 :          0 :     result = CUBIT_FAILURE;
   20613         [ #  # ]:          0 :     CubitUndo::remove_last_undo();
   20614                 :            :   }
   20615                 :            : 
   20616 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   20617                 :            :   {
   20618         [ #  # ]:          0 :     if( result == CUBIT_SUCCESS )
   20619         [ #  # ]:          0 :       CubitUndo::note_result_bodies( result_list );
   20620                 :            :     else
   20621         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   20622                 :            :   }
   20623                 :            : 
   20624         [ #  # ]:          0 :   return result;
   20625                 :            : }
   20626                 :            : 
   20627                 :            : 
   20628                 :            : 
   20629                 :          0 : CubitStatus GeometryModifyTool::discover_topology(RefFace *surf, CubitVector &pos,
   20630                 :            :                                                   double &step_size,
   20631                 :            :                                                   int num_subdivisions)
   20632                 :            : {
   20633                 :          0 :   CubitStatus ret = CUBIT_SUCCESS;
   20634                 :            : 
   20635         [ #  # ]:          0 :   CubitVector point_on_surf;
   20636 [ #  # ][ #  # ]:          0 :   surf->get_surface_ptr()->closest_point_trimmed(pos, point_on_surf);
                 [ #  # ]
   20637         [ #  # ]:          0 :   RefVolume *v = surf->ref_volume();
   20638         [ #  # ]:          0 :   CubitVector norm = surf->normal_at(point_on_surf, v);
   20639 [ #  # ][ #  # ]:          0 :   CubitVector march_dir = norm * CubitVector(1,0,0);
   20640 [ #  # ][ #  # ]:          0 :   if(march_dir.length() < .001)
   20641                 :            :   {
   20642 [ #  # ][ #  # ]:          0 :     march_dir = norm * CubitVector(0,1,0);
                 [ #  # ]
   20643 [ #  # ][ #  # ]:          0 :     if(march_dir.length() < .001)
   20644                 :            :     {
   20645 [ #  # ][ #  # ]:          0 :       march_dir = norm * CubitVector(0,0,1);
                 [ #  # ]
   20646 [ #  # ][ #  # ]:          0 :       if(march_dir.length() < .001)
   20647                 :            :       {
   20648 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("Couldn't find a good march direction.\n");
         [ #  # ][ #  # ]
   20649                 :          0 :         ret = CUBIT_FAILURE;
   20650                 :            :       }
   20651                 :            :     }
   20652                 :            :   }
   20653                 :            : 
   20654         [ #  # ]:          0 :   if(ret == CUBIT_SUCCESS)
   20655                 :            :   {
   20656                 :          0 :     int new_approach = 0;
   20657         [ #  # ]:          0 :     if(new_approach)
   20658                 :            :     {
   20659                 :            :       // Get initial 4 directions.
   20660         [ #  # ]:          0 :       march_dir.normalize();
   20661         [ #  # ]:          0 :       DLIList<CubitVector> march_directions;
   20662         [ #  # ]:          0 :       CubitVector v1 = march_dir;
   20663         [ #  # ]:          0 :       CubitVector v3 = -march_dir;
   20664         [ #  # ]:          0 :       CubitVector v2 = norm*march_dir;
   20665         [ #  # ]:          0 :       march_directions.append(v1);
   20666         [ #  # ]:          0 :       march_directions.append(v2);
   20667         [ #  # ]:          0 :       march_directions.append(v3);
   20668                 :            : 
   20669                 :            :       // Now subdivide directions further if requested.
   20670         [ #  # ]:          0 :       for(int i=0; i<num_subdivisions; ++i)
   20671                 :            :       {
   20672         [ #  # ]:          0 :         DLIList<CubitVector> tmp_list;
   20673         [ #  # ]:          0 :         int list_size = march_directions.size();
   20674         [ #  # ]:          0 :         for(int j=0; j<list_size-1; j++)
   20675                 :            :         {
   20676 [ #  # ][ #  # ]:          0 :           CubitVector dir1 = march_directions[j];
   20677 [ #  # ][ #  # ]:          0 :           CubitVector dir2 = march_directions[(j+1)%list_size];
   20678         [ #  # ]:          0 :           CubitVector mid = dir1 + dir2;
   20679         [ #  # ]:          0 :           mid.normalize();
   20680         [ #  # ]:          0 :           tmp_list.append(dir1);
   20681         [ #  # ]:          0 :           tmp_list.append(mid);
   20682                 :            :         }
   20683 [ #  # ][ #  # ]:          0 :         tmp_list.append(march_directions[list_size-1]);
   20684         [ #  # ]:          0 :         march_directions = tmp_list;
   20685         [ #  # ]:          0 :       }
   20686 [ #  # ][ #  # ]:          0 :       DLIList<DLIList<CubitVector> > horizontal_points, vertical_points;
         [ #  # ][ #  # ]
   20687 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> horiz_ending_faces, vert_ending_faces;
         [ #  # ][ #  # ]
   20688 [ #  # ][ #  # ]:          0 :       for(int i=0; i<march_directions.size()-1; i++)
   20689                 :            :       {
   20690         [ #  # ]:          0 :         DLIList<CubitVector> new_list;
   20691         [ #  # ]:          0 :         horizontal_points.append(new_list);
   20692         [ #  # ]:          0 :         vertical_points.append(new_list);
   20693 [ #  # ][ #  # ]:          0 :         march_using_planes(point_on_surf, surf, march_directions[i], step_size, horizontal_points[i], vertical_points[i]);
         [ #  # ][ #  # ]
   20694 [ #  # ][ #  # ]:          0 :       }
   20695                 :            :     }
   20696                 :            :     else
   20697                 :            :     {
   20698                 :            :       // Get initial 4 directions.
   20699         [ #  # ]:          0 :       march_dir.normalize();
   20700         [ #  # ]:          0 :       DLIList<CubitVector> march_directions;
   20701         [ #  # ]:          0 :       CubitVector v1 = march_dir;
   20702         [ #  # ]:          0 :       CubitVector v3 = -march_dir;
   20703         [ #  # ]:          0 :       CubitVector v2 = norm*march_dir;
   20704         [ #  # ]:          0 :       CubitVector v4 = -v2;
   20705         [ #  # ]:          0 :       march_directions.append(v1);
   20706         [ #  # ]:          0 :       march_directions.append(v2);
   20707         [ #  # ]:          0 :       march_directions.append(v3);
   20708         [ #  # ]:          0 :       march_directions.append(v4);
   20709                 :            :       
   20710                 :            :       // Now subdivide directions further if requested.
   20711         [ #  # ]:          0 :       for(int i=0; i<num_subdivisions; ++i)
   20712                 :            :       {
   20713         [ #  # ]:          0 :         DLIList<CubitVector> tmp_list;
   20714         [ #  # ]:          0 :         int list_size = march_directions.size();
   20715         [ #  # ]:          0 :         for(int j=0; j<list_size; j++)
   20716                 :            :         {
   20717 [ #  # ][ #  # ]:          0 :           CubitVector dir1 = march_directions[j];
   20718 [ #  # ][ #  # ]:          0 :           CubitVector dir2 = march_directions[(j+1)%list_size];
   20719         [ #  # ]:          0 :           CubitVector mid = dir1 + dir2;
   20720         [ #  # ]:          0 :           mid.normalize();
   20721         [ #  # ]:          0 :           tmp_list.append(dir1);
   20722         [ #  # ]:          0 :           tmp_list.append(mid);
   20723                 :            :         }
   20724         [ #  # ]:          0 :         march_directions = tmp_list;
   20725         [ #  # ]:          0 :       }
   20726 [ #  # ][ #  # ]:          0 :       DLIList<DLIList<CubitVector> > horizontal_points, vertical_points;
         [ #  # ][ #  # ]
   20727 [ #  # ][ #  # ]:          0 :       DLIList<RefFace*> horiz_ending_faces, vert_ending_faces;
         [ #  # ][ #  # ]
   20728 [ #  # ][ #  # ]:          0 :       for(int i=0; i<march_directions.size(); i++)
   20729                 :            :       {
   20730         [ #  # ]:          0 :         DLIList<CubitVector> new_list;
   20731         [ #  # ]:          0 :         new_list.append(point_on_surf);
   20732         [ #  # ]:          0 :         horizontal_points.append(new_list);
   20733 [ #  # ][ #  # ]:          0 :         march_path_to_discover_horizontal(point_on_surf, norm, surf, march_directions[i], step_size, horizontal_points[i], horiz_ending_faces);
                 [ #  # ]
   20734         [ #  # ]:          0 :       }
   20735         [ #  # ]:          0 :       CubitVector new_dir = -norm;
   20736 [ #  # ][ #  # ]:          0 :       for(int i=0; i<march_directions.size(); i++)
   20737                 :            :       {
   20738 [ #  # ][ #  # ]:          0 :         CubitVector start_pos = horizontal_points[i].last_item();
                 [ #  # ]
   20739         [ #  # ]:          0 :         DLIList<CubitVector> new_list;
   20740         [ #  # ]:          0 :         new_list.append(start_pos);
   20741         [ #  # ]:          0 :         vertical_points.append(new_list);
   20742 [ #  # ][ #  # ]:          0 :         march_path_to_discover_vertical(start_pos, norm, horiz_ending_faces[i], new_dir, step_size, vertical_points[i], vert_ending_faces);
                 [ #  # ]
   20743                 :            : //        GfxDebug::draw_point(vertical_points[i].last_item(), CUBIT_GREEN_INDEX);
   20744                 :            : //        GfxDebug::flush();
   20745         [ #  # ]:          0 :       }
   20746                 :            :       
   20747                 :            :       // Draw lines traced out by marching directions
   20748 [ #  # ][ #  # ]:          0 :       for(int i=0; i<horizontal_points.size(); i++)
   20749                 :            :       {
   20750 [ #  # ][ #  # ]:          0 :         int size1 = horizontal_points[i].size();
   20751         [ #  # ]:          0 :         for(int j=0; j<size1-1; j++)
   20752                 :            :         {
   20753 [ #  # ][ #  # ]:          0 :           GfxDebug::draw_line(horizontal_points[i][j],
   20754 [ #  # ][ #  # ]:          0 :                               horizontal_points[i][j+1],
   20755         [ #  # ]:          0 :                               CUBIT_WHITE_INDEX);
   20756                 :            :         }
   20757                 :            :       }
   20758 [ #  # ][ #  # ]:          0 :       for(int i=0; i<vertical_points.size(); i++)
   20759                 :            :       {
   20760 [ #  # ][ #  # ]:          0 :         int size1 = vertical_points[i].size();
   20761         [ #  # ]:          0 :         for(int j=0; j<size1-1; j++)
   20762                 :            :         {
   20763 [ #  # ][ #  # ]:          0 :           GfxDebug::draw_line(vertical_points[i][j],
   20764 [ #  # ][ #  # ]:          0 :                               vertical_points[i][j+1],
   20765         [ #  # ]:          0 :                               CUBIT_YELLOW_INDEX);
   20766                 :            :         }
   20767                 :            :       }
   20768                 :            :       // Draw new topology
   20769         [ #  # ]:          0 :       int size1 = horizontal_points.size();
   20770         [ #  # ]:          0 :       for(int i=0; i<size1; i++)
   20771                 :            :       {
   20772 [ #  # ][ #  # ]:          0 :         GfxDebug::draw_line(horizontal_points[i].last_item(),
   20773 [ #  # ][ #  # ]:          0 :                             horizontal_points[(i+1)%size1].last_item(),
   20774         [ #  # ]:          0 :                             CUBIT_RED_INDEX);
   20775                 :            :       }
   20776         [ #  # ]:          0 :       size1 = vertical_points.size();
   20777         [ #  # ]:          0 :       for(int i=0; i<size1; i++)
   20778                 :            :       {
   20779 [ #  # ][ #  # ]:          0 :         GfxDebug::draw_line(vertical_points[i].last_item(),
   20780 [ #  # ][ #  # ]:          0 :                             vertical_points[(i+1)%size1].last_item(),
   20781         [ #  # ]:          0 :                             CUBIT_RED_INDEX);
   20782                 :            :       }
   20783 [ #  # ][ #  # ]:          0 :       GfxDebug::flush();
   20784                 :            :     }
   20785                 :            :   }
   20786                 :            : 
   20787                 :          0 :   return ret;
   20788                 :            : }
   20789                 :            : 
   20790                 :          0 : void GeometryModifyTool::subdivide_pie(CubitVector &dir1, CubitVector &dir2, int num_subdivisions,
   20791                 :            :                                        DLIList<CubitVector> &all_directions)
   20792                 :            : {
   20793         [ #  # ]:          0 :   if(num_subdivisions > 0)
   20794                 :            :   {
   20795         [ #  # ]:          0 :     CubitVector mid = dir1 + dir2;
   20796         [ #  # ]:          0 :     mid.normalize();
   20797         [ #  # ]:          0 :     all_directions.append(mid);
   20798         [ #  # ]:          0 :     if(num_subdivisions > 1)
   20799                 :            :     {
   20800         [ #  # ]:          0 :       subdivide_pie(dir1, mid, num_subdivisions-1, all_directions);
   20801         [ #  # ]:          0 :       subdivide_pie(mid, dir2, num_subdivisions-1, all_directions);
   20802                 :            :     }
   20803                 :            :   }
   20804                 :          0 : }
   20805                 :            : 
   20806                 :          0 : Body* GeometryModifyTool::create_rectangle_surface( double width, double height, CubitVector plane )
   20807                 :            : {
   20808 [ #  # ][ #  # ]:          0 :   if(0 == gmeList.size())
   20809                 :            :   {
   20810 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
   20811                 :          0 :     return NULL;
   20812                 :            :   }
   20813                 :            : 
   20814 [ #  # ][ #  # ]:          0 :   if( width <= GEOMETRY_RESABS || height <= GEOMETRY_RESABS )
   20815                 :            :   {
   20816 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Values must be positive\n");
         [ #  # ][ #  # ]
   20817                 :          0 :     return NULL;
   20818                 :            :   }
   20819                 :            : 
   20820 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   20821         [ #  # ]:          0 :     CubitUndo::save_state();
   20822                 :            : 
   20823                 :          0 :   BodySM *sheet_body_sm = NULL;
   20824 [ #  # ][ #  # ]:          0 :   CubitStatus status = gmeList.get()->create_rectangle_surface(width, height, plane, sheet_body_sm );
                 [ #  # ]
   20825                 :            : 
   20826         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   20827                 :            :   {
   20828 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20829         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   20830                 :          0 :     return NULL;
   20831                 :            :   }
   20832                 :            : 
   20833                 :          0 :   Body *new_body = NULL;
   20834         [ #  # ]:          0 :   if( sheet_body_sm )
   20835 [ #  # ][ #  # ]:          0 :     new_body = GeometryQueryTool::instance()->make_Body(sheet_body_sm);
   20836                 :            : 
   20837         [ #  # ]:          0 :   if (new_body)
   20838                 :            :   {
   20839 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20840         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);
   20841                 :          0 :     status = CUBIT_SUCCESS;
   20842                 :            :   }
   20843                 :            :   else
   20844                 :            :   {
   20845 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20846         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   20847                 :          0 :     status = CUBIT_FAILURE;
   20848                 :            :   }
   20849                 :            : 
   20850                 :          0 :   return new_body;
   20851                 :            : }
   20852                 :            : 
   20853                 :          0 : Body* GeometryModifyTool::create_parallelogram_surface( RefVertex *v1,
   20854                 :            :                                                               RefVertex *v2,
   20855                 :            :                                                               RefVertex *v3 )
   20856                 :            : {
   20857 [ #  # ][ #  # ]:          0 :   if(0 == gmeList.size())
   20858                 :            :   {
   20859 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
   20860                 :          0 :     return NULL;
   20861                 :            :   }
   20862                 :            : 
   20863 [ #  # ][ #  # ]:          0 :   GeometryModifyEngine *GMEPtr = get_engine( v1->get_point_ptr() );
   20864                 :            : 
   20865 [ #  # ][ #  # ]:          0 :   if( GMEPtr != get_engine( v2->get_point_ptr() ) )
                 [ #  # ]
   20866                 :            :   {
   20867 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Vertices are not from same modeling engine.\n");
         [ #  # ][ #  # ]
   20868                 :          0 :     return NULL;
   20869                 :            :   }
   20870 [ #  # ][ #  # ]:          0 :   if( GMEPtr != get_engine( v3->get_point_ptr() ) )
                 [ #  # ]
   20871                 :            :   {
   20872 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Vertices are not from same modeling engine.\n");
         [ #  # ][ #  # ]
   20873                 :          0 :     return NULL;
   20874                 :            :   }
   20875                 :            : 
   20876                 :            :   TBPoint *pt1, *pt2, *pt3;
   20877                 :            : 
   20878         [ #  # ]:          0 :   DLIList<RefVertex*> free_ref_vertices;
   20879 [ #  # ][ #  # ]:          0 :   if( v1->num_parent_ref_entities() == 0 )
   20880                 :            :   {
   20881         [ #  # ]:          0 :     free_ref_vertices.append( v1 );
   20882         [ #  # ]:          0 :     pt1 = v1->get_point_ptr();
   20883                 :            :   }
   20884                 :            :   else
   20885 [ #  # ][ #  # ]:          0 :     pt1 = GMEPtr->make_Point( v1->coordinates() );
   20886                 :            : 
   20887 [ #  # ][ #  # ]:          0 :   if( v2->num_parent_ref_entities() == 0 )
   20888                 :            :   {
   20889         [ #  # ]:          0 :     free_ref_vertices.append( v2 );
   20890         [ #  # ]:          0 :     pt2 = v2->get_point_ptr();
   20891                 :            :   }
   20892                 :            :   else
   20893 [ #  # ][ #  # ]:          0 :     pt2 = GMEPtr->make_Point( v2->coordinates() );
   20894                 :            : 
   20895 [ #  # ][ #  # ]:          0 :   if( v3->num_parent_ref_entities() == 0 )
   20896                 :            :   {
   20897         [ #  # ]:          0 :     free_ref_vertices.append( v3 );
   20898         [ #  # ]:          0 :     pt3 = v3->get_point_ptr();
   20899                 :            :   }
   20900                 :            :   else
   20901 [ #  # ][ #  # ]:          0 :     pt3 = GMEPtr->make_Point( v3->coordinates() );
   20902                 :            : 
   20903 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   20904                 :            :   {
   20905 [ #  # ][ #  # ]:          0 :     if( free_ref_vertices.size() )
   20906         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( free_ref_vertices, true );
   20907                 :            :     else
   20908         [ #  # ]:          0 :       CubitUndo::save_state();
   20909                 :            :   }
   20910                 :            : 
   20911                 :          0 :   BodySM *sheet_body_sm = NULL;
   20912         [ #  # ]:          0 :   CubitStatus status = GMEPtr->create_parallelogram_surface(pt1, pt2, pt3, sheet_body_sm );
   20913                 :            : 
   20914         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   20915                 :            :   {
   20916 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20917         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   20918                 :          0 :     return NULL;
   20919                 :            :   }
   20920                 :            : 
   20921                 :          0 :   Body *new_body = NULL;
   20922         [ #  # ]:          0 :   if( sheet_body_sm )
   20923 [ #  # ][ #  # ]:          0 :     new_body = GeometryQueryTool::instance()->make_Body(sheet_body_sm);
   20924                 :            : 
   20925         [ #  # ]:          0 :   if (new_body)
   20926                 :            :   {
   20927 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20928         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);    
   20929                 :            :   }
   20930                 :            :   else
   20931                 :            :   {
   20932 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20933         [ #  # ]:          0 :       CubitUndo::remove_last_undo();    
   20934                 :            :   }
   20935                 :            : 
   20936         [ #  # ]:          0 :   return new_body;
   20937                 :            : }
   20938                 :            : 
   20939                 :          0 : Body* GeometryModifyTool::create_circle_surface( double radius, CubitVector plane )
   20940                 :            : {
   20941 [ #  # ][ #  # ]:          0 :   if(0 == gmeList.size())
   20942                 :            :   {
   20943 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
   20944                 :          0 :     return NULL;
   20945                 :            :   }
   20946                 :            : 
   20947         [ #  # ]:          0 :   if( radius <= GEOMETRY_RESABS )
   20948                 :            :   {
   20949 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Values must be positive\n");
         [ #  # ][ #  # ]
   20950                 :          0 :     return NULL;
   20951                 :            :   }
   20952                 :            : 
   20953 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   20954         [ #  # ]:          0 :     CubitUndo::save_state();
   20955                 :            : 
   20956                 :          0 :   BodySM *sheet_body_sm = NULL;
   20957 [ #  # ][ #  # ]:          0 :   CubitStatus status = gmeList.get()->create_circle_surface(radius, plane, sheet_body_sm );
                 [ #  # ]
   20958                 :            : 
   20959         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   20960                 :            :   {
   20961 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20962         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   20963                 :          0 :     return NULL;
   20964                 :            :   }
   20965                 :            : 
   20966                 :          0 :   Body *new_body = NULL;
   20967         [ #  # ]:          0 :   if( sheet_body_sm )
   20968 [ #  # ][ #  # ]:          0 :     new_body = GeometryQueryTool::instance()->make_Body(sheet_body_sm);
   20969                 :            : 
   20970         [ #  # ]:          0 :   if (new_body)
   20971                 :            :   {
   20972 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20973         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);    
   20974                 :            :   }
   20975                 :            :   else
   20976                 :            :   {
   20977 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   20978         [ #  # ]:          0 :       CubitUndo::remove_last_undo();    
   20979                 :            :   }
   20980                 :            : 
   20981                 :          0 :   return new_body;
   20982                 :            : }
   20983                 :            : 
   20984                 :          0 : Body* GeometryModifyTool::create_circle_surface( RefVertex *v1,
   20985                 :            :                                                        RefVertex *v2,
   20986                 :            :                                                        RefVertex *v3 )
   20987                 :            : {
   20988 [ #  # ][ #  # ]:          0 :   if(0 == gmeList.size())
   20989                 :            :   {
   20990 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
   20991                 :          0 :     return NULL;
   20992                 :            :   }
   20993                 :            : 
   20994 [ #  # ][ #  # ]:          0 :   GeometryModifyEngine *GMEPtr = get_engine( v1->get_point_ptr() );
   20995                 :            : 
   20996 [ #  # ][ #  # ]:          0 :   if( GMEPtr != get_engine( v3->get_point_ptr() ) )
                 [ #  # ]
   20997                 :            :   {
   20998 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Vertices are not from same modeling engine.\n");
         [ #  # ][ #  # ]
   20999                 :          0 :     return NULL;
   21000                 :            :   }
   21001                 :            : 
   21002                 :            :   TBPoint *pt1, *pt3;
   21003                 :            : 
   21004         [ #  # ]:          0 :   DLIList<RefVertex*> free_ref_vertices;
   21005 [ #  # ][ #  # ]:          0 :   if( v1->num_parent_ref_entities() == 0 )
   21006                 :            :   {
   21007         [ #  # ]:          0 :     free_ref_vertices.append( v1 );
   21008         [ #  # ]:          0 :     pt1 = v1->get_point_ptr();
   21009                 :            :   }
   21010                 :            :   else
   21011 [ #  # ][ #  # ]:          0 :     pt1 = GMEPtr->make_Point( v1->coordinates() );
   21012                 :            : 
   21013 [ #  # ][ #  # ]:          0 :   if( v3->num_parent_ref_entities() == 0 )
   21014                 :            :   {
   21015         [ #  # ]:          0 :     free_ref_vertices.append( v3 );
   21016         [ #  # ]:          0 :     pt3 = v3->get_point_ptr();
   21017                 :            :   }
   21018                 :            :   else
   21019 [ #  # ][ #  # ]:          0 :     pt3 = GMEPtr->make_Point( v3->coordinates() );
   21020                 :            : 
   21021                 :            : 
   21022 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   21023                 :            :   {
   21024 [ #  # ][ #  # ]:          0 :     if( free_ref_vertices.size() )
   21025         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( free_ref_vertices, true );
   21026                 :            :     else
   21027         [ #  # ]:          0 :       CubitUndo::save_state();
   21028                 :            :   }
   21029                 :            : 
   21030                 :          0 :   BodySM *sheet_body_sm = NULL;
   21031 [ #  # ][ #  # ]:          0 :   CubitStatus status = GMEPtr->create_circle_surface(pt1, v2->coordinates(), pt3, sheet_body_sm );
   21032                 :            : 
   21033         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   21034                 :            :   {
   21035 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21036         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   21037                 :          0 :     return NULL;
   21038                 :            :   }
   21039                 :            : 
   21040                 :          0 :   Body *new_body = NULL;
   21041         [ #  # ]:          0 :   if( sheet_body_sm )
   21042 [ #  # ][ #  # ]:          0 :     new_body = GeometryQueryTool::instance()->make_Body(sheet_body_sm);
   21043                 :            : 
   21044         [ #  # ]:          0 :   if (new_body)
   21045                 :            :   {
   21046 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21047         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);    
   21048                 :            :   }
   21049                 :            :   else
   21050                 :            :   {
   21051 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21052         [ #  # ]:          0 :       CubitUndo::remove_last_undo();    
   21053                 :            :   }
   21054                 :            : 
   21055         [ #  # ]:          0 :   return new_body;
   21056                 :            : }
   21057                 :            : 
   21058                 :          0 : Body* GeometryModifyTool::create_circle_surface( RefVertex *v1,
   21059                 :            :                                                        RefVertex *v2,
   21060                 :            :                                                        CubitVector center_point )
   21061                 :            : {
   21062 [ #  # ][ #  # ]:          0 :   if(0 == gmeList.size())
   21063                 :            :   {
   21064 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
   21065                 :          0 :     return NULL;
   21066                 :            :   }
   21067                 :            : 
   21068 [ #  # ][ #  # ]:          0 :   GeometryModifyEngine *GMEPtr = get_engine( v1->get_point_ptr() );
   21069                 :            : 
   21070 [ #  # ][ #  # ]:          0 :   if( GMEPtr != get_engine( v2->get_point_ptr() ) )
                 [ #  # ]
   21071                 :            :   {
   21072 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Vertices are not from same modeling engine.\n");
         [ #  # ][ #  # ]
   21073                 :          0 :     return NULL;
   21074                 :            :   }
   21075                 :            : 
   21076                 :            :   TBPoint *pt1, *pt2;
   21077                 :            : 
   21078         [ #  # ]:          0 :   DLIList<RefVertex*> free_ref_vertices;
   21079 [ #  # ][ #  # ]:          0 :   if( v1->num_parent_ref_entities() == 0 )
   21080                 :            :   {
   21081         [ #  # ]:          0 :     free_ref_vertices.append( v1 );
   21082         [ #  # ]:          0 :     pt1 = v1->get_point_ptr();
   21083                 :            :   }
   21084                 :            :   else
   21085 [ #  # ][ #  # ]:          0 :     pt1 = GMEPtr->make_Point( v1->coordinates() );
   21086                 :            : 
   21087 [ #  # ][ #  # ]:          0 :   if( v2->num_parent_ref_entities() == 0 )
   21088                 :            :   {
   21089         [ #  # ]:          0 :     free_ref_vertices.append( v2 );
   21090         [ #  # ]:          0 :     pt2 = v2->get_point_ptr();
   21091                 :            :   }
   21092                 :            :   else
   21093 [ #  # ][ #  # ]:          0 :     pt2 = GMEPtr->make_Point( v2->coordinates() );
   21094                 :            : 
   21095                 :            : 
   21096 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   21097                 :            :   {
   21098 [ #  # ][ #  # ]:          0 :     if( free_ref_vertices.size() )
   21099         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( free_ref_vertices, true );
   21100                 :            :     else
   21101         [ #  # ]:          0 :       CubitUndo::save_state();
   21102                 :            :   }
   21103                 :            : 
   21104                 :          0 :   BodySM *sheet_body_sm = NULL;
   21105 [ #  # ][ #  # ]:          0 :   CubitStatus status = GMEPtr->create_circle_surface(pt1, pt2, center_point, sheet_body_sm );
   21106                 :            : 
   21107         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   21108                 :            :   {
   21109 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21110         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   21111                 :          0 :     return NULL;
   21112                 :            :   }
   21113                 :            : 
   21114                 :          0 :   Body *new_body = NULL;
   21115         [ #  # ]:          0 :   if( sheet_body_sm )
   21116 [ #  # ][ #  # ]:          0 :     new_body = GeometryQueryTool::instance()->make_Body(sheet_body_sm);
   21117                 :            : 
   21118         [ #  # ]:          0 :   if (new_body)
   21119                 :            :   {
   21120 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21121         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);    
   21122                 :            :   }
   21123                 :            :   else
   21124                 :            :   {
   21125 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21126         [ #  # ]:          0 :       CubitUndo::remove_last_undo();    
   21127                 :            :   }
   21128                 :            : 
   21129         [ #  # ]:          0 :   return new_body;
   21130                 :            : }
   21131                 :            : 
   21132                 :          0 : Body* GeometryModifyTool::create_ellipse_surface( RefVertex *v1,
   21133                 :            :                                                   RefVertex *v2,
   21134                 :            :                                                   CubitVector center_point )
   21135                 :            : {
   21136 [ #  # ][ #  # ]:          0 :   if(0 == gmeList.size())
   21137                 :            :   {
   21138 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
   21139                 :          0 :     return NULL;
   21140                 :            :   }
   21141                 :            : 
   21142 [ #  # ][ #  # ]:          0 :   GeometryModifyEngine *GMEPtr = get_engine( v1->get_point_ptr() );
   21143                 :            : 
   21144 [ #  # ][ #  # ]:          0 :   if( GMEPtr != get_engine( v2->get_point_ptr() ) )
                 [ #  # ]
   21145                 :            :   {
   21146 [ #  # ][ #  # ]:          0 :     PRINT_INFO("Vertices are not from same modeling engine.\n");
         [ #  # ][ #  # ]
   21147                 :          0 :     return NULL;
   21148                 :            :   }
   21149                 :            : 
   21150                 :            :   TBPoint *pt1, *pt2;
   21151                 :            : 
   21152         [ #  # ]:          0 :   DLIList<RefVertex*> free_ref_vertices;
   21153 [ #  # ][ #  # ]:          0 :   if( v1->num_parent_ref_entities() == 0 )
   21154                 :            :   {
   21155         [ #  # ]:          0 :     free_ref_vertices.append( v1 );
   21156         [ #  # ]:          0 :     pt1 = v1->get_point_ptr();
   21157                 :            :   }
   21158                 :            :   else
   21159 [ #  # ][ #  # ]:          0 :     pt1 = GMEPtr->make_Point( v1->coordinates() );
   21160                 :            : 
   21161 [ #  # ][ #  # ]:          0 :   if( v2->num_parent_ref_entities() == 0 )
   21162                 :            :   {
   21163         [ #  # ]:          0 :     free_ref_vertices.append( v2 );
   21164         [ #  # ]:          0 :     pt2 = v2->get_point_ptr();
   21165                 :            :   }
   21166                 :            :   else
   21167 [ #  # ][ #  # ]:          0 :     pt2 = GMEPtr->make_Point( v2->coordinates() );
   21168                 :            : 
   21169 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   21170                 :            :   {
   21171 [ #  # ][ #  # ]:          0 :     if( free_ref_vertices.size() )
   21172         [ #  # ]:          0 :       CubitUndo::save_state_with_cubit_file( free_ref_vertices, true );
   21173                 :            :     else
   21174         [ #  # ]:          0 :       CubitUndo::save_state();
   21175                 :            :   }
   21176                 :            : 
   21177                 :          0 :   BodySM *sheet_body_sm = NULL;
   21178 [ #  # ][ #  # ]:          0 :   CubitStatus status = GMEPtr->create_ellipse_surface(pt1, pt2, center_point, sheet_body_sm );
   21179                 :            : 
   21180         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   21181                 :            :   {
   21182 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21183         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   21184                 :          0 :     return NULL;
   21185                 :            :   }
   21186                 :            : 
   21187                 :          0 :   Body *new_body = NULL;
   21188         [ #  # ]:          0 :   if( sheet_body_sm )
   21189 [ #  # ][ #  # ]:          0 :     new_body = GeometryQueryTool::instance()->make_Body(sheet_body_sm);
   21190                 :            : 
   21191         [ #  # ]:          0 :   if (new_body)
   21192                 :            :   {
   21193 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21194         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);    
   21195                 :            :   }
   21196                 :            :   else
   21197                 :            :   {
   21198 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21199         [ #  # ]:          0 :       CubitUndo::remove_last_undo();    
   21200                 :            :   }
   21201                 :            : 
   21202         [ #  # ]:          0 :   return new_body;
   21203                 :            : }
   21204                 :            : 
   21205                 :          0 : Body* GeometryModifyTool::create_ellipse_surface( double major_radius,
   21206                 :            :                                                   double minor_radius,
   21207                 :            :                                                   CubitVector plane )
   21208                 :            : {
   21209 [ #  # ][ #  # ]:          0 :   if(0 == gmeList.size())
   21210                 :            :   {
   21211 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
         [ #  # ][ #  # ]
   21212                 :          0 :     return NULL;
   21213                 :            :   }
   21214                 :            : 
   21215 [ #  # ][ #  # ]:          0 :   if( major_radius <= GEOMETRY_RESABS || minor_radius <= GEOMETRY_RESABS )
   21216                 :            :   {
   21217 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Values must be positive\n");
         [ #  # ][ #  # ]
   21218                 :          0 :     return NULL;
   21219                 :            :   }
   21220                 :            : 
   21221 [ #  # ][ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   21222         [ #  # ]:          0 :     CubitUndo::save_state();
   21223                 :            : 
   21224                 :          0 :   BodySM *sheet_body_sm = NULL;
   21225 [ #  # ][ #  # ]:          0 :   CubitStatus status = gmeList.get()->create_ellipse_surface(major_radius, minor_radius, plane, sheet_body_sm );
                 [ #  # ]
   21226                 :            : 
   21227         [ #  # ]:          0 :   if( status == CUBIT_FAILURE )
   21228                 :            :   {
   21229 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21230         [ #  # ]:          0 :       CubitUndo::remove_last_undo();
   21231                 :          0 :     return NULL;
   21232                 :            :   }
   21233                 :            : 
   21234                 :          0 :   Body *new_body = NULL;
   21235         [ #  # ]:          0 :   if( sheet_body_sm )
   21236 [ #  # ][ #  # ]:          0 :     new_body = GeometryQueryTool::instance()->make_Body(sheet_body_sm);
   21237                 :            : 
   21238         [ #  # ]:          0 :   if (new_body)
   21239                 :            :   {
   21240 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21241         [ #  # ]:          0 :       CubitUndo::note_result_body(new_body);    
   21242                 :            :   }
   21243                 :            :   else
   21244                 :            :   {
   21245 [ #  # ][ #  # ]:          0 :     if(CubitUndo::get_undo_enabled())
   21246         [ #  # ]:          0 :       CubitUndo::remove_last_undo();    
   21247                 :            :   }
   21248                 :            : 
   21249                 :          0 :   return new_body;
   21250                 :            : }
   21251                 :            : 
   21252                 :          0 : CubitStatus GeometryModifyTool::create_curve_helix( CubitVector &location,
   21253                 :            :                                                     CubitVector &direction,
   21254                 :            :                                                     CubitVector &start_point,
   21255                 :            :                                                     double &thread_distance,
   21256                 :            :                                                     double &angle,
   21257                 :            :                                                     bool right_handed,
   21258                 :            :                                                     RefEdge *&new_ref_edge_ptr)
   21259                 :            : {
   21260         [ #  # ]:          0 :   if (0 == gmeList.size())
   21261                 :            :   {
   21262 [ #  # ][ #  # ]:          0 :     PRINT_WARNING("No active geometry engine.\n");
   21263                 :          0 :     return CUBIT_FAILURE;
   21264                 :            :   }
   21265                 :            : 
   21266                 :          0 :   Curve *new_curve = gmeList.get()->create_curve_helix(location, direction,
   21267                 :            :                                                 start_point, thread_distance,
   21268                 :          0 :                                                 angle, right_handed );
   21269                 :            : 
   21270         [ #  # ]:          0 :   if (new_curve == NULL)
   21271                 :          0 :     return CUBIT_FAILURE;
   21272                 :            : 
   21273         [ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   21274                 :          0 :     CubitUndo::save_state();
   21275                 :            : 
   21276                 :          0 :   new_ref_edge_ptr = GeometryQueryTool::instance()->make_free_RefEdge(new_curve);
   21277                 :            : 
   21278         [ #  # ]:          0 :   if( CubitUndo::get_undo_enabled() )
   21279         [ #  # ]:          0 :     CubitUndo::note_result_entity( new_ref_edge_ptr );
   21280                 :            : 
   21281                 :          0 :   return CUBIT_SUCCESS;
   21282                 :            : }
   21283                 :            : 
   21284                 :         11 : void GeometryModifyTool::remove_bodies_outside_bounding_box(
   21285                 :            :   DLIList<Body*> &body_list,
   21286                 :            :         CubitBox &tool_bounding_box )
   21287                 :            : {
   21288                 :            :   //remove bodies that don't overlap
   21289         [ +  + ]:         22 :   for( int k=body_list.size(); k--; )
   21290                 :            :   {
   21291                 :         11 :     Body *tmp_body = body_list.get();
   21292 [ +  - ][ -  + ]:         11 :     if( !tool_bounding_box.overlap( 0.001, tmp_body->bounding_box() ) )
   21293                 :          0 :       body_list.change_to( NULL );
   21294                 :         11 :     body_list.step();
   21295                 :            :   }
   21296                 :            : 
   21297         [ +  - ]:         11 :   body_list.remove_all_with_value(NULL);
   21298                 :         11 : }
   21299                 :            : 
   21300                 :            : 
   21301                 :            : 
   21302                 :         11 : void GeometryModifyTool::remove_bodies_outside_bounding_box(
   21303                 :            :   DLIList<Body*> &body_list,
   21304                 :            :         CubitVector v1, CubitVector v2, CubitVector v3 )
   21305                 :            : {
   21306                 :            :         //create a bounding box from the body list and the passed in points
   21307         [ +  - ]:         11 :         CubitBox bbox1;
   21308 [ +  - ][ +  + ]:         22 :         for( int k=body_list.size(); k--; )
   21309 [ +  - ][ +  - ]:         11 :                 bbox1 |= body_list.get_and_step()->bounding_box();
         [ +  - ][ +  - ]
   21310                 :            : 
   21311                 :            :   //add in the pts
   21312         [ +  - ]:         11 :   bbox1 |= v1;
   21313         [ +  - ]:         11 :   bbox1 |= v2;
   21314         [ +  - ]:         11 :   bbox1 |= v3;
   21315                 :            : 
   21316                 :            :         //get the diagonal of the bounding box
   21317 [ +  - ][ +  - ]:         11 :   double diagonal_length = bbox1.diagonal().length();
   21318                 :            : 
   21319                 :            :         //offset each point by the diagonal
   21320         [ +  - ]:         11 :   CubitVector new_pt;
   21321         [ +  - ]:         11 :   CubitVector direction;
   21322 [ +  - ][ +  - ]:         11 :   direction = v2-v1;
   21323         [ +  - ]:         11 :   direction.normalize();
   21324 [ +  - ][ +  - ]:         11 :   new_pt = v1 + direction*diagonal_length;
                 [ +  - ]
   21325                 :            : 
   21326 [ +  - ][ +  - ]:         22 :   CubitBox bbox2( new_pt );
   21327                 :            : 
   21328 [ +  - ][ +  - ]:         11 :   direction = v3-v1;
   21329         [ +  - ]:         11 :   direction.normalize();
   21330 [ +  - ][ +  - ]:         11 :   new_pt = v1 + direction*diagonal_length;
                 [ +  - ]
   21331         [ +  - ]:         11 :   bbox2 |= new_pt;
   21332                 :            : 
   21333 [ +  - ][ +  - ]:         11 :   direction = v1-v2;
   21334         [ +  - ]:         11 :   direction.normalize();
   21335 [ +  - ][ +  - ]:         11 :   new_pt = v2 + direction*diagonal_length;
                 [ +  - ]
   21336         [ +  - ]:         11 :   bbox2 |= new_pt;
   21337 [ +  - ][ +  - ]:         11 :   direction = v3-v2;
   21338         [ +  - ]:         11 :   direction.normalize();
   21339 [ +  - ][ +  - ]:         11 :   new_pt = v2 + direction*diagonal_length;
                 [ +  - ]
   21340         [ +  - ]:         11 :   bbox2 |= new_pt;
   21341                 :            : 
   21342 [ +  - ][ +  - ]:         11 :   direction = v1-v3;
   21343         [ +  - ]:         11 :   direction.normalize();
   21344 [ +  - ][ +  - ]:         11 :   new_pt = v3 + direction*diagonal_length;
                 [ +  - ]
   21345         [ +  - ]:         11 :   bbox2 |= new_pt;
   21346 [ +  - ][ +  - ]:         11 :   direction = v2-v3;
   21347         [ +  - ]:         11 :   direction.normalize();
   21348 [ +  - ][ +  - ]:         11 :   new_pt = v3 + direction*diagonal_length;
                 [ +  - ]
   21349         [ +  - ]:         11 :   bbox2 |= new_pt;
   21350                 :            : 
   21351                 :            :   //remove bodies that don't overlap
   21352 [ +  - ][ +  + ]:         22 :   for( int k=body_list.size(); k--; )
   21353                 :            :   {
   21354         [ +  - ]:         11 :     Body *tmp_body = body_list.get();
   21355 [ +  - ][ +  - ]:         11 :     if( !bbox2.overlap( 0.001, tmp_body->bounding_box() ) )
         [ +  - ][ -  + ]
   21356         [ #  # ]:          0 :       body_list.change_to( NULL );
   21357         [ +  - ]:         11 :     body_list.step();
   21358                 :            :   }
   21359                 :            : 
   21360 [ +  - ][ +  - ]:         22 :   body_list.remove_all_with_value(NULL);
   21361                 :         11 : }
   21362                 :            : 
   21363                 :          0 : CubitStatus prepare_surface_sweep(
   21364                 :            :                               DLIList<BodySM*> &blank_bodies,
   21365                 :            :                               DLIList<Surface*> &surfaces,
   21366                 :            :                               const CubitVector& sweep_vector,
   21367                 :            :                               bool sweep_perp,
   21368                 :            :                               bool through_all,
   21369                 :            :                               bool outward,
   21370                 :            :                               bool up_to_next,
   21371                 :            :                               Surface *stop_surf,
   21372                 :            :                               Curve *curve_to_sweep_along,
   21373                 :            :                               BodySM* &cutting_tool_ptr ,
   21374                 :            :                               const CubitVector* point ,
   21375                 :            :                               double *angle )
   21376                 :            : {
   21377                 :            :   GeometryModifyEngine* gme = GeometryModifyTool::instance()->
   21378 [ #  # ][ #  # ]:          0 :                                   get_engine(blank_bodies.get());
                 [ #  # ]
   21379                 :            : 
   21380 [ #  # ][ #  # ]:          0 :   if(surfaces.size() == 0 )
   21381                 :          0 :     return CUBIT_FAILURE;
   21382                 :            : 
   21383         [ #  # ]:          0 :   DLIList<GeometryEntity*> ref_ent_list;
   21384                 :          0 :   Surface * temp_face = NULL;
   21385 [ #  # ][ #  # ]:          0 :   for(int i = 0; i < surfaces.size(); i++)
   21386                 :            :     {
   21387                 :            :       //copy the faces before sweep
   21388 [ #  # ][ #  # ]:          0 :       temp_face = gme->make_Surface(surfaces.get_and_step());
   21389         [ #  # ]:          0 :       if (temp_face)
   21390         [ #  # ]:          0 :         ref_ent_list.append((GeometryEntity*)temp_face);
   21391                 :            :     }
   21392                 :            : 
   21393                 :          0 :   BodySM* to_body = NULL;
   21394                 :          0 :   CubitStatus stat = CUBIT_SUCCESS;
   21395 [ #  # ][ #  # ]:          0 :   if(up_to_next && blank_bodies.size() > 1) //unite all bland_bodies
         [ #  # ][ #  # ]
   21396                 :            :     {
   21397         [ #  # ]:          0 :        DLIList<BodySM*> newBodies;
   21398 [ #  # ][ #  # ]:          0 :        DLIList<BodySM*> copied_bodies;
                 [ #  # ]
   21399 [ #  # ][ #  # ]:          0 :        for(int i = 0; i < blank_bodies.size(); i++)
   21400 [ #  # ][ #  # ]:          0 :          copied_bodies.append(gme->copy_body(blank_bodies.get_and_step()));
                 [ #  # ]
   21401                 :            : 
   21402         [ #  # ]:          0 :        stat = gme->unite(copied_bodies, newBodies);
   21403         [ #  # ]:          0 :        if(stat == CUBIT_FAILURE)
   21404                 :            :          {
   21405 [ #  # ][ #  # ]:          0 :            PRINT_ERROR("Cannot use 'up_to_next' option with specified geometry\n");
         [ #  # ][ #  # ]
   21406 [ #  # ][ #  # ]:          0 :            PRINT_INFO("Try the 'stop surface <id>' option instead\n");
         [ #  # ][ #  # ]
   21407                 :          0 :            return stat;
   21408                 :            :          }
   21409 [ #  # ][ #  # ]:          0 :        to_body = newBodies.get();
                 [ #  # ]
   21410                 :            :     }
   21411                 :            : 
   21412 [ #  # ][ #  # ]:          0 :   else if(up_to_next && blank_bodies.size() == 1)
         [ #  # ][ #  # ]
   21413 [ #  # ][ #  # ]:          0 :     to_body = gme->copy_body(blank_bodies.get());
   21414                 :            : 
   21415 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*> swept_bodies;
   21416 [ #  # ][ #  # ]:          0 :   if (point && angle) //sweep_surface_rotated
   21417                 :            :     stat = gme->sweep_rotational(ref_ent_list,swept_bodies,*point,
   21418                 :            :                            sweep_vector, *angle,0, 0.0,0,false,false,
   21419         [ #  # ]:          0 :                            false,stop_surf, to_body);
   21420                 :            : 
   21421                 :            :   else
   21422                 :            :   {
   21423         [ #  # ]:          0 :     CubitVector tmp_sweep_vector = sweep_vector;
   21424                 :            : 
   21425                 :            :     //get model bbox info...will scale sweep vector by its diagonal
   21426                 :            :     //so that we go far enough
   21427 [ #  # ][ #  # ]:          0 :     if( through_all || stop_surf || up_to_next)
                 [ #  # ]
   21428                 :            :     {
   21429 [ #  # ][ #  # ]:          0 :       CubitBox bounding_box = GeometryQueryTool::instance()->model_bounding_box();
   21430         [ #  # ]:          0 :       tmp_sweep_vector.normalize();
   21431 [ #  # ][ #  # ]:          0 :       tmp_sweep_vector*=(2*bounding_box.diagonal().length());
         [ #  # ][ #  # ]
   21432                 :            :     }
   21433                 :            : 
   21434                 :            :     //see if we're sweeping along a specified curve
   21435         [ #  # ]:          0 :     if( curve_to_sweep_along )
   21436                 :            :       {
   21437         [ #  # ]:          0 :         DLIList<Curve*> curves_to_sweep_along;
   21438         [ #  # ]:          0 :         curves_to_sweep_along.append(curve_to_sweep_along);
   21439                 :            :         stat = gme->sweep_along_curve(ref_ent_list, swept_bodies,
   21440                 :            :                                  curves_to_sweep_along, 0.0,0,false,stop_surf,
   21441 [ #  # ][ #  # ]:          0 :                                  to_body);
   21442                 :            :       }
   21443                 :            : 
   21444         [ #  # ]:          0 :     else if (sweep_perp )
   21445                 :            :       stat = gme->sweep_perpendicular(ref_ent_list, swept_bodies,
   21446                 :          0 :                                  tmp_sweep_vector.length(),0.0,0,!outward,false,
   21447 [ #  # ][ #  # ]:          0 :                                  stop_surf, to_body);
   21448                 :            :     else
   21449                 :            :       stat = gme->sweep_translational(ref_ent_list, swept_bodies,
   21450                 :            :                                  tmp_sweep_vector,0.0,0, false, false, stop_surf,
   21451         [ #  # ]:          0 :                                  to_body);
   21452                 :            :   }
   21453                 :            : 
   21454 [ #  # ][ #  # ]:          0 :   if(stat == CUBIT_FAILURE || swept_bodies.size() == 0)
         [ #  # ][ #  # ]
   21455                 :            :     {
   21456                 :            :        //delete copied faces
   21457                 :          0 :        GeometryEntity * temp_entity = NULL;
   21458 [ #  # ][ #  # ]:          0 :        for(int i = ref_ent_list.size();i--;)
   21459                 :            :          {
   21460         [ #  # ]:          0 :             temp_entity = ref_ent_list.get_and_step();
   21461         [ #  # ]:          0 :             if (temp_entity)
   21462 [ #  # ][ #  # ]:          0 :               gme->get_gqe()->delete_solid_model_entities( (Surface*)temp_entity);
   21463                 :            :          }
   21464                 :            : 
   21465                 :          0 :        return stat;
   21466                 :            :     }
   21467                 :            : 
   21468                 :            :   //if there are more than 1, unite them all
   21469 [ #  # ][ #  # ]:          0 :   DLIList<BodySM*>  newBodies;
   21470 [ #  # ][ #  # ]:          0 :   if (swept_bodies.size() > 1)
   21471         [ #  # ]:          0 :      stat = gme->unite(swept_bodies, newBodies);
   21472                 :            :   else
   21473         [ #  # ]:          0 :      newBodies = swept_bodies;
   21474                 :            : 
   21475 [ #  # ][ #  # ]:          0 :   if(stat == CUBIT_FAILURE || newBodies.size()!= 1)
         [ #  # ][ #  # ]
   21476                 :            :     {
   21477 [ #  # ][ #  # ]:          0 :        PRINT_ERROR("webcut tool body is not created from occ.\n");
         [ #  # ][ #  # ]
   21478                 :            :        //delete the swept_bodies
   21479                 :          0 :        BodySM* tmp_body = NULL;
   21480 [ #  # ][ #  # ]:          0 :        for (int i = swept_bodies.size(); i--;)
   21481                 :            :          {
   21482         [ #  # ]:          0 :            tmp_body= swept_bodies.get_and_step();
   21483         [ #  # ]:          0 :            if (tmp_body)
   21484 [ #  # ][ #  # ]:          0 :              gme->get_gqe()->delete_solid_model_entities(tmp_body);
   21485                 :            :          }
   21486                 :            : 
   21487                 :            :        //delete copied faces
   21488                 :          0 :        GeometryEntity * temp_entity = NULL;
   21489 [ #  # ][ #  # ]:          0 :        for(int i = ref_ent_list.size();i--;)
   21490                 :            :          {
   21491         [ #  # ]:          0 :             temp_entity = ref_ent_list.get_and_step();
   21492         [ #  # ]:          0 :             if (temp_entity)
   21493 [ #  # ][ #  # ]:          0 :               gme->get_gqe()->delete_solid_model_entities( (Surface*)temp_entity);
   21494                 :            :          }
   21495                 :          0 :        return CUBIT_FAILURE;
   21496                 :            :     }
   21497                 :            : 
   21498         [ #  # ]:          0 :     cutting_tool_ptr = newBodies.get();
   21499         [ #  # ]:          0 :     return stat;
   21500                 :            : }
   21501                 :            : 
   21502                 :            : 
   21503                 :            : 
   21504                 :            : //******************************************************************************************************************************
   21505                 :          0 : CubitVector GeometryModifyTool::FindExtendedEndPt( double outer_rad , double inner_rad , CubitVector inner_AxisPt ,
   21506                 :            :                                                     CubitVector Axis , double Height )
   21507                 :            : {
   21508         [ #  # ]:          0 :     CubitVector Extended_End_Pt;
   21509                 :            : 
   21510                 :          0 :     double Diff     = (outer_rad - inner_rad);
   21511                 :          0 :            Diff    /= Height;
   21512                 :          0 :     double dAngle   = atan ( Diff ) ;
   21513         [ #  # ]:          0 :     Axis.normalize();
   21514                 :            : 
   21515                 :          0 :     double dTan        = tan( dAngle );
   21516                 :          0 :     double dExtendvalue = inner_rad / dTan;
   21517                 :            : 
   21518         [ #  # ]:          0 :     CubitVector ExtendedPt;
   21519 [ #  # ][ #  # ]:          0 :     ExtendedPt.x( ( Axis.x() * dExtendvalue )  + inner_AxisPt.x() );
                 [ #  # ]
   21520 [ #  # ][ #  # ]:          0 :     ExtendedPt.y( ( Axis.y() * dExtendvalue )  + inner_AxisPt.y() );
                 [ #  # ]
   21521 [ #  # ][ #  # ]:          0 :     ExtendedPt.z( ( Axis.z() * dExtendvalue )  + inner_AxisPt.z() );
                 [ #  # ]
   21522                 :            : 
   21523                 :          0 :     return ExtendedPt;
   21524                 :            : }
   21525                 :            : //**********************************************************************************************************************************
   21526                 :          0 : CubitVector GeometryModifyTool::FindExtendedStartPt( CubitBox Box , double outer_rad , double inner_rad , CubitVector AxisPt ,
   21527                 :            :                                                     CubitVector Axis , double &dLength , double dTanAngle,  double &dExtendedadius )
   21528                 :            : {
   21529         [ #  # ]:          0 :     CubitVector Extended_Start_Pt;
   21530                 :            : 
   21531                 :            :     // Find the Difference between the Max and thre min values in all 3 directions.
   21532                 :            :     // Incase the point is within the box limits, then add the difference values
   21533                 :            :     // in all 3 directions , witht he " Axis " as the direction vector and extend the point.
   21534                 :            : 
   21535                 :            :     // After that find the Radius of this bigger end.
   21536                 :            : 
   21537         [ #  # ]:          0 :     CubitVector DiffVec;
   21538                 :            : 
   21539         [ #  # ]:          0 :     Axis.normalize();
   21540                 :            : 
   21541 [ #  # ][ #  # ]:          0 :     DiffVec.x( fabs( Box.max_x() - Box.min_x() ));
                 [ #  # ]
   21542 [ #  # ][ #  # ]:          0 :     DiffVec.y( fabs( Box.max_y() - Box.min_y() ));
                 [ #  # ]
   21543 [ #  # ][ #  # ]:          0 :     DiffVec.z( fabs( Box.max_z() - Box.min_z() ));
                 [ #  # ]
   21544                 :            : 
   21545                 :            :     // Extend the start Pt
   21546                 :            : 
   21547 [ #  # ][ #  # ]:          0 :     Extended_Start_Pt.x( AxisPt.x() + ( Axis.x() * DiffVec.x() ) );
         [ #  # ][ #  # ]
   21548 [ #  # ][ #  # ]:          0 :     Extended_Start_Pt.y( AxisPt.y() + ( Axis.y() * DiffVec.y() ) );
         [ #  # ][ #  # ]
   21549 [ #  # ][ #  # ]:          0 :     Extended_Start_Pt.z( AxisPt.z() + ( Axis.z() * DiffVec.z() ) );
         [ #  # ][ #  # ]
   21550                 :            : 
   21551                 :            : 
   21552                 :            :     // Find the length
   21553                 :            : 
   21554 [ #  # ][ #  # ]:          0 :     dLength = sqrt( (( AxisPt.x() - Extended_Start_Pt.x()) *  (AxisPt.x() - Extended_Start_Pt.x()) ) +
         [ #  # ][ #  # ]
   21555 [ #  # ][ #  # ]:          0 :                            (( AxisPt.y() - Extended_Start_Pt.y()) *  (AxisPt.y() - Extended_Start_Pt.y()) ) +
         [ #  # ][ #  # ]
   21556 [ #  # ][ #  # ]:          0 :                            (( AxisPt.z() - Extended_Start_Pt.z()) *  (AxisPt.z() - Extended_Start_Pt.z()) ) );
         [ #  # ][ #  # ]
   21557                 :            : 
   21558                 :            : 
   21559                 :            : 
   21560                 :            :     // Find the Extended Radius
   21561                 :            : 
   21562                 :          0 :     dExtendedadius = outer_rad + ( tan( dTanAngle ) /** 2 */* dLength ) ;
   21563                 :            : 
   21564                 :          0 :     return Extended_Start_Pt;
   21565                 :            : }
   21566                 :            : //*****************************************************************************************************************************************
   21567                 :          0 : void GeometryModifyTool::FindExtendedPoints( CubitVector AxisPt1 , CubitVector AxisPt2 , double outer_radius , double inner_radius ,
   21568                 :            :             CubitVector axis,double Height , CubitBox bounding_box , double dTanAngle ,
   21569                 :            :             CubitVector& start , CubitVector& end , double& dExtended_OuterRadius, double& dExtended_InnerRadius  )
   21570                 :            : {
   21571                 :            : 
   21572         [ #  # ]:          0 :     CubitVector endpt ;
   21573         [ #  # ]:          0 :     if( outer_radius > inner_radius )
   21574                 :            :     {
   21575 [ #  # ][ #  # ]:          0 :         endpt  = FindExtendedEndPt( outer_radius , inner_radius , AxisPt2 , axis,  Height );
         [ #  # ][ #  # ]
   21576 [ #  # ][ #  # ]:          0 :         Height = sqrt( (endpt.x() - AxisPt1.x()) * (endpt.x() - AxisPt1.x())+
         [ #  # ][ #  # ]
   21577 [ #  # ][ #  # ]:          0 :             (endpt.y() - AxisPt1.y()) * (endpt.y() - AxisPt1.y())+
         [ #  # ][ #  # ]
   21578 [ #  # ][ #  # ]:          0 :             (endpt.z() - AxisPt1.z()) * (endpt.z() - AxisPt1.z()) );
         [ #  # ][ #  # ]
   21579                 :            : 
   21580 [ #  # ][ #  # ]:          0 :         AxisPt2.x( endpt.x() );
   21581 [ #  # ][ #  # ]:          0 :         AxisPt2.y( endpt.y() );
   21582 [ #  # ][ #  # ]:          0 :         AxisPt2.z( endpt.z() );
   21583                 :            : 
   21584 [ #  # ][ #  # ]:          0 :         end.x( endpt.x() );
   21585 [ #  # ][ #  # ]:          0 :         end.y( endpt.y() );
   21586 [ #  # ][ #  # ]:          0 :         end.z( endpt.z() );
   21587                 :            : 
   21588                 :          0 :         dExtended_InnerRadius = 0;
   21589                 :            :     }
   21590                 :            :     else
   21591                 :            :     {
   21592                 :            :         // reverse the axis.
   21593                 :            : 
   21594 [ #  # ][ #  # ]:          0 :         axis.x( -axis.x());
   21595 [ #  # ][ #  # ]:          0 :         axis.y( -axis.y());
   21596 [ #  # ][ #  # ]:          0 :         axis.z( -axis.z());
   21597                 :            : 
   21598 [ #  # ][ #  # ]:          0 :         endpt  = FindExtendedEndPt( inner_radius , outer_radius , AxisPt1 , axis,  Height );
         [ #  # ][ #  # ]
   21599 [ #  # ][ #  # ]:          0 :         Height = sqrt( (endpt.x() - AxisPt2.x()) * (endpt.x() - AxisPt2.x())+
         [ #  # ][ #  # ]
   21600 [ #  # ][ #  # ]:          0 :             (endpt.y() - AxisPt2.y()) * (endpt.y() - AxisPt2.y())+
         [ #  # ][ #  # ]
   21601 [ #  # ][ #  # ]:          0 :             (endpt.z() - AxisPt2.z()) * (endpt.z() - AxisPt2.z()) );
         [ #  # ][ #  # ]
   21602                 :            : 
   21603 [ #  # ][ #  # ]:          0 :         AxisPt1.x( endpt.x() );
   21604 [ #  # ][ #  # ]:          0 :         AxisPt1.y( endpt.y() );
   21605 [ #  # ][ #  # ]:          0 :         AxisPt1.z( endpt.z() );
   21606                 :            : 
   21607 [ #  # ][ #  # ]:          0 :         start.x( endpt.x() );
   21608 [ #  # ][ #  # ]:          0 :         start.y( endpt.y() );
   21609 [ #  # ][ #  # ]:          0 :         start.z( endpt.z() );
   21610                 :            : 
   21611                 :            :         // reset the axis.
   21612 [ #  # ][ #  # ]:          0 :         axis.x( -axis.x());
   21613 [ #  # ][ #  # ]:          0 :         axis.y( -axis.y());
   21614 [ #  # ][ #  # ]:          0 :         axis.z( -axis.z());
   21615                 :            : 
   21616                 :            : 
   21617                 :          0 :         dExtended_OuterRadius = 0;
   21618                 :            : 
   21619                 :            :      }
   21620                 :            : 
   21621                 :            : 
   21622                 :            : 
   21623                 :            :     //*****************************************//
   21624                 :            :     // Now find the extension of the bigger end.
   21625                 :            :     //*****************************************//
   21626                 :            : 
   21627         [ #  # ]:          0 :     if( outer_radius > inner_radius )
   21628                 :            :     {
   21629                 :            :         // reverse the axis.
   21630 [ #  # ][ #  # ]:          0 :         axis.x( -axis.x());
   21631 [ #  # ][ #  # ]:          0 :         axis.y( -axis.y());
   21632 [ #  # ][ #  # ]:          0 :         axis.z( -axis.z());
   21633                 :            : 
   21634                 :            : 
   21635 [ #  # ][ #  # ]:          0 :         endpt  = FindExtendedStartPt( bounding_box , outer_radius , inner_radius , AxisPt1 , axis,  Height , dTanAngle , dExtended_OuterRadius );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   21636 [ #  # ][ #  # ]:          0 :         Height = sqrt( (endpt.x() - AxisPt2.x()) * (endpt.x() - AxisPt2.x())+
         [ #  # ][ #  # ]
   21637 [ #  # ][ #  # ]:          0 :             (endpt.y() - AxisPt2.y()) * (endpt.y() - AxisPt2.y())+
         [ #  # ][ #  # ]
   21638 [ #  # ][ #  # ]:          0 :             (endpt.z() - AxisPt2.z()) * (endpt.z() - AxisPt2.z()) );
         [ #  # ][ #  # ]
   21639                 :            : 
   21640 [ #  # ][ #  # ]:          0 :         AxisPt1.x( endpt.x() );
   21641 [ #  # ][ #  # ]:          0 :         AxisPt1.y( endpt.y() );
   21642 [ #  # ][ #  # ]:          0 :         AxisPt1.z( endpt.z() );
   21643                 :            : 
   21644 [ #  # ][ #  # ]:          0 :         start.x( endpt.x() );
   21645 [ #  # ][ #  # ]:          0 :         start.y( endpt.y() );
   21646 [ #  # ][ #  # ]:          0 :         start.z( endpt.z() );
   21647                 :            : 
   21648                 :            :         // reverse the axis.
   21649 [ #  # ][ #  # ]:          0 :         axis.x( -axis.x());
   21650 [ #  # ][ #  # ]:          0 :         axis.y( -axis.y());
   21651 [ #  # ][ #  # ]:          0 :         axis.z( -axis.z());
   21652                 :            : 
   21653                 :            :     }
   21654                 :            :     else
   21655                 :            :     {
   21656 [ #  # ][ #  # ]:          0 :         endpt  = FindExtendedStartPt( bounding_box ,  inner_radius , outer_radius , AxisPt2 , axis,  Height , dTanAngle , dExtended_InnerRadius );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   21657 [ #  # ][ #  # ]:          0 :         Height = sqrt( (endpt.x() - AxisPt1.x()) * (endpt.x() - AxisPt1.x())+
         [ #  # ][ #  # ]
   21658 [ #  # ][ #  # ]:          0 :             (endpt.y() - AxisPt1.y()) * (endpt.y() - AxisPt1.y())+
         [ #  # ][ #  # ]
   21659 [ #  # ][ #  # ]:          0 :             (endpt.z() - AxisPt1.z()) * (endpt.z() - AxisPt1.z()) );
         [ #  # ][ #  # ]
   21660                 :            : 
   21661 [ #  # ][ #  # ]:          0 :         AxisPt2.x( endpt.x() );
   21662 [ #  # ][ #  # ]:          0 :         AxisPt2.y( endpt.y() );
   21663 [ #  # ][ #  # ]:          0 :         AxisPt2.z( endpt.z() );
   21664                 :            : 
   21665 [ #  # ][ #  # ]:          0 :         end.x( endpt.x() );
   21666 [ #  # ][ #  # ]:          0 :         end.y( endpt.y() );
   21667 [ #  # ][ #  # ]:          0 :         end.z( endpt.z() );
   21668                 :            :     }
   21669                 :          0 : }
   21670                 :            : 
   21671                 :            : //This function gets called after RefEntities have been created
   21672                 :            : //on TopologyBridges.  It builds up a map from original RefEntity 
   21673                 :            : //to the copy RefEntity.  Used when copying Bodies, RefFaces, and
   21674                 :            : //RefEdges.
   21675                 :          0 : CubitStatus GeometryModifyTool::create_old_to_new_ref_ent_map( 
   21676                 :            :    TopologyBridge *old_top_level_bridge,
   21677                 :            :    TopologyBridge *new_top_level_bridge,
   21678                 :            :    std::map< RefEntity*, RefEntity* > &old_to_new_map,
   21679                 :            :    std::map< TopologyBridge*, TopologyBridge*> &old_tb_to_new_tb )
   21680                 :            : {
   21681         [ #  # ]:          0 :   std::vector< std::pair<TopologyBridge*, TopologyBridge*> > unmatched_pairs;
   21682                 :          0 :   bool debug = false;
   21683         [ #  # ]:          0 :   std::map< TopologyBridge*, TopologyBridge*>::iterator iter;  
   21684                 :            : 
   21685                 :            :   //This first loop tries to find a RefEntity on each TopologyBridge pair in the
   21686                 :            :   //map 'old_tb_to_new_tb'.  If there is no virtual geometry here, everything
   21687                 :            :   //should be found.  If it didn't find a RefEntity, put it in the 
   21688                 :            :   //unmatched_pairs vector.
   21689 [ #  # ][ #  # ]:          0 :   for( iter = old_tb_to_new_tb.begin(); iter!=old_tb_to_new_tb.end(); iter++ )
         [ #  # ][ #  # ]
                 [ #  # ]
   21690                 :            :   {
   21691 [ #  # ][ #  # ]:          0 :     std::pair<TopologyBridge*, TopologyBridge*> tmp_pair = *iter;
   21692                 :          0 :     TopologyBridge *old_tb = tmp_pair.first;
   21693                 :          0 :     TopologyBridge *new_tb = tmp_pair.second;
   21694                 :            : 
   21695         [ #  # ]:          0 :     TopologyEntity *te_old = old_tb->topology_entity();
   21696         [ #  # ]:          0 :     TopologyEntity *te_new = new_tb->topology_entity();
   21697                 :            : 
   21698 [ #  # ][ #  # ]:          0 :     if( te_old && te_new )
   21699                 :            :     {
   21700         [ #  # ]:          0 :       RefEntity *old_ref_ent = dynamic_cast<RefEntity*>(te_old);
   21701         [ #  # ]:          0 :       RefEntity *new_ref_ent = dynamic_cast<RefEntity*>(te_new);
   21702                 :            : 
   21703 [ #  # ][ #  # ]:          0 :       if( old_ref_ent && new_ref_ent )
   21704                 :            :       {
   21705         [ #  # ]:          0 :         if( debug )
   21706 [ #  # ][ #  # ]:          0 :           PRINT_INFO("%s %d ---> %s %d\n", 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   21707                 :            :           old_ref_ent->class_name(), old_ref_ent->id(),
   21708         [ #  # ]:          0 :           new_ref_ent->class_name(), new_ref_ent->id() );
   21709                 :            : 
   21710 [ #  # ][ #  # ]:          0 :         old_to_new_map.insert( std::make_pair( old_ref_ent, new_ref_ent ) );
                 [ #  # ]
   21711                 :            :       }
   21712                 :            :       else
   21713         [ #  # ]:          0 :         unmatched_pairs.push_back( tmp_pair );
   21714                 :            :     }
   21715                 :            :     else
   21716         [ #  # ]:          0 :       unmatched_pairs.push_back( tmp_pair );
   21717                 :            :   }  
   21718                 :            : 
   21719                 :            :   //Virtual geometry will be in unmatched pairs.  Composite will have an n-to-1 
   21720                 :            :   //TB-to-RefEntity mapping.  So it might try to stuff duplicate pairs into the 
   21721                 :            :   //map, but that's alright.
   21722 [ #  # ][ #  # ]:          0 :   for( size_t k=0; k<unmatched_pairs.size(); k++ )
   21723                 :            :   {
   21724         [ #  # ]:          0 :     std::pair<TopologyBridge*, TopologyBridge*> tmp_pair = unmatched_pairs[k];
   21725                 :            : 
   21726                 :          0 :     TopologyBridge *old_tb = tmp_pair.first;
   21727                 :          0 :     TopologyBridge *new_tb = tmp_pair.second;
   21728                 :            : 
   21729                 :            :     //get the owner tbs associate with old_tb
   21730         [ #  # ]:          0 :     DLIList<TopologyBridge*> old_owner_tbs;
   21731 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->get_tbs_with_bridge_manager_as_owner( old_tb, old_owner_tbs );
   21732                 :            : 
   21733 [ #  # ][ #  # ]:          0 :     DLIList<TopologyBridge*> new_owner_tbs;
   21734 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->get_tbs_with_bridge_manager_as_owner( new_tb, new_owner_tbs );
   21735                 :            :     
   21736 [ #  # ][ #  # ]:          0 :     if( old_owner_tbs.size() && old_owner_tbs.size() == new_owner_tbs.size() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
   21737                 :            :     {
   21738 [ #  # ][ #  # ]:          0 :       if( old_owner_tbs.size() == 1 && new_owner_tbs.size() == 1 ) //composite case
         [ #  # ][ #  # ]
                 [ #  # ]
   21739                 :            :       {
   21740 [ #  # ][ #  # ]:          0 :         TopologyEntity *te_old = old_owner_tbs.get()->topology_entity();
   21741 [ #  # ][ #  # ]:          0 :         TopologyEntity *te_new = new_owner_tbs.get()->topology_entity();
   21742                 :            : 
   21743 [ #  # ][ #  # ]:          0 :         if( te_old && te_new )
   21744                 :            :         {
   21745         [ #  # ]:          0 :           RefEntity *old_ref_ent = dynamic_cast<RefEntity*>(te_old);
   21746         [ #  # ]:          0 :           RefEntity *new_ref_ent = dynamic_cast<RefEntity*>(te_new);
   21747                 :            : 
   21748 [ #  # ][ #  # ]:          0 :           if( old_ref_ent && new_ref_ent )
   21749                 :            :           {
   21750         [ #  # ]:          0 :             if( debug )
   21751 [ #  # ][ #  # ]:          0 :               PRINT_INFO("Virtual: %s %d ---> %s %d\n", 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   21752                 :            :               old_ref_ent->class_name(), old_ref_ent->id(),
   21753         [ #  # ]:          0 :               new_ref_ent->class_name(), new_ref_ent->id() );
   21754                 :            : 
   21755 [ #  # ][ #  # ]:          0 :             old_to_new_map.insert( std::make_pair( old_ref_ent, new_ref_ent ) );
                 [ #  # ]
   21756                 :            : 
   21757 [ #  # ][ #  # ]:          0 :             old_tb_to_new_tb.insert( std::make_pair( old_owner_tbs.get(), new_owner_tbs.get() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
   21758                 :            :           }
   21759                 :            :         }        
   21760                 :            :       }      
   21761                 :            :     }
   21762         [ #  # ]:          0 :   }
   21763                 :            : 
   21764                 :            :   //Partitions can hide entities because of the the n-to-m mapping.
   21765                 :            :   //The solution is to get all the child TB lumps, surface, curves, and
   21766                 :            :   //points.  
   21767 [ #  # ][ #  # ]:          0 :   double tol_sq = old_top_level_bridge->get_geometry_query_engine()->get_sme_resabs_tolerance();
   21768                 :          0 :   tol_sq *= tol_sq;
   21769                 :            : 
   21770 [ #  # ][ #  # ]:          0 :   DLIList<Lump*> old_lumps, new_lumps;
         [ #  # ][ #  # ]
   21771 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> old_surfaces, new_surfaces;
         [ #  # ][ #  # ]
   21772 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> old_curves, new_curves;
         [ #  # ][ #  # ]
   21773 [ #  # ][ #  # ]:          0 :   DLIList<TBPoint*> old_points, new_points;
         [ #  # ][ #  # ]
   21774                 :            :   
   21775 [ #  # ][ #  # ]:          0 :   if( dynamic_cast<BodySM*>(old_top_level_bridge) )
                 [ #  # ]
   21776                 :            :   {
   21777         [ #  # ]:          0 :     old_top_level_bridge->lumps( old_lumps );
   21778         [ #  # ]:          0 :     old_top_level_bridge->surfaces( old_surfaces );
   21779         [ #  # ]:          0 :     new_top_level_bridge->lumps( new_lumps );
   21780         [ #  # ]:          0 :     new_top_level_bridge->surfaces( new_surfaces );
   21781                 :            :   }
   21782                 :            : 
   21783         [ #  # ]:          0 :   old_top_level_bridge->curves( old_curves );
   21784         [ #  # ]:          0 :   old_top_level_bridge->points( old_points ); 
   21785         [ #  # ]:          0 :   new_top_level_bridge->curves( new_curves );
   21786         [ #  # ]:          0 :   new_top_level_bridge->points( new_points );
   21787                 :            : 
   21788                 :            :   //If it is already in the map, it has been paired to something.
   21789                 :            :   //Remove it from the list and forget about it.
   21790 [ #  # ][ #  # ]:          0 :   for( int k=0; k<old_lumps.size(); k++ )
   21791                 :            :   {
   21792                 :            :     //if it is found, make it NULL in the list
   21793 [ #  # ][ #  # ]:          0 :     iter = old_tb_to_new_tb.find( old_lumps[k] );
   21794 [ #  # ][ #  # ]:          0 :     if( iter != old_tb_to_new_tb.end() )
                 [ #  # ]
   21795                 :            :     {
   21796         [ #  # ]:          0 :       old_lumps[k] = NULL;
   21797 [ #  # ][ #  # ]:          0 :       if( new_lumps.move_to( (Lump*)iter->second ) )
                 [ #  # ]
   21798         [ #  # ]:          0 :         new_lumps.change_to( NULL );
   21799                 :            :     }
   21800                 :            :   }
   21801 [ #  # ][ #  # ]:          0 :   for( int k=0; k<old_surfaces.size(); k++ )
   21802                 :            :   {
   21803                 :            :     //if it is found, make it NULL in the list
   21804 [ #  # ][ #  # ]:          0 :     iter = old_tb_to_new_tb.find( old_surfaces[k] );
   21805 [ #  # ][ #  # ]:          0 :     if( iter != old_tb_to_new_tb.end() )
                 [ #  # ]
   21806                 :            :     {
   21807         [ #  # ]:          0 :       old_surfaces[k] = NULL;
   21808 [ #  # ][ #  # ]:          0 :       if( new_surfaces.move_to( (Surface*)iter->second ) )
                 [ #  # ]
   21809         [ #  # ]:          0 :         new_surfaces.change_to( NULL );
   21810                 :            :     }
   21811                 :            :   }
   21812 [ #  # ][ #  # ]:          0 :   for( int k=0; k<old_curves.size(); k++ )
   21813                 :            :   {
   21814                 :            :     //if it is found, make it NULL in the list
   21815 [ #  # ][ #  # ]:          0 :     iter = old_tb_to_new_tb.find( old_curves[k] );
   21816 [ #  # ][ #  # ]:          0 :     if( iter != old_tb_to_new_tb.end() )
                 [ #  # ]
   21817                 :            :     {
   21818         [ #  # ]:          0 :       old_curves[k] = NULL;
   21819 [ #  # ][ #  # ]:          0 :       if( new_curves.move_to( (Curve*)iter->second ) )
                 [ #  # ]
   21820         [ #  # ]:          0 :         new_curves.change_to( NULL );
   21821                 :            :     }
   21822                 :            :   }
   21823 [ #  # ][ #  # ]:          0 :   for( int k=0; k<old_points.size(); k++ )
   21824                 :            :   {
   21825                 :            :     //if it is found, make it NULL in the list
   21826 [ #  # ][ #  # ]:          0 :     iter = old_tb_to_new_tb.find( old_points[k] );
   21827 [ #  # ][ #  # ]:          0 :     if( iter != old_tb_to_new_tb.end() )
                 [ #  # ]
   21828                 :            :     {
   21829         [ #  # ]:          0 :       old_points[k] = NULL;
   21830 [ #  # ][ #  # ]:          0 :       if( new_points.move_to( (TBPoint*)iter->second ) )
                 [ #  # ]
   21831         [ #  # ]:          0 :         new_points.change_to( NULL );
   21832                 :            :     }
   21833                 :            :   }
   21834                 :            : 
   21835                 :            :   //Remove all the NULL-ed out stuff
   21836         [ #  # ]:          0 :   old_lumps.remove_all_with_value(NULL);
   21837         [ #  # ]:          0 :   old_surfaces.remove_all_with_value(NULL);
   21838         [ #  # ]:          0 :   old_curves.remove_all_with_value(NULL);
   21839         [ #  # ]:          0 :   old_points.remove_all_with_value(NULL);
   21840                 :            : 
   21841         [ #  # ]:          0 :   new_lumps.remove_all_with_value(NULL);
   21842         [ #  # ]:          0 :   new_surfaces.remove_all_with_value(NULL);
   21843         [ #  # ]:          0 :   new_curves.remove_all_with_value(NULL);
   21844         [ #  # ]:          0 :   new_points.remove_all_with_value(NULL);
   21845                 :            : 
   21846                 :            :   //should have exact correspondence
   21847 [ #  # ][ #  # ]:          0 :   if( old_lumps.size() != new_lumps.size() )
                 [ #  # ]
   21848                 :          0 :     return CUBIT_FAILURE;
   21849 [ #  # ][ #  # ]:          0 :   if( old_surfaces.size() != new_surfaces.size() )
                 [ #  # ]
   21850                 :          0 :     return CUBIT_FAILURE;
   21851 [ #  # ][ #  # ]:          0 :   if( old_curves.size() != new_curves.size() )
                 [ #  # ]
   21852                 :          0 :     return CUBIT_FAILURE;
   21853 [ #  # ][ #  # ]:          0 :   if( old_points.size() != new_points.size() )
                 [ #  # ]
   21854                 :          0 :     return CUBIT_FAILURE;
   21855                 :            : 
   21856                 :            :   //If we are here, there are partitions we have to resolve.  The only way to do it 
   21857                 :            :   //is a brute force approach.  It's save to use a tolerance since we know the 
   21858                 :            :   //entities will be exactly on top of each other.  
   21859 [ #  # ][ #  # ]:          0 :   for( int k=0; k<old_surfaces.size(); k++ )
   21860                 :            :   {
   21861         [ #  # ]:          0 :     Surface *old_surf = old_surfaces[k];
   21862         [ #  # ]:          0 :     CubitBox old_bbox = old_surf->bounding_box();
   21863                 :            : 
   21864 [ #  # ][ #  # ]:          0 :     for( int j=0; j<new_surfaces.size(); j++ )
   21865                 :            :     {
   21866         [ #  # ]:          0 :       Surface *new_surf = new_surfaces[j];
   21867         [ #  # ]:          0 :       if( new_surf )
   21868                 :            :       {
   21869         [ #  # ]:          0 :         CubitBox new_bbox = new_surf->bounding_box();          
   21870 [ #  # ][ #  # ]:          0 :         if( old_bbox.center().distance_between_squared( new_bbox.center() ) < tol_sq )
         [ #  # ][ #  # ]
   21871                 :            :         {
   21872 [ #  # ][ #  # ]:          0 :           if( fabs(old_bbox.diagonal().length_squared() - 
                 [ #  # ]
   21873 [ #  # ][ #  # ]:          0 :             new_bbox.diagonal().length_squared() ) < tol_sq )
   21874                 :            :           {
   21875         [ #  # ]:          0 :             TopologyEntity *te_old = old_surf->topology_entity();
   21876         [ #  # ]:          0 :             TopologyEntity *te_new = new_surf->topology_entity();
   21877                 :            : 
   21878 [ #  # ][ #  # ]:          0 :             if( te_old && te_new )
   21879                 :            :             {
   21880         [ #  # ]:          0 :               RefEntity *old_ref_ent = dynamic_cast<RefEntity*>(te_old);
   21881         [ #  # ]:          0 :               RefEntity *new_ref_ent = dynamic_cast<RefEntity*>(te_new);
   21882                 :            : 
   21883 [ #  # ][ #  # ]:          0 :               if( old_ref_ent && new_ref_ent )
   21884                 :            :               {
   21885         [ #  # ]:          0 :                 if( debug )
   21886 [ #  # ][ #  # ]:          0 :                   PRINT_INFO("Partition: %s %d ---> %s %d\n", 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   21887                 :            :                   old_ref_ent->class_name(), old_ref_ent->id(),
   21888         [ #  # ]:          0 :                   new_ref_ent->class_name(), new_ref_ent->id() );
   21889                 :            : 
   21890 [ #  # ][ #  # ]:          0 :                 old_to_new_map.insert( std::make_pair( old_ref_ent, new_ref_ent ) );
                 [ #  # ]
   21891         [ #  # ]:          0 :                 new_surfaces[j] = NULL;
   21892 [ #  # ][ #  # ]:          0 :                 break;
   21893                 :            :               }
   21894                 :            :             }
   21895                 :            :           }
   21896                 :          0 :         }
   21897                 :            :       }
   21898                 :            :     }
   21899         [ #  # ]:          0 :   }
   21900                 :            : 
   21901                 :            :   //Curves
   21902 [ #  # ][ #  # ]:          0 :   for( int k=0; k<old_curves.size(); k++ )
   21903                 :            :   {
   21904         [ #  # ]:          0 :     Curve *old_curve = old_curves[k];
   21905         [ #  # ]:          0 :     CubitBox old_bbox = old_curve->bounding_box();
   21906                 :            : 
   21907 [ #  # ][ #  # ]:          0 :     for( int j=0; j<new_curves.size(); j++ )
   21908                 :            :     {
   21909         [ #  # ]:          0 :       Curve *new_curve = new_curves[j];
   21910         [ #  # ]:          0 :       if( new_curve )
   21911                 :            :       {
   21912         [ #  # ]:          0 :         CubitBox new_bbox = new_curve->bounding_box();          
   21913 [ #  # ][ #  # ]:          0 :         if( old_bbox.center().distance_between_squared( new_bbox.center() ) < tol_sq )
         [ #  # ][ #  # ]
   21914                 :            :         {
   21915 [ #  # ][ #  # ]:          0 :           if( fabs(old_bbox.diagonal().length_squared() - 
                 [ #  # ]
   21916 [ #  # ][ #  # ]:          0 :             new_bbox.diagonal().length_squared() ) < tol_sq )
   21917                 :            :           {
   21918         [ #  # ]:          0 :             TopologyEntity *te_old = old_curve->topology_entity();
   21919         [ #  # ]:          0 :             TopologyEntity *te_new = new_curve->topology_entity();
   21920                 :            : 
   21921 [ #  # ][ #  # ]:          0 :             if( te_old && te_new )
   21922                 :            :             {
   21923         [ #  # ]:          0 :               RefEntity *old_ref_ent = dynamic_cast<RefEntity*>(te_old);
   21924         [ #  # ]:          0 :               RefEntity *new_ref_ent = dynamic_cast<RefEntity*>(te_new);
   21925                 :            : 
   21926 [ #  # ][ #  # ]:          0 :               if( old_ref_ent && new_ref_ent )
   21927                 :            :               {
   21928         [ #  # ]:          0 :                 if( debug )
   21929 [ #  # ][ #  # ]:          0 :                   PRINT_INFO("Partition: %s %d ---> %s %d\n", 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   21930                 :            :                   old_ref_ent->class_name(), old_ref_ent->id(),
   21931         [ #  # ]:          0 :                   new_ref_ent->class_name(), new_ref_ent->id() );
   21932                 :            : 
   21933 [ #  # ][ #  # ]:          0 :                 old_to_new_map.insert( std::make_pair( old_ref_ent, new_ref_ent ) );
                 [ #  # ]
   21934         [ #  # ]:          0 :                 new_curves[j] = NULL;
   21935 [ #  # ][ #  # ]:          0 :                 break;
   21936                 :            :               }
   21937                 :            :             }
   21938                 :            :           }
   21939                 :          0 :         }
   21940                 :            :       }
   21941                 :            :     }
   21942         [ #  # ]:          0 :   }
   21943                 :            : 
   21944                 :            :   //Points
   21945 [ #  # ][ #  # ]:          0 :   for( int k=0; k<old_points.size(); k++ )
   21946                 :            :   {
   21947         [ #  # ]:          0 :     TBPoint *old_point = old_points[k];
   21948         [ #  # ]:          0 :     CubitBox old_bbox = old_point->bounding_box();
   21949                 :            : 
   21950 [ #  # ][ #  # ]:          0 :     for( int j=0; j<new_points.size(); j++ )
   21951                 :            :     {
   21952         [ #  # ]:          0 :       TBPoint *new_point = new_points[j];
   21953         [ #  # ]:          0 :       if( new_point )
   21954                 :            :       {
   21955         [ #  # ]:          0 :         CubitBox new_bbox = new_point->bounding_box();          
   21956 [ #  # ][ #  # ]:          0 :         if( old_bbox.center().distance_between_squared( new_bbox.center() ) < tol_sq )
         [ #  # ][ #  # ]
   21957                 :            :         {
   21958 [ #  # ][ #  # ]:          0 :           if( fabs(old_bbox.diagonal().length_squared() - 
                 [ #  # ]
   21959 [ #  # ][ #  # ]:          0 :             new_bbox.diagonal().length_squared() ) < tol_sq )
   21960                 :            :           {
   21961         [ #  # ]:          0 :             TopologyEntity *te_old = old_point->topology_entity();
   21962         [ #  # ]:          0 :             TopologyEntity *te_new = new_point->topology_entity();
   21963                 :            : 
   21964 [ #  # ][ #  # ]:          0 :             if( te_old && te_new )
   21965                 :            :             {
   21966         [ #  # ]:          0 :               RefEntity *old_ref_ent = dynamic_cast<RefEntity*>(te_old);
   21967         [ #  # ]:          0 :               RefEntity *new_ref_ent = dynamic_cast<RefEntity*>(te_new);
   21968                 :            : 
   21969 [ #  # ][ #  # ]:          0 :               if( old_ref_ent && new_ref_ent )
   21970                 :            :               {
   21971         [ #  # ]:          0 :                 if( debug )
   21972 [ #  # ][ #  # ]:          0 :                   PRINT_INFO("Partition: %s %d ---> %s %d\n", 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
   21973                 :            :                   old_ref_ent->class_name(), old_ref_ent->id(),
   21974         [ #  # ]:          0 :                   new_ref_ent->class_name(), new_ref_ent->id() );
   21975                 :            : 
   21976 [ #  # ][ #  # ]:          0 :                 old_to_new_map.insert( std::make_pair( old_ref_ent, new_ref_ent ) );
                 [ #  # ]
   21977         [ #  # ]:          0 :                 new_points[j] = NULL;
   21978 [ #  # ][ #  # ]:          0 :                 break;
   21979                 :            :               }
   21980                 :            :             }
   21981                 :            :           }
   21982                 :          0 :         }
   21983                 :            :       }
   21984                 :            :     }
   21985         [ #  # ]:          0 :   }
   21986                 :            : 
   21987         [ #  # ]:          0 :   return CUBIT_SUCCESS;
   21988                 :            : 
   21989                 :            : }
   21990                 :            : 
   21991                 :            : //author: Jane Hu
   21992                 :            : //Date Created: Jan. 9, 2013
   21993                 :          0 : CubitStatus webcut_w_cylinder( DLIList<BodySM*> &webcut_body_list,
   21994                 :            :                                double radius,
   21995                 :            :                                const CubitVector &axis,
   21996                 :            :                                const CubitVector &center,
   21997                 :            :                                DLIList<BodySM*>& neighbor_imprint_list,
   21998                 :            :                                DLIList<BodySM*>& results_list,
   21999                 :            :                                ImprintType imprint_type )
   22000                 :            : {
   22001                 :          0 :   GeometryModifyEngine* gme = 0;
   22002                 :            :   gme = GeometryModifyTool::instance()->
   22003 [ #  # ][ #  # ]:          0 :                     get_engine(webcut_body_list.get());
                 [ #  # ]
   22004         [ #  # ]:          0 :   assert(gme);
   22005                 :            : 
   22006                 :          0 :   double max_size =  0.;
   22007                 :            :   //lets find the distance to the center for each body and take
   22008                 :            :   //the max.
   22009                 :            :   double curr;
   22010         [ #  # ]:          0 :   CubitVector cent_bod;
   22011         [ #  # ]:          0 :   CubitBox bounding_box;
   22012                 :            :   BodySM *body_ptr;
   22013 [ #  # ][ #  # ]:          0 :   bounding_box = webcut_body_list[0]->bounding_box();
         [ #  # ][ #  # ]
   22014 [ #  # ][ #  # ]:          0 :   cent_bod =  bounding_box.center();
   22015 [ #  # ][ #  # ]:          0 :   cent_bod = cent_bod - center;
   22016         [ #  # ]:          0 :   curr = cent_bod.length();
   22017         [ #  # ]:          0 :   if ( curr > max_size )
   22018                 :          0 :      max_size = curr;
   22019                 :            : 
   22020                 :            : 
   22021 [ #  # ][ #  # ]:          0 :   for ( int ii = webcut_body_list.size()-1; ii > 0; ii-- )
   22022                 :            :     {
   22023         [ #  # ]:          0 :       body_ptr = webcut_body_list[ii];
   22024 [ #  # ][ #  # ]:          0 :       bounding_box |= body_ptr->bounding_box();
                 [ #  # ]
   22025 [ #  # ][ #  # ]:          0 :       cent_bod = body_ptr->bounding_box().center();
         [ #  # ][ #  # ]
   22026 [ #  # ][ #  # ]:          0 :       cent_bod = cent_bod - center;
   22027         [ #  # ]:          0 :       curr = cent_bod.length();
   22028         [ #  # ]:          0 :       if ( curr > max_size )
   22029                 :          0 :         max_size = curr;
   22030                 :            :     }
   22031                 :            : 
   22032 [ #  # ][ #  # ]:          0 :   curr = bounding_box.diagonal().length();
   22033                 :            : 
   22034         [ #  # ]:          0 :   if ( curr > max_size )
   22035                 :          0 :      max_size = curr;
   22036                 :            : 
   22037                 :          0 :   double height = 0.0;
   22038 [ #  # ][ #  # ]:          0 :   if ( center.x() > max_size )
   22039                 :            :     {
   22040         [ #  # ]:          0 :       height = 500.0 * center.x();
   22041                 :            :     }
   22042 [ #  # ][ #  # ]:          0 :   else if ( center.y() > max_size )
   22043                 :            :     {
   22044         [ #  # ]:          0 :       height = 500.0 * center.y();
   22045                 :            :     }
   22046 [ #  # ][ #  # ]:          0 :   else if ( center.z() > max_size )
   22047                 :            :     {
   22048         [ #  # ]:          0 :       height = 500.0 * center.z();
   22049                 :            :     }
   22050                 :            :   else
   22051                 :            :     {
   22052                 :          0 :       height = 500.0 * max_size;
   22053                 :            :     }
   22054                 :            : 
   22055                 :            :   //lets make certain we have a valid height..
   22056         [ #  # ]:          0 :   if ( height < GEOMETRY_RESABS )
   22057                 :            :     {
   22058                 :          0 :       height = 500.0;
   22059                 :            :     }
   22060                 :            : 
   22061         [ #  # ]:          0 :   BodySM *cutting_tool_ptr = gme->cylinder( height, radius, radius, radius );
   22062                 :            : 
   22063         [ #  # ]:          0 :   if( cutting_tool_ptr == NULL )
   22064                 :          0 :     return CUBIT_FAILURE;
   22065                 :            : 
   22066                 :            :   //transform the cyclinder to cernter and axis
   22067                 :            :   // The current frustum is centered on the z axis.
   22068         [ #  # ]:          0 :   CubitVector axis2(0., 0., 1.0 );
   22069                 :            :   //now find the normal to the current axis and axis we want to be
   22070                 :            :   //at. This normal is where we will rotate about.
   22071         [ #  # ]:          0 :   CubitVector normal_axis = axis2 * axis;
   22072 [ #  # ][ #  # ]:          0 :   if ( normal_axis.length() > CUBIT_RESABS )
   22073                 :            :     {
   22074                 :            :        //angle in degrees.
   22075         [ #  # ]:          0 :        double angle = normal_axis.vector_angle( axis2, axis );
   22076 [ #  # ][ #  # ]:          0 :        gme->get_gqe()->rotate(cutting_tool_ptr, normal_axis, angle);
   22077                 :            :     }
   22078 [ #  # ][ #  # ]:          0 :   gme->get_gqe()->translate(cutting_tool_ptr, center);
   22079                 :            : 
   22080                 :            :   CubitStatus stat = gme->webcut( webcut_body_list, cutting_tool_ptr,
   22081         [ #  # ]:          0 :               neighbor_imprint_list, results_list, imprint_type) ;
   22082                 :            : 
   22083                 :            :   // Delete the BodySM that was created to be used as a tool
   22084 [ #  # ][ #  # ]:          0 :   gme->get_gqe()->delete_solid_model_entities(cutting_tool_ptr) ;
   22085                 :            : 
   22086         [ #  # ]:          0 :   return stat;
   22087 [ +  - ][ +  - ]:       6540 : }
   22088                 :            : 
   22089                 :            : //*********************************************************************************************************************************************************************
   22090                 :            : 

Generated by: LCOV version 1.11