diff --git a/src/BRepCheck/BRepCheck_Edge.cxx b/src/BRepCheck/BRepCheck_Edge.cxx index 32d55b8cd7..d4ccb4d516 100644 --- a/src/BRepCheck/BRepCheck_Edge.cxx +++ b/src/BRepCheck/BRepCheck_Edge.cxx @@ -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 : diff --git a/src/BRepCheck/BRepCheck_Edge.hxx b/src/BRepCheck/BRepCheck_Edge.hxx index 3a8ef877c8..4864fed1e9 100644 --- a/src/BRepCheck/BRepCheck_Edge.hxx +++ b/src/BRepCheck/BRepCheck_Edge.hxx @@ -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); diff --git a/tests/bugs/heal/bug27170 b/tests/bugs/heal/bug27170 new file mode 100644 index 0000000000..6856d2567e --- /dev/null +++ b/tests/bugs/heal/bug27170 @@ -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 diff --git a/tests/bugs/xde/bug27170_2 b/tests/bugs/xde/bug27170_2 index bb4fa4eb4b..15204f2f78 100644 --- a/tests/bugs/xde/bug27170_2 +++ b/tests/bugs/xde/bug27170_2 @@ -1,5 +1,3 @@ -puts "TODO CR27170 ALL: Faulty shapes in variables faulty_1 to" - puts "============" puts "CR27170" puts "============" diff --git a/tests/bugs/xde/bug27170_3 b/tests/bugs/xde/bug27170_3 index d867db0763..0c5e540729 100644 --- a/tests/bugs/xde/bug27170_3 +++ b/tests/bugs/xde/bug27170_3 @@ -1,5 +1,3 @@ -puts "TODO CR27170 ALL: Faulty shapes in variables faulty_1 to" - puts "============" puts "CR27170" puts "============" diff --git a/tests/heal/checkshape/bug27814_7 b/tests/heal/checkshape/bug27814_7 index 2919124ae8..70024e8765 100644 --- a/tests/heal/checkshape/bug27814_7 +++ b/tests/heal/checkshape/bug27814_7 @@ -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 "==========" diff --git a/tests/heal/checkshape/bug32448_1 b/tests/heal/checkshape/bug32448_1 index a6f8cd3eef..a77d3f326e 100644 --- a/tests/heal/checkshape/bug32448_1 +++ b/tests/heal/checkshape/bug32448_1 @@ -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 "==========" diff --git a/tests/heal/checkshape/bug32448_6 b/tests/heal/checkshape/bug32448_6 index a1599c0531..63a1e68878 100644 --- a/tests/heal/checkshape/bug32448_6 +++ b/tests/heal/checkshape/bug32448_6 @@ -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 "=========="