0028784: [HLR] Crash while getting hidden lines for a compound
authorjgv <jgv@opencascade.com>
Fri, 2 Jun 2017 14:26:10 +0000 (17:26 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 9 Jun 2017 09:58:49 +0000 (12:58 +0300)
Method HLRBRep_PolyHLRToShape::InternalCompound is modified: avoid creation an edge with null length.

Add testing Draw command.

src/HLRBRep/HLRBRep_PolyHLRToShape.cxx
src/QABugs/QABugs_20.cxx
tests/bugs/modalg_7/bug28784 [new file with mode: 0755]

index b91d1e6..771e082 100644 (file)
@@ -132,8 +132,13 @@ HLRBRep_PolyHLRToShape::InternalCompound (const Standard_Integer typ,
       if (todraw)
        if (!S.IsNull()) todraw = Map.Contains(BP.Shape());
       if (todraw) {
-       B.Add(Result,BRepLib_MakeEdge2d(BP.P1(),BP.P2()));
-       added = Standard_True;
+        const gp_Pnt2d& FirstP2d = BP.P1();
+        const gp_Pnt2d& LastP2d  = BP.P2();
+        if (FirstP2d.SquareDistance(LastP2d) > 1.e-20)
+        {
+          B.Add(Result,BRepLib_MakeEdge2d(BP.P1(),BP.P2()));
+          added = Standard_True;
+        }
       }
     }
   }
@@ -156,7 +161,7 @@ HLRBRep_PolyHLRToShape::InternalCompound (const Standard_Integer typ,
   const gp_XY aSta2D(aSta.X(), aSta.Y());
   const gp_XY aEnd2D(aEnd.X(), aEnd.Y());
   const gp_XY aD = aEnd2D - aSta2D;
-       if (aD.Modulus() > 1.e-10) {
+       if (aD.SquareModulus() > 1.e-20) {
          B.Add(Result,BRepLib_MakeEdge2d(aSta2D, aEnd2D));
          added = Standard_True;
        }
index 6bb1271..dfeaecc 100644 (file)
@@ -56,6 +56,8 @@
 #include <XCAFDoc_ShapeTool.hxx>
 
 #include <HLRAppli_ReflectLines.hxx>
+#include <HLRBRep_PolyHLRToShape.hxx>
+#include <HLRBRep_PolyAlgo.hxx>
 
 //=======================================================================
 //function : SurfaceGenOCC26675_1 
@@ -2305,6 +2307,32 @@ static Standard_Integer OCC28594(Draw_Interpretor& di, Standard_Integer argc, co
   return 0;
 }
 
+static Standard_Integer OCC28784(Draw_Interpretor&, Standard_Integer argc, const char** argv)
+{
+  if (argc < 3)
+    return 1;
+
+  TopoDS_Shape aShape =  DBRep::Get(argv[2]);
+  if (aShape.IsNull())
+    return 1;
+
+  gp_Ax2 aPlane (gp::Origin(), gp::DX(), -gp::DZ());
+  HLRAlgo_Projector aProjector(aPlane);
+
+  Handle(HLRBRep_PolyAlgo) aHLR = new HLRBRep_PolyAlgo(aShape);
+  aHLR->Projector(aProjector);
+  aHLR->Update();
+
+  HLRBRep_PolyHLRToShape aHLRtoShape;
+  aHLRtoShape.Update(aHLR);
+
+  TopoDS_Shape aHidden = aHLRtoShape.HCompound();
+  
+  DBRep::Set(argv[1], aHidden);
+
+  return 0;
+}
+
 void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -2326,6 +2354,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC27875", "OCC27875 curve", __FILE__, OCC27875, group);
   theCommands.Add("OCC28389", "OCC28389", __FILE__, OCC28389, group);
   theCommands.Add("OCC28594", "OCC28594", __FILE__, OCC28594, group);
+  theCommands.Add("OCC28784", "OCC28784 result shape", __FILE__, OCC28784, group);
 
   return;
 }
diff --git a/tests/bugs/modalg_7/bug28784 b/tests/bugs/modalg_7/bug28784
new file mode 100755 (executable)
index 0000000..5289bd6
--- /dev/null
@@ -0,0 +1,20 @@
+puts "========"
+puts "OCC28784"
+puts "========"
+puts ""
+#######################################################
+# [HLR] Crash while getting hidden lines for a compound
+#######################################################
+
+pload QAcommands
+
+restore [locate_data_file bug28784_MHX_SKG_MS_Pos1_simplified.brep] a
+OCC28784 result a
+
+checknbshapes result -edge 236
+
+smallview
+top
+donly result
+fit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png