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

@@ -264,13 +264,13 @@ void Select3D_InteriorSensitivePointSet::Swap (const Standard_Integer theIdx1,
// =======================================================================
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);
}
// =======================================================================
@@ -280,7 +280,7 @@ Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasi
Standard_Boolean Select3D_InteriorSensitivePointSet::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
const Standard_Integer theElemIdx)
{
Standard_Real aDummy;
SelectBasics_PickResult aDummy;
return overlapsElement (theMgr, theElemIdx, aDummy);
}

View File

@@ -78,7 +78,7 @@ protected:
//! 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,

View File

@@ -86,23 +86,18 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveBox::GetConnected()
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;
}

View File

@@ -238,14 +238,10 @@ void Select3D_SensitiveCircle::BVH()
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;
}
}
@@ -255,24 +251,21 @@ Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolume
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;

View File

@@ -202,14 +202,12 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
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)
{
@@ -222,17 +220,15 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
}
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;
}
@@ -332,14 +328,11 @@ Standard_Integer Select3D_SensitiveGroup::Size() const
// =======================================================================
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;
}
@@ -353,7 +346,7 @@ Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_Selectin
Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
const Standard_Integer theElemIdx)
{
Standard_Real aDummy;
SelectBasics_PickResult aDummy;
return overlapsElement(theMgr, theElemIdx, aDummy);
}

View File

@@ -148,7 +148,7 @@ private:
//! 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,

View File

@@ -37,16 +37,12 @@ Select3D_SensitivePoint::Select3D_SensitivePoint (const Handle(SelectBasics_Enti
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;
}

View File

@@ -222,7 +222,7 @@ void Select3D_SensitivePoly::Swap (const Standard_Integer theIdx1,
//==================================================
Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
Standard_Real& theMatchDepth)
SelectBasics_PickResult& thePickResult)
{
if (mySegmentIndexes.IsNull())
return Standard_False;
@@ -231,7 +231,7 @@ Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_Selecting
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);
}
//==================================================

View File

@@ -97,7 +97,7 @@ private:
//! 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,

View File

@@ -928,15 +928,14 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
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());
@@ -959,20 +958,18 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
}
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;
}
@@ -982,25 +979,23 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
// =======================================================================
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:
@@ -1021,16 +1016,15 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
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)
{
@@ -1046,7 +1040,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
aResult = Standard_True;
}
}
aMinDepth = Min (aMinDepth, aCurrentDepth);
thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
}
break;
}
@@ -1072,15 +1066,14 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
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;
}
@@ -1094,12 +1087,12 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
{
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)
@@ -1116,19 +1109,19 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
{
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;
}
@@ -1138,7 +1131,6 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
}
}
theMatchDepth = aMinDepth;
return aResult;
}
@@ -1161,7 +1153,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::elementIsInside (SelectBasics
const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx);
if (!myGroups.IsNull())
{
Standard_Real aDummy;
SelectBasics_PickResult aDummy;
return overlapsElement (theMgr, theElemIdx, aDummy);
}

View File

@@ -280,7 +280,7 @@ protected:
//! 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;

View File

@@ -42,22 +42,17 @@ Select3D_SensitiveSegment::Select3D_SensitiveSegment (const Handle(SelectBasics_
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;
}

View File

@@ -76,7 +76,6 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
{
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)))
{
@@ -88,7 +87,7 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
Standard_Integer aHead = -1;
Standard_Integer aMatchesNb = -1;
Standard_Real aMinDepth = RealLast();
SelectBasics_PickResult aPickResult;
for (;;)
{
const BVH_Vec4i& aData = aBVH->NodeInfoBuffer()[aNode];
@@ -150,16 +149,14 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
}
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;
}
@@ -176,7 +173,7 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
if (aMatchesNb != -1)
{
thePickResult = SelectBasics_PickResult (aMinDepth, distanceToCOG (theMgr));
thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
}
return !theMgr.IsOverlapAllowed() || aMatchesNb != -1;

View File

@@ -100,7 +100,7 @@ protected:
//! @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,

View File

@@ -48,8 +48,6 @@ Select3D_SensitiveTriangle::Select3D_SensitiveTriangle (const Handle(SelectBasic
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])
@@ -57,14 +55,12 @@ Standard_Boolean Select3D_SensitiveTriangle::Matches (SelectBasics_SelectingVolu
&& 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;
}

View File

@@ -198,9 +198,9 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
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())),
@@ -213,8 +213,8 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
{
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()),
@@ -236,9 +236,8 @@ Standard_Real Select3D_SensitiveTriangulation::Center (const Standard_Integer th
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];
}
//=======================================================================
@@ -262,7 +261,7 @@ void Select3D_SensitiveTriangulation::Swap (const Standard_Integer theIdx1,
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
Standard_Real& theMatchDepth)
SelectBasics_PickResult& thePickResult)
{
const Standard_Integer& aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx);
@@ -270,13 +269,14 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
{
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
@@ -284,10 +284,10 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
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);
}
}
@@ -302,23 +302,18 @@ Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_
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);

View File

@@ -104,7 +104,7 @@ private:
//! 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;

View File

@@ -114,18 +114,11 @@ void Select3D_SensitiveWire::Swap (const Standard_Integer theIdx1,
// =======================================================================
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);
}
// =======================================================================

View File

@@ -75,7 +75,7 @@ protected:
//! 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,