]> OCCT Git - occt-copy.git/commitdiff
0028715: Invalid shape produced by reading of attached STEP file. Regression from...
authorskl <skl@opencascade.com>
Mon, 31 Jul 2017 14:20:25 +0000 (17:20 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 17 Aug 2017 12:47:32 +0000 (15:47 +0300)
Corrections: to use fixed shape as result in the non-manifold mode was made.

Regression was due to using modified initial shape as result in the previous version OCCT. At present initial shape is not modified during ShapeProcessing. Therefore modification to use fixed result was made.

Additionally using of nonManifold flag is added to ShapeProcessing.

src/STEPControl/STEPControl_ActorRead.cxx
src/ShapeFix/ShapeFix_Shape.cxx
src/ShapeFix/ShapeFix_Shell.cxx
src/ShapeFix/ShapeFix_Shell.hxx
src/ShapeProcess/ShapeProcess_OperLibrary.cxx
src/ShapeProcess/ShapeProcess_ShapeContext.cxx
src/ShapeProcess/ShapeProcess_ShapeContext.hxx
src/XSAlgo/XSAlgo_AlgoContainer.cxx
src/XSAlgo/XSAlgo_AlgoContainer.hxx
tests/bugs/step/bug27329
tests/bugs/step/bug28715 [new file with mode: 0644]

index fd392c95c367c87609769c482b21d89e35b40382..db1b5038575520f4c79dc94cc09e81a370b14633 100644 (file)
@@ -47,6 +47,7 @@
 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
 #include <StepGeom_Axis2Placement3d.hxx>
 #include <StepGeom_CartesianTransformationOperator3d.hxx>
+#include <StepGeom_Direction.hxx>
 #include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
 #include <StepGeom_GeometricRepresentationItem.hxx>
 #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
@@ -823,18 +824,30 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
       nsh ++;
     }
   }
-  
+
   // [BEGIN] Proceed with non-manifold topology (ssv; 12.11.2010)
   if (!isManifold) {
+
     Handle(Standard_Transient) info;
     // IMPORTANT: any fixing on non-manifold topology must be done after the shape is transferred from STEP
     TopoDS_Shape fixedResult = 
       XSAlgo::AlgoContainer()->ProcessShape( comp, myPrecision, myMaxTol,
                                              "read.step.resource.name", 
                                              "read.step.sequence", info,
-                                             TP->GetProgress() );
+                                             TP->GetProgress(), Standard_True);
     XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
 
+    if (fixedResult.ShapeType() == TopAbs_COMPOUND)
+    {
+        comp = TopoDS::Compound(fixedResult);
+    }
+    else
+    {
+        comp.Nullify();
+        B.MakeCompound(comp);
+        B.Add(comp, fixedResult);
+    }
+
     BRep_Builder brepBuilder;
 
     // [BEGIN] Try to close OPEN Shells in I-DEAS case (ssv; 17.11.2010)
@@ -874,20 +887,19 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
     // [BEGIN] Reconstruct Solids from Closed Shells (ssv; 15.11.2010)
     TopoDS_Compound reconstComp;
     brepBuilder.MakeCompound(reconstComp);
-    
-    TopoDS_Iterator it(comp);
-    for ( ; it.More(); it.Next() ) {
-      TopoDS_Shape aSubShape = it.Value();
-      if ( aSubShape.ShapeType() == TopAbs_SHELL && aSubShape.Closed() ) {
-        TopoDS_Solid nextSolid;
-        brepBuilder.MakeSolid(nextSolid);
-        brepBuilder.Add(nextSolid, aSubShape);
-        brepBuilder.Add(reconstComp, nextSolid);
-      } 
-      else if (aSubShape.ShapeType() == TopAbs_SHELL)
-        brepBuilder.Add(reconstComp, aSubShape);
+    TopExp_Explorer exp(comp, TopAbs_SHELL);
+    for (; exp.More(); exp.Next())
+    {
+        TopoDS_Shape aSubShape = exp.Current();
+        if (aSubShape.ShapeType() == TopAbs_SHELL && aSubShape.Closed()) {
+            TopoDS_Solid nextSolid;
+            brepBuilder.MakeSolid(nextSolid);
+            brepBuilder.Add(nextSolid, aSubShape);
+            brepBuilder.Add(reconstComp, nextSolid);
+        }
+        else if (aSubShape.ShapeType() == TopAbs_SHELL)
+            brepBuilder.Add(reconstComp, aSubShape);
     }
-
     comp = reconstComp;
     // [END] Reconstruct Solids from Closed Shells (ssv; 15.11.2010)
   }
@@ -896,6 +908,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
   if      (nsh == 0) shbinder.Nullify();
   else if (nsh == 1) shbinder = new TransferBRep_ShapeBinder (OneResult);
   else               shbinder = new TransferBRep_ShapeBinder (comp);
+
   PrepareUnits ( oldSRContext, TP ); //:S4136
   TP->Bind(sr, shbinder);
 
index c6e19f87c8af54b46570588cc8e8d22ca5201999..9ed6db145c036dbb03c5f9d3a419f8fbe65cf0ec 100644 (file)
@@ -243,6 +243,7 @@ Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator)
   aPSentry.Next();
 
   myResult = Context()->Apply(S);
+
   if ( NeedFix(myFixSameParameterMode) )
   {
     SameParameter(myResult, Standard_False, theProgress);
@@ -269,6 +270,7 @@ Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator)
       }
     }
   }
+
   myResult = Context()->Apply(myResult);
 
   if ( !fft.IsNull() )
index 9bf0d58161d77ec2fa9014bb299bbaa3f90595b8..1d9782feb620726507e0464a07d341a71dc7056f 100644 (file)
@@ -70,6 +70,7 @@ ShapeFix_Shell::ShapeFix_Shell()
   myFixOrientationMode = -1;
   myFixFace = new ShapeFix_Face;
   myNbShells =0;
+  myNonManifold = Standard_False;
 }
 
 //=======================================================================
@@ -84,6 +85,7 @@ ShapeFix_Shell::ShapeFix_Shell(const TopoDS_Shell& shape)
   myFixOrientationMode = -1;
   myFixFace = new ShapeFix_Face;
   Init(shape);
+  myNonManifold = Standard_False;
 }
 
 //=======================================================================
@@ -138,9 +140,10 @@ Standard_Boolean ShapeFix_Shell::Perform(const Handle(Message_ProgressIndicator)
     if ( !aPSentry.More() )
       return Standard_False;
   }
+
   TopoDS_Shape newsh = Context()->Apply(myShell);
   if ( NeedFix ( myFixOrientationMode) )
-    FixFaceOrientation(TopoDS::Shell(newsh));
+    FixFaceOrientation(TopoDS::Shell(newsh), Standard_True, myNonManifold);
 
   TopoDS_Shape aNewsh = Context()->Apply (newsh);
   ShapeAnalysis_Shell aSas;
@@ -853,7 +856,10 @@ static void CreateClosedShell(TopTools_SequenceOfShape& OpenShells,
 // purpose  : 
 //=======================================================================
   
-Standard_Boolean ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell,const Standard_Boolean isAccountMultiConex,const Standard_Boolean NonManifold) 
+Standard_Boolean ShapeFix_Shell::FixFaceOrientation(
+    const TopoDS_Shell& shell,
+    const Standard_Boolean isAccountMultiConex,
+    const Standard_Boolean NonManifold) 
 {
   //myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
   Standard_Boolean done = Standard_False;
@@ -1101,6 +1107,7 @@ void ShapeFix_Shell::SetMaxTolerance (const Standard_Real maxtol)
   ShapeFix_Root::SetMaxTolerance ( maxtol );
   myFixFace->SetMaxTolerance ( maxtol );
 }
+
 //=======================================================================
 //function : NbShells
 //purpose  : 
@@ -1110,3 +1117,13 @@ Standard_Integer ShapeFix_Shell::NbShells() const
 {
   return myNbShells;
 }
+
+//=======================================================================
+//function : SetNonManifoldFlag
+//purpose  : 
+//=======================================================================
+
+void ShapeFix_Shell::SetNonManifoldFlag(const Standard_Boolean isNonManifold)
+{
+    myNonManifold = isNonManifold;
+}
index c098d084ca11e914bec501a9a015abd4ea4e7081..5e8325f82198123812e8849dfb9fc313d6338864 100644 (file)
@@ -73,7 +73,10 @@ public:
   //! If this mode is equal to Standard_True one non-manifold will be created from shell
   //! contains multishared edges. Else if this mode is equal to Standard_False only
   //! manifold shells will be created. By default - Standard_False.
-  Standard_EXPORT Standard_Boolean FixFaceOrientation (const TopoDS_Shell& shell, const Standard_Boolean isAccountMultiConex = Standard_True, const Standard_Boolean NonManifold = Standard_False);
+  Standard_EXPORT Standard_Boolean FixFaceOrientation (
+      const TopoDS_Shell& shell,
+      const Standard_Boolean isAccountMultiConex = Standard_True,
+      const Standard_Boolean NonManifold = Standard_False);
   
   //! Returns fixed shell (or subset of oriented faces).
   Standard_EXPORT TopoDS_Shell Shell();
@@ -114,7 +117,8 @@ public:
   //! FixFaceOrientation, by default True.
     Standard_Integer& FixOrientationMode();
 
-
+  //! Sets NonManifold flag
+  Standard_EXPORT virtual void SetNonManifoldFlag(const Standard_Boolean isNonManifold);
 
 
   DEFINE_STANDARD_RTTIEXT(ShapeFix_Shell,ShapeFix_Root)
@@ -129,7 +133,7 @@ protected:
   Standard_Integer myFixFaceMode;
   Standard_Integer myFixOrientationMode;
   Standard_Integer myNbShells;
-
+  Standard_Boolean myNonManifold;
 
 private:
 
index c3d348c40617c79bd24bc5ca26b90051ffdd432b..a16e6b6187d2f19c7b0557f689b4ce6ac85cfc83 100644 (file)
@@ -716,7 +716,8 @@ static Standard_Boolean fixshape (const Handle(ShapeProcess_Context)& context)
   sfs->FixSolidTool()->CreateOpenSolidMode() = ctx->BooleanVal ( "CreateOpenSolidMode", Standard_True );
 
   sfs->FixShellTool()->FixFaceMode() = ctx->IntegerVal ( "FixFaceMode", -1 );
-  sfs->FixShellTool()->FixOrientationMode() = ctx->IntegerVal ( "FixFaceOrientationMode", -1 );
+  sfs->FixShellTool()->SetNonManifoldFlag(ctx->IsNonManifold());
+  sfs->FixShellTool()->FixOrientationMode() = ctx->IntegerVal("FixFaceOrientationMode", -1);
 
   //parameters for ShapeFix_Face
   sff->FixWireMode()              = ctx->IntegerVal ( "FixWireMode", -1 );
index 526dcaa71f3821bd97330e26975408b06af56b07..2e717c619090fc0e9e08586710f84328044515b9 100644 (file)
@@ -38,7 +38,8 @@ IMPLEMENT_STANDARD_RTTIEXT(ShapeProcess_ShapeContext,ShapeProcess_Context)
 //=======================================================================
 ShapeProcess_ShapeContext::ShapeProcess_ShapeContext (const Standard_CString file,
                                                       const Standard_CString seq) 
-     : ShapeProcess_Context ( file, seq ), myUntil(TopAbs_FACE)
+     : ShapeProcess_Context ( file, seq ), myUntil(TopAbs_FACE),
+       myNonManifold(Standard_False)
 {
 }
 
@@ -50,7 +51,8 @@ ShapeProcess_ShapeContext::ShapeProcess_ShapeContext (const Standard_CString fil
 ShapeProcess_ShapeContext::ShapeProcess_ShapeContext (const TopoDS_Shape &S,
                                                       const Standard_CString file,
                                                       const Standard_CString seq) 
-     : ShapeProcess_Context ( file, seq ), myUntil(TopAbs_FACE)
+     : ShapeProcess_Context ( file, seq ), myUntil(TopAbs_FACE),
+       myNonManifold(Standard_False)
 {
   Init ( S );
 }
index eba7b310cda5bf0995ca1882ebca052be87db5ca..8a814a5841e66d612145caaa2cf9de82b6fed4ad 100644 (file)
@@ -126,7 +126,17 @@ public:
   //! Prints statistics on Shape Processing onto the current Messenger.
   Standard_EXPORT void PrintStatistics() const;
 
+  //! Set NonManifold flag
+  Standard_EXPORT void SetNonManifold(Standard_Boolean theNonManifold)
+  {
+      myNonManifold = theNonManifold;
+  }
 
+  //! Get NonManifold flag
+  Standard_EXPORT Standard_Boolean IsNonManifold()
+  {
+      return myNonManifold;
+  }
 
 
   DEFINE_STANDARD_RTTIEXT(ShapeProcess_ShapeContext,ShapeProcess_Context)
@@ -144,7 +154,7 @@ private:
   TopTools_DataMapOfShapeShape myMap;
   Handle(ShapeExtend_MsgRegistrator) myMsg;
   TopAbs_ShapeEnum myUntil;
-
+  Standard_Boolean myNonManifold;
 
 };
 
index 7094d09aac9a37b16fc48677380f8d0ec8227e4c..a492773fa208528e608d7fadb0c6bba7daa25e11 100644 (file)
@@ -97,7 +97,8 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
                                                  const Standard_CString prscfile,
                                                  const Standard_CString pseq,
                                                  Handle(Standard_Transient)& info,
-                                                 const Handle(Message_ProgressIndicator)& progress) const
+                                                 const Handle(Message_ProgressIndicator)& progress,
+                                                 const Standard_Boolean NonManifold) const
 {
   if ( shape.IsNull() ) return shape;
   
@@ -112,6 +113,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
     if ( !progress.IsNull() )
       context->SetProgress(progress);
   }
+  context->SetNonManifold(NonManifold);
   info = context;
   
   Standard_CString seq = Interface_Static::CVal ( pseq );
index f64c90730a6eb4f9595d6ae87ab9f32a4215a0fa..ec03dfb6ffc92696a882454978783658ebf06922 100644 (file)
@@ -63,7 +63,11 @@ public:
   //! This information should be later transmitted to
   //! MergeTransferInfo in order to be recorded in the
   //! translation map
-  Standard_EXPORT virtual TopoDS_Shape ProcessShape (const TopoDS_Shape& shape, const Standard_Real Prec, const Standard_Real MaxTol, const Standard_CString rscfile, const Standard_CString seq, Handle(Standard_Transient)& info, const Handle(Message_ProgressIndicator)& progress = 0) const;
+  Standard_EXPORT virtual TopoDS_Shape ProcessShape (
+      const TopoDS_Shape& shape, const Standard_Real Prec, const Standard_Real MaxTol,
+      const Standard_CString rscfile, const Standard_CString seq, Handle(Standard_Transient)& info,
+      const Handle(Message_ProgressIndicator)& progress = 0,
+      const Standard_Boolean NonManifold = Standard_False) const;
   
   //! Checks quality of pcurve of the edge on the given face,
   //! and corrects it if necessary.
index 9f9ca5c343336bc9709246a4f793ebe656a9098f..cb31fc5c3df94d0fde4c0ca21cbdb073696f7feb 100644 (file)
@@ -16,7 +16,7 @@ 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
+checknbshapes result -solid 1 -shell 5 -face 42
 
 param write.step.nonmanifold 0
 param read.step.nonmanifold 0
diff --git a/tests/bugs/step/bug28715 b/tests/bugs/step/bug28715
new file mode 100644 (file)
index 0000000..4f687d5
--- /dev/null
@@ -0,0 +1,26 @@
+puts "========"
+puts "OCC28715"
+puts "========"
+puts ""
+##########################################################################
+# Invalid shape after import STeP file
+##########################################################################
+
+stepread [locate_data_file bug28715_Ailette_mm.stp] a *
+
+checkshape a_1
+
+set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 487
+ EDGE      : 794
+ WIRE      : 313
+ FACE      : 313
+ SHELL     : 3
+ SOLID     : 0
+ COMPSOLID : 0
+ COMPOUND  : 1
+ SHAPE     : 1911
+"
+checknbshapes a_1 -ref ${nbshapes_expected} -t -m "importing file"
+checkview -display a_1 -3d -path ${imagedir}/${test_image}.png