mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-05-16 10:54:53 +03:00
0023785: Crash on make face from wire
Adding test case for this fix
This commit is contained in:
parent
de75ed09ad
commit
26347898a8
@ -78,30 +78,30 @@ static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints,
|
|||||||
|
|
||||||
return dfMaxDist;
|
return dfMaxDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Is2DConnected
|
//function : Is2DConnected
|
||||||
//purpose : Return true if the last vertex of theEdge1 coincides with
|
//purpose : Return true if the last vertex of theEdge1 coincides with
|
||||||
// the first vertex of theEdge2 in parametric space of theFace
|
// the first vertex of theEdge2 in parametric space of theFace
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1,
|
||||||
inline static Standard_Boolean Is2DConnected( const TopoDS_Edge& theEdge1,
|
const TopoDS_Edge& theEdge2,
|
||||||
const TopoDS_Edge& theEdge2,
|
const Handle(Geom_Surface)& theSurface,
|
||||||
const TopoDS_Face& theFace )
|
const TopLoc_Location& theLocation)
|
||||||
{
|
{
|
||||||
Standard_Real f,l;
|
Standard_Real f,l;
|
||||||
|
//TopLoc_Location aLoc;
|
||||||
Handle(Geom2d_Curve) aCurve;
|
Handle(Geom2d_Curve) aCurve;
|
||||||
gp_Pnt2d p1, p2;
|
gp_Pnt2d p1, p2;
|
||||||
|
|
||||||
// get 2D points
|
// 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 );
|
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 );
|
p2 = aCurve->Value( theEdge2.Orientation() == TopAbs_FORWARD ? f : l );
|
||||||
|
|
||||||
// compare 2D points
|
// compare 2D points
|
||||||
BRepAdaptor_Surface aSurface( theFace );
|
GeomAdaptor_Surface aSurface( theSurface );
|
||||||
TopoDS_Vertex aV = TopExp::FirstVertex( theEdge2, /*CumOri=*/Standard_True );
|
TopoDS_Vertex aV = TopExp::FirstVertex( theEdge2, Standard_True );
|
||||||
Standard_Real tol3D = BRep_Tool::Tolerance( aV );
|
Standard_Real tol3D = BRep_Tool::Tolerance( aV );
|
||||||
Standard_Real tol2D = aSurface.UResolution( tol3D ) + aSurface.VResolution( tol3D );
|
Standard_Real tol2D = aSurface.UResolution( tol3D ) + aSurface.VResolution( tol3D );
|
||||||
Standard_Real dist2 = p1.SquareDistance( p2 );
|
Standard_Real dist2 = p1.SquareDistance( p2 );
|
||||||
@ -114,15 +114,17 @@ inline static Standard_Boolean Is2DConnected( const TopoDS_Edge& theEdge1,
|
|||||||
// parametric space of theSurface
|
// parametric space of theSurface
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
static Standard_Boolean Is2DClosed( const TopoDS_Shape& theShape,
|
static Standard_Boolean Is2DClosed(const TopoDS_Shape& theShape,
|
||||||
const Handle(Geom_Surface)& theSurface)
|
const Handle(Geom_Surface)& theSurface,
|
||||||
|
const TopLoc_Location& theLocation)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// get a wire theShape
|
// get a wire theShape
|
||||||
TopExp_Explorer aWireExp( theShape, TopAbs_WIRE );
|
TopExp_Explorer aWireExp( theShape, TopAbs_WIRE );
|
||||||
if ( !aWireExp.More() )
|
if ( !aWireExp.More() ) {
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
}
|
||||||
TopoDS_Wire aWire = TopoDS::Wire( aWireExp.Current() );
|
TopoDS_Wire aWire = TopoDS::Wire( aWireExp.Current() );
|
||||||
// a tmp face
|
// a tmp face
|
||||||
TopoDS_Face aTmpFace = BRepLib_MakeFace( theSurface, Precision::PConfusion() );
|
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
|
// check topological closeness using wire explorer, if the wire is not closed
|
||||||
// the 1st and the last vertices of wire are different
|
// the 1st and the last vertices of wire are different
|
||||||
BRepTools_WireExplorer aWireExplorer( aWire, aTmpFace );
|
BRepTools_WireExplorer aWireExplorer( aWire, aTmpFace );
|
||||||
if ( !aWireExplorer.More())
|
if ( !aWireExplorer.More()) {
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
}
|
||||||
// remember the 1st and the last edges of aWire
|
// remember the 1st and the last edges of aWire
|
||||||
TopoDS_Edge aFisrtEdge = aWireExplorer.Current(), aLastEdge = aFisrtEdge;
|
TopoDS_Edge aFisrtEdge = aWireExplorer.Current(), aLastEdge = aFisrtEdge;
|
||||||
// check if edges connected topologically (that is assured by BRepTools_WireExplorer)
|
// check if edges connected topologically (that is assured by BRepTools_WireExplorer)
|
||||||
// are connected in 2D
|
// are connected in 2D
|
||||||
TopoDS_Edge aPrevEdge = aFisrtEdge;
|
TopoDS_Edge aPrevEdge = aFisrtEdge;
|
||||||
for ( aWireExplorer.Next(); aWireExplorer.More(); aWireExplorer.Next() )
|
for ( aWireExplorer.Next(); aWireExplorer.More(); aWireExplorer.Next() ) {
|
||||||
{
|
|
||||||
aLastEdge = aWireExplorer.Current();
|
aLastEdge = aWireExplorer.Current();
|
||||||
if ( !Is2DConnected( aPrevEdge, aLastEdge, aTmpFace ))
|
if ( !Is2DConnected( aPrevEdge, aLastEdge, theSurface, theLocation)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
aPrevEdge = aLastEdge;
|
aPrevEdge = aLastEdge;
|
||||||
}
|
}
|
||||||
// wire is closed if ( 1st vertex of aFisrtEdge ) ==
|
// wire is closed if ( 1st vertex of aFisrtEdge ) ==
|
||||||
// ( last vertex of aLastEdge ) in 2D
|
// ( last vertex of aLastEdge ) in 2D
|
||||||
TopoDS_Vertex aV1 = TopExp::FirstVertex( aFisrtEdge, /*CumOri=*/Standard_True );
|
TopoDS_Vertex aV1 = TopExp::FirstVertex( aFisrtEdge, Standard_True );
|
||||||
TopoDS_Vertex aV2 = TopExp::LastVertex( aLastEdge, /*CumOri=*/Standard_True );
|
TopoDS_Vertex aV2 = TopExp::LastVertex( aLastEdge, Standard_True );
|
||||||
return ( aV1.IsSame( aV2 ) && Is2DConnected( aLastEdge, aFisrtEdge, aTmpFace ));
|
return ( aV1.IsSame( aV2 ) && Is2DConnected( aLastEdge, aFisrtEdge, theSurface, theLocation));
|
||||||
}
|
}
|
||||||
catch ( Standard_Failure )
|
catch ( Standard_Failure ) {
|
||||||
{
|
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : BRepLib_FindSurface
|
//function : BRepLib_FindSurface
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -250,7 +251,7 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
|
|||||||
if (!mySurface.IsNull())
|
if (!mySurface.IsNull())
|
||||||
// if S is e.g. the bottom face of a cylinder, mySurface can be the
|
// 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
|
// lateral (cylindrical) face of the cylinder; reject an improper mySurface
|
||||||
if ( !OnlyClosed || Is2DClosed( S, mySurface ))
|
if ( !OnlyClosed || Is2DClosed( S, mySurface, myLocation ))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,3 +541,4 @@ TopLoc_Location BRepLib_FindSurface::Location() const
|
|||||||
{
|
{
|
||||||
return myLocation;
|
return myLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W,
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Find a surface through the wire
|
// 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()) {
|
if (!FS.Found()) {
|
||||||
myError = BRepLib_NotPlanar;
|
myError = BRepLib_NotPlanar;
|
||||||
return;
|
return;
|
||||||
@ -268,9 +268,11 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W,
|
|||||||
|
|
||||||
B.MakeFace(TopoDS::Face(myShape),FS.Surface(),FS.Location(),tol);
|
B.MakeFace(TopoDS::Face(myShape),FS.Surface(),FS.Location(),tol);
|
||||||
Add(W);
|
Add(W);
|
||||||
|
//
|
||||||
BRepLib::UpdateTolerances(myShape);
|
BRepLib::UpdateTolerances(myShape);
|
||||||
|
//
|
||||||
|
BRepLib::SameParameter(myShape, tol, Standard_True);
|
||||||
|
//
|
||||||
CheckInside();
|
CheckInside();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
tests/bugs/modalg_5/bug23785
Executable file
15
tests/bugs/modalg_5/bug23785
Executable file
@ -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
|
@ -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
|
restore [locate_data_file offset_wire_089.brep] s
|
||||||
|
|
||||||
set length 953.42
|
set length 953.42
|
||||||
|
@ -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
|
restore [locate_data_file offset_wire_089.brep] s
|
||||||
|
|
||||||
set length 1110.06
|
set length 1110.06
|
||||||
|
@ -1,18 +1,7 @@
|
|||||||
set os "ALL"
|
puts "TODO ?OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_"
|
||||||
if {[array get env os_type] != ""} {
|
puts "TODO ?OCC23068 ALL: Error : result is not a topological shape"
|
||||||
set os $env(os_type)
|
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
|
restore [locate_data_file offset_wire_059.brep] s
|
||||||
|
|
||||||
set length 347.204
|
set length 347.204
|
||||||
|
@ -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
|
restore [locate_data_file offset_wire_068.brep] s
|
||||||
|
|
||||||
set length 1589.9
|
set length 1589.9
|
||||||
|
@ -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"
|
puts "TODO OCC23068 ALL: Error : The resulting shape is WRONG"
|
||||||
restore [locate_data_file offset_wire_027.brep] s
|
restore [locate_data_file offset_wire_027.brep] s
|
||||||
|
|
||||||
|
17
tests/offset/wire_unclosed_outside_0_075/A8
Normal file → Executable file
17
tests/offset/wire_unclosed_outside_0_075/A8
Normal file → Executable file
@ -1,19 +1,5 @@
|
|||||||
puts "TODO OCC23068 ALL: Error : big tolerance of shape result"
|
puts "TODO OCC23068 ALL: Error : big tolerance of shape result"
|
||||||
set os "ALL"
|
puts "TODO ?OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_"
|
||||||
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
restore [locate_data_file offset_wire_026.brep] s
|
restore [locate_data_file offset_wire_026.brep] s
|
||||||
|
|
||||||
@ -21,4 +7,3 @@ set length 25688.3
|
|||||||
set nbsh_v 319
|
set nbsh_v 319
|
||||||
set nbsh_e 319
|
set nbsh_e 319
|
||||||
set nbsh_w 1
|
set nbsh_w 1
|
||||||
|
|
||||||
|
15
tests/offset/wire_unclosed_outside_0_075/A9
Normal file → Executable file
15
tests/offset/wire_unclosed_outside_0_075/A9
Normal file → Executable file
@ -1,19 +1,6 @@
|
|||||||
puts "TODO OCC23068 ALL: Error : The length of the resulting shape is"
|
puts "TODO OCC23068 ALL: Error : The length of the resulting shape is"
|
||||||
puts "TODO OCC23068 ALL: Error : The resulting shape is WRONG"
|
puts "TODO OCC23068 ALL: Error : The resulting shape is WRONG"
|
||||||
set os "ALL"
|
puts "TODO ?OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_"
|
||||||
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
restore [locate_data_file offset_wire_027.brep] s
|
restore [locate_data_file offset_wire_027.brep] s
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user