1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +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

@ -1610,4 +1610,8 @@ A set of deprecated methods previously related to Local Context and now redirect
@subsection upgrade_740_extremaalgo Changes in behavior of Convert algorithms @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. 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).

View File

@ -224,7 +224,7 @@ void MeshVS_CommonSensitiveEntity::Swap (const Standard_Integer theIdx1,
//======================================================================= //=======================================================================
Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) SelectBasics_PickResult& thePickResult)
{ {
const Standard_Integer anItemIdx = myItemIndexes.Value (theElemIdx); const Standard_Integer anItemIdx = myItemIndexes.Value (theElemIdx);
if (mySelMethod == MeshVS_MSM_PRECISE) if (mySelMethod == MeshVS_MSM_PRECISE)
@ -250,7 +250,7 @@ Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_Sel
return theMgr.Overlaps (gp_Pnt (aCoords (1), aCoords (2), aCoords (3)), return theMgr.Overlaps (gp_Pnt (aCoords (1), aCoords (2), aCoords (3)),
gp_Pnt (aCoords (4), aCoords (5), aCoords (6)), gp_Pnt (aCoords (4), aCoords (5), aCoords (6)),
gp_Pnt (aCoords (7), aCoords (8), aCoords (9)), gp_Pnt (aCoords (7), aCoords (8), aCoords (9)),
Select3D_TOS_INTERIOR, theMatchDepth); Select3D_TOS_INTERIOR, thePickResult);
} }
MeshVS_Buffer aFacePntsBuf (aNbNodes * 3 * sizeof (Standard_Real)); MeshVS_Buffer aFacePntsBuf (aNbNodes * 3 * sizeof (Standard_Real));
@ -261,12 +261,12 @@ Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_Sel
aCoords (3 * aNodeIdx - 1), aCoords (3 * aNodeIdx - 1),
aCoords (3 * aNodeIdx))); 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) else if (mySelMethod == MeshVS_MSM_NODES)
{ {
const gp_Pnt aVert = getVertexByIndex (anItemIdx); const gp_Pnt aVert = getVertexByIndex (anItemIdx);
return theMgr.Overlaps (aVert, theMatchDepth); return theMgr.Overlaps (aVert, thePickResult);
} }
return Standard_False; return Standard_False;
} }

View File

@ -67,7 +67,7 @@ protected:
//! Checks whether the entity with index theIdx overlaps the current selecting volume //! Checks whether the entity with index theIdx overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, 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 //! Checks whether the entity with index theIdx is inside the current selecting volume
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,

View File

@ -84,22 +84,21 @@ Handle(Select3D_SensitiveEntity) MeshVS_SensitivePolyhedron::GetConnected()
Standard_Boolean MeshVS_SensitivePolyhedron::Matches (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean MeshVS_SensitivePolyhedron::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) SelectBasics_PickResult& thePickResult)
{ {
Standard_Real aDepthMin = RealLast(); SelectBasics_PickResult aPickResult;
Standard_Real aDistToCOG = RealLast();
for (MeshVS_PolyhedronVertsIter aIter (myTopology); aIter.More(); aIter.Next()) for (MeshVS_PolyhedronVertsIter aIter (myTopology); aIter.More(); aIter.Next())
{ {
Standard_Real aDepth = RealLast(); if (theMgr.Overlaps (aIter.Value(), Select3D_TOS_INTERIOR, aPickResult))
if (theMgr.Overlaps (aIter.Value(), Select3D_TOS_INTERIOR, aDepth))
{ {
aDepthMin = Min (aDepth, aDepthMin); thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
} }
} }
if (!thePickResult.IsValid())
{
return Standard_False;
}
aDistToCOG = aDepthMin == RealLast() ? RealLast() : theMgr.DistToGeometryCenter (myCenter); thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (CenterOfGeometry()));
thePickResult = SelectBasics_PickResult (aDepthMin, aDistToCOG); return Standard_True;
return aDepthMin != RealLast();
} }
//======================================================================= //=======================================================================

View File

@ -66,8 +66,6 @@ Handle(Select3D_SensitiveEntity) MeshVS_SensitiveQuad::GetConnected()
Standard_Boolean MeshVS_SensitiveQuad::Matches (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean MeshVS_SensitiveQuad::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) SelectBasics_PickResult& thePickResult)
{ {
thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
if (!theMgr.IsOverlapAllowed()) // check for inclusion if (!theMgr.IsOverlapAllowed()) // check for inclusion
{ {
for (Standard_Integer aPntIdx = 0; aPntIdx < 4; ++aPntIdx) for (Standard_Integer aPntIdx = 0; aPntIdx < 4; ++aPntIdx)
@ -80,16 +78,15 @@ Standard_Boolean MeshVS_SensitiveQuad::Matches (SelectBasics_SelectingVolumeMana
} }
// check for overlap // check for overlap
Standard_Real aDepth1 = std::numeric_limits<Standard_Real>::max(); SelectBasics_PickResult aPickResult1, aPickResult2;
Standard_Real aDepth2 = std::numeric_limits<Standard_Real>::max(); if (!theMgr.Overlaps (myVertices[0], myVertices[1], myVertices[2], Select3D_TOS_INTERIOR, aPickResult1)
if (!theMgr.Overlaps (myVertices[0], myVertices[1], myVertices[2], Select3D_TOS_INTERIOR, aDepth1) && !theMgr.Overlaps (myVertices[0], myVertices[2], myVertices[3], Select3D_TOS_INTERIOR, aPickResult2))
&& !theMgr.Overlaps (myVertices[0], myVertices[2], myVertices[3], Select3D_TOS_INTERIOR, aDepth2))
{ {
return Standard_False; 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; return Standard_True;
} }

View File

@ -264,13 +264,13 @@ void Select3D_InteriorSensitivePointSet::Swap (const Standard_Integer theIdx1,
// ======================================================================= // =======================================================================
Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) SelectBasics_PickResult& thePickResult)
{ {
Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theElemIdx); Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theElemIdx);
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx); const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx);
Handle(TColgp_HArray1OfPnt) aPoints; Handle(TColgp_HArray1OfPnt) aPoints;
aPolygon->Points3D (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, Standard_Boolean Select3D_InteriorSensitivePointSet::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
const Standard_Integer theElemIdx) const Standard_Integer theElemIdx)
{ {
Standard_Real aDummy; SelectBasics_PickResult aDummy;
return overlapsElement (theMgr, theElemIdx, aDummy); return overlapsElement (theMgr, theElemIdx, aDummy);
} }

View File

@ -78,7 +78,7 @@ protected:
//! in myPlanarPolygons overlaps the current selecting volume //! in myPlanarPolygons overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, 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 //! Checks whether the entity with index theIdx is inside the current selecting volume
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, 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, Standard_Boolean Select3D_SensitiveBox::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) SelectBasics_PickResult& thePickResult)
{ {
thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
if (!theMgr.IsOverlapAllowed()) // check for inclusion if (!theMgr.IsOverlapAllowed()) // check for inclusion
{ {
Standard_Boolean isInside = Standard_True; Standard_Boolean isInside = Standard_True;
return theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), &isInside) && isInside; return theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), &isInside) && isInside;
} }
Standard_Real aDepth; if (!theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), thePickResult)) // check for overlap
if (!theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), aDepth)) // check for overlap
{ {
return Standard_False; return Standard_False;
} }
thePickResult = SelectBasics_PickResult ( thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCenter3d));
aDepth, theMgr.DistToGeometryCenter (myCenter3d));
return Standard_True; return Standard_True;
} }

View File

@ -238,14 +238,10 @@ void Select3D_SensitiveCircle::BVH()
Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) SelectBasics_PickResult& thePickResult)
{ {
Standard_Real aDepth = RealLast();
Standard_Real aDistToCOG = RealLast();
if (mySensType == Select3D_TOS_BOUNDARY) if (mySensType == Select3D_TOS_BOUNDARY)
{ {
if (!Select3D_SensitivePoly::Matches (theMgr, thePickResult)) if (!Select3D_SensitivePoly::Matches (theMgr, thePickResult))
{ {
thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_False; return Standard_False;
} }
} }
@ -255,24 +251,21 @@ Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolume
Points3D (anArrayOfPnt); Points3D (anArrayOfPnt);
if (!theMgr.IsOverlapAllowed()) if (!theMgr.IsOverlapAllowed())
{ {
thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper(); ++aPntIdx) 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_False;
}
} }
return Standard_True; 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; return Standard_False;
} }
else thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
{
thePickResult = SelectBasics_PickResult (aDepth, theMgr.DistToGeometryCenter (myCenter3D));
}
} }
return Standard_True; return Standard_True;

View File

@ -202,14 +202,12 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
return Select3D_SensitiveSet::Matches (theMgr, thePickResult); return Select3D_SensitiveSet::Matches (theMgr, thePickResult);
} }
Standard_Real aDepth = RealLast(); SelectBasics_PickResult aPickResult;
Standard_Real aDistToCOG = RealLast();
Standard_Boolean isFailed = Standard_False; Standard_Boolean isFailed = Standard_False;
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next()) for (Select3D_IndexedMapOfEntity::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
{ {
SelectBasics_PickResult aMatchResult;
const Handle(Select3D_SensitiveEntity)& aChild = anEntityIter.Value(); const Handle(Select3D_SensitiveEntity)& aChild = anEntityIter.Value();
if (!aChild->Matches (theMgr, aMatchResult)) if (!aChild->Matches (theMgr, aPickResult))
{ {
if (toMatchAll) if (toMatchAll)
{ {
@ -222,17 +220,15 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
} }
else else
{ {
aDepth = Min (aMatchResult.Depth(), aDepth); thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
} }
} }
if (isFailed) if (isFailed)
{ {
thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
return Standard_False; return Standard_False;
} }
aDistToCOG = theMgr.DistToGeometryCenter (CenterOfGeometry()); thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_True; return Standard_True;
} }
@ -332,14 +328,11 @@ Standard_Integer Select3D_SensitiveGroup::Size() const
// ======================================================================= // =======================================================================
Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) SelectBasics_PickResult& thePickResult)
{ {
theMatchDepth = RealLast();
const Standard_Integer aSensitiveIdx = myBVHPrimIndexes.Value (theElemIdx); const Standard_Integer aSensitiveIdx = myBVHPrimIndexes.Value (theElemIdx);
SelectBasics_PickResult aResult; if (myEntities.FindKey (aSensitiveIdx)->Matches (theMgr, thePickResult))
if (myEntities.FindKey (aSensitiveIdx)->Matches (theMgr, aResult))
{ {
theMatchDepth = aResult.Depth();
return Standard_True; return Standard_True;
} }
@ -353,7 +346,7 @@ Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_Selectin
Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
const Standard_Integer theElemIdx) const Standard_Integer theElemIdx)
{ {
Standard_Real aDummy; SelectBasics_PickResult aDummy;
return overlapsElement(theMgr, theElemIdx, 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 //! Checks whether the entity with index theIdx overlaps the current selecting volume
virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, 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 //! Checks whether the entity with index theIdx is inside the current selecting volume
virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, 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, Standard_Boolean Select3D_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) SelectBasics_PickResult& thePickResult)
{ {
Standard_Real aDepth = RealLast(); if (!theMgr.Overlaps (myPoint, thePickResult))
Standard_Real aDistToCOG = RealLast();
if (!theMgr.Overlaps (myPoint, aDepth))
{ {
thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_False; return Standard_False;
} }
aDistToCOG = aDepth; thePickResult.SetDistToGeomCenter (thePickResult.Depth());
thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_True; 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_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) SelectBasics_PickResult& thePickResult)
{ {
if (mySegmentIndexes.IsNull()) if (mySegmentIndexes.IsNull())
return Standard_False; return Standard_False;
@ -231,7 +231,7 @@ Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_Selecting
gp_Pnt aPnt1 = myPolyg.Pnt3d (aSegmentIdx); gp_Pnt aPnt1 = myPolyg.Pnt3d (aSegmentIdx);
gp_Pnt aPnt2 = myPolyg.Pnt3d (aSegmentIdx + 1); 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 //! Checks whether the segment with index theIdx overlaps the current selecting volume
virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, 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 //! Checks whether the entity with index theIdx is inside the current selecting volume
virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,

View File

@ -928,15 +928,14 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
return Standard_True; return Standard_True;
} }
Standard_Real aDepth = RealLast(); SelectBasics_PickResult aPickResult;
bool isFailed = false; bool isFailed = false;
const bool toMatchAll = !theMgr.IsOverlapAllowed(); const bool toMatchAll = !theMgr.IsOverlapAllowed();
for (Standard_Integer aGroupIter = 0; aGroupIter < myBvhIndices.NbElements; ++aGroupIter) for (Standard_Integer aGroupIter = 0; aGroupIter < myBvhIndices.NbElements; ++aGroupIter)
{ {
const Standard_Integer anElemIdx = myBvhIndices.Index (aGroupIter); const Standard_Integer anElemIdx = myBvhIndices.Index (aGroupIter);
SelectBasics_PickResult aMatchResult;
Handle(Select3D_SensitivePrimitiveArray)& aChild = myGroups->ChangeValue (anElemIdx); Handle(Select3D_SensitivePrimitiveArray)& aChild = myGroups->ChangeValue (anElemIdx);
const bool isMatched = aChild->Matches (theMgr, aMatchResult); const bool isMatched = aChild->Matches (theMgr, aPickResult);
if (!myDetectedElemMap.IsNull()) if (!myDetectedElemMap.IsNull())
{ {
myDetectedElemMap->ChangeMap().Unite (aChild->myDetectedElemMap->Map()); myDetectedElemMap->ChangeMap().Unite (aChild->myDetectedElemMap->Map());
@ -959,20 +958,18 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
} }
else else
{ {
if (aDepth > aMatchResult.Depth()) if (thePickResult.Depth() > aPickResult.Depth())
{ {
myDetectedIdx = aGroupIter; myDetectedIdx = aGroupIter;
aDepth = aMatchResult.Depth(); thePickResult = aPickResult;
} }
} }
} }
if (isFailed) if (isFailed)
{ {
thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
return Standard_False; return Standard_False;
} }
thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(CenterOfGeometry()));
thePickResult = SelectBasics_PickResult (aDepth, theMgr.DistToGeometryCenter (CenterOfGeometry()));
return Standard_True; return Standard_True;
} }
@ -982,25 +979,23 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
// ======================================================================= // =======================================================================
Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) SelectBasics_PickResult& thePickResult)
{ {
const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx); const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx);
if (!myGroups.IsNull()) if (!myGroups.IsNull())
{ {
SelectBasics_PickResult aResult; if (myGroups->Value (anElemIdx)->Matches (theMgr, thePickResult))
if (myGroups->Value (anElemIdx)->Matches (theMgr, aResult))
{ {
theMatchDepth = aResult.Depth();
return Standard_True; return Standard_True;
} }
theMatchDepth = RealLast();
return Standard_False; return Standard_False;
} }
const Standard_Integer aPatchSize = myBvhIndices.PatchSize (theElemIdx); const Standard_Integer aPatchSize = myBvhIndices.PatchSize (theElemIdx);
Select3D_BndBox3d aBox; Select3D_BndBox3d aBox;
Standard_Boolean aResult = Standard_False; Standard_Boolean aResult = Standard_False;
Standard_Real aMinDepth = RealLast(); SelectBasics_PickResult aPickResult;
switch (myPrimType) switch (myPrimType)
{ {
case Graphic3d_TOPA_POINTS: case Graphic3d_TOPA_POINTS:
@ -1021,16 +1016,15 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
aPoint = vecToPnt (getPosVec2 (aPointIndex)); aPoint = vecToPnt (getPosVec2 (aPointIndex));
} }
Standard_Real aCurrentDepth = RealLast();
if (myToDetectNode if (myToDetectNode
|| myToDetectElem) || myToDetectElem)
{ {
if (theMgr.Overlaps (aPoint, aCurrentDepth)) if (theMgr.Overlaps (aPoint, aPickResult))
{ {
if (aCurrentDepth <= myMinDepthNode) if (aPickResult.Depth() <= myMinDepthNode)
{ {
myDetectedElem = myDetectedNode = aPointIndex; myDetectedElem = myDetectedNode = aPointIndex;
myMinDepthElem = myMinDepthNode = aCurrentDepth; myMinDepthElem = myMinDepthNode = aPickResult.Depth();
} }
if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point) if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
{ {
@ -1046,7 +1040,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
aResult = Standard_True; aResult = Standard_True;
} }
} }
aMinDepth = Min (aMinDepth, aCurrentDepth); thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
} }
break; break;
} }
@ -1072,15 +1066,14 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
aPnts[2] = vecToPnt (getPosVec2 (aTriNodes[2])); aPnts[2] = vecToPnt (getPosVec2 (aTriNodes[2]));
} }
Standard_Real aCurrentDepth = RealLast();
if (myToDetectElem) 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; myDetectedElem = aTriIndex;
myMinDepthElem = aCurrentDepth; myMinDepthElem = aPickResult.Depth();
} }
aResult = Standard_True; aResult = Standard_True;
} }
@ -1094,12 +1087,12 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
{ {
for (int aNodeIter = 0; aNodeIter < 3; ++aNodeIter) 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]; myDetectedNode = aTriNodes[aNodeIter];
myMinDepthNode = aCurrentDepth; myMinDepthNode = aPickResult.Depth();
} }
if (!myDetectedNodeMap.IsNull() if (!myDetectedNodeMap.IsNull()
&& theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point) && theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
@ -1116,19 +1109,19 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
{ {
int aNode1 = aNodeIter == 0 ? 2 : (aNodeIter - 1); int aNode1 = aNodeIter == 0 ? 2 : (aNodeIter - 1);
int aNode2 = aNodeIter; 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]; myDetectedEdgeNode1 = aTriNodes[aNode1];
myDetectedEdgeNode2 = aTriNodes[aNode2]; myDetectedEdgeNode2 = aTriNodes[aNode2];
myMinDepthEdge = aCurrentDepth; myMinDepthEdge = aPickResult.Depth();
} }
aResult = Standard_True; aResult = Standard_True;
} }
} }
} }
aMinDepth = Min (aMinDepth, aCurrentDepth); thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
} }
break; break;
} }
@ -1138,7 +1131,6 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::overlapsElement (SelectBasics
} }
} }
theMatchDepth = aMinDepth;
return aResult; return aResult;
} }
@ -1161,7 +1153,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::elementIsInside (SelectBasics
const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx); const Standard_Integer anElemIdx = myBvhIndices.Index (theElemIdx);
if (!myGroups.IsNull()) if (!myGroups.IsNull())
{ {
Standard_Real aDummy; SelectBasics_PickResult aDummy;
return overlapsElement (theMgr, theElemIdx, 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 //! Checks whether the element with index theIdx overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, 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 //! 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_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, Standard_Boolean Select3D_SensitiveSegment::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) SelectBasics_PickResult& thePickResult)
{ {
thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
Standard_Real aDepth;
if (!theMgr.IsOverlapAllowed()) // check for inclusion 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; return Standard_False;
} }
thePickResult = SelectBasics_PickResult (aDepth, thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(CenterOfGeometry()));
theMgr.DistToGeometryCenter (CenterOfGeometry()));
return Standard_True; return Standard_True;
} }

View File

@ -76,7 +76,6 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
{ {
myDetectedIdx = -1; myDetectedIdx = -1;
const BVH_Tree<Standard_Real, 3, BVH_BinaryTree>* aBVH = myContent.GetBVH().get(); 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), if (myContent.Size() < 1 || !theMgr.Overlaps (aBVH->MinPoint (0),
aBVH->MaxPoint (0))) aBVH->MaxPoint (0)))
{ {
@ -88,7 +87,7 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
Standard_Integer aHead = -1; Standard_Integer aHead = -1;
Standard_Integer aMatchesNb = -1; Standard_Integer aMatchesNb = -1;
Standard_Real aMinDepth = RealLast(); SelectBasics_PickResult aPickResult;
for (;;) for (;;)
{ {
const BVH_Vec4i& aData = aBVH->NodeInfoBuffer()[aNode]; const BVH_Vec4i& aData = aBVH->NodeInfoBuffer()[aNode];
@ -150,16 +149,14 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
} }
else // overlap test else // overlap test
{ {
Standard_Real aCurrentDepth = aMinDepth; if (!overlapsElement (theMgr, anElemIdx, aPickResult))
if (!overlapsElement (theMgr, anElemIdx, aCurrentDepth))
{ {
continue; continue;
} }
if (aMinDepth > aCurrentDepth) if (thePickResult.Depth() > aPickResult.Depth())
{ {
aMinDepth = aCurrentDepth; thePickResult = aPickResult;
myDetectedIdx = anElemIdx; myDetectedIdx = anElemIdx;
} }
@ -176,7 +173,7 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
if (aMatchesNb != -1) if (aMatchesNb != -1)
{ {
thePickResult = SelectBasics_PickResult (aMinDepth, distanceToCOG (theMgr)); thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
} }
return !theMgr.IsOverlapAllowed() || aMatchesNb != -1; 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 //! @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, virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) = 0; SelectBasics_PickResult& thePickResult) = 0;
//! Checks whether the entity with index theIdx is inside the current selecting volume //! Checks whether the entity with index theIdx is inside the current selecting volume
virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, 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, Standard_Boolean Select3D_SensitiveTriangle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) SelectBasics_PickResult& thePickResult)
{ {
Standard_Real aDepth = RealLast();
Standard_Real aDistToCOG = RealLast();
if (!theMgr.IsOverlapAllowed()) if (!theMgr.IsOverlapAllowed())
{ {
return theMgr.Overlaps (myPoints[0]) return theMgr.Overlaps (myPoints[0])
@ -57,14 +55,12 @@ Standard_Boolean Select3D_SensitiveTriangle::Matches (SelectBasics_SelectingVolu
&& theMgr.Overlaps (myPoints[2]); && 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; return Standard_False;
} }
aDistToCOG = theMgr.DistToGeometryCenter (myCentroid); thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCentroid));
thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
return Standard_True; return Standard_True;
} }

View File

@ -198,9 +198,9 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
Standard_Integer aNode1, aNode2, aNode3; Standard_Integer aNode1, aNode2, aNode3;
myTriangul->Triangles() (aPrimIdx + 1).Get (aNode1, aNode2, aNode3); myTriangul->Triangles() (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1); const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2); const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3); const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
aMinPnt = SelectMgr_Vec3 (Min (aPnt1.X(), Min (aPnt2.X(), aPnt3.X())), aMinPnt = SelectMgr_Vec3 (Min (aPnt1.X(), Min (aPnt2.X(), aPnt3.X())),
Min (aPnt1.Y(), Min (aPnt2.Y(), aPnt3.Y())), 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 aNodeIdx1 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx);
Standard_Integer aNodeIdx2 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx + 1); Standard_Integer aNodeIdx2 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx + 1);
gp_Pnt aNode1 = myTriangul->Nodes().Value (aNodeIdx1); const gp_Pnt& aNode1 = myTriangul->Nodes().Value (aNodeIdx1);
gp_Pnt aNode2 = myTriangul->Nodes().Value (aNodeIdx2); const gp_Pnt& aNode2 = myTriangul->Nodes().Value (aNodeIdx2);
aMinPnt = SelectMgr_Vec3 (Min (aNode1.X(), aNode2.X()), aMinPnt = SelectMgr_Vec3 (Min (aNode1.X(), aNode2.X()),
Min (aNode1.Y(), aNode2.Y()), Min (aNode1.Y(), aNode2.Y()),
@ -236,9 +236,8 @@ Standard_Real Select3D_SensitiveTriangulation::Center (const Standard_Integer th
const Standard_Integer theAxis) const const Standard_Integer theAxis) const
{ {
const Select3D_BndBox3d& aBox = Box (theIdx); const Select3D_BndBox3d& aBox = Box (theIdx);
SelectMgr_Vec3 aCenter = (aBox.CornerMin () + aBox.CornerMax ()) * 0.5; const SelectMgr_Vec3 aCenter = (aBox.CornerMin () + aBox.CornerMax ()) * 0.5;
return aCenter[theAxis];
return theAxis == 0 ? aCenter.x() : (theAxis == 1 ? aCenter.y() : aCenter.z());
} }
//======================================================================= //=======================================================================
@ -262,7 +261,7 @@ void Select3D_SensitiveTriangulation::Swap (const Standard_Integer theIdx1,
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) SelectBasics_PickResult& thePickResult)
{ {
const Standard_Integer& aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx); 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 aSegmStartIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 1);
Standard_Integer aSegmEndIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 2); Standard_Integer aSegmEndIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 2);
Handle(TColgp_HArray1OfPnt) anEdgePnts = new TColgp_HArray1OfPnt (1, 2);
gp_Pnt aSegmStart = myTriangul->Nodes().Value (aSegmStartIdx); const gp_Pnt anEdgePnts[2] =
gp_Pnt aSegmEnd = myTriangul->Nodes().Value (aSegmEndIdx); {
anEdgePnts->SetValue (1, aSegmStart); myTriangul->Nodes().Value (aSegmStartIdx),
anEdgePnts->SetValue (2, aSegmEnd); myTriangul->Nodes().Value (aSegmEndIdx)
Standard_Boolean isMatched = theMgr.Overlaps (anEdgePnts, Select3D_TOS_BOUNDARY, theMatchDepth); };
anEdgePnts.Nullify(); TColgp_Array1OfPnt anEdgePntsArr (anEdgePnts[0], 1, 2);
Standard_Boolean isMatched = theMgr.Overlaps (anEdgePntsArr, Select3D_TOS_BOUNDARY, thePickResult);
return isMatched; return isMatched;
} }
else else
@ -284,10 +284,10 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles(); const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles();
Standard_Integer aNode1, aNode2, aNode3; Standard_Integer aNode1, aNode2, aNode3;
aTriangles (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3); aTriangles (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1); const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2); const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3); const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
return theMgr.Overlaps (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, theMatchDepth); 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) if (mySensType == Select3D_TOS_BOUNDARY)
{ {
gp_Pnt aSegmPnt1 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 1)); const 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& aSegmPnt2 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
return theMgr.Overlaps (aSegmPnt1) && theMgr.Overlaps (aSegmPnt2); return theMgr.Overlaps (aSegmPnt1) && theMgr.Overlaps (aSegmPnt2);
} }
else else
{ {
Standard_Integer aNode1; Standard_Integer aNode1, aNode2, aNode3;
Standard_Integer aNode2;
Standard_Integer aNode3;
myTriangul->Triangles() (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3); myTriangul->Triangles() (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
gp_Pnt aPnt1 = myTriangul->Nodes().Value (aNode1); const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
gp_Pnt aPnt2 = myTriangul->Nodes().Value (aNode2); const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
gp_Pnt aPnt3 = myTriangul->Nodes().Value (aNode3); const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
return theMgr.Overlaps (aPnt1) return theMgr.Overlaps (aPnt1)
&& theMgr.Overlaps (aPnt2) && theMgr.Overlaps (aPnt2)
&& theMgr.Overlaps (aPnt3); && theMgr.Overlaps (aPnt3);

View File

@ -104,7 +104,7 @@ private:
//! Checks whether the element with index theIdx overlaps the current selecting volume //! Checks whether the element with index theIdx overlaps the current selecting volume
virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, 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 //! 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; 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_Boolean Select3D_SensitiveWire::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) SelectBasics_PickResult& thePickResult)
{ {
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (theElemIdx); const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (theElemIdx);
const Handle(SelectBasics_SensitiveEntity)& aSeg = myEntities.Value (aSensitiveIdx); const Handle(SelectBasics_SensitiveEntity)& aSeg = myEntities.Value (aSensitiveIdx);
SelectBasics_PickResult aMatchResult; return aSeg->Matches (theMgr, thePickResult);
if (aSeg->Matches (theMgr, aMatchResult))
{
theMatchDepth = aMatchResult.Depth();
return Standard_True;
}
return Standard_False;
} }
// ======================================================================= // =======================================================================

View File

@ -75,7 +75,7 @@ protected:
//! Checks whether the entity with index theIdx overlaps the current selecting volume //! Checks whether the entity with index theIdx overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx, 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 //! Checks whether the entity with index theIdx is inside the current selecting volume
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,

View File

@ -19,37 +19,71 @@
#include <Standard.hxx> #include <Standard.hxx>
#include <NCollection_Vec4.hxx> #include <NCollection_Vec4.hxx>
//! This structure provides unified access to the results of //! This structure provides unified access to the results of Matches() method in all sensitive entities,
//! 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 struct SelectBasics_PickResult
{ {
public: 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() SelectBasics_PickResult()
: myDepth (DBL_MAX), : myObjPickedPnt (RealLast(), 0.0, 0.0),
myDistToCenter (DBL_MAX) {} myDepth (RealLast()),
myDistToCenter (RealLast()) {}
SelectBasics_PickResult (const Standard_Real theDepth, //! Constructor with initialization.
const Standard_Real theDistToCenter) SelectBasics_PickResult (Standard_Real theDepth,
: myDepth (theDepth), Standard_Real theDistToCenter,
const gp_Pnt& theObjPickedPnt)
: myObjPickedPnt (theObjPickedPnt),
myDepth (theDepth),
myDistToCenter (theDistToCenter) {} myDistToCenter (theDistToCenter) {}
public: public:
inline Standard_Real Depth() const
//! Return TRUE if result was been defined.
Standard_Boolean IsValid() const { return myDepth != RealLast(); }
//! Reset depth value.
void Invalidate()
{ {
return myDepth; myDepth = RealLast();
myObjPickedPnt = gp_Pnt (RealLast(), 0.0, 0.0);
} }
inline Standard_Real DistToGeomCenter() const //! Return depth along picking ray.
{ Standard_Real Depth() const { return myDepth; }
return myDistToCenter;
} //! 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: private:
//!< Depth to detected point gp_Pnt myObjPickedPnt; //!< User-picked selection point onto object
Standard_Real myDepth; Standard_Real myDepth; //!< Depth to detected point
//!< Distance from 3d projection user-picked selection point to entity's geometry center Standard_Real myDistToCenter; //!< Distance from 3d projection user-picked selection point to entity's geometry center
Standard_Real myDistToCenter;
}; };
#endif // _SelectBasics_PickResult_HeaderFile #endif // _SelectBasics_PickResult_HeaderFile

View File

@ -19,6 +19,7 @@
#include <BVH_Box.hxx> #include <BVH_Box.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#include <TColgp_HArray1OfPnt.hxx> #include <TColgp_HArray1OfPnt.hxx>
#include <SelectBasics_PickResult.hxx>
class Bnd_Box; class Bnd_Box;
class gp_Pnt; class gp_Pnt;
@ -45,7 +46,7 @@ public:
//! Returns true if selecting volume is overlapped by box theBox //! Returns true if selecting volume is overlapped by box theBox
virtual Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin, virtual Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin,
const NCollection_Vec3<Standard_Real>& theBoxMax, 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 //! Returns true if selecting volume is overlapped by axis-aligned bounding box with minimum
//! corner at point theMinPt and maximum at point theMaxPt //! corner at point theMinPt and maximum at point theMaxPt
@ -55,7 +56,7 @@ public:
//! Returns true if selecting volume is overlapped by point thePnt //! Returns true if selecting volume is overlapped by point thePnt
virtual Standard_Boolean Overlaps (const gp_Pnt& 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. //! Returns true if selecting volume is overlapped by point thePnt.
//! Does not perform depth calculation, so this method is defined as //! Does not perform depth calculation, so this method is defined as
@ -66,19 +67,19 @@ public:
//! are stored in theArrayOfPts, taking into account sensitivity type theSensType //! are stored in theArrayOfPts, taking into account sensitivity type theSensType
virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
Standard_Integer theSensType, Standard_Integer theSensType,
Standard_Real& theDepth) = 0; SelectBasics_PickResult& thePickResult) = 0;
//! Returns true if selecting volume is overlapped by planar convex polygon, which points //! Returns true if selecting volume is overlapped by planar convex polygon, which points
//! are stored in theArrayOfPts, taking into account sensitivity type theSensType //! are stored in theArrayOfPts, taking into account sensitivity type theSensType
virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts, virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
Standard_Integer theSensType, 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 //! Returns true if selecting volume is overlapped by line segment with start point at thePt1
//! and end point at thePt2 //! and end point at thePt2
virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1, virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
const gp_Pnt& thePt2, const gp_Pnt& thePt2,
Standard_Real& theDepth) = 0; SelectBasics_PickResult& thePickResult) = 0;
//! Returns true if selecting volume is overlapped by triangle with vertices thePt1, //! Returns true if selecting volume is overlapped by triangle with vertices thePt1,
//! thePt2 and thePt3, taking into account sensitivity type theSensType //! thePt2 and thePt3, taking into account sensitivity type theSensType
@ -86,7 +87,7 @@ public:
const gp_Pnt& thePt2, const gp_Pnt& thePt2,
const gp_Pnt& thePt3, const gp_Pnt& thePt3,
Standard_Integer theSensType, Standard_Integer theSensType,
Standard_Real& theDepth) = 0; SelectBasics_PickResult& thePickResult) = 0;
//! Calculates distance from 3d projection of user-defined selection point //! Calculates distance from 3d projection of user-defined selection point
//! to the given point theCOG //! to the given point theCOG

View File

@ -146,7 +146,7 @@ void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)&
//======================================================================= //=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/, Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
const SelectMgr_Vec3& /*theBoxMax*/, const SelectMgr_Vec3& /*theBoxMax*/,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& /*thePickResult*/)
{ {
return Standard_False; 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 // purpose : Intersection test between defined volume and given point
//======================================================================= //=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/, Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& )
{ {
return Standard_False; 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*/, Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
Select3D_TypeOfSensitivity /*theSensType*/, Select3D_TypeOfSensitivity /*theSensType*/,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& )
{ {
return Standard_False; return Standard_False;
} }
@ -206,7 +206,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
const gp_Pnt& /*thePt2*/, const gp_Pnt& /*thePt2*/,
const gp_Pnt& /*thePt3*/, const gp_Pnt& /*thePt3*/,
Select3D_TypeOfSensitivity /*theSensType*/, Select3D_TypeOfSensitivity /*theSensType*/,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& )
{ {
return Standard_False; 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*/, Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
const gp_Pnt& /*thePnt2*/, const gp_Pnt& /*thePnt2*/,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& )
{ {
return Standard_False; return Standard_False;
} }

View File

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

View File

@ -24,7 +24,7 @@
// ======================================================================= // =======================================================================
void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegPnt1, void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegPnt1,
const gp_Pnt& theSegPnt2, const gp_Pnt& theSegPnt2,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
gp_XYZ anU = theSegPnt2.XYZ() - theSegPnt1.XYZ(); gp_XYZ anU = theSegPnt2.XYZ() - theSegPnt1.XYZ();
gp_XYZ aV = myViewRayDir.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); aTc = (Abs (aTd) < gp::Resolution() ? 0.0 : aTn / aTd);
gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTc; const gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTc;
theDepth = myNearPickedPnt.Distance (aClosestPnt) * myScale; 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 // function : segmentPlaneIntersection
// purpose : // purpose :
// ======================================================================= // =======================================================================
void SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePlane, bool SelectMgr_RectangularFrustum::segmentPlaneIntersection (const gp_Vec& thePlane,
const gp_Pnt& thePntOnPlane, const gp_Pnt& thePntOnPlane,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
gp_XYZ anU = myViewRayDir.XYZ(); gp_XYZ anU = myViewRayDir.XYZ();
gp_XYZ aW = myNearPickedPnt.XYZ() - thePntOnPlane.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()) if (Abs (aN) < Precision::Angular())
{ {
theDepth = DBL_MAX; thePickResult.Invalidate();
return; return false;
} }
else else
{ {
theDepth = DBL_MAX; thePickResult.Invalidate();
return; return false;
} }
} }
Standard_Real aParam = aN / aD; Standard_Real aParam = aN / aD;
if (aParam < 0.0 || aParam > 1.0) if (aParam < 0.0 || aParam > 1.0)
{ {
theDepth = DBL_MAX; thePickResult.Invalidate();
return; return false;
} }
gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + anU * aParam; gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + anU * aParam;
theDepth = myNearPickedPnt.Distance (aClosestPnt) * myScale; thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale);
return true;
} }
namespace namespace
@ -425,7 +441,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
// ======================================================================= // =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& theBoxMin, Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax, const SelectMgr_Vec3& theBoxMax,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (!hasOverlap (theBoxMin, theBoxMax)) if (!hasOverlap (theBoxMin, theBoxMax))
return Standard_False; 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.SetY (Max (Min (myNearPickedPnt.Y(), theBoxMax.y()), theBoxMin.y()));
aNearestPnt.SetZ (Max (Min (myNearPickedPnt.Z(), theBoxMax.z()), theBoxMin.z())); 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 // purpose : Intersection test between defined volume and given point
// ======================================================================= // =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt, Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (!hasOverlap (thePnt)) if (!hasOverlap (thePnt))
return Standard_False; return Standard_False;
@ -454,9 +470,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
gp_Pnt aDetectedPnt = gp_Pnt aDetectedPnt =
myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * (aV.Dot (myViewRayDir.XYZ()) / myViewRayDir.Dot (myViewRayDir)); 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, Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2, const gp_Pnt& thePnt2,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
theDepth = -DBL_MAX;
if (!hasOverlap (thePnt1, thePnt2)) if (!hasOverlap (thePnt1, thePnt2))
return Standard_False; 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, Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (theSensType == Select3D_TOS_BOUNDARY) if (theSensType == Select3D_TOS_BOUNDARY)
{ {
Standard_Integer aMatchingSegmentsNb = -1; Standard_Integer aMatchingSegmentsNb = -1;
theDepth = DBL_MAX; SelectBasics_PickResult aPickResult;
thePickResult.Invalidate();
const Standard_Integer aLower = theArrayOfPnts.Lower(); const Standard_Integer aLower = theArrayOfPnts.Lower();
const Standard_Integer anUpper = theArrayOfPnts.Upper(); const Standard_Integer anUpper = theArrayOfPnts.Upper();
for (Standard_Integer aPntIter = aLower; aPntIter <= anUpper; ++aPntIter) for (Standard_Integer aPntIter = aLower; aPntIter <= anUpper; ++aPntIter)
@ -509,9 +526,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
if (hasOverlap (aStartPnt, aEndPnt)) if (hasOverlap (aStartPnt, aEndPnt))
{ {
aMatchingSegmentsNb++; aMatchingSegmentsNb++;
Standard_Real aSegmentDepth = RealLast(); segmentSegmentDistance (aStartPnt, aEndPnt, aPickResult);
segmentSegmentDistance (aStartPnt, aEndPnt, aSegmentDepth); thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
theDepth = Min (theDepth, aSegmentDepth);
} }
} }
@ -521,15 +537,16 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
else if (theSensType == Select3D_TOS_INTERIOR) else if (theSensType == Select3D_TOS_INTERIOR)
{ {
gp_Vec aPolyNorm (gp_XYZ (RealLast(), RealLast(), RealLast())); gp_Vec aPolyNorm (gp_XYZ (RealLast(), RealLast(), RealLast()));
if (!hasOverlap (theArrayOfPnts, aPolyNorm)) if (!hasOverlap (theArrayOfPnts, aPolyNorm)
|| !segmentPlaneIntersection (aPolyNorm,
theArrayOfPnts.First(),
thePickResult))
{
return Standard_False; 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& thePnt2,
const gp_Pnt& thePnt3, const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (theSensType == Select3D_TOS_BOUNDARY) if (theSensType == Select3D_TOS_BOUNDARY)
{ {
const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 }; const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 };
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 4); 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) 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. // handle degenerated triangles: in this case, there is no possible way to detect overlap correctly.
if (aTriangleNormal.SquareMagnitude() < gp::Resolution()) if (aTriangleNormal.SquareMagnitude() < gp::Resolution())
{ {
theDepth = std::numeric_limits<Standard_Real>::max();
return Standard_False; return Standard_False;
} }
// handle the case when triangle normal and selecting frustum direction are orthogonal: for this case, overlap // 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. // 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(); const gp_XYZ aDiff = myNearPickedPnt.XYZ() - thePnt1.XYZ();
theDepth = aTriangleNormal.Dot (aDiff) * myScale; thePickResult.SetDepth (aTriangleNormal.Dot (aDiff) * myScale);
thePickResult.SetPickedPoint (thePnt1);
return isViewClippingOk (theDepth); return isViewClippingOk (thePickResult);
} }
gp_XYZ anEdge = (thePnt1.XYZ() - myNearPickedPnt.XYZ()) * (1.0 / anAlpha); 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 anU = aVec.Dot (aTrEdges[2]);
Standard_Real aV = aVec.Dot (aTrEdges[0]); 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) if (isInterior)
{ {
gp_Pnt aDetectedPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTime; thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
theDepth = myNearPickedPnt.Distance (aDetectedPnt) * myScale; thePickResult.SetPickedPoint (aPtOnPlane);
return isViewClippingOk (thePickResult);
return isViewClippingOk (theDepth);
} }
gp_Pnt aPnts[3] = {thePnt1, thePnt2, thePnt3}; gp_Pnt aPnts[3] = {thePnt1, thePnt2, thePnt3};
Standard_Real aMinDist = RealLast(); Standard_Real aMinDist = RealLast();
Standard_Integer aNearestEdgeIdx = -1; Standard_Integer aNearestEdgeIdx = -1;
gp_Pnt aPtOnPlane = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aTime;
for (Standard_Integer anEdgeIdx = 0; anEdgeIdx < 3; ++anEdgeIdx) for (Standard_Integer anEdgeIdx = 0; anEdgeIdx < 3; ++anEdgeIdx)
{ {
gp_XYZ aW = aPtOnPlane.XYZ() - aPnts[anEdgeIdx].XYZ(); gp_XYZ aW = aPtOnPlane.XYZ() - aPnts[anEdgeIdx].XYZ();
@ -614,10 +628,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
aNearestEdgeIdx = anEdgeIdx; 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 // function : isViewClippingOk
// purpose : // purpose :
// ======================================================================= // =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const Standard_Real theDepth) const Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const SelectBasics_PickResult& thePickResult) const
{ {
return !myIsViewClipEnabled 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 //! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax, 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 //! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt //! with minimum corner at point theMinPt and maximum at point theMaxPt
@ -69,7 +69,7 @@ public:
//! Intersection test between defined volume and given point //! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, 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 //! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE; 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 //! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE; SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum //! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2, 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 //! SAT intersection test between defined volume and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices //! be considered of interior part or boundary line defined by triangle vertices
@ -93,7 +93,7 @@ public:
const gp_Pnt& thePnt2, const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3, const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE; SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked //! Measures distance between 3d projection of user-picked
//! screen point and given point theCOG //! screen point and given point theCOG
@ -141,18 +141,18 @@ protected:
Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1, Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1,
const gp_Pnt& theSegPnt2, 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, const gp_Pnt& thePntOnPlane,
Standard_Real& theDepth); SelectBasics_PickResult& thePickResult);
//! Computes valid depth range for the given clipping planes //! Computes valid depth range for the given clipping planes
Standard_EXPORT void computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes, Standard_EXPORT void computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
SelectMgr_ViewClipRange& theRange); SelectMgr_ViewClipRange& theRange);
//! Returns false if theDepth must be clipped by current view clip range //! 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: private:

View File

@ -236,12 +236,12 @@ void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const TColgp_Array1
//======================================================================= //=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec3& theBoxMin, Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax, const SelectMgr_Vec3& theBoxMax,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (myActiveSelectionType == Unknown) if (myActiveSelectionType == Unknown)
return Standard_False; 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 // purpose : Intersection test between defined volume and given point
//======================================================================= //=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePnt, Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (myActiveSelectionType == Unknown) if (myActiveSelectionType == Unknown)
return Standard_False; return Standard_False;
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt, 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_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
Standard_Integer theSensType, Standard_Integer theSensType,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (myActiveSelectionType == Unknown) if (myActiveSelectionType == Unknown)
return Standard_False; return Standard_False;
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(), return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(),
(Select3D_TypeOfSensitivity)theSensType, (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_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Standard_Integer theSensType, Standard_Integer theSensType,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (myActiveSelectionType == Unknown) if (myActiveSelectionType == Unknown)
return Standard_False; return Standard_False;
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts, return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts,
(Select3D_TypeOfSensitivity)theSensType, (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, Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt1,
const gp_Pnt& thePt2, const gp_Pnt& thePt2,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (myActiveSelectionType == Unknown) if (myActiveSelectionType == Unknown)
return Standard_False; 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& thePt2,
const gp_Pnt& thePt3, const gp_Pnt& thePt3,
Standard_Integer theSensType, Standard_Integer theSensType,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (myActiveSelectionType == Unknown) if (myActiveSelectionType == Unknown)
return Standard_False; return Standard_False;
@ -356,7 +356,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
thePt2, thePt2,
thePt3, thePt3,
(Select3D_TypeOfSensitivity)theSensType, (Select3D_TypeOfSensitivity)theSensType,
theDepth); thePickResult);
} }
//======================================================================= //=======================================================================

View File

@ -105,8 +105,8 @@ public:
//! SAT intersection test between defined volume and given axis-aligned box //! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax, 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 //! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt //! with minimum corner at point theMinPt and maximum at point theMaxPt
@ -116,7 +116,7 @@ public:
//! Intersection test between defined volume and given point //! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, 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 //! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE; 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 //! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
Standard_Integer theSensType, 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, //! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or //! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type //! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts, Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
Standard_Integer theSensType, Standard_Integer theSensType,
Standard_Real& theDepth) Standard_OVERRIDE; SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum //! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2, 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 //! SAT intersection test between defined volume and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices //! be considered of interior part or boundary line defined by triangle vertices
@ -147,7 +147,7 @@ public:
const gp_Pnt& thePnt2, const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3, const gp_Pnt& thePnt3,
Standard_Integer theSensType, Standard_Integer theSensType,
Standard_Real& theDepth) Standard_OVERRIDE; SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked //! 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, Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt, const SelectMgr_Vec3& theMaxPt,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& /*thePickResult*/)
{ {
return hasOverlap (theMinPt, theMaxPt); 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 // purpose : Intersection test between defined volume and given point
// ======================================================================= // =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt, Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& /*thePickResult*/)
{ {
return hasOverlap (thePnt); 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, Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& /*thePickResult*/)
{ {
if (theSensType == Select3D_TOS_BOUNDARY) 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, Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2, const gp_Pnt& thePnt2,
Standard_Real& /*theDepth*/) SelectBasics_PickResult& /*thePickResult*/)
{ {
return hasOverlap (thePnt1, thePnt2); return hasOverlap (thePnt1, thePnt2);
} }
@ -253,13 +253,13 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2, const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3, const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
if (theSensType == Select3D_TOS_BOUNDARY) if (theSensType == Select3D_TOS_BOUNDARY)
{ {
const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 }; const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 };
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 3); 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) else if (theSensType == Select3D_TOS_INTERIOR)
{ {

View File

@ -48,7 +48,7 @@ public:
//! SAT intersection test between defined volume and given axis-aligned box //! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt, 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 //! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt //! with minimum corner at point theMinPt and maximum at point theMaxPt
@ -58,19 +58,19 @@ public:
//! Intersection test between defined volume and given point //! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, 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, //! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or //! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type //! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE; SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum //! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2, 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 //! SAT intersection test between defined volume and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices //! be considered of interior part or boundary line defined by triangle vertices
@ -79,7 +79,7 @@ public:
const gp_Pnt& thePnt2, const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3, const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE; SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Nullifies the handle to corresponding builder instance to prevent memory leaks //! Nullifies the handle to corresponding builder instance to prevent memory leaks
Standard_EXPORT void Clear(); 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, Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt, const SelectMgr_Vec3& theMaxPnt,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) 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; return Standard_True;
} }
@ -160,11 +160,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3&
// purpose : // purpose :
// ======================================================================= // =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt, Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{ {
if (anIter.Value()->Overlaps (thePnt, theDepth)) if (anIter.Value()->Overlaps (thePnt, thePickResult))
return Standard_True; 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, Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) 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; return Standard_True;
} }
@ -194,11 +194,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1Of
// ======================================================================= // =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1, Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2, const gp_Pnt& thePnt2,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) 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; return Standard_True;
} }
@ -213,11 +213,11 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1
const gp_Pnt& thePnt2, const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3, const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType, Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) SelectBasics_PickResult& thePickResult)
{ {
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next()) 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; return Standard_True;
} }

View File

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

View File

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

View File

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

50
tests/bugs/vis/bug29938 Normal file
View File

@ -0,0 +1,50 @@
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)" }
}