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.
@subsection upgrade_740_extremaalgo Changes in behavior of Convert algorithms
-Now methods *GeomConvert::ConcatG1*, *GeomConvert::ConcatC1*, *Geom2dConvert::ConcatG1*, *Geom2dConvert::ConcatC1* modify the input argument representing the flag of closedness.
\ No newline at end of file
+Now methods *GeomConvert::ConcatG1*, *GeomConvert::ConcatC1*, *Geom2dConvert::ConcatG1*, *Geom2dConvert::ConcatC1* modify the input argument representing the flag of closedness.
+@subsection upgrade_740_selection Change in selection API and picked point calculation algorithm.
+
+*SelectBasics_PickResult* structure has been extended, so that it now defines 3D point on detected entity in addition to Depth value along picking ray.
+*SelectMgr_SelectingVolumeManager::Overlap()* methods have been corrected to fill in *SelectBasics_PickResult* structure (depth and 3D point) instead of only depth value, so that custom *Select3D_SensitiveEntity* implementation should be updated accordingly (including *Select3D_SensitiveSet* subclasses).
//=======================================================================
Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth)
+ SelectBasics_PickResult& thePickResult)
{
const Standard_Integer anItemIdx = myItemIndexes.Value (theElemIdx);
if (mySelMethod == MeshVS_MSM_PRECISE)
return theMgr.Overlaps (gp_Pnt (aCoords (1), aCoords (2), aCoords (3)),
gp_Pnt (aCoords (4), aCoords (5), aCoords (6)),
gp_Pnt (aCoords (7), aCoords (8), aCoords (9)),
- Select3D_TOS_INTERIOR, theMatchDepth);
+ Select3D_TOS_INTERIOR, thePickResult);
}
MeshVS_Buffer aFacePntsBuf (aNbNodes * 3 * sizeof (Standard_Real));
aCoords (3 * aNodeIdx - 1),
aCoords (3 * aNodeIdx)));
}
- return theMgr.Overlaps (aFacePnts, Select3D_TOS_INTERIOR, theMatchDepth);
+ return theMgr.Overlaps (aFacePnts, Select3D_TOS_INTERIOR, thePickResult);
}
else if (mySelMethod == MeshVS_MSM_NODES)
{
const gp_Pnt aVert = getVertexByIndex (anItemIdx);
- return theMgr.Overlaps (aVert, theMatchDepth);
+ return theMgr.Overlaps (aVert, thePickResult);
}
return Standard_False;
}
//! Checks whether the entity with index theIdx overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth) Standard_OVERRIDE;
+ SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks whether the entity with index theIdx is inside the current selecting volume
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Boolean MeshVS_SensitivePolyhedron::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
- Standard_Real aDepthMin = RealLast();
- Standard_Real aDistToCOG = RealLast();
-
+ SelectBasics_PickResult aPickResult;
for (MeshVS_PolyhedronVertsIter aIter (myTopology); aIter.More(); aIter.Next())
{
- Standard_Real aDepth = RealLast();
- if (theMgr.Overlaps (aIter.Value(), Select3D_TOS_INTERIOR, aDepth))
+ if (theMgr.Overlaps (aIter.Value(), Select3D_TOS_INTERIOR, aPickResult))
{
- aDepthMin = Min (aDepth, aDepthMin);
+ thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
}
}
+ if (!thePickResult.IsValid())
+ {
+ return Standard_False;
+ }
- aDistToCOG = aDepthMin == RealLast() ? RealLast() : theMgr.DistToGeometryCenter (myCenter);
- thePickResult = SelectBasics_PickResult (aDepthMin, aDistToCOG);
-
- return aDepthMin != RealLast();
+ thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (CenterOfGeometry()));
+ return Standard_True;
}
//=======================================================================
Standard_Boolean MeshVS_SensitiveQuad::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
- thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
-
if (!theMgr.IsOverlapAllowed()) // check for inclusion
{
for (Standard_Integer aPntIdx = 0; aPntIdx < 4; ++aPntIdx)
}
// check for overlap
- Standard_Real aDepth1 = std::numeric_limits<Standard_Real>::max();
- Standard_Real aDepth2 = std::numeric_limits<Standard_Real>::max();
- if (!theMgr.Overlaps (myVertices[0], myVertices[1], myVertices[2], Select3D_TOS_INTERIOR, aDepth1)
- && !theMgr.Overlaps (myVertices[0], myVertices[2], myVertices[3], Select3D_TOS_INTERIOR, aDepth2))
+ SelectBasics_PickResult aPickResult1, aPickResult2;
+ if (!theMgr.Overlaps (myVertices[0], myVertices[1], myVertices[2], Select3D_TOS_INTERIOR, aPickResult1)
+ && !theMgr.Overlaps (myVertices[0], myVertices[2], myVertices[3], Select3D_TOS_INTERIOR, aPickResult2))
{
return Standard_False;
}
- thePickResult = SelectBasics_PickResult (Min (aDepth1, aDepth2), theMgr.DistToGeometryCenter (CenterOfGeometry()));
-
+ thePickResult = SelectBasics_PickResult::Min (aPickResult1, aPickResult2);
+ thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(CenterOfGeometry()));
return Standard_True;
}
// =======================================================================
Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth)
+ SelectBasics_PickResult& thePickResult)
{
Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theElemIdx);
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx);
Handle(TColgp_HArray1OfPnt) aPoints;
aPolygon->Points3D (aPoints);
- return theMgr.Overlaps (aPoints, Select3D_TOS_INTERIOR, theMatchDepth);
+ return theMgr.Overlaps (aPoints, Select3D_TOS_INTERIOR, thePickResult);
}
// =======================================================================
Standard_Boolean Select3D_InteriorSensitivePointSet::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
const Standard_Integer theElemIdx)
{
- Standard_Real aDummy;
+ SelectBasics_PickResult aDummy;
return overlapsElement (theMgr, theElemIdx, aDummy);
}
//! in myPlanarPolygons overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth) Standard_OVERRIDE;
+ SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks whether the entity with index theIdx is inside the current selecting volume
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Boolean Select3D_SensitiveBox::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
- thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
-
if (!theMgr.IsOverlapAllowed()) // check for inclusion
{
Standard_Boolean isInside = Standard_True;
return theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), &isInside) && isInside;
}
- Standard_Real aDepth;
- if (!theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), aDepth)) // check for overlap
+ if (!theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), thePickResult)) // check for overlap
{
return Standard_False;
}
- thePickResult = SelectBasics_PickResult (
- aDepth, theMgr.DistToGeometryCenter (myCenter3d));
-
+ thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCenter3d));
return Standard_True;
}
Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
- Standard_Real aDepth = RealLast();
- Standard_Real aDistToCOG = RealLast();
-
if (mySensType == Select3D_TOS_BOUNDARY)
{
if (!Select3D_SensitivePoly::Matches (theMgr, thePickResult))
{
- thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_False;
}
}
Points3D (anArrayOfPnt);
if (!theMgr.IsOverlapAllowed())
{
- thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper(); ++aPntIdx)
{
- if (!theMgr.Overlaps (anArrayOfPnt->Value (aPntIdx)))
+ if (!theMgr.Overlaps (anArrayOfPnt->Value(aPntIdx)))
+ {
return Standard_False;
+ }
}
return Standard_True;
}
- if (!theMgr.Overlaps (anArrayOfPnt, Select3D_TOS_INTERIOR, aDepth))
+ if (!theMgr.Overlaps (anArrayOfPnt, Select3D_TOS_INTERIOR, thePickResult))
{
- thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_False;
}
- else
- {
- thePickResult = SelectBasics_PickResult (aDepth, theMgr.DistToGeometryCenter (myCenter3D));
- }
+ thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
}
return Standard_True;
return Select3D_SensitiveSet::Matches (theMgr, thePickResult);
}
- Standard_Real aDepth = RealLast();
- Standard_Real aDistToCOG = RealLast();
+ SelectBasics_PickResult aPickResult;
Standard_Boolean isFailed = Standard_False;
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
{
- SelectBasics_PickResult aMatchResult;
const Handle(Select3D_SensitiveEntity)& aChild = anEntityIter.Value();
- if (!aChild->Matches (theMgr, aMatchResult))
+ if (!aChild->Matches (theMgr, aPickResult))
{
if (toMatchAll)
{
}
else
{
- aDepth = Min (aMatchResult.Depth(), aDepth);
+ thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
}
}
if (isFailed)
{
- thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
return Standard_False;
}
- aDistToCOG = theMgr.DistToGeometryCenter (CenterOfGeometry());
- thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+ thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
return Standard_True;
}
// =======================================================================
Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth)
+ SelectBasics_PickResult& thePickResult)
{
- theMatchDepth = RealLast();
const Standard_Integer aSensitiveIdx = myBVHPrimIndexes.Value (theElemIdx);
- SelectBasics_PickResult aResult;
- if (myEntities.FindKey (aSensitiveIdx)->Matches (theMgr, aResult))
+ if (myEntities.FindKey (aSensitiveIdx)->Matches (theMgr, thePickResult))
{
- theMatchDepth = aResult.Depth();
return Standard_True;
}
Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
const Standard_Integer theElemIdx)
{
- Standard_Real aDummy;
+ SelectBasics_PickResult aDummy;
return overlapsElement(theMgr, theElemIdx, aDummy);
}
//! Checks whether the entity with index theIdx overlaps the current selecting volume
virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth) Standard_OVERRIDE;
+ SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks whether the entity with index theIdx is inside the current selecting volume
virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Boolean Select3D_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
- Standard_Real aDepth = RealLast();
- Standard_Real aDistToCOG = RealLast();
- if (!theMgr.Overlaps (myPoint, aDepth))
+ if (!theMgr.Overlaps (myPoint, thePickResult))
{
- thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_False;
}
- aDistToCOG = aDepth;
- thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+ thePickResult.SetDistToGeomCenter (thePickResult.Depth());
return Standard_True;
}
//==================================================
Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth)
+ SelectBasics_PickResult& thePickResult)
{
if (mySegmentIndexes.IsNull())
return Standard_False;
gp_Pnt aPnt1 = myPolyg.Pnt3d (aSegmentIdx);
gp_Pnt aPnt2 = myPolyg.Pnt3d (aSegmentIdx + 1);
- return theMgr.Overlaps (aPnt1, aPnt2, theMatchDepth);
+ return theMgr.Overlaps (aPnt1, aPnt2, thePickResult);
}
//==================================================
//! Checks whether the segment with index theIdx overlaps the current selecting volume
virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth) Standard_OVERRIDE;
+ SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks whether the entity with index theIdx is inside the current selecting volume
virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
return Standard_True;
}
- Standard_Real aDepth = RealLast();
+ SelectBasics_PickResult aPickResult;
bool isFailed = false;
const bool toMatchAll = !theMgr.IsOverlapAllowed();
for (Standard_Integer aGroupIter = 0; aGroupIter < myBvhIndices.NbElements; ++aGroupIter)
{
const Standard_Integer anElemIdx = myBvhIndices.Index (aGroupIter);
- SelectBasics_PickResult aMatchResult;
Handle(Select3D_SensitivePrimitiveArray)& aChild = myGroups->ChangeValue (anElemIdx);
- const bool isMatched = aChild->Matches (theMgr, aMatchResult);
+ const bool isMatched = aChild->Matches (theMgr, aPickResult);
if (!myDetectedElemMap.IsNull())
{
myDetectedElemMap->ChangeMap().Unite (aChild->myDetectedElemMap->Map());
}
else
{
- if (aDepth > aMatchResult.Depth())
+ if (thePickResult.Depth() > aPickResult.Depth())
{
myDetectedIdx = aGroupIter;
- aDepth = aMatchResult.Depth();
+ thePickResult = aPickResult;
}
}
}
if (isFailed)
{
- thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
return Standard_False;
}
-
- thePickResult = SelectBasics_PickResult (aDepth, theMgr.DistToGeometryCenter (CenterOfGeometry()));
+ thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(CenterOfGeometry()));
return Standard_True;
}
// =======================================================================
Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth)
+ SelectBasics_PickResult& thePickResult)
{
const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx);
if (!myGroups.IsNull())
{
- SelectBasics_PickResult aResult;
- if (myGroups->Value (anElemIdx)->Matches (theMgr, aResult))
+ if (myGroups->Value (anElemIdx)->Matches (theMgr, thePickResult))
{
- theMatchDepth = aResult.Depth();
return Standard_True;
}
- theMatchDepth = RealLast();
+
return Standard_False;
}
const Standard_Integer aPatchSize = myBvhIndices.PatchSize (theElemIdx);
Select3D_BndBox3d aBox;
Standard_Boolean aResult = Standard_False;
- Standard_Real aMinDepth = RealLast();
+ SelectBasics_PickResult aPickResult;
switch (myPrimType)
{
case Graphic3d_TOPA_POINTS:
aPoint = vecToPnt (getPosVec2 (aPointIndex));
}
- Standard_Real aCurrentDepth = RealLast();
if (myToDetectNode
|| myToDetectElem)
{
- if (theMgr.Overlaps (aPoint, aCurrentDepth))
+ if (theMgr.Overlaps (aPoint, aPickResult))
{
- if (aCurrentDepth <= myMinDepthNode)
+ if (aPickResult.Depth() <= myMinDepthNode)
{
myDetectedElem = myDetectedNode = aPointIndex;
- myMinDepthElem = myMinDepthNode = aCurrentDepth;
+ myMinDepthElem = myMinDepthNode = aPickResult.Depth();
}
if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
{
aResult = Standard_True;
}
}
- aMinDepth = Min (aMinDepth, aCurrentDepth);
+ thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
}
break;
}
aPnts[2] = vecToPnt (getPosVec2 (aTriNodes[2]));
}
- Standard_Real aCurrentDepth = RealLast();
if (myToDetectElem)
{
- if (theMgr.Overlaps (aPnts[0], aPnts[1], aPnts[2], Select3D_TOS_INTERIOR, aCurrentDepth))
+ if (theMgr.Overlaps (aPnts[0], aPnts[1], aPnts[2], Select3D_TOS_INTERIOR, aPickResult))
{
- if (aCurrentDepth <= myMinDepthElem)
+ if (aPickResult.Depth() <= myMinDepthElem)
{
myDetectedElem = aTriIndex;
- myMinDepthElem = aCurrentDepth;
+ myMinDepthElem = aPickResult.Depth();
}
aResult = Standard_True;
}
{
for (int aNodeIter = 0; aNodeIter < 3; ++aNodeIter)
{
- if (theMgr.Overlaps (aPnts[aNodeIter], aCurrentDepth))
+ if (theMgr.Overlaps (aPnts[aNodeIter], aPickResult))
{
- if (aCurrentDepth <= myMinDepthNode)
+ if (aPickResult.Depth() <= myMinDepthNode)
{
myDetectedNode = aTriNodes[aNodeIter];
- myMinDepthNode = aCurrentDepth;
+ myMinDepthNode = aPickResult.Depth();
}
if (!myDetectedNodeMap.IsNull()
&& theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
{
int aNode1 = aNodeIter == 0 ? 2 : (aNodeIter - 1);
int aNode2 = aNodeIter;
- if (theMgr.Overlaps (aPnts[aNode1], aPnts[aNode2], aCurrentDepth))
+ if (theMgr.Overlaps (aPnts[aNode1], aPnts[aNode2], aPickResult))
{
- if (aCurrentDepth <= myMinDepthEdge)
+ if (aPickResult.Depth() <= myMinDepthEdge)
{
myDetectedEdgeNode1 = aTriNodes[aNode1];
myDetectedEdgeNode2 = aTriNodes[aNode2];
- myMinDepthEdge = aCurrentDepth;
+ myMinDepthEdge = aPickResult.Depth();
}
aResult = Standard_True;
}
}
}
- aMinDepth = Min (aMinDepth, aCurrentDepth);
+ thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
}
break;
}
}
}
- theMatchDepth = aMinDepth;
return aResult;
}
const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx);
if (!myGroups.IsNull())
{
- Standard_Real aDummy;
+ SelectBasics_PickResult aDummy;
return overlapsElement (theMgr, theElemIdx, aDummy);
}
//! Checks whether the element with index theIdx overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth) Standard_OVERRIDE;
+ SelectBasics_PickResult& thePickResult) 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;
Standard_Boolean Select3D_SensitiveSegment::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
- thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
-
- Standard_Real aDepth;
if (!theMgr.IsOverlapAllowed()) // check for inclusion
{
- return theMgr.Overlaps (myStart, aDepth) && theMgr.Overlaps (myEnd, aDepth);
+ return theMgr.Overlaps (myStart, thePickResult) && theMgr.Overlaps (myEnd, thePickResult);
}
- if (!theMgr.Overlaps (myStart, myEnd, aDepth)) // check for overlap
+ if (!theMgr.Overlaps (myStart, myEnd, thePickResult)) // check for overlap
{
return Standard_False;
}
- thePickResult = SelectBasics_PickResult (aDepth,
- theMgr.DistToGeometryCenter (CenterOfGeometry()));
-
+ thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(CenterOfGeometry()));
return Standard_True;
}
{
myDetectedIdx = -1;
const BVH_Tree<Standard_Real, 3, BVH_BinaryTree>* aBVH = myContent.GetBVH().get();
- thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
if (myContent.Size() < 1 || !theMgr.Overlaps (aBVH->MinPoint (0),
aBVH->MaxPoint (0)))
{
Standard_Integer aHead = -1;
Standard_Integer aMatchesNb = -1;
- Standard_Real aMinDepth = RealLast();
+ SelectBasics_PickResult aPickResult;
for (;;)
{
const BVH_Vec4i& aData = aBVH->NodeInfoBuffer()[aNode];
}
else // overlap test
{
- Standard_Real aCurrentDepth = aMinDepth;
-
- if (!overlapsElement (theMgr, anElemIdx, aCurrentDepth))
+ if (!overlapsElement (theMgr, anElemIdx, aPickResult))
{
continue;
}
- if (aMinDepth > aCurrentDepth)
+ if (thePickResult.Depth() > aPickResult.Depth())
{
- aMinDepth = aCurrentDepth;
+ thePickResult = aPickResult;
myDetectedIdx = anElemIdx;
}
if (aMatchesNb != -1)
{
- thePickResult = SelectBasics_PickResult (aMinDepth, distanceToCOG (theMgr));
+ thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
}
return !theMgr.IsOverlapAllowed() || aMatchesNb != -1;
//! @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,
- Standard_Real& theMatchDepth) = 0;
+ SelectBasics_PickResult& thePickResult) = 0;
//! Checks whether the entity with index theIdx is inside the current selecting volume
virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Boolean Select3D_SensitiveTriangle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
- Standard_Real aDepth = RealLast();
- Standard_Real aDistToCOG = RealLast();
if (!theMgr.IsOverlapAllowed())
{
return theMgr.Overlaps (myPoints[0])
&& theMgr.Overlaps (myPoints[2]);
}
- if (!theMgr.Overlaps (myPoints[0], myPoints[1], myPoints[2], mySensType, aDepth))
+ if (!theMgr.Overlaps (myPoints[0], myPoints[1], myPoints[2], mySensType, thePickResult))
{
- thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_False;
}
- aDistToCOG = theMgr.DistToGeometryCenter (myCentroid);
- thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+ thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCentroid));
return Standard_True;
}
Standard_Integer aNode1, aNode2, aNode3;
myTriangul->Triangles() (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
- gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1);
- gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2);
- gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3);
+ const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
+ const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
+ const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
aMinPnt = SelectMgr_Vec3 (Min (aPnt1.X(), Min (aPnt2.X(), aPnt3.X())),
Min (aPnt1.Y(), Min (aPnt2.Y(), aPnt3.Y())),
{
Standard_Integer aNodeIdx1 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx);
Standard_Integer aNodeIdx2 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx + 1);
- gp_Pnt aNode1 = myTriangul->Nodes().Value (aNodeIdx1);
- gp_Pnt aNode2 = myTriangul->Nodes().Value (aNodeIdx2);
+ const gp_Pnt& aNode1 = myTriangul->Nodes().Value (aNodeIdx1);
+ const gp_Pnt& aNode2 = myTriangul->Nodes().Value (aNodeIdx2);
aMinPnt = SelectMgr_Vec3 (Min (aNode1.X(), aNode2.X()),
Min (aNode1.Y(), aNode2.Y()),
const Standard_Integer theAxis) const
{
const Select3D_BndBox3d& aBox = Box (theIdx);
- SelectMgr_Vec3 aCenter = (aBox.CornerMin () + aBox.CornerMax ()) * 0.5;
-
- return theAxis == 0 ? aCenter.x() : (theAxis == 1 ? aCenter.y() : aCenter.z());
+ const SelectMgr_Vec3 aCenter = (aBox.CornerMin () + aBox.CornerMax ()) * 0.5;
+ return aCenter[theAxis];
}
//=======================================================================
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth)
+ SelectBasics_PickResult& thePickResult)
{
const Standard_Integer& aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx);
{
Standard_Integer aSegmStartIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 1);
Standard_Integer aSegmEndIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 2);
- Handle(TColgp_HArray1OfPnt) anEdgePnts = new TColgp_HArray1OfPnt (1, 2);
- gp_Pnt aSegmStart = myTriangul->Nodes().Value (aSegmStartIdx);
- gp_Pnt aSegmEnd = myTriangul->Nodes().Value (aSegmEndIdx);
- anEdgePnts->SetValue (1, aSegmStart);
- anEdgePnts->SetValue (2, aSegmEnd);
- Standard_Boolean isMatched = theMgr.Overlaps (anEdgePnts, Select3D_TOS_BOUNDARY, theMatchDepth);
- anEdgePnts.Nullify();
+
+ const gp_Pnt anEdgePnts[2] =
+ {
+ myTriangul->Nodes().Value (aSegmStartIdx),
+ myTriangul->Nodes().Value (aSegmEndIdx)
+ };
+ TColgp_Array1OfPnt anEdgePntsArr (anEdgePnts[0], 1, 2);
+ Standard_Boolean isMatched = theMgr.Overlaps (anEdgePntsArr, Select3D_TOS_BOUNDARY, thePickResult);
return isMatched;
}
else
const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles();
Standard_Integer aNode1, aNode2, aNode3;
aTriangles (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
- gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1);
- gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2);
- gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3);
- return theMgr.Overlaps (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, theMatchDepth);
+ const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
+ const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
+ const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
+ return theMgr.Overlaps (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, thePickResult);
}
}
if (mySensType == Select3D_TOS_BOUNDARY)
{
- gp_Pnt aSegmPnt1 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
- gp_Pnt aSegmPnt2 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
-
+ const gp_Pnt& aSegmPnt1 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
+ const gp_Pnt& aSegmPnt2 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
return theMgr.Overlaps (aSegmPnt1) && theMgr.Overlaps (aSegmPnt2);
}
else
{
- Standard_Integer aNode1;
- Standard_Integer aNode2;
- Standard_Integer aNode3;
-
+ Standard_Integer aNode1, aNode2, aNode3;
myTriangul->Triangles() (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
- gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1);
- gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2);
- gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3);
-
+ const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
+ const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
+ const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
return theMgr.Overlaps (aPnt1)
&& theMgr.Overlaps (aPnt2)
&& theMgr.Overlaps (aPnt3);
//! Checks whether the element with index theIdx overlaps the current selecting volume
virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth) Standard_OVERRIDE;
+ SelectBasics_PickResult& thePickResult) 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;
// =======================================================================
Standard_Boolean Select3D_SensitiveWire::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth)
+ SelectBasics_PickResult& thePickResult)
{
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (theElemIdx);
const Handle(SelectBasics_SensitiveEntity)& aSeg = myEntities.Value (aSensitiveIdx);
- SelectBasics_PickResult aMatchResult;
- if (aSeg->Matches (theMgr, aMatchResult))
- {
- theMatchDepth = aMatchResult.Depth();
- return Standard_True;
- }
-
- return Standard_False;
+ return aSeg->Matches (theMgr, thePickResult);
}
// =======================================================================
//! Checks whether the entity with index theIdx overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
- Standard_Real& theMatchDepth) Standard_OVERRIDE;
+ SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks whether the entity with index theIdx is inside the current selecting volume
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
#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 myDepth;
- }
- inline Standard_Real DistToGeomCenter() const
+ //! Return TRUE if result was been defined.
+ Standard_Boolean IsValid() const { return myDepth != RealLast(); }
+
+ //! Reset depth value.
+ void Invalidate()
{
- return myDistToCenter;
+ myDepth = RealLast();
+ myObjPickedPnt = gp_Pnt (RealLast(), 0.0, 0.0);
}
+ //! 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
#include <BVH_Box.hxx>
#include <gp_Pnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
+#include <SelectBasics_PickResult.hxx>
class Bnd_Box;
class gp_Pnt;
//! 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
//! 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
//! 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
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
//=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
const SelectMgr_Vec3& /*theBoxMax*/,
- Standard_Real& /*theDepth*/)
+ SelectBasics_PickResult& /*thePickResult*/)
{
return Standard_False;
}
// 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;
}
//=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
Select3D_TypeOfSensitivity /*theSensType*/,
- Standard_Real& /*theDepth*/)
+ SelectBasics_PickResult& )
{
return Standard_False;
}
const gp_Pnt& /*thePt2*/,
const gp_Pnt& /*thePt3*/,
Select3D_TypeOfSensitivity /*theSensType*/,
- Standard_Real& /*theDepth*/)
+ SelectBasics_PickResult& )
{
return Standard_False;
}
//=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
const gp_Pnt& /*thePnt2*/,
- Standard_Real& /*theDepth*/)
+ SelectBasics_PickResult& )
{
return Standard_False;
}
#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
//! 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
//! 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
//! 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
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
// =======================================================================
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();
}
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();
{
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
// =======================================================================
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;
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);
}
// =======================================================================
// 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;
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);
}
// =======================================================================
// =======================================================================
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);
}
// =======================================================================
// =======================================================================
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)
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);
}
}
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);
}
// =======================================================================
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)
{
// 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);
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();
aNearestEdgeIdx = anEdgeIdx;
}
}
- segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], theDepth);
+ segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], thePickResult);
}
- return isViewClippingOk (theDepth);
+ return isViewClippingOk (thePickResult);
}
// =======================================================================
// 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());
}
// =======================================================================
//! 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
//! 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;
//! 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
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
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:
//=======================================================================
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);
}
//=======================================================================
// 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);
}
//=======================================================================
//=======================================================================
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);
}
//=======================================================================
//=======================================================================
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);
}
//=======================================================================
//=======================================================================
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);
}
//=======================================================================
const gp_Pnt& thePt2,
const gp_Pnt& thePt3,
Standard_Integer theSensType,
- Standard_Real& theDepth)
+ SelectBasics_PickResult& thePickResult)
{
if (myActiveSelectionType == Unknown)
return Standard_False;
thePt2,
thePt3,
(Select3D_TypeOfSensitivity)theSensType,
- theDepth);
+ thePickResult);
}
//=======================================================================
//! 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
//! 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;
//! 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
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
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
- Standard_Real& /*theDepth*/)
+ SelectBasics_PickResult& /*thePickResult*/)
{
return hasOverlap (theMinPt, theMaxPt);
}
// 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);
}
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
- Standard_Real& /*theDepth*/)
+ SelectBasics_PickResult& /*thePickResult*/)
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
- Standard_Real& /*theDepth*/)
+ SelectBasics_PickResult& /*thePickResult*/)
{
return hasOverlap (thePnt1, thePnt2);
}
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)
{
//! 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
//! 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
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();
// =======================================================================
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;
}
// 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;
}
// =======================================================================
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;
}
// =======================================================================
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;
}
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;
}
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
// 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
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())
{
{
if (aCriterion > *aPrevCriterion)
{
- updatePoint3d (aCriterion, theEntity, theInversedTrsf, theMgr);
+ updatePoint3d (aCriterion, aPickResult, theEntity, theInversedTrsf, theMgr);
*aPrevCriterion = aCriterion;
}
}
else
{
aCriterion.NbOwnerMatches = 1;
- updatePoint3d (aCriterion, theEntity, theInversedTrsf, theMgr);
+ updatePoint3d (aCriterion, aPickResult, theEntity, theInversedTrsf, theMgr);
mystored.Add (anOwner, aCriterion);
}
}
//! 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;
--- /dev/null
+puts "============"
+puts "0029938: Visualization - SelectMgr_ViewerSelector::PickedPoint() should return point lying on an object"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION
+box b 1 2 3
+vcaps -core
+vclear
+vinit View1
+vaxo
+vdisplay -dispMode 1 -mutable b
+vfit
+vrotate 0.2 0.0 0.0
+vselmode 0 off
+
+#Check Vertex selection mode case
+vselmode 1 on
+vmoveto 337 45
+set pnt "1 2 3"
+set exp {Point: ([-0-9.+eE]+) ([-0-9.+eE]+) ([-0-9.+eE]+)}
+set match [regexp -all -inline $exp [vstate -entities]]
+foreach {_ x y z} $match {
+ if {$pnt != "$x $y $z"} {
+ puts "Error: Calculate point ($x $y $z) is not equal to target ($pnt)" }
+}
+
+#Check Wire selection mode case
+vselmode 1 off
+vselmode 2 on
+vmoveto 295 317
+set pnt "1 2 0"
+set exp {Point: ([-0-9.+eE]+) ([-0-9.+eE]+) ([-0-9.+eE]+)}
+set match [regexp -all -inline $exp [vstate -entities]]
+foreach {_ x y z} $match {
+ if {$pnt != "$x $y $z"} {
+ puts "Error: Calculate point ($x $y $z) is not equal to target ($pnt)" }
+}
+
+#Check Face selection mode case
+vselmode 2 off
+vselmode 4 on
+vmoveto 284 324
+set pnt "1 1.8383 0"
+set exp {Point: ([-0-9.+eE]+) ([-0-9.+eE]+) ([-0-9.+eE]+)}
+set match [regexp -all -inline $exp [vstate -entities]]
+foreach {_ x y z} $match {
+ if {$pnt != "$x $y $z"} {
+ puts "Error: Calculate point ($x $y $z) is not equal to target ($pnt)" }
+}