[cgma-dev] r1602 - in cgm/trunk/geom: . OCC

janehu at mcs.anl.gov janehu at mcs.anl.gov
Wed Feb 20 14:15:29 CST 2008


Author: janehu
Date: 2008-02-20 14:15:29 -0600 (Wed, 20 Feb 2008)
New Revision: 1602

Modified:
   cgm/trunk/geom/GeometryModifyTool.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
Log:
Added make_BodySM for surface; Added make_Surface from curve_list.

Modified: cgm/trunk/geom/GeometryModifyTool.cpp
===================================================================
--- cgm/trunk/geom/GeometryModifyTool.cpp	2008-02-19 18:38:03 UTC (rev 1601)
+++ cgm/trunk/geom/GeometryModifyTool.cpp	2008-02-20 20:15:29 UTC (rev 1602)
@@ -1336,15 +1336,70 @@
    if (ref_face_ptr)
     old_surface_ptr = dynamic_cast<Surface*>(bridge_list.pop());
 
+   //perform edge checks
+   DLIList<RefEdge*> copied_ref_edges;
+   if( check_edges ) 
+   { 
+      DLIList<RefEdge*> vtx_edges;
+      DLIList<RefVertex*> vtx_list; 
+      for ( int i = ref_edge_list.size(); i > 0; i-- )
+      {
+         RefEdge *ref_edge = ref_edge_list.get();
+
+         CubitBoolean other_edge = CUBIT_FALSE;
+         ref_edge->ref_vertices(vtx_list);
+         while( vtx_list.size() )
+         {
+            vtx_edges.clean_out();
+            vtx_list.pop()->ref_edges( vtx_edges );
+            while( vtx_edges.size() )
+            {
+               if( ! ref_edge_list.is_in_list( vtx_edges.pop() ) )
+               {
+                   other_edge = CUBIT_TRUE;
+                   vtx_list.clean_out();
+                   break;
+               }
+            }
+            if(other_edge)
+	       break;
+         }
+
+         if ( other_edge || (ref_edge->get_parents() > 0) )
+         {
+            RefEdge *replacement_edge = GeometryModifyTool::instance()->make_RefEdge( ref_edge );
+            if (!replacement_edge)
+            {
+                PRINT_WARNING("Creation of Surface Unsuccessful\n");
+                return (RefFace *)NULL;
+            }
+            ref_edge_list.change_to( replacement_edge );
+            copied_ref_edges.append( replacement_edge );
+         }
+         ref_edge_list.step();
+      }//end 'for' loop
+   }
+
    DLIList<Curve*> curve_list(ref_edge_list.size());
+   if (copied_ref_edges.size() > 0)
+   {
+     entity_list.clean_out();
+     bridge_list.clean_out();
+     CAST_LIST_TO_PARENT( ref_edge_list, entity_list );
+
+     GME_ptr =
+        common_modify_engine( entity_list, bridge_list ); 
+   }
    CAST_LIST( bridge_list, curve_list, Curve );
 
      // Use the Curves to create a Surface
    Surface* surface_ptr = GME_ptr->make_Surface(ref_face_type, curve_list,
-                                                old_surface_ptr, check_edges) ;
+                                                old_surface_ptr, CUBIT_FALSE) ;
 
    if (surface_ptr == NULL) {
      PRINT_ERROR("Couldn't make new RefFace.\n");
+     for(i=copied_ref_edges.size(); i--; )
+       GeometryQueryTool::instance()->delete_RefEdge( copied_ref_edges.get_and_step() );
      return NULL;
    }
 

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-02-19 18:38:03 UTC (rev 1601)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-02-20 20:15:29 UTC (rev 1602)
@@ -632,6 +632,8 @@
 // Function   : make_Surface
 // Member Type: PUBLIC
 // Description: make a surface of type surface_type, given the list of curves.
+//              check edges option is down in GeometryModifyTool level, so 
+//              disregard this option.
 // Author     : Jane Hu
 // Date       : 02/08
 //===============================================================================
@@ -640,8 +642,43 @@
                                  Surface * old_surface_ptr,
                                  bool check_edges) const
 {
+  //Create TopoDS_Edge list to make a surface.
+  DLIList<TopoDS_Edge*> topo_edges;
+  curve_list.reset() ;
+  Curve const* curve_ptr = NULL ;
+  OCCCurve* occ_curve = NULL;
+  TopoDS_Edge* topo_edge = NULL;
+  for ( i = 0 ; i < curve_list.size() ; i++ )
+  {
+     curve_ptr = curve_list.get_and_step() ;  
+     occ_curve = CAST_TO(const_cast<Curve*>(curve_ptr), OCCCurve);
+
+     if(occ_curve ==  NULL)
+     {
+        PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+                    "       Got a NULL pointer to OCCCurve\n") ;
+	return (Surface*) NULL;
+     }
+
+     topo_edge = occ_curve->get_TopoDS_Edge();
+     topo_edges.append(topo_edge);
+  }
   
-  return (Surface*) NULL;
+  // Use the topo_edges to make a topo_face
+  TopoDS_Face* topo_face = this->make_TopoDS_Face(surface_type,
+					topo_edges, old_surface_ptr) ;
+ 
+  if(topo_face == NULL)
+  {
+     PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+                 "       Cannot make Surface object.\n");
+     return (Surface *)NULL;
+  }
+
+  // make the topology bridges for the face
+  Surface *surface = OCCQueryEngine::instance()->populate_topology_bridge(
+                               *topo_face, CUBIT_TRUE); 
+  return surface ;
 }
 
 //===============================================================================
@@ -664,9 +701,28 @@
 // Author     : John Fowler
 // Date       : 10/02
 //===============================================================================
-BodySM* OCCModifyEngine::make_BodySM( Surface * ) const
-    {return NULL ;}
+BodySM* OCCModifyEngine::make_BodySM( Surface *surface ) const
+{
+  OCCSurface* occ_surface = CAST_TO(surface, OCCSurface);
+  if(!occ_surface)
+  {
+     PRINT_ERROR("Cannot create an OCC body from the given surface.\n"
+                 "Possible incompatible geometry engines.\n");
+     return (BodySM *)NULL;
+  }
 
+  OCCBody* occ_body = occ_surface->my_body();
+  if(occ_body)
+     return occ_body;
+
+  TopoDS_Face* face = occ_surface->get_TopoDS_Face();
+  surface = OCCQueryEngine::instance()->populate_topology_bridge(*face, CUBIT_TRUE);
+   
+  return CAST_TO(surface, OCCSurface)->my_body();
+}
+
+
+
 //===============================================================================
 // Function   : make_BodySM
 // Member Type: PUBLIC

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-02-19 18:38:03 UTC (rev 1601)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-02-20 20:15:29 UTC (rev 1602)
@@ -1197,15 +1197,6 @@
     {
       surface = new OCCSurface(poface);
 
-      if(build_body)
-      {
-        OCCShell* shell = new OCCShell(NULL, surface);
-        OCCLump* lump = new OCCLump(NULL, surface);
-        OCCBody* body = new OCCBody(NULL, CUBIT_TRUE, surface);
-        surface->set_body(body);
-        surface->set_lump(lump);
-        surface->set_shell(shell);
-      }
       if(PRINT_RESULT)
         PRINT_INFO("Adding faces.\n");
       iTotalTBCreated++;
@@ -1219,6 +1210,17 @@
       int k = OCCMap->Find(*poface);
       surface = (OCCSurface*)(OccToCGM->find(k))->second;
     }
+
+  if(build_body)
+    {
+      OCCShell* shell = new OCCShell(NULL, surface);
+      OCCLump* lump = new OCCLump(NULL, surface);
+      OCCBody* body = new OCCBody(NULL, CUBIT_TRUE, surface);
+      surface->set_body(body);
+      surface->set_lump(lump);
+      surface->set_shell(shell);
+    }
+
   TopExp_Explorer Ex;
   for (Ex.Init(aShape, TopAbs_WIRE); Ex.More(); Ex.Next())
     populate_topology_bridge(TopoDS::Wire(Ex.Current()));




More information about the cgma-dev mailing list