[cgma-dev] r2039 - cgm/trunk/geom/OCC

janehu at mcs.anl.gov janehu at mcs.anl.gov
Tue Aug 12 13:57:38 CDT 2008


Author: janehu
Date: 2008-08-12 13:57:38 -0500 (Tue, 12 Aug 2008)
New Revision: 2039

Modified:
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCCurve.cpp
   cgm/trunk/geom/OCC/OCCCurve.hpp
   cgm/trunk/geom/OCC/OCCLump.cpp
   cgm/trunk/geom/OCC/OCCLump.hpp
   cgm/trunk/geom/OCC/OCCPoint.cpp
   cgm/trunk/geom/OCC/OCCPoint.hpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.hpp
   cgm/trunk/geom/OCC/OCCShapeAttributeSet.cpp
   cgm/trunk/geom/OCC/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/geom/OCC/OCCSurface.hpp
Log:
Added similiar function of split_owner as Acis, updated the test case.

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -42,6 +42,7 @@
 #include <TopTools_IndexedMapOfShape.hxx>
 #include "BRepBuilderAPI_Transform.hxx"
 #include "TopTools_DataMapOfShapeInteger.hxx"
+#include "TopTools_ListIteratorOfListOfShape.hxx"
 #include "gp_Ax1.hxx"
 #include "gp_Ax2.hxx"
 #include "Bnd_Box.hxx"
@@ -468,8 +469,17 @@
       shape = shapes.First();
 
     else if(shapes.Extent() > 1)
-      shape.Nullify();
-
+    {
+      //update all attributes first.
+      TopTools_ListIteratorOfListOfShape it;
+      it.Initialize(shapes);
+      for(it; it.More(); it.Next())
+      {
+        shape = it.Value();
+        OCCQueryEngine::instance()->copy_attributes(old_shape, shape);
+      } 
+      shape = shapes.First();
+    }
     else if(op->IsDeleted(solid))
     {
        TopTools_IndexedMapOfShape M_new;

Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -41,6 +41,7 @@
 #include "GProp_GProps.hxx"
 #include "BRepGProp.hxx"
 #include <TopTools_IndexedMapOfShape.hxx>
+#include "TopTools_ListIteratorOfListOfShape.hxx"
 #include <GCPnts_AbscissaPoint.hxx>
 #include <Bnd_Box.hxx>
 #include <BndLib_Add3dCurve.hxx>
@@ -923,8 +924,20 @@
   {
     TopTools_ListOfShape shapes;
     shapes.Assign(op->Modified(*get_TopoDS_Edge()));
-    if(shapes.Extent())
+    if(shapes.Extent() == 1)
       shape = shapes.First();
+    else if(shapes.Extent() > 1)
+    {
+      //update all attributes first.
+      TopTools_ListIteratorOfListOfShape it;
+      it.Initialize(shapes);
+      for(it; it.More(); it.Next())
+      {
+        shape = it.Value();
+        OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Edge(), shape);
+      }
+      shape = shapes.First();
+    }
     else if (op->IsDeleted(*get_TopoDS_Edge()))
       ;
     else

Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -307,12 +307,6 @@
     //                           if not known let the function figure it out)
     // NOTE: POINT MUST LIE ON THE SURFACE FOR THIS FUNCTION TO WORK PROPERLY.
 
-  CubitStatus save_attribs( FILE* file_ptr );
-    // Write FactAttribs out to file
-
-  CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
-    // Read FactAttribs from file
-  
   virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
   virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -39,6 +39,7 @@
 #include <TopTools_IndexedMapOfShape.hxx>
 #include "BRepBuilderAPI_Transform.hxx"
 #include "TopTools_DataMapOfShapeInteger.hxx"
+#include "TopTools_ListIteratorOfListOfShape.hxx"
 #include "BRepAlgoAPI_BooleanOperation.hxx"
 #include "BRepBuilderAPI_MakeShape.hxx"
 #include "Bnd_Box.hxx"
@@ -360,8 +361,21 @@
   {
     TopTools_ListOfShape shapes;
     shapes.Assign(op->Modified(*get_TopoDS_Solid()));
-    if(shapes.Extent() > 0)
+    if(shapes.Extent() > 1)
+    { 
+      //update all attributes first.
+      TopTools_ListIteratorOfListOfShape it;
+      it.Initialize(shapes);
+      for(it; it.More(); it.Next())
+      {
+        shape = it.Value();
+        OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Solid(), 
+                                                    shape);
+      } 
       shape = shapes.First();
+    }
+    else if (shapes.Extent() == 1)
+      shape = shapes.First();
     else if(op->IsDeleted(*get_TopoDS_Solid()))
       ;
     else
@@ -398,11 +412,17 @@
   TopTools_IndexedMapOfShape M;
   TopoDS_Shape shape;
   TopExp::MapShapes(new_shape, TopAbs_SOLID,M);
-  CubitBoolean is_null_new_shape = CUBIT_FALSE;
   TopoDS_Solid new_solid;
   if(M.Extent() > 1)
-    is_null_new_shape = CUBIT_TRUE;
-  else if(M.Extent() == 1 )
+  {
+    //update all attributes first.
+    for(int ii=1; ii<=M.Extent(); ii++)
+    {
+      TopoDS_Solid solid = TopoDS::Solid(M(ii));
+      OCCQueryEngine::instance()->copy_attributes(old_solid, solid);
+    }
+  }
+  if(M.Extent() == 1 )
     new_solid = TopoDS::Solid(M(1));  
 
   M.Clear();
@@ -423,8 +443,17 @@
       shape = shapes.First();
 
     else if(shapes.Extent() > 1)
-      shape.Nullify();
-
+    {
+      //update all attributes first.
+      TopTools_ListIteratorOfListOfShape it;
+      it.Initialize(shapes);
+      for(it; it.More(); it.Next())
+      {
+        shape = it.Value();
+        OCCQueryEngine::instance()->copy_attributes(shell, shape);
+      }
+      shape = shapes.First();
+    }
     else if(op->IsDeleted(shell))
     {
        TopTools_IndexedMapOfShape M_new;

Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCLump.hpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -138,12 +138,6 @@
     //- Returns volume for Lump, area for Surface, length for Curve and 
     //- 1.0 for Point
 
-  CubitStatus save_attribs( FILE* file_ptr );
-    // Write FactAttribs out to file
-
-  CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
-    // Read FactAttribs from file
-  
   virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
   virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 

Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -273,8 +273,20 @@
   {
     TopTools_ListOfShape shapes;
     shapes.Assign(op->Modified(*get_TopoDS_Vertex()));
-    if(shapes.Extent())
+    if(shapes.Extent() == 1)
       shape = shapes.First();
+    else if(shapes.Extent() > 1)
+    {
+      //update all attributes first.
+      TopTools_ListIteratorOfListOfShape it;
+      it.Initialize(shapes);
+      for(it; it.More(); it.Next())
+      {
+        shape = it.Value();
+        OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Vertex(),shape);
+      }
+      shape = shapes.First();
+    }
     else if(op->IsDeleted(*get_TopoDS_Vertex()))
       ;
     else

Modified: cgm/trunk/geom/OCC/OCCPoint.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.hpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCPoint.hpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -133,10 +133,6 @@
   virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
   virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 
-  CubitStatus save_attribs( FILE *file_ptr );
-
-  CubitStatus restore_attribs( FILE *file_ptr, unsigned int endian );
-
   void update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
                           BRepAlgoAPI_BooleanOperation *op = NULL);
 };

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -2622,24 +2622,30 @@
   return CUBIT_FALSE;
 }
 
-int OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape, 
-                                   TopoDS_Shape new_shape)
+void OCCQueryEngine::copy_attributes(TopoDS_Shape old_shape,
+                                     TopoDS_Shape new_shape)
 {
-  if (!OCCMap->IsBound(old_shape) || old_shape.IsEqual(new_shape))
-    return -1;
-
   //update the attribute label tree
   DLIList<CubitSimpleAttrib*> list;
   OCCAttribSet::get_attributes(old_shape, list);
-  
-  OCCAttribSet::remove_attribute(old_shape);
 
   for(int i = 0; !new_shape.IsNull() && i < list.size(); i ++)
   {
     CubitSimpleAttrib* s_attr = list.get_and_step();
     OCCAttribSet::append_attribute(s_attr, new_shape);
   }
-  
+}
+
+int OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape, 
+                                   TopoDS_Shape new_shape)
+{
+  if (!OCCMap->IsBound(old_shape) || old_shape.IsEqual(new_shape))
+    return -1;
+
+  //update the attribute label tree
+  copy_attributes(old_shape, new_shape); 
+  OCCAttribSet::remove_attribute(old_shape);
+
   //update CGM-OCC map
   int k = OCCMap->Find(old_shape);
   assert (k > 0 && k <= iTotalTBCreated);

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -114,6 +114,9 @@
 
   CubitBoolean EXPORT_ATTRIB;
 
+  void copy_attributes(TopoDS_Shape old_shape,
+                       TopoDS_Shape new_shape);
+
   int update_OCC_map(TopoDS_Shape old_shape, TopoDS_Shape new_shape);
 
   virtual ~OCCQueryEngine();

Modified: cgm/trunk/geom/OCC/OCCShapeAttributeSet.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShapeAttributeSet.cpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCShapeAttributeSet.cpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -564,7 +564,7 @@
     if(child.FindAttribute(TDataStd_Name::GetID(), attr_name))
     {
       OS << "\n";
-      OS << "NEW_SIMPLE_ATTRIB ";
+      OS << "CGM_ATTRIB ";
       name_string = attr_name->Get(); 
       name_string.Print(OS);
       OS << "* " ;
@@ -784,7 +784,7 @@
     // Read Attributes and Set the flags
     IS >> buffer;
 
-    while (buffer[0] == 'N')
+    while (buffer[0] == 'C')
     {
       ReadAttribute(S, IS,l_attr);
       IS >> buffer;

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -221,7 +221,22 @@
     TopTools_ListOfShape shapes;
     shapes.Assign(op->Modified(*get_TopoDS_Shell()));
     if (shapes.Extent())
-      shape = shapes.First();
+    {
+      if(shapes.Extent() > 1)
+      {
+        TopTools_ListIteratorOfListOfShape it;
+        it.Initialize(shapes);
+        for(it; it.More(); it.Next())
+        {
+          shape = it.Value();
+          OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Shell(), 
+                                                      shape);
+        }
+        shape.Nullify();
+      }
+      else
+        shape = shapes.First();
+    }
     else if(op->IsDeleted(*get_TopoDS_Shell()))
       ;
     else
@@ -280,8 +295,19 @@
     if(shapes.Extent() == 1)
       shape = shapes.First();
     else
+    {
+      if(shapes.Extent() > 1)
+      {
+        TopTools_ListIteratorOfListOfShape it;
+        it.Initialize(shapes);
+        for(it; it.More(); it.Next())
+        {
+          shape = it.Value();
+          OCCQueryEngine::instance()->copy_attributes(face, shape);
+        }
+      }
       shape.Nullify();
-
+    }
     if(shapes.Extent() > 0 || (op && op->IsDeleted(face)))
       OCCSurface::update_OCC_entity(face,shape, op, sp);
   }

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -784,8 +784,20 @@
   {
     TopTools_ListOfShape shapes;
     shapes.Assign(op->Modified(*get_TopoDS_Face()));
-    if (shapes.Extent() > 0)
+    if (shapes.Extent() == 1)
       shape = shapes.First();
+    else if(shapes.Extent() > 1)
+    {
+      //update all attributes first.
+      TopTools_ListIteratorOfListOfShape it;
+      it.Initialize(shapes);
+      for(it; it.More(); it.Next())
+      {
+        shape = it.Value();
+        OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Face(), shape);
+      }
+      shape = shapes.First();
+    }
     else if(op->IsDeleted(*get_TopoDS_Face()))
       ;
     else
@@ -874,7 +886,17 @@
        if (shapes.Extent() == 1)
          shape_edge = shapes.First();
        else if (shapes.Extent() > 1)
-         shape_edge.Nullify();
+       {
+         //update all attributes first.
+         TopTools_ListIteratorOfListOfShape it;
+         it.Initialize(shapes);
+         for(it; it.More(); it.Next())
+         {
+           shape = it.Value();
+           OCCQueryEngine::instance()->copy_attributes(edge, shape_edge);
+         }
+         shape_edge = shapes.First();
+       }
        else if (op->IsDeleted(edge))
          shape_edge.Nullify(); 
        else 
@@ -890,6 +912,18 @@
        if (shapes.Extent() == 1)
          shape_vertex = shapes.First();
 
+       else if(shapes.Extent() > 1)
+       {
+         //update all attributes first.
+         TopTools_ListIteratorOfListOfShape it;
+         it.Initialize(shapes);
+         for(it; it.More(); it.Next())
+         {
+           shape = it.Value();
+           OCCQueryEngine::instance()->copy_attributes(vertex, shape_vertex);
+         }
+         shape_vertex = shapes.First();
+       }
        else
          shape_vertex.Nullify();
 

Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp	2008-08-12 18:55:33 UTC (rev 2038)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp	2008-08-12 18:57:38 UTC (rev 2039)
@@ -399,12 +399,6 @@
   virtual CubitSense get_geometry_sense();
     //- Return the relative surface sense. (see below)
   
-  CubitStatus save_attribs( FILE* file_ptr );
-    // Write FactAttribs out to file
-
-  CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
-    // Read FactAttribs from file
-  
   virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
   virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 




More information about the cgma-dev mailing list