0031617: Export STEP in nonmanifold mode corrupts the shape
authorjgv <jgv@opencascade.com>
Mon, 20 Jul 2020 14:38:22 +0000 (17:38 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 23 Jul 2020 13:08:19 +0000 (16:08 +0300)
Modify method XSControl_TransferWriter::TransferWriteShape: add removal of locations before writing the shape.

src/XSControl/XSControl_TransferWriter.cxx
tests/bugs/step/bug31617 [new file with mode: 0644]

index 5532d3a..e11ede5 100644 (file)
@@ -16,6 +16,7 @@
 #include <Interface_CheckIterator.hxx>
 #include <Interface_InterfaceModel.hxx>
 #include <Interface_Macros.hxx>
+#include <Interface_Static.hxx>
 #include <Message_Messenger.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Standard_Failure.hxx>
@@ -29,6 +30,7 @@
 #include <XSControl_Controller.hxx>
 #include <XSControl_TransferWriter.hxx>
 #include <XSControl_Utils.hxx>
+#include <ShapeUpgrade_RemoveLocations.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(XSControl_TransferWriter,Standard_Transient)
 
@@ -133,12 +135,22 @@ Standard_Boolean XSControl_TransferWriter::RecognizeShape (const TopoDS_Shape& s
 //=======================================================================
 
 IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteShape
-  (const Handle(Interface_InterfaceModel)& model,
-   const TopoDS_Shape& shape)
+  (const Handle(Interface_InterfaceModel)& theModel,
+   const TopoDS_Shape& theShape)
 {
   IFSelect_ReturnStatus status = IFSelect_RetVoid;
   if (myController.IsNull()) return IFSelect_RetError;
-  if (model.IsNull()) return IFSelect_RetVoid;
+  if (theModel.IsNull()) return IFSelect_RetVoid;
+
+  TopoDS_Shape aShape = theShape;
+  Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0;
+  if (isNMMode)
+  {
+    ShapeUpgrade_RemoveLocations aRemLoc;
+    aRemLoc.SetRemoveLevel(TopAbs_COMPOUND);
+    aRemLoc.Remove(aShape);
+    aShape = aRemLoc.GetResult();
+  }
 
   if (myTransferWriter.IsNull()) myTransferWriter = new Transfer_FinderProcess;
 //  effacer l actor : Controller s en charge
@@ -149,10 +161,10 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteShape
   try {
     OCC_CATCH_SIGNALS
     PrintStats(myTransferMode);
-    sout << "******        Transferring Shape, ShapeType = " << shape.ShapeType();
+    sout << "******        Transferring Shape, ShapeType = " << aShape.ShapeType();
     sout<<"                      ******"<<std::endl;
     status = myController->TransferWriteShape
-      (shape,myTransferWriter,model,myTransferMode);
+      (aShape,myTransferWriter,theModel,myTransferMode);
   }
   catch(Standard_Failure const& anException) {
     sout<<"****  ****  TransferWriteShape, EXCEPTION : "; 
diff --git a/tests/bugs/step/bug31617 b/tests/bugs/step/bug31617
new file mode 100644 (file)
index 0000000..b3ba1e2
--- /dev/null
@@ -0,0 +1,15 @@
+puts "============================================================"
+puts "OCC31617: Export STEP in nonmanifold mode corrupts the shape"
+puts "============================================================"
+puts ""
+
+brestore [locate_data_file bug31617.brep] a
+
+param write.step.nonmanifold 1
+
+testwritestep comp_nonmanifold.step a
+testreadstep comp_nonmanifold.step result
+
+checkshape result
+
+checknbshapes result -ref [lrange [nbshapes a] 11 16]