0027329: Export to STEP failure
authorika <ika@opencascade.com>
Thu, 9 Jun 2016 13:48:53 +0000 (16:48 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 16 Jun 2016 09:11:40 +0000 (12:11 +0300)
Do ProcessShape for non-manifold too,
Add binding of already written shared faces to STEP entity for non-manifold.

Minor correction of test case bugs/step/bug27329

src/STEPControl/STEPControl_ActorWrite.cxx
src/STEPControl/STEPControl_ActorWrite.hxx
tests/bugs/step/bug27329 [new file with mode: 0644]

index 6087575..da131b2 100644 (file)
@@ -33,6 +33,7 @@
 #include <OSD_Timer.hxx>
 #include <ShapeAnalysis_ShapeTolerance.hxx>
 #include <ShapeExtend_Explorer.hxx>
+#include <ShapeProcess_ShapeContext.hxx>
 #include <Standard_Type.hxx>
 #include <StepBasic_ApplicationProtocolDefinition.hxx>
 #include <StepBasic_HArray1OfProduct.hxx>
@@ -269,6 +270,34 @@ Handle(StepShape_NonManifoldSurfaceShapeRepresentation) STEPControl_ActorWrite::
   return aResult;
 }
 
+//=======================================================================
+//function : mergeInfoForNM
+//purpose  : bind already written shared faces to STEP entity for non-manifold
+//=======================================================================
+void STEPControl_ActorWrite::mergeInfoForNM(const Handle(Transfer_FinderProcess)& theFP,
+                                            const Handle(Standard_Transient) &theInfo) const
+{
+  Handle(ShapeProcess_ShapeContext) aContext = Handle(ShapeProcess_ShapeContext)::DownCast ( theInfo );
+  if ( aContext.IsNull() ) return;
+
+  const TopTools_DataMapOfShapeShape &aMap = aContext->Map();
+  TopTools_DataMapIteratorOfDataMapOfShapeShape aShapeShapeIt(aMap);
+
+  for ( ; aShapeShapeIt.More(); aShapeShapeIt.Next() ) {
+    TopoDS_Shape anOrig = aShapeShapeIt.Key(), aRes = aShapeShapeIt.Value();
+    if (anOrig.ShapeType() != TopAbs_FACE)
+      continue;
+
+    Handle(TransferBRep_ShapeMapper) anOrigMapper= TransferBRep::ShapeMapper ( theFP, anOrig);
+    Handle(Transfer_Binder) anOrigBinder = theFP->Find ( anOrigMapper );
+    if (anOrigBinder.IsNull())
+      continue;
+
+    Handle(TransferBRep_ShapeMapper) aResMapper = TransferBRep::ShapeMapper ( theFP, aRes );
+    theFP->Bind(aResMapper, anOrigBinder);
+  }
+}
+
 
 //=======================================================================
 //function : SetMode
@@ -867,16 +896,15 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran
     Handle(Standard_Transient) info;
     Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val");
 
-    // Fix only manifold shapes, do nothing with non-manifold topology as it is processed separately (ssv; 13.11.2010)
     TopoDS_Shape aShape;
-    if (isManifold)
-      aShape = XSAlgo::AlgoContainer()->ProcessShape(xShape, Tol, maxTol
-                                                    "write.step.resource.name", 
-                                                    "write.step.sequence", info,
-                                                    FP->GetProgress() );
-    else
-      aShape = xShape;
-    
+    aShape = XSAlgo::AlgoContainer()->ProcessShape(xShape, Tol, maxTol, 
+                                                  "write.step.resource.name"
+                                                  "write.step.sequence", info,
+                                                  FP->GetProgress() );
+    if (!isManifold) {
+      mergeInfoForNM(FP, info);
+    }
+
     // create a STEP entity corresponding to shape
     Handle(StepGeom_GeometricRepresentationItem) item;
     switch (trmode)
index be67859..afc1869 100644 (file)
@@ -95,6 +95,9 @@ private:
   //! to create a new one if doesn't exist yet)
   //! (ssv; 13.11.2010)
   Standard_EXPORT Handle(StepShape_NonManifoldSurfaceShapeRepresentation) getNMSSRForGroup (const Handle(TopTools_HSequenceOfShape)& shapeGroup, const Handle(Transfer_FinderProcess)& FP, Standard_Boolean& isNMSSRCreated) const;
+  
+  //! bind already written shared faces to STEP entity for non-manifold
+  Standard_EXPORT void mergeInfoForNM(const Handle(Transfer_FinderProcess)& theFP, const Handle(Standard_Transient) &theInfo) const;
 
   Standard_Integer mygroup;
   Standard_Real mytoler;
diff --git a/tests/bugs/step/bug27329 b/tests/bugs/step/bug27329
new file mode 100644 (file)
index 0000000..9f9ca5c
--- /dev/null
@@ -0,0 +1,23 @@
+puts "========"
+puts "OCC27329"
+puts "========"
+puts ""
+#########################
+# Export to STEP failure
+#########################
+
+restore [locate_data_file bug27329_phenix.brep] a
+
+param write.step.nonmanifold 1
+param read.step.nonmanifold 1
+newmodel
+
+stepwrite 0 a $imagedir/bug27329_temp.stp
+stepread $imagedir/bug27329_temp.stp b *
+renamevar b_1 result
+
+checknbshapes result -solid 3 -shell 3 -face 42
+
+param write.step.nonmanifold 0
+param read.step.nonmanifold 0
+newmodel