From 4a056d205b17a587deae6611c05a2ccf930b1375 Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 17 Aug 2018 15:00:11 +0300 Subject: [PATCH] 0030058: Visualization, Select3D_SensitivePrimitiveArray - the selection is not fast enough Select3D_SensitiveSet::Matches() has been improved to check if BVH node is fully included by selection volume and pass this information to overlapsElement()/elementIsInside() interfaces to avoid expensive partial overlapping checks for individual elements. Select3D_SensitivePrimitiveArray implements this new interface to improve partial overlapping performance. Select3D_SensitivePrimitiveArray::Matches() now handles rectangle selection for sub-elements when Elements map is defined. Added missing const to SelectMgr_BaseFrustum::Overlaps() methods. AIS_PointCloud has been extended with new selection mode for collecting selected nodes Draw Harness command vdrawparray has been extended with an option -shape allowing to create a triangulation from tessellated shape. --- src/AIS/AIS_PointCloud.cxx | 144 +++++++++++++++++- src/AIS/AIS_PointCloud.hxx | 51 +++++-- src/MeshVS/MeshVS_CommonSensitiveEntity.cxx | 18 ++- src/MeshVS/MeshVS_CommonSensitiveEntity.hxx | 8 +- .../Select3D_InteriorSensitivePointSet.cxx | 13 +- .../Select3D_InteriorSensitivePointSet.hxx | 8 +- src/Select3D/Select3D_SensitiveGroup.cxx | 10 +- src/Select3D/Select3D_SensitiveGroup.hxx | 8 +- src/Select3D/Select3D_SensitivePoly.cxx | 21 ++- src/Select3D/Select3D_SensitivePoly.hxx | 8 +- .../Select3D_SensitivePrimitiveArray.cxx | 68 ++++----- .../Select3D_SensitivePrimitiveArray.hxx | 8 +- src/Select3D/Select3D_SensitiveSet.cxx | 90 +++++++---- src/Select3D/Select3D_SensitiveSet.hxx | 42 +++-- .../Select3D_SensitiveTriangulation.cxx | 20 ++- .../Select3D_SensitiveTriangulation.hxx | 8 +- src/Select3D/Select3D_SensitiveWire.cxx | 8 +- src/Select3D/Select3D_SensitiveWire.hxx | 8 +- src/SelectBasics/SelectBasics_EntityOwner.cxx | 10 ++ src/SelectBasics/SelectBasics_EntityOwner.hxx | 4 +- .../SelectBasics_SelectingVolumeManager.hxx | 18 +-- src/SelectMgr/SelectMgr_BaseFrustum.cxx | 18 +-- src/SelectMgr/SelectMgr_BaseFrustum.hxx | 18 +-- src/SelectMgr/SelectMgr_Frustum.hxx | 10 +- src/SelectMgr/SelectMgr_Frustum.lxx | 10 +- .../SelectMgr_RectangularFrustum.cxx | 24 +-- .../SelectMgr_RectangularFrustum.hxx | 24 +-- .../SelectMgr_SelectingVolumeManager.cxx | 20 +-- .../SelectMgr_SelectingVolumeManager.hxx | 20 +-- src/SelectMgr/SelectMgr_TriangularFrustum.cxx | 12 +- src/SelectMgr/SelectMgr_TriangularFrustum.hxx | 12 +- .../SelectMgr_TriangularFrustumSet.cxx | 12 +- .../SelectMgr_TriangularFrustumSet.hxx | 12 +- src/ViewerTest/ViewerTest_ObjectCommands.cxx | 41 +++-- 34 files changed, 548 insertions(+), 258 deletions(-) diff --git a/src/AIS/AIS_PointCloud.cxx b/src/AIS/AIS_PointCloud.cxx index 454dbc202e..dcfea91c14 100644 --- a/src/AIS/AIS_PointCloud.cxx +++ b/src/AIS/AIS_PointCloud.cxx @@ -32,8 +32,140 @@ #include #include +IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner) +IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject) -IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud,AIS_InteractiveObject) +//======================================================================= +//function : AIS_PointCloudOwner +//purpose : +//======================================================================= +AIS_PointCloudOwner::AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin) +: SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theOrigin, 5), + myDetPoints (new TColStd_HPackedMapOfInteger()), + mySelPoints (new TColStd_HPackedMapOfInteger()) +{ + // +} + +//======================================================================= +//function : ~AIS_PointCloudOwner +//purpose : +//======================================================================= +AIS_PointCloudOwner::~AIS_PointCloudOwner() +{ + // +} + +//======================================================================= +//function : HilightWithColor +//purpose : +//======================================================================= +Standard_Boolean AIS_PointCloudOwner::IsForcedHilight() const +{ + return true; +} + +//======================================================================= +//function : HilightWithColor +//purpose : +//======================================================================= +void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, + const Handle(Prs3d_Drawer)& theStyle, + const Standard_Integer ) +{ + Handle(AIS_PointCloud) anObj = Handle(AIS_PointCloud)::DownCast (Selectable()); + if (anObj.IsNull()) + { + throw Standard_ProgramError ("Internal Error within AIS_PointCloud::PointsOwner!"); + } + + const Handle(TColStd_HPackedMapOfInteger)& aMap = thePrsMgr->IsImmediateModeOn() + ? myDetPoints + : mySelPoints; + Handle(Prs3d_Presentation) aPrs = thePrsMgr->IsImmediateModeOn() + ? anObj->GetHilightPresentation(thePrsMgr) + : anObj->GetSelectPresentation (thePrsMgr); + const Graphic3d_ZLayerId aZLayer = theStyle->ZLayer() != -1 + ? theStyle->ZLayer() + : (thePrsMgr->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : anObj->ZLayer()); + aMap->ChangeMap().Clear(); + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) + { + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + for (NCollection_Vector::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) + { + const Handle(SelectMgr_SensitiveEntity)& aSelEnt = aSelEntIter.Value(); + if (aSelEnt->BaseSensitive()->OwnerId() == this) + { + if (Handle(Select3D_SensitivePrimitiveArray) aSensitive = Handle(Select3D_SensitivePrimitiveArray)::DownCast (aSelEnt->BaseSensitive())) + { + aMap->ChangeMap() = aSensitive->LastDetectedElementMap()->Map(); + if (aSensitive->LastDetectedElement() != -1) + { + aMap->ChangeMap().Add (aSensitive->LastDetectedElement()); + } + break; + } + } + } + } + + aPrs->Clear(); + if (aPrs->GetZLayer() != aZLayer) + { + aPrs->SetZLayer (aZLayer); + } + if (aMap->Map().IsEmpty()) + { + return; + } + + const Handle(Graphic3d_ArrayOfPoints) anAllPoints = anObj->GetPoints(); + if (anAllPoints.IsNull()) + { + return; + } + + Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (aMap->Map().Extent()); + for (TColStd_PackedMapOfInteger::Iterator aPntIter (aMap->Map()); aPntIter.More(); aPntIter.Next()) + { + const gp_Pnt aPnt = anAllPoints->Vertice (aPntIter.Key() + 1); + aPoints->AddVertex (aPnt); + } + + Handle(Graphic3d_Group) aGroup = aPrs->NewGroup(); + aGroup->SetGroupPrimitivesAspect (theStyle->PointAspect()->Aspect()); + aGroup->AddPrimitiveArray (aPoints); + if (thePrsMgr->IsImmediateModeOn()) + { + thePrsMgr->AddToImmediateList (aPrs); + } + else + { + aPrs->Display(); + } +} + +//======================================================================= +//function : Unhilight +//purpose : +//======================================================================= +void AIS_PointCloudOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer ) +{ + if (Handle(Prs3d_Presentation) aPrs = Selectable()->GetSelectPresentation (Handle(PrsMgr_PresentationManager3d)())) + { + aPrs->Erase(); + } +} + +//======================================================================= +//function : Clear +//purpose : +//======================================================================= +void AIS_PointCloudOwner::Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) +{ + SelectMgr_EntityOwner::Clear (thePrsMgr, theMode); +} //================================================== // Function: AIS_PointCloud @@ -46,6 +178,8 @@ AIS_PointCloud::AIS_PointCloud() SetDisplayMode (AIS_PointCloud::DM_Points); SetHilightMode (AIS_PointCloud::DM_BndBox); + + myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 1.0)); } //======================================================================= @@ -432,14 +566,22 @@ void AIS_PointCloud::ComputeSelection (const Handle(SelectMgr_Selection)& theSel switch (theMode) { case SM_Points: + case SM_SubsetOfPoints: { const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints(); if (!aPoints.IsNull() && !aPoints->Attributes().IsNull()) { + if (theMode == SM_SubsetOfPoints) + { + anOwner = new AIS_PointCloudOwner (this); + } + // split large point clouds into several groups const Standard_Integer aNbGroups = aPoints->Attributes()->NbElements > 500000 ? 8 : 1; Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anOwner); + aSensitive->SetDetectElements (true); + aSensitive->SetDetectElementMap (theMode == SM_SubsetOfPoints); aSensitive->SetSensitivityFactor (8); aSensitive->InitPoints (aPoints->Attributes(), aPoints->Indices(), TopLoc_Location(), true, aNbGroups); aSensitive->BVH(); diff --git a/src/AIS/AIS_PointCloud.hxx b/src/AIS/AIS_PointCloud.hxx index 83f3f9a88c..ab7ab322fc 100644 --- a/src/AIS/AIS_PointCloud.hxx +++ b/src/AIS/AIS_PointCloud.hxx @@ -21,14 +21,11 @@ #include #include #include -#include -#include -#include +#include #include #include -class AIS_PointCloud; -DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject) +class TColStd_HPackedMapOfInteger; //! Interactive object for set of points. //! The presentation supports two display modes: @@ -43,7 +40,7 @@ DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject) //! hilight mode, e.g. 100); class AIS_PointCloud : public AIS_InteractiveObject { - + DEFINE_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject) public: //! Display modes supported by this Point Cloud object @@ -56,8 +53,9 @@ public: //! Selection modes supported by this Point Cloud object enum SelectionMode { - SM_Points = 0, //!< detected by points - SM_BndBox = 2 //!< detected by bounding box + SM_Points = 0, //!< detected by points + SM_SubsetOfPoints = 1, //!< detect point(s) within Point Cloud rather than object as whole + SM_BndBox = 2, //!< detected by bounding box }; public: @@ -121,10 +119,45 @@ private: Handle(Graphic3d_ArrayOfPoints) myPoints; //!< points array for presentation Bnd_Box myBndBox; //!< bounding box for presentation +}; + +DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject) + +//! Custom owner for highlighting selected points. +class AIS_PointCloudOwner : public SelectMgr_EntityOwner +{ + DEFINE_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner) public: + //! Main constructor. + Standard_EXPORT AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin); - DEFINE_STANDARD_RTTIEXT(AIS_PointCloud,AIS_InteractiveObject) + //! Destructor. + Standard_EXPORT virtual ~AIS_PointCloudOwner(); + //! Return selected points. + //! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()). + const Handle(TColStd_HPackedMapOfInteger)& SelectedPoints() const { return mySelPoints; } + + //! Return last detected points. + //! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()). + const Handle(TColStd_HPackedMapOfInteger)& DetectedPoints() const { return myDetPoints; } + + //! Always update dynamic highlighting. + Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE; + + //! Handle dynamic highlighting. + Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, + const Handle(Prs3d_Drawer)& theStyle, + const Standard_Integer theMode) Standard_OVERRIDE; + + //! Removes highlighting. + Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE; + + //! Clears presentation. + Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE; +protected: + Handle(TColStd_HPackedMapOfInteger) myDetPoints; //!< last detected points + Handle(TColStd_HPackedMapOfInteger) mySelPoints; //!< selected points }; #endif // _AIS_PointCloud_HeaderFile diff --git a/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx b/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx index c6a445ec62..eacba59f27 100644 --- a/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx +++ b/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx @@ -222,10 +222,16 @@ void MeshVS_CommonSensitiveEntity::Swap (const Standard_Integer theIdx1, //function : overlapsElement //purpose : //======================================================================= -Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, +Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) + Standard_Boolean theIsFullInside) { + if (theIsFullInside) + { + return Standard_True; + } + const Standard_Integer anItemIdx = myItemIndexes.Value (theElemIdx); if (mySelMethod == MeshVS_MSM_PRECISE) { @@ -276,8 +282,14 @@ Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_Sel //purpose : //======================================================================= Standard_Boolean MeshVS_CommonSensitiveEntity::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) { + if (theIsFullInside) + { + return Standard_True; + } + const Standard_Integer anItemIdx = myItemIndexes.Value (theElemIdx); if (mySelMethod == MeshVS_MSM_PRECISE) { diff --git a/src/MeshVS/MeshVS_CommonSensitiveEntity.hxx b/src/MeshVS/MeshVS_CommonSensitiveEntity.hxx index 6f9bae8518..dd2ea1d564 100644 --- a/src/MeshVS/MeshVS_CommonSensitiveEntity.hxx +++ b/src/MeshVS/MeshVS_CommonSensitiveEntity.hxx @@ -65,13 +65,15 @@ public: protected: //! Checks whether the entity with index theIdx overlaps the current selecting volume - Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, + Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Checks whether the entity with index theIdx is inside the current selecting volume Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) Standard_OVERRIDE; + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE; diff --git a/src/Select3D/Select3D_InteriorSensitivePointSet.cxx b/src/Select3D/Select3D_InteriorSensitivePointSet.cxx index 553ddcb378..7e0c76e78c 100644 --- a/src/Select3D/Select3D_InteriorSensitivePointSet.cxx +++ b/src/Select3D/Select3D_InteriorSensitivePointSet.cxx @@ -259,12 +259,12 @@ void Select3D_InteriorSensitivePointSet::Swap (const Standard_Integer theIdx1, // ======================================================================= // function : overlapsElement -// purpose : Checks whether the planar convex polygon with index theIdx -// in myPlanarPolygons overlaps the current selecting volume +// purpose : // ======================================================================= -Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, +Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) + Standard_Boolean ) { Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theElemIdx); const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx); @@ -278,10 +278,11 @@ Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasi // purpose : // ======================================================================= Standard_Boolean Select3D_InteriorSensitivePointSet::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) { SelectBasics_PickResult aDummy; - return overlapsElement (theMgr, theElemIdx, aDummy); + return overlapsElement (aDummy, theMgr, theElemIdx, theIsFullInside); } // ======================================================================= diff --git a/src/Select3D/Select3D_InteriorSensitivePointSet.hxx b/src/Select3D/Select3D_InteriorSensitivePointSet.hxx index cfaca922a0..4375f221a0 100644 --- a/src/Select3D/Select3D_InteriorSensitivePointSet.hxx +++ b/src/Select3D/Select3D_InteriorSensitivePointSet.hxx @@ -76,13 +76,15 @@ protected: //! Checks whether the planar convex polygon with index theIdx //! in myPlanarPolygons overlaps the current selecting volume - Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, + Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Checks whether the entity with index theIdx is inside the current selecting volume Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) Standard_OVERRIDE; + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Calculates distance from the 3d projection of used-picked //! screen point to center of the geometry diff --git a/src/Select3D/Select3D_SensitiveGroup.cxx b/src/Select3D/Select3D_SensitiveGroup.cxx index edf866c8e1..31215fc11c 100644 --- a/src/Select3D/Select3D_SensitiveGroup.cxx +++ b/src/Select3D/Select3D_SensitiveGroup.cxx @@ -326,9 +326,10 @@ Standard_Integer Select3D_SensitiveGroup::Size() const // purpose : Checks whether the entity with index theIdx overlaps the // current selecting volume // ======================================================================= -Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, +Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) + Standard_Boolean ) { const Standard_Integer aSensitiveIdx = myBVHPrimIndexes.Value (theElemIdx); if (myEntities.FindKey (aSensitiveIdx)->Matches (theMgr, thePickResult)) @@ -344,10 +345,11 @@ Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_Selectin // purpose : // ======================================================================= Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) { SelectBasics_PickResult aDummy; - return overlapsElement(theMgr, theElemIdx, aDummy); + return overlapsElement (aDummy, theMgr, theElemIdx, theIsFullInside); } // ======================================================================= diff --git a/src/Select3D/Select3D_SensitiveGroup.hxx b/src/Select3D/Select3D_SensitiveGroup.hxx index 7b7380f609..58e64a383c 100644 --- a/src/Select3D/Select3D_SensitiveGroup.hxx +++ b/src/Select3D/Select3D_SensitiveGroup.hxx @@ -146,13 +146,15 @@ public: private: //! Checks whether the entity with index theIdx overlaps the current selecting volume - virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, + virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Checks whether the entity with index theIdx is inside the current selecting volume virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) Standard_OVERRIDE; + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE; diff --git a/src/Select3D/Select3D_SensitivePoly.cxx b/src/Select3D/Select3D_SensitivePoly.cxx index 5c19d6892d..20ffe84904 100644 --- a/src/Select3D/Select3D_SensitivePoly.cxx +++ b/src/Select3D/Select3D_SensitivePoly.cxx @@ -220,17 +220,23 @@ void Select3D_SensitivePoly::Swap (const Standard_Integer theIdx1, // theIdx overlaps the current selecting // volume //================================================== -Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, +Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) + Standard_Boolean theIsFullInside) { if (mySegmentIndexes.IsNull()) + { return Standard_False; + } + else if (theIsFullInside) + { + return Standard_True; + } const Standard_Integer aSegmentIdx = mySegmentIndexes->Value (theElemIdx); gp_Pnt aPnt1 = myPolyg.Pnt3d (aSegmentIdx); gp_Pnt aPnt2 = myPolyg.Pnt3d (aSegmentIdx + 1); - return theMgr.Overlaps (aPnt1, aPnt2, thePickResult); } @@ -239,10 +245,15 @@ Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_Selecting // Purpose : //================================================== Standard_Boolean Select3D_SensitivePoly::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) { - const Standard_Integer aSegmentIdx = mySegmentIndexes->Value (theElemIdx); + if (theIsFullInside) + { + return Standard_True; + } + const Standard_Integer aSegmentIdx = mySegmentIndexes->Value (theElemIdx); return theMgr.Overlaps (myPolyg.Pnt3d (aSegmentIdx + 0)) && theMgr.Overlaps (myPolyg.Pnt3d (aSegmentIdx + 1)); } diff --git a/src/Select3D/Select3D_SensitivePoly.hxx b/src/Select3D/Select3D_SensitivePoly.hxx index aaa7429abd..8f600c8405 100644 --- a/src/Select3D/Select3D_SensitivePoly.hxx +++ b/src/Select3D/Select3D_SensitivePoly.hxx @@ -95,13 +95,15 @@ public: private: //! Checks whether the segment with index theIdx overlaps the current selecting volume - virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, + virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Checks whether the entity with index theIdx is inside the current selecting volume virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) Standard_OVERRIDE; + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Calculates distance from the 3d projection of used-picked screen point //! to center of the geometry diff --git a/src/Select3D/Select3D_SensitivePrimitiveArray.cxx b/src/Select3D/Select3D_SensitivePrimitiveArray.cxx index eb3dcf5df5..f7dd11d194 100644 --- a/src/Select3D/Select3D_SensitivePrimitiveArray.cxx +++ b/src/Select3D/Select3D_SensitivePrimitiveArray.cxx @@ -908,7 +908,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti || theMgr.GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point || !toDetectRange) { - if (!Select3D_SensitiveSet::Matches (theMgr, thePickResult)) + if (!matches (theMgr, thePickResult, toDetectRange)) { return Standard_False; } @@ -929,35 +929,22 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti } SelectBasics_PickResult aPickResult; - bool isFailed = false; - const bool toMatchAll = !theMgr.IsOverlapAllowed(); + bool hasResults = false; for (Standard_Integer aGroupIter = 0; aGroupIter < myBvhIndices.NbElements; ++aGroupIter) { const Standard_Integer anElemIdx = myBvhIndices.Index (aGroupIter); Handle(Select3D_SensitivePrimitiveArray)& aChild = myGroups->ChangeValue (anElemIdx); - const bool isMatched = aChild->Matches (theMgr, aPickResult); - if (!myDetectedElemMap.IsNull()) + if (aChild->Matches (theMgr, aPickResult)) { - myDetectedElemMap->ChangeMap().Unite (aChild->myDetectedElemMap->Map()); - } - if (!myDetectedNodeMap.IsNull()) - { - myDetectedNodeMap->ChangeMap().Unite (aChild->myDetectedNodeMap->Map()); - } - - if (!isMatched) - { - if (toMatchAll) + hasResults = true; + if (!myDetectedElemMap.IsNull()) { - isFailed = true; - if (!toDetectRange) - { - break; - } + myDetectedElemMap->ChangeMap().Unite (aChild->myDetectedElemMap->Map()); + } + if (!myDetectedNodeMap.IsNull()) + { + myDetectedNodeMap->ChangeMap().Unite (aChild->myDetectedNodeMap->Map()); } - } - else - { if (thePickResult.Depth() > aPickResult.Depth()) { myDetectedIdx = aGroupIter; @@ -965,7 +952,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti } } } - if (isFailed) + if (!hasResults) { return Standard_False; } @@ -977,19 +964,15 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti // function : overlapsElement // purpose : // ======================================================================= -Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, +Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) + Standard_Boolean theIsFullInside) { const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx); if (!myGroups.IsNull()) { - if (myGroups->Value (anElemIdx)->Matches (theMgr, thePickResult)) - { - return Standard_True; - } - - return Standard_False; + return myGroups->Value (anElemIdx)->Matches (theMgr, thePickResult); } const Standard_Integer aPatchSize = myBvhIndices.PatchSize (theElemIdx); @@ -1019,7 +1002,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics if (myToDetectNode || myToDetectElem) { - if (theMgr.Overlaps (aPoint, aPickResult)) + if (theIsFullInside || theMgr.Overlaps (aPoint, aPickResult)) { if (aPickResult.Depth() <= myMinDepthNode) { @@ -1068,7 +1051,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics if (myToDetectElem) { - if (theMgr.Overlaps (aPnts[0], aPnts[1], aPnts[2], Select3D_TOS_INTERIOR, aPickResult)) + if (theIsFullInside || theMgr.Overlaps (aPnts[0], aPnts[1], aPnts[2], Select3D_TOS_INTERIOR, aPickResult)) { if (aPickResult.Depth() <= myMinDepthElem) { @@ -1087,7 +1070,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics { for (int aNodeIter = 0; aNodeIter < 3; ++aNodeIter) { - if (theMgr.Overlaps (aPnts[aNodeIter], aPickResult)) + if (theIsFullInside || theMgr.Overlaps (aPnts[aNodeIter], aPickResult)) { if (aPickResult.Depth() <= myMinDepthNode) { @@ -1109,7 +1092,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics { int aNode1 = aNodeIter == 0 ? 2 : (aNodeIter - 1); int aNode2 = aNodeIter; - if (theMgr.Overlaps (aPnts[aNode1], aPnts[aNode2], aPickResult)) + if (theIsFullInside || theMgr.Overlaps (aPnts[aNode1], aPnts[aNode2], aPickResult)) { if (aPickResult.Depth() <= myMinDepthEdge) { @@ -1148,13 +1131,14 @@ Standard_Real Select3D_SensitivePrimitiveArray::distanceToCOG (SelectBasics_Sele // purpose : // ======================================================================= Standard_Boolean Select3D_SensitivePrimitiveArray::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) { const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx); if (!myGroups.IsNull()) { SelectBasics_PickResult aDummy; - return overlapsElement (theMgr, theElemIdx, aDummy); + return myGroups->Value (anElemIdx)->Matches (theMgr, aDummy); } const Standard_Integer aPatchSize = myBvhIndices.PatchSize (theElemIdx); @@ -1177,7 +1161,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::elementIsInside (SelectBasics { aPoint = vecToPnt (getPosVec2 (aPointIndex)); } - if (!theMgr.Overlaps (aPoint)) + if (!theIsFullInside && !theMgr.Overlaps (aPoint)) { return Standard_False; } @@ -1218,9 +1202,9 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::elementIsInside (SelectBasics aPnts[2] = vecToPnt (getPosVec2 (aTriNodes[2])); } - if (!theMgr.Overlaps (aPnts[0]) - || !theMgr.Overlaps (aPnts[1]) - || !theMgr.Overlaps (aPnts[2])) + if (!theIsFullInside && ( !theMgr.Overlaps (aPnts[0]) + || !theMgr.Overlaps (aPnts[1]) + || !theMgr.Overlaps (aPnts[2]))) { return Standard_False; } diff --git a/src/Select3D/Select3D_SensitivePrimitiveArray.hxx b/src/Select3D/Select3D_SensitivePrimitiveArray.hxx index c36cd3e91c..50e767bf04 100644 --- a/src/Select3D/Select3D_SensitivePrimitiveArray.hxx +++ b/src/Select3D/Select3D_SensitivePrimitiveArray.hxx @@ -278,16 +278,18 @@ protected: } //! Checks whether the element with index theIdx overlaps the current selecting volume - Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, + Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE; //! Checks whether the entity with index theIdx is inside the current selecting volume Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) Standard_OVERRIDE; + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) Standard_OVERRIDE; private: diff --git a/src/Select3D/Select3D_SensitiveSet.cxx b/src/Select3D/Select3D_SensitiveSet.cxx index df7f996639..c7e606ad06 100644 --- a/src/Select3D/Select3D_SensitiveSet.cxx +++ b/src/Select3D/Select3D_SensitiveSet.cxx @@ -65,14 +65,26 @@ void Select3D_SensitiveSet::BVH() myContent.GetBVH(); } +namespace +{ + //! This structure describes the node in BVH + struct NodeInStack + { + NodeInStack (Standard_Integer theId = 0, + Standard_Boolean theIsFullInside = false) : Id (theId), IsFullInside (theIsFullInside) {} + + Standard_Integer Id; //!< node identifier + Standard_Boolean IsFullInside; //!< if the node is completely inside the current selection volume + }; +} + //======================================================================= // function : Matches -// purpose : Checks whether one or more entities of the set overlap -// current selecting volume. Implements the traverse of BVH -// tree built for the set +// purpose : //======================================================================= -Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeManager& theMgr, - SelectBasics_PickResult& thePickResult) +Standard_Boolean Select3D_SensitiveSet::matches (SelectBasics_SelectingVolumeManager& theMgr, + SelectBasics_PickResult& thePickResult, + Standard_Boolean theToCheckAllInside) { myDetectedIdx = -1; const BVH_Tree* aBVH = myContent.GetBVH().get(); @@ -82,50 +94,58 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan return Standard_False; } - Standard_Integer aStack[BVH_Constants_MaxTreeDepth]; - Standard_Integer aNode = 0; + NodeInStack aStack[BVH_Constants_MaxTreeDepth]; + NodeInStack aNode; + Standard_Integer aHead = -1; Standard_Integer aMatchesNb = -1; SelectBasics_PickResult aPickResult; + const bool toCheckFullInside = (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point); for (;;) { - const BVH_Vec4i& aData = aBVH->NodeInfoBuffer()[aNode]; + const BVH_Vec4i& aData = aBVH->NodeInfoBuffer()[aNode.Id]; if (aData.x() == 0) // is inner node { - const Standard_Integer aLftIdx = aData.y(); - const Standard_Integer aRghIdx = aData.z(); + NodeInStack aLeft (aData.y(), toCheckFullInside), aRight(aData.z(), toCheckFullInside); + Standard_Boolean toCheckLft = Standard_True, toCheckRgh = Standard_True; + if (!aNode.IsFullInside) + { + toCheckLft = theMgr.Overlaps (aBVH->MinPoint (aLeft.Id), aBVH->MaxPoint (aLeft.Id), toCheckFullInside ? &aLeft.IsFullInside : NULL); + if (!toCheckLft) + { + aLeft.IsFullInside = Standard_False; + } - Standard_Boolean isLftInside = Standard_True; - Standard_Boolean isRghInside = Standard_True; - - Standard_Boolean toCheckLft = theMgr.Overlaps (aBVH->MinPoint (aLftIdx), - aBVH->MaxPoint (aLftIdx), - theMgr.IsOverlapAllowed() ? NULL : &isLftInside); - - Standard_Boolean toCheckRgh = theMgr.Overlaps (aBVH->MinPoint (aRghIdx), - aBVH->MaxPoint (aRghIdx), - theMgr.IsOverlapAllowed() ? NULL : &isRghInside); + toCheckRgh = theMgr.Overlaps (aBVH->MinPoint (aRight.Id), aBVH->MaxPoint (aRight.Id), toCheckFullInside ? &aRight.IsFullInside : NULL); + if (!toCheckRgh) + { + aRight.IsFullInside = Standard_False; + } + } if (!theMgr.IsOverlapAllowed()) // inclusion test { - if (!toCheckLft || !toCheckRgh) + if (!theToCheckAllInside) { - return Standard_False; // no inclusion - } + if (!toCheckLft || !toCheckRgh) + { + return Standard_False; // no inclusion + } - toCheckLft &= !isLftInside; - toCheckRgh &= !isRghInside; + // skip extra checks + toCheckLft &= !aLeft.IsFullInside; + toCheckRgh &= !aRight.IsFullInside; + } } if (toCheckLft || toCheckRgh) { - aNode = toCheckLft ? aLftIdx : aRghIdx; - + aNode = toCheckLft ? aLeft : aRight; if (toCheckLft && toCheckRgh) { - aStack[++aHead] = aRghIdx; + aStack[++aHead] = aRight; } } else @@ -142,14 +162,18 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan { if (!theMgr.IsOverlapAllowed()) // inclusion test { - if (!elementIsInside (theMgr, anElemIdx)) + if (!elementIsInside (theMgr, anElemIdx, aNode.IsFullInside)) { + if (theToCheckAllInside) + { + continue; + } return Standard_False; } } else // overlap test { - if (!overlapsElement (theMgr, anElemIdx, aPickResult)) + if (!overlapsElement (aPickResult, theMgr, anElemIdx, aNode.IsFullInside)) { continue; } @@ -159,9 +183,8 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan thePickResult = aPickResult; myDetectedIdx = anElemIdx; } - - ++aMatchesNb; } + ++aMatchesNb; } if (aHead < 0) @@ -176,7 +199,8 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr)); } - return !theMgr.IsOverlapAllowed() || aMatchesNb != -1; + return aMatchesNb != -1 + || (!theToCheckAllInside && !theMgr.IsOverlapAllowed()); } //======================================================================= diff --git a/src/Select3D/Select3D_SensitiveSet.hxx b/src/Select3D/Select3D_SensitiveSet.hxx index 13ad6ba706..b03a68e859 100644 --- a/src/Select3D/Select3D_SensitiveSet.hxx +++ b/src/Select3D/Select3D_SensitiveSet.hxx @@ -64,8 +64,11 @@ public: //! Checks whether one or more entities of the set overlap current selecting volume. //! Implements the traverse of BVH tree built for the set - Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, + SelectBasics_PickResult& thePickResult) Standard_OVERRIDE + { + return matches (theMgr, thePickResult, false); + } //! Builds BVH tree for sensitive set. //! Must be called manually to build BVH tree for any sensitive set @@ -96,15 +99,36 @@ public: protected: - //! Checks whether the entity with index theIdx overlaps the current selecting volume. - //! @param theMatchDepth set to the current minimum depth by Select3D_SensitiveSet; should be set to the new depth when overlapping is detected - virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, - Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) = 0; + //! Checks whether one or more entities of the set overlap current selecting volume. + //! Implements the traverse of BVH tree built for the set + //! @param theMgr selection manager + //! @param thePickResult picking result (for picking by ray) + //! @param theToCheckAllInside flag indicating that even with SelectMgr_SelectingVolumeManager::IsOverlapAllowed() returning FALSE + //! the method will return TRUE if at least one sub-element is fully inside selection volume ::elementIsInside(); + //! this is useful for entities allowing local selection of sub-elements using single Owner object. + Standard_EXPORT Standard_Boolean matches (SelectBasics_SelectingVolumeManager& theMgr, + SelectBasics_PickResult& thePickResult, + Standard_Boolean theToCheckAllInside); - //! Checks whether the entity with index theIdx is inside the current selecting volume + //! Checks whether the entity with index theIdx (partially) overlaps the current selecting volume. + //! @param thePickResult [OUT] picking result, should update minimum depth + //! @param theMgr [IN] selection manager + //! @param theElemIdx [IN] element index within BVH tree to check + //! @param theIsFullInside [IN] when TRUE indicates that entire BVH node is already inside selection volume (in case of rectangle selection); + //! in this case algorithm might skip checking the element and just register it as detected + virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) = 0; + + //! Checks whether the entity with index theIdx is (fully) inside the current selecting volume + //! @param theMgr [IN] selection manager + //! @param theElemIdx [IN] element index within BVH tree to check + //! @param theIsFullInside [IN] when TRUE indicates that entire BVH node is already inside selection volume (in case of rectangle selection); + //! in this case algorithm might skip checking the element and just register it as detected virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) = 0; + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) = 0; //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) = 0; diff --git a/src/Select3D/Select3D_SensitiveTriangulation.cxx b/src/Select3D/Select3D_SensitiveTriangulation.cxx index b8109e5076..c583950102 100644 --- a/src/Select3D/Select3D_SensitiveTriangulation.cxx +++ b/src/Select3D/Select3D_SensitiveTriangulation.cxx @@ -259,12 +259,17 @@ void Select3D_SensitiveTriangulation::Swap (const Standard_Integer theIdx1, // purpose : Checks whether the element with index theIdx overlaps the // current selecting volume //======================================================================= -Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, +Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) + Standard_Boolean theIsFullInside) { - const Standard_Integer& aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx); + if (theIsFullInside) + { + return Standard_True; + } + const Standard_Integer aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx); if (mySensType == Select3D_TOS_BOUNDARY) { Standard_Integer aSegmStartIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 1); @@ -296,10 +301,15 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_ // Purpose : //================================================== Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) { - const Standard_Integer& aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx); + if (theIsFullInside) + { + return Standard_True; + } + const Standard_Integer aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx); if (mySensType == Select3D_TOS_BOUNDARY) { const gp_Pnt& aSegmPnt1 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 1)); diff --git a/src/Select3D/Select3D_SensitiveTriangulation.hxx b/src/Select3D/Select3D_SensitiveTriangulation.hxx index cbd7a4c835..b7228f0e21 100644 --- a/src/Select3D/Select3D_SensitiveTriangulation.hxx +++ b/src/Select3D/Select3D_SensitiveTriangulation.hxx @@ -102,16 +102,18 @@ protected: private: //! Checks whether the element with index theIdx overlaps the current selecting volume - virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, + virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE; //! Checks whether the entity with index theIdx is inside the current selecting volume virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) Standard_OVERRIDE; + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) Standard_OVERRIDE; private: diff --git a/src/Select3D/Select3D_SensitiveWire.cxx b/src/Select3D/Select3D_SensitiveWire.cxx index fd235fcbb8..8185e4e167 100644 --- a/src/Select3D/Select3D_SensitiveWire.cxx +++ b/src/Select3D/Select3D_SensitiveWire.cxx @@ -112,9 +112,10 @@ void Select3D_SensitiveWire::Swap (const Standard_Integer theIdx1, // purpose : Checks whether the entity with index theIdx overlaps the // current selecting volume // ======================================================================= -Standard_Boolean Select3D_SensitiveWire::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, +Standard_Boolean Select3D_SensitiveWire::overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) + Standard_Boolean ) { const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (theElemIdx); const Handle(SelectBasics_SensitiveEntity)& aSeg = myEntities.Value (aSensitiveIdx); @@ -126,7 +127,8 @@ Standard_Boolean Select3D_SensitiveWire::overlapsElement (SelectBasics_Selecting // purpose : // ======================================================================= Standard_Boolean Select3D_SensitiveWire::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) + Standard_Integer theElemIdx, + Standard_Boolean ) { SelectBasics_PickResult aMatchResult; return myEntities.Value (myEntityIndexes.Value (theElemIdx))->Matches (theMgr, aMatchResult); diff --git a/src/Select3D/Select3D_SensitiveWire.hxx b/src/Select3D/Select3D_SensitiveWire.hxx index ac85ffd604..a32f4752dd 100644 --- a/src/Select3D/Select3D_SensitiveWire.hxx +++ b/src/Select3D/Select3D_SensitiveWire.hxx @@ -73,13 +73,15 @@ public: protected: //! Checks whether the entity with index theIdx overlaps the current selecting volume - Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, + Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult, + SelectBasics_SelectingVolumeManager& theMgr, Standard_Integer theElemIdx, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Checks whether the entity with index theIdx is inside the current selecting volume Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, - const Standard_Integer theElemIdx) Standard_OVERRIDE; + Standard_Integer theElemIdx, + Standard_Boolean theIsFullInside) Standard_OVERRIDE; //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE; diff --git a/src/SelectBasics/SelectBasics_EntityOwner.cxx b/src/SelectBasics/SelectBasics_EntityOwner.cxx index fef12b0e95..5580543f96 100644 --- a/src/SelectBasics/SelectBasics_EntityOwner.cxx +++ b/src/SelectBasics/SelectBasics_EntityOwner.cxx @@ -27,3 +27,13 @@ SelectBasics_EntityOwner::SelectBasics_EntityOwner (const Standard_Integer thePr { // } + +//======================================== +// Function : SelectBasics_EntityOwner +// Purpose : +//======================================== +SelectBasics_EntityOwner::SelectBasics_EntityOwner() +: mypriority (0) +{ + // +} diff --git a/src/SelectBasics/SelectBasics_EntityOwner.hxx b/src/SelectBasics/SelectBasics_EntityOwner.hxx index 8a28b974c0..a03aa131d3 100644 --- a/src/SelectBasics/SelectBasics_EntityOwner.hxx +++ b/src/SelectBasics/SelectBasics_EntityOwner.hxx @@ -62,7 +62,9 @@ public: protected: - Standard_EXPORT SelectBasics_EntityOwner (const Standard_Integer thePriority = 0); + Standard_EXPORT SelectBasics_EntityOwner (const Standard_Integer thePriority); + + Standard_EXPORT SelectBasics_EntityOwner(); protected: diff --git a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx index 7ebf8a610d..1c68de1cbd 100644 --- a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx +++ b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx @@ -46,40 +46,40 @@ public: //! Returns true if selecting volume is overlapped by box theBox virtual Standard_Boolean Overlaps (const NCollection_Vec3& theBoxMin, const NCollection_Vec3& theBoxMax, - SelectBasics_PickResult& thePickResult) = 0; + 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 virtual Standard_Boolean Overlaps (const NCollection_Vec3& theBoxMin, const NCollection_Vec3& theBoxMax, - Standard_Boolean* theInside = NULL) = 0; + Standard_Boolean* theInside = NULL) const = 0; //! Returns true if selecting volume is overlapped by point thePnt virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) = 0; + SelectBasics_PickResult& thePickResult) const = 0; //! Returns true if selecting volume is overlapped by point thePnt. //! Does not perform depth calculation, so this method is defined as //! helper function for inclusion test. - virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) = 0; + virtual Standard_Boolean Overlaps (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 Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) = 0; + 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 Overlaps (const TColgp_Array1OfPnt& theArrayOfPts, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) = 0; + SelectBasics_PickResult& thePickResult) const = 0; //! Returns true if selecting volume is overlapped by line segment with start point at thePt1 //! and end point at thePt2 virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1, const gp_Pnt& thePt2, - SelectBasics_PickResult& thePickResult) = 0; + SelectBasics_PickResult& thePickResult) const = 0; //! Returns true if selecting volume is overlapped by triangle with vertices thePt1, //! thePt2 and thePt3, taking into account sensitivity type theSensType @@ -87,11 +87,11 @@ public: const gp_Pnt& thePt2, const gp_Pnt& thePt3, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) = 0; + SelectBasics_PickResult& thePickResult) const = 0; //! Calculates distance from 3d projection of user-defined selection point //! to the given point theCOG - virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) = 0; + virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const = 0; virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const = 0; diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.cxx b/src/SelectMgr/SelectMgr_BaseFrustum.cxx index d9b448480e..bf9f43a395 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.cxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.cxx @@ -146,7 +146,7 @@ void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& //======================================================================= Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/, const SelectMgr_Vec3& /*theBoxMax*/, - SelectBasics_PickResult& /*thePickResult*/) + SelectBasics_PickResult& /*thePickResult*/) const { return Standard_False; } @@ -157,7 +157,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBox //======================================================================= Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/, const SelectMgr_Vec3& /*theBoxMax*/, - Standard_Boolean* /*theInside*/) + Standard_Boolean* /*theInside*/) const { return Standard_False; } @@ -167,7 +167,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBox // purpose : Intersection test between defined volume and given point //======================================================================= Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/, - SelectBasics_PickResult& ) + SelectBasics_PickResult& ) const { return Standard_False; } @@ -176,7 +176,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/, // function : Overlaps // purpose : Intersection test between defined volume and given point //======================================================================= -Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/) +Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/) const { return Standard_False; } @@ -190,7 +190,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/) //======================================================================= Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/, Select3D_TypeOfSensitivity /*theSensType*/, - SelectBasics_PickResult& ) + SelectBasics_PickResult& ) const { return Standard_False; } @@ -206,7 +206,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/, const gp_Pnt& /*thePt2*/, const gp_Pnt& /*thePt3*/, Select3D_TypeOfSensitivity /*theSensType*/, - SelectBasics_PickResult& ) + SelectBasics_PickResult& ) const { return Standard_False; } @@ -217,7 +217,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/, //======================================================================= Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/, const gp_Pnt& /*thePnt2*/, - SelectBasics_PickResult& ) + SelectBasics_PickResult& ) const { return Standard_False; } @@ -227,7 +227,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/, // purpose : Measures distance between 3d projection of user-picked // screen point and given point theCOG //======================================================================= -Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/) +Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/) const { return DBL_MAX; } @@ -247,7 +247,7 @@ gp_Pnt SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) c // detected belongs to the region defined by clipping planes //======================================================================= Standard_Boolean SelectMgr_BaseFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/, - const Standard_Real /*theDepth*/) + const Standard_Real /*theDepth*/) const { return Standard_True; } diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.hxx b/src/SelectMgr/SelectMgr_BaseFrustum.hxx index a7890c5e22..6e4852ce11 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.hxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.hxx @@ -120,35 +120,35 @@ public: //! SAT intersection test between defined volume and given axis-aligned box Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - SelectBasics_PickResult& thePickResult); + SelectBasics_PickResult& thePickResult) const; //! 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 Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside = NULL); + Standard_Boolean* theInside = NULL) const; //! Intersection test between defined volume and given point Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult); + SelectBasics_PickResult& thePickResult) const; //! 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 Overlaps (const gp_Pnt& thePnt); + Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) const; //! 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 Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult); + SelectBasics_PickResult& thePickResult) const; //! Checks if line segment overlaps selecting frustum Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, - SelectBasics_PickResult& thePickResult); + SelectBasics_PickResult& thePickResult) const; //! SAT intersection test between defined volume and given triangle. The test may //! be considered of interior part or boundary line defined by triangle vertices @@ -157,18 +157,18 @@ public: const gp_Pnt& thePt2, const gp_Pnt& thePt3, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult); + SelectBasics_PickResult& thePickResult) const; //! Measures distance between 3d projection of user-picked //! screen point and given point theCOG - Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG); + Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const; Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const; //! Checks if the point of sensitive in which selection was detected belongs //! to the region defined by clipping planes Standard_EXPORT virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, - const Standard_Real theDepth); + const Standard_Real theDepth) const; //! Valid for point selection only! //! Computes depth range for global (defined for the whole view) clipping planes. diff --git a/src/SelectMgr/SelectMgr_Frustum.hxx b/src/SelectMgr/SelectMgr_Frustum.hxx index 1bd6105a98..d758bb5e9f 100644 --- a/src/SelectMgr/SelectMgr_Frustum.hxx +++ b/src/SelectMgr/SelectMgr_Frustum.hxx @@ -66,24 +66,24 @@ protected: //! with minimum corner at point theMinPt and maximum at point theMaxPt Standard_Boolean hasOverlap (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside = NULL); + Standard_Boolean* theInside = NULL) const; //! SAT intersection test between defined volume and given point - Standard_Boolean hasOverlap (const gp_Pnt& thePnt); + Standard_Boolean hasOverlap (const gp_Pnt& thePnt) const; //! SAT intersection test between defined volume and given segment Standard_Boolean hasOverlap (const gp_Pnt& thePnt1, - const gp_Pnt& thePnt2); + const gp_Pnt& thePnt2) const; //! SAT intersection test between frustum given and planar convex polygon represented as ordered point set Standard_Boolean hasOverlap (const TColgp_Array1OfPnt& theArrayOfPnts, - gp_Vec& theNormal); + gp_Vec& theNormal) const; //! SAT intersection test between defined volume and given triangle Standard_Boolean hasOverlap (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, - gp_Vec& theNormal); + gp_Vec& theNormal) const; private: diff --git a/src/SelectMgr/SelectMgr_Frustum.lxx b/src/SelectMgr/SelectMgr_Frustum.lxx index 1562d3e04e..b923f01864 100644 --- a/src/SelectMgr/SelectMgr_Frustum.lxx +++ b/src/SelectMgr/SelectMgr_Frustum.lxx @@ -129,7 +129,7 @@ Standard_Boolean SelectMgr_Frustum::isSeparated (const gp_Pnt& thePnt1, template Standard_Boolean SelectMgr_Frustum::hasOverlap (const SelectMgr_Vec3& theMinPnt, const SelectMgr_Vec3& theMaxPnt, - Standard_Boolean* theInside) + Standard_Boolean* theInside) const { for (Standard_Integer anAxis = 0; anAxis < 3; ++anAxis) { @@ -203,7 +203,7 @@ Standard_Boolean SelectMgr_Frustum::hasOverlap (const SelectMgr_Vec3& theMinP // purpose : SAT intersection test between defined volume and given point // ======================================================================= template -Standard_Boolean SelectMgr_Frustum::hasOverlap (const gp_Pnt& thePnt) +Standard_Boolean SelectMgr_Frustum::hasOverlap (const gp_Pnt& thePnt) const { const Standard_Integer anIncFactor = (myIsOrthographic && N == 4) ? 2 : 1; @@ -227,7 +227,7 @@ Standard_Boolean SelectMgr_Frustum::hasOverlap (const gp_Pnt& thePnt) // ======================================================================= template Standard_Boolean SelectMgr_Frustum::hasOverlap (const gp_Pnt& theStartPnt, - const gp_Pnt& theEndPnt) + const gp_Pnt& theEndPnt) const { const gp_XYZ& aDir = theEndPnt.XYZ() - theStartPnt.XYZ(); if (aDir.Modulus() < Precision::Confusion()) @@ -309,7 +309,7 @@ Standard_Boolean SelectMgr_Frustum::hasOverlap (const gp_Pnt& theStartPnt, // ======================================================================= template Standard_Boolean SelectMgr_Frustum::hasOverlap (const TColgp_Array1OfPnt& theArrayOfPnts, - gp_Vec& theNormal) + gp_Vec& theNormal) const { Standard_Integer aStartIdx = theArrayOfPnts.Lower(); Standard_Integer anEndIdx = theArrayOfPnts.Upper(); @@ -406,7 +406,7 @@ template Standard_Boolean SelectMgr_Frustum::hasOverlap (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, - gp_Vec& theNormal) + gp_Vec& theNormal) const { const gp_XYZ aTrEdges[3] = { thePnt2.XYZ() - thePnt1.XYZ(), thePnt3.XYZ() - thePnt2.XYZ(), diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index f95a6d16e6..d972e19f2d 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -24,7 +24,7 @@ // ======================================================================= void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegPnt1, const gp_Pnt& theSegPnt2, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { gp_XYZ anU = theSegPnt2.XYZ() - theSegPnt1.XYZ(); gp_XYZ aV = myViewRayDir.XYZ(); @@ -95,7 +95,7 @@ void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegP // ======================================================================= bool SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePlane, const gp_Pnt& thePntOnPlane, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { gp_XYZ anU = myViewRayDir.XYZ(); gp_XYZ aW = myNearPickedPnt.XYZ() - thePntOnPlane.XYZ(); @@ -429,7 +429,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_RectangularFrustum::ScaleAndTransform (c // ======================================================================= Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside) + Standard_Boolean* theInside) const { return hasOverlap (theBoxMin, theBoxMax, theInside); } @@ -441,7 +441,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t // ======================================================================= Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (!hasOverlap (theBoxMin, theBoxMax)) return Standard_False; @@ -461,7 +461,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t // purpose : Intersection test between defined volume and given point // ======================================================================= Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (!hasOverlap (thePnt)) return Standard_False; @@ -480,7 +480,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt, // function : Overlaps // purpose : Intersection test between defined volume and given point // ======================================================================= -Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt) +Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt) const { return hasOverlap (thePnt); } @@ -491,7 +491,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt) // ======================================================================= Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (!hasOverlap (thePnt1, thePnt2)) return Standard_False; @@ -510,7 +510,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1, // ======================================================================= Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (theSensType == Select3D_TOS_BOUNDARY) { @@ -560,7 +560,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (theSensType == Select3D_TOS_BOUNDARY) { @@ -639,7 +639,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1, // purpose : Measures distance between 3d projection of user-picked // screen point and given point theCOG // ======================================================================= -Standard_Real SelectMgr_RectangularFrustum::DistToGeometryCenter (const gp_Pnt& theCOG) +Standard_Real SelectMgr_RectangularFrustum::DistToGeometryCenter (const gp_Pnt& theCOG) const { return theCOG.Distance (myNearPickedPnt) * myScale; } @@ -659,7 +659,7 @@ gp_Pnt SelectMgr_RectangularFrustum::DetectedPoint (const Standard_Real theDepth // purpose : // ======================================================================= void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes, - SelectMgr_ViewClipRange& theRange) + SelectMgr_ViewClipRange& theRange) const { Standard_Real aPlaneA, aPlaneB, aPlaneC, aPlaneD; for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next()) @@ -744,7 +744,7 @@ void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_Sequenc // detected belongs to the region defined by clipping planes // ======================================================================= Standard_Boolean SelectMgr_RectangularFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, - const Standard_Real theDepth) + const Standard_Real theDepth) const { SelectMgr_ViewClipRange aRange; computeClippingRange (thePlanes, aRange); diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx index f2413a9a6f..1fae9f4f0a 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx @@ -59,32 +59,32 @@ public: //! SAT intersection test between defined volume and given axis-aligned box Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + 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 Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside = NULL) Standard_OVERRIDE; + Standard_Boolean* theInside) const Standard_OVERRIDE; //! Intersection test between defined volume and given point Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Intersection test between defined volume and given point - Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean Overlaps (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 Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Checks if line segment overlaps selecting frustum Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + 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 @@ -93,11 +93,11 @@ public: const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Measures distance between 3d projection of user-picked //! screen point and given point theCOG - Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE; //! 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; @@ -105,7 +105,7 @@ public: //! Checks if the point of sensitive in which selection was detected belongs //! to the region defined by clipping planes Standard_EXPORT virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, - const Standard_Real theDepth) Standard_OVERRIDE; + const Standard_Real theDepth) const Standard_OVERRIDE; //! Valid for point selection only! //! Computes depth range for global (defined for the whole view) clipping planes. @@ -141,15 +141,15 @@ protected: Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1, const gp_Pnt& theSegPnt2, - SelectBasics_PickResult& thePickResult); + SelectBasics_PickResult& thePickResult) const; Standard_EXPORT bool segmentPlaneIntersection (const gp_Vec& thePlane, const gp_Pnt& thePntOnPlane, - SelectBasics_PickResult& thePickResult); + SelectBasics_PickResult& thePickResult) const; //! Computes valid depth range for the given clipping planes Standard_EXPORT void computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes, - SelectMgr_ViewClipRange& theRange); + SelectMgr_ViewClipRange& theRange) const; //! Returns false if theDepth must be clipped by current view clip range Standard_EXPORT Standard_Boolean isViewClippingOk (const SelectBasics_PickResult& thePickResult) const; diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx index 879a632308..7073a002ba 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx @@ -236,7 +236,7 @@ void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const TColgp_Array1 //======================================================================= Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -250,7 +250,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec //======================================================================= Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside) + Standard_Boolean* theInside) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -263,7 +263,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec // purpose : Intersection test between defined volume and given point //======================================================================= Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -276,7 +276,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePn // function : Overlaps // purpose : Intersection test between defined volume and given point //======================================================================= -Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePnt) +Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePnt) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -293,7 +293,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePn //======================================================================= Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -312,7 +312,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp //======================================================================= Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -328,7 +328,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1 //======================================================================= Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt1, const gp_Pnt& thePt2, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -347,7 +347,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt const gp_Pnt& thePt2, const gp_Pnt& thePt3, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -364,7 +364,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt // purpose : Measures distance between 3d projection of user-picked // screen point and given point theCOG //======================================================================= -Standard_Real SelectMgr_SelectingVolumeManager::DistToGeometryCenter (const gp_Pnt& theCOG) +Standard_Real SelectMgr_SelectingVolumeManager::DistToGeometryCenter (const gp_Pnt& theCOG) const { if (myActiveSelectionType == Unknown) return Standard_False; @@ -394,7 +394,7 @@ gp_Pnt SelectMgr_SelectingVolumeManager::DetectedPoint (const Standard_Real theD // detected belongs to the region defined by clipping planes //======================================================================= Standard_Boolean SelectMgr_SelectingVolumeManager::IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, - const Standard_Real& theDepth) + const Standard_Real& theDepth) const { if (myActiveSelectionType != Point) return Standard_False; diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx index 263ba50fef..92715faabe 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx @@ -106,39 +106,39 @@ public: //! SAT intersection test between defined volume and given axis-aligned box Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + 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 Overlaps (const SelectMgr_Vec3& theBoxMin, const SelectMgr_Vec3& theBoxMax, - Standard_Boolean* theInside = NULL) Standard_OVERRIDE; + Standard_Boolean* theInside = NULL) const Standard_OVERRIDE; //! Intersection test between defined volume and given point Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Intersection test between defined volume and given point - Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean Overlaps (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 Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + 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 Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Checks if line segment overlaps selecting frustum Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + 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 @@ -147,12 +147,12 @@ public: const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, Standard_Integer theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Measures distance between 3d projection of user-picked //! screen point and given point theCOG - Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE; //! Calculates the point on a view ray that was detected during the run of selection algo by given depth. //! Throws exception if active selection type is not Point. @@ -161,7 +161,7 @@ public: //! Checks if the point of sensitive in which selection was detected belongs //! to the region defined by clipping planes Standard_EXPORT virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, - const Standard_Real& theDepth); + const Standard_Real& theDepth) const; //! Is used for rectangular selection only //! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx index 488ed90811..3e8b1e95b5 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx @@ -169,7 +169,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustum::ScaleAndTransform (co //======================================================================= Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt, const SelectMgr_Vec3& theMaxPt, - SelectBasics_PickResult& /*thePickResult*/) + SelectBasics_PickResult& /*thePickResult*/) const { return hasOverlap (theMinPt, theMaxPt); } @@ -182,7 +182,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& th // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt, const SelectMgr_Vec3& theMaxPt, - Standard_Boolean* /*theInside*/) + Standard_Boolean* /*theInside*/) const { return hasOverlap (theMinPt, theMaxPt, NULL); } @@ -192,7 +192,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& th // purpose : Intersection test between defined volume and given point // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& /*thePickResult*/) + SelectBasics_PickResult& /*thePickResult*/) const { return hasOverlap (thePnt); } @@ -206,7 +206,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt, // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& /*thePickResult*/) + SelectBasics_PickResult& /*thePickResult*/) const { if (theSensType == Select3D_TOS_BOUNDARY) { @@ -237,7 +237,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, - SelectBasics_PickResult& /*thePickResult*/) + SelectBasics_PickResult& /*thePickResult*/) const { return hasOverlap (thePnt1, thePnt2); } @@ -253,7 +253,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { if (theSensType == Select3D_TOS_BOUNDARY) { diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx index 8be66c0859..4dea1f81eb 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx @@ -48,29 +48,29 @@ public: //! SAT intersection test between defined volume and given axis-aligned box Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, const SelectMgr_Vec3& theMaxPnt, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + 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 Overlaps (const SelectMgr_Vec3& theMinPt, const SelectMgr_Vec3& theMaxPt, - Standard_Boolean* theInside) Standard_OVERRIDE; + Standard_Boolean* theInside) const Standard_OVERRIDE; //! Intersection test between defined volume and given point Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + 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 Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Checks if line segment overlaps selecting frustum Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + 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 @@ -79,7 +79,7 @@ public: const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Nullifies the handle to corresponding builder instance to prevent memory leaks Standard_EXPORT void Clear(); diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx index c9cdf2eaab..dee6d1fbd8 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx @@ -127,7 +127,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustumSet::ScaleAndTransform // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& theMinPnt, const SelectMgr_Vec3& theMaxPnt, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) { @@ -144,7 +144,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& theMinPnt, const SelectMgr_Vec3& theMaxPnt, - Standard_Boolean* /*theInside*/) + Standard_Boolean* /*theInside*/) const { for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) { @@ -160,7 +160,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& // purpose : // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) { @@ -177,7 +177,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt, // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) { @@ -194,7 +194,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1Of // ======================================================================= Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) { @@ -213,7 +213,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1 const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) + SelectBasics_PickResult& thePickResult) const { for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) { diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx index b3d53203fb..47b7bbf200 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx @@ -52,28 +52,28 @@ public: Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, const SelectMgr_Vec3& theMaxPnt, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, const SelectMgr_Vec3& theMaxPnt, - Standard_Boolean* theInside) Standard_OVERRIDE; + Standard_Boolean* theInside) const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, const gp_Pnt& thePnt3, Select3D_TypeOfSensitivity theSensType, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; //! Stores plane equation coefficients (in the following form: //! Ax + By + Cz + D = 0) to the given vector diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index b80392f79c..1e73e1f23c 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -3445,20 +3445,12 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char* Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext(); if (aContextAIS.IsNull()) { - di << "Call vinit before!\n"; + std::cout << "Error: no active Viewer\n"; return 1; } else if (argc < 3) { - di << "Use: " << argv[0] << " Name TypeOfArray" - << " [vertex] ... [bounds] ... [edges]\n" - << " TypeOfArray={ points | segments | polylines | triangles |\n" - << " trianglefans | trianglestrips | quads |\n" - << " quadstrips | polygons }\n" - << " vertex={ 'v' x y z [normal={ 'n' nx ny nz }] [color={ 'c' r g b }]" - << " [texel={ 't' tx ty }] } \n" - << " bounds={ 'b' verticies_count [color={ 'c' r g b }] }\n" - << " edges={ 'e' vertex_id }\n"; + std::cout << "Syntax error: wrong number of arguments\n"; return 1; } @@ -3466,6 +3458,26 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char* Standard_Integer aArgIndex = 1; TCollection_AsciiString aName (argv[aArgIndex++]); TCollection_AsciiString anArrayType (argv[aArgIndex++]); + if (anArrayType == "-shape") + { + Standard_CString aShapeName = argv[aArgIndex++]; + TopoDS_Shape aShape = DBRep::Get (aShapeName); + Handle(Graphic3d_ArrayOfPrimitives) aTris = StdPrs_ShadedShape::FillTriangles (aShape); + if (aShape.IsNull()) + { + std::cout << "Syntax error: shape '" << aShapeName << "' is not found\n"; + return 1; + } + else if (aTris.IsNull()) + { + std::cout << "Syntax error: shape '" << aShapeName << "' is not triangulated\n"; + return 1; + } + + Handle(MyPArrayObject) aPObject = new MyPArrayObject (aTris); + ViewerTest::Display (aName, aPObject); + return 0; + } Standard_Boolean hasVertex = Standard_False; @@ -6306,7 +6318,14 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands) __FILE__, VComputeHLR, group); theCommands.Add("vdrawparray", - "vdrawparray : vdrawparray Name TypeOfArray [vertex = { 'v' x y z [vertex_normal = { 'n' x y z }] [vertex_color = { 'c' r g b }] ] ... [bound = { 'b' vertex_count [bound_color = { 'c' r g b }] ] ... [edge = { 'e' vertex_id ]", + "vdrawparray name TypeOfArray={points|segments|polylines|triangles" + "\n\t\t: |trianglefans|trianglestrips|quads|quadstrips|polygons}" + "\n\t\t: [vertex={'v' x y z [normal={'n' nx ny nz}] [color={'c' r g b}] [texel={'t' tx ty}]]" + "\n\t\t: [bound= {'b' nbVertices [bound_color={'c' r g b}]]" + "\n\t\t: [edge= {'e' vertexId]" + "\n\t\t: [-shape shapeName]" + "\n\t\t: Commands create an Interactive Object for specified Primitive Array definition (Graphic3d_ArrayOfPrimitives)" + "\n\t\t: with the main purpose is covering various combinations by tests", __FILE__,VDrawPArray,group); theCommands.Add("vconnect",