LCOV - code coverage report
Current view: top level - geom/virtual - CompositeTool.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 1 1236 0.1 %
Date: 2020-06-30 00:58:45 Functions: 2 30 6.7 %
Branches: 2 4106 0.1 %

           Branch data     Line data    Source code
       1                 :            : #include <assert.h>
       2                 :            : #include <vector>
       3                 :            : 
       4                 :            : #include "CompositeTool.hpp"
       5                 :            : 
       6                 :            : #include "DLIList.hpp"
       7                 :            : #include "CastTo.hpp"
       8                 :            : #include "CubitUtil.hpp"
       9                 :            : 
      10                 :            : #include "RefEntityFactory.hpp"
      11                 :            : #include "RefEdge.hpp"
      12                 :            : #include "RefFace.hpp"
      13                 :            : #include "RefVertex.hpp"
      14                 :            : #include "RefVolume.hpp"
      15                 :            : #include "Loop.hpp"
      16                 :            : #include "Shell.hpp"
      17                 :            : #include "Chain.hpp"
      18                 :            : #include "CoEdge.hpp"
      19                 :            : #include "CoFace.hpp"
      20                 :            : #include "CoVertex.hpp"
      21                 :            : #include "Body.hpp"
      22                 :            : 
      23                 :            : #include "CompositeCurve.hpp"
      24                 :            : #include "CompositeSurface.hpp"
      25                 :            : #include "CompositeLump.hpp"
      26                 :            : #include "CompositeBody.hpp"
      27                 :            : 
      28                 :            : //#include "VirtualQueryEngine.hpp"
      29                 :            : #include "PartitionTool.hpp"
      30                 :            : #include "BasicTopologyEntity.hpp"
      31                 :            : #include "ModelQueryEngine.hpp"
      32                 :            : #include "RefEntityName.hpp"
      33                 :            : 
      34                 :            : #include "CompositeEngine.hpp"
      35                 :            : #include "Point.hpp"
      36                 :            : #include "GeometryQueryTool.hpp"
      37                 :            : #include "DAG.hpp"
      38                 :            : //#include "CAMergePartner.hpp"
      39                 :            : //#include "TDUniqueId.hpp"
      40                 :            : #include "CubitAttrib.hpp"
      41                 :            : #include "CADefines.hpp"
      42                 :            : 
      43                 :            : #include "PartitionEngine.hpp"
      44                 :            : #include "PartitionSurface.hpp"
      45                 :            : #include "SegmentedCurve.hpp"
      46                 :            : #include "PartPTCurve.hpp"
      47                 :            : #include "PartitionPoint.hpp"
      48                 :            : #include "GMem.hpp"
      49                 :            : #include "GfxDebug.hpp"
      50                 :            : 
      51                 :            : CompositeTool* CompositeTool::instance_ = NULL;
      52                 :            : 
      53                 :            : 
      54                 :            : //-------------------------------------------------------------------------
      55                 :            : // Purpose       : Constructor 
      56                 :            : //
      57                 :            : // Special Notes : 
      58                 :            : //
      59                 :            : // Creator       : Jason Kraftcheck
      60                 :            : //
      61                 :            : // Creation Date : 10/17/03
      62                 :            : //-------------------------------------------------------------------------
      63                 :          0 : CompositeTool::CompositeTool()
      64                 :            : {
      65                 :          0 : }
      66                 :            : 
      67                 :            : 
      68                 :            : //-------------------------------------------------------------------------
      69                 :            : // Purpose       : Destructor
      70                 :            : //
      71                 :            : // Special Notes : 
      72                 :            : //
      73                 :            : // Creator       : Jason Kraftcheck
      74                 :            : //
      75                 :            : // Creation Date : 
      76                 :            : //-------------------------------------------------------------------------
      77                 :          0 : CompositeTool::~CompositeTool()
      78                 :            : {
      79         [ #  # ]:          0 :   assert( instance_ == this );
      80                 :          0 :   instance_ = NULL;
      81         [ #  # ]:          0 : }
      82                 :            : 
      83                 :            : //-------------------------------------------------------------------------
      84                 :            : // Purpose       : Create a composite curve
      85                 :            : //
      86                 :            : // Special Notes : 
      87                 :            : //
      88                 :            : // Creator       : Jason Kraftcheck
      89                 :            : //
      90                 :            : // Creation Date : 
      91                 :            : //-------------------------------------------------------------------------
      92                 :          0 : RefEdge* CompositeTool::composite( DLIList<RefEdge*>& edge_list,
      93                 :            :                                    RefVertex* keep,
      94                 :            :                                    RefEdge* survivor  )
      95                 :            : {
      96                 :            :   int i;
      97         [ #  # ]:          0 :   DLIList<RefVertex*> vertex_list;
      98 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> modified_edges;
      99                 :            :   
     100 [ #  # ][ #  # ]:          0 :   for( i = edge_list.size(); i--; )
     101                 :            :   {
     102         [ #  # ]:          0 :     RefEdge* edge = edge_list.get_and_step();
     103         [ #  # ]:          0 :     RefVertex* start_vtx = edge->start_vertex();
     104         [ #  # ]:          0 :     RefVertex* end_vtx = edge->end_vertex();
     105         [ #  # ]:          0 :     start_vtx->marked(0);
     106         [ #  # ]:          0 :     end_vtx->marked(0);
     107         [ #  # ]:          0 :     vertex_list.append( start_vtx );
     108         [ #  # ]:          0 :     vertex_list.append( end_vtx );
     109                 :            :   }
     110 [ #  # ][ #  # ]:          0 :   for( i = vertex_list.size(); i--; )
     111                 :            :   {
     112         [ #  # ]:          0 :     RefVertex* vtx = vertex_list.get_and_step();
     113 [ #  # ][ #  # ]:          0 :     vtx->marked( vtx->marked() + 1 );
     114                 :            :   }
     115                 :            :   // Check for edges that will have both vertices removed.
     116                 :            :   // If any exist then we want to set the flag to have the
     117                 :            :   // DAG updated after each vertex is removed.  Otherwise
     118                 :            :   // things get left in a bad state.
     119                 :          0 :   bool update_dag = false;
     120 [ #  # ][ #  # ]:          0 :   for(i=edge_list.size(); i>0; i--)
     121                 :            :   {
     122         [ #  # ]:          0 :     RefEdge* edge = edge_list.get_and_step();
     123 [ #  # ][ #  # ]:          0 :     if(edge->start_vertex()->marked() == 2 &&
         [ #  # ][ #  # ]
                 [ #  # ]
     124 [ #  # ][ #  # ]:          0 :        edge->end_vertex()->marked() == 2)
     125                 :            :     {
     126                 :          0 :       update_dag = true;
     127                 :          0 :       i=0;
     128                 :            :     }
     129                 :            :   }
     130 [ #  # ][ #  # ]:          0 :   for( i = vertex_list.size(); i--; )
     131 [ #  # ][ #  # ]:          0 :     if( vertex_list.step_and_get()->marked() == 2 )
                 [ #  # ]
     132 [ #  # ][ #  # ]:          0 :       vertex_list.get()->marked(0);
     133                 :            :     else
     134         [ #  # ]:          0 :       vertex_list.change_to( 0 );
     135         [ #  # ]:          0 :   vertex_list.remove_all_with_value(0);
     136                 :            :   
     137 [ #  # ][ #  # ]:          0 :   if ( keep && vertex_list.move_to(keep) )
         [ #  # ][ #  # ]
     138         [ #  # ]:          0 :     vertex_list.remove();
     139                 :            :   
     140 [ #  # ][ #  # ]:          0 :   if( vertex_list.size() == 0 )
     141                 :            :   {
     142 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot create any composites from passed curves.\n");
         [ #  # ][ #  # ]
     143                 :          0 :     return 0;
     144                 :            :   }
     145         [ #  # ]:          0 :   vertex_list.reset();
     146                 :          0 :   RefEdge* result = 0;
     147 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> vtx_edges;
     148 [ #  # ][ #  # ]:          0 :   for( i = vertex_list.size(); i--; )
     149                 :            :   {
     150         [ #  # ]:          0 :     RefVertex* vtx = vertex_list.get_and_step();
     151         [ #  # ]:          0 :     vtx_edges.clean_out();
     152         [ #  # ]:          0 :     vtx->ref_edges(vtx_edges);
     153                 :            :     //check to make sure that the two edges resides on the same surface(s)
     154 [ #  # ][ #  # ]:          0 :     if ( vtx_edges.size() == 2 )
     155                 :            :     {
     156         [ #  # ]:          0 :       RefEdge* first_edge = vtx_edges.get();
     157         [ #  # ]:          0 :       RefEdge* second_edge = vtx_edges.step_and_get();
     158         [ #  # ]:          0 :       DLIList <RefFace*> common_faces;
     159         [ #  # ]:          0 :       int size = first_edge->common_ref_faces(second_edge, common_faces);
     160 [ #  # ][ #  # ]:          0 :       if (first_edge->num_ref_faces() != second_edge->num_ref_faces() ||
         [ #  # ][ #  # ]
                 [ #  # ]
     161         [ #  # ]:          0 :           size != first_edge->num_ref_faces())
     162                 :            :       {
     163 [ #  # ][ #  # ]:          0 :          PRINT_INFO("Curve %d and curve %d don't reside on the same surfaces.\n", first_edge->id(), second_edge->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     164                 :          0 :          continue;
     165                 :            :       }
     166                 :            :     
     167         [ #  # ]:          0 :       result = remove_vertex( vtx, false, update_dag, survivor );
     168         [ #  # ]:          0 :       if (result)
     169                 :            :       {
     170                 :            :         // First remove any edges from the list that got destroyed in the
     171                 :            :         // last remove_vertex operation.
     172 [ #  # ][ #  # ]:          0 :         if(result == first_edge && modified_edges.move_to(second_edge))
         [ #  # ][ #  # ]
     173                 :            :         {
     174         [ #  # ]:          0 :           modified_edges.remove();
     175                 :            :         }
     176 [ #  # ][ #  # ]:          0 :         else if(result == second_edge && modified_edges.move_to(first_edge))
         [ #  # ][ #  # ]
     177                 :            :         {
     178         [ #  # ]:          0 :           modified_edges.remove();
     179                 :            :         }
     180 [ #  # ][ #  # ]:          0 :         modified_edges.append_unique(result);
                 [ #  # ]
     181                 :          0 :       }
     182                 :            :     }  
     183                 :            :   }
     184                 :            :   
     185 [ #  # ][ #  # ]:          0 :   for ( i = modified_edges.size(); i--; )
     186 [ #  # ][ #  # ]:          0 :     if ( ! modified_edges.step_and_get()->get_curve_ptr() )
                 [ #  # ]
     187         [ #  # ]:          0 :       modified_edges.change_to(0);
     188         [ #  # ]:          0 :   modified_edges.remove_all_with_value(0);
     189                 :            :   
     190 [ #  # ][ #  # ]:          0 :   result = modified_edges.size() ? modified_edges.get() : 0;
                 [ #  # ]
     191                 :            : 
     192 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> update_surfaces, curve_surfaces;
         [ #  # ][ #  # ]
     193 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> curve_bridges;
     194 [ #  # ][ #  # ]:          0 :   for ( i = modified_edges.size(); i--; )
     195                 :            :   {
     196         [ #  # ]:          0 :     RefEdge* edge = modified_edges.get_and_step();
     197 [ #  # ][ #  # ]:          0 :     edge->set_id( RefEntityFactory::instance()->next_ref_edge_id() );
                 [ #  # ]
     198 [ #  # ][ #  # ]:          0 :     edge->bridge_manager()->get_bridge_list(curve_bridges);
     199         [ #  # ]:          0 :     curve_bridges.reset();
     200 [ #  # ][ #  # ]:          0 :     for (int j = curve_bridges.size(); j--; )
     201                 :            :     {
     202         [ #  # ]:          0 :       curve_surfaces.clean_out();
     203 [ #  # ][ #  # ]:          0 :       curve_bridges.get_and_step()->surfaces(curve_surfaces);
     204         [ #  # ]:          0 :       update_surfaces.merge_unique(curve_surfaces);
     205                 :            :     }
     206                 :            :   }
     207                 :            : 
     208         [ #  # ]:          0 :   update_surfaces.reset();
     209 [ #  # ][ #  # ]:          0 :   for ( i = update_surfaces.size(); i--; )
     210                 :            :   {
     211 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->make_RefFace(update_surfaces.get_and_step());
                 [ #  # ]
     212                 :            :   }
     213 [ #  # ][ #  # ]:          0 :   assert( !(survivor && survivor->deactivated()) );
                 [ #  # ]
     214 [ #  # ][ #  # ]:          0 :   DAG::instance()->cleanout_deactivated_DAG_nodes();
     215                 :            : 
     216         [ #  # ]:          0 :   return result;
     217                 :            : }
     218                 :            : 
     219                 :            : 
     220                 :            : //-------------------------------------------------------------------------
     221                 :            : // Purpose       : Composite over a vertex
     222                 :            : //
     223                 :            : // Special Notes : 
     224                 :            : //
     225                 :            : // Creator       : Jason Kraftcheck
     226                 :            : //
     227                 :            : // Creation Date : 03/12/03
     228                 :            : //-------------------------------------------------------------------------
     229                 :          0 : RefEdge* CompositeTool::remove_vertex( RefVertex* vertex,
     230                 :            :                                        bool remove_partitions, /* = false */
     231                 :            :                                        bool update_dag ,       /* = true  */
     232                 :            :                                        RefEdge* keep_edge      /* = NULL */ )
     233                 :            : {
     234         [ #  # ]:          0 :   DLIList<RefEdge*> vertex_edges;
     235                 :            :   int i;
     236                 :            :   
     237                 :            :     // Get two ref-edges
     238         [ #  # ]:          0 :   vertex->ref_edges( vertex_edges );
     239 [ #  # ][ #  # ]:          0 :   if ( vertex_edges.size() != 2 )
     240                 :            :   {
     241 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot composite over valence-%d vertex.\n", vertex_edges.size());
         [ #  # ][ #  # ]
                 [ #  # ]
     242                 :          0 :     return 0;
     243                 :            :   }
     244                 :            :   
     245 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> point_bridges;
     246 [ #  # ][ #  # ]:          0 :   DLIList<CoEdgeSM*> coedgesms;
     247                 :            :     
     248                 :          0 :   RefEdge *edge = 0, *refedge1 = 0, *refedge2 = 0;
     249         [ #  # ]:          0 :   point_bridges.clean_out();
     250 [ #  # ][ #  # ]:          0 :   vertex->bridge_manager()->get_bridge_list( point_bridges );
     251                 :            :     
     252                 :            : 
     253                 :          0 :   int result_interval=-1;
     254                 :          0 :   double result_size=-1;
     255                 :          0 :   SizeIntervalType  result_size_type=NOT_SET; 
     256                 :          0 :   FirmnessType  result_count_type=LIMP; 
     257                 :            : 
     258 [ #  # ][ #  # ]:          0 :   std::vector<CubitString> names_to_add;
     259                 :          0 :   Curve* end_result = 0;
     260         [ #  # ]:          0 :   point_bridges.reset();
     261 [ #  # ][ #  # ]:          0 :   while( point_bridges.size() )
     262                 :            :   {
     263                 :          0 :     Curve* result_curve = 0;
     264 [ #  # ][ #  # ]:          0 :     TBPoint* point = dynamic_cast<TBPoint*>(point_bridges.pop());
     265                 :            : 
     266                 :            :       // get the RefEdges that will be joined when the vertex is removed
     267         [ #  # ]:          0 :     DLIList<Curve*> curves;
     268         [ #  # ]:          0 :     point->curves(curves);
     269         [ #  # ]:          0 :     curves.reset();
     270                 :            :     
     271 [ #  # ][ #  # ]:          0 :     if (curves.size() == 0)  // merged free vertex -- ignore it
     272                 :          0 :       continue;
     273                 :            : 
     274                 :            :       // If only one curve, need to stitch point with some other
     275                 :            :       // point in same vertex.
     276 [ #  # ][ #  # ]:          0 :     if (curves.size() == 1) {
     277                 :            :     
     278                 :            :       /* Stitching code not complete.  Fail for now. */
     279                 :          0 :       return 0;
     280                 :            :       
     281                 :            :       /*
     282                 :            :       Curve* first_curve = curves.pop();
     283                 :            :     
     284                 :            :       TBPoint* other = 0;
     285                 :            :       for ( i = point_bridges.size(); i--; ) {
     286                 :            :         TBPoint* temp = dynamic_cast<TBPoint*>(point_bridges.step_and_get());
     287                 :            :         curves.clean_out();
     288                 :            :         temp->curves(curves);
     289                 :            :         if ( curves.size() == 1 && curves.get()->owner() != first_curve->owner() ) 
     290                 :            :         {
     291                 :            :           point_bridges.extract();
     292                 :            :           other = temp;
     293                 :            :           break;
     294                 :            :         }
     295                 :            :       }
     296                 :            :     
     297                 :            :       if (!other)
     298                 :            :         return 0;
     299                 :            :       
     300                 :            :       point = CompositeEngine::instance().stitch_points(point, other);
     301                 :            :       if (!point)
     302                 :            :         return 0;
     303                 :            :         
     304                 :            :       curves.append(first_curve);
     305                 :            :       
     306                 :            :       */
     307                 :            :     } // end if (curves.size() == 1)
     308                 :            :     
     309                 :            : 
     310                 :            :    // assert(curves.size() == 2);
     311 [ #  # ][ #  # ]:          0 :     if(curves.size() != 2)
     312                 :            :     {
     313                 :          0 :       break;
     314                 :            :     }
     315                 :            : 
     316                 :            : 
     317 [ #  # ][ #  # ]:          0 :     TopologyEntity* topo = curves.get()->topology_entity();
     318         [ #  # ]:          0 :     refedge1 = CAST_TO(topo, RefEdge);
     319         [ #  # ]:          0 :     assert(refedge1 != NULL);
     320 [ #  # ][ #  # ]:          0 :     curves.get()->set_saved_id(refedge1->id());
                 [ #  # ]
     321 [ #  # ][ #  # ]:          0 :     DLIList<CubitString> tmp_names;
           [ #  #  #  # ]
     322 [ #  # ][ #  # ]:          0 :     std::vector<CubitString> edge1_names;
                 [ #  # ]
     323         [ #  # ]:          0 :     refedge1->entity_names( tmp_names );
     324 [ #  # ][ #  # ]:          0 :     curves.get()->set_saved_names( tmp_names.as_vector() );
                 [ #  # ]
     325 [ #  # ][ #  # ]:          0 :     for( int i=tmp_names.size(); i--; )
     326 [ #  # ][ #  # ]:          0 :       edge1_names.push_back( tmp_names.get_and_step() );
     327         [ #  # ]:          0 :     tmp_names.clean_out();
     328         [ #  # ]:          0 :     refedge1->remove_entity_names();
     329                 :            : 
     330 [ #  # ][ #  # ]:          0 :     topo = curves.next()->topology_entity();
     331         [ #  # ]:          0 :     refedge2 = CAST_TO(topo, RefEdge);
     332         [ #  # ]:          0 :     assert(refedge2 != NULL);   
     333 [ #  # ][ #  # ]:          0 :     curves.next()->set_saved_id(refedge2->id());
                 [ #  # ]
     334 [ #  # ][ #  # ]:          0 :     std::vector<CubitString> edge2_names;
                 [ #  # ]
     335         [ #  # ]:          0 :     refedge2->entity_names( tmp_names );
     336 [ #  # ][ #  # ]:          0 :     curves.next()->set_saved_names( tmp_names.as_vector() );
                 [ #  # ]
     337 [ #  # ][ #  # ]:          0 :     for( int i=tmp_names.size(); i--; )
     338 [ #  # ][ #  # ]:          0 :       edge2_names.push_back( tmp_names.get_and_step() );
     339         [ #  # ]:          0 :     refedge2->remove_entity_names();
     340                 :            : 
     341                 :            : 
     342                 :            : 
     343         [ #  # ]:          0 :     determine_combined_edges_interval_or_size( refedge1,refedge2,result_interval,result_size,result_count_type,result_size_type); 
     344                 :            : 
     345                 :            : 
     346                 :          0 :     Curve* keep = 0;
     347         [ #  # ]:          0 :     if (keep_edge) 
     348                 :            :     {
     349 [ #  # ][ #  # ]:          0 :       if (keep_edge->bridge_manager() == curves.get()->owner())
         [ #  # ][ #  # ]
     350         [ #  # ]:          0 :         keep = curves.get();
     351 [ #  # ][ #  # ]:          0 :       else if (keep_edge->bridge_manager() == curves.next()->owner())
         [ #  # ][ #  # ]
     352         [ #  # ]:          0 :         keep = curves.next();
     353                 :            :     }
     354                 :            : 
     355                 :            :       // remove the point to make the composite curve
     356         [ #  # ]:          0 :     PartitionPoint* part = dynamic_cast<PartitionPoint*>(point);
     357 [ #  # ][ #  # ]:          0 :     if( remove_partitions && part )
     358 [ #  # ][ #  # ]:          0 :       result_curve = PartitionEngine::instance().remove_point( part );
     359         [ #  # ]:          0 :     if ( !result_curve )
     360 [ #  # ][ #  # ]:          0 :       result_curve = CompositeEngine::instance().remove_point( point, remove_partitions, keep );
     361                 :            : 
     362         [ #  # ]:          0 :     if( !result_curve )
     363                 :            :     {
     364                 :            :       //reapply names
     365 [ #  # ][ #  # ]:          0 :       for( int i=edge1_names.size(); i--; )
     366 [ #  # ][ #  # ]:          0 :         refedge1->entity_name( edge1_names[i] );
         [ #  # ][ #  # ]
     367 [ #  # ][ #  # ]:          0 :       for( int i=edge2_names.size(); i--; )
     368 [ #  # ][ #  # ]:          0 :         refedge2->entity_name( edge2_names[i] );
         [ #  # ][ #  # ]
     369                 :            : 
     370 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Failed to remove vertex %d\n", vertex->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
     371                 :          0 :       break;
     372                 :            :     }
     373         [ #  # ]:          0 :     else if( !edge )
     374                 :            :     {
     375 [ #  # ][ #  # ]:          0 :       edge = dynamic_cast<RefEdge*>(result_curve->topology_entity());     
     376                 :            :     }
     377                 :            :     else
     378                 :            :     {
     379 [ #  # ][ #  # ]:          0 :       if( result_curve->owner() )
     380 [ #  # ][ #  # ]:          0 :         result_curve->owner()->remove_bridge( result_curve );
     381 [ #  # ][ #  # ]:          0 :       edge->bridge_manager()->add_bridge( result_curve );
     382                 :            :         
     383         [ #  # ]:          0 :       Curve* curve = edge->get_curve_ptr();
     384         [ #  # ]:          0 :       bool geom_sense = curve->relative_sense( result_curve ) == CUBIT_FORWARD;
     385 [ #  # ][ #  # ]:          0 :       bool bridge_sense = curve->bridge_sense() == result_curve->bridge_sense();
     386         [ #  # ]:          0 :       if( geom_sense != bridge_sense )
     387         [ #  # ]:          0 :         result_curve->reverse_bridge_sense();
     388                 :            : 
     389         [ #  # ]:          0 :       coedgesms.clean_out();
     390         [ #  # ]:          0 :       result_curve->coedgesms( coedgesms );
     391 [ #  # ][ #  # ]:          0 :       while( coedgesms.size() )
     392                 :            :       { 
     393         [ #  # ]:          0 :         CoEdgeSM* coe = coedgesms.pop();
     394 [ #  # ][ #  # ]:          0 :         if( coe->owner() )
     395 [ #  # ][ #  # ]:          0 :           coe->owner()->remove_bridge( coe );
     396                 :            :       }
     397                 :            :     }
     398                 :            : 
     399 [ #  # ][ #  # ]:          0 :     names_to_add.insert(names_to_add.end(), edge1_names.begin(), edge1_names.end() );
         [ #  # ][ #  # ]
     400 [ #  # ][ #  # ]:          0 :     names_to_add.insert(names_to_add.end(), edge2_names.begin(), edge2_names.end() );
         [ #  # ][ #  # ]
     401                 :            :     
     402         [ #  # ]:          0 :     if ( result_curve )
     403 [ #  # ][ #  # ]:          0 :       end_result = result_curve;
     404                 :          0 :   }
     405                 :            :   
     406                 :          0 :   RefEdge* result = NULL;
     407         [ #  # ]:          0 :   if(end_result)
     408 [ #  # ][ #  # ]:          0 :     result = dynamic_cast<RefEdge*>(end_result->topology_entity());
     409                 :            :     
     410                 :          0 :   RefEdge* dead = NULL;
     411         [ #  # ]:          0 :   if(result)
     412                 :            :   {
     413                 :            :     // notify observers that one edge is being composited into another
     414                 :            :     // TODO - make a simple function for this notification since it is  times????
     415 [ #  # ][ #  # ]:          0 :     dead = result != refedge1 ? refedge1 : result != refedge2 ? refedge2 : 0;
     416         [ #  # ]:          0 :     update_combined_edges( result, dead ,result_interval,result_size,result_count_type,result_size_type);
     417                 :            : 
     418                 :            :     //append all names to this ref entity
     419 [ #  # ][ #  # ]:          0 :     for (size_t k = 0; k < names_to_add.size(); k++)
     420 [ #  # ][ #  # ]:          0 :       result->entity_name( names_to_add[k] );
         [ #  # ][ #  # ]
     421                 :            :     
     422                 :            :   }
     423                 :            : 
     424 [ #  # ][ #  # ]:          0 :   if ( result && update_dag )
     425                 :            :   {
     426 [ #  # ][ #  # ]:          0 :     CubitBoolean flag = CGMApp::instance()->attrib_manager()->auto_actuate_flag(CA_MERGE_PARTNER);
                 [ #  # ]
     427 [ #  # ][ #  # ]:          0 :     CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_MERGE_PARTNER, CUBIT_TRUE);
                 [ #  # ]
     428                 :            :     
     429         [ #  # ]:          0 :     DLIList<RefFace*> parent_faces;
     430         [ #  # ]:          0 :     result->ref_faces( parent_faces );
     431                 :            :     
     432 [ #  # ][ #  # ]:          0 :     for( i = parent_faces.size(); i--; )
     433                 :            :     {
     434 [ #  # ][ #  # ]:          0 :       Surface* surf = parent_faces.get_and_step()->get_surface_ptr();
     435 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->make_RefFace( surf );
     436                 :            :     }
     437 [ #  # ][ #  # ]:          0 :     if ( !parent_faces.size() && end_result) // free curves
         [ #  # ][ #  # ]
     438                 :            :     {
     439 [ #  # ][ #  # ]:          0 :       RefEdge* edge = GeometryQueryTool::instance()->make_RefEdge(end_result);
     440 [ #  # ][ #  # ]:          0 :       RefEdge* dead = edge == refedge1 ? refedge2 : edge == refedge2 ? refedge1 : 0;
     441 [ #  # ][ #  # ]:          0 :       assert( dead && !dead->get_curve_ptr() );
                 [ #  # ]
     442         [ #  # ]:          0 :       dead->remove_from_DAG();
     443                 :            :     }
     444 [ #  # ][ #  # ]:          0 :     assert( !(keep_edge && keep_edge->deactivated()) );
                 [ #  # ]
     445 [ #  # ][ #  # ]:          0 :     DAG::instance()->cleanout_deactivated_DAG_nodes();
     446 [ #  # ][ #  # ]:          0 :     CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(CA_MERGE_PARTNER, flag);
         [ #  # ][ #  # ]
     447                 :            :   }
     448                 :            : 
     449                 :            :   
     450         [ #  # ]:          0 :   return result;
     451                 :            : }
     452                 :            : 
     453                 :            : 
     454                 :            : /*
     455                 :            : CubitStatus CompositeTool::make_mergeable( GeometryEntity* bridge1,
     456                 :            :                                            GeometryEntity* bridge2 )
     457                 :            : {
     458                 :            :   BasicTopologyEntity *bte1, *bte2;
     459                 :            :   bte1 = dynamic_cast<BasicTopologyEntity*>(bridge1->topology_entity());
     460                 :            :   bte2 = dynamic_cast<BasicTopologyEntity*>(bridge2->topology_entity());
     461                 :            :   if( (!bte1) == (!bte2) ) // 1 must be null and one non-null
     462                 :            :     return CUBIT_FAILURE;
     463                 :            :   
     464                 :            :   if( bte2 )
     465                 :            :   {
     466                 :            :     bte1 = bte2;
     467                 :            :     GeometryEntity* tmp = bridge1;
     468                 :            :     bridge1 = bridge2;
     469                 :            :     bridge2 = tmp;
     470                 :            :   }
     471                 :            :   
     472                 :            :   DLIList<CubitSimpleAttrib> csa_list;
     473                 :            :   bridge1->get_simple_attribute( csa_list );
     474                 :            :   CubitSimpleAttrib* csa = 0;
     475                 :            :   for( int i = csa_list.size(); !csa && i--; )
     476                 :            :     if( CubitAttrib::attrib_type(csa_list.step_and_get()) == CA_MERGE_PARTNER )
     477                 :            :       csa = csa_list.get();
     478                 :            :   
     479                 :            :   if( !csa )
     480                 :            :   {
     481                 :            :     int merge_id = TDUniqueId::get_unique_id(bte1);
     482                 :            :     csa = CAMergePartner::cubit_simple_attrib(merge_id);
     483                 :            :     bridge1->append_simple_attribute( csa );
     484                 :            :   }
     485                 :            :  
     486                 :            :   assert(csa);
     487                 :            :   bridge2->append_simple_attribute( csa );
     488                 :            :   delete csa;
     489                 :            :   return CUBIT_SUCCESS;
     490                 :            : }
     491                 :            : */
     492                 :            :   
     493                 :            : 
     494                 :            : //-------------------------------------------------------------------------
     495                 :            : // Purpose       : Create a composite surface
     496                 :            : //
     497                 :            : // Special Notes : 
     498                 :            : //
     499                 :            : // Creator       : Jason Kraftcheck
     500                 :            : //
     501                 :            : // Creation Date : 
     502                 :            : //-------------------------------------------------------------------------
     503                 :          0 : RefFace* CompositeTool::composite( DLIList<RefFace*>& face_list,
     504                 :            :                                    RefFace* keep_face /* = 0 */ )
     505                 :            : {
     506                 :            :   int i;
     507         [ #  # ]:          0 :   DLIList<RefFace*> modified_faces;
     508                 :            : 
     509                 :            :     // Get all edges in the faces in face_list
     510 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> query_input(face_list.size()), query_output;
         [ #  # ][ #  # ]
                 [ #  # ]
     511 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(face_list, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     512                 :            :   ModelQueryEngine::instance()
     513 [ #  # ][ #  # ]:          0 :     ->query_model( query_input, DagType::ref_edge_type(), query_output );
                 [ #  # ]
     514 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> edge_list(query_output.size());
                 [ #  # ]
     515 [ #  # ][ #  # ]:          0 :   CAST_LIST(query_output, edge_list, RefEdge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     516                 :            :   
     517                 :            :     // Remove all edges that don't occur in exactly two faces in list
     518         [ #  # ]:          0 :   edge_list.last();
     519 [ #  # ][ #  # ]:          0 :   DLIList<CoEdge*> coedges;
     520 [ #  # ][ #  # ]:          0 :   for (i = edge_list.size(); i--; )
     521                 :            :   {
     522         [ #  # ]:          0 :     RefEdge* edge = edge_list.step_and_get();
     523         [ #  # ]:          0 :     coedges.clean_out();
     524         [ #  # ]:          0 :     edge->co_edges(coedges);
     525 [ #  # ][ #  # ]:          0 :     if (coedges.size() == 2)
     526                 :            :     {
     527 [ #  # ][ #  # ]:          0 :       RefFace* face1 = coedges.get()->get_ref_face();
     528 [ #  # ][ #  # ]:          0 :       RefFace* face2 = coedges.next()->get_ref_face();
     529                 :            :       // Check to make sure both faces are in the faces we are compositing
     530                 :            :       // and also make sure the faces are not the same otherwise we
     531                 :            :       // will composite out hardlines in one of the faces.
     532 [ #  # ][ #  # ]:          0 :       if (face1 != face2 &&
     533 [ #  # ][ #  # ]:          0 :         face_list.is_in_list(face1) && face_list.is_in_list(face2))
         [ #  # ][ #  # ]
     534                 :          0 :         continue;
     535                 :            :     }
     536                 :            :     
     537         [ #  # ]:          0 :     edge_list.change_to(0);
     538                 :            :   }
     539         [ #  # ]:          0 :   edge_list.remove_all_with_value(0);
     540                 :            :   
     541 [ #  # ][ #  # ]:          0 :   if( edge_list.size() == 0 )
     542                 :            :   {
     543 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot create composites from the specified surfaces.\n");
         [ #  # ][ #  # ]
     544                 :          0 :     return 0;
     545                 :            :   } 
     546                 :            : 
     547         [ #  # ]:          0 :   edge_list.reset();
     548 [ #  # ][ #  # ]:          0 :   for( i = edge_list.size(); i--; )
     549                 :            :   {
     550         [ #  # ]:          0 :     RefEdge* edge = edge_list.get_and_step();
     551         [ #  # ]:          0 :     RefFace* face = remove_edge( edge, false, false, keep_face );      
     552         [ #  # ]:          0 :     if (face)
     553         [ #  # ]:          0 :       modified_faces.append_unique(face);
     554                 :            :   }
     555                 :            :   
     556 [ #  # ][ #  # ]:          0 :   for ( i = modified_faces.size(); i--; )
     557 [ #  # ][ #  # ]:          0 :     if( ! modified_faces.step_and_get()->get_surface_ptr() )
                 [ #  # ]
     558         [ #  # ]:          0 :       modified_faces.change_to(0);
     559         [ #  # ]:          0 :   modified_faces.remove_all_with_value(0);  
     560                 :            :   
     561 [ #  # ][ #  # ]:          0 :   RefFace* result = modified_faces.size() ? modified_faces.get() : 0;
                 [ #  # ]
     562                 :            : 
     563                 :            : #ifdef ALPHA_TREADSWEEP
     564                 :            :   // Make sure names from all of the faces get added to the
     565                 :            :   // list of names in the result.
     566                 :            :   if(result)
     567                 :            :   {
     568                 :            :     for(i=face_list.size(); i--;)
     569                 :            :     {
     570                 :            :       RefFace *cur_face = face_list.get_and_step();
     571                 :            :       if(cur_face != result)
     572                 :            :       {
     573                 :            :         result->merge_entity_names(cur_face);
     574                 :            :       }
     575                 :            :     }
     576                 :            :   }
     577                 :            : #endif
     578                 :            : 
     579 [ #  # ][ #  # ]:          0 :   DLIList<RefVolume*> vol_list, surf_vols;
         [ #  # ][ #  # ]
     580 [ #  # ][ #  # ]:          0 :   for ( i = modified_faces.size(); i--; )
     581                 :            :   {
     582         [ #  # ]:          0 :     RefFace* face = modified_faces.get_and_step();
     583 [ #  # ][ #  # ]:          0 :     face->set_id( RefEntityFactory::instance()->next_ref_face_id() );
                 [ #  # ]
     584         [ #  # ]:          0 :     surf_vols.clean_out();
     585         [ #  # ]:          0 :     face->ref_volumes(surf_vols);
     586         [ #  # ]:          0 :     vol_list.merge_unique(surf_vols);
     587                 :            :   }
     588                 :            :   
     589         [ #  # ]:          0 :   vol_list.reset();
     590 [ #  # ][ #  # ]:          0 :   for ( i = vol_list.size(); i--; )
     591                 :            :   {
     592         [ #  # ]:          0 :     RefVolume* vol = vol_list.get_and_step();
     593         [ #  # ]:          0 :     Lump* lump = vol->get_lump_ptr();
     594 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->make_Body(lump->bodysm());
                 [ #  # ]
     595                 :            :   }
     596 [ #  # ][ #  # ]:          0 :   assert( !(keep_face && keep_face->deactivated()) );
                 [ #  # ]
     597 [ #  # ][ #  # ]:          0 :   DAG::instance()->cleanout_deactivated_DAG_nodes();
     598                 :            : 
     599         [ #  # ]:          0 :   return result;
     600                 :            : }
     601                 :            : 
     602                 :            : //-------------------------------------------------------------------------
     603                 :            : // Purpose       : Composite over a curve
     604                 :            : //
     605                 :            : // Special Notes : 
     606                 :            : //
     607                 :            : // Creator       : Jason Kraftcheck
     608                 :            : //
     609                 :            : // Creation Date : 03/12/03
     610                 :            : //-------------------------------------------------------------------------
     611                 :          0 : RefFace* CompositeTool::remove_edge( RefEdge* edge,
     612                 :            :                                      bool remove_partitions, /* = false */
     613                 :            :                                      bool update_dag,        /* = true  */
     614                 :            :                                      RefFace* keep_face      /* = NULL  */ )
     615                 :            : {
     616                 :            :   int i;
     617                 :            : 
     618         [ #  # ]:          0 :   DLIList<CoEdge*> edge_coedges;
     619         [ #  # ]:          0 :   edge->co_edges(edge_coedges);
     620 [ #  # ][ #  # ]:          0 :   if (edge_coedges.size() != 2 && 
         [ #  # ][ #  # ]
     621 [ #  # ][ #  # ]:          0 :      (edge->get_curve_ptr()->geometry_type() != POINT_CURVE_TYPE ||
                 [ #  # ]
     622         [ #  # ]:          0 :       edge_coedges.size() != 1))
     623                 :            :   {
     624 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot composite over %d-valent curve %d (%s)\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     625         [ #  # ]:          0 :       edge_coedges.size(), edge->id(), edge->entity_name().c_str());
     626                 :          0 :     return NULL;
     627                 :            :   }
     628                 :            : 
     629 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> curves(edge->bridge_manager()->number_of_bridges());
         [ #  # ][ #  # ]
     630 [ #  # ][ #  # ]:          0 :   edge->bridge_manager()->get_bridge_list( curves );
     631                 :            : 
     632 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surfaces;
     633 [ #  # ][ #  # ]:          0 :   assert(curves.size());
     634 [ #  # ][ #  # ]:          0 :   curves.get()->surfaces( surfaces );
     635 [ #  # ][ #  # ]:          0 :   if ( surfaces.size() > 2  || surfaces.size() < 1 )
         [ #  # ][ #  # ]
                 [ #  # ]
     636                 :            :   {
     637 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot composite over %d-valence curve %d\n",
         [ #  # ][ #  # ]
                 [ #  # ]
     638         [ #  # ]:          0 :       surfaces.size(), edge->id() );
     639                 :          0 :     return 0;
     640                 :            :   }
     641                 :            :     
     642                 :          0 :   RefFace* face = 0;
     643                 :            : 
     644                 :            :   // These will be the two RefFaces associated with the two 
     645                 :            :   // surfaces being composited.  We need to store them before we
     646                 :            :   // get to the call to remove_curve because after that we won't
     647                 :            :   // have access to both of them and we need to pass both of them
     648                 :            :   // down to update_combined_faces.
     649                 :          0 :   RefFace *face1 = NULL;
     650                 :          0 :   RefFace *face2 = NULL;
     651                 :            :     
     652 [ #  # ][ #  # ]:          0 :   std::vector<CubitString> names_to_add;
     653         [ #  # ]:          0 :   curves.reset();
     654                 :          0 :   Surface* surface = 0;
     655 [ #  # ][ #  # ]:          0 :   for( i = curves.size(); i--; )
     656                 :            :   {
     657 [ #  # ][ #  # ]:          0 :     Curve* curve = dynamic_cast<Curve*>(curves.get_and_step());
     658                 :            : 
     659                 :            :       // get the two Surfaces that will be involved in the composite operation
     660                 :            :       // when the curve is removed
     661         [ #  # ]:          0 :     DLIList<Surface*> surfs;
     662         [ #  # ]:          0 :     curve->surfaces(surfs);
     663 [ #  # ][ #  # ]:          0 :     assert(surfs.size() > 0  && surfs.size() <= 2);  // should be one or two surfs
         [ #  # ][ #  # ]
     664 [ #  # ][ #  # ]:          0 :     face1 = dynamic_cast<RefFace*>(surfs.get()->topology_entity());
                 [ #  # ]
     665 [ #  # ][ #  # ]:          0 :     face2 = dynamic_cast<RefFace*>(surfs.next()->topology_entity());
                 [ #  # ]
     666                 :            : 
     667                 :            :     //Save the names and ids
     668 [ #  # ][ #  # ]:          0 :     surfs.get()->set_saved_id(face1->id());
                 [ #  # ]
     669 [ #  # ][ #  # ]:          0 :     DLIList<CubitString> tmp_names;
                 [ #  # ]
     670         [ #  # ]:          0 :     face1->entity_names( tmp_names );        
     671 [ #  # ][ #  # ]:          0 :     surfs.get()->set_saved_names( tmp_names.as_vector() );
                 [ #  # ]
     672 [ #  # ][ #  # ]:          0 :     std::vector<CubitString> face1_names = tmp_names.as_vector();
         [ #  # ][ #  # ]
     673         [ #  # ]:          0 :     tmp_names.clean_out();       
     674         [ #  # ]:          0 :     face1->remove_entity_names();
     675                 :            :     
     676 [ #  # ][ #  # ]:          0 :     surfs.next()->set_saved_id(face2->id());
                 [ #  # ]
     677         [ #  # ]:          0 :     face2->entity_names( tmp_names );        
     678 [ #  # ][ #  # ]:          0 :     surfs.next()->set_saved_names( tmp_names.as_vector() );
                 [ #  # ]
     679 [ #  # ][ #  # ]:          0 :     std::vector<CubitString> face2_names = tmp_names.as_vector();
         [ #  # ][ #  # ]
     680         [ #  # ]:          0 :     tmp_names.clean_out();       
     681         [ #  # ]:          0 :     face2->remove_entity_names();
     682                 :            : 
     683                 :            :       // if only one surface, the edge should be internal to a composite surface
     684         [ #  # ]:          0 :     surfs.reset();
     685                 :            : 
     686                 :            :       // Composite the surfaces
     687                 :          0 :     Surface* result = 0;
     688                 :          0 :     PartitionCurve* partcurve = 0;
     689 [ #  # ][ #  # ]:          0 :     if ( !(partcurve = dynamic_cast<SegmentedCurve*>(curve)) )
     690         [ #  # ]:          0 :       partcurve = dynamic_cast<PartPTCurve*>(curve);
     691                 :            :     
     692                 :          0 :     Surface* keep = 0;
     693         [ #  # ]:          0 :     if (keep_face) {
     694 [ #  # ][ #  # ]:          0 :       if (surfs.get()->owner() == keep_face->bridge_manager())
         [ #  # ][ #  # ]
     695         [ #  # ]:          0 :         keep = surfs.get();
     696 [ #  # ][ #  # ]:          0 :       else if (surfs.next()->owner() == keep_face->bridge_manager())
         [ #  # ][ #  # ]
     697         [ #  # ]:          0 :         keep = surfs.next();
     698                 :            :     }
     699 [ #  # ][ #  # ]:          0 :     if( remove_partitions && partcurve )
     700 [ #  # ][ #  # ]:          0 :       result = PartitionEngine::instance().remove_curve( partcurve );
     701         [ #  # ]:          0 :     if( !result )
     702 [ #  # ][ #  # ]:          0 :       result = CompositeEngine::instance().remove_curve( curve, remove_partitions, keep );
     703                 :            : 
     704         [ #  # ]:          0 :     if( !result )
     705                 :            :     {
     706                 :            :       //reapply names
     707 [ #  # ][ #  # ]:          0 :       for( int i=face1_names.size(); i--; )
     708 [ #  # ][ #  # ]:          0 :         face1->entity_name( face1_names[i] );
         [ #  # ][ #  # ]
     709 [ #  # ][ #  # ]:          0 :       for( int i=face2_names.size(); i--; )
     710 [ #  # ][ #  # ]:          0 :         face2->entity_name( face2_names[i] );
         [ #  # ][ #  # ]
     711                 :            : 
     712 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Failed to remove curve %d\n",edge->id());
         [ #  # ][ #  # ]
                 [ #  # ]
     713                 :          0 :       break;
     714                 :            :     }
     715         [ #  # ]:          0 :     else if( !face )  // get surviving refface
     716                 :            :     {
     717 [ #  # ][ #  # ]:          0 :       face = dynamic_cast<RefFace*>(result->topology_entity());
     718                 :            :     }
     719                 :            :     
     720                 :            :     else  // merge resulting composites into surviving refface
     721                 :            :     {
     722 [ #  # ][ #  # ]:          0 :       RefFace* old_face = dynamic_cast<RefFace*>(result->topology_entity());
     723         [ #  # ]:          0 :       if( old_face != face )
     724                 :            :       {
     725         [ #  # ]:          0 :         if( old_face )
     726 [ #  # ][ #  # ]:          0 :           old_face->bridge_manager()->remove_bridge( result );
     727 [ #  # ][ #  # ]:          0 :         face->bridge_manager()->add_bridge( result );                
     728                 :            :       }
     729                 :            :     }
     730                 :            :     
     731 [ #  # ][ #  # ]:          0 :     names_to_add.insert(names_to_add.end(), face1_names.begin(), face1_names.end() );
         [ #  # ][ #  # ]
     732 [ #  # ][ #  # ]:          0 :     names_to_add.insert(names_to_add.end(), face2_names.begin(), face2_names.end() );
         [ #  # ][ #  # ]
     733                 :            :       
     734         [ #  # ]:          0 :     if( result )
     735 [ #  # ][ #  # ]:          0 :       surface = result;
     736                 :          0 :   }
     737                 :            :   
     738         [ #  # ]:          0 :   if( !surface )
     739                 :            :   {
     740 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Failed to remove curve %d\n", edge->id() );
         [ #  # ][ #  # ]
                 [ #  # ]
     741                 :          0 :     return 0;
     742                 :            :   }
     743                 :            :   
     744 [ #  # ][ #  # ]:          0 :   RefFace* result = dynamic_cast<RefFace*>(surface->topology_entity());
     745         [ #  # ]:          0 :   assert( result == face );
     746                 :            : 
     747                 :            :   //append all names to this ref entity
     748 [ #  # ][ #  # ]:          0 :   for (size_t k = 0; k < names_to_add.size(); k++)
     749 [ #  # ][ #  # ]:          0 :     result->entity_name( names_to_add[k] );
         [ #  # ][ #  # ]
     750                 :            : 
     751                 :            :     // notify observers that one face is being composited into another
     752                 :            : 
     753                 :            :   // We need to pass the result face and also the one that wasn't chosen
     754                 :            :   // as the result face.
     755                 :          0 :   RefFace *delete_face = face1;
     756         [ #  # ]:          0 :   if(result == delete_face)
     757                 :          0 :     delete_face = face2;
     758         [ #  # ]:          0 :   update_combined_faces( result, edge, delete_face );
     759                 :            :   
     760         [ #  # ]:          0 :   if ( update_dag )
     761                 :            :   {
     762         [ #  # ]:          0 :     DLIList<RefVolume*> modified_volumes;
     763         [ #  # ]:          0 :     result->ref_volumes(modified_volumes);
     764 [ #  # ][ #  # ]:          0 :     for( i = modified_volumes.size(); i--; )
     765                 :            :     {
     766         [ #  # ]:          0 :       RefVolume* volume = modified_volumes.get_and_step();
     767         [ #  # ]:          0 :       Lump* lump = volume->get_lump_ptr();
     768 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->make_Body(lump->bodysm());
                 [ #  # ]
     769                 :            :     }
     770                 :            : 
     771 [ #  # ][ #  # ]:          0 :     assert( !(keep_face && keep_face->deactivated()) );
                 [ #  # ]
     772 [ #  # ][ #  # ]:          0 :     DAG::instance()->cleanout_deactivated_DAG_nodes();
                 [ #  # ]
     773                 :            :   }
     774                 :            :   
     775         [ #  # ]:          0 :   return result;
     776                 :            : }
     777                 :            : 
     778                 :            : //-------------------------------------------------------------------------
     779                 :            : // Purpose       : Create a composite volume
     780                 :            : //
     781                 :            : // Special Notes : 
     782                 :            : //
     783                 :            : // Creator       : Jason Kraftcheck
     784                 :            : //
     785                 :            : // Creation Date : 09/25/01
     786                 :            : //-------------------------------------------------------------------------
     787                 :          0 : RefVolume* CompositeTool::composite( DLIList<RefVolume*>& volumes,
     788                 :            :                                      Body** body_ptr /* = 0 */ )
     789                 :            : {
     790                 :            :   int i;
     791         [ #  # ]:          0 :   DLIList<RefVolume*> modified_vols;
     792 [ #  # ][ #  # ]:          0 :   DLIList<Body*> input_bodies;
     793 [ #  # ][ #  # ]:          0 :   for (i = volumes.size(); i--; )
     794 [ #  # ][ #  # ]:          0 :     input_bodies.append_unique( volumes.get_and_step()->get_body_ptr() );
                 [ #  # ]
     795                 :            : 
     796                 :            :     // Get all faces in the volumes
     797 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> query_input(volumes.size()), query_output;
         [ #  # ][ #  # ]
                 [ #  # ]
     798 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT(volumes, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     799                 :            :   ModelQueryEngine::instance()
     800 [ #  # ][ #  # ]:          0 :     ->query_model( query_input, DagType::ref_face_type(), query_output );
                 [ #  # ]
     801 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> faces(query_output.size());
                 [ #  # ]
     802 [ #  # ][ #  # ]:          0 :   CAST_LIST(query_output, faces, RefFace);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     803                 :            :   
     804                 :            :     // Remove all faces that don't occur in exactly two volumes in list
     805         [ #  # ]:          0 :   faces.last();
     806 [ #  # ][ #  # ]:          0 :   DLIList<CoFace*> cofaces;
     807 [ #  # ][ #  # ]:          0 :   for (i = faces.size(); i--; )
     808                 :            :   {
     809         [ #  # ]:          0 :     RefFace* face = faces.step_and_get();
     810         [ #  # ]:          0 :     cofaces.clean_out();
     811         [ #  # ]:          0 :     face->co_faces(cofaces);
     812 [ #  # ][ #  # ]:          0 :     if (cofaces.size() == 2)
     813                 :            :     {
     814 [ #  # ][ #  # ]:          0 :       RefVolume* vol1 = cofaces.get()->get_ref_volume();
     815 [ #  # ][ #  # ]:          0 :       RefVolume* vol2 = cofaces.next()->get_ref_volume();
     816 [ #  # ][ #  # ]:          0 :       if (volumes.is_in_list(vol1) && volumes.is_in_list(vol2))
         [ #  # ][ #  # ]
                 [ #  # ]
     817                 :          0 :         continue;
     818                 :            :     }
     819                 :            :     
     820         [ #  # ]:          0 :     faces.change_to(0);
     821                 :            :   }
     822         [ #  # ]:          0 :   faces.remove_all_with_value(0);
     823                 :            :   
     824 [ #  # ][ #  # ]:          0 :   if( faces.size() == 0 )
     825                 :            :   {
     826 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot create composites from the specified volumes.\n");
         [ #  # ][ #  # ]
     827                 :          0 :     return 0;
     828                 :            :   }
     829                 :            :   
     830         [ #  # ]:          0 :   faces.reset();
     831 [ #  # ][ #  # ]:          0 :   for( i = faces.size(); i--; )
     832                 :            :   {
     833         [ #  # ]:          0 :     RefFace* face = faces.get_and_step();
     834         [ #  # ]:          0 :     RefVolume* vol = remove_face( face, false, false );
     835         [ #  # ]:          0 :     if (vol)
     836         [ #  # ]:          0 :       modified_vols.append_unique(vol);
     837                 :            :   }
     838                 :            :   
     839 [ #  # ][ #  # ]:          0 :   for ( i = modified_vols.size(); i--; )
     840 [ #  # ][ #  # ]:          0 :     if( ! modified_vols.step_and_get()->get_lump_ptr() )
                 [ #  # ]
     841         [ #  # ]:          0 :       modified_vols.change_to(0);
     842         [ #  # ]:          0 :   modified_vols.remove_all_with_value(0);  
     843                 :            :   
     844 [ #  # ][ #  # ]:          0 :   RefVolume* result = modified_vols.size() ? modified_vols.get() : 0;
                 [ #  # ]
     845 [ #  # ][ #  # ]:          0 :   for ( i = modified_vols.size(); i--; )
     846                 :            :   {
     847         [ #  # ]:          0 :     RefVolume* vol = modified_vols.get_and_step();
     848 [ #  # ][ #  # ]:          0 :     vol->set_id( RefEntityFactory::instance()->next_ref_volume_id() );
                 [ #  # ]
     849                 :            :   }
     850                 :            :   
     851         [ #  # ]:          0 :   input_bodies.reset();
     852 [ #  # ][ #  # ]:          0 :   for ( i = input_bodies.size(); i--; )
     853                 :            :   {
     854         [ #  # ]:          0 :     Body* body = input_bodies.get_and_step();
     855         [ #  # ]:          0 :     BodySM* sm = body->get_body_sm_ptr();
     856         [ #  # ]:          0 :     if (sm)
     857 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->make_Body(sm);
     858                 :            :     else
     859 [ #  # ][ #  # ]:          0 :       GeometryQueryTool::instance()->destroy_dead_entity( body );
     860                 :            :   }
     861 [ #  # ][ #  # ]:          0 :   DAG::instance()->cleanout_deactivated_DAG_nodes();
     862                 :            :    
     863         [ #  # ]:          0 :   if (body_ptr)
     864         [ #  # ]:          0 :     *body_ptr = result->get_body_ptr();
     865         [ #  # ]:          0 :   return result;
     866                 :            : }
     867                 :            : 
     868                 :            : //-------------------------------------------------------------------------
     869                 :            : // Purpose       : Composite over a surface
     870                 :            : //
     871                 :            : // Special Notes : 
     872                 :            : //
     873                 :            : // Creator       : Jason Kraftcheck
     874                 :            : //
     875                 :            : // Creation Date : 03/12/03
     876                 :            : //-------------------------------------------------------------------------
     877                 :          0 : RefVolume* CompositeTool::remove_face( RefFace* face,
     878                 :            :                                   bool remove_partitions, /* = false */
     879                 :            :                                   bool update_dag         /* = true  */)
     880                 :            : {
     881                 :            :   int i;
     882                 :            : 
     883         [ #  # ]:          0 :   DLIList<RefVolume*> vol_list(2);
     884         [ #  # ]:          0 :   face->ref_volumes( vol_list );
     885                 :            : 
     886 [ #  # ][ #  # ]:          0 :   DLIList<CoFace*> face_cofaces;
     887         [ #  # ]:          0 :   face->co_faces(face_cofaces);
     888 [ #  # ][ #  # ]:          0 :   if (face_cofaces.size() != 2)
     889                 :            :   {
     890 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot composite over %d-valent surface %d (%s)\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     891         [ #  # ]:          0 :       face_cofaces.size(), face->id(), face->entity_name().c_str());
     892                 :          0 :     return NULL;
     893                 :            :   }
     894                 :            : 
     895 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> surfs(face->bridge_manager()->number_of_bridges());
         [ #  # ][ #  # ]
     896 [ #  # ][ #  # ]:          0 :   face->bridge_manager()->get_bridge_list( surfs );
     897                 :            :   
     898                 :            :     // Seam topology
     899                 :          0 :   Surface *surf1 = 0, *surf2 = 0;
     900 [ #  # ][ #  # ]:          0 :   if (surfs.size()  == 2)
     901                 :            :   {
     902         [ #  # ]:          0 :     surfs.reset();
     903 [ #  # ][ #  # ]:          0 :     surf1 = dynamic_cast<Surface*>(surfs.get());
     904 [ #  # ][ #  # ]:          0 :     surf2 = dynamic_cast<Surface*>(surfs.next());
     905                 :            :     
     906         [ #  # ]:          0 :     DLIList<RefEdge*> edge_list;
     907 [ #  # ][ #  # ]:          0 :     DLIList<TopologyBridge*> bridges, ptcurves;
         [ #  # ][ #  # ]
     908 [ #  # ][ #  # ]:          0 :     DLIList<Surface*> surfaces;
     909         [ #  # ]:          0 :     face->ref_edges( edge_list );
     910 [ #  # ][ #  # ]:          0 :     while( edge_list.size() )
     911                 :            :     {
     912         [ #  # ]:          0 :       RefEdge* edge = edge_list.pop();
     913 [ #  # ][ #  # ]:          0 :       edge->bridge_manager()->get_bridge_list( bridges );
     914                 :          0 :       TopologyBridge *curve1 = 0, *curve2 = 0;
     915 [ #  # ][ #  # ]:          0 :       while (bridges.size())
     916                 :            :       {
     917         [ #  # ]:          0 :         TopologyBridge* curve = bridges.pop();
     918         [ #  # ]:          0 :         surfaces.clean_out();
     919         [ #  # ]:          0 :         curve->surfaces( surfaces );
     920 [ #  # ][ #  # ]:          0 :         if (surfaces.is_in_list(surf1))
     921                 :          0 :           curve1 = curve;
     922 [ #  # ][ #  # ]:          0 :         if (surfaces.is_in_list(surf2))
     923                 :          0 :           curve2 = curve;
     924                 :            :       }
     925                 :            :       
     926 [ #  # ][ #  # ]:          0 :       assert(curve1 && curve2);
     927         [ #  # ]:          0 :       if (curve1 == curve2)
     928                 :          0 :         continue;
     929                 :            :       
     930         [ #  # ]:          0 :       for (int i = 0; i < 2; i++)
     931                 :            :       {
     932 [ #  # ][ #  # ]:          0 :         RefVertex* vtx = i ? edge->end_vertex() : edge->start_vertex();
                 [ #  # ]
     933 [ #  # ][ #  # ]:          0 :         vtx->bridge_manager()->get_bridge_list( bridges );
     934                 :          0 :         TopologyBridge *point1 = 0, *point2 = 0;
     935 [ #  # ][ #  # ]:          0 :         while (bridges.size())
     936                 :            :         {
     937         [ #  # ]:          0 :           TopologyBridge* point = bridges.pop();
     938         [ #  # ]:          0 :           ptcurves.clean_out();
     939         [ #  # ]:          0 :           point->get_parents(ptcurves);
     940 [ #  # ][ #  # ]:          0 :           if (ptcurves.is_in_list( curve1 ))
     941                 :          0 :             point1 = point;
     942 [ #  # ][ #  # ]:          0 :           if (ptcurves.is_in_list( curve2 ))
     943                 :          0 :             point2 = point;
     944                 :            :         }
     945                 :            :         
     946         [ #  # ]:          0 :         if (point1 != point2)
     947         [ #  # ]:          0 :           CompositeEngine::instance().stitch_points( 
     948                 :            :             dynamic_cast<TBPoint*>(point1), 
     949 [ #  # ][ #  # ]:          0 :             dynamic_cast<TBPoint*>(point2) );
                 [ #  # ]
     950                 :            :       }
     951                 :            :       
     952         [ #  # ]:          0 :       CompositeEngine::instance().stitch_curves( 
     953                 :            :             dynamic_cast<Curve*>(curve1), 
     954 [ #  # ][ #  # ]:          0 :             dynamic_cast<Curve*>(curve2) );
                 [ #  # ]
     955         [ #  # ]:          0 :     }
     956                 :            :   }
     957 [ #  # ][ #  # ]:          0 :   else if (surfs.size() == 1)
     958                 :            :   {
     959 [ #  # ][ #  # ]:          0 :      surf1 = dynamic_cast<Surface*>(surfs.get());
     960                 :          0 :      surf2 = 0;
     961                 :            :   }
     962                 :            :   else
     963                 :            :   {
     964                 :          0 :     return 0;
     965                 :            :   }
     966                 :            : 
     967 [ #  # ][ #  # ]:          0 :   DLIList<Lump*> lumps, tmp;
         [ #  # ][ #  # ]
     968         [ #  # ]:          0 :   surf1->lumps( lumps );
     969         [ #  # ]:          0 :   if (surf2)
     970                 :            :   {
     971         [ #  # ]:          0 :     surf2->lumps(tmp);
     972         [ #  # ]:          0 :     lumps.merge_unique(tmp);
     973                 :            :   }
     974 [ #  # ][ #  # ]:          0 :   if ( lumps.size() > 2  || lumps.size() < 1 )
         [ #  # ][ #  # ]
                 [ #  # ]
     975                 :            :   {
     976 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot composite over %d-valence surface %d\n",
         [ #  # ][ #  # ]
                 [ #  # ]
     977         [ #  # ]:          0 :       lumps.size(), face->id() );
     978                 :          0 :     return 0;
     979                 :            :   }
     980                 :            :     
     981                 :            :     // get the two Lumps that will be involved in the composite operation
     982                 :            :     // when the surface is removed
     983                 :          0 :   Lump* lump = 0;
     984 [ #  # ][ #  # ]:          0 :   RefVolume *tmp_vol = dynamic_cast<RefVolume*>(lumps.get()->topology_entity());
                 [ #  # ]
     985 [ #  # ][ #  # ]:          0 :   lumps.get()->set_saved_id( tmp_vol->id() );
                 [ #  # ]
     986 [ #  # ][ #  # ]:          0 :   DLIList<CubitString> names;
     987         [ #  # ]:          0 :   tmp_vol->entity_names( names );
     988 [ #  # ][ #  # ]:          0 :   lumps.get()->set_saved_names( names.as_vector() );
                 [ #  # ]
     989         [ #  # ]:          0 :   names.clean_out();  
     990                 :            : 
     991 [ #  # ][ #  # ]:          0 :   tmp_vol = dynamic_cast<RefVolume*>(lumps.get()->topology_entity());
                 [ #  # ]
     992 [ #  # ][ #  # ]:          0 :   lumps.next()->set_saved_id( tmp_vol->id() );
                 [ #  # ]
     993         [ #  # ]:          0 :   tmp_vol->entity_names( names );
     994 [ #  # ][ #  # ]:          0 :   lumps.next()->set_saved_names( names.as_vector() );
                 [ #  # ]
     995                 :            : 
     996                 :            :     // if only one lump, the surface should be internal to a composite lump
     997         [ #  # ]:          0 :   lumps.reset();
     998                 :            : 
     999                 :            :     // Composite the lumps
    1000         [ #  # ]:          0 :   PartitionSurface* partsurf = dynamic_cast<PartitionSurface*>(surf1);
    1001 [ #  # ][ #  # ]:          0 :   if( surf1 == surf2 && remove_partitions && partsurf )
                 [ #  # ]
    1002 [ #  # ][ #  # ]:          0 :     lump = PartitionEngine::instance().remove_surface( partsurf );
    1003         [ #  # ]:          0 :   if( !lump )
    1004 [ #  # ][ #  # ]:          0 :     lump = CompositeEngine::instance().remove_surface( surf1, surf2, remove_partitions );
    1005                 :            : 
    1006         [ #  # ]:          0 :   if( !lump )
    1007                 :            :   {
    1008 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Failed to remove surface %d\n",face->id());
         [ #  # ][ #  # ]
                 [ #  # ]
    1009                 :          0 :     return 0;
    1010                 :            :   }
    1011                 :            :   
    1012 [ #  # ][ #  # ]:          0 :   RefVolume* result = dynamic_cast<RefVolume*>(lump->topology_entity());
    1013                 :            :   
    1014                 :            :     // notify observers that one face is being composited into another
    1015                 :          0 :   RefVolume* dead_vol =0;
    1016 [ #  # ][ #  # ]:          0 :   if (vol_list.size() > 1)
    1017                 :            :   {
    1018         [ #  # ]:          0 :     vol_list.move_to( result );
    1019         [ #  # ]:          0 :     dead_vol = vol_list.next();
    1020                 :            :   }
    1021         [ #  # ]:          0 :   update_combined_vols( result, dead_vol );
    1022                 :            :   
    1023         [ #  # ]:          0 :   if ( update_dag )
    1024                 :            :   {
    1025         [ #  # ]:          0 :     DLIList<Body*> modified_bodies;
    1026         [ #  # ]:          0 :     result->bodies(modified_bodies);
    1027 [ #  # ][ #  # ]:          0 :     for( i = modified_bodies.size(); i--; )
    1028                 :            :     {
    1029         [ #  # ]:          0 :       Body* body = modified_bodies.get_and_step();
    1030         [ #  # ]:          0 :       BodySM* sm = body->get_body_sm_ptr();
    1031         [ #  # ]:          0 :       if (sm)
    1032 [ #  # ][ #  # ]:          0 :         GeometryQueryTool::instance()->make_Body(sm);
    1033                 :            :       else
    1034 [ #  # ][ #  # ]:          0 :         GeometryQueryTool::instance()->destroy_dead_entity( body );
    1035                 :            :     }
    1036                 :            : 
    1037 [ #  # ][ #  # ]:          0 :     DAG::instance()->cleanout_deactivated_DAG_nodes();
                 [ #  # ]
    1038                 :            :   }
    1039                 :            :   
    1040         [ #  # ]:          0 :   return result;
    1041                 :            : }
    1042                 :            : 
    1043                 :            : 
    1044                 :            : //-------------------------------------------------------------------------
    1045                 :            : // Purpose       : Create a composite body
    1046                 :            : //
    1047                 :            : // Special Notes : 
    1048                 :            : //
    1049                 :            : // Creator       : Jason Kraftcheck
    1050                 :            : //
    1051                 :            : // Creation Date : 10/02/01
    1052                 :            : //-------------------------------------------------------------------------
    1053                 :          0 : Body* CompositeTool::composite( DLIList<Body*>& )
    1054                 :            : {
    1055                 :          0 :   return 0;
    1056                 :            : }
    1057                 :            : 
    1058                 :            : 
    1059                 :            : //-------------------------------------------------------------------------
    1060                 :            : // Purpose       : Check for the topological validity of a possible composite
    1061                 :            : //
    1062                 :            : // Special Notes : 
    1063                 :            : //
    1064                 :            : // Creator       : Jason Kraftcheck
    1065                 :            : //
    1066                 :            : // Creation Date : 
    1067                 :            : //-------------------------------------------------------------------------
    1068                 :          0 : CubitBoolean CompositeTool::okayToComposite( 
    1069                 :            :                         DLIList<BasicTopologyEntity*>& bte_list,
    1070                 :            :                         DLIList<BasicTopologyEntity*>* boundary,
    1071                 :            :                         DLIList<BasicTopologyEntity*>* internal,
    1072                 :            :                         bool print_errors,
    1073                 :            :                         bool force_same_parents ) const
    1074                 :            : {
    1075                 :            :   //check that all entities are of the same type
    1076         [ #  # ]:          0 :   bte_list.reset();
    1077 [ #  # ][ #  # ]:          0 :   DagType type = bte_list.get_and_step()->dag_type();
    1078 [ #  # ][ #  # ]:          0 :   if( (type != DagType::ref_face_type()) && 
         [ #  # ][ #  # ]
    1079 [ #  # ][ #  # ]:          0 :       (type != DagType::ref_edge_type()) && 
         [ #  # ][ #  # ]
    1080 [ #  # ][ #  # ]:          0 :       (type != DagType::ref_volume_type()) )
    1081                 :            :   {
    1082         [ #  # ]:          0 :     if (print_errors) 
    1083 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Invalid entities passed to CompositeTool::okayToComposite().\n");
         [ #  # ][ #  # ]
    1084                 :          0 :     return CUBIT_FALSE;
    1085                 :            :   }
    1086                 :            :   int i;
    1087 [ #  # ][ #  # ]:          0 :   for( i = bte_list.size(); i > 1; i-- )
    1088                 :            :   {
    1089 [ #  # ][ #  # ]:          0 :     if( bte_list.get_and_step()->dag_type() != type )
         [ #  # ][ #  # ]
    1090                 :            :     {
    1091 [ #  # ][ #  # ]:          0 :       if (print_errors) PRINT_ERROR("Cannot combine entities of different dimensionality.\n");
         [ #  # ][ #  # ]
                 [ #  # ]
    1092                 :          0 :       return CUBIT_FALSE;
    1093                 :            :     }
    1094                 :            :   }
    1095                 :            :   
    1096                 :            :   //check that all entities are C0-continous
    1097 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> unchecked_entities, current_entities,
                 [ #  # ]
    1098 [ #  # ][ #  # ]:          0 :                   next_entities, child_entities, temp_list ;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1099 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( bte_list, unchecked_entities);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1100 [ #  # ][ #  # ]:          0 :   current_entities.append( unchecked_entities.pop() );
    1101                 :            : 
    1102 [ #  # ][ #  # ]:          0 :   while( current_entities.size() > 0 )
    1103                 :            :   {
    1104         [ #  # ]:          0 :     next_entities.clean_out();
    1105         [ #  # ]:          0 :     child_entities.clean_out();
    1106                 :            : 
    1107                 :            :     
    1108                 :            :     // Get all adjacent entities
    1109 [ #  # ][ #  # ]:          0 :     for( i = current_entities.size(); i > 0; i-- )
    1110                 :            :     {
    1111         [ #  # ]:          0 :       temp_list.clean_out();
    1112 [ #  # ][ #  # ]:          0 :       current_entities.get_and_step()->get_child_ref_entities( temp_list );
    1113         [ #  # ]:          0 :       child_entities.merge_unique( temp_list );
    1114                 :            :     }
    1115                 :            : 
    1116 [ #  # ][ #  # ]:          0 :     for( i = child_entities.size(); i > 0; i-- )
    1117                 :            :     {
    1118         [ #  # ]:          0 :       temp_list.clean_out();
    1119 [ #  # ][ #  # ]:          0 :       child_entities.get_and_step()->get_parent_ref_entities( temp_list );
    1120         [ #  # ]:          0 :       next_entities.merge_unique( temp_list );
    1121                 :            :     }
    1122                 :            :     
    1123         [ #  # ]:          0 :     temp_list.clean_out();
    1124 [ #  # ][ #  # ]:          0 :     for( i = next_entities.size(); i > 0; i-- )
    1125                 :            :     {
    1126         [ #  # ]:          0 :       RefEntity* entity_ptr = next_entities.get_and_step();
    1127                 :            : 
    1128 [ #  # ][ #  # ]:          0 :       if( unchecked_entities.move_to( entity_ptr ) )
    1129                 :            :       {
    1130         [ #  # ]:          0 :         temp_list.append( entity_ptr );
    1131         [ #  # ]:          0 :         unchecked_entities.extract();
    1132                 :            :       }
    1133                 :            :     }
    1134         [ #  # ]:          0 :     current_entities = temp_list;
    1135                 :            :   }
    1136 [ #  # ][ #  # ]:          0 :   if( unchecked_entities.size() == 1 )
    1137                 :            :   {
    1138         [ #  # ]:          0 :     if (print_errors) 
    1139                 :            :     {
    1140 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("%s is not connected to any others.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1141         [ #  # ]:          0 :         unchecked_entities.get()->entity_name().c_str() );
    1142 [ #  # ][ #  # ]:          0 :       if( unchecked_entities.get()->dag_type() == DagType::ref_volume_type() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1143 [ #  # ][ #  # ]:          0 :         PRINT_ERROR("\tTry merging first.\n");
         [ #  # ][ #  # ]
    1144                 :            :     }
    1145                 :          0 :     return CUBIT_FALSE;
    1146                 :            :   }
    1147 [ #  # ][ #  # ]:          0 :   else if( unchecked_entities.size() > 1 )
    1148                 :            :   {
    1149         [ #  # ]:          0 :     if (print_errors) {
    1150 [ #  # ][ #  # ]:          0 :       PRINT_ERROR("Entities \n");
         [ #  # ][ #  # ]
    1151 [ #  # ][ #  # ]:          0 :       for( i = unchecked_entities.size(); i > 0; i-- )
    1152 [ #  # ][ #  # ]:          0 :         PRINT_INFO("%d, ",unchecked_entities.get_and_step()->id());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1153 [ #  # ][ #  # ]:          0 :       PRINT_INFO("do not appear to be connected to the others.\n");
         [ #  # ][ #  # ]
    1154                 :            :     }
    1155                 :            :     
    1156                 :          0 :     return CUBIT_FALSE;
    1157                 :            :   }
    1158                 :            :   
    1159                 :            :   //Check that all common children have at most two
    1160                 :            :   //parents (and those parents are in the list of entities to
    1161                 :            :   //composite).
    1162         [ #  # ]:          0 :   unchecked_entities.clean_out();
    1163         [ #  # ]:          0 :   child_entities.clean_out();
    1164 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( bte_list, unchecked_entities);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1165 [ #  # ][ #  # ]:          0 :   for( i = unchecked_entities.size(); i > 0; i-- )
    1166                 :            :   {
    1167         [ #  # ]:          0 :     temp_list.clean_out();
    1168 [ #  # ][ #  # ]:          0 :     unchecked_entities.get_and_step()->get_child_ref_entities( temp_list );
    1169         [ #  # ]:          0 :     child_entities.merge_unique( temp_list );
    1170                 :            :   }
    1171                 :            :   
    1172 [ #  # ][ #  # ]:          0 :   DLIList<SenseEntity*> sense_entity_list;
    1173 [ #  # ][ #  # ]:          0 :   for( i = child_entities.size(); i > 0; i-- )
    1174                 :            :   {
    1175                 :          0 :     int parent_count = 0;
    1176         [ #  # ]:          0 :     current_entities.clean_out();
    1177         [ #  # ]:          0 :     RefEntity* child_ptr = child_entities.step_and_get();
    1178         [ #  # ]:          0 :     sense_entity_list.clean_out();
    1179 [ #  # ][ #  # ]:          0 :     CAST_TO(child_ptr,BasicTopologyEntity)->get_sense_entity_list( sense_entity_list );
    1180 [ #  # ][ #  # ]:          0 :     for( int k = sense_entity_list.size(); k > 0; k-- )
    1181         [ #  # ]:          0 :       current_entities.append( sense_entity_list.get_and_step()->
    1182 [ #  # ][ #  # ]:          0 :         get_grouping_entity_ptr()->get_basic_topology_entity_ptr() );
         [ #  # ][ #  # ]
    1183 [ #  # ][ #  # ]:          0 :     for( int j = current_entities.size(); j> 0; j-- )
    1184 [ #  # ][ #  # ]:          0 :       if( unchecked_entities.move_to( current_entities.get_and_step() ) )
                 [ #  # ]
    1185                 :          0 :         parent_count++;
    1186   [ #  #  #  # ]:          0 :     switch( parent_count )
    1187                 :            :     {
    1188                 :            :       case 0:
    1189                 :            : //        assert( parent_count != 0 ); break;
    1190                 :          0 :         return CUBIT_FALSE;
    1191                 :            :       case 1:
    1192         [ #  # ]:          0 :         if( boundary != NULL ) boundary->
    1193 [ #  # ][ #  # ]:          0 :           append( CAST_TO( child_entities.get(), BasicTopologyEntity) );
                 [ #  # ]
    1194                 :          0 :         break;
    1195                 :            :       case 2:
    1196 [ #  # ][ #  # ]:          0 :         if( current_entities.size() != 2 )
    1197                 :            :         {
    1198 [ #  # ][ #  # ]:          0 :           if (print_errors) PRINT_ERROR("Child entity %d cannot be removed.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1199         [ #  # ]:          0 :                                         child_entities.get()->id() );
    1200                 :          0 :           return CUBIT_FALSE;
    1201                 :            :         }
    1202         [ #  # ]:          0 :         if( internal != NULL ) internal->
    1203 [ #  # ][ #  # ]:          0 :           append( CAST_TO( child_entities.get(), BasicTopologyEntity) );
                 [ #  # ]
    1204                 :          0 :         break;
    1205                 :            :       default:
    1206 [ #  # ][ #  # ]:          0 :         if (print_errors) PRINT_ERROR("Entities are not simply connected.\n");
         [ #  # ][ #  # ]
                 [ #  # ]
    1207                 :          0 :         return CUBIT_FALSE;
    1208                 :            :     }
    1209                 :            :   }
    1210                 :            :   
    1211                 :            :     //Check that all entities to merge are common to all parent grouping entities.
    1212         [ #  # ]:          0 :   if( force_same_parents )
    1213                 :            :   {
    1214 [ #  # ][ #  # ]:          0 :     assert( type.functional_type() == DagType::BasicTopologyEntity_TYPE );
    1215 [ #  # ][ #  # ]:          0 :     const DagType type_2 = DagType( type.dimension(), DagType::GroupingEntity_TYPE );
    1216 [ #  # ][ #  # ]:          0 :     DLIList<TopologyEntity*> first_entity_parents, current_entity_parents;
         [ #  # ][ #  # ]
    1217         [ #  # ]:          0 :     bte_list.reset();
    1218                 :            :     ModelQueryEngine::instance()->query_model( 
    1219 [ #  # ][ #  # ]:          0 :       *(bte_list.get_and_step()), type_2, first_entity_parents ); 
                 [ #  # ]
    1220                 :            : 
    1221 [ #  # ][ #  # ]:          0 :     for( i = bte_list.size(); i > 1; i-- )
         [ #  # ][ #  # ]
    1222                 :            :     {
    1223         [ #  # ]:          0 :       current_entity_parents.clean_out();
    1224                 :            :       ModelQueryEngine::instance()->query_model(
    1225 [ #  # ][ #  # ]:          0 :         *(bte_list.get_and_step()), type_2, current_entity_parents );
                 [ #  # ]
    1226                 :            : 
    1227 [ #  # ][ #  # ]:          0 :       if( current_entity_parents != first_entity_parents )  
    1228                 :            :       {
    1229 [ #  # ][ #  # ]:          0 :         if (print_errors) PRINT_ERROR("All entities to be combined must have common "
         [ #  # ][ #  # ]
    1230         [ #  # ]:          0 :                                       "topological parents.\n");
    1231                 :          0 :         return CUBIT_FALSE;
    1232                 :            :       }
    1233                 :          0 :     }
    1234                 :            :   }
    1235                 :            :     
    1236         [ #  # ]:          0 :   return CUBIT_TRUE;
    1237                 :            : }
    1238                 :            : 
    1239                 :            : //-------------------------------------------------------------------------
    1240                 :            : // Purpose       : Classify child topology
    1241                 :            : //
    1242                 :            : // Special Notes : 
    1243                 :            : //
    1244                 :            : // Creator       : Jason Kraftcheck
    1245                 :            : //
    1246                 :            : // Creation Date : 
    1247                 :            : //-------------------------------------------------------------------------
    1248                 :          0 : CubitStatus CompositeTool::classify_children( 
    1249                 :            :                                  DLIList<BasicTopologyEntity*>& bte_list,
    1250                 :            :                                  DLIList<BasicTopologyEntity*>& boundary_children,
    1251                 :            :                                  DLIList<BasicTopologyEntity*>& interior_children,
    1252                 :            :                                  DLIList<BasicTopologyEntity*>& unknown_children )
    1253                 :            : {
    1254 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> ref_entity_list, all_children;
                 [ #  # ]
    1255                 :            :   RefEntity *child_ptr, *parent_ptr;
    1256                 :            :   BasicTopologyEntity* bte_ptr;
    1257                 :            :   int i, j;
    1258 [ #  # ][ #  # ]:          0 :   for( i = bte_list.size(); i > 0; i-- )
    1259                 :            :   {
    1260         [ #  # ]:          0 :     ref_entity_list.clean_out();
    1261 [ #  # ][ #  # ]:          0 :     bte_list.get_and_step()->get_child_ref_entities( ref_entity_list );
    1262         [ #  # ]:          0 :     all_children.merge_unique( ref_entity_list );
    1263                 :            :   }
    1264 [ #  # ][ #  # ]:          0 :   for( i = all_children.size(); i > 0; i-- )
    1265                 :            :   {
    1266         [ #  # ]:          0 :     ref_entity_list.clean_out();
    1267         [ #  # ]:          0 :     child_ptr = all_children.get_and_step();
    1268         [ #  # ]:          0 :     child_ptr->get_parent_ref_entities( ref_entity_list );
    1269                 :            :     
    1270                 :          0 :     int parent_count = 0;
    1271 [ #  # ][ #  # ]:          0 :     for( j = ref_entity_list.size(); j > 0; j-- )
    1272                 :            :     {
    1273         [ #  # ]:          0 :       parent_ptr = ref_entity_list.get_and_step();
    1274         [ #  # ]:          0 :       bte_ptr = CAST_TO( parent_ptr, BasicTopologyEntity );
    1275 [ #  # ][ #  # ]:          0 :       if( bte_list.move_to( bte_ptr ) ) parent_count++;
    1276                 :            :     }
    1277                 :            :     
    1278         [ #  # ]:          0 :     bte_ptr = CAST_TO( child_ptr, BasicTopologyEntity );
    1279         [ #  # ]:          0 :     if( parent_count == 1 )
    1280         [ #  # ]:          0 :       boundary_children.append( bte_ptr );
    1281 [ #  # ][ #  # ]:          0 :     else if( parent_count == ref_entity_list.size() )
    1282         [ #  # ]:          0 :       interior_children.append( bte_ptr );
    1283                 :            :     else
    1284         [ #  # ]:          0 :       unknown_children.append( bte_ptr );
    1285                 :            :   }
    1286         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    1287                 :            : }
    1288                 :            :   
    1289                 :            :   
    1290                 :            :   
    1291                 :            : 
    1292                 :            : //-------------------------------------------------------------------------
    1293                 :            : // Purpose       : remove a composite edge, restoring the orignial edges.
    1294                 :            : //
    1295                 :            : // Special Notes : 
    1296                 :            : //
    1297                 :            : // Creator       : Jason Kraftcheck
    1298                 :            : //
    1299                 :            : // Creation Date : 
    1300                 :            : //-------------------------------------------------------------------------
    1301                 :          0 : CubitStatus CompositeTool::uncomposite( RefEdge* composite_edge, 
    1302                 :            :                                         DLIList<RefEdge*>* restored_edges)
    1303                 :            : {
    1304                 :            :   int i;
    1305         [ #  # ]:          0 :   DLIList<TBPoint*> hidden_points;
    1306 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> face_list;
    1307 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list;
    1308                 :            :   
    1309         [ #  # ]:          0 :   composite_edge->ref_faces( face_list );
    1310                 :            :   
    1311 [ #  # ][ #  # ]:          0 :   if( composite_edge->bridge_manager()->number_of_bridges() != 1 )
                 [ #  # ]
    1312                 :            :   {
    1313 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Curve %d is a merged curve.  Unmerge before removing composite.\n",
         [ #  # ][ #  # ]
    1314         [ #  # ]:          0 :       composite_edge->id() );
    1315                 :          0 :     return CUBIT_FAILURE;
    1316                 :            :   }
    1317                 :            :   
    1318 [ #  # ][ #  # ]:          0 :   CompositeCurve* curve_ptr = dynamic_cast<CompositeCurve*>(composite_edge->get_curve_ptr());
    1319         [ #  # ]:          0 :   if( !curve_ptr )
    1320                 :          0 :     return CUBIT_FAILURE;
    1321                 :            :   
    1322 [ #  # ][ #  # ]:          0 :   for( i = 0; i < curve_ptr->num_curves(); i++ )  
    1323 [ #  # ][ #  # ]:          0 :     curve_list.append( curve_ptr->get_curve(i) );
    1324                 :            : 
    1325                 :            :   //remove all names off this ref entity
    1326         [ #  # ]:          0 :   composite_edge->remove_entity_names();
    1327                 :            :   
    1328         [ #  # ]:          0 :   curve_ptr->get_hidden_points( hidden_points );
    1329                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
    1330         [ #  # ]:          0 :   hidden_points.reset();
    1331 [ #  # ][ #  # ]:          0 :   for( i = hidden_points.size(); i--; )
    1332                 :            :   {
    1333                 :            :     //remove attributes off the hidden points
    1334 [ #  # ][ #  # ]:          0 :     CompositeEngine::strip_attributes( hidden_points.get() );
    1335                 :            : 
    1336 [ #  # ][ #  # ]:          0 :     if( ! CompositeEngine::instance().
    1337 [ #  # ][ #  # ]:          0 :       restore_point( hidden_points.get_and_step() ) )
    1338                 :          0 :       result = CUBIT_FAILURE;
    1339                 :            :   }
    1340                 :            :   
    1341 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list;
    1342 [ #  # ][ #  # ]:          0 :   composite_edge->bridge_manager()->get_bridge_list(bridge_list);
    1343                 :          0 :   int smallest_id = 0;
    1344 [ #  # ][ #  # ]:          0 :   for ( i = bridge_list.size(); i--; )
    1345                 :            :   {
    1346 [ #  # ][ #  # ]:          0 :     GeometryEntity* geom_ptr = dynamic_cast<GeometryEntity*>(bridge_list.get_and_step());
    1347         [ #  # ]:          0 :     int saved_id = geom_ptr->get_saved_id();
    1348 [ #  # ][ #  # ]:          0 :     if ( saved_id && (!smallest_id || saved_id < smallest_id) &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1349 [ #  # ][ #  # ]:          0 :          !RefEntityFactory::instance()->get_ref_edge(saved_id) )
    1350                 :          0 :       smallest_id = saved_id;
    1351                 :            :   }
    1352 [ #  # ][ #  # ]:          0 :   if ( smallest_id && composite_edge->id() != smallest_id )
         [ #  # ][ #  # ]
    1353         [ #  # ]:          0 :     composite_edge->set_id( smallest_id );
    1354                 :            : 
    1355                 :            :   
    1356 [ #  # ][ #  # ]:          0 :   for( i = face_list.size(); i--; ) 
    1357                 :            :   {
    1358 [ #  # ][ #  # ]:          0 :     Surface* surf = face_list.get_and_step()->get_surface_ptr();
    1359 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->make_RefFace( surf );
    1360                 :            :   }
    1361 [ #  # ][ #  # ]:          0 :   for( i = face_list.size(); i--; )
    1362 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->destroy_dead_entity( face_list.get_and_step() );
                 [ #  # ]
    1363                 :            :   
    1364 [ #  # ][ #  # ]:          0 :   for( i = curve_list.size(); i--; )
    1365                 :            :   {
    1366                 :            :     //remove attributes off the underlying curves
    1367         [ #  # ]:          0 :     Curve *tmp_curve = curve_list.get_and_step();
    1368         [ #  # ]:          0 :     CompositeEngine::strip_attributes( tmp_curve );
    1369                 :            : 
    1370 [ #  # ][ #  # ]:          0 :     BridgeManager* bm = dynamic_cast<BridgeManager*>(tmp_curve->owner());
    1371 [ #  # ][ #  # ]:          0 :     RefEdge* edge = bm ? dynamic_cast<RefEdge*>(bm->topology_entity()) : 0;
                 [ #  # ]
    1372         [ #  # ]:          0 :     if( restored_edges )
    1373         [ #  # ]:          0 :       restored_edges->append( edge );
    1374         [ #  # ]:          0 :     std::vector<CubitString> underlying_names;
    1375         [ #  # ]:          0 :     tmp_curve->get_saved_names( underlying_names );
    1376 [ #  # ][ #  # ]:          0 :     for (size_t k = 0; k < underlying_names.size(); k++)
    1377 [ #  # ][ #  # ]:          0 :       edge->entity_name( underlying_names[k] );
         [ #  # ][ #  # ]
    1378         [ #  # ]:          0 :   }
    1379                 :            :     
    1380         [ #  # ]:          0 :   return result;
    1381                 :            : }
    1382                 :            : 
    1383                 :            : //-------------------------------------------------------------------------
    1384                 :            : // Purpose       : Restore a hidden point, remerging points and
    1385                 :            : //                 parent curves if possible.
    1386                 :            : //
    1387                 :            : // Special Notes : Helper function for uncomposite(RefFace*,...)
    1388                 :            : //
    1389                 :            : // Creator       : Jason Kraftcheck
    1390                 :            : //
    1391                 :            : // Creation Date : 08/06/03
    1392                 :            : //-------------------------------------------------------------------------
    1393                 :          0 : CubitStatus CompositeTool::restore_merged_point( TBPoint* hidden_pt,
    1394                 :            :                                       DLIList<RefFace*>& modified,
    1395                 :            :                                       bool force )
    1396                 :            : {
    1397                 :            :   int i;
    1398                 :            :   
    1399 [ #  # ][ #  # ]:          0 :   HiddenEntitySet* hs = dynamic_cast<HiddenEntitySet*>(hidden_pt->owner());
    1400         [ #  # ]:          0 :   if (!hs)
    1401                 :          0 :     return CUBIT_FAILURE;
    1402 [ #  # ][ #  # ]:          0 :   CompositeCurve* owner = dynamic_cast<CompositeCurve*>(hs->owner());
    1403         [ #  # ]:          0 :   if (!owner)
    1404                 :          0 :     return CUBIT_FAILURE;
    1405                 :            :   
    1406 [ #  # ][ #  # ]:          0 :   RefEdge* old_edge = dynamic_cast<RefEdge*>(owner->topology_entity());
    1407                 :            :   int num_curves;
    1408         [ #  # ]:          0 :   DLIList<TopologyBridge*> curve_bridges;
    1409         [ #  # ]:          0 :   if (old_edge)
    1410                 :            :   {
    1411 [ #  # ][ #  # ]:          0 :     num_curves = old_edge->bridge_manager()->number_of_bridges();
    1412 [ #  # ][ #  # ]:          0 :     old_edge->bridge_manager()->get_bridge_list(curve_bridges);
    1413                 :            :   }
    1414                 :            :   else
    1415                 :            :   {
    1416                 :          0 :     num_curves = 1;
    1417         [ #  # ]:          0 :     curve_bridges.append(owner);
    1418                 :            :   }
    1419                 :            :      
    1420 [ #  # ][ #  # ]:          0 :   DLIList<CompositeCurve*> curves(num_curves);
    1421 [ #  # ][ #  # ]:          0 :   CAST_LIST(curve_bridges, curves, CompositeCurve);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1422 [ #  # ][ #  # ]:          0 :   DLIList<TBPoint*> points(curves.size());
                 [ #  # ]
    1423                 :            :   
    1424 [ #  # ][ #  # ]:          0 :   assert(curves.is_in_list(owner));
    1425         [ #  # ]:          0 :   CubitVector position = hidden_pt->coordinates();
    1426                 :            :   
    1427 [ #  # ][ #  # ]:          0 :   DLIList<TBPoint*> curve_pts;
    1428         [ #  # ]:          0 :   curves.reset();
    1429         [ #  # ]:          0 :   GeometryQueryTool* gqt = GeometryQueryTool::instance();
    1430         [ #  # ]:          0 :   double factor = gqt->get_geometry_factor();
    1431 [ #  # ][ #  # ]:          0 :   for ( i = curves.size(); i--; )
    1432                 :            :   {
    1433         [ #  # ]:          0 :     curve_pts.clean_out();
    1434 [ #  # ][ #  # ]:          0 :     curves.get_and_step()->get_hidden_points(curve_pts);
    1435 [ #  # ][ #  # ]:          0 :     for (int j = curve_pts.size(); j--; )
    1436                 :            :     {
    1437         [ #  # ]:          0 :       TBPoint* curve_pt = curve_pts.get_and_step();
    1438 [ #  # ][ #  # ]:          0 :       if (gqt->about_spatially_equal(position, curve_pt->coordinates(), factor))
                 [ #  # ]
    1439                 :            :       {
    1440         [ #  # ]:          0 :         points.append(curve_pt);
    1441                 :          0 :         break;
    1442                 :            :       }
    1443                 :            :     }
    1444                 :            :   }
    1445                 :            :   
    1446 [ #  # ][ #  # ]:          0 :   if (!force && points.size() != curve_bridges.size())
         [ #  # ][ #  # ]
                 [ #  # ]
    1447                 :            :   {
    1448 [ #  # ][ #  # ]:          0 :     RefEdge* edge = dynamic_cast<RefEdge*>(owner->topology_entity());
    1449 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Cannot restore vertex hidden by curve %d without unmerging "
         [ #  # ][ #  # ]
                 [ #  # ]
    1450                 :            :                 "curve and possibly adjacent surfaces.  Use the 'force' "
    1451         [ #  # ]:          0 :                 "option to force unmerging of geometry.\n", edge ? edge->id() : 0);
    1452                 :          0 :     return CUBIT_FAILURE;
    1453                 :            :   }
    1454                 :            :   
    1455         [ #  # ]:          0 :   points.last();
    1456 [ #  # ][ #  # ]:          0 :   for ( i = points.size(); i--; )
    1457                 :            :   {
    1458         [ #  # ]:          0 :     TBPoint* pt = points.step_and_get();
    1459 [ #  # ][ #  # ]:          0 :     if (CompositePoint* cp = dynamic_cast<CompositePoint*>(pt))
    1460         [ #  # ]:          0 :       pt = cp->get_point();
    1461                 :            :     
    1462 [ #  # ][ #  # ]:          0 :     if (!CompositeEngine::instance().restore_point(pt))
                 [ #  # ]
    1463         [ #  # ]:          0 :       points.change_to(0);
    1464 [ #  # ][ #  # ]:          0 :     else if (CompositePoint* cp = dynamic_cast<CompositePoint*>(pt->owner()))
                 [ #  # ]
    1465         [ #  # ]:          0 :       points.change_to(cp);
    1466                 :            :     else
    1467         [ #  # ]:          0 :       points.change_to(pt);
    1468                 :            :   }
    1469         [ #  # ]:          0 :   points.remove_all_with_value(0);
    1470                 :            :   
    1471 [ #  # ][ #  # ]:          0 :   if (!points.size())
    1472                 :          0 :     return CUBIT_FAILURE;
    1473                 :            :   
    1474         [ #  # ]:          0 :   points.reset();
    1475 [ #  # ][ #  # ]:          0 :   RefVertex* new_vtx = gqt->make_RefVertex(points.get());
    1476 [ #  # ][ #  # ]:          0 :   for ( i = points.size(); i--; )
    1477                 :            :   {
    1478         [ #  # ]:          0 :     TBPoint* pt = points.get_and_step();
    1479 [ #  # ][ #  # ]:          0 :     if (pt->owner())
    1480 [ #  # ][ #  # ]:          0 :       assert(pt->topology_entity() == new_vtx);
    1481                 :            :     else
    1482 [ #  # ][ #  # ]:          0 :       new_vtx->bridge_manager()->add_bridge(pt);
    1483                 :            :   }
    1484                 :            :           
    1485 [ #  # ][ #  # ]:          0 :   CubitVector center_1, center_2;
    1486 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> pt_curves(2);
    1487         [ #  # ]:          0 :   points.reset();
    1488 [ #  # ][ #  # ]:          0 :   points.get()->get_parents(pt_curves);
    1489                 :            :   
    1490                 :            :     // Ignore composite point-curves.  They are transient and will be
    1491                 :            :     // deleted later.  Don't try to create RefEdges for them now.
    1492 [ #  # ][ #  # ]:          0 :   if (pt_curves.size() != 2)
    1493                 :            :   {
    1494                 :            : #ifndef NDEBUG
    1495 [ #  # ][ #  # ]:          0 :     assert(pt_curves.size() == 1);
    1496 [ #  # ][ #  # ]:          0 :     CompositeCurve* ccurve = dynamic_cast<CompositeCurve*>(pt_curves.get());
    1497 [ #  # ][ #  # ]:          0 :     assert(ccurve->num_curves() == 0 && ccurve->geometry_type() == POINT_CURVE_TYPE );
         [ #  # ][ #  # ]
    1498                 :            : #endif
    1499                 :          0 :     return CUBIT_SUCCESS;
    1500                 :            :   }
    1501                 :            :   
    1502 [ #  # ][ #  # ]:          0 :   dynamic_cast<Curve*>(pt_curves.get())->position_from_fraction(0.5, center_1);
                 [ #  # ]
    1503 [ #  # ][ #  # ]:          0 :   dynamic_cast<Curve*>(pt_curves.next())->position_from_fraction(0.5, center_2);
                 [ #  # ]
    1504                 :            :   
    1505 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> new_edge_1_curves(points.size()), 
                 [ #  # ]
    1506 [ #  # ][ #  # ]:          0 :                   new_edge_2_curves(points.size());
                 [ #  # ]
    1507                 :            :   
    1508         [ #  # ]:          0 :   points.reset();
    1509 [ #  # ][ #  # ]:          0 :   for ( i = points.size(); i--; )
    1510                 :            :   {
    1511         [ #  # ]:          0 :     pt_curves.clean_out();
    1512 [ #  # ][ #  # ]:          0 :     points.get_and_step()->get_parents(pt_curves);
    1513 [ #  # ][ #  # ]:          0 :     assert(pt_curves.size() == 2);
    1514 [ #  # ][ #  # ]:          0 :     Curve* curve_1 = dynamic_cast<Curve*>(pt_curves.get());
    1515 [ #  # ][ #  # ]:          0 :     Curve* curve_2 = dynamic_cast<Curve*>(pt_curves.next());
    1516 [ #  # ][ #  # ]:          0 :     CubitVector ptc1, ptc2;
    1517         [ #  # ]:          0 :     curve_1->position_from_fraction( 0.5, ptc1 );
    1518         [ #  # ]:          0 :     curve_2->position_from_fraction( 0.5, ptc2 );
    1519 [ #  # ][ #  # ]:          0 :     bool close1 = (center_1 - ptc1).length_squared() < (center_2 - ptc1).length_squared();
         [ #  # ][ #  # ]
    1520 [ #  # ][ #  # ]:          0 :     bool close2 = (center_1 - ptc2).length_squared() < (center_2 - ptc2).length_squared();
         [ #  # ][ #  # ]
    1521 [ #  # ][ #  # ]:          0 :     if (close1 && !close2)
    1522                 :            :     {
    1523         [ #  # ]:          0 :       new_edge_1_curves.append(curve_1);
    1524         [ #  # ]:          0 :       new_edge_2_curves.append(curve_2);
    1525                 :            :     }
    1526 [ #  # ][ #  # ]:          0 :     else if (!close1 && close2)
    1527                 :            :     {
    1528         [ #  # ]:          0 :       new_edge_2_curves.append(curve_1);
    1529         [ #  # ]:          0 :       new_edge_1_curves.append(curve_2);
    1530                 :            :     }
    1531                 :            :     else
    1532                 :            :     {
    1533         [ #  # ]:          0 :       assert(close1 != close2);
    1534                 :            :     }
    1535                 :            :   }
    1536                 :            : 
    1537         [ #  # ]:          0 :   for ( i = 0; i < 2; i++ )
    1538                 :            :   {
    1539                 :            :     int j;
    1540         [ #  # ]:          0 :     DLIList<Curve*>& new_edge_curves = i ? new_edge_2_curves : new_edge_1_curves;
    1541         [ #  # ]:          0 :     DLIList<Curve*>& otr_edge_curves = i ? new_edge_1_curves : new_edge_2_curves;
    1542                 :          0 :     RefEdge* new_edge = 0;
    1543         [ #  # ]:          0 :     new_edge_curves.reset();
    1544 [ #  # ][ #  # ]:          0 :     for (j = new_edge_curves.size(); j--; )
    1545                 :            :     {
    1546         [ #  # ]:          0 :       Curve* curve = new_edge_curves.get_and_step();
    1547 [ #  # ][ #  # ]:          0 :       if (curve->owner())
    1548                 :            :       {
    1549 [ #  # ][ #  # ]:          0 :         RefEdge* edge = dynamic_cast<RefEdge*>(curve->topology_entity());
    1550         [ #  # ]:          0 :         assert(!!edge);
    1551 [ #  # ][ #  # ]:          0 :         if (!otr_edge_curves.is_in_list(edge->get_curve_ptr()))
                 [ #  # ]
    1552                 :          0 :           new_edge = edge;
    1553                 :            :       }
    1554                 :            :     }
    1555         [ #  # ]:          0 :     if (!new_edge)
    1556                 :            :     {
    1557         [ #  # ]:          0 :       Curve* curve = new_edge_curves.get();
    1558 [ #  # ][ #  # ]:          0 :       if (curve->owner())
    1559 [ #  # ][ #  # ]:          0 :         curve->owner()->remove_bridge(curve);
    1560         [ #  # ]:          0 :       new_edge = gqt->make_RefEdge(curve);
    1561                 :            :     }
    1562                 :            :   
    1563         [ #  # ]:          0 :     Curve* first = new_edge->get_curve_ptr();
    1564 [ #  # ][ #  # ]:          0 :     for (j = new_edge_curves.size(); j--; )
    1565                 :            :     {
    1566         [ #  # ]:          0 :       Curve* curve = new_edge_curves.get_and_step();
    1567 [ #  # ][ #  # ]:          0 :       if (curve->owner())
    1568                 :            :       {
    1569 [ #  # ][ #  # ]:          0 :         if (curve->topology_entity() == new_edge)
    1570                 :          0 :           continue;
    1571                 :            :         else
    1572 [ #  # ][ #  # ]:          0 :           curve->owner()->remove_bridge(curve);
    1573                 :            :       }
    1574                 :            :       
    1575         [ #  # ]:          0 :       bool reversed = first->relative_sense(curve) == CUBIT_REVERSED;
    1576 [ #  # ][ #  # ]:          0 :       bool saved = first->bridge_sense() == curve->bridge_sense();
    1577         [ #  # ]:          0 :       if (reversed == saved)
    1578         [ #  # ]:          0 :         curve->reverse_bridge_sense();
    1579 [ #  # ][ #  # ]:          0 :       new_edge->bridge_manager()->add_bridge(curve);
    1580                 :            :     }
    1581                 :            :   }
    1582                 :            :   
    1583         [ #  # ]:          0 :   if (old_edge)
    1584                 :            :   {
    1585         [ #  # ]:          0 :     DLIList<RefFace*> face_list;
    1586         [ #  # ]:          0 :     old_edge->ref_faces(face_list);
    1587 [ #  # ][ #  # ]:          0 :     modified += face_list;
    1588                 :            :   }
    1589         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    1590                 :            : }
    1591                 :            :   
    1592                 :            :   
    1593                 :            :   
    1594                 :            :   
    1595                 :            : 
    1596                 :            :   
    1597                 :            : 
    1598                 :            : 
    1599                 :            : //-------------------------------------------------------------------------
    1600                 :            : // Purpose       : remove a composite face, restoring the orignial faces.
    1601                 :            : //
    1602                 :            : // Special Notes : 
    1603                 :            : //
    1604                 :            : // Creator       : Jason Kraftcheck
    1605                 :            : //
    1606                 :            : // Creation Date : 
    1607                 :            : //-------------------------------------------------------------------------
    1608                 :          0 : CubitStatus CompositeTool::uncomposite( RefFace* composite_face,
    1609                 :            :                                         DLIList<RefFace*>* restored_faces,
    1610                 :            :                                         bool force_unmerge )
    1611                 :            : {
    1612                 :            :   int i;
    1613         [ #  # ]:          0 :   DLIList<Curve*> hidden_curves;
    1614 [ #  # ][ #  # ]:          0 :   DLIList<RefVolume*> vol_list;
    1615 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list;
    1616                 :            :   
    1617         [ #  # ]:          0 :   composite_face->ref_volumes( vol_list );
    1618                 :            :   
    1619 [ #  # ][ #  # ]:          0 :   if( composite_face->bridge_manager()->number_of_bridges() != 1 )
                 [ #  # ]
    1620                 :            :   {
    1621 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Surface %d is a merged curve.  Unmerge before removing composite.\n",
         [ #  # ][ #  # ]
    1622         [ #  # ]:          0 :       composite_face->id() );
    1623                 :          0 :     return CUBIT_FAILURE;
    1624                 :            :   }
    1625                 :            :   
    1626 [ #  # ][ #  # ]:          0 :   CompositeSurface* surf_ptr = dynamic_cast<CompositeSurface*>(composite_face->get_surface_ptr());
    1627         [ #  # ]:          0 :   if( !surf_ptr )
    1628                 :          0 :     return CUBIT_FAILURE;
    1629                 :            : 
    1630                 :            :   //remove all names off this ref entity
    1631         [ #  # ]:          0 :   composite_face->remove_entity_names();
    1632                 :            :   
    1633 [ #  # ][ #  # ]:          0 :   for( i = 0; i < surf_ptr->num_surfs(); i++ )
    1634 [ #  # ][ #  # ]:          0 :     surface_list.append( surf_ptr->get_surface(i) );
    1635                 :            :   
    1636         [ #  # ]:          0 :   surf_ptr->get_hidden_curves( hidden_curves );
    1637                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
    1638         [ #  # ]:          0 :   hidden_curves.reset();
    1639 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> points(2);
    1640 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> modified_faces;
    1641 [ #  # ][ #  # ]:          0 :   for( i = hidden_curves.size(); i--; )
    1642                 :            :   {
    1643                 :            :     //remove attributes off the hidden curves 
    1644 [ #  # ][ #  # ]:          0 :     CompositeEngine::strip_attributes( hidden_curves.get() );
    1645                 :            : 
    1646         [ #  # ]:          0 :     Curve* curve = hidden_curves.get_and_step();
    1647                 :            : 
    1648 [ #  # ][ #  # ]:          0 :     if(DEBUG_FLAG(87))
                 [ #  # ]
    1649                 :            :     {
    1650         [ #  # ]:          0 :       GMem gmem;
    1651 [ #  # ][ #  # ]:          0 :       curve->get_geometry_query_engine()->get_graphics(curve,&gmem);
    1652 [ #  # ][ #  # ]:          0 :       GfxDebug::draw_polyline(gmem.point_list(),gmem.pointListCount,CUBIT_RED_INDEX);
    1653 [ #  # ][ #  # ]:          0 :       GfxDebug::flush();
    1654                 :            :     }
    1655                 :            : 
    1656         [ #  # ]:          0 :     curve->get_children(points, true);
    1657 [ #  # ][ #  # ]:          0 :     while (points.size())
    1658                 :            :     {
    1659 [ #  # ][ #  # ]:          0 :       TBPoint* pt = dynamic_cast<TBPoint*>(points.pop());
    1660                 :            : 
    1661                 :            :       //remove attributes off the underlying points 
    1662         [ #  # ]:          0 :       CompositeEngine::strip_attributes( pt ); 
    1663                 :            : 
    1664 [ #  # ][ #  # ]:          0 :       HiddenEntitySet* hs = dynamic_cast<HiddenEntitySet*>(pt->owner());
    1665 [ #  # ][ #  # ]:          0 :       if (hs && dynamic_cast<CompositeCurve*>(hs->owner()))
         [ #  # ][ #  # ]
                 [ #  # ]
    1666                 :            :       {
    1667 [ #  # ][ #  # ]:          0 :         if (!restore_merged_point(pt, modified_faces, force_unmerge))
    1668                 :            :         {
    1669 [ #  # ][ #  # ]:          0 :           PRINT_ERROR("Failed to restore hidden vertex.\n");
         [ #  # ][ #  # ]
    1670                 :          0 :           result = CUBIT_FAILURE;
    1671                 :          0 :           break;
    1672                 :            :         }
    1673                 :            :       }
    1674                 :            :     }
    1675                 :            :     
    1676         [ #  # ]:          0 :     if (!result)
    1677                 :          0 :       break;
    1678                 :            :     
    1679 [ #  # ][ #  # ]:          0 :     if( ! CompositeEngine::instance().restore_curve( curve ) )
                 [ #  # ]
    1680                 :          0 :       result = CUBIT_FAILURE;
    1681                 :            :   }
    1682                 :            :   
    1683 [ #  # ][ #  # ]:          0 :   if (modified_faces.size())
    1684                 :            :   {
    1685 [ #  # ][ #  # ]:          0 :     DLIList<TopologyEntity*> query_input(modified_faces.size());
    1686 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(modified_faces, query_input);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1687 [ #  # ][ #  # ]:          0 :     DLIList<TopologyEntity*> query_output;
    1688                 :            :     ModelQueryEngine::instance()->
    1689 [ #  # ][ #  # ]:          0 :       query_model(query_input,DagType::ref_volume_type(),query_output);
                 [ #  # ]
    1690 [ #  # ][ #  # ]:          0 :     while(query_output.size())
    1691 [ #  # ][ #  # ]:          0 :       vol_list.append_unique(dynamic_cast<RefVolume*>(query_output.pop()));
         [ #  # ][ #  # ]
    1692                 :            :   }
    1693                 :            :                                  
    1694                 :            :   
    1695 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list;
    1696 [ #  # ][ #  # ]:          0 :   composite_face->bridge_manager()->get_bridge_list(bridge_list);
    1697                 :          0 :   int smallest_id = 0;
    1698 [ #  # ][ #  # ]:          0 :   for ( i = bridge_list.size(); i--; )
    1699                 :            :   {
    1700 [ #  # ][ #  # ]:          0 :     GeometryEntity* geom_ptr = dynamic_cast<GeometryEntity*>(bridge_list.get_and_step());
    1701         [ #  # ]:          0 :     int saved_id = geom_ptr->get_saved_id();
    1702 [ #  # ][ #  # ]:          0 :     if ( saved_id && (!smallest_id || saved_id < smallest_id) &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1703 [ #  # ][ #  # ]:          0 :          !RefEntityFactory::instance()->get_ref_face(saved_id) )
    1704                 :          0 :       smallest_id = saved_id;
    1705                 :            :   }
    1706 [ #  # ][ #  # ]:          0 :   if ( smallest_id && composite_face->id() != smallest_id )
         [ #  # ][ #  # ]
    1707         [ #  # ]:          0 :     composite_face->set_id( smallest_id );
    1708                 :            :   
    1709 [ #  # ][ #  # ]:          0 :   for( i = vol_list.size(); i--; )
    1710                 :            :   {
    1711                 :            :     Lump* lump= dynamic_cast<Lump*>(
    1712 [ #  # ][ #  # ]:          0 :       vol_list.get_and_step()->bridge_manager()->topology_bridge() );
         [ #  # ][ #  # ]
    1713 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->make_Body( lump->bodysm() );
                 [ #  # ]
    1714                 :            :   }
    1715 [ #  # ][ #  # ]:          0 :   for( i = vol_list.size(); i--; )
    1716 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->destroy_dead_entity( vol_list.get_and_step() );
                 [ #  # ]
    1717                 :            :   
    1718 [ #  # ][ #  # ]:          0 :   for( i = surface_list.size(); i--; )
    1719                 :            :   {
    1720         [ #  # ]:          0 :     Surface *tmp_surf = surface_list.get_and_step();
    1721                 :            :     //remove attributes off the surfaces 
    1722         [ #  # ]:          0 :     CompositeEngine::strip_attributes( tmp_surf ); 
    1723                 :            : 
    1724 [ #  # ][ #  # ]:          0 :     BridgeManager* bm = dynamic_cast<BridgeManager*>(tmp_surf->owner());
    1725 [ #  # ][ #  # ]:          0 :     RefFace* face = bm ? dynamic_cast<RefFace*>(bm->topology_entity()) : 0;
                 [ #  # ]
    1726         [ #  # ]:          0 :     if( restored_faces )
    1727         [ #  # ]:          0 :       restored_faces->append( face );
    1728         [ #  # ]:          0 :     std::vector<CubitString> underlying_names;
    1729         [ #  # ]:          0 :     tmp_surf->get_saved_names( underlying_names );
    1730 [ #  # ][ #  # ]:          0 :     for (size_t k = 0; k < underlying_names.size(); k++)
    1731 [ #  # ][ #  # ]:          0 :       face->entity_name( underlying_names[k] );
         [ #  # ][ #  # ]
    1732         [ #  # ]:          0 :   }
    1733                 :            :   
    1734         [ #  # ]:          0 :   return result;
    1735                 :            : }
    1736                 :            : 
    1737                 :            : 
    1738                 :            : //-------------------------------------------------------------------------
    1739                 :            : // Purpose       : Remove a composite volume
    1740                 :            : //
    1741                 :            : // Special Notes : 
    1742                 :            : //
    1743                 :            : // Creator       : Jason Kraftcheck
    1744                 :            : //
    1745                 :            : // Creation Date : 09/25/01
    1746                 :            : //-------------------------------------------------------------------------
    1747                 :          0 : CubitStatus CompositeTool::uncomposite( RefVolume* composite_vol,
    1748                 :            :                                         DLIList<RefVolume*>* restored_vols )
    1749                 :            : {
    1750                 :            :   int i;
    1751         [ #  # ]:          0 :   DLIList<Surface*> hidden_surfs;
    1752 [ #  # ][ #  # ]:          0 :   DLIList<Body*> body_list;
    1753 [ #  # ][ #  # ]:          0 :   DLIList<Lump*> lump_list;
    1754                 :            :   
    1755         [ #  # ]:          0 :   composite_vol->bodies( body_list );
    1756                 :            :   
    1757 [ #  # ][ #  # ]:          0 :   CompositeLump* lump_ptr = dynamic_cast<CompositeLump*>(composite_vol->get_lump_ptr());
    1758         [ #  # ]:          0 :   if( !lump_ptr )
    1759                 :          0 :     return CUBIT_FAILURE;
    1760                 :            :   
    1761 [ #  # ][ #  # ]:          0 :   for( i = 0; i < lump_ptr->num_lumps(); i++ )
    1762 [ #  # ][ #  # ]:          0 :     lump_list.append( lump_ptr->get_lump(i) );
    1763                 :            :   
    1764         [ #  # ]:          0 :   lump_ptr->get_hidden_surfaces( hidden_surfs );
    1765                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
    1766         [ #  # ]:          0 :   hidden_surfs.reverse();
    1767 [ #  # ][ #  # ]:          0 :   while( hidden_surfs.size() )
    1768                 :            :   {
    1769         [ #  # ]:          0 :     Surface* surf = hidden_surfs.pop();
    1770                 :          0 :     Surface* stitch = 0;
    1771 [ #  # ][ #  # ]:          0 :     if( ! CompositeEngine::instance().restore_surface( surf, stitch ) )
                 [ #  # ]
    1772                 :          0 :       result = CUBIT_FAILURE;
    1773         [ #  # ]:          0 :     if (stitch)
    1774         [ #  # ]:          0 :       hidden_surfs.remove( stitch );
    1775                 :            :   }
    1776                 :            :   
    1777 [ #  # ][ #  # ]:          0 :   int saved_id = composite_vol->get_lump_ptr()->get_saved_id();
    1778 [ #  # ][ #  # ]:          0 :   if (saved_id && saved_id < composite_vol->id() &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1779 [ #  # ][ #  # ]:          0 :       !RefEntityFactory::instance()->get_ref_volume(saved_id))
    1780         [ #  # ]:          0 :     composite_vol->set_id( saved_id );
    1781                 :            :   
    1782 [ #  # ][ #  # ]:          0 :   for( i = body_list.size(); i--; )
    1783 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->make_Body( body_list.get_and_step()->get_body_sm_ptr() );
         [ #  # ][ #  # ]
    1784 [ #  # ][ #  # ]:          0 :   for( i = body_list.size(); i--; )
    1785 [ #  # ][ #  # ]:          0 :     GeometryQueryTool::instance()->destroy_dead_entity( body_list.get_and_step() );
                 [ #  # ]
    1786                 :            :   
    1787         [ #  # ]:          0 :   if( restored_vols )
    1788                 :            :   {
    1789 [ #  # ][ #  # ]:          0 :     for( i = lump_list.size(); i--; )
    1790                 :            :     {
    1791 [ #  # ][ #  # ]:          0 :       TBOwner* owner = lump_list.get_and_step()->owner();
    1792 [ #  # ][ #  # ]:          0 :       if (BridgeManager* bm = dynamic_cast<BridgeManager*>(owner))
    1793 [ #  # ][ #  # ]:          0 :         restored_vols->append( dynamic_cast<RefVolume*>(bm->topology_entity()) );
                 [ #  # ]
    1794 [ #  # ][ #  # ]:          0 :       else if (CompositeLump* lump = dynamic_cast<CompositeLump*>(owner))
    1795 [ #  # ][ #  # ]:          0 :         restored_vols->append_unique( dynamic_cast<RefVolume*>(lump->topology_entity() ) );
                 [ #  # ]
    1796                 :            :     }
    1797                 :            :   }
    1798                 :            :   
    1799         [ #  # ]:          0 :   return result;
    1800                 :            : }
    1801                 :            : 
    1802                 :            : //-------------------------------------------------------------------------
    1803                 :            : // Purpose       : Remove composite body
    1804                 :            : //
    1805                 :            : // Special Notes : 
    1806                 :            : //
    1807                 :            : // Creator       : Jason Kraftcheck
    1808                 :            : //
    1809                 :            : // Creation Date : 10/02/01
    1810                 :            : //-------------------------------------------------------------------------
    1811                 :          0 : CubitStatus CompositeTool::uncomposite( Body* , 
    1812                 :            :                                         DLIList<Body*>* )
    1813                 :            : {
    1814                 :          0 :   return CUBIT_FAILURE;
    1815                 :            : }
    1816                 :            : 
    1817                 :            : 
    1818                 :            : 
    1819                 :            : 
    1820                 :            : //-------------------------------------------------------------------------
    1821                 :            : // Purpose       : Create multiple composite curves
    1822                 :            : //
    1823                 :            : // Special Notes : 
    1824                 :            : //
    1825                 :            : // Creator       : Jason Kraftcheck
    1826                 :            : //
    1827                 :            : // Creation Date : 12/03/99
    1828                 :            : //-------------------------------------------------------------------------
    1829                 :          0 : CubitStatus CompositeTool::composite( DLIList<RefEdge*>& edges, 
    1830                 :            :                                       DLIList<RefEdge*>& new_edge_list,
    1831                 :            :                                       DLIList<RefVertex*>* vertices_to_keep, 
    1832                 :            :                                       double max_curve_angle /*radians*/ )
    1833                 :            : {
    1834         [ #  # ]:          0 :   new_edge_list.clean_out();
    1835                 :          0 :   double min_cos_angle = cos( max_curve_angle );
    1836                 :            :   int i;
    1837                 :            :   
    1838                 :            :   //check for duplicates
    1839         [ #  # ]:          0 :   DLIList<RefEdge*> edges_to_composite;
    1840 [ #  # ][ #  # ]:          0 :   for( i = edges.size(); i > 0; i-- )
    1841                 :            :   {
    1842         [ #  # ]:          0 :     RefEdge* edge_ptr = edges.get_and_step();
    1843 [ #  # ][ #  # ]:          0 :     if( ! edges_to_composite.append_unique( edge_ptr ) )
    1844                 :            :     {
    1845 [ #  # ][ #  # ]:          0 :       PRINT_WARNING("Duplicate curve %d in list of curves to composite.\n",
         [ #  # ][ #  # ]
    1846         [ #  # ]:          0 :         edge_ptr->id());
    1847                 :            :     }
    1848                 :            :   }
    1849                 :            :   
    1850                 :            :   
    1851 [ #  # ][ #  # ]:          0 :   if( edges_to_composite.size() < 2 ) return CUBIT_SUCCESS;
    1852                 :            :   
    1853         [ #  # ]:          0 :   fast_edge_sort( edges_to_composite, true );
    1854                 :            :   
    1855                 :            :   //look for a place to start (a point that we cannot 
    1856                 :            :   //composite across.)
    1857                 :            : 
    1858                 :            :   RefVertex *vtx_ptr;
    1859                 :            :   RefEdge* first_edge;
    1860 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> vertex_edges;
    1861                 :            : 
    1862         [ #  # ]:          0 :   edges_to_composite.last();
    1863         [ #  # ]:          0 :   RefEdge* prev_edge = edges_to_composite.get();
    1864         [ #  # ]:          0 :   edges_to_composite.reset();
    1865                 :            :   
    1866 [ #  # ][ #  # ]:          0 :   for( i = edges_to_composite.size(); i >= 0; i-- )
    1867                 :            :   {
    1868         [ #  # ]:          0 :     first_edge = edges_to_composite.get_and_step();
    1869         [ #  # ]:          0 :     vtx_ptr = first_edge->common_ref_vertex( prev_edge );
    1870         [ #  # ]:          0 :     if( ! vtx_ptr ) break;
    1871                 :            :     
    1872         [ #  # ]:          0 :     vertex_edges.clean_out();
    1873         [ #  # ]:          0 :     vtx_ptr->ref_edges( vertex_edges );
    1874         [ #  # ]:          0 :     vertex_edges.remove( first_edge );
    1875         [ #  # ]:          0 :     vertex_edges.remove( prev_edge );
    1876 [ #  # ][ #  # ]:          0 :     if( vertex_edges.size() > 0 ) break;
    1877                 :            :     
    1878                 :          0 :     prev_edge = first_edge;
    1879                 :            :   }
    1880                 :            :   
    1881         [ #  # ]:          0 :   if( i < 0 ) //if all the edges get composited into one
    1882                 :            :   {
    1883         [ #  # ]:          0 :     edges_to_composite.reset();
    1884         [ #  # ]:          0 :     first_edge = edges_to_composite.get();
    1885                 :            :   }
    1886                 :            :     
    1887                 :            :   //composite chains of consecutive edges
    1888                 :            :   
    1889         [ #  # ]:          0 :   edges_to_composite.move_to( first_edge );
    1890 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> edge_list, sublist;
         [ #  # ][ #  # ]
    1891         [ #  # ]:          0 :   int edge_count = edges_to_composite.size();
    1892         [ #  # ]:          0 :   while( edge_count > 0 )
    1893                 :            :   {
    1894         [ #  # ]:          0 :     edge_list.clean_out();
    1895         [ #  # ]:          0 :     RefEdge* edge_ptr = edges_to_composite.get_and_step();
    1896         [ #  # ]:          0 :     edge_list.append( edge_ptr );
    1897                 :          0 :     edge_count--;
    1898                 :            :     
    1899                 :            :     //Find a chain of connected edges that can form a 
    1900                 :            :     //topologically valid composite.
    1901                 :            :     
    1902         [ #  # ]:          0 :     while( edge_count > 0 )
    1903                 :            :     {
    1904         [ #  # ]:          0 :       RefEdge* next_edge = edges_to_composite.get();
    1905         [ #  # ]:          0 :       vtx_ptr = edge_ptr->common_ref_vertex( next_edge );
    1906         [ #  # ]:          0 :       if( ! vtx_ptr ) break;
    1907                 :            :       
    1908         [ #  # ]:          0 :       vertex_edges.clean_out();
    1909         [ #  # ]:          0 :       vtx_ptr->ref_edges( vertex_edges );
    1910         [ #  # ]:          0 :       vertex_edges.remove( edge_ptr );
    1911         [ #  # ]:          0 :       vertex_edges.remove( next_edge );
    1912 [ #  # ][ #  # ]:          0 :       if( vertex_edges.size() > 0 ) break;
    1913                 :            :       
    1914                 :          0 :       edge_ptr = next_edge;
    1915         [ #  # ]:          0 :       edges_to_composite.step();
    1916         [ #  # ]:          0 :       edge_list.append( edge_ptr );
    1917                 :          0 :       edge_count--;
    1918                 :            :     }
    1919                 :            :       
    1920 [ #  # ][ #  # ]:          0 :     if( edge_list.size() == 1 ) continue;
    1921 [ #  # ][ #  # ]:          0 :     assert( edge_list.size() );
    1922                 :            :     
    1923                 :            :     //Now split that chain of edges further based on
    1924                 :            :     //user-specified constraints (vertices and/or angle.)
    1925                 :            :     //This is done seperatly from the above loop to handle
    1926                 :            :     //cases where the edge_list forms a closed loop, and the
    1927                 :            :     //user specified one position on that loop to keep.
    1928                 :            :     
    1929                 :            :     //Find a start point in the chain.
    1930         [ #  # ]:          0 :     edge_list.last();
    1931         [ #  # ]:          0 :     edge_ptr = edge_list.get();
    1932         [ #  # ]:          0 :     edge_list.reset();
    1933                 :          0 :     RefVertex* keep_vertex = 0;
    1934 [ #  # ][ #  # ]:          0 :     if( edge_ptr->common_ref_vertex( edge_list.get() ) )
                 [ #  # ]
    1935                 :            :     //if we have a closed loop
    1936                 :            :     {
    1937         [ #  # ]:          0 :       edge_ptr = edge_list.get_and_step();
    1938 [ #  # ][ #  # ]:          0 :       for( i = edge_list.size(); i > 0; i-- )
    1939                 :            :       {
    1940         [ #  # ]:          0 :         RefEdge* next_edge = edge_list.get();
    1941         [ #  # ]:          0 :         vtx_ptr = edge_ptr->common_ref_vertex( next_edge );
    1942         [ #  # ]:          0 :         assert( vtx_ptr != 0 );
    1943                 :            :         
    1944 [ #  # ][ #  # ]:          0 :         if( vertices_to_keep && vertices_to_keep->is_in_list( vtx_ptr ) )
         [ #  # ][ #  # ]
    1945                 :            :         {
    1946                 :          0 :           keep_vertex = vtx_ptr;
    1947                 :          0 :           break;
    1948                 :            :         }
    1949 [ #  # ][ #  # ]:          0 :         CubitVector cur_tan = tangent( edge_ptr, vtx_ptr ) * -1.0;
    1950         [ #  # ]:          0 :         CubitVector next_tan = tangent( next_edge, vtx_ptr );
    1951         [ #  # ]:          0 :         double cos_angle = (cur_tan % next_tan) / 
    1952 [ #  # ][ #  # ]:          0 :                        (cur_tan.length() * next_tan.length());
    1953         [ #  # ]:          0 :         if( cos_angle < min_cos_angle )
    1954                 :            :         {
    1955                 :          0 :           keep_vertex = vtx_ptr;
    1956                 :          0 :           break;
    1957                 :            :         }
    1958                 :            :         
    1959                 :          0 :         edge_ptr = next_edge;
    1960         [ #  # ]:          0 :         edge_list.step();
    1961                 :            :       }
    1962                 :            :     }
    1963                 :            :     
    1964                 :            :     //If we didn't find any split locations, that's okay.
    1965                 :            :     //We'll let the compositing code choose which vertex to keep.
    1966                 :            :     
    1967         [ #  # ]:          0 :     int subcount = edge_list.size();
    1968         [ #  # ]:          0 :     while( subcount > 0 )
    1969                 :            :     {
    1970         [ #  # ]:          0 :       sublist.clean_out();
    1971         [ #  # ]:          0 :       edge_ptr = edge_list.get_and_step();
    1972                 :          0 :       subcount--;
    1973         [ #  # ]:          0 :       sublist.append( edge_ptr );
    1974                 :            :       
    1975         [ #  # ]:          0 :       while( subcount > 0 )
    1976                 :            :       {
    1977         [ #  # ]:          0 :         RefEdge* next_edge = edge_list.get();
    1978         [ #  # ]:          0 :         vtx_ptr = edge_ptr->common_ref_vertex( next_edge );
    1979         [ #  # ]:          0 :         assert( vtx_ptr != 0 );
    1980                 :            :         
    1981 [ #  # ][ #  # ]:          0 :         if( vertices_to_keep && vertices_to_keep->is_in_list( vtx_ptr ) )
         [ #  # ][ #  # ]
    1982                 :            :         {
    1983                 :          0 :           keep_vertex = vtx_ptr;
    1984                 :          0 :           break;
    1985                 :            :         }
    1986 [ #  # ][ #  # ]:          0 :         CubitVector cur_tan = tangent( edge_ptr, vtx_ptr ) * -1.0;
    1987         [ #  # ]:          0 :         CubitVector next_tan = tangent( next_edge, vtx_ptr );
    1988         [ #  # ]:          0 :         double cos_angle = (cur_tan % next_tan) / 
    1989 [ #  # ][ #  # ]:          0 :                         (cur_tan.length() * next_tan.length());
    1990         [ #  # ]:          0 :         if( cos_angle < min_cos_angle )
    1991                 :            :         {
    1992                 :          0 :           keep_vertex = vtx_ptr;
    1993                 :          0 :           break;
    1994                 :            :         }
    1995                 :            :         
    1996                 :          0 :         edge_ptr = next_edge;
    1997         [ #  # ]:          0 :         edge_list.step();
    1998                 :          0 :         subcount--;
    1999         [ #  # ]:          0 :         sublist.append( edge_ptr );
    2000                 :            :       }
    2001                 :            :       
    2002                 :            :     
    2003 [ #  # ][ #  # ]:          0 :       if( sublist.size() > 1 )
    2004                 :            :       {
    2005         [ #  # ]:          0 :         edge_ptr = composite( sublist, keep_vertex );
    2006         [ #  # ]:          0 :         if( ! edge_ptr ) return CUBIT_FAILURE;
    2007         [ #  # ]:          0 :         new_edge_list.append( edge_ptr );
    2008                 :            :       }
    2009                 :            :     }
    2010                 :            :   }
    2011                 :            :   
    2012         [ #  # ]:          0 :   return CUBIT_SUCCESS;
    2013                 :            : }
    2014                 :            : 
    2015                 :            : //-------------------------------------------------------------------------
    2016                 :            : // Purpose       : Get the tangent along an edge away from a vertex.
    2017                 :            : //
    2018                 :            : // Special Notes : 
    2019                 :            : //
    2020                 :            : // Creator       : Jason Kraftcheck
    2021                 :            : //
    2022                 :            : // Creation Date : 12/03/99
    2023                 :            : //-------------------------------------------------------------------------
    2024                 :          0 : CubitVector CompositeTool::tangent( RefEdge* edge_ptr, RefVertex* vtx_ptr ) const
    2025                 :            : {
    2026                 :          0 :   CubitVector result;
    2027         [ #  # ]:          0 :   edge_ptr->tangent( vtx_ptr->coordinates(), result );
    2028         [ #  # ]:          0 :   if( vtx_ptr == edge_ptr->end_vertex() )
    2029                 :          0 :     result *= -1;
    2030                 :          0 :   return result;
    2031                 :            : } 
    2032                 :            : 
    2033                 :            : //-------------------------------------------------------------------------
    2034                 :            : // Purpose       : Sort edges topologically.  
    2035                 :            : //
    2036                 :            : // Special Notes : Not safe with secondary links
    2037                 :            : //
    2038                 :            : // Creator       : Jason Kraftcheck
    2039                 :            : //
    2040                 :            : // Creation Date : 12/03/99
    2041                 :            : //-------------------------------------------------------------------------
    2042                 :          0 : CubitStatus CompositeTool::fast_edge_sort( DLIList<RefEdge*>& edge_list,
    2043                 :            :                                            bool valence2_vertices ) const
    2044                 :            : {
    2045                 :            :   int i;
    2046 [ #  # ][ #  # ]:          0 :   if( edge_list.size() < 2 ) return CUBIT_SUCCESS;
    2047                 :            :   
    2048                 :            :   //make sure all RefEdges are initially marked as zero.
    2049 [ #  # ][ #  # ]:          0 :   DLIList<RefVertex*> vtx_list(2), all_vertices(edge_list.size() * 2);
         [ #  # ][ #  # ]
    2050 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> vertex_edges;
    2051                 :            :   RefEdge* edge_ptr;
    2052                 :            :   RefVertex* vtx_ptr;
    2053 [ #  # ][ #  # ]:          0 :   for( i = edge_list.size(); i > 0; i-- )
    2054                 :            :   {
    2055         [ #  # ]:          0 :     edge_ptr = edge_list.get_and_step();
    2056         [ #  # ]:          0 :     vtx_list.clean_out();
    2057         [ #  # ]:          0 :     edge_ptr->ref_vertices( vtx_list );
    2058 [ #  # ][ #  # ]:          0 :     for( int j = vtx_list.size(); j > 0; j-- )
    2059                 :            :     {
    2060         [ #  # ]:          0 :       vtx_ptr = vtx_list.get_and_step();
    2061         [ #  # ]:          0 :       vtx_ptr->marked( 0 );
    2062                 :            :     }
    2063                 :            :   }
    2064 [ #  # ][ #  # ]:          0 :   for( i = edge_list.size(); i > 0; i-- )
    2065                 :            :   {
    2066         [ #  # ]:          0 :     edge_ptr = edge_list.get_and_step();
    2067         [ #  # ]:          0 :     vtx_list.clean_out();
    2068         [ #  # ]:          0 :     edge_ptr->ref_vertices( vtx_list );
    2069 [ #  # ][ #  # ]:          0 :     for( int j = vtx_list.size(); j > 0; j-- )
    2070                 :            :     {
    2071         [ #  # ]:          0 :       vtx_ptr = vtx_list.get_and_step();
    2072 [ #  # ][ #  # ]:          0 :       if( vtx_ptr->marked() ) continue;
    2073                 :            :     
    2074         [ #  # ]:          0 :       all_vertices.append( vtx_ptr );
    2075         [ #  # ]:          0 :       vtx_ptr->marked( 1 );
    2076                 :            : 
    2077         [ #  # ]:          0 :       vertex_edges.clean_out();
    2078         [ #  # ]:          0 :       vtx_ptr->ref_edges( vertex_edges );
    2079 [ #  # ][ #  # ]:          0 :       for( int k = vertex_edges.size(); k > 0; k-- )
    2080 [ #  # ][ #  # ]:          0 :         vertex_edges.get_and_step()->marked( 0 );
    2081                 :            :     }
    2082                 :            :   }
    2083                 :            :   
    2084                 :            :   //now mark all of the edges in the edge list with a 1
    2085 [ #  # ][ #  # ]:          0 :   for( i = edge_list.size(); i > 0; i-- )
    2086 [ #  # ][ #  # ]:          0 :     edge_list.get_and_step()->marked( 1 );
    2087                 :            :     
    2088 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> sorted_edge_list( edge_list.size() );
                 [ #  # ]
    2089                 :            :   
    2090                 :          0 :   int passes = 0;
    2091 [ #  # ][ #  # ]:          0 :   while( sorted_edge_list.size() < edge_list.size() ) 
                 [ #  # ]
    2092                 :            :   {
    2093                 :          0 :     passes++;
    2094                 :          0 :     RefVertex* start_vtx = 0;
    2095                 :          0 :     RefEdge* start_edge = 0;
    2096                 :            :     
    2097                 :            :     //choose a start_vtx and start_edge
    2098 [ #  # ][ #  # ]:          0 :     for( i = all_vertices.size(); i > 0; i-- )
    2099                 :            :     {
    2100         [ #  # ]:          0 :       vtx_ptr = all_vertices.get_and_step();
    2101                 :            :       //if( ! vtx_ptr->marked() ) continue;
    2102                 :            :       
    2103                 :          0 :       int edge_count = 0;
    2104         [ #  # ]:          0 :       vertex_edges.clean_out();
    2105         [ #  # ]:          0 :       vtx_ptr->ref_edges( vertex_edges );
    2106 [ #  # ][ #  # ]:          0 :       for( int j = vertex_edges.size(); j > 0; j-- )
    2107                 :            :       {
    2108         [ #  # ]:          0 :         edge_ptr = vertex_edges.get_and_step();
    2109 [ #  # ][ #  # ]:          0 :         if( edge_ptr->marked() )
    2110                 :            :         {
    2111                 :          0 :           start_edge = edge_ptr;
    2112                 :          0 :           edge_count++;
    2113 [ #  # ][ #  # ]:          0 :           if( (edge_count > 1) || (valence2_vertices && vertex_edges.size() > 2) ) 
         [ #  # ][ #  # ]
                 [ #  # ]
    2114                 :          0 :             break;
    2115                 :            :           // If the vertex has more than two edges, consider it a 
    2116                 :            :           // valid starting point for the search because it will not
    2117                 :            :           // be possible to create a composite across that vertex
    2118                 :            :           // anyway.
    2119                 :            :         }
    2120                 :            :       }
    2121         [ #  # ]:          0 :       if( edge_count == 1 )
    2122                 :            :       {
    2123                 :          0 :         start_vtx = vtx_ptr;
    2124                 :          0 :         break;
    2125                 :            :       }
    2126                 :            :     }
    2127                 :            :     
    2128                 :            :     //If we have a circular loop, choose any vertex as the start vertex
    2129         [ #  # ]:          0 :     if( ! start_vtx )
    2130                 :            :     {
    2131                 :          0 :       start_edge = 0;
    2132         [ #  # ]:          0 :       all_vertices.reset();
    2133 [ #  # ][ #  # ]:          0 :       for( i = all_vertices.size(); ! start_edge && (i > 0); i-- )
                 [ #  # ]
    2134                 :            :       {
    2135         [ #  # ]:          0 :         start_vtx = all_vertices.get_and_step();
    2136         [ #  # ]:          0 :         vertex_edges.clean_out();
    2137         [ #  # ]:          0 :         start_vtx->ref_edges( vertex_edges );
    2138 [ #  # ][ #  # ]:          0 :         for( int j = vertex_edges.size(); j > 0; j-- )
    2139                 :            :         {
    2140         [ #  # ]:          0 :           edge_ptr = vertex_edges.get_and_step();
    2141 [ #  # ][ #  # ]:          0 :           if( edge_ptr->marked() )
    2142                 :            :           {
    2143                 :          0 :             start_edge = edge_ptr;
    2144                 :          0 :             break;
    2145                 :            :           }
    2146                 :            :         }
    2147 [ #  # ][ #  # ]:          0 :         if( start_vtx->marked() ) break;
    2148                 :            :       }
    2149                 :            :     }
    2150                 :            : 
    2151         [ #  # ]:          0 :     assert( start_edge != 0 );
    2152         [ #  # ]:          0 :     assert( start_vtx != 0 );
    2153                 :            : 
    2154                 :            : 
    2155         [ #  # ]:          0 :     start_vtx->marked( 0 );
    2156                 :          0 :     edge_ptr = start_edge;
    2157                 :          0 :     vtx_ptr = start_vtx;
    2158                 :            :     
    2159         [ #  # ]:          0 :     do
    2160                 :            :     {
    2161         [ #  # ]:          0 :       sorted_edge_list.append( edge_ptr );
    2162         [ #  # ]:          0 :       edge_ptr->marked( 0 );
    2163                 :            :       
    2164         [ #  # ]:          0 :       RefVertex* next_vtx = edge_ptr->other_vertex( vtx_ptr );
    2165         [ #  # ]:          0 :       next_vtx->marked( 0 );
    2166                 :            :       
    2167         [ #  # ]:          0 :       vertex_edges.clean_out();
    2168         [ #  # ]:          0 :       next_vtx->ref_edges( vertex_edges );
    2169                 :          0 :       RefEdge* next_edge = 0;
    2170                 :            :       
    2171 [ #  # ][ #  # ]:          0 :       if( !valence2_vertices || vertex_edges.size() < 3 )
         [ #  # ][ #  # ]
    2172                 :            :       {
    2173 [ #  # ][ #  # ]:          0 :         for( i = vertex_edges.size(); i > 0; i-- )
    2174                 :            :         {
    2175         [ #  # ]:          0 :           RefEdge* edge2_ptr = vertex_edges.get_and_step();
    2176 [ #  # ][ #  # ]:          0 :           if( edge2_ptr->marked() )
    2177                 :            :           {
    2178                 :          0 :             next_edge = edge2_ptr;
    2179                 :          0 :             break;
    2180                 :            :           }
    2181                 :            :         }
    2182                 :            :       }
    2183                 :            :       
    2184                 :          0 :       edge_ptr = next_edge;
    2185                 :          0 :       vtx_ptr = next_vtx;
    2186                 :            :     } while( edge_ptr );
    2187                 :            :   }
    2188                 :            :   
    2189 [ #  # ][ #  # ]:          0 :   assert( sorted_edge_list.size() == edge_list.size() );
                 [ #  # ]
    2190                 :            :   
    2191         [ #  # ]:          0 :   edge_list.clean_out();
    2192         [ #  # ]:          0 :   edge_list = sorted_edge_list;
    2193 [ #  # ][ #  # ]:          0 :   return (passes == 1) ? CUBIT_SUCCESS : CUBIT_FAILURE;
    2194                 :            : }
    2195                 :            : 
    2196                 :            : 
    2197                 :          0 : CubitStatus CompositeTool::composite( DLIList<RefFace*>& faces_to_composite,
    2198                 :            :                                       DLIList<RefFace*>& new_composites,
    2199                 :            :                                       double max_angle )
    2200                 :            : {
    2201                 :            :   int i;
    2202         [ #  # ]:          0 :   DLIList<CoEdge*> coedges(2);
    2203                 :          0 :   double cos_max_angle = cos( max_angle );
    2204                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
    2205                 :            :   
    2206 [ #  # ][ #  # ]:          0 :   DLIList<BasicTopologyEntity*> input, boundary, internal, other;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2207 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( faces_to_composite, input );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2208         [ #  # ]:          0 :   classify_children( input, boundary, internal, other );
    2209 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> internal_edges(internal.size());
                 [ #  # ]
    2210 [ #  # ][ #  # ]:          0 :   CAST_LIST( internal, internal_edges, RefEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2211 [ #  # ][ #  # ]:          0 :   if ( !internal_edges.size() )
    2212                 :          0 :     return CUBIT_FAILURE;
    2213                 :            :     
    2214                 :            :     // Group faces into sets to be composited
    2215                 :            :   
    2216 [ #  # ][ #  # ]:          0 :   std::vector< DLIList<RefFace*> > face_sets;
    2217 [ #  # ][ #  # ]:          0 :   for ( i = faces_to_composite.size(); i--; )
    2218 [ #  # ][ #  # ]:          0 :     faces_to_composite.get_and_step()->marked(0);
    2219                 :            :   
    2220 [ #  # ][ #  # ]:          0 :   while ( internal_edges.size() )
    2221                 :            :   {
    2222         [ #  # ]:          0 :     RefEdge* edge = internal_edges.pop();
    2223         [ #  # ]:          0 :     coedges.clean_out();
    2224         [ #  # ]:          0 :     edge->co_edges(coedges);
    2225 [ #  # ][ #  # ]:          0 :     if ( coedges.size() != 2 )
    2226                 :          0 :       continue;
    2227                 :            :     
    2228         [ #  # ]:          0 :     CoEdge* coedge1 = coedges.get_and_step();
    2229         [ #  # ]:          0 :     CoEdge* coedge2 = coedges.get_and_step();
    2230         [ #  # ]:          0 :     RefFace* face1 = coedge1->get_ref_face();
    2231         [ #  # ]:          0 :     RefFace* face2 = coedge2->get_ref_face();
    2232                 :            :     
    2233         [ #  # ]:          0 :     if ( max_angle < 4.0 )
    2234                 :            :     {
    2235 [ #  # ][ #  # ]:          0 :       CubitVector point, norm1, norm2;
                 [ #  # ]
    2236 [ #  # ][ #  # ]:          0 :       bool reversed = coedge1->get_sense() == coedge2->get_sense();
    2237                 :            : 
    2238         [ #  # ]:          0 :       edge->position_from_fraction( 0.33, point );
    2239 [ #  # ][ #  # ]:          0 :       norm1 = face1->normal_at( point );
    2240 [ #  # ][ #  # ]:          0 :       norm2 = face2->normal_at( point );
    2241 [ #  # ][ #  # ]:          0 :       if ( reversed ) norm2 *= -1.0;
    2242 [ #  # ][ #  # ]:          0 :       double cos_angle = (norm1 % norm2)/(norm1.length()*norm2.length());
                 [ #  # ]
    2243         [ #  # ]:          0 :       if ( cos_angle < cos_max_angle )
    2244                 :          0 :         continue;
    2245                 :            : 
    2246         [ #  # ]:          0 :       edge->position_from_fraction( 0.67, point );
    2247 [ #  # ][ #  # ]:          0 :       norm1 = face1->normal_at( point );
    2248 [ #  # ][ #  # ]:          0 :       norm2 = face2->normal_at( point );
    2249 [ #  # ][ #  # ]:          0 :       if ( reversed ) norm2 *= -1.0;
    2250 [ #  # ][ #  # ]:          0 :       cos_angle = (norm1 % norm2)/(norm1.length()*norm2.length());
                 [ #  # ]
    2251         [ #  # ]:          0 :       if ( cos_angle < cos_max_angle )
    2252                 :          0 :         continue;
    2253                 :            :     }
    2254                 :            :     
    2255 [ #  # ][ #  # ]:          0 :     if ( face1->marked() && face2->marked() )
         [ #  # ][ #  # ]
                 [ #  # ]
    2256                 :            :     {
    2257 [ #  # ][ #  # ]:          0 :       if ( face1->marked() != face2->marked() )
                 [ #  # ]
    2258                 :            :       {
    2259 [ #  # ][ #  # ]:          0 :         DLIList<RefFace*>& merge_set = face_sets[face2->marked()-1];
    2260 [ #  # ][ #  # ]:          0 :         face_sets[face1->marked()-1] += merge_set;
                 [ #  # ]
    2261 [ #  # ][ #  # ]:          0 :         while( merge_set.size() )
    2262 [ #  # ][ #  # ]:          0 :           merge_set.pop()->marked( face1->marked() );
                 [ #  # ]
    2263                 :            :       }
    2264                 :            :     }
    2265 [ #  # ][ #  # ]:          0 :     else if ( face2->marked() )
    2266                 :            :     {
    2267 [ #  # ][ #  # ]:          0 :       face1->marked(face2->marked());
    2268 [ #  # ][ #  # ]:          0 :       face_sets[face2->marked()-1].append(face1);
                 [ #  # ]
    2269                 :            :     }
    2270                 :            :     else
    2271                 :            :     {
    2272 [ #  # ][ #  # ]:          0 :       if ( !face1->marked() )
    2273                 :            :       {
    2274 [ #  # ][ #  # ]:          0 :         face_sets.push_back(DLIList<RefFace*>());
                 [ #  # ]
    2275 [ #  # ][ #  # ]:          0 :         face1->marked(face_sets.size());
    2276 [ #  # ][ #  # ]:          0 :         face_sets[face1->marked()-1].append(face1);
                 [ #  # ]
    2277                 :            :       }
    2278 [ #  # ][ #  # ]:          0 :       face2->marked(face1->marked());
    2279 [ #  # ][ #  # ]:          0 :       face_sets[face1->marked()-1].append(face2);
                 [ #  # ]
    2280                 :            :     }
    2281                 :            :   }
    2282                 :            :   
    2283                 :            :     // clear all marks
    2284         [ #  # ]:          0 :   std::vector< DLIList<RefFace*> >::iterator s_itor;
    2285 [ #  # ][ #  # ]:          0 :   for ( s_itor = face_sets.begin(); s_itor != face_sets.end(); ++s_itor )
         [ #  # ][ #  # ]
                 [ #  # ]
    2286                 :            :   {
    2287 [ #  # ][ #  # ]:          0 :     for ( i = s_itor->size(); i--; )
                 [ #  # ]
    2288 [ #  # ][ #  # ]:          0 :       s_itor->get_and_step()->marked(0);
                 [ #  # ]
    2289                 :            :   }
    2290                 :            : 
    2291                 :            :     // composite faces
    2292 [ #  # ][ #  # ]:          0 :   for ( s_itor = face_sets.begin(); s_itor != face_sets.end(); ++s_itor )
         [ #  # ][ #  # ]
                 [ #  # ]
    2293                 :            :   {
    2294 [ #  # ][ #  # ]:          0 :     if ( s_itor->size() < 2 )
                 [ #  # ]
    2295                 :          0 :       continue;
    2296                 :            :     
    2297 [ #  # ][ #  # ]:          0 :     RefFace* comp = composite(*s_itor);
    2298         [ #  # ]:          0 :     if ( comp )
    2299         [ #  # ]:          0 :       new_composites.append(comp);
    2300                 :            :     else
    2301                 :          0 :       result = CUBIT_FAILURE;
    2302                 :            :   }
    2303                 :            : 
    2304         [ #  # ]:          0 :   return result;
    2305                 :            : }
    2306                 :            : 
    2307                 :            : //-------------------------------------------------------------------------
    2308                 :            : // Purpose       : Composite surfaces and curves.
    2309                 :            : //
    2310                 :            : // Special Notes : 
    2311                 :            : //
    2312                 :            : // Creator       : Jason Kraftcheck
    2313                 :            : //
    2314                 :            : // Creation Date : 04/13/00
    2315                 :            : //-------------------------------------------------------------------------
    2316                 :          0 : RefFace* CompositeTool::composite( DLIList<RefFace*>& faces_to_composite,
    2317                 :            :                                    DLIList<RefEdge*>& result_edges,
    2318                 :            :                                    DLIList<RefVertex*>* vertices_to_keep,
    2319                 :            :                                    double max_vertex_angle )
    2320                 :            : {
    2321         [ #  # ]:          0 :   result_edges.clean_out();
    2322         [ #  # ]:          0 :   RefFace* result = composite( faces_to_composite );
    2323         [ #  # ]:          0 :   if( ! result ) return 0;
    2324                 :            :   
    2325         [ #  # ]:          0 :   DLIList<RefEdge*> face_edges;
    2326         [ #  # ]:          0 :   result->ref_edges( face_edges );
    2327         [ #  # ]:          0 :   composite( face_edges, result_edges, vertices_to_keep, max_vertex_angle );
    2328                 :            :   
    2329         [ #  # ]:          0 :   return result;
    2330                 :            : }
    2331                 :            : 
    2332                 :            : //-------------------------------------------------------------------------
    2333                 :            : // Purpose       : Composite surfaces and curves.
    2334                 :            : //
    2335                 :            : // Special Notes : 
    2336                 :            : //
    2337                 :            : // Creator       : Jason Kraftcheck
    2338                 :            : //
    2339                 :            : // Creation Date : 04/13/00
    2340                 :            : //-------------------------------------------------------------------------
    2341                 :          0 : CubitStatus CompositeTool::composite( DLIList<RefFace*>& faces_to_composite,
    2342                 :            :                                       DLIList<RefFace*>& result_faces,
    2343                 :            :                                       DLIList<RefEdge*>& result_edges,
    2344                 :            :                                       double max_curve_angle,
    2345                 :            :                                       DLIList<RefVertex*>* vertices_to_keep,
    2346                 :            :                                       double max_vtx_angle  )
    2347                 :            : {
    2348         [ #  # ]:          0 :   result_faces.clean_out();
    2349         [ #  # ]:          0 :   result_edges.clean_out();
    2350                 :            :   
    2351                 :            :   CubitStatus status = 
    2352         [ #  # ]:          0 :     composite( faces_to_composite, result_faces, max_curve_angle );
    2353         [ #  # ]:          0 :   if( ! status ) return status;
    2354                 :            :   
    2355 [ #  # ][ #  # ]:          0 :   DLIList<TopologyEntity*> query_input, query_output;
                 [ #  # ]
    2356 [ #  # ][ #  # ]:          0 :   CAST_LIST_TO_PARENT( result_faces, query_input );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2357                 :            :   ModelQueryEngine::instance()->
    2358 [ #  # ][ #  # ]:          0 :     query_model( query_input, DagType::ref_edge_type(), query_output );
                 [ #  # ]
    2359                 :            :   
    2360 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> edge_list;
    2361 [ #  # ][ #  # ]:          0 :   CAST_LIST( query_output, edge_list, RefEdge );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2362                 :            :   
    2363 [ #  # ][ #  # ]:          0 :   return composite( edge_list, result_edges, vertices_to_keep, max_vtx_angle );
    2364                 :            : }
    2365                 :            : 
    2366                 :            :   
    2367                 :            : 
    2368                 :            :   
    2369                 :          0 : CubitStatus CompositeTool::stitch_points( TBPoint* pt1, TBPoint* pt2 )
    2370                 :            : {
    2371 [ #  # ][ #  # ]:          0 :   if ( pt1->owner() && pt2->owner() && pt1->owner() != pt2->owner() )
         [ #  # ][ #  # ]
    2372                 :          0 :     return CUBIT_FAILURE;
    2373                 :            :   
    2374                 :          0 :   CompositePoint* result = CompositeEngine::instance().stitch_points( pt1, pt2 );
    2375         [ #  # ]:          0 :   return result ? CUBIT_SUCCESS : CUBIT_FAILURE;
    2376                 :            : }
    2377                 :            : 
    2378                 :          0 : CubitStatus CompositeTool::stitch_curves( Curve* cv1, Curve* cv2 )
    2379                 :            : {
    2380 [ #  # ][ #  # ]:          0 :   if ( cv1->owner() && cv2->owner() && cv1->owner() != cv2->owner() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2381                 :          0 :     return CUBIT_FAILURE;
    2382                 :            :   
    2383         [ #  # ]:          0 :   DLIList<TopologyBridge*> points;
    2384                 :            :   TBPoint *start1, *end1, *start2, *end2;
    2385                 :            : 
    2386         [ #  # ]:          0 :   points.clean_out();
    2387         [ #  # ]:          0 :   cv1->get_children( points );
    2388         [ #  # ]:          0 :   points.reset();
    2389 [ #  # ][ #  # ]:          0 :   start1 = dynamic_cast<TBPoint*>(points.get_and_step());
    2390 [ #  # ][ #  # ]:          0 :   end1 = dynamic_cast<TBPoint*>(points.get_and_step());
    2391                 :            : 
    2392         [ #  # ]:          0 :   points.clean_out();
    2393         [ #  # ]:          0 :   cv2->get_children( points );
    2394         [ #  # ]:          0 :   points.reset();
    2395 [ #  # ][ #  # ]:          0 :   start2 = dynamic_cast<TBPoint*>(points.get_and_step());
    2396 [ #  # ][ #  # ]:          0 :   end2 = dynamic_cast<TBPoint*>(points.get_and_step());
    2397                 :            :   
    2398 [ #  # ][ #  # ]:          0 :   assert( start1 && start2 && end1 && end2 );
         [ #  # ][ #  # ]
    2399                 :            :   
    2400         [ #  # ]:          0 :   if ( (start1 == end1) != (start2 == end2) )
    2401                 :          0 :     return CUBIT_FAILURE;
    2402                 :            :   
    2403 [ #  # ][ #  # ]:          0 :   if ( start1 == end2 || start1->owner() == end2->owner() )
         [ #  # ][ #  # ]
                 [ #  # ]
    2404         [ #  # ]:          0 :     std::swap(start2, end2);
    2405                 :            :   
    2406 [ #  # ][ #  # ]:          0 :   if ( (start1->owner() != start2->owner()) || (end1->owner() != end2->owner()) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2407                 :          0 :     return CUBIT_FAILURE;
    2408                 :            :   
    2409 [ #  # ][ #  # ]:          0 :   if ( start1 != start2 && !stitch_points( start1, start2 ) )
         [ #  # ][ #  # ]
    2410                 :          0 :     return CUBIT_FAILURE;
    2411                 :            :   
    2412 [ #  # ][ #  # ]:          0 :   if ( start1 != end1 && end1 != end2 && !stitch_points( end1, end2 ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2413                 :          0 :     return CUBIT_FAILURE;
    2414                 :            :   
    2415 [ #  # ][ #  # ]:          0 :   CompositeCurve* result = CompositeEngine::instance().stitch_curves( cv1, cv2 );
    2416 [ #  # ][ #  # ]:          0 :   return result ? CUBIT_SUCCESS : CUBIT_FAILURE;
    2417                 :            : }
    2418                 :            : 
    2419                 :            : 
    2420                 :            : 
    2421                 :            :         
    2422                 :            : //-------------------------------------------------------------------------
    2423                 :            : // Purpose       : Functions overloaded by CompositeToolMesh
    2424                 :            : //
    2425                 :            : // Special Notes : 
    2426                 :            : //
    2427                 :            : // Creator       : Jason Kraftcheck
    2428                 :            : //
    2429                 :            : // Creation Date : 05/10/04
    2430                 :            : //-------------------------------------------------------------------------
    2431                 :          0 : CubitStatus CompositeTool::update_combined_vols( RefVolume*, RefVolume* ) 
    2432                 :          0 :   {return CUBIT_SUCCESS;}
    2433                 :          0 : CubitStatus CompositeTool::update_combined_faces( RefFace*, RefEdge*, RefFace* ) 
    2434                 :          0 :   {return CUBIT_SUCCESS;}
    2435                 :          0 : CubitStatus CompositeTool::update_combined_edges( RefEdge*, RefEdge* ,int keep_interval,double keep_size,FirmnessType interval_keep_type,SizeIntervalType size_keep_type) 
    2436                 :          0 :   {return CUBIT_SUCCESS;}
    2437                 :          0 : CubitStatus CompositeTool::determine_combined_edges_interval_or_size( RefEdge* edge_1, RefEdge* edge_2,int& result_interval,double& result_size,FirmnessType& interval_keep_type,SizeIntervalType& size_keep_type)
    2438 [ +  - ][ +  - ]:       6364 : {return CUBIT_SUCCESS;}
    2439                 :            : 
    2440                 :            : 
    2441                 :            : 
    2442                 :            : 

Generated by: LCOV version 1.11