diff --git a/src/MeshVS/MeshVS_SensitivePolyhedron.cxx b/src/MeshVS/MeshVS_SensitivePolyhedron.cxx index 447028cb94..9522553762 100644 --- a/src/MeshVS/MeshVS_SensitivePolyhedron.cxx +++ b/src/MeshVS/MeshVS_SensitivePolyhedron.cxx @@ -86,7 +86,7 @@ Standard_Boolean MeshVS_SensitivePolyhedron::Matches (SelectBasics_SelectingVolu SelectBasics_PickResult aPickResult; for (MeshVS_PolyhedronVertsIter aIter (myTopology); aIter.More(); aIter.Next()) { - if (theMgr.OverlapsPolygon (aIter.Value(), Select3D_TOS_INTERIOR, aPickResult)) + if (theMgr.OverlapsPolygon (aIter.Value()->Array1(), Select3D_TOS_INTERIOR, aPickResult)) { thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult); } diff --git a/src/Select3D/Select3D_InteriorSensitivePointSet.cxx b/src/Select3D/Select3D_InteriorSensitivePointSet.cxx index 03d8d0a26b..c2bcff4732 100644 --- a/src/Select3D/Select3D_InteriorSensitivePointSet.cxx +++ b/src/Select3D/Select3D_InteriorSensitivePointSet.cxx @@ -270,7 +270,7 @@ Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasi const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx); Handle(TColgp_HArray1OfPnt) aPoints; aPolygon->Points3D (aPoints); - return theMgr.OverlapsPolygon (aPoints, Select3D_TOS_INTERIOR, thePickResult); + return theMgr.OverlapsPolygon (aPoints->Array1(), Select3D_TOS_INTERIOR, thePickResult); } // ======================================================================= diff --git a/src/Select3D/Select3D_SensitiveCircle.cxx b/src/Select3D/Select3D_SensitiveCircle.cxx index d8cfb92828..6a4864c7dd 100644 --- a/src/Select3D/Select3D_SensitiveCircle.cxx +++ b/src/Select3D/Select3D_SensitiveCircle.cxx @@ -228,7 +228,7 @@ Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolume if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline) { SelectBasics_PickResult aDummy; - return theMgr.OverlapsPolygon (anArrayOfPnt, mySensType, aDummy); + return theMgr.OverlapsPolygon (anArrayOfPnt->Array1(), mySensType, aDummy); } for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper(); ++aPntIdx) { @@ -240,7 +240,7 @@ Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolume return Standard_True; } - if (!theMgr.OverlapsPolygon (anArrayOfPnt, Select3D_TOS_INTERIOR, thePickResult)) + if (!theMgr.OverlapsPolygon (anArrayOfPnt->Array1(), Select3D_TOS_INTERIOR, thePickResult)) { return Standard_False; } diff --git a/src/SelectBasics/FILES b/src/SelectBasics/FILES index 169e58d3ca..3d0d42f1a6 100644 --- a/src/SelectBasics/FILES +++ b/src/SelectBasics/FILES @@ -1,5 +1,6 @@ SelectBasics.hxx SelectBasics_EntityOwner.hxx SelectBasics_PickResult.hxx +SelectBasics_SelectingVolumeManager.cxx SelectBasics_SelectingVolumeManager.hxx SelectBasics_SensitiveEntity.hxx diff --git a/src/SelectBasics/SelectBasics_SelectingVolumeManager.cxx b/src/SelectBasics/SelectBasics_SelectingVolumeManager.cxx new file mode 100644 index 0000000000..3d84755e06 --- /dev/null +++ b/src/SelectBasics/SelectBasics_SelectingVolumeManager.cxx @@ -0,0 +1,43 @@ +// Copyright (c) 2021 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +// ======================================================================= +// function : SelectBasics_SelectingVolumeManager +// purpose : +// ======================================================================= +SelectBasics_SelectingVolumeManager::SelectBasics_SelectingVolumeManager() +{ + // +} + +// ======================================================================= +// function : ~SelectBasics_SelectingVolumeManager +// purpose : +// ======================================================================= +SelectBasics_SelectingVolumeManager::~SelectBasics_SelectingVolumeManager() +{ + // +} + +// ======================================================================= +// function : Overlaps +// purpose : +// ======================================================================= +Standard_Boolean SelectBasics_SelectingVolumeManager::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, + Standard_Integer theSensType, + SelectBasics_PickResult& thePickResult) const +{ + return OverlapsPolygon (theArrayOfPts->Array1(), theSensType, thePickResult); +} diff --git a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx index 6c177af4a1..68aaaab90c 100644 --- a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx +++ b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx @@ -20,6 +20,7 @@ #include #include #include +#include #include class Bnd_Box; @@ -33,12 +34,17 @@ class SelectBasics_SelectingVolumeManager { public: - SelectBasics_SelectingVolumeManager() {} + //! Empty constructor. + SelectBasics_SelectingVolumeManager(); - virtual ~SelectBasics_SelectingVolumeManager() {} + //! Destructor. + Standard_EXPORT virtual ~SelectBasics_SelectingVolumeManager(); + //! Return selection type. virtual Standard_Integer GetActiveSelectionType() const = 0; +public: + //! Returns true if selecting volume is overlapped by box theBox virtual Standard_Boolean OverlapsBox (const NCollection_Vec3& theBoxMin, const NCollection_Vec3& theBoxMax, @@ -59,12 +65,6 @@ public: //! helper function for inclusion test. virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const = 0; - //! Returns true if selecting volume is overlapped by planar convex polygon, which points - //! are stored in theArrayOfPts, taking into account sensitivity type theSensType - virtual Standard_Boolean OverlapsPolygon (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, - Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) const = 0; - //! Returns true if selecting volume is overlapped by planar convex polygon, which points //! are stored in theArrayOfPts, taking into account sensitivity type theSensType virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPts, @@ -85,12 +85,16 @@ public: Standard_Integer theSensType, SelectBasics_PickResult& thePickResult) const = 0; +public: + //! Calculates distance from 3d projection of user-defined selection point //! to the given point theCOG virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const = 0; + //! Return 3D point corresponding to specified depth within picking ray. virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const = 0; + //! Returns flag indicating if partial overlapping of entities is allowed or should be rejected. virtual Standard_Boolean IsOverlapAllowed() const = 0; //! Valid only for point and rectangular selection. @@ -126,6 +130,85 @@ public: (void )theOStream; (void )theDepth; } + +public: + + Standard_DEPRECATED ("Deprecated alias for OverlapsBox()") + Standard_Boolean Overlaps (const NCollection_Vec3& theBoxMin, + const NCollection_Vec3& theBoxMax, + SelectBasics_PickResult& thePickResult) const + { + return OverlapsBox (theBoxMin, theBoxMax, thePickResult); + } + + Standard_DEPRECATED ("Deprecated alias for OverlapsBox()") + Standard_Boolean Overlaps (const NCollection_Vec3& theBoxMin, + const NCollection_Vec3& theBoxMax, + Standard_Boolean* theInside = NULL) const + { + return OverlapsBox (theBoxMin, theBoxMax, theInside); + } + + Standard_DEPRECATED ("Deprecated alias for OverlapsPoint()") + Standard_Boolean Overlaps (const gp_Pnt& thePnt, + SelectBasics_PickResult& thePickResult) const + { + return OverlapsPoint (thePnt, thePickResult); + } + + Standard_DEPRECATED ("Deprecated alias for OverlapsPoint()") + Standard_Boolean Overlaps (const gp_Pnt& thePnt) const + { + return OverlapsPoint (thePnt); + } + + Standard_DEPRECATED ("Deprecated alias for OverlapsPolygon()") + Standard_EXPORT Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, + Standard_Integer theSensType, + SelectBasics_PickResult& thePickResult) const; + + Standard_DEPRECATED ("Deprecated alias for OverlapsPolygon()") + Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts, + Standard_Integer theSensType, + SelectBasics_PickResult& thePickResult) const + { + return OverlapsPolygon (theArrayOfPts, theSensType, thePickResult); + } + + Standard_DEPRECATED ("Deprecated alias for OverlapsSegment()") + Standard_Boolean Overlaps (const gp_Pnt& thePnt1, + const gp_Pnt& thePnt2, + SelectBasics_PickResult& thePickResult) const + { + return OverlapsSegment (thePnt1, thePnt2, thePickResult); + } + + Standard_DEPRECATED ("Deprecated alias for OverlapsTriangle()") + Standard_Boolean Overlaps (const gp_Pnt& thePnt1, + const gp_Pnt& thePnt2, + const gp_Pnt& thePnt3, + Standard_Integer theSensType, + SelectBasics_PickResult& thePickResult) const + { + return OverlapsTriangle (thePnt1, thePnt2, thePnt3, theSensType, thePickResult); + } + +//! Deprecated static const class members aren't supported for Visual Studio prior to 2015 (vc14) +//! and GCC >= 5.0 and GCC < 6.3 (due to bug when warning was raised without member usage). +#if (!defined(_MSC_VER) || (_MSC_VER >= 1900)) && (!defined(__GNUC__) || (__GNUC__ != 5 && (__GNUC__ != 6 || __GNUC_MINOR__ >= 3))) + Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") + static const SelectMgr_SelectionType Point = SelectMgr_SelectionType_Point; + + Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") + static const SelectMgr_SelectionType Box = SelectMgr_SelectionType_Box; + + Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") + static const SelectMgr_SelectionType Polyline = SelectMgr_SelectionType_Polyline; + + Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") + static const SelectMgr_SelectionType Unknown = SelectMgr_SelectionType_Unknown; +#endif + }; #endif // _SelectBasics_SelectingVolumeManager_HeaderFile diff --git a/src/SelectMgr/SelectMgr_AxisIntersector.cxx b/src/SelectMgr/SelectMgr_AxisIntersector.cxx index ae1e024703..2dc4d4df1c 100644 --- a/src/SelectMgr/SelectMgr_AxisIntersector.cxx +++ b/src/SelectMgr/SelectMgr_AxisIntersector.cxx @@ -25,6 +25,16 @@ // ======================================================================= SelectMgr_AxisIntersector::SelectMgr_AxisIntersector() { + // +} + +// ======================================================================= +// function : ~SelectMgr_AxisIntersector +// purpose : +// ======================================================================= +SelectMgr_AxisIntersector::~SelectMgr_AxisIntersector() +{ + // } // ======================================================================= diff --git a/src/SelectMgr/SelectMgr_AxisIntersector.hxx b/src/SelectMgr/SelectMgr_AxisIntersector.hxx index 9f7b95a478..4e92d96fe6 100644 --- a/src/SelectMgr/SelectMgr_AxisIntersector.hxx +++ b/src/SelectMgr/SelectMgr_AxisIntersector.hxx @@ -28,7 +28,7 @@ public: Standard_EXPORT SelectMgr_AxisIntersector(); //! Destructor - virtual ~SelectMgr_AxisIntersector() {} + Standard_EXPORT virtual ~SelectMgr_AxisIntersector(); //! Initializes selecting axis according to the input one Standard_EXPORT void Init (const gp_Ax1& theAxis); @@ -37,14 +37,16 @@ public: //! NOTE: it should be called after Init() method Standard_EXPORT virtual void Build() Standard_OVERRIDE; + //! Returns FALSE (not applicable to this volume). + virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; } + //! IMPORTANT: Scaling doesn't make sense for this intersector. //! Returns a copy of the intersector transformed using the matrix given. - //! Builder is an optional argument that represents corresponding settings for re-constructing transformed - //! frustum from scratch. Can be null if reconstruction is not expected furthermore. - Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) - ScaleAndTransform (const Standard_Integer theScaleFactor, - const gp_GTrsf& theTrsf, - const Handle(SelectMgr_FrustumBuilder)& theBuilder = Handle(SelectMgr_FrustumBuilder)()) const Standard_OVERRIDE; + //! Builder is an optional argument that represents corresponding settings for re-constructing transformed frustum from scratch. + //! Can be null if reconstruction is not expected furthermore. + Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScaleFactor, + const gp_GTrsf& theTrsf, + const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE; public: diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.cxx b/src/SelectMgr/SelectMgr_BaseFrustum.cxx index d61e930882..718b122727 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.cxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.cxx @@ -23,8 +23,7 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum, SelectMgr_BaseIntersector) //======================================================================= // function : SelectMgr_BaseFrustum -// purpose : Creates new selecting volume with pixel toletance set to 2, -// orthographic camera and empty frustum builder +// purpose : //======================================================================= SelectMgr_BaseFrustum::SelectMgr_BaseFrustum() : myPixelTolerance (2), @@ -143,94 +142,6 @@ void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& myBuilder = theBuilder; } -//======================================================================= -// function : OverlapsBox -// purpose : SAT intersection test between defined volume and -// given axis-aligned box -//======================================================================= -Standard_Boolean SelectMgr_BaseFrustum::OverlapsBox (const SelectMgr_Vec3& /*theBoxMin*/, - const SelectMgr_Vec3& /*theBoxMax*/, - const SelectMgr_ViewClipRange& /*theClipRange*/, - SelectBasics_PickResult& /*thePickResult*/) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsBox -// purpose : Intersection test between defined volume and given point -//======================================================================= -Standard_Boolean SelectMgr_BaseFrustum::OverlapsBox (const SelectMgr_Vec3& /*theBoxMin*/, - const SelectMgr_Vec3& /*theBoxMax*/, - Standard_Boolean* /*theInside*/) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsPoint -// purpose : Intersection test between defined volume and given point -//======================================================================= -Standard_Boolean SelectMgr_BaseFrustum::OverlapsPoint (const gp_Pnt& /*thePnt*/, - const SelectMgr_ViewClipRange& /*theClipRange*/, - SelectBasics_PickResult& ) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsPoint -// purpose : Intersection test between defined volume and given point -//======================================================================= -Standard_Boolean SelectMgr_BaseFrustum::OverlapsPoint (const gp_Pnt& /*thePnt*/) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsPolygon -// purpose : SAT intersection test between defined volume and given -// ordered set of points, representing line segments. The test -// may be considered of interior part or boundary line defined -// by segments depending on given sensitivity type -//======================================================================= -Standard_Boolean SelectMgr_BaseFrustum::OverlapsPolygon (const TColgp_Array1OfPnt& /*theArrayOfPnts*/, - Select3D_TypeOfSensitivity /*theSensType*/, - const SelectMgr_ViewClipRange& /*theClipRange*/, - SelectBasics_PickResult& ) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsTriangle -// purpose : SAT intersection test between defined volume and given -// triangle. The test may be considered of interior part or -// boundary line defined by triangle vertices depending on -// given sensitivity type -//======================================================================= -Standard_Boolean SelectMgr_BaseFrustum::OverlapsTriangle (const gp_Pnt& /*thePt1*/, - const gp_Pnt& /*thePt2*/, - const gp_Pnt& /*thePt3*/, - Select3D_TypeOfSensitivity /*theSensType*/, - const SelectMgr_ViewClipRange& /*theClipRange*/, - SelectBasics_PickResult& ) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsSegment -// purpose : Checks if line segment overlaps selecting volume -//======================================================================= -Standard_Boolean SelectMgr_BaseFrustum::OverlapsSegment (const gp_Pnt& /*thePnt1*/, - const gp_Pnt& /*thePnt2*/, - const SelectMgr_ViewClipRange& /*theClipRange*/, - SelectBasics_PickResult& ) const -{ - return Standard_False; -} - //======================================================================= //function : DumpJson //purpose : diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.hxx b/src/SelectMgr/SelectMgr_BaseFrustum.hxx index e303b04452..9a0ef2cbdd 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.hxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.hxx @@ -27,7 +27,7 @@ class SelectMgr_BaseFrustum : public SelectMgr_BaseIntersector { public: - //! Creates new selecting volume with pixel toletance set to 2, + //! Creates new selecting volume with pixel tolerance set to 2, //! orthographic camera and empty frustum builder Standard_EXPORT SelectMgr_BaseFrustum(); @@ -72,55 +72,6 @@ public: const Standard_Real theWidth, const Standard_Real theHeight) Standard_OVERRIDE; - - - //! SAT intersection test between defined volume and given axis-aligned box - Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin, - const SelectMgr_Vec3& theBoxMax, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; - - //! Returns true if selecting volume is overlapped by axis-aligned bounding box - //! with minimum corner at point theMinPt and maximum at point theMaxPt - Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin, - const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside = NULL) const Standard_OVERRIDE; - - //! Intersection test between defined volume and given point - Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; - - //! Intersection test between defined volume and given point - //! Does not perform depth calculation, so this method is defined as - //! helper function for inclusion test. Therefore, its implementation - //! makes sense only for rectangular frustum with box selection mode activated. - Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE; - - //! SAT intersection test between defined volume and given ordered set of points, - //! representing line segments. The test may be considered of interior part or - //! boundary line defined by segments depending on given sensitivity type - Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts, - Select3D_TypeOfSensitivity theSensType, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; - - //! Checks if line segment overlaps selecting frustum - Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1, - const gp_Pnt& thePnt2, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; - - //! SAT intersection test between defined volume and given triangle. The test may - //! be considered of interior part or boundary line defined by triangle vertices - //! depending on given sensitivity type - Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePt1, - const gp_Pnt& thePt2, - const gp_Pnt& thePt3, - Select3D_TypeOfSensitivity theSensType, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; - //! Dumps the content of me into the stream Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; diff --git a/src/SelectMgr/SelectMgr_BaseIntersector.cxx b/src/SelectMgr/SelectMgr_BaseIntersector.cxx index 1dadf955de..739ea74e35 100644 --- a/src/SelectMgr/SelectMgr_BaseIntersector.cxx +++ b/src/SelectMgr/SelectMgr_BaseIntersector.cxx @@ -18,14 +18,22 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseIntersector, Standard_Transient) //======================================================================= -// function : ScaleAndTransform +// function : SelectMgr_BaseIntersector // purpose : //======================================================================= -Handle(SelectMgr_BaseIntersector) SelectMgr_BaseIntersector::ScaleAndTransform (const Standard_Integer, - const gp_GTrsf&, - const Handle(SelectMgr_FrustumBuilder)&) const +SelectMgr_BaseIntersector::SelectMgr_BaseIntersector() +: mySelectionType (SelectMgr_SelectionType_Unknown) { - return NULL; + // +} + +//======================================================================= +// function : ~SelectMgr_BaseIntersector +// purpose : +//======================================================================= +SelectMgr_BaseIntersector::~SelectMgr_BaseIntersector() +{ + // } //======================================================================= @@ -164,88 +172,6 @@ const gp_Pnt2d& SelectMgr_BaseIntersector::GetMousePosition() const return aPnt; } -//======================================================================= -// function : OverlapsBox -// purpose : -//======================================================================= -Standard_Boolean SelectMgr_BaseIntersector::OverlapsBox (const SelectMgr_Vec3&, - const SelectMgr_Vec3&, - const SelectMgr_ViewClipRange&, - SelectBasics_PickResult&) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsBox -// purpose : -//======================================================================= -Standard_Boolean SelectMgr_BaseIntersector::OverlapsBox (const SelectMgr_Vec3&, - const SelectMgr_Vec3&, - Standard_Boolean*) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsPoint -// purpose : -//======================================================================= -Standard_Boolean SelectMgr_BaseIntersector::OverlapsPoint (const gp_Pnt&, - const SelectMgr_ViewClipRange&, - SelectBasics_PickResult&) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsPoint -// purpose : -//======================================================================= -Standard_Boolean SelectMgr_BaseIntersector::OverlapsPoint (const gp_Pnt& thePnt) const -{ - (void )thePnt; - return Standard_False; -} - -//======================================================================= -// function : OverlapsPolygon -// purpose : -//======================================================================= -Standard_Boolean SelectMgr_BaseIntersector::OverlapsPolygon (const TColgp_Array1OfPnt&, - Select3D_TypeOfSensitivity, - const SelectMgr_ViewClipRange&, - SelectBasics_PickResult&) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsTriangle -// purpose : -//======================================================================= -Standard_Boolean SelectMgr_BaseIntersector::OverlapsTriangle (const gp_Pnt&, - const gp_Pnt&, - const gp_Pnt&, - Select3D_TypeOfSensitivity, - const SelectMgr_ViewClipRange&, - SelectBasics_PickResult&) const -{ - return Standard_False; -} - -//======================================================================= -// function : OverlapsSegment -// purpose : -//======================================================================= -Standard_Boolean SelectMgr_BaseIntersector::OverlapsSegment (const gp_Pnt&, - const gp_Pnt&, - const SelectMgr_ViewClipRange&, - SelectBasics_PickResult&) const -{ - return Standard_False; -} - //======================================================================= // function : DistToGeometryCenter // purpose : diff --git a/src/SelectMgr/SelectMgr_BaseIntersector.hxx b/src/SelectMgr/SelectMgr_BaseIntersector.hxx index bc2b5b41d7..c792169569 100644 --- a/src/SelectMgr/SelectMgr_BaseIntersector.hxx +++ b/src/SelectMgr/SelectMgr_BaseIntersector.hxx @@ -39,15 +39,13 @@ class SelectMgr_BaseIntersector : public Standard_Transient public: //! Creates new empty selecting volume - SelectMgr_BaseIntersector() - : mySelectionType (SelectMgr_SelectionType_Unknown) - {} + Standard_EXPORT SelectMgr_BaseIntersector(); //! Destructor - virtual ~SelectMgr_BaseIntersector() {} + Standard_EXPORT virtual ~SelectMgr_BaseIntersector(); //! Builds intersector according to internal parameters - virtual void Build() {} + virtual void Build() = 0; //! Returns selection type of this intersector SelectMgr_SelectionType GetSelectionType() const { return mySelectionType; } @@ -55,27 +53,23 @@ public: public: //! Checks if it is possible to scale this intersector. - //! @return false for the base class. - virtual Standard_Boolean IsScalable() const { return Standard_False; } + virtual Standard_Boolean IsScalable() const = 0; //! Sets pixel tolerance. //! It makes sense only for scalable intersectors (built on a single point). //! This method does nothing for the base class. Standard_EXPORT virtual void SetPixelTolerance (const Standard_Integer theTol); - //! IMPORTANT: Scaling makes sense only for scalable intersectors (built on a single point)! - //! Note that this method does not perform any checks on type of the frustum. - //! Returns a copy of the frustum resized according to the scale factor given - //! and transforms it using the matrix given. - //! There are no default parameters, but in case if: - //! - transformation only is needed: @theScaleFactor must be initialized as any negative value; - //! - scale only is needed: @theTrsf must be set to gp_Identity. - //! Builder is an optional argument that represents corresponding settings for re-constructing transformed - //! frustum from scratch. Can be null if reconstruction is not expected furthermore. - //! This method does nothing for the base class. - Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScaleFactor, - const gp_GTrsf& theTrsf, - const Handle(SelectMgr_FrustumBuilder)& theBuilder) const; + //! Note that this method does not perform any checks on type of the frustum. + //! @param theScaleFactor [in] scale factor for new intersector or negative value if undefined; + //! IMPORTANT: scaling makes sense only for scalable ::IsScalable() intersectors (built on a single point)! + //! @param theTrsf [in] transformation for new intersector or gp_Identity if undefined + //! @param theBuilder [in] an optional argument that represents corresponding settings for re-constructing transformed frustum from scratch; + //! could be NULL if reconstruction is not expected furthermore + //! @return a copy of the frustum resized according to the scale factor given and transforms it using the matrix given + virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScaleFactor, + const gp_GTrsf& theTrsf, + const Handle(SelectMgr_FrustumBuilder)& theBuilder) const = 0; public: @@ -150,51 +144,50 @@ public: public: //! SAT intersection test between defined volume and given axis-aligned box - Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin, - const SelectMgr_Vec3& theBoxMax, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const; + virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin, + const SelectMgr_Vec3& theBoxMax, + const SelectMgr_ViewClipRange& theClipRange, + SelectBasics_PickResult& thePickResult) const = 0; //! Returns true if selecting volume is overlapped by axis-aligned bounding box //! with minimum corner at point theMinPt and maximum at point theMaxPt - Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin, - const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside = NULL) const; + virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin, + const SelectMgr_Vec3& theBoxMax, + Standard_Boolean* theInside = NULL) const = 0; //! Intersection test between defined volume and given point - Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const; + virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt, + const SelectMgr_ViewClipRange& theClipRange, + SelectBasics_PickResult& thePickResult) const = 0; //! Intersection test between defined volume and given point - //! Does not perform depth calculation, so this method is defined as - //! helper function for inclusion test. Therefore, its implementation - //! makes sense only for rectangular frustum with box selection mode activated. - Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const; + //! Does not perform depth calculation, so this method is defined as helper function for inclusion test. + //! Therefore, its implementation makes sense only for rectangular frustum with box selection mode activated. + virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const = 0; //! SAT intersection test between defined volume and given ordered set of points, //! representing line segments. The test may be considered of interior part or //! boundary line defined by segments depending on given sensitivity type - Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts, - Select3D_TypeOfSensitivity theSensType, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const; + virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts, + Select3D_TypeOfSensitivity theSensType, + const SelectMgr_ViewClipRange& theClipRange, + SelectBasics_PickResult& thePickResult) const = 0; //! Checks if line segment overlaps selecting frustum - Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1, - const gp_Pnt& thePnt2, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const; + virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1, + const gp_Pnt& thePnt2, + const SelectMgr_ViewClipRange& theClipRange, + SelectBasics_PickResult& thePickResult) const = 0; //! SAT intersection test between defined volume and given triangle. The test may //! be considered of interior part or boundary line defined by triangle vertices //! depending on given sensitivity type - Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePt1, - const gp_Pnt& thePt2, - const gp_Pnt& thePt3, - Select3D_TypeOfSensitivity theSensType, - const SelectMgr_ViewClipRange& theClipRange, - SelectBasics_PickResult& thePickResult) const; + virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1, + const gp_Pnt& thePnt2, + const gp_Pnt& thePnt3, + Select3D_TypeOfSensitivity theSensType, + const SelectMgr_ViewClipRange& theClipRange, + SelectBasics_PickResult& thePickResult) const = 0; public: diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx index b8045dc686..ee709488aa 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx @@ -390,26 +390,6 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPoint (const gp_Pnt& return myActiveSelectingVolume->OverlapsPoint (thePnt); } -//======================================================================= -// function : OverlapsPolygon -// purpose : SAT intersection test between defined volume and given -// ordered set of points, representing line segments. The test -// may be considered of interior part or boundary line defined -// by segments depending on given sensitivity type -//======================================================================= -Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPolygon (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts, - Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) const -{ - if (myActiveSelectingVolume.IsNull()) - { - return Standard_False; - } - - return myActiveSelectingVolume->OverlapsPolygon (theArrayOfPnts->Array1(), (Select3D_TypeOfSensitivity)theSensType, - myViewClipRange, thePickResult); -} - //======================================================================= // function : OverlapsPolygon // purpose : SAT intersection test between defined volume and given diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx index 1cd81cadd3..291831e7db 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx @@ -147,13 +147,6 @@ public: //! Intersection test between defined volume and given point Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE; - //! SAT intersection test between defined volume and given ordered set of points, - //! representing line segments. The test may be considered of interior part or - //! boundary line defined by segments depending on given sensitivity type - Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, - Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; - //! SAT intersection test between defined volume and given ordered set of points, //! representing line segments. The test may be considered of interior part or //! boundary line defined by segments depending on given sensitivity type @@ -248,22 +241,6 @@ public: public: -//! Deprecated static const class members aren't supported for Visual Studio prior to 2015 (vc14) -//! and GCC >= 5.0 and GCC < 6.3 (due to bug when warning was raised without member usage). -#if (!defined(_MSC_VER) || (_MSC_VER >= 1900)) && (!defined(__GNUC__) || (__GNUC__ != 5 && (__GNUC__ != 6 || __GNUC_MINOR__ >= 3))) - Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") - static const SelectMgr_SelectionType Point = SelectMgr_SelectionType_Point; - - Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") - static const SelectMgr_SelectionType Box = SelectMgr_SelectionType_Box; - - Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") - static const SelectMgr_SelectionType Polyline = SelectMgr_SelectionType_Polyline; - - Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") - static const SelectMgr_SelectionType Unknown = SelectMgr_SelectionType_Unknown; -#endif - Standard_DEPRECATED("Deprecated method - InitPointSelectingVolume() and Build() methods should be used instead") Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& thePoint); @@ -274,84 +251,6 @@ public: Standard_DEPRECATED("Deprecated method - InitPolylineSelectingVolume() and Build() should be used instead") Standard_EXPORT void BuildSelectingVolume (const TColgp_Array1OfPnt2d& thePoints); - //! SAT intersection test between defined volume and given axis-aligned box - Standard_DEPRECATED ("Deprecated method - OverlapsBox() should be used instead") - Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, - const SelectMgr_Vec3& theBoxMax, - SelectBasics_PickResult& thePickResult) const - { - return OverlapsBox (theBoxMin, theBoxMax, thePickResult); - } - - //! Returns true if selecting volume is overlapped by axis-aligned bounding box - //! with minimum corner at point theMinPt and maximum at point theMaxPt - Standard_DEPRECATED ("Deprecated method - OverlapsBox() should be used instead") - Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, - const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside = NULL) const - { - return OverlapsBox (theBoxMin, theBoxMax, theInside); - } - - //! Intersection test between defined volume and given point - Standard_DEPRECATED ("Deprecated method - OverlapsPoint() should be used instead") - Standard_Boolean Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) const - { - return OverlapsPoint (thePnt, thePickResult); - } - - //! Intersection test between defined volume and given point - Standard_DEPRECATED ("Deprecated method - OverlapsPoint() should be used instead") - Standard_Boolean Overlaps (const gp_Pnt& thePnt) const - { - return OverlapsPoint (thePnt); - } - - //! SAT intersection test between defined volume and given ordered set of points, - //! representing line segments. The test may be considered of interior part or - //! boundary line defined by segments depending on given sensitivity type - Standard_DEPRECATED ("Deprecated method - OverlapsPolygon() should be used instead") - Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, - Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) const - { - return OverlapsPolygon (theArrayOfPts, theSensType, thePickResult); - } - - //! SAT intersection test between defined volume and given ordered set of points, - //! representing line segments. The test may be considered of interior part or - //! boundary line defined by segments depending on given sensitivity type - Standard_DEPRECATED ("Deprecated method - OverlapsPolygon() should be used instead") - Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts, - Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) const - { - return OverlapsPolygon (theArrayOfPts, theSensType, thePickResult); - } - - //! Checks if line segment overlaps selecting frustum - Standard_DEPRECATED ("Deprecated method - OverlapsSegment() should be used instead") - Standard_Boolean Overlaps (const gp_Pnt& thePnt1, - const gp_Pnt& thePnt2, - SelectBasics_PickResult& thePickResult) const - { - return OverlapsSegment (thePnt1, thePnt2, thePickResult); - } - - //! SAT intersection test between defined volume and given triangle. The test may - //! be considered of interior part or boundary line defined by triangle vertices - //! depending on given sensitivity type - Standard_DEPRECATED ("Deprecated method - OverlapsTriangle() should be used instead") - Standard_Boolean Overlaps (const gp_Pnt& thePnt1, - const gp_Pnt& thePnt2, - const gp_Pnt& thePnt3, - Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) const - { - return OverlapsTriangle (thePnt1, thePnt2, thePnt3, theSensType, thePickResult); - } - private: Handle(SelectMgr_BaseIntersector) myActiveSelectingVolume; Handle(Graphic3d_SequenceOfHClipPlane) myViewClipPlanes; //!< view clipping planes diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx index c27aa4b668..72a15e36e3 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx @@ -17,12 +17,7 @@ #include -IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_TriangularFrustum,Standard_Transient) - -SelectMgr_TriangularFrustum::~SelectMgr_TriangularFrustum() -{ - Clear(); -} +IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_TriangularFrustum, Standard_Transient) namespace { @@ -41,6 +36,24 @@ namespace } } +// ======================================================================= +// function : SelectMgr_TriangularFrustum +// purpose : +// ======================================================================= +SelectMgr_TriangularFrustum::SelectMgr_TriangularFrustum() +{ + // +} + +// ======================================================================= +// function : ~SelectMgr_TriangularFrustum +// purpose : +// ======================================================================= +SelectMgr_TriangularFrustum::~SelectMgr_TriangularFrustum() +{ + Clear(); +} + // ======================================================================= // function : cacheVertexProjections // purpose : Caches projection of frustum's vertices onto its plane directions @@ -325,4 +338,4 @@ void SelectMgr_TriangularFrustum::DumpJson (Standard_OStream& theOStream, Standa { OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_TriangularFrustum) OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_Frustum) -} \ No newline at end of file +} diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx index 58990520ec..18ae7487e3 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx @@ -19,19 +19,11 @@ #include //! This class contains representation of triangular selecting frustum, created in case -//! of polyline selection, and algorithms for overlap detection between selecting -//! frustum and sensitive entities. -//! Overlap detection tests are implemented according to the terms of separating axis -//! theorem (SAT). +//! of polyline selection, and algorithms for overlap detection between selecting frustum and sensitive entities. +//! Overlap detection tests are implemented according to the terms of separating axis theorem (SAT). //! NOTE: the object of this class can be created only as part of SelectMgr_TriangularFrustumSet. class SelectMgr_TriangularFrustum : public SelectMgr_Frustum<3> { -protected: - - //! Creates new triangular frustum with bases of triangles with vertices theP1, - //! theP2 and theP3 projections onto near and far view frustum planes - SelectMgr_TriangularFrustum() {} - public: //! Auxiliary structure to define selection triangle @@ -40,7 +32,10 @@ public: gp_Pnt2d Points[3]; }; - Standard_EXPORT ~SelectMgr_TriangularFrustum(); +public: + + //! Destructor. + Standard_EXPORT virtual ~SelectMgr_TriangularFrustum(); //! Initializes selection triangle by input points Standard_EXPORT void Init (const gp_Pnt2d& theP1, @@ -52,12 +47,15 @@ public: //! NOTE: it should be called after Init() method Standard_EXPORT virtual void Build() Standard_OVERRIDE; + //! Returns FALSE (not applicable to this volume). + virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; } + //! Returns a copy of the frustum transformed according to the matrix given Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScale, const gp_GTrsf& theTrsf, const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE; - // SAT Tests for different objects +public: //! @name SAT Tests for different objects //! SAT intersection test between defined volume and given axis-aligned box Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPnt, @@ -76,6 +74,12 @@ public: const SelectMgr_ViewClipRange& theClipRange, SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; + //! Always returns FALSE (not applicable to this selector). + virtual Standard_Boolean OverlapsPoint (const gp_Pnt& ) const Standard_OVERRIDE + { + return Standard_False; + } + //! SAT intersection test between defined volume and given ordered set of points, //! representing line segments. The test may be considered of interior part or //! boundary line defined by segments depending on given sensitivity type @@ -100,6 +104,8 @@ public: const SelectMgr_ViewClipRange& theClipRange, SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; +public: + //! Nullifies the handle to corresponding builder instance to prevent memory leaks Standard_EXPORT void Clear(); @@ -110,6 +116,11 @@ public: //! Dumps the content of me into the stream Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; +protected: + + //! Creates an empty triangular frustum. + Standard_EXPORT SelectMgr_TriangularFrustum(); + private: void cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum) const; @@ -121,7 +132,6 @@ protected: public: DEFINE_STANDARD_RTTIEXT(SelectMgr_TriangularFrustum, SelectMgr_Frustum<3>) - friend class SelectMgr_TriangularFrustumSet; }; diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx index 3e15d50dd2..d07652a0e1 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx @@ -13,24 +13,36 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include + #include #include #include #include -#include - -#define MEMORY_BLOCK_SIZE 512 * 7 +namespace +{ + static const size_t MEMORY_BLOCK_SIZE = 512 * 7; +} // ======================================================================= // function : SelectMgr_TriangularFrustumSet // purpose : // ======================================================================= SelectMgr_TriangularFrustumSet::SelectMgr_TriangularFrustumSet() -: myToAllowOverlap (Standard_False) +: myToAllowOverlap (Standard_False) { } +// ======================================================================= +// function : ~SelectMgr_TriangularFrustumSet +// purpose : +// ======================================================================= +SelectMgr_TriangularFrustumSet::~SelectMgr_TriangularFrustumSet() +{ + // +} + // ======================================================================= // function : Init // purpose : @@ -150,8 +162,7 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustumSet::ScaleAndTransf "Error! SelectMgr_TriangularFrustumSet::ScaleAndTransform() should be called after selection frustum initialization"); Handle(SelectMgr_TriangularFrustumSet) aRes = new SelectMgr_TriangularFrustumSet(); - - for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next()) { aRes->myFrustums.Append (Handle(SelectMgr_TriangularFrustum)::DownCast (anIter.Value()->ScaleAndTransform (theScale, theTrsf, theBuilder))); } @@ -182,10 +193,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsBox (const SelectMgr_Ve Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Polyline, "Error! SelectMgr_TriangularFrustumSet::Overlaps() should be called after selection frustum initialization"); - for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next()) { if (anIter.Value()->OverlapsBox (theMinPnt, theMaxPnt, theClipRange, thePickResult)) + { return Standard_True; + } } return Standard_False; @@ -202,41 +215,41 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsBox (const SelectMgr_Ve Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Polyline, "Error! SelectMgr_TriangularFrustumSet::Overlaps() should be called after selection frustum initialization"); - for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next()) { - if (anIter.Value()->OverlapsBox (theMinPnt, theMaxPnt, NULL)) + if (!anIter.Value()->OverlapsBox (theMinPnt, theMaxPnt, NULL)) { - if (myToAllowOverlap || theInside == NULL) - { - return Standard_True; - } - else - { - gp_Pnt aMinMaxPnts[2] = { gp_Pnt (theMinPnt.x(), theMinPnt.y(), theMinPnt.z()), - gp_Pnt (theMaxPnt.x(), theMaxPnt.y(), theMaxPnt.z())}; - - gp_Pnt anOffset[3] = { gp_Pnt (aMinMaxPnts[1].X() - aMinMaxPnts[0].X(), 0.0, 0.0), - gp_Pnt (0.0, aMinMaxPnts[1].Y() - aMinMaxPnts[0].Y(), 0.0), - gp_Pnt (0.0, 0.0, aMinMaxPnts[1].Z() - aMinMaxPnts[0].Z()) }; - - Standard_Integer aSign = 1; - for (Standard_Integer aPntsIdx = 0; aPntsIdx < 2; aPntsIdx++) - { - for (Standard_Integer aCoordIdx = 0; aCoordIdx < 3; aCoordIdx++) - { - gp_Pnt anOffsetPnt = aMinMaxPnts [aPntsIdx].XYZ() + aSign * anOffset [aCoordIdx].XYZ(); - if (isIntersectBoundary (aMinMaxPnts [aPntsIdx], anOffsetPnt) - || isIntersectBoundary (anOffsetPnt, anOffsetPnt.XYZ() + aSign * anOffset [(aCoordIdx + 1) % 3].XYZ())) - { - *theInside &= Standard_False; - return Standard_True; - } - } - aSign = -aSign; - } - return Standard_True; - } + continue; } + + if (myToAllowOverlap || theInside == NULL) + { + return Standard_True; + } + + gp_Pnt aMinMaxPnts[2] = { gp_Pnt (theMinPnt.x(), theMinPnt.y(), theMinPnt.z()), + gp_Pnt (theMaxPnt.x(), theMaxPnt.y(), theMaxPnt.z())}; + + gp_Pnt anOffset[3] = { gp_Pnt (aMinMaxPnts[1].X() - aMinMaxPnts[0].X(), 0.0, 0.0), + gp_Pnt (0.0, aMinMaxPnts[1].Y() - aMinMaxPnts[0].Y(), 0.0), + gp_Pnt (0.0, 0.0, aMinMaxPnts[1].Z() - aMinMaxPnts[0].Z()) }; + + Standard_Integer aSign = 1; + for (Standard_Integer aPntsIdx = 0; aPntsIdx < 2; aPntsIdx++) + { + for (Standard_Integer aCoordIdx = 0; aCoordIdx < 3; aCoordIdx++) + { + gp_Pnt anOffsetPnt = aMinMaxPnts [aPntsIdx].XYZ() + aSign * anOffset [aCoordIdx].XYZ(); + if (isIntersectBoundary (aMinMaxPnts [aPntsIdx], anOffsetPnt) + || isIntersectBoundary (anOffsetPnt, anOffsetPnt.XYZ() + aSign * anOffset [(aCoordIdx + 1) % 3].XYZ())) + { + *theInside &= Standard_False; + return Standard_True; + } + } + aSign = -aSign; + } + return Standard_True; } return Standard_False; @@ -253,10 +266,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsPoint (const gp_Pnt& th Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Polyline, "Error! SelectMgr_TriangularFrustumSet::Overlaps() should be called after selection frustum initialization"); - for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next()) { if (anIter.Value()->OverlapsPoint (thePnt, theClipRange, thePickResult)) + { return Standard_True; + } } return Standard_False; @@ -274,28 +289,28 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsPolygon (const TColgp_A Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Polyline, "Error! SelectMgr_TriangularFrustumSet::Overlaps() should be called after selection frustum initialization"); - for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next()) { - if (anIter.Value()->OverlapsPolygon (theArrayOfPts, theSensType, theClipRange, thePickResult)) + if (!anIter.Value()->OverlapsPolygon (theArrayOfPts, theSensType, theClipRange, thePickResult)) { - if (myToAllowOverlap) + continue; + } + + if (myToAllowOverlap) + { + return Standard_True; + } + + Standard_Integer aPtsLower = theArrayOfPts.Lower(); + Standard_Integer aPtsUpper = theArrayOfPts.Upper(); + for (Standard_Integer anIdx = aPtsLower; anIdx <= aPtsUpper; anIdx++) + { + if (isIntersectBoundary (theArrayOfPts.Value (anIdx), theArrayOfPts.Value (anIdx < aPtsUpper ? anIdx + 1 : aPtsLower))) { - return Standard_True; - } - else - { - Standard_Integer aPtsLower = theArrayOfPts.Lower(); - Standard_Integer aPtsUpper = theArrayOfPts.Upper(); - for (Standard_Integer anIdx = aPtsLower; anIdx <= aPtsUpper; anIdx++) - { - if (isIntersectBoundary (theArrayOfPts.Value (anIdx), theArrayOfPts.Value (anIdx < aPtsUpper ? anIdx + 1 : aPtsLower))) - { - return Standard_False; - } - } - return Standard_True; + return Standard_False; } } + return Standard_True; } return Standard_False; @@ -313,23 +328,23 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsSegment (const gp_Pnt& Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Polyline, "Error! SelectMgr_TriangularFrustumSet::Overlaps() should be called after selection frustum initialization"); - for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next()) { - if (anIter.Value()->OverlapsSegment (thePnt1, thePnt2, theClipRange, thePickResult)) + if (!anIter.Value()->OverlapsSegment (thePnt1, thePnt2, theClipRange, thePickResult)) { - if (myToAllowOverlap) - { - return Standard_True; - } - else - { - if (isIntersectBoundary (thePnt1, thePnt2)) - { - return Standard_False; - } - return Standard_True; - } + continue; } + + if (myToAllowOverlap) + { + return Standard_True; + } + + if (isIntersectBoundary (thePnt1, thePnt2)) + { + return Standard_False; + } + return Standard_True; } return Standard_False; @@ -349,25 +364,25 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsTriangle (const gp_Pnt& Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Polyline, "Error! SelectMgr_TriangularFrustumSet::Overlaps() should be called after selection frustum initialization"); - for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next()) { - if (anIter.Value()->OverlapsTriangle (thePnt1, thePnt2, thePnt3, theSensType, theClipRange, thePickResult)) + if (!anIter.Value()->OverlapsTriangle (thePnt1, thePnt2, thePnt3, theSensType, theClipRange, thePickResult)) { - if (myToAllowOverlap) - { - return Standard_True; - } - else - { - if (isIntersectBoundary (thePnt1, thePnt2) - || isIntersectBoundary (thePnt2, thePnt3) - || isIntersectBoundary (thePnt3, thePnt1)) - { - return Standard_False; - } - return Standard_True; - } + continue; } + + if (myToAllowOverlap) + { + return Standard_True; + } + + if (isIntersectBoundary (thePnt1, thePnt2) + || isIntersectBoundary (thePnt2, thePnt3) + || isIntersectBoundary (thePnt3, thePnt1)) + { + return Standard_False; + } + return Standard_True; } return Standard_False; @@ -381,7 +396,7 @@ void SelectMgr_TriangularFrustumSet::GetPlanes (NCollection_VectorGetPlanes (thePlaneEquations); } @@ -485,11 +500,9 @@ void SelectMgr_TriangularFrustumSet::DumpJson (Standard_OStream& theOStream, Sta OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_TriangularFrustumSet) OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_BaseFrustum) - for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) + for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next()) { const Handle(SelectMgr_TriangularFrustum)& aFrustum = anIter.Value(); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aFrustum.get()) } } - -#undef MEMORY_BLOCK_SIZE diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx index 14c1f38291..70cfb7a5c8 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx @@ -20,16 +20,14 @@ #include typedef NCollection_List SelectMgr_TriangFrustums; -typedef NCollection_List::Iterator SelectMgr_TriangFrustumsIter; //! This class is used to handle polyline selection. The main principle of polyline selection -//! algorithm is to split the polygon defined by polyline onto triangles. Than each of -//! them is considered as a base for triangular frustum building. In other -//! words, each triangle vertiex will be projected from 2d screen space to 3d world space -//! onto near and far view frustum planes. Thus, the projected triangles make up the bases of -//! selecting frustum. When the set of such frustums is created, the function determining -//! selection iterates through triangular frustum set and searches for overlap with any -//! frustum. +//! algorithm is to split the polygon defined by polyline onto triangles. +//! Than each of them is considered as a base for triangular frustum building. +//! In other words, each triangle vertex will be projected from 2d screen space to 3d world space onto near and far view frustum planes. +//! Thus, the projected triangles make up the bases of selecting frustum. +//! When the set of such frustums is created, the function determining +//! selection iterates through triangular frustum set and searches for overlap with any frustum. class SelectMgr_TriangularFrustumSet : public SelectMgr_BaseFrustum { public: @@ -40,24 +38,32 @@ public: Handle(TColgp_HArray1OfPnt2d) Points; }; +public: + + //! Constructor. SelectMgr_TriangularFrustumSet(); - ~SelectMgr_TriangularFrustumSet() {}; + //! Destructor. + Standard_EXPORT virtual ~SelectMgr_TriangularFrustumSet(); //! Initializes set of triangular frustums by polyline Standard_EXPORT void Init (const TColgp_Array1OfPnt2d& thePoints); //! Meshes polygon bounded by polyline. Than organizes a set of triangular frustums, - //! where each triangle's projection onto near and far view frustum planes is - //! considered as a frustum base + //! where each triangle's projection onto near and far view frustum planes is considered as a frustum base //! NOTE: it should be called after Init() method Standard_EXPORT virtual void Build() Standard_OVERRIDE; + //! Returns FALSE (not applicable to this volume). + virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; } + //! Returns a copy of the frustum with all sub-volumes transformed according to the matrix given Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScale, const gp_GTrsf& theTrsf, const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE; +public: + Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPnt, const SelectMgr_Vec3& theMaxPnt, const SelectMgr_ViewClipRange& theClipRange, @@ -71,6 +77,12 @@ public: const SelectMgr_ViewClipRange& theClipRange, SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; + //! Always returns FALSE (not applicable to this selector). + virtual Standard_Boolean OverlapsPoint (const gp_Pnt& ) const Standard_OVERRIDE + { + return Standard_False; + } + Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts, Select3D_TypeOfSensitivity theSensType, const SelectMgr_ViewClipRange& theClipRange, @@ -88,6 +100,8 @@ public: const SelectMgr_ViewClipRange& theClipRange, SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; +public: + //! Calculates the point on a view ray that was detected during the run of selection algo by given depth Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;