1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0030292: Modeling Algorithms - BRepBndLib should avoid using Poly_Polygon3D when called with useTriangulation set to false

BRepBndLib.cxx : treatment of useTriangulation is modified according to specified behavior of algorithm
BRepTest_CurveCommands.cxx : creation edge from polygon3d is added in Draw command mkedge.
This commit is contained in:
akaftasev 2023-02-06 14:17:10 +03:00 committed by Vadim Glukhikh
parent 44be123039
commit 6d140acb14
3 changed files with 87 additions and 4 deletions

View File

@ -127,6 +127,14 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next())
{
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
if (!useTriangulation && BRep_Tool::IsGeometric(E))
{
BC.Initialize(E);
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(E), B);
continue;
}
Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
if (!P3d.IsNull() && P3d->NbNodes() > 0)
{
@ -143,7 +151,7 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
else
{
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
if (useTriangulation && !Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
if (!Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
{
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
nbNodes = Indices.Length();

View File

@ -281,9 +281,11 @@ static Standard_Integer mkedge(Draw_Interpretor& di, Standard_Integer n, const c
Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
Handle(Geom2d_Curve) C2d = DrawTrSurf::GetCurve2d(a[2]);
if (C.IsNull() && C2d.IsNull()) {
Handle(Poly_Polygon3D) P3d = DrawTrSurf::GetPolygon3D(a[2]);
if (C.IsNull() && C2d.IsNull() && P3d.IsNull()) {
//std::cout << a[2] << " is not a curve" << std::endl;
di << a[2] << " is not a curve\n";
di << a[2] << " is not a curve or polygon 3d\n";
return 1;
}
@ -291,7 +293,12 @@ static Standard_Integer mkedge(Draw_Interpretor& di, Standard_Integer n, const c
if (n == 3) {
if (!C.IsNull()) edge = BRepBuilderAPI_MakeEdge(C);
else edge = BRepBuilderAPI_MakeEdge2d(C2d);
else if (!C2d.IsNull()) edge = BRepBuilderAPI_MakeEdge2d(C2d);
else
{
BRep_Builder aBB;
aBB.MakeEdge(edge, P3d);
}
}
else {
Handle(Geom_Surface) S;

View File

@ -0,0 +1,68 @@
puts "========"
puts "0030292: Modeling Algorithms - BRepBndLib should avoid using Poly_Polygon3D when called with useTriangulation set to false"
puts "========"
puts ""
## geometric edge without any discrete representations
circle c 0 0 0 1
mkedge e c
set res1 [bounding e]
set res2 [bounding e -noTriangulation]
if {$res1 != $res2} {
puts "Error: bounding boxes are different for geometric edge"
}
## geometric edge with polygon 3d
incmesh e 0.1
set res1_ref "-1.1000000999999999 -1.0927089740980542 -0.10000010000000001 1.1000000999999999 1.092708974098054 0.10000010000000001"
set res2_ref "-1.0000001000000001 -1.0000001000000001 -9.9999999999999995e-08 1.0000001000000001 1.0000001000000001 9.9999999999999995e-08"
unset res1
set res1 [bounding e]
foreach dd $res1 {
if ![regexp $dd $res1_ref] {
puts "Error: bounding box is wrong"
}
}
unset res2
set res2 [bounding e -noTriangulation]
foreach dd $res2 {
if ![regexp $dd $res2_ref] {
puts "Error: bounding box is wrong"
}
}
## geometric edge with polygon on triangulation
pcylinder cyl 1 1
incmesh cyl 0.1
explode cyl e
renamevar cyl_3 e
unset res1
set res1 [bounding e]
foreach dd $res1 {
if ![regexp $dd $res1_ref] {
puts "Error: bounding box is wrong"
}
}
unset res2
set res2 [bounding e -noTriangulation]
foreach dd $res2 {
if ![regexp $dd $res2_ref] {
puts "Error: bounding box is wrong"
}
}
## not geometric edge with polygon 3d
polygon3d pol3d 5 1 0 0 0 1 0 -1 0 0 0 -1 0 1 0 0
mkedge e pol3d
unset res1
set res1 [bounding e]
unset res2
set res2 [bounding e -noTriangulation]
if {$res1 != $res2} {
puts "Error: bounding boxes are different for not geometric edge"
}