]> OCCT Git - occt.git/commitdiff
0030292: Modeling Algorithms - BRepBndLib should avoid using Poly_Polygon3D when...
authorakaftasev <akaftasev@opencascade.com>
Mon, 6 Feb 2023 11:17:10 +0000 (14:17 +0300)
committerVadim Glukhikh <vadim.glukhikh@opencascade.com>
Mon, 6 Feb 2023 17:51:52 +0000 (17:51 +0000)
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.

src/BRepBndLib/BRepBndLib.cxx
src/BRepTest/BRepTest_CurveCommands.cxx
tests/lowalgos/bnd/bug30292 [new file with mode: 0644]

index e8e3a9870846c94b29e5c0e99d5124d905fa8690..f3ab8ed86042bb6502deed0240a54c0993e0e30c 100644 (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();
index b0f58d031eeabe9e71bfff3a002b18e78e4c05dd..4bd39be3b7bd0f4d93a343fa52041e907a79f40e 100644 (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;
diff --git a/tests/lowalgos/bnd/bug30292 b/tests/lowalgos/bnd/bug30292
new file mode 100644 (file)
index 0000000..4bc136f
--- /dev/null
@@ -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"
+}
+