From 7bb2b8293aaf7114320faee740d4d31e36956880 Mon Sep 17 00:00:00 2001 From: vpa Date: Thu, 16 Apr 2015 11:19:05 +0300 Subject: [PATCH] 0026031: Visualization - fix out-of-range within Select3D_InteriorSensitivePointSet::GetPoints() Removed unnecessary point duplication at initialization of planar polygons in Select3D_InteriorSensitivePointSet; Test case for issue #26031 --- .../Select3D_InteriorSensitivePointSet.cxx | 7 +++-- tests/bugs/vis/bug26031 | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tests/bugs/vis/bug26031 diff --git a/src/Select3D/Select3D_InteriorSensitivePointSet.cxx b/src/Select3D/Select3D_InteriorSensitivePointSet.cxx index 1ea7e35d37..e24af87940 100644 --- a/src/Select3D/Select3D_InteriorSensitivePointSet.cxx +++ b/src/Select3D/Select3D_InteriorSensitivePointSet.cxx @@ -115,7 +115,8 @@ Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Ha Standard_Real anAngle = aVec1.Dot (aVec2); if (!aPlane.Contains (thePoints.Value (aPntIter)) || anAngle > Precision::Confusion()) { - Standard_Integer anUpperBound = aPntIter - aStartIdx; + // subtract 1 due to indexation from zero in sub-polygons + Standard_Integer anUpperBound = aPntIter - aStartIdx - 1; Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anUpperBound); for (Standard_Integer aIdx = aStartIdx; aIdx <= aStartIdx + anUpperBound; ++aIdx) { @@ -217,7 +218,8 @@ Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Ha Standard_Real anAngle = aVec1.Dot (aVec2); if (!aPlane.Contains (thePoints->Value (aPntIter)) || anAngle > Precision::Confusion()) { - Standard_Integer anUpperBound = aPntIter - aStartIdx; + // subtract 1 due to indexation from zero in sub-polygons + Standard_Integer anUpperBound = aPntIter - aStartIdx - 1; Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anUpperBound); for (Standard_Integer aIdx = aStartIdx; aIdx <= aStartIdx + anUpperBound; ++aIdx) { @@ -284,7 +286,6 @@ void Select3D_InteriorSensitivePointSet::GetPoints (Handle(TColgp_HArray1OfPnt)& const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (anIdx); aSize += aPolygon->NbSubElements(); } - aSize -= (myPlanarPolygons.Length() - 1) * 2; theHArrayOfPnt = new TColgp_HArray1OfPnt (1, aSize); Standard_Integer anOutputPntArrayIdx = 1; diff --git a/tests/bugs/vis/bug26031 b/tests/bugs/vis/bug26031 new file mode 100644 index 0000000000..ae1ab438de --- /dev/null +++ b/tests/bugs/vis/bug26031 @@ -0,0 +1,29 @@ +puts "============" +puts "CR26031" +puts "============" +puts "" + +########################################################################################## +# Visualization - fix out-of-range within Select3D_InteriorSensitivePointSet::GetPoints() +########################################################################################## + +pload VISUALIZATION XDE + +testreadiges [locate_data_file bug25747_pencil.igs] aPencil + +vinit View1 +vclear +vdefaults -autoTriang 0 +vdisplay aPencil +vsetdispmode 1 +vfit + +# create a connected interactive +vconnectto aCopy 50 50 50 aPencil +vfit + +# check that selection primitives for connected object were created successfully +vmoveto 220 133 +checkcolor 220 133 0 1 1 + +vdump ${imagedir}/${casename}.png