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

0025814: Visualization, Prs3d_WFShape::AddPolygon() - always use polygonal representation from edge regardless from requested deflection

This commit is contained in:
osa 2015-02-11 16:14:05 +03:00 committed by bugmaster
parent 20f319cdb8
commit 2c12770c38
3 changed files with 74 additions and 41 deletions

View File

@ -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))
{

View File

@ -105,7 +105,6 @@ public:
private:
static Standard_Boolean AddPolygon (const TopoDS_Edge& theEdge,
const Standard_Real theDeflection,
TColgp_SequenceOfPnt& thePoints);
private:

43
tests/bugs/vis/bug25814 Normal file
View File

@ -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"
}