1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +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:
mnv
2018-07-23 15:08:01 +03:00
committed by bugmaster
parent c348746059
commit 170175554f
39 changed files with 365 additions and 309 deletions

View File

@@ -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*/,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& /*thePickResult*/)
{
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*/,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& )
{
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*/,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& )
{
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*/,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& )
{
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*/,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& )
{
return Standard_False;
}

View File

@@ -33,6 +33,8 @@
#include <Select3D_TypeOfSensitivity.hxx>
#include <SelectMgr_VectorTypes.hxx>
#include <SelectBasics_PickResult.hxx>
//! This class is an interface for different types of selecting frustums,
//! defining different selection types, like point, box or polyline
//! selection. It contains signatures of functions for detection of
@@ -118,7 +120,7 @@ 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,
Standard_Real& theDepth);
SelectBasics_PickResult& thePickResult);
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt
@@ -128,7 +130,7 @@ public:
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth);
SelectBasics_PickResult& thePickResult);
//! Intersection test between defined volume and given point
//! Does not perform depth calculation, so this method is defined as
@@ -141,12 +143,12 @@ public:
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth);
SelectBasics_PickResult& thePickResult);
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
Standard_Real& theDepth);
SelectBasics_PickResult& thePickResult);
//! SAT intersection test between defined volume and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices
@@ -155,7 +157,7 @@ public:
const gp_Pnt& thePt2,
const gp_Pnt& thePt3,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth);
SelectBasics_PickResult& thePickResult);
//! Measures distance between 3d projection of user-picked
//! screen point and given point theCOG

View File

@@ -24,7 +24,7 @@
// =======================================================================
void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegPnt1,
const gp_Pnt& theSegPnt2,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
gp_XYZ anU = theSegPnt2.XYZ() - theSegPnt1.XYZ();
gp_XYZ aV = myViewRayDir.XYZ();
@@ -70,17 +70,32 @@ void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegP
}
aTc = (Abs (aTd) < gp::Resolution() ? 0.0 : aTn / aTd);
gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTc;
theDepth = myNearPickedPnt.Distance (aClosestPnt) * myScale;
const gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTc;
thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale);
const gp_Vec aPickedVec = aClosestPnt.XYZ() - theSegPnt1.XYZ();
const gp_Vec aFigureVec = theSegPnt2.XYZ() - theSegPnt1.XYZ();
const Standard_Real aPickedVecMod = aPickedVec.Magnitude();
const Standard_Real aFigureVecMod = aFigureVec.Magnitude();
if (aPickedVecMod <= gp::Resolution()
|| aFigureVecMod <= gp::Resolution())
{
thePickResult.SetPickedPoint (aClosestPnt);
return;
}
const Standard_Real aCosOfAngle = aFigureVec.Dot (aPickedVec) / (aPickedVecMod * aFigureVecMod);
const Standard_Real aSegPntShift = Min(aFigureVecMod, Max(0.0, aCosOfAngle * aPickedVecMod));
thePickResult.SetPickedPoint (theSegPnt1.XYZ() + aFigureVec.XYZ() * (aSegPntShift / aFigureVecMod));
}
// =======================================================================
// function : segmentPlaneIntersection
// purpose :
// =======================================================================
void SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePlane,
bool SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePlane,
const gp_Pnt& thePntOnPlane,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
gp_XYZ anU = myViewRayDir.XYZ();
gp_XYZ aW = myNearPickedPnt.XYZ() - thePntOnPlane.XYZ();
@@ -91,25 +106,26 @@ void SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePl
{
if (Abs (aN) < Precision::Angular())
{
theDepth = DBL_MAX;
return;
thePickResult.Invalidate();
return false;
}
else
{
theDepth = DBL_MAX;
return;
thePickResult.Invalidate();
return false;
}
}
Standard_Real aParam = aN / aD;
if (aParam < 0.0 || aParam > 1.0)
{
theDepth = DBL_MAX;
return;
thePickResult.Invalidate();
return false;
}
gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + anU * aParam;
theDepth = myNearPickedPnt.Distance (aClosestPnt) * myScale;
thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale);
return true;
}
namespace
@@ -425,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,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (!hasOverlap (theBoxMin, theBoxMax))
return Standard_False;
@@ -435,9 +451,9 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
aNearestPnt.SetY (Max (Min (myNearPickedPnt.Y(), theBoxMax.y()), theBoxMin.y()));
aNearestPnt.SetZ (Max (Min (myNearPickedPnt.Z(), theBoxMax.z()), theBoxMin.z()));
theDepth = aNearestPnt.Distance (myNearPickedPnt);
thePickResult.SetDepth (aNearestPnt.Distance (myNearPickedPnt));
return isViewClippingOk (theDepth);
return isViewClippingOk (thePickResult);
}
// =======================================================================
@@ -445,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,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (!hasOverlap (thePnt))
return Standard_False;
@@ -454,9 +470,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
gp_Pnt aDetectedPnt =
myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * (aV.Dot (myViewRayDir.XYZ()) / myViewRayDir.Dot (myViewRayDir));
theDepth = aDetectedPnt.Distance (myNearPickedPnt) * myScale;
thePickResult.SetDepth (aDetectedPnt.Distance (myNearPickedPnt) * myScale);
thePickResult.SetPickedPoint (thePnt);
return isViewClippingOk (theDepth);
return isViewClippingOk (thePickResult);
}
// =======================================================================
@@ -474,15 +491,14 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt)
// =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
theDepth = -DBL_MAX;
if (!hasOverlap (thePnt1, thePnt2))
return Standard_False;
segmentSegmentDistance (thePnt1, thePnt2, theDepth);
segmentSegmentDistance (thePnt1, thePnt2, thePickResult);
return isViewClippingOk (theDepth);
return isViewClippingOk (thePickResult);
}
// =======================================================================
@@ -494,12 +510,13 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
// =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
Standard_Integer aMatchingSegmentsNb = -1;
theDepth = DBL_MAX;
SelectBasics_PickResult aPickResult;
thePickResult.Invalidate();
const Standard_Integer aLower = theArrayOfPnts.Lower();
const Standard_Integer anUpper = theArrayOfPnts.Upper();
for (Standard_Integer aPntIter = aLower; aPntIter <= anUpper; ++aPntIter)
@@ -509,9 +526,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
if (hasOverlap (aStartPnt, aEndPnt))
{
aMatchingSegmentsNb++;
Standard_Real aSegmentDepth = RealLast();
segmentSegmentDistance (aStartPnt, aEndPnt, aSegmentDepth);
theDepth = Min (theDepth, aSegmentDepth);
segmentSegmentDistance (aStartPnt, aEndPnt, aPickResult);
thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
}
}
@@ -521,15 +537,16 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
else if (theSensType == Select3D_TOS_INTERIOR)
{
gp_Vec aPolyNorm (gp_XYZ (RealLast(), RealLast(), RealLast()));
if (!hasOverlap (theArrayOfPnts, aPolyNorm))
if (!hasOverlap (theArrayOfPnts, aPolyNorm)
|| !segmentPlaneIntersection (aPolyNorm,
theArrayOfPnts.First(),
thePickResult))
{
return Standard_False;
segmentPlaneIntersection (aPolyNorm,
theArrayOfPnts.Value (theArrayOfPnts.Lower()),
theDepth);
}
}
return isViewClippingOk (theDepth);
return isViewClippingOk (thePickResult);
}
// =======================================================================
@@ -543,13 +560,13 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 };
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 4);
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theDepth);
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, thePickResult);
}
else if (theSensType == Select3D_TOS_INTERIOR)
{
@@ -568,16 +585,15 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
// handle degenerated triangles: in this case, there is no possible way to detect overlap correctly.
if (aTriangleNormal.SquareMagnitude() < gp::Resolution())
{
theDepth = std::numeric_limits<Standard_Real>::max();
return Standard_False;
}
// handle the case when triangle normal and selecting frustum direction are orthogonal: for this case, overlap
// is detected correctly, and distance to triangle's plane can be measured as distance to its arbitrary vertex.
const gp_XYZ aDiff = myNearPickedPnt.XYZ() - thePnt1.XYZ();
theDepth = aTriangleNormal.Dot (aDiff) * myScale;
return isViewClippingOk (theDepth);
thePickResult.SetDepth (aTriangleNormal.Dot (aDiff) * myScale);
thePickResult.SetPickedPoint (thePnt1);
return isViewClippingOk (thePickResult);
}
gp_XYZ anEdge = (thePnt1.XYZ() - myNearPickedPnt.XYZ()) * (1.0 / anAlpha);
@@ -589,20 +605,18 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
Standard_Real anU = aVec.Dot (aTrEdges[2]);
Standard_Real aV = aVec.Dot (aTrEdges[0]);
Standard_Boolean isInterior = (aTime >= 0.0) && (anU >= 0.0) && (aV >= 0.0) && (anU + aV <= 1.0);
const Standard_Boolean isInterior = (aTime >= 0.0) && (anU >= 0.0) && (aV >= 0.0) && (anU + aV <= 1.0);
const gp_Pnt aPtOnPlane = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTime;
if (isInterior)
{
gp_Pnt aDetectedPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTime;
theDepth = myNearPickedPnt.Distance (aDetectedPnt) * myScale;
return isViewClippingOk (theDepth);
thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
thePickResult.SetPickedPoint (aPtOnPlane);
return isViewClippingOk (thePickResult);
}
gp_Pnt aPnts[3] = {thePnt1, thePnt2, thePnt3};
Standard_Real aMinDist = RealLast();
Standard_Integer aNearestEdgeIdx = -1;
gp_Pnt aPtOnPlane = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTime;
for (Standard_Integer anEdgeIdx = 0; anEdgeIdx < 3; ++anEdgeIdx)
{
gp_XYZ aW = aPtOnPlane.XYZ() - aPnts[anEdgeIdx].XYZ();
@@ -614,10 +628,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
aNearestEdgeIdx = anEdgeIdx;
}
}
segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], theDepth);
segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], thePickResult);
}
return isViewClippingOk (theDepth);
return isViewClippingOk (thePickResult);
}
// =======================================================================
@@ -757,10 +771,10 @@ void SelectMgr_RectangularFrustum::SetViewClipping (const Handle(Graphic3d_Seque
// function : isViewClippingOk
// purpose :
// =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const Standard_Real theDepth) const
Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const SelectBasics_PickResult& thePickResult) const
{
return !myIsViewClipEnabled
|| !myViewClipRange.IsClipped (theDepth);
|| !myViewClipRange.IsClipped (thePickResult.Depth());
}
// =======================================================================

View File

@@ -59,7 +59,7 @@ 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,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) 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
@@ -69,7 +69,7 @@ public:
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE;
@@ -79,12 +79,12 @@ public:
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) 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,7 +93,7 @@ public:
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked
//! screen point and given point theCOG
@@ -141,18 +141,18 @@ protected:
Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1,
const gp_Pnt& theSegPnt2,
Standard_Real& theDepth);
SelectBasics_PickResult& thePickResult);
Standard_EXPORT void segmentPlaneIntersection (const gp_Vec& thePlane,
Standard_EXPORT bool segmentPlaneIntersection (const gp_Vec& thePlane,
const gp_Pnt& thePntOnPlane,
Standard_Real& theDepth);
SelectBasics_PickResult& thePickResult);
//! Computes valid depth range for the given clipping planes
Standard_EXPORT void computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
SelectMgr_ViewClipRange& theRange);
//! Returns false if theDepth must be clipped by current view clip range
Standard_EXPORT Standard_Boolean isViewClippingOk (const Standard_Real theDepth) const;
Standard_EXPORT Standard_Boolean isViewClippingOk (const SelectBasics_PickResult& thePickResult) const;
private:

View File

@@ -236,12 +236,12 @@ void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const TColgp_Array1
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (myActiveSelectionType == Unknown)
return Standard_False;
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, theDepth);
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, thePickResult);
}
//=======================================================================
@@ -263,13 +263,13 @@ 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,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (myActiveSelectionType == Unknown)
return Standard_False;
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt,
theDepth);
thePickResult);
}
//=======================================================================
@@ -293,14 +293,14 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePn
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
Standard_Integer theSensType,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (myActiveSelectionType == Unknown)
return Standard_False;
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(),
(Select3D_TypeOfSensitivity)theSensType,
theDepth);
thePickResult);
}
//=======================================================================
@@ -312,14 +312,14 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Standard_Integer theSensType,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (myActiveSelectionType == Unknown)
return Standard_False;
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts,
(Select3D_TypeOfSensitivity)theSensType,
theDepth);
thePickResult);
}
//=======================================================================
@@ -328,12 +328,12 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt1,
const gp_Pnt& thePt2,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (myActiveSelectionType == Unknown)
return Standard_False;
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, theDepth);
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, thePickResult);
}
//=======================================================================
@@ -347,7 +347,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
const gp_Pnt& thePt2,
const gp_Pnt& thePt3,
Standard_Integer theSensType,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (myActiveSelectionType == Unknown)
return Standard_False;
@@ -356,7 +356,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
thePt2,
thePt3,
(Select3D_TypeOfSensitivity)theSensType,
theDepth);
thePickResult);
}
//=======================================================================

View File

@@ -105,8 +105,8 @@ 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,
Standard_Real& theDepth) Standard_OVERRIDE;
const SelectMgr_Vec3& theBoxMax,
SelectBasics_PickResult& thePickResult) 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
@@ -116,7 +116,7 @@ public:
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE;
@@ -126,19 +126,19 @@ public:
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
Standard_Integer theSensType,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) 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,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) 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,7 +147,7 @@ public:
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Standard_Integer theSensType,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked

View File

@@ -169,7 +169,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustum::ScaleAndTransform (co
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& /*thePickResult*/)
{
return hasOverlap (theMinPt, theMaxPt);
}
@@ -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,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& /*thePickResult*/)
{
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,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& /*thePickResult*/)
{
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,
Standard_Real& /*theDepth*/)
SelectBasics_PickResult& /*thePickResult*/)
{
return hasOverlap (thePnt1, thePnt2);
}
@@ -253,13 +253,13 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 };
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 3);
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theDepth);
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, thePickResult);
}
else if (theSensType == Select3D_TOS_INTERIOR)
{

View File

@@ -48,7 +48,7 @@ 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,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) 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
@@ -58,19 +58,19 @@ public:
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) 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,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) 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,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Nullifies the handle to corresponding builder instance to prevent memory leaks
Standard_EXPORT void Clear();

View File

@@ -127,11 +127,11 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustumSet::ScaleAndTransform
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, theDepth))
if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, thePickResult))
return Standard_True;
}
@@ -160,11 +160,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3&
// purpose :
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
if (anIter.Value()->Overlaps (thePnt, theDepth))
if (anIter.Value()->Overlaps (thePnt, thePickResult))
return Standard_True;
}
@@ -177,11 +177,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, theDepth))
if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, thePickResult))
return Standard_True;
}
@@ -194,11 +194,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1Of
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
if (anIter.Value()->Overlaps (thePnt1, thePnt2, theDepth))
if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePickResult))
return Standard_True;
}
@@ -213,11 +213,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth)
SelectBasics_PickResult& thePickResult)
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, theDepth))
if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, thePickResult))
return Standard_True;
}

View File

@@ -52,28 +52,28 @@ public:
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
Standard_Boolean* theInside) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector

View File

@@ -67,6 +67,7 @@ namespace {
// purpose :
//=======================================================================
void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriterion,
const SelectBasics_PickResult& thePickResult,
const Handle(SelectBasics_SensitiveEntity)& theEntity,
const gp_GTrsf& theInversedTrsf,
const SelectMgr_SelectingVolumeManager& theMgr) const
@@ -76,7 +77,15 @@ void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriter
return;
}
theCriterion.Point = theMgr.DetectedPoint (theCriterion.Depth);
if (thePickResult.HasPickedPoint())
{
theCriterion.Point = thePickResult.PickedPoint();
}
else
{
theCriterion.Point = theMgr.DetectedPoint (theCriterion.Depth);
}
gp_GTrsf anInvTrsf = theInversedTrsf;
if (theCriterion.Entity->HasInitLocation())
{
@@ -277,7 +286,7 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive
{
if (aCriterion > *aPrevCriterion)
{
updatePoint3d (aCriterion, theEntity, theInversedTrsf, theMgr);
updatePoint3d (aCriterion, aPickResult, theEntity, theInversedTrsf, theMgr);
*aPrevCriterion = aCriterion;
}
}
@@ -285,7 +294,7 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive
else
{
aCriterion.NbOwnerMatches = 1;
updatePoint3d (aCriterion, theEntity, theInversedTrsf, theMgr);
updatePoint3d (aCriterion, aPickResult, theEntity, theInversedTrsf, theMgr);
mystored.Add (anOwner, aCriterion);
}
}

View File

@@ -326,6 +326,7 @@ private: // implementation of deprecated methods
//! Compute 3d position for detected entity.
void updatePoint3d (SelectMgr_SortCriterion& theCriterion,
const SelectBasics_PickResult& thePickResult,
const Handle(SelectBasics_SensitiveEntity)& theEntity,
const gp_GTrsf& theInversedTrsf,
const SelectMgr_SelectingVolumeManager& theMgr) const;