diff --git a/src/BRepLib/BRepLib_FindSurface.cxx b/src/BRepLib/BRepLib_FindSurface.cxx index f314b2c701..e3cfbf01d4 100755 --- a/src/BRepLib/BRepLib_FindSurface.cxx +++ b/src/BRepLib/BRepLib_FindSurface.cxx @@ -78,30 +78,30 @@ static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints, return dfMaxDist; } - //======================================================================= //function : Is2DConnected //purpose : Return true if the last vertex of theEdge1 coincides with // the first vertex of theEdge2 in parametric space of theFace //======================================================================= - -inline static Standard_Boolean Is2DConnected( const TopoDS_Edge& theEdge1, - const TopoDS_Edge& theEdge2, - const TopoDS_Face& theFace ) +inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1, + const TopoDS_Edge& theEdge2, + const Handle(Geom_Surface)& theSurface, + const TopLoc_Location& theLocation) { Standard_Real f,l; + //TopLoc_Location aLoc; Handle(Geom2d_Curve) aCurve; gp_Pnt2d p1, p2; // get 2D points - aCurve = BRep_Tool::CurveOnSurface( theEdge1, theFace,f,l ); + aCurve=BRep_Tool::CurveOnSurface(theEdge1, theSurface, theLocation, f, l); p1 = aCurve->Value( theEdge1.Orientation() == TopAbs_FORWARD ? l : f ); - aCurve = BRep_Tool::CurveOnSurface( theEdge2, theFace,f,l ); + aCurve=BRep_Tool::CurveOnSurface(theEdge2, theSurface, theLocation, f, l); p2 = aCurve->Value( theEdge2.Orientation() == TopAbs_FORWARD ? f : l ); // compare 2D points - BRepAdaptor_Surface aSurface( theFace ); - TopoDS_Vertex aV = TopExp::FirstVertex( theEdge2, /*CumOri=*/Standard_True ); + GeomAdaptor_Surface aSurface( theSurface ); + TopoDS_Vertex aV = TopExp::FirstVertex( theEdge2, Standard_True ); Standard_Real tol3D = BRep_Tool::Tolerance( aV ); Standard_Real tol2D = aSurface.UResolution( tol3D ) + aSurface.VResolution( tol3D ); Standard_Real dist2 = p1.SquareDistance( p2 ); @@ -114,15 +114,17 @@ inline static Standard_Boolean Is2DConnected( const TopoDS_Edge& theEdge1, // parametric space of theSurface //======================================================================= -static Standard_Boolean Is2DClosed( const TopoDS_Shape& theShape, - const Handle(Geom_Surface)& theSurface) +static Standard_Boolean Is2DClosed(const TopoDS_Shape& theShape, + const Handle(Geom_Surface)& theSurface, + const TopLoc_Location& theLocation) { try { // get a wire theShape TopExp_Explorer aWireExp( theShape, TopAbs_WIRE ); - if ( !aWireExp.More() ) + if ( !aWireExp.More() ) { return Standard_False; + } TopoDS_Wire aWire = TopoDS::Wire( aWireExp.Current() ); // a tmp face TopoDS_Face aTmpFace = BRepLib_MakeFace( theSurface, Precision::PConfusion() ); @@ -130,32 +132,31 @@ static Standard_Boolean Is2DClosed( const TopoDS_Shape& theShape, // check topological closeness using wire explorer, if the wire is not closed // the 1st and the last vertices of wire are different BRepTools_WireExplorer aWireExplorer( aWire, aTmpFace ); - if ( !aWireExplorer.More()) + if ( !aWireExplorer.More()) { return Standard_False; + } // remember the 1st and the last edges of aWire TopoDS_Edge aFisrtEdge = aWireExplorer.Current(), aLastEdge = aFisrtEdge; // check if edges connected topologically (that is assured by BRepTools_WireExplorer) // are connected in 2D TopoDS_Edge aPrevEdge = aFisrtEdge; - for ( aWireExplorer.Next(); aWireExplorer.More(); aWireExplorer.Next() ) - { + for ( aWireExplorer.Next(); aWireExplorer.More(); aWireExplorer.Next() ) { aLastEdge = aWireExplorer.Current(); - if ( !Is2DConnected( aPrevEdge, aLastEdge, aTmpFace )) + if ( !Is2DConnected( aPrevEdge, aLastEdge, theSurface, theLocation)) { return false; + } aPrevEdge = aLastEdge; } // wire is closed if ( 1st vertex of aFisrtEdge ) == // ( last vertex of aLastEdge ) in 2D - TopoDS_Vertex aV1 = TopExp::FirstVertex( aFisrtEdge, /*CumOri=*/Standard_True ); - TopoDS_Vertex aV2 = TopExp::LastVertex( aLastEdge, /*CumOri=*/Standard_True ); - return ( aV1.IsSame( aV2 ) && Is2DConnected( aLastEdge, aFisrtEdge, aTmpFace )); + TopoDS_Vertex aV1 = TopExp::FirstVertex( aFisrtEdge, Standard_True ); + TopoDS_Vertex aV2 = TopExp::LastVertex( aLastEdge, Standard_True ); + return ( aV1.IsSame( aV2 ) && Is2DConnected( aLastEdge, aFisrtEdge, theSurface, theLocation)); } - catch ( Standard_Failure ) - { + catch ( Standard_Failure ) { return Standard_False; } } - //======================================================================= //function : BRepLib_FindSurface //purpose : @@ -250,7 +251,7 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S, if (!mySurface.IsNull()) // if S is e.g. the bottom face of a cylinder, mySurface can be the // lateral (cylindrical) face of the cylinder; reject an improper mySurface - if ( !OnlyClosed || Is2DClosed( S, mySurface )) + if ( !OnlyClosed || Is2DClosed( S, mySurface, myLocation )) break; } @@ -540,3 +541,4 @@ TopLoc_Location BRepLib_FindSurface::Location() const { return myLocation; } + diff --git a/src/BRepLib/BRepLib_MakeFace.cxx b/src/BRepLib/BRepLib_MakeFace.cxx index 9168f687cb..0366b2164e 100755 --- a/src/BRepLib/BRepLib_MakeFace.cxx +++ b/src/BRepLib/BRepLib_MakeFace.cxx @@ -254,7 +254,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W, { // Find a surface through the wire - BRepLib_FindSurface FS(W, -1, OnlyPlane, /*OnlyClosed=*/Standard_True); + BRepLib_FindSurface FS(W, -1, OnlyPlane, Standard_True); if (!FS.Found()) { myError = BRepLib_NotPlanar; return; @@ -268,9 +268,11 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W, B.MakeFace(TopoDS::Face(myShape),FS.Surface(),FS.Location(),tol); Add(W); - + // BRepLib::UpdateTolerances(myShape); - + // + BRepLib::SameParameter(myShape, tol, Standard_True); + // CheckInside(); } diff --git a/tests/bugs/modalg_5/bug23785 b/tests/bugs/modalg_5/bug23785 new file mode 100755 index 0000000000..1ca1feda62 --- /dev/null +++ b/tests/bugs/modalg_5/bug23785 @@ -0,0 +1,15 @@ +puts "================" +puts "OCC23785" +puts "================" +puts "" +####################################################################### +# Crash on make face from wire +####################################################################### + +set BugNumber OCC23777 + +restore [locate_data_file bug23785_Wire_1.brep] w + +mkplane result w 0 + +set 2dviewer 1 diff --git a/tests/offset/wire_closed_inside_0_025/H3 b/tests/offset/wire_closed_inside_0_025/H3 index 52d22d0ef1..71b5e58c00 100644 --- a/tests/offset/wire_closed_inside_0_025/H3 +++ b/tests/offset/wire_closed_inside_0_025/H3 @@ -1,4 +1,4 @@ -puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_6" +puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" restore [locate_data_file offset_wire_089.brep] s set length 953.42 diff --git a/tests/offset/wire_closed_inside_0_075/H3 b/tests/offset/wire_closed_inside_0_075/H3 index dfd7cf6126..fa41564255 100644 --- a/tests/offset/wire_closed_inside_0_075/H3 +++ b/tests/offset/wire_closed_inside_0_075/H3 @@ -1,4 +1,4 @@ -puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_6" +puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" restore [locate_data_file offset_wire_089.brep] s set length 1110.06 diff --git a/tests/offset/wire_closed_outside_0_005/E8 b/tests/offset/wire_closed_outside_0_005/E8 index ab6d5acbef..2d57383cbc 100644 --- a/tests/offset/wire_closed_outside_0_005/E8 +++ b/tests/offset/wire_closed_outside_0_005/E8 @@ -1,18 +1,7 @@ -set os "ALL" -if {[array get env os_type] != ""} { - set os $env(os_type) -} +puts "TODO ?OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" +puts "TODO ?OCC23068 ALL: Error : result is not a topological shape" +puts "TODO ?OCC23068 ALL: Error : The offset cannot be built." -if { - [string compare $os "Mandriva2010"] == 0 - || [string compare $os "Debian40" ] == 0 - || [string compare $os "Mandriva2008"] == 0 - } { - puts "TODO OCC23068 $os: Faulty shapes in variables faulty_1 to faulty_26" -} else { - puts "TODO OCC23068 $os: Error : result is not a topological shape" - puts "TODO OCC23068 $os: Error : The offset cannot be built." -} restore [locate_data_file offset_wire_059.brep] s set length 347.204 diff --git a/tests/offset/wire_closed_outside_0_025/F8 b/tests/offset/wire_closed_outside_0_025/F8 index b9477d97cd..aa95130d02 100644 --- a/tests/offset/wire_closed_outside_0_025/F8 +++ b/tests/offset/wire_closed_outside_0_025/F8 @@ -1,4 +1,4 @@ -puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_7" +puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" restore [locate_data_file offset_wire_068.brep] s set length 1589.9 diff --git a/tests/offset/wire_unclosed_outside_0_025/A9 b/tests/offset/wire_unclosed_outside_0_025/A9 index 4b1f56fb5f..7eb7e1905d 100644 --- a/tests/offset/wire_unclosed_outside_0_025/A9 +++ b/tests/offset/wire_unclosed_outside_0_025/A9 @@ -1,4 +1,4 @@ -puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_48" +puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" puts "TODO OCC23068 ALL: Error : The resulting shape is WRONG" restore [locate_data_file offset_wire_027.brep] s diff --git a/tests/offset/wire_unclosed_outside_0_075/A8 b/tests/offset/wire_unclosed_outside_0_075/A8 old mode 100644 new mode 100755 index 873c79ef92..0fca866670 --- a/tests/offset/wire_unclosed_outside_0_075/A8 +++ b/tests/offset/wire_unclosed_outside_0_075/A8 @@ -1,19 +1,5 @@ puts "TODO OCC23068 ALL: Error : big tolerance of shape result" -set os "ALL" -if {[array get env os_type] != ""} { - set os $env(os_type) -} - -if { - [string compare $os "Mandriva2010"] == 0 - || [string compare $os "Debian40" ] == 0 - || [string compare $os "Mandriva2008"] == 0 - } { - puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_42" -} else { - puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_43" -} - +puts "TODO ?OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" restore [locate_data_file offset_wire_026.brep] s @@ -21,4 +7,3 @@ set length 25688.3 set nbsh_v 319 set nbsh_e 319 set nbsh_w 1 - diff --git a/tests/offset/wire_unclosed_outside_0_075/A9 b/tests/offset/wire_unclosed_outside_0_075/A9 old mode 100644 new mode 100755 index ea48c36d27..fecd86ebdb --- a/tests/offset/wire_unclosed_outside_0_075/A9 +++ b/tests/offset/wire_unclosed_outside_0_075/A9 @@ -1,19 +1,6 @@ puts "TODO OCC23068 ALL: Error : The length of the resulting shape is" puts "TODO OCC23068 ALL: Error : The resulting shape is WRONG" -set os "ALL" -if {[array get env os_type] != ""} { - set os $env(os_type) -} - -if { - [string compare $os "Mandriva2010"] == 0 - || [string compare $os "Debian40" ] == 0 - || [string compare $os "Mandriva2008"] == 0 - } { - puts "TODO OCC23068 $os: Faulty shapes in variables faulty_1 to faulty_26" -} else { - puts "TODO OCC23068 $os: Faulty shapes in variables faulty_1 to faulty_27" -} +puts "TODO ?OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" restore [locate_data_file offset_wire_027.brep] s