]> OCCT Git - occt.git/commitdiff
0027170: Reading STEP files produces invalid shapes CR27170_2
authorssafarov <ssafarov@opencascade.com>
Sun, 13 Feb 2022 11:39:37 +0000 (14:39 +0300)
committerssafarov <ssafarov@opencascade.com>
Fri, 11 Mar 2022 12:33:35 +0000 (15:33 +0300)
Added a new GetEdgeCurve() method that returns a 3D curve or a curve on a surface by subtracting the location of the face and add test.

src/BRepCheck/BRepCheck_Edge.cxx
src/BRepCheck/BRepCheck_Edge.hxx
src/ShapeFix/ShapeFix_Wire.cxx
tests/bugs/heal/bug27170 [new file with mode: 0644]
tests/bugs/xde/bug27170_2
tests/bugs/xde/bug27170_3
tests/heal/checkshape/bug27814_7
tests/heal/checkshape/bug32448_1
tests/heal/checkshape/bug32448_6

index 32d55b8cd75236a94a0219d87027e3c0cc5fbb4d..d4ccb4d516febed742588c4f5b63a63aa8754ddc 100644 (file)
@@ -316,6 +316,7 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
       BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
       Standard_Real eps = Precision::PConfusion();
       Standard_Boolean toRunParallel = !myMutex.IsNull();
+      const Handle(Adaptor3d_Curve)& aLocalHCurve = GetEdgeCurve(TopoDS::Face(S));
       while (itcr.More()) {
         const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
         if (cr != myCref && cr->IsCurveOnSurface(Su,L)) {
@@ -372,13 +373,13 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
             Handle(Geom_Surface) Sb = cr->Surface();
             Sb = Handle(Geom_Surface)::DownCast
               //             (Su->Transformed(L.Transformation()));
-              (Su->Transformed(/*L*/(Floc * TFloc).Transformation()));
+              (Su->Transformed(/*L*/TFloc.Transformation()));
             Handle(Geom2d_Curve) PC = cr->PCurve();
             Handle(GeomAdaptor_Surface) GAHS = new GeomAdaptor_Surface(Sb);
             Handle(Geom2dAdaptor_Curve) GHPC = new Geom2dAdaptor_Curve(PC,f,l);
             Handle(Adaptor3d_CurveOnSurface) ACS = new Adaptor3d_CurveOnSurface(GHPC,GAHS);
 
-            BRepLib_ValidateEdge aValidateEdge(myHCurve, ACS, SameParameter);
+            BRepLib_ValidateEdge aValidateEdge(aLocalHCurve, ACS, SameParameter);
             aValidateEdge.SetExitIfToleranceExceeded(Tol);
             aValidateEdge.SetExactMethod(myIsExactMethod);
             aValidateEdge.SetParallel(toRunParallel);
@@ -402,7 +403,7 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
               GHPC->Load(cr->PCurve2(),f,l); // same bounds
               ACS->Load(GHPC, GAHS); // sans doute inutile
 
-              BRepLib_ValidateEdge aValidateEdgeOnClosedSurf(myHCurve, ACS, SameParameter);
+              BRepLib_ValidateEdge aValidateEdgeOnClosedSurf(aLocalHCurve, ACS, SameParameter);
               aValidateEdgeOnClosedSurf.SetExitIfToleranceExceeded(Tol);
               aValidateEdgeOnClosedSurf.SetExactMethod(myIsExactMethod);
               aValidateEdgeOnClosedSurf.SetParallel(toRunParallel);
@@ -440,12 +441,12 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
           // plan en position
           if (myGctrl) {
             P = Handle(Geom_Plane)::
-              DownCast(P->Transformed(/*L*/(Floc * TFloc).Transformation()));// eap occ332
+              DownCast(P->Transformed(/*L*/TFloc.Transformation()));// eap occ332
             //on projette Cref sur ce plan
             Handle(GeomAdaptor_Surface) GAHS = new GeomAdaptor_Surface(P);
 
-            // Dub - Normalement myHCurve est une GeomAdaptor_Curve
-            Handle(GeomAdaptor_Curve) Gac = Handle(GeomAdaptor_Curve)::DownCast(myHCurve);
+            // Dub - Normalement aLocalHCurve est une GeomAdaptor_Curve
+            Handle(GeomAdaptor_Curve) Gac = Handle(GeomAdaptor_Curve)::DownCast(aLocalHCurve);
             Handle(Geom_Curve) C3d = Gac->Curve();
             Handle(Geom_Curve) ProjOnPlane = 
               GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,First,Last),
@@ -458,12 +459,12 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
             Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj);
             Handle(Geom2dAdaptor_Curve) GHPC = 
               new Geom2dAdaptor_Curve(PC,
-              myHCurve->FirstParameter(),
-              myHCurve->LastParameter());
+              aLocalHCurve->FirstParameter(),
+              aLocalHCurve->LastParameter());
 
             Handle(Adaptor3d_CurveOnSurface) ACS = new Adaptor3d_CurveOnSurface(GHPC,GAHS);
 
-            BRepLib_ValidateEdge aValidateEdgeProj(myHCurve, ACS, SameParameter);
+            BRepLib_ValidateEdge aValidateEdgeProj(aLocalHCurve, ACS, SameParameter);
             aValidateEdgeProj.SetExitIfToleranceExceeded(Tol);
             aValidateEdgeProj.SetExactMethod(myIsExactMethod);
             aValidateEdgeProj.SetParallel(toRunParallel);
@@ -665,6 +666,50 @@ Standard_Real BRepCheck_Edge::Tolerance()
 }
 
 
+//=======================================================================
+//function : GetEdgeCurve
+//purpose  : 
+//=======================================================================
+
+Handle(Adaptor3d_Curve) BRepCheck_Edge::GetEdgeCurve(const TopoDS_Face& theFace)
+{
+  Handle(Adaptor3d_Curve) aLocalCurve;
+  Handle(BRep_GCurve) GCref(Handle(BRep_GCurve)::DownCast(myCref));
+  Standard_Real First, Last;
+  GCref->Range(First, Last);
+  if (myCref->IsCurve3D())
+  {
+    TopLoc_Location aLoc = !theFace.IsNull()
+                         ? (myShape.Location() * myCref->Location()).Predivided(theFace.Location())
+                         : myShape.Location() * myCref->Location();
+    Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
+      (myCref->Curve3D()->Transformed
+      (aLoc.Transformation()));
+
+    GeomAdaptor_Curve GAC3d(C3d, C3d->TransformedParameter(First, aLoc.Transformation()),
+                               C3d->TransformedParameter(Last, aLoc.Transformation()));
+    aLocalCurve = new GeomAdaptor_Curve(GAC3d);
+  }
+  else // curve on surface
+  {
+    TopLoc_Location aFaceLoc = theFace.Location();
+    Handle(Geom_Surface) Sref = myCref->Surface();
+    Sref = !theFace.IsNull()
+           ? Handle(Geom_Surface)::DownCast(Sref->Transformed(myCref->Location().Predivided(aFaceLoc).Transformation()))
+           : Handle(Geom_Surface)::DownCast(Sref->Transformed(myCref->Location().Transformation()));
+
+    const Handle(Geom2d_Curve)& PCref = myCref->PCurve();
+    Handle(GeomAdaptor_Surface) GAHSref = new GeomAdaptor_Surface(Sref);
+    Handle(Geom2dAdaptor_Curve) GHPCref =
+      new Geom2dAdaptor_Curve(PCref, First, Last);
+    Adaptor3d_CurveOnSurface ACSref(GHPCref, GAHSref);
+    aLocalCurve = new Adaptor3d_CurveOnSurface(ACSref);
+  }
+  
+    return aLocalCurve;
+  }
+
+
 //=======================================================================
 //function : CheckPolygonOnTriangulation
 //purpose  : 
index 3a8ef877c821c3db8296fe4dc66ec05800ce716a..4864fed1e9862bc2f8af4f444f3a2859c6572412 100644 (file)
@@ -23,6 +23,7 @@
 
 class BRep_CurveRepresentation;
 class TopoDS_Edge;
+class TopoDS_Face;
 class TopoDS_Shape;
 
 class BRepCheck_Edge;
@@ -49,6 +50,11 @@ public:
   
   Standard_EXPORT Standard_Real Tolerance();
   
+  //! Creates a 3d curve or curve on surface by subtracting the location of the face
+  //! @param[in] theFace input face to get the location from it
+  //! @return a 3d curve or curve on surface
+  Standard_EXPORT Handle(Adaptor3d_Curve) GetEdgeCurve (const TopoDS_Face& theFace);
+  
   //! Sets status of Edge;
   Standard_EXPORT void SetStatus (const BRepCheck_Status theStatus);
 
index fcfe71b8e973994b4cc3b3cd75f9052081edb86c..72c45abb3d26bc354900d6de552156fd6ed42eee 100644 (file)
@@ -2535,7 +2535,6 @@ Standard_Boolean ShapeFix_Wire::FixIntersectingEdges (const Standard_Integer num
           myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE6 );
           locMayEdit = Standard_False;
         }
-        newtol = 1.000001 * maxte;
       }
     }
     
diff --git a/tests/bugs/heal/bug27170 b/tests/bugs/heal/bug27170
new file mode 100644 (file)
index 0000000..6856d25
--- /dev/null
@@ -0,0 +1,10 @@
+puts "============"
+puts "0027170: Reading STEP files produces invalid shapes"
+puts "============"
+
+restore [locate_data_file bug27170_f.brep] f
+
+fixshape result f
+
+ttranslate result 9.68119149294e-13 217.938944319 299.700009766
+checkshape result
\ No newline at end of file
index bb4fa4eb4bbc088ee22962527104cd4bb7e9c913..15204f2f78c6937177b3f4d7b2f85585dd21b90e 100644 (file)
@@ -1,5 +1,3 @@
-puts "TODO CR27170 ALL: Faulty shapes in variables faulty_1 to"
-
 puts "============"
 puts "CR27170"
 puts "============"
index d867db07631775bb226950b31a989fcdf7753d36..0c5e54072909927ae43882e447fab4b42ec90c9a 100644 (file)
@@ -1,5 +1,3 @@
-puts "TODO CR27170 ALL: Faulty shapes in variables faulty_1 to"
-
 puts "============"
 puts "CR27170"
 puts "============"
index 2919124ae84a90eca51438a1a10efa4ded837e74..70024e876585b03c3423bc1b18855e88580ce685 100644 (file)
@@ -1,4 +1,4 @@
-puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_114"
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_92"
 puts "=========="
 puts "0027814: Parallelize BRepCheck_Analyzer"
 puts "=========="
index a6f8cd3eefe26ac35ad47fb4288b61c566453667..a77d3f326e15a72e8f18bf69008cf614c79760f8 100644 (file)
@@ -1,4 +1,4 @@
-puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_88"
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_112"
 puts "=========="
 puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
 puts "=========="
index a1599c053185bf214fce543f9fb21fc3dadba584..63a1e688785e4b95b071fd3029d3447642984a72 100644 (file)
@@ -1,4 +1,4 @@
-puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_7656"
+puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_7659"
 puts "=========="
 puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface"
 puts "=========="