From 2c12770c38dabffdedd03aa3ba0f990d65b6a9f0 Mon Sep 17 00:00:00 2001 From: osa Date: Wed, 11 Feb 2015 16:14:05 +0300 Subject: [PATCH] 0025814: Visualization, Prs3d_WFShape::AddPolygon() - always use polygonal representation from edge regardless from requested deflection --- src/Prs3d/Prs3d_WFShape.cxx | 71 ++++++++++++++++--------------------- src/Prs3d/Prs3d_WFShape.hxx | 1 - tests/bugs/vis/bug25814 | 43 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 tests/bugs/vis/bug25814 diff --git a/src/Prs3d/Prs3d_WFShape.cxx b/src/Prs3d/Prs3d_WFShape.cxx index de6a9e0697..2d0a7f1c32 100755 --- a/src/Prs3d/Prs3d_WFShape.cxx +++ b/src/Prs3d/Prs3d_WFShape.cxx @@ -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 - { - for (; anIndex <= aPoints.Upper(); ++anIndex) - { - thePoints.Append (aPoints.Value (anIndex).Transformed (aLocation)); - } - } - return Standard_True; } + else + { + for (; anIndex <= aPoints.Upper(); ++anIndex) + { + thePoints.Append (aPoints.Value (anIndex).Transformed (aLocation)); + } + } + 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 - { - for (; anIndex <= anIndices.Upper(); ++anIndex) - { - thePoints.Append (aNodes (anIndices (anIndex)).Transformed (aLocation)); - } - } - return Standard_True; } + else + { + for (; anIndex <= anIndices.Upper(); ++anIndex) + { + thePoints.Append (aNodes (anIndices (anIndex)).Transformed (aLocation)); + } + } + 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)) { diff --git a/src/Prs3d/Prs3d_WFShape.hxx b/src/Prs3d/Prs3d_WFShape.hxx index 845e81a642..32d6b12023 100755 --- a/src/Prs3d/Prs3d_WFShape.hxx +++ b/src/Prs3d/Prs3d_WFShape.hxx @@ -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 index 0000000000..c7fbd442e1 --- /dev/null +++ b/tests/bugs/vis/bug25814 @@ -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" +}