diff --git a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx index fc2ef18e10..ebbe1e8632 100644 --- a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx +++ b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx @@ -108,6 +108,10 @@ public: //! correspondingly) onto far view frustum plane virtual gp_Pnt GetFarPickedPnt() const = 0; + //! Stores plane equation coefficients (in the following form: + //! Ax + By + Cz + D = 0) to the given vector + virtual void GetPlanes (NCollection_Vector >& thePlaneEquations) const = 0; + protected: SelectionType myActiveSelectionType; //!< Active selection type: point, box or polyline }; diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.hxx b/src/SelectMgr/SelectMgr_BaseFrustum.hxx index 0ba1df784a..cbd840f998 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.hxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.hxx @@ -173,6 +173,14 @@ public: //! @return previous value of the flag virtual Standard_Boolean SetViewClippingEnabled (const Standard_Boolean /*theToEnable*/) { return Standard_False; } + //! Stores plane equation coefficients (in the following form: + //! Ax + By + Cz + D = 0) to the given vector + virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const + { + thePlaneEquations.Clear(); + return; + } + DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient) protected: diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index ac2291a646..6322cf2d10 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -746,3 +746,24 @@ Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const Standard_ return myViewClipRange.MaxDepth() > theDepth && myViewClipRange.MinDepth() < theDepth; } + +// ======================================================================= +// function : GetPlanes +// purpose : +// ======================================================================= +void SelectMgr_RectangularFrustum::GetPlanes (NCollection_Vector& thePlaneEquations) const +{ + thePlaneEquations.Clear(); + + SelectMgr_Vec4 anEquation; + for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < 6; ++aPlaneIdx) + { + const gp_Vec& aPlaneNorm = myIsOrthographic && aPlaneIdx % 2 == 1 ? + myPlanes[aPlaneIdx - 1].Reversed() : myPlanes[aPlaneIdx]; + anEquation.x() = aPlaneNorm.X(); + anEquation.y() = aPlaneNorm.Y(); + anEquation.z() = aPlaneNorm.Z(); + anEquation.w() = - (aPlaneNorm.XYZ().Dot (myVertices[aPlaneIdx % 2 == 0 ? aPlaneIdx : aPlaneIdx + 2].XYZ())); + thePlaneEquations.Append (anEquation); + } +} diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx index ecad0b8b84..4c9276adb3 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx @@ -132,6 +132,11 @@ public: //! of center of 2d rectangle (for point and rectangular selection //! correspondingly) onto far view frustum plane inline const gp_Pnt& GetFarPnt() const { return myFarPickedPnt; } + + //! Stores plane equation coefficients (in the following form: + //! Ax + By + Cz + D = 0) to the given vector + Standard_EXPORT virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE; + protected: Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1, diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx index 42ae4765f5..95bb8f6c65 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx @@ -196,6 +196,29 @@ public: //! correspondingly) onto far view frustum plane Standard_EXPORT virtual gp_Pnt GetFarPickedPnt() const Standard_OVERRIDE; + //! Returns active selecting volume that was built during last + //! run of OCCT selection mechanism + Handle(SelectMgr_BaseFrustum) ActiveVolume() const + { + if (myActiveSelectionType == Unknown) + return Handle(SelectMgr_BaseFrustum)(); + + return mySelectingVolumes[myActiveSelectionType / 2]; + } + + //! Stores plane equation coefficients (in the following form: + //! Ax + By + Cz + D = 0) to the given vector + virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE + { + if (myActiveSelectionType == Unknown) + { + thePlaneEquations.Clear(); + return; + } + + return mySelectingVolumes[myActiveSelectionType / 2]->GetPlanes (thePlaneEquations); + } + private: enum { Frustum, FrustumSet, VolumeTypesNb }; //!< Defines the amount of available selecting volumes diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx index 9c318cc2e0..641e75461e 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx @@ -279,3 +279,21 @@ void SelectMgr_TriangularFrustum::Clear() { myBuilder.Nullify(); } + +// ======================================================================= +// function : GetPlanes +// purpose : +// ======================================================================= +void SelectMgr_TriangularFrustum::GetPlanes (NCollection_Vector& thePlaneEquations) const +{ + SelectMgr_Vec4 aPlaneEquation; + for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < 5; ++aPlaneIdx) + { + const gp_Vec& aNorm = myPlanes[aPlaneIdx]; + aPlaneEquation.x() = aNorm.X(); + aPlaneEquation.y() = aNorm.Y(); + aPlaneEquation.z() = aNorm.Z(); + aPlaneEquation.w() = - (aNorm.XYZ().Dot (myVertices[aPlaneIdx % 2 == 0 ? aPlaneIdx : 1].XYZ())); + thePlaneEquations.Append (aPlaneEquation); + } +} diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx index 46a9443e21..4e32813424 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx @@ -84,6 +84,10 @@ public: //! Nullifies the handle to corresponding builder instance to prevent memory leaks Standard_EXPORT void Clear(); + //! Stores plane equation coefficients (in the following form: + //! Ax + By + Cz + D = 0) to the given vector + Standard_EXPORT virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE; + private: void cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum) const; diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx index 202b84e1b0..87f7a473f0 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx @@ -224,4 +224,18 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1 return Standard_False; } +// ======================================================================= +// function : GetPlanes +// purpose : +// ======================================================================= +void SelectMgr_TriangularFrustumSet::GetPlanes (NCollection_Vector& thePlaneEquations) const +{ + thePlaneEquations.Clear(); + + for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + { + anIter.Value()->GetPlanes (thePlaneEquations); + } +} + #undef MEMORY_BLOCK_SIZE diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx index 09f285b0a8..a28baf9362 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx @@ -75,6 +75,10 @@ public: Select3D_TypeOfSensitivity theSensType, Standard_Real& theDepth) Standard_OVERRIDE; + //! Stores plane equation coefficients (in the following form: + //! Ax + By + Cz + D = 0) to the given vector + Standard_EXPORT virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE; + private: SelectMgr_TriangFrustums myFrustums;