mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0027180: Visualization - improve selection logic of MeshVS_Mesh
MeshVS_Mesh selection logic in MeshVS_SMF_Mesh mode (entire mesh) has been optimized. MeshVS_Mesh::ComputeSelection() now creates single sensitive entity MeshVS_CommonSensitiveEntity (new class) instead of small sensitive entity on each element. MeshVS_SensitiveQuad (new class) and Select3D_SensitiveTriangle are used instead of Select3D_SensitiveFace for local selection to reduce memory consumption when possible.
This commit is contained in:
@@ -176,7 +176,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/)
|
||||
// may be considered of interior part or boundary line defined
|
||||
// by segments depending on given sensitivity type
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& /*theArrayOfPnts*/,
|
||||
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
|
||||
Select3D_TypeOfSensitivity /*theSensType*/,
|
||||
Standard_Real& /*theDepth*/)
|
||||
{
|
||||
|
@@ -129,7 +129,7 @@ public:
|
||||
//! SAT intersection test between defined volume and given ordered set of points,
|
||||
//! representing line segments. The test may be considered of interior part or
|
||||
//! boundary line defined by segments depending on given sensitivity type
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
Standard_Real& theDepth);
|
||||
|
||||
|
@@ -76,7 +76,7 @@ protected:
|
||||
const gp_Pnt& thePnt2);
|
||||
|
||||
//! SAT intersection test between frustum given and planar convex polygon represented as ordered point set
|
||||
Standard_EXPORT Standard_Boolean hasOverlap (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
|
||||
Standard_EXPORT Standard_Boolean hasOverlap (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
gp_Vec& theNormal);
|
||||
|
||||
//! SAT intersection test between defined volume and given triangle
|
||||
|
@@ -308,15 +308,15 @@ Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const gp_Pnt& theStartPnt,
|
||||
// polygon represented as ordered point set
|
||||
// =======================================================================
|
||||
template <int N>
|
||||
Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
|
||||
Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
gp_Vec& theNormal)
|
||||
{
|
||||
Standard_Integer aStartIdx = theArrayOfPnts->Lower();
|
||||
Standard_Integer anEndIdx = theArrayOfPnts->Upper();
|
||||
Standard_Integer aStartIdx = theArrayOfPnts.Lower();
|
||||
Standard_Integer anEndIdx = theArrayOfPnts.Upper();
|
||||
|
||||
const gp_XYZ& aPnt1 = theArrayOfPnts->Value (aStartIdx).XYZ();
|
||||
const gp_XYZ& aPnt2 = theArrayOfPnts->Value (aStartIdx + 1).XYZ();
|
||||
const gp_XYZ& aPnt3 = theArrayOfPnts->Value (aStartIdx + 2).XYZ();
|
||||
const gp_XYZ& aPnt1 = theArrayOfPnts.Value (aStartIdx).XYZ();
|
||||
const gp_XYZ& aPnt2 = theArrayOfPnts.Value (aStartIdx + 1).XYZ();
|
||||
const gp_XYZ& aPnt3 = theArrayOfPnts.Value (aStartIdx + 2).XYZ();
|
||||
const gp_XYZ aVec1 = aPnt1 - aPnt2;
|
||||
const gp_XYZ aVec2 = aPnt3 - aPnt2;
|
||||
theNormal = aVec2.Crossed (aVec1);
|
||||
@@ -347,7 +347,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const Handle(TColgp_HArray1Of
|
||||
const gp_XYZ& aPlane = myPlanes[aPlaneIdx].XYZ();
|
||||
for (Standard_Integer aPntIter = aStartIdx; aPntIter <= anEndIdx; ++aPntIter)
|
||||
{
|
||||
Standard_Real aProjection = aPlane.Dot (theArrayOfPnts->Value (aPntIter).XYZ());
|
||||
Standard_Real aProjection = aPlane.Dot (theArrayOfPnts.Value (aPntIter).XYZ());
|
||||
aMaxPolyg = Max (aMaxPolyg, aProjection);
|
||||
aMinPolyg = Min (aMinPolyg, aProjection);
|
||||
}
|
||||
@@ -361,10 +361,10 @@ Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const Handle(TColgp_HArray1Of
|
||||
}
|
||||
|
||||
Standard_Integer aDirectionsNb = myIsOrthographic ? 4 : 6;
|
||||
for (Standard_Integer aPntsIter = 0, aLastIdx = anEndIdx - aStartIdx, aLen = theArrayOfPnts->Length(); aPntsIter <= aLastIdx; ++aPntsIter)
|
||||
for (Standard_Integer aPntsIter = 0, aLastIdx = anEndIdx - aStartIdx, aLen = theArrayOfPnts.Length(); aPntsIter <= aLastIdx; ++aPntsIter)
|
||||
{
|
||||
const gp_XYZ aSegmDir = theArrayOfPnts->Value ((aPntsIter + 1) % aLen + aStartIdx).XYZ()
|
||||
- theArrayOfPnts->Value (aPntsIter + aStartIdx).XYZ();
|
||||
const gp_XYZ aSegmDir = theArrayOfPnts.Value ((aPntsIter + 1) % aLen + aStartIdx).XYZ()
|
||||
- theArrayOfPnts.Value (aPntsIter + aStartIdx).XYZ();
|
||||
for (Standard_Integer aVolDir = 0; aVolDir < aDirectionsNb; ++aVolDir)
|
||||
{
|
||||
Standard_Real aMaxPolyg = RealFirst();
|
||||
@@ -375,7 +375,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const Handle(TColgp_HArray1Of
|
||||
|
||||
for (Standard_Integer aPntIter = aStartIdx; aPntIter <= anEndIdx; ++aPntIter)
|
||||
{
|
||||
Standard_Real aProjection = aTestDir.Dot (theArrayOfPnts->Value (aPntIter).XYZ());
|
||||
Standard_Real aProjection = aTestDir.Dot (theArrayOfPnts.Value (aPntIter).XYZ());
|
||||
aMaxPolyg = Max (aMaxPolyg, aProjection);
|
||||
aMinPolyg = Min (aMinPolyg, aProjection);
|
||||
}
|
||||
|
@@ -491,7 +491,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
// may be considered of interior part or boundary line defined
|
||||
// by segments depending on given sensitivity type
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
|
||||
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
Standard_Real& theDepth)
|
||||
{
|
||||
@@ -499,15 +499,12 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const Handle(TColgp_HAr
|
||||
{
|
||||
Standard_Integer aMatchingSegmentsNb = -1;
|
||||
theDepth = DBL_MAX;
|
||||
Standard_Integer aLower = theArrayOfPnts->Lower();
|
||||
Standard_Integer anUpper = theArrayOfPnts->Upper();
|
||||
|
||||
const Standard_Integer aLower = theArrayOfPnts.Lower();
|
||||
const Standard_Integer anUpper = theArrayOfPnts.Upper();
|
||||
for (Standard_Integer aPntIter = aLower; aPntIter <= anUpper; ++aPntIter)
|
||||
{
|
||||
const gp_Pnt& aStartPnt = theArrayOfPnts->Value (aPntIter);
|
||||
const gp_Pnt& aEndPnt = aPntIter == anUpper ? theArrayOfPnts->Value (aLower)
|
||||
: theArrayOfPnts->Value (aPntIter + 1);
|
||||
|
||||
const gp_Pnt& aStartPnt = theArrayOfPnts.Value (aPntIter);
|
||||
const gp_Pnt& aEndPnt = theArrayOfPnts.Value (aPntIter == anUpper ? aLower : (aPntIter + 1));
|
||||
if (hasOverlap (aStartPnt, aEndPnt))
|
||||
{
|
||||
aMatchingSegmentsNb++;
|
||||
@@ -527,7 +524,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const Handle(TColgp_HAr
|
||||
return Standard_False;
|
||||
|
||||
segmentPlaneIntersection (aPolyNorm,
|
||||
theArrayOfPnts->Value (theArrayOfPnts->Lower()),
|
||||
theArrayOfPnts.Value (theArrayOfPnts.Lower()),
|
||||
theDepth);
|
||||
}
|
||||
|
||||
@@ -549,11 +546,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
{
|
||||
if (theSensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
Handle(TColgp_HArray1OfPnt) aPntsArray = new TColgp_HArray1OfPnt(1, 4);
|
||||
aPntsArray->SetValue (1, thePnt1);
|
||||
aPntsArray->SetValue (2, thePnt2);
|
||||
aPntsArray->SetValue (3, thePnt3);
|
||||
aPntsArray->SetValue (4, thePnt1);
|
||||
const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 };
|
||||
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 4);
|
||||
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theDepth);
|
||||
}
|
||||
else if (theSensType == Select3D_TOS_INTERIOR)
|
||||
|
@@ -77,7 +77,7 @@ public:
|
||||
//! SAT intersection test between defined volume and given ordered set of points,
|
||||
//! representing line segments. The test may be considered of interior part or
|
||||
//! boundary line defined by segments depending on given sensitivity type
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
Standard_Real& theDepth) Standard_OVERRIDE;
|
||||
|
||||
|
@@ -284,6 +284,25 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp
|
||||
if (myActiveSelectionType == Unknown)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(),
|
||||
(Select3D_TypeOfSensitivity)theSensType,
|
||||
theDepth);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Overlaps
|
||||
// purpose : SAT intersection test between defined volume and given
|
||||
// ordered set of points, representing line segments. The test
|
||||
// may be considered of interior part or boundary line defined
|
||||
// by segments depending on given sensitivity type
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Standard_Integer theSensType,
|
||||
Standard_Real& theDepth)
|
||||
{
|
||||
if (myActiveSelectionType == Unknown)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts,
|
||||
(Select3D_TypeOfSensitivity)theSensType,
|
||||
theDepth);
|
||||
|
@@ -120,6 +120,13 @@ public:
|
||||
Standard_Integer theSensType,
|
||||
Standard_Real& theDepth) Standard_OVERRIDE;
|
||||
|
||||
//! SAT intersection test between defined volume and given ordered set of points,
|
||||
//! representing line segments. The test may be considered of interior part or
|
||||
//! boundary line defined by segments depending on given sensitivity type
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
|
||||
Standard_Integer theSensType,
|
||||
Standard_Real& theDepth) Standard_OVERRIDE;
|
||||
|
||||
//! Checks if line segment overlaps selecting frustum
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
|
@@ -210,20 +210,18 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt,
|
||||
// may be considered of interior part or boundary line defined
|
||||
// by segments depending on given sensitivity type
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
|
||||
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
Standard_Real& /*theDepth*/)
|
||||
{
|
||||
if (theSensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
Standard_Integer aLower = theArrayOfPnts->Lower();
|
||||
Standard_Integer anUpper = theArrayOfPnts->Upper();
|
||||
|
||||
const Standard_Integer aLower = theArrayOfPnts.Lower();
|
||||
const Standard_Integer anUpper = theArrayOfPnts.Upper();
|
||||
for (Standard_Integer aPtIdx = aLower; aPtIdx <= anUpper; ++aPtIdx)
|
||||
{
|
||||
const gp_Pnt& aStartPt = theArrayOfPnts->Value (aPtIdx);
|
||||
const gp_Pnt& aEndPt = aPtIdx == anUpper ? theArrayOfPnts->Value (aLower) : theArrayOfPnts->Value (aPtIdx + 1);
|
||||
|
||||
const gp_Pnt& aStartPt = theArrayOfPnts.Value (aPtIdx);
|
||||
const gp_Pnt& aEndPt = theArrayOfPnts.Value (aPtIdx == anUpper ? aLower : (aPtIdx + 1));
|
||||
if (!hasOverlap (aStartPt, aEndPt))
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -265,11 +263,9 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
{
|
||||
if (theSensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
Handle(TColgp_HArray1OfPnt) aPtsArray = new TColgp_HArray1OfPnt(1, 4);
|
||||
aPtsArray->SetValue (1, thePnt1);
|
||||
aPtsArray->SetValue (2, thePnt2);
|
||||
aPtsArray->SetValue (3, thePnt3);
|
||||
return Overlaps (aPtsArray, Select3D_TOS_BOUNDARY, theDepth);
|
||||
const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 };
|
||||
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 3);
|
||||
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theDepth);
|
||||
}
|
||||
else if (theSensType == Select3D_TOS_INTERIOR)
|
||||
{
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
//! SAT intersection test between defined volume and given ordered set of points,
|
||||
//! representing line segments. The test may be considered of interior part or
|
||||
//! boundary line defined by segments depending on given sensitivity type
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
Standard_Real& theDepth) Standard_OVERRIDE;
|
||||
|
||||
|
@@ -175,7 +175,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
|
||||
// function : Overlaps
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
|
||||
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
Standard_Real& theDepth)
|
||||
{
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
|
||||
Standard_Real& theDepth) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
Standard_Real& theDepth) Standard_OVERRIDE;
|
||||
|
||||
|
Reference in New Issue
Block a user