From: vpa Date: Mon, 17 Oct 2016 15:22:44 +0000 (+0300) Subject: Provide an interface to retrieve selecting volume's planes from SelectBasics_Selectin... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=a8d343c379c75c8382fbffe6ada71aa686b00584;p=occt-copy.git Provide an interface to retrieve selecting volume's planes from SelectBasics_SelectingVolumeManager --- diff --git a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx index d4d40ea982..63fdf3dec7 100644 --- a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx +++ b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx @@ -96,6 +96,9 @@ public: virtual Standard_Boolean IsOverlapAllowed() const = 0; + //! Stores plane equations 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 225b835445..9f56c0f101 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.hxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.hxx @@ -162,6 +162,9 @@ public: //! Computes depth range for global (defined for the whole view) clipping planes. Standard_EXPORT virtual void SetViewClipping (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/) {}; + //! Stores plane equations to the given vector + Standard_EXPORT virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const = 0; + DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient) protected: diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index 664d3d4387..fe491f71c8 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -741,3 +741,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 9cf9c12173..8cdf79824e 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx @@ -117,6 +117,10 @@ public: inline gp_Pnt GetNearPnt() const { return myNearPickedPnt; } inline gp_Pnt GetFarPnt() const { return myFarPickedPnt; } + + //! Stores plane equations 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 13a4a6e03a..d945435125 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx @@ -183,6 +183,18 @@ public: return mySelectingVolumes[myActiveSelectionType]; } + //! Stores plane equations to the given vector + virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE + { + if (myActiveSelectionType == Unknown) + { + thePlaneEquations.Clear(); + return; + } + + return mySelectingVolumes[myActiveSelectionType]->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 79b02a1fc6..8ae203659f 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx @@ -285,3 +285,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 ceb104f378..6b69f37ac6 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx @@ -84,6 +84,9 @@ public: //! Nullifies the handle to corresponding builder instance to prevent memory leaks Standard_EXPORT void Clear(); + //! Stores plane equations to the given vector + Standard_EXPORT virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE; + private: void cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum); diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx index c5d8c9fb9d..1604d85411 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 baad601daf..32e520aaff 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx @@ -75,6 +75,9 @@ public: Select3D_TypeOfSensitivity theSensType, Standard_Real& theDepth) Standard_OVERRIDE; + //! Stores plane equations to the given vector + Standard_EXPORT virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE; + private: SelectMgr_TriangFrustums myFrustums;