1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0026195: Visualization - optimize selection algorithms

- initial transformation of triangulation is now applied to selecting frustum;
- switched from NCollection_Vec3 to gp collections to avoid conversions and usage of macros;
- calculation of frustum was refactored to reduce its build time;
- double pixel tolerances for selection were replaced by integer ones;
- switched to splitting along the main axis only in SelectMgr BVH selection primitive sets.
This commit is contained in:
vpa
2015-08-31 10:29:53 +03:00
committed by bugmaster
parent 646529083a
commit 3bf9a45f7a
50 changed files with 1057 additions and 978 deletions

View File

@@ -17,8 +17,8 @@
#define _SelectBasics_SelectingVolumeManager_HeaderFile
#include <BVH_Box.hxx>
#include <gp_Pnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <NCollection_Vec3.hxx>
class Bnd_Box;
class gp_Pnt;
@@ -43,7 +43,8 @@ public:
virtual Standard_Integer GetActiveSelectionType() const = 0;
//! Returns true if selecting volume is overlapped by box theBox
virtual Standard_Boolean Overlaps (const BVH_Box<Standard_Real, 3>& theBox,
virtual Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin,
const NCollection_Vec3<Standard_Real>& theBoxMax,
Standard_Real& theDepth) = 0;
//! Returns true if selecting volume is overlapped by axis-aligned bounding box with minimum
@@ -52,10 +53,15 @@ public:
const NCollection_Vec3<Standard_Real>& theBoxMax,
Standard_Boolean* theInside = NULL) = 0;
//! Returns true if selecting volume is overlapped by point thePt
virtual Standard_Boolean Overlaps (const gp_Pnt& thePt,
//! Returns true if selecting volume is overlapped by point thePnt
virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) = 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;
//! 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,
@@ -80,7 +86,7 @@ public:
//! to the given point theCOG
virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) = 0;
virtual NCollection_Vec3<Standard_Real> DetectedPoint (const Standard_Real theDepth) const = 0;
virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const = 0;
virtual Standard_Boolean IsOverlapAllowed() const = 0;

View File

@@ -24,10 +24,9 @@
// function : SelectBasics_SensitiveEntity
// purpose : Creates new empty sensitive entity instance
//=======================================================================
SelectBasics_SensitiveEntity::SelectBasics_SensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const Standard_Real theSensFactor)
SelectBasics_SensitiveEntity::SelectBasics_SensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwnerId)
: myOwnerId (theOwnerId),
mySFactor (theSensFactor) {}
mySFactor (2) {}
//=======================================================================
// function : Set

View File

@@ -17,6 +17,8 @@
#ifndef _SelectBasics_SensitiveEntity_HeaderFile
#define _SelectBasics_SensitiveEntity_HeaderFile
#include <gp_Trsf.hxx>
#include <Standard.hxx>
#include <Standard_Type.hxx>
@@ -27,6 +29,7 @@
#include <SelectBasics_PickResult.hxx>
#include <Standard_Integer.hxx>
#include <Select3D_BndBox3d.hxx>
class SelectBasics_EntityOwner;
@@ -49,51 +52,51 @@ public:
//! Checks whether the sensitive entity is overlapped by
//! current selecting volume
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, SelectBasics_PickResult& thePickResult) = 0;
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, SelectBasics_PickResult& thePickResult) = 0;
//! allows a better sensitivity for
//! a specific entity in selection algorithms
//! useful for small sized entities.
Standard_EXPORT Standard_Real SensitivityFactor() const;
Standard_EXPORT Standard_Integer SensitivityFactor() const;
//! Returns the number of sub-entities or elements in
//! sensitive entity. Is used to determine if entity is
//! complex and needs to pre-build BVH at the creation of
//! sensitive entity step or is light-weighted so the tree
//! can be build on demand with unnoticeable delay
Standard_EXPORT virtual Standard_Integer NbSubElements() = 0;
virtual Standard_Integer NbSubElements() = 0;
//! Returns bounding box of sensitive entity
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() = 0;
virtual Select3D_BndBox3d BoundingBox() = 0;
//! Builds BVH tree for sensitive if it is needed
Standard_EXPORT virtual void BVH() = 0;
virtual void BVH() = 0;
//! Clears up all the resources and memory allocated
Standard_EXPORT virtual void Clear() = 0;
virtual void Clear() = 0;
//! Returns true if the shape corresponding to the entity has init location
virtual Standard_Boolean HasInitLocation() const = 0;
//! Returns inversed location transformation matrix if the shape corresponding
//! to this entity has init location set. Otherwise, returns identity matrix.
virtual gp_Trsf InvInitLocation() const = 0;
DEFINE_STANDARD_RTTI(SelectBasics_SensitiveEntity,MMgt_TShared)
protected:
Standard_EXPORT SelectBasics_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& theOwnerId, const Standard_Real theSensFactor = 2.0);
Standard_EXPORT SelectBasics_SensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwnerId);
//! Allows to manage the sensitivity of the entity
void SetSensitivityFactor (const Standard_Real theSensFactor);
void SetSensitivityFactor (const Standard_Integer theSensFactor);
Handle(SelectBasics_EntityOwner) myOwnerId;
private:
Standard_Real mySFactor;
Standard_Integer mySFactor;
};

View File

@@ -16,7 +16,7 @@
// function : SetSensitivityFactor
// purpose : Allows to manage the sensitivity of the entity
//=======================================================================
inline void SelectBasics_SensitiveEntity::SetSensitivityFactor (const Standard_Real theSensFactor)
inline void SelectBasics_SensitiveEntity::SetSensitivityFactor (const Standard_Integer theSensFactor)
{
mySFactor = theSensFactor;
}
@@ -25,7 +25,7 @@ inline void SelectBasics_SensitiveEntity::SetSensitivityFactor (const Standard_R
// function : SensitivityFactor
// purpose : Gets sensitivity factor for the entity
//=======================================================================
inline Standard_Real SelectBasics_SensitiveEntity::SensitivityFactor() const
inline Standard_Integer SelectBasics_SensitiveEntity::SensitivityFactor() const
{
return mySFactor;
}