diff --git a/src/BRepCheck/BRepCheck.cxx b/src/BRepCheck/BRepCheck.cxx index 1c60f5a056..6d088f44c1 100644 --- a/src/BRepCheck/BRepCheck.cxx +++ b/src/BRepCheck/BRepCheck.cxx @@ -23,6 +23,11 @@ #include #include #include +#include +#include +#include +#include +#include //======================================================================= //function : Add @@ -44,6 +49,7 @@ void BRepCheck::Add(BRepCheck_ListOfStatus& lst, const BRepCheck_Status stat) } lst.Append(stat); } + //======================================================================= //function : SelfIntersection //purpose : @@ -57,6 +63,67 @@ Standard_Boolean BRepCheck::SelfIntersection(const TopoDS_Wire& W, BRepCheck_Status stat = chkw->SelfIntersect(myFace,RetE1,RetE2); return (stat == BRepCheck_SelfIntersectingWire); } + +//======================================================================= +//function : PrecCurve +//purpose : +//======================================================================= +Standard_Real BRepCheck::PrecCurve(const Adaptor3d_Curve& aAC3D) +{ + Standard_Real aXEmax = RealEpsilon(); + // + GeomAbs_CurveType aCT = aAC3D.GetType(); + if (aCT==GeomAbs_Ellipse) { + Standard_Real aX[5]; + // + gp_Elips aEL3D=aAC3D.Ellipse(); + aEL3D.Location().Coord(aX[0], aX[1], aX[2]); + aX[3]=aEL3D.MajorRadius(); + aX[4]=aEL3D.MinorRadius(); + aXEmax=-1.; + for (Standard_Integer i = 0; i < 5; ++i) { + if (aX[i]<0.) { + aX[i]=-aX[i]; + } + Standard_Real aXE = Epsilon(aX[i]); + if (aXE > aXEmax) { + aXEmax = aXE; + } + } + }//if (aCT=GeomAbs_Ellipse) { + // + return aXEmax; +} + +//======================================================================= +//function : PrecSurface +//purpose : +//======================================================================= +Standard_Real BRepCheck::PrecSurface(const Handle(Adaptor3d_HSurface)& aAHSurf) +{ + Standard_Real aXEmax = RealEpsilon(); + // + GeomAbs_SurfaceType aST = aAHSurf->GetType(); + if (aST == GeomAbs_Cone) { + gp_Cone aCone=aAHSurf->Cone(); + Standard_Real aX[4]; + // + aCone.Location().Coord(aX[0], aX[1], aX[2]); + aX[3]=aCone.RefRadius(); + aXEmax=-1.; + for (Standard_Integer i = 0; i < 4; ++i) { + if (aX[i] < 0.) { + aX[i] = -aX[i]; + } + Standard_Real aXE = Epsilon(aX[i]); + if (aXE > aXEmax) { + aXEmax = aXE; + } + } + }//if (aST==GeomAbs_Cone) { + return aXEmax; +} + //======================================================================= //function : Print //purpose : diff --git a/src/BRepCheck/BRepCheck.hxx b/src/BRepCheck/BRepCheck.hxx index 7d3419fb99..3ce578d44b 100644 --- a/src/BRepCheck/BRepCheck.hxx +++ b/src/BRepCheck/BRepCheck.hxx @@ -28,6 +28,8 @@ class TopoDS_Wire; class TopoDS_Face; class TopoDS_Edge; +class Adaptor3d_Curve; +class Adaptor3d_HSurface; class BRepCheck_Result; class BRepCheck_Vertex; class BRepCheck_Edge; @@ -53,6 +55,11 @@ public: Standard_EXPORT static Standard_Boolean SelfIntersection (const TopoDS_Wire& W, const TopoDS_Face& F, TopoDS_Edge& E1, TopoDS_Edge& E2); + //! Returns the resolution on the 3d curve + Standard_EXPORT static Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D); + + //! Returns the resolution on the surface + Standard_EXPORT static Standard_Real PrecSurface(const Handle(Adaptor3d_HSurface)& aAHSurf); diff --git a/src/BRepCheck/BRepCheck_Edge.cxx b/src/BRepCheck/BRepCheck_Edge.cxx index b65d247453..9bc292a9e4 100644 --- a/src/BRepCheck/BRepCheck_Edge.cxx +++ b/src/BRepCheck/BRepCheck_Edge.cxx @@ -77,10 +77,6 @@ static static Standard_Real Prec(const Adaptor3d_Curve& aAC3D, const Adaptor3d_CurveOnSurface& aACS); -static - Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D); -static - Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS); //static Standard_Boolean Validate(const Adaptor3d_Curve&, // const Adaptor3d_Curve&, @@ -898,87 +894,23 @@ Standard_Boolean Validate(const Adaptor3d_Curve& CRef, return Status ; } + //======================================================================= //function : Prec //purpose : //======================================================================= Standard_Real Prec(const Adaptor3d_Curve& aAC3D, - const Adaptor3d_CurveOnSurface& aACS) + const Adaptor3d_CurveOnSurface& aACS) { Standard_Real aXEmax, aXC, aXS; + const Handle(Adaptor3d_HSurface)& aAHS = aACS.GetSurface(); // - aXC=PrecCurve(aAC3D); - aXS=PrecSurface(aACS); - aXEmax=(aXC>aXS) ? aXC: aXS; - return aXEmax; -} -//======================================================================= -//function : PrecCurve -//purpose : -//======================================================================= -Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D) -{ - Standard_Real aXEmax; - GeomAbs_CurveType aCT; - // - aXEmax=RealEpsilon(); - // - aCT=aAC3D.GetType(); - if (aCT==GeomAbs_Ellipse) { - Standard_Integer i; - Standard_Real aX[5], aXE; - // - gp_Elips aEL3D=aAC3D.Ellipse(); - aEL3D.Location().Coord(aX[0], aX[1], aX[2]); - aX[3]=aEL3D.MajorRadius(); - aX[4]=aEL3D.MinorRadius(); - aXEmax=-1.; - for (i=0; i<5; ++i) { - if (aX[i]<0.) { - aX[i]=-aX[i]; - } - aXE=Epsilon(aX[i]); - if (aXE>aXEmax) { - aXEmax=aXE; - } - } - }//if (aCT=GeomAbs_Ellipse) { - // - return aXEmax; -} -//======================================================================= -//function : PrecSurface -//purpose : -//======================================================================= -Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS) -{ - Standard_Real aXEmax; - GeomAbs_SurfaceType aST; - // - aXEmax=RealEpsilon(); - // - const Handle(Adaptor3d_HSurface)& aAHS=aACS.GetSurface(); - aST=aAHS->GetType(); - if (aST==GeomAbs_Cone) { - gp_Cone aCone=aAHS->Cone(); - Standard_Integer i; - Standard_Real aX[4], aXE; - // - aCone.Location().Coord(aX[0], aX[1], aX[2]); - aX[3]=aCone.RefRadius(); - aXEmax=-1.; - for (i=0; i<4; ++i) { - if (aX[i]<0.) { - aX[i]=-aX[i]; - } - aXE=Epsilon(aX[i]); - if (aXE>aXEmax) { - aXEmax=aXE; - } - } - }//if (aST==GeomAbs_Cone) { + aXC = BRepCheck::PrecCurve(aAC3D); + aXS = BRepCheck::PrecSurface(aAHS); + aXEmax = (aXC>aXS) ? aXC: aXS; return aXEmax; } + //======================================================================= //function : PrintProblematicPoint //purpose : diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx index f07d7e659b..f6006c5d38 100644 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1311,6 +1312,8 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, } GAC.Load(C3d,f3d,l3d); + Standard_Real Prec_C3d = BRepCheck::PrecCurve(GAC); + Standard_Boolean IsSameP = 1; Standard_Real maxdist = 0.; @@ -1597,7 +1600,9 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge, // Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898 Begin if (!IsSameP) { - if (anEdgeTol >= error) { + Standard_Real Prec_Surf = BRepCheck::PrecSurface(HS); + Standard_Real CurTol = anEdgeTol + Max(Prec_C3d, Prec_Surf); + if (CurTol >= error) { maxdist = Max(maxdist, anEdgeTol); IsSameP = Standard_True; } diff --git a/tests/bugs/modalg_7/bug30363 b/tests/bugs/modalg_7/bug30363 new file mode 100644 index 0000000000..7ccf30e853 --- /dev/null +++ b/tests/bugs/modalg_7/bug30363 @@ -0,0 +1,10 @@ +puts "==========================================================================" +puts "OCC30363: BRepLib::SameParameter with option 'forced' corrupts valid shape" +puts "==========================================================================" +puts "" + +restore [locate_data_file bug30363_shell_3faces.brep] a +checkshape a + +fsameparameter a 1.e-7 +checkshape a