diff --git a/src/Select3D/Select3D_BoundarySensitivePointSet.cxx b/src/Select3D/Select3D_BoundarySensitivePointSet.cxx index 7a34c12189..8a5b6a232d 100644 --- a/src/Select3D/Select3D_BoundarySensitivePointSet.cxx +++ b/src/Select3D/Select3D_BoundarySensitivePointSet.cxx @@ -25,16 +25,6 @@ Select3D_BoundarySensitivePointSet::Select3D_BoundarySensitivePointSet (const Ha : Select3D_SensitivePoly (OwnerId, ThePoints, Standard_True) {} -//======================================================================= -// function : Select3D_BoundarySensitivePointSet -// purpose : Creates new instance of Select3D_SensitivePoly with BVH tree -// required and initializes it with the given array of points -//======================================================================= -Select3D_BoundarySensitivePointSet::Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId, - const Handle(TColgp_HArray1OfPnt)& ThePoints) - : Select3D_SensitivePoly (OwnerId, ThePoints, Standard_True) -{} - //======================================================================= // function : Matches // purpose : Checks whether the point set overlaps current selecting diff --git a/src/Select3D/Select3D_BoundarySensitivePointSet.hxx b/src/Select3D/Select3D_BoundarySensitivePointSet.hxx index f04c6133ad..12188110e8 100644 --- a/src/Select3D/Select3D_BoundarySensitivePointSet.hxx +++ b/src/Select3D/Select3D_BoundarySensitivePointSet.hxx @@ -36,11 +36,6 @@ public: Standard_EXPORT Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId, const TColgp_Array1OfPnt& ThePoints); - //! Creates new instance of Select3D_SensitivePoly with BVH tree - //! required and initializes it with the given array of points - Standard_EXPORT Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId, - const Handle(TColgp_HArray1OfPnt)& ThePoints); - //! Checks whether the point set overlaps current selecting volume Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; diff --git a/src/Select3D/Select3D_InteriorSensitivePointSet.cxx b/src/Select3D/Select3D_InteriorSensitivePointSet.cxx index e24af87940..cc2c7f8af0 100644 --- a/src/Select3D/Select3D_InteriorSensitivePointSet.cxx +++ b/src/Select3D/Select3D_InteriorSensitivePointSet.cxx @@ -84,146 +84,55 @@ Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Ha : Select3D_SensitiveSet (theOwnerId) { Select3D_Plane aPlane; - Standard_Integer aStartIdx = 1, anEndIdx = 0; Standard_Integer aLowerIdx = thePoints.Lower(); Standard_Integer anUpperIdx = thePoints.Upper(); - Select3D_BndBox3d aBndBox; - gp_XYZ aPntSum (0.0, 0.0, 0.0); - if (thePoints.Length() > 3) - { - for (Standard_Integer aPntIter = aLowerIdx; aPntIter <= anUpperIdx; ++aPntIter) - { - gp_Pnt aPnt1, aPnt2; - const gp_Pnt& aPnt3 = thePoints.Value (aPntIter); - aBndBox.Add (SelectMgr_Vec3 (aPnt3.X(), aPnt3.Y(), aPnt3.Z())); - aPntSum += aPnt3.XYZ(); - if (aPntIter - aLowerIdx >= 2) - { - aPnt1 = thePoints.Value (aPntIter - 2); - aPnt2 = thePoints.Value (aPntIter - 1); - } - if (aPntIter - aStartIdx == 2 && !aPlane.IsValid()) - { - aPlane.MakePlane (aPnt1, aPnt2, aPnt3); - aStartIdx = aPntIter - 2; - anEndIdx = aPntIter; - } - else if (aPlane.IsValid()) - { - const gp_XYZ& aVec1 = aPnt1.XYZ() - aPnt2.XYZ(); - const gp_XYZ& aVec2 = aPnt3.XYZ() - aPnt2.XYZ(); - Standard_Real anAngle = aVec1.Dot (aVec2); - if (!aPlane.Contains (thePoints.Value (aPntIter)) || anAngle > Precision::Confusion()) - { - // 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) - { - aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value (aIdx)); - } - Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId, - aPointsArray, - Standard_False); - myPlanarPolygons.Append (aPlanarPolyg); - aStartIdx = aPntIter; - anEndIdx = aPntIter; - aPlane.Invalidate(); - } - else - { - if (anEndIdx == anUpperIdx) - { - Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anEndIdx - aStartIdx); - for (Standard_Integer aIdx = aStartIdx; aIdx <= anEndIdx; ++aIdx) - { - aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value (aIdx)); - } - Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId, - aPointsArray, - Standard_False); - myPlanarPolygons.Append (aPlanarPolyg); - } - anEndIdx++; - } - } - } - } - else - { - Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, 2); - const gp_Pnt& aPnt1 = thePoints.Value (aLowerIdx); - const gp_Pnt& aPnt2 = thePoints.Value (aLowerIdx + 1); - const gp_Pnt& aPnt3 = thePoints.Value (aLowerIdx + 2); - aPointsArray->SetValue (0, aPnt1); - aPointsArray->SetValue (1, aPnt2); - aPointsArray->SetValue (2, aPnt3); - aBndBox.Add (SelectMgr_Vec3 (aPnt1.X(), aPnt1.Y(), aPnt1.Z())); - aBndBox.Add (SelectMgr_Vec3 (aPnt2.X(), aPnt2.Y(), aPnt2.Z())); - aBndBox.Add (SelectMgr_Vec3 (aPnt3.X(), aPnt3.Y(), aPnt3.Z())); - aPntSum += aPnt1.XYZ() + aPnt2.XYZ() + aPnt3.XYZ(); - Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId, - aPointsArray, - Standard_False); - myPlanarPolygons.Append (aPlanarPolyg); - } - - myPolygonsIdxs = new TColStd_HArray1OfInteger (0, myPlanarPolygons.Length() - 1); - for (Standard_Integer aIdx = 0; aIdx < myPlanarPolygons.Length(); ++aIdx) - { - myPolygonsIdxs->SetValue (aIdx, aIdx); - } - - myCOG = aPntSum / thePoints.Length(); - myBndBox = aBndBox; -} - -// ======================================================================= -// function : Select3D_InteriorSensitivePointSet -// purpose : Splits the given point set thePoints onto planar convex -// polygons -// ======================================================================= -Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId, - const Handle(TColgp_HArray1OfPnt)& thePoints) - : Select3D_SensitiveSet (theOwnerId) -{ - Select3D_Plane aPlane; - Standard_Integer aLowerIdx = thePoints->Lower(); - Standard_Integer anUpperIdx = thePoints->Upper(); Standard_Integer aStartIdx = aLowerIdx, anEndIdx = 0; Select3D_BndBox3d aBndBox; gp_XYZ aPntSum (0.0, 0.0, 0.0); for (Standard_Integer aPntIter = aLowerIdx; aPntIter <= anUpperIdx; ++aPntIter) { gp_Pnt aPnt1, aPnt2; - const gp_Pnt& aPnt3 = thePoints->Value (aPntIter); + const gp_Pnt& aPnt3 = thePoints.Value (aPntIter); aPntSum += aPnt3.XYZ(); SelectMgr_Vec3 aCurrPnt (aPnt3.X(), aPnt3.Y(), aPnt3.Z()); aBndBox.Add (aCurrPnt); if (aPntIter - aLowerIdx >= 2) { - aPnt1 = thePoints->Value (aPntIter - 2); - aPnt2 = thePoints->Value (aPntIter - 1); + aPnt1 = thePoints.Value (aPntIter - 2); + aPnt2 = thePoints.Value (aPntIter - 1); } if (aPntIter - aStartIdx == 2 && !aPlane.IsValid()) { aPlane.MakePlane (aPnt1, aPnt2, aPnt3); aStartIdx = aPntIter - 2; anEndIdx = aPntIter; + + if (anEndIdx == anUpperIdx) + { + Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anEndIdx - aStartIdx); + for (Standard_Integer aIdx = aStartIdx; aIdx <= anEndIdx; ++aIdx) + { + aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value(aIdx)); + } + Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId, + aPointsArray, + Standard_False); + myPlanarPolygons.Append (aPlanarPolyg); + } } else if (aPlane.IsValid()) { const gp_XYZ& aVec1 = aPnt1.XYZ() - aPnt2.XYZ(); const gp_XYZ& aVec2 = aPnt3.XYZ() - aPnt2.XYZ(); Standard_Real anAngle = aVec1.Dot (aVec2); - if (!aPlane.Contains (thePoints->Value (aPntIter)) || anAngle > Precision::Confusion()) + if (!aPlane.Contains (thePoints.Value (aPntIter)) || anAngle > Precision::Confusion()) { // 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) { - aPointsArray->SetValue (aIdx - aStartIdx, thePoints->Value (aIdx)); + aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value (aIdx)); } Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId, aPointsArray, @@ -241,7 +150,7 @@ Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Ha Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anEndIdx - aStartIdx); for (Standard_Integer aIdx = aStartIdx; aIdx <= anEndIdx; ++aIdx) { - aPointsArray->SetValue (aIdx - aStartIdx, thePoints->Value (aIdx)); + aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value (aIdx)); } Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId, aPointsArray, @@ -252,14 +161,14 @@ Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Ha } } + myCOG = aPntSum / thePoints.Length(); + myBndBox = aBndBox; + myPolygonsIdxs = new TColStd_HArray1OfInteger (0, myPlanarPolygons.Length() - 1); for (Standard_Integer aIdx = 0; aIdx < myPlanarPolygons.Length(); ++aIdx) { myPolygonsIdxs->SetValue (aIdx, aIdx); } - - myCOG = aPntSum / thePoints->Length(); - myBndBox = aBndBox; } // ======================================================================= diff --git a/src/Select3D/Select3D_InteriorSensitivePointSet.hxx b/src/Select3D/Select3D_InteriorSensitivePointSet.hxx index 2e1dab0ef4..22df1664a4 100644 --- a/src/Select3D/Select3D_InteriorSensitivePointSet.hxx +++ b/src/Select3D/Select3D_InteriorSensitivePointSet.hxx @@ -45,10 +45,6 @@ public: Standard_EXPORT Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId, const TColgp_Array1OfPnt& thePoints); - //! Splits the given point set thePoints onto planar convex polygons - Standard_EXPORT Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId, - const Handle(TColgp_HArray1OfPnt)& thePoints); - //! Checks whether the point set overlaps current selecting volume Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; diff --git a/src/Select3D/Select3D_SensitiveFace.cxx b/src/Select3D/Select3D_SensitiveFace.cxx index 5fdd578f09..630f6d1c07 100644 --- a/src/Select3D/Select3D_SensitiveFace.cxx +++ b/src/Select3D/Select3D_SensitiveFace.cxx @@ -57,11 +57,11 @@ Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_Entity { if (mySensType == Select3D_TOS_INTERIOR) { - myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints); + myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints->Array1()); } else { - myFacePoints = new Select3D_BoundarySensitivePointSet (theOwnerId, thePoints); + myFacePoints = new Select3D_BoundarySensitivePointSet (theOwnerId, thePoints->Array1()); } }