0025814: Visualization, Prs3d_WFShape::AddPolygon() - always use polygonal representa...
authorosa <osa@opencascade.com>
Wed, 11 Feb 2015 13:14:05 +0000 (16:14 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 12 Feb 2015 09:17:00 +0000 (12:17 +0300)
src/Prs3d/Prs3d_WFShape.cxx
src/Prs3d/Prs3d_WFShape.hxx
tests/bugs/vis/bug25814 [new file with mode: 0644]

index de6a9e0..2d0a7f1 100755 (executable)
@@ -67,35 +67,29 @@ namespace
 // purpose :
 // =========================================================================
 Standard_Boolean Prs3d_WFShape::AddPolygon (const TopoDS_Edge&    theEdge,
-                                            const Standard_Real   theDeflection,
                                             TColgp_SequenceOfPnt& thePoints)
 {
   TopLoc_Location aLocation;
-  Standard_Real aFirst, aLast;
-  Handle(Geom_Curve)     aCurve3d = BRep_Tool::Curve     (theEdge, aFirst, aLast);
   Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
   if (!aPolygon.IsNull())
   {
-    if ((aPolygon->Deflection() <= theDeflection) || aCurve3d.IsNull())
+    const TColgp_Array1OfPnt& aPoints = aPolygon->Nodes();
+    Standard_Integer anIndex = aPoints.Lower();
+    if (aLocation.IsIdentity())
     {
-      const TColgp_Array1OfPnt& aPoints = aPolygon->Nodes();
-      Standard_Integer anIndex = aPoints.Lower();
-      if (aLocation.IsIdentity())
+      for (; anIndex <= aPoints.Upper(); ++anIndex)
       {
-        for (; anIndex <= aPoints.Upper(); ++anIndex)
-        {
-          thePoints.Append (aPoints.Value (anIndex));
-        }
+        thePoints.Append (aPoints.Value (anIndex));
       }
-      else
+    }
+    else
+    {
+      for (; anIndex <= aPoints.Upper(); ++anIndex)
       {
-        for (; anIndex <= aPoints.Upper(); ++anIndex)
-        {
-          thePoints.Append (aPoints.Value (anIndex).Transformed (aLocation));
-        }
+        thePoints.Append (aPoints.Value (anIndex).Transformed (aLocation));
       }
-      return Standard_True;
     }
+    return Standard_True;
   }
 
   Handle(Poly_Triangulation)          aTriangulation;
@@ -103,28 +97,25 @@ Standard_Boolean Prs3d_WFShape::AddPolygon (const TopoDS_Edge&    theEdge,
   BRep_Tool::PolygonOnTriangulation (theEdge, aHIndices, aTriangulation, aLocation);
   if (!aHIndices.IsNull())
   {
-    if ((aHIndices->Deflection() <= theDeflection) || aCurve3d.IsNull())
-    {
-      const TColStd_Array1OfInteger& anIndices = aHIndices->Nodes();
-      const TColgp_Array1OfPnt&      aNodes    = aTriangulation->Nodes();
+    const TColStd_Array1OfInteger& anIndices = aHIndices->Nodes();
+    const TColgp_Array1OfPnt&      aNodes    = aTriangulation->Nodes();
 
-      Standard_Integer anIndex = anIndices.Lower();
-      if (aLocation.IsIdentity())
+    Standard_Integer anIndex = anIndices.Lower();
+    if (aLocation.IsIdentity())
+    {
+      for (; anIndex <= anIndices.Upper(); ++anIndex)
       {
-        for (; anIndex <= anIndices.Upper(); ++anIndex)
-        {
-          thePoints.Append (aNodes (anIndices (anIndex)));
-        }
+        thePoints.Append (aNodes (anIndices (anIndex)));
       }
-      else
+    }
+    else
+    {
+      for (; anIndex <= anIndices.Upper(); ++anIndex)
       {
-        for (; anIndex <= anIndices.Upper(); ++anIndex)
-        {
-          thePoints.Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
-        }
+        thePoints.Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
       }
-      return Standard_True;
     }
+    return Standard_True;
   }
   return Standard_False;
 }
@@ -429,7 +420,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
       {
         OCC_CATCH_SIGNALS
         const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
-        if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
+        if (!AddPolygon (anEdge, aPoints->ChangeSequence()))
         {
           if (BRep_Tool::IsGeometric (anEdge))
           {
@@ -465,7 +456,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
         {
           OCC_CATCH_SIGNALS
           const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
-          if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
+          if (!AddPolygon (anEdge, aPoints->ChangeSequence()))
           {
             if (BRep_Tool::IsGeometric (anEdge))
             {
@@ -500,7 +491,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
       {
         OCC_CATCH_SIGNALS
         const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
-        if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
+        if (!AddPolygon (anEdge, aPoints->ChangeSequence()))
         {
           if (BRep_Tool::IsGeometric (anEdge))
           {
index 845e81a..32d6b12 100755 (executable)
@@ -105,7 +105,6 @@ public:
 private:
 
   static Standard_Boolean AddPolygon (const TopoDS_Edge&    theEdge,
-                                      const Standard_Real   theDeflection,
                                       TColgp_SequenceOfPnt& thePoints);
 
 private:
diff --git a/tests/bugs/vis/bug25814 b/tests/bugs/vis/bug25814
new file mode 100644 (file)
index 0000000..c7fbd44
--- /dev/null
@@ -0,0 +1,43 @@
+puts "============"
+puts "CR25814"
+puts "Check that the discretization of the sub-shape is identical in shaded and wireframe modes"
+puts "if the whole shape was already displayed"
+puts "============"
+puts ""
+
+set aSubShapeTriang $imagedir/${casename}_subshape_triangulation.png
+set aShapeTriang $imagedir/${casename}_shape_triangulation.png
+set aDiff $imagedir/${casename}_diff.png
+
+pcylinder c 100 350
+explode c f
+
+vinit View1 w=900 h=900
+vclear
+vsetdispmode 1
+
+vdisplay c_3
+vfit
+vzoom 4
+vtranslateview 70 20 0
+vmoveto 200 200
+vdump $aSubShapeTriang
+
+vclear
+tclean c_3
+
+vdisplay c
+vfit
+vclear
+
+vdisplay c_3
+vfit
+vzoom 4
+vtranslateview 70 20 0
+vmoveto 200 200
+vdump $aShapeTriang
+
+set aDiffRes [diffimage $aSubShapeTriang $aShapeTriang 0.1 0 0 $aDiff]
+if {$aDiffRes != 0} {
+  puts "ERROR : Test failed: there is a difference between images. Discretization of the sub-shape in wireframe mode is incorrect"
+}