mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0029938: Visualization - SelectMgr_ViewerSelector::PickedPoint() should return point lying on an object
Extended SelectBasics_PickResult structure by myObjPickedPnt field, which contained the value of the 3d point on the selected object. Changed all Overlaps methods. Parameter theDepth replaced on object of the structure SelectBasics_PickResult. This approach will be able to add new fields to SelectBasics_PickResult structure without big changes in modules which contained Overlaps method.
This commit is contained in:
@@ -19,37 +19,71 @@
|
||||
#include <Standard.hxx>
|
||||
#include <NCollection_Vec4.hxx>
|
||||
|
||||
//! This structure provides unified access to the results of
|
||||
//! Matches() method in all sensitive entities.
|
||||
//! This structure provides unified access to the results of Matches() method in all sensitive entities,
|
||||
//! so that it defines a Depth (distance to the entity along picking ray) and a closest Point on entity.
|
||||
struct SelectBasics_PickResult
|
||||
{
|
||||
public:
|
||||
//! Return closest result between two Pick Results according to Depth value.
|
||||
static const SelectBasics_PickResult& Min (const SelectBasics_PickResult& thePickResult1,
|
||||
const SelectBasics_PickResult& thePickResult2)
|
||||
{
|
||||
return thePickResult1.Depth() <= thePickResult2.Depth() ? thePickResult1 : thePickResult2;
|
||||
}
|
||||
|
||||
public:
|
||||
//! Empty constructor defining an invalid result.
|
||||
SelectBasics_PickResult()
|
||||
: myDepth (DBL_MAX),
|
||||
myDistToCenter (DBL_MAX) {}
|
||||
: myObjPickedPnt (RealLast(), 0.0, 0.0),
|
||||
myDepth (RealLast()),
|
||||
myDistToCenter (RealLast()) {}
|
||||
|
||||
SelectBasics_PickResult (const Standard_Real theDepth,
|
||||
const Standard_Real theDistToCenter)
|
||||
: myDepth (theDepth),
|
||||
//! Constructor with initialization.
|
||||
SelectBasics_PickResult (Standard_Real theDepth,
|
||||
Standard_Real theDistToCenter,
|
||||
const gp_Pnt& theObjPickedPnt)
|
||||
: myObjPickedPnt (theObjPickedPnt),
|
||||
myDepth (theDepth),
|
||||
myDistToCenter (theDistToCenter) {}
|
||||
|
||||
public:
|
||||
inline Standard_Real Depth() const
|
||||
|
||||
//! Return TRUE if result was been defined.
|
||||
Standard_Boolean IsValid() const { return myDepth != RealLast(); }
|
||||
|
||||
//! Reset depth value.
|
||||
void Invalidate()
|
||||
{
|
||||
return myDepth;
|
||||
myDepth = RealLast();
|
||||
myObjPickedPnt = gp_Pnt (RealLast(), 0.0, 0.0);
|
||||
}
|
||||
|
||||
inline Standard_Real DistToGeomCenter() const
|
||||
{
|
||||
return myDistToCenter;
|
||||
}
|
||||
//! Return depth along picking ray.
|
||||
Standard_Real Depth() const { return myDepth; }
|
||||
|
||||
//! Set depth along picking ray.
|
||||
void SetDepth (Standard_Real theDepth) { myDepth = theDepth; }
|
||||
|
||||
//! Return TRUE if Picked Point lying on detected entity was set.
|
||||
Standard_Boolean HasPickedPoint() const { return myObjPickedPnt.X() != RealLast(); }
|
||||
|
||||
//! Return picked point lying on detected entity.
|
||||
//! WARNING! Point is defined in local coordinate system and should be translated into World System before usage!
|
||||
const gp_Pnt& PickedPoint() const { return myObjPickedPnt; }
|
||||
|
||||
//! Set picked point.
|
||||
void SetPickedPoint (const gp_Pnt& theObjPickedPnt) { myObjPickedPnt = theObjPickedPnt; }
|
||||
|
||||
//! Return distance to geometry center (auxiliary value for comparing results).
|
||||
Standard_Real DistToGeomCenter() const { return myDistToCenter; }
|
||||
|
||||
//! Set distance to geometry center.
|
||||
void SetDistToGeomCenter (Standard_Real theDistToCenter) { myDistToCenter = theDistToCenter; }
|
||||
|
||||
private:
|
||||
//!< Depth to detected point
|
||||
Standard_Real myDepth;
|
||||
//!< Distance from 3d projection user-picked selection point to entity's geometry center
|
||||
Standard_Real myDistToCenter;
|
||||
gp_Pnt myObjPickedPnt; //!< User-picked selection point onto object
|
||||
Standard_Real myDepth; //!< Depth to detected point
|
||||
Standard_Real myDistToCenter; //!< Distance from 3d projection user-picked selection point to entity's geometry center
|
||||
};
|
||||
|
||||
#endif // _SelectBasics_PickResult_HeaderFile
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <BVH_Box.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <SelectBasics_PickResult.hxx>
|
||||
|
||||
class Bnd_Box;
|
||||
class gp_Pnt;
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
//! Returns true if selecting volume is overlapped by box theBox
|
||||
virtual Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin,
|
||||
const NCollection_Vec3<Standard_Real>& theBoxMax,
|
||||
Standard_Real& theDepth) = 0;
|
||||
SelectBasics_PickResult& thePickResult) = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by axis-aligned bounding box with minimum
|
||||
//! corner at point theMinPt and maximum at point theMaxPt
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
|
||||
//! Returns true if selecting volume is overlapped by point thePnt
|
||||
virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
|
||||
Standard_Real& theDepth) = 0;
|
||||
SelectBasics_PickResult& thePickResult) = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by point thePnt.
|
||||
//! Does not perform depth calculation, so this method is defined as
|
||||
@@ -66,19 +67,19 @@ public:
|
||||
//! are stored in theArrayOfPts, taking into account sensitivity type theSensType
|
||||
virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
|
||||
Standard_Integer theSensType,
|
||||
Standard_Real& theDepth) = 0;
|
||||
SelectBasics_PickResult& thePickResult) = 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,
|
||||
Standard_Real& theDepth) = 0;
|
||||
SelectBasics_PickResult& thePickResult) = 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,
|
||||
Standard_Real& theDepth) = 0;
|
||||
SelectBasics_PickResult& thePickResult) = 0;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by triangle with vertices thePt1,
|
||||
//! thePt2 and thePt3, taking into account sensitivity type theSensType
|
||||
@@ -86,7 +87,7 @@ public:
|
||||
const gp_Pnt& thePt2,
|
||||
const gp_Pnt& thePt3,
|
||||
Standard_Integer theSensType,
|
||||
Standard_Real& theDepth) = 0;
|
||||
SelectBasics_PickResult& thePickResult) = 0;
|
||||
|
||||
//! Calculates distance from 3d projection of user-defined selection point
|
||||
//! to the given point theCOG
|
||||
|
Reference in New Issue
Block a user