mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Coding - Apply .clang-format formatting #286
Update empty method guards to new style with regex (see PR). Used clang-format 18.1.8. New actions to validate code formatting is added. Update .clang-format with disabling of include sorting. It is temporary changes, then include will be sorted. Apply formatting for /src and /tools folder. The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
@@ -22,19 +22,20 @@
|
||||
class Select3D_BVHIndexBuffer : public Graphic3d_Buffer
|
||||
{
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
Select3D_BVHIndexBuffer (const Handle(NCollection_BaseAllocator)& theAlloc)
|
||||
: Graphic3d_Buffer (theAlloc), myHasPatches (false) {}
|
||||
Select3D_BVHIndexBuffer(const Handle(NCollection_BaseAllocator)& theAlloc)
|
||||
: Graphic3d_Buffer(theAlloc),
|
||||
myHasPatches(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool HasPatches() const { return myHasPatches; }
|
||||
|
||||
//! Allocates new empty index array
|
||||
bool Init (const Standard_Integer theNbElems,
|
||||
const bool theHasPatches)
|
||||
bool Init(const Standard_Integer theNbElems, const bool theHasPatches)
|
||||
{
|
||||
release();
|
||||
Stride = sizeof(unsigned int);
|
||||
Stride = sizeof(unsigned int);
|
||||
myHasPatches = theHasPatches;
|
||||
if (theHasPatches)
|
||||
{
|
||||
@@ -43,8 +44,7 @@ public:
|
||||
|
||||
NbElements = theNbElems;
|
||||
NbAttributes = 0;
|
||||
if (NbElements != 0
|
||||
&& !Allocate (size_t(Stride) * size_t(NbElements)))
|
||||
if (NbElements != 0 && !Allocate(size_t(Stride) * size_t(NbElements)))
|
||||
{
|
||||
release();
|
||||
return false;
|
||||
@@ -53,43 +53,40 @@ public:
|
||||
}
|
||||
|
||||
//! Access index at specified position
|
||||
Standard_Integer Index (const Standard_Integer theIndex) const
|
||||
Standard_Integer Index(const Standard_Integer theIndex) const
|
||||
{
|
||||
return Standard_Integer(*reinterpret_cast<const unsigned int* >(value (theIndex)));
|
||||
return Standard_Integer(*reinterpret_cast<const unsigned int*>(value(theIndex)));
|
||||
}
|
||||
|
||||
//! Access index at specified position
|
||||
Standard_Integer PatchSize (const Standard_Integer theIndex) const
|
||||
Standard_Integer PatchSize(const Standard_Integer theIndex) const
|
||||
{
|
||||
return myHasPatches
|
||||
? Standard_Integer(*reinterpret_cast<const unsigned int* >(value (theIndex) + sizeof(unsigned int)))
|
||||
: 1;
|
||||
return myHasPatches ? Standard_Integer(*reinterpret_cast<const unsigned int*>(
|
||||
value(theIndex) + sizeof(unsigned int)))
|
||||
: 1;
|
||||
}
|
||||
|
||||
//! Change index at specified position
|
||||
void SetIndex (const Standard_Integer theIndex,
|
||||
const Standard_Integer theValue)
|
||||
void SetIndex(const Standard_Integer theIndex, const Standard_Integer theValue)
|
||||
{
|
||||
*reinterpret_cast<unsigned int* >(changeValue (theIndex)) = (unsigned int )theValue;
|
||||
*reinterpret_cast<unsigned int*>(changeValue(theIndex)) = (unsigned int)theValue;
|
||||
}
|
||||
|
||||
//! Change index at specified position
|
||||
void SetIndex (const Standard_Integer theIndex,
|
||||
const Standard_Integer theValue,
|
||||
const Standard_Integer thePatchSize)
|
||||
void SetIndex(const Standard_Integer theIndex,
|
||||
const Standard_Integer theValue,
|
||||
const Standard_Integer thePatchSize)
|
||||
{
|
||||
*reinterpret_cast<unsigned int* >(changeValue (theIndex)) = (unsigned int )theValue;
|
||||
*reinterpret_cast<unsigned int* >(changeValue (theIndex) + sizeof(unsigned int)) = (unsigned int )thePatchSize;
|
||||
*reinterpret_cast<unsigned int*>(changeValue(theIndex)) = (unsigned int)theValue;
|
||||
*reinterpret_cast<unsigned int*>(changeValue(theIndex) + sizeof(unsigned int)) =
|
||||
(unsigned int)thePatchSize;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool myHasPatches;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE(Select3D_BVHIndexBuffer,Graphic3d_Buffer)
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE(Select3D_BVHIndexBuffer, Graphic3d_Buffer)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_BVHIndexBuffer, Graphic3d_Buffer)
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <gp_Trsf.hxx>
|
||||
|
||||
typedef BVH_Box<Standard_Real, 3> Select3D_BndBox3d;
|
||||
typedef BVH_Box<Standard_Real, 3> Select3D_BndBox3d;
|
||||
typedef NCollection_Vec3<Standard_Real> Select3D_Vec3;
|
||||
|
||||
#endif // _Select3D_BndBox3d_Header
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
class Select3D_SensitiveEntity;
|
||||
typedef NCollection_Sequence<Handle(Select3D_SensitiveEntity)> Select3D_EntitySequence;
|
||||
typedef NCollection_Sequence<Handle(Select3D_SensitiveEntity)>::Iterator Select3D_EntitySequenceIter;
|
||||
typedef NCollection_Sequence<Handle(Select3D_SensitiveEntity)>::Iterator
|
||||
Select3D_EntitySequenceIter;
|
||||
|
||||
#endif // _Select3D_EntitySequence_Header
|
||||
|
@@ -17,29 +17,28 @@
|
||||
|
||||
#include <Select3D_InteriorSensitivePointSet.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_InteriorSensitivePointSet,Select3D_SensitiveSet)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
// Internal class for creation of planar polygons
|
||||
class Select3D_Plane
|
||||
{
|
||||
public:
|
||||
|
||||
Select3D_Plane()
|
||||
: myPlane (0.0),
|
||||
myIsInitialized (Standard_False)
|
||||
{}
|
||||
: myPlane(0.0),
|
||||
myIsInitialized(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
Standard_Boolean Contains (const gp_Pnt& thePnt) const
|
||||
Standard_Boolean Contains(const gp_Pnt& thePnt) const
|
||||
{
|
||||
if (!myIsInitialized)
|
||||
return Standard_False;
|
||||
|
||||
Standard_Real aRes = myPlane.x() * thePnt.X() +
|
||||
myPlane.y() * thePnt.Y() +
|
||||
myPlane.z() * thePnt.Z() +
|
||||
myPlane.w();
|
||||
Standard_Real aRes =
|
||||
myPlane.x() * thePnt.X() + myPlane.y() * thePnt.Y() + myPlane.z() * thePnt.Z() + myPlane.w();
|
||||
|
||||
if (aRes < Precision::Confusion())
|
||||
return Standard_True;
|
||||
@@ -47,27 +46,19 @@ public:
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
void MakePlane (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3)
|
||||
void MakePlane(const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, const gp_Pnt& thePnt3)
|
||||
{
|
||||
const gp_XYZ& aVec1 = thePnt2.XYZ() - thePnt1.XYZ();
|
||||
const gp_XYZ& aVec2 = thePnt3.XYZ() - thePnt1.XYZ();
|
||||
const gp_XYZ& aDir = aVec1.Crossed (aVec2);
|
||||
Standard_Real aD = aDir.Dot (thePnt1.XYZ().Reversed());
|
||||
myPlane = NCollection_Vec4<Standard_Real> (aDir.X(), aDir.Y(), aDir.Z(), aD);
|
||||
myIsInitialized = Standard_True;
|
||||
const gp_XYZ& aDir = aVec1.Crossed(aVec2);
|
||||
Standard_Real aD = aDir.Dot(thePnt1.XYZ().Reversed());
|
||||
myPlane = NCollection_Vec4<Standard_Real>(aDir.X(), aDir.Y(), aDir.Z(), aD);
|
||||
myIsInitialized = Standard_True;
|
||||
}
|
||||
|
||||
void Invalidate()
|
||||
{
|
||||
myIsInitialized = Standard_False;
|
||||
}
|
||||
void Invalidate() { myIsInitialized = Standard_False; }
|
||||
|
||||
Standard_Boolean IsValid() const
|
||||
{
|
||||
return myIsInitialized;
|
||||
}
|
||||
Standard_Boolean IsValid() const { return myIsInitialized; }
|
||||
|
||||
private:
|
||||
NCollection_Vec4<Standard_Real> myPlane;
|
||||
@@ -76,73 +67,71 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : Select3D_InteriorSensitivePointSet
|
||||
// purpose : Splits the given point set thePoints onto planar convex
|
||||
// polygons
|
||||
// =======================================================================
|
||||
Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints)
|
||||
: Select3D_SensitiveSet (theOwnerId)
|
||||
Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints)
|
||||
: Select3D_SensitiveSet(theOwnerId)
|
||||
{
|
||||
Select3D_Plane aPlane;
|
||||
Standard_Integer aLowerIdx = thePoints.Lower();
|
||||
Standard_Integer anUpperIdx = thePoints.Upper();
|
||||
Standard_Integer aStartIdx = aLowerIdx, anEndIdx = 0;
|
||||
Select3D_Plane aPlane;
|
||||
Standard_Integer aLowerIdx = thePoints.Lower();
|
||||
Standard_Integer anUpperIdx = thePoints.Upper();
|
||||
Standard_Integer aStartIdx = aLowerIdx, anEndIdx = 0;
|
||||
Select3D_BndBox3d aBndBox;
|
||||
gp_XYZ aPntSum (0.0, 0.0, 0.0);
|
||||
gp_XYZ aPntSum(0.0, 0.0, 0.0);
|
||||
for (Standard_Integer aPntIter = aLowerIdx; aPntIter <= anUpperIdx; ++aPntIter)
|
||||
{
|
||||
gp_Pnt aPnt1, aPnt2;
|
||||
const gp_Pnt& aPnt3 = thePoints.Value (aPntIter);
|
||||
gp_Pnt aPnt1, aPnt2;
|
||||
const gp_Pnt& aPnt3 = thePoints.Value(aPntIter);
|
||||
aPntSum += aPnt3.XYZ();
|
||||
SelectMgr_Vec3 aCurrPnt (aPnt3.X(), aPnt3.Y(), aPnt3.Z());
|
||||
aBndBox.Add (aCurrPnt);
|
||||
SelectMgr_Vec3 aCurrPnt(aPnt3.X(), aPnt3.Y(), aPnt3.Z());
|
||||
aBndBox.Add(aCurrPnt);
|
||||
if (aPntIter - aLowerIdx >= 2)
|
||||
{
|
||||
aPnt1 = thePoints.Value (aPntIter - 2);
|
||||
aPnt2 = thePoints.Value (aPntIter - 1);
|
||||
aPnt1 = thePoints.Value(aPntIter - 2);
|
||||
aPnt2 = thePoints.Value(aPntIter - 1);
|
||||
}
|
||||
if (aPntIter - aStartIdx == 2 && !aPlane.IsValid())
|
||||
{
|
||||
aPlane.MakePlane (aPnt1, aPnt2, aPnt3);
|
||||
aPlane.MakePlane(aPnt1, aPnt2, aPnt3);
|
||||
aStartIdx = aPntIter - 2;
|
||||
anEndIdx = aPntIter;
|
||||
anEndIdx = aPntIter;
|
||||
|
||||
if (anEndIdx == anUpperIdx)
|
||||
{
|
||||
Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anEndIdx - aStartIdx);
|
||||
Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt(0, anEndIdx - aStartIdx);
|
||||
for (Standard_Integer aIdx = aStartIdx; aIdx <= anEndIdx; ++aIdx)
|
||||
{
|
||||
aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value(aIdx));
|
||||
aPointsArray->SetValue(aIdx - aStartIdx, thePoints.Value(aIdx));
|
||||
}
|
||||
Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId,
|
||||
aPointsArray,
|
||||
Standard_False);
|
||||
myPlanarPolygons.Append (aPlanarPolyg);
|
||||
Handle(Select3D_SensitivePoly) aPlanarPolyg =
|
||||
new Select3D_SensitivePoly(theOwnerId, aPointsArray, Standard_False);
|
||||
myPlanarPolygons.Append(aPlanarPolyg);
|
||||
}
|
||||
}
|
||||
else if (aPlane.IsValid())
|
||||
{
|
||||
const gp_XYZ& aVec1 = aPnt1.XYZ() - aPnt2.XYZ();
|
||||
const gp_XYZ& aVec2 = aPnt3.XYZ() - aPnt2.XYZ();
|
||||
Standard_Real anAngle = aVec1.Dot (aVec2);
|
||||
if (!aPlane.Contains (thePoints.Value (aPntIter)) || anAngle > Precision::Confusion())
|
||||
const gp_XYZ& aVec1 = aPnt1.XYZ() - aPnt2.XYZ();
|
||||
const gp_XYZ& aVec2 = aPnt3.XYZ() - aPnt2.XYZ();
|
||||
Standard_Real anAngle = aVec1.Dot(aVec2);
|
||||
if (!aPlane.Contains(thePoints.Value(aPntIter)) || anAngle > Precision::Confusion())
|
||||
{
|
||||
// subtract 1 due to indexation from zero in sub-polygons
|
||||
Standard_Integer anUpperBound = aPntIter - aStartIdx - 1;
|
||||
Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anUpperBound);
|
||||
Standard_Integer anUpperBound = aPntIter - aStartIdx - 1;
|
||||
Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt(0, anUpperBound);
|
||||
for (Standard_Integer aIdx = aStartIdx; aIdx <= aStartIdx + anUpperBound; ++aIdx)
|
||||
{
|
||||
aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value (aIdx));
|
||||
aPointsArray->SetValue(aIdx - aStartIdx, thePoints.Value(aIdx));
|
||||
}
|
||||
Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId,
|
||||
aPointsArray,
|
||||
Standard_True);
|
||||
myPlanarPolygons.Append (aPlanarPolyg);
|
||||
Handle(Select3D_SensitivePoly) aPlanarPolyg =
|
||||
new Select3D_SensitivePoly(theOwnerId, aPointsArray, Standard_True);
|
||||
myPlanarPolygons.Append(aPlanarPolyg);
|
||||
aStartIdx = aPntIter;
|
||||
anEndIdx = aPntIter;
|
||||
anEndIdx = aPntIter;
|
||||
aPlane.Invalidate();
|
||||
}
|
||||
else
|
||||
@@ -150,27 +139,27 @@ Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Ha
|
||||
anEndIdx++;
|
||||
if (anEndIdx == anUpperIdx)
|
||||
{
|
||||
Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anEndIdx - aStartIdx);
|
||||
Handle(TColgp_HArray1OfPnt) aPointsArray =
|
||||
new TColgp_HArray1OfPnt(0, anEndIdx - aStartIdx);
|
||||
for (Standard_Integer aIdx = aStartIdx; aIdx <= anEndIdx; ++aIdx)
|
||||
{
|
||||
aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value (aIdx));
|
||||
aPointsArray->SetValue(aIdx - aStartIdx, thePoints.Value(aIdx));
|
||||
}
|
||||
Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId,
|
||||
aPointsArray,
|
||||
Standard_True);
|
||||
myPlanarPolygons.Append (aPlanarPolyg);
|
||||
Handle(Select3D_SensitivePoly) aPlanarPolyg =
|
||||
new Select3D_SensitivePoly(theOwnerId, aPointsArray, Standard_True);
|
||||
myPlanarPolygons.Append(aPlanarPolyg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myCOG = aPntSum / thePoints.Length();
|
||||
myCOG = aPntSum / thePoints.Length();
|
||||
myBndBox = aBndBox;
|
||||
|
||||
myPolygonsIdxs = new TColStd_HArray1OfInteger (0, myPlanarPolygons.Length() - 1);
|
||||
myPolygonsIdxs = new TColStd_HArray1OfInteger(0, myPlanarPolygons.Length() - 1);
|
||||
for (Standard_Integer aIdx = 0; aIdx < myPlanarPolygons.Length(); ++aIdx)
|
||||
{
|
||||
myPolygonsIdxs->SetValue (aIdx, aIdx);
|
||||
myPolygonsIdxs->SetValue(aIdx, aIdx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,27 +168,28 @@ Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Ha
|
||||
// purpose : Initializes the given array theHArrayOfPnt by 3d
|
||||
// coordinates of vertices of the whole point set
|
||||
// =======================================================================
|
||||
void Select3D_InteriorSensitivePointSet::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
|
||||
void Select3D_InteriorSensitivePointSet::GetPoints(Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
|
||||
{
|
||||
Standard_Integer aSize = 0;
|
||||
for (Standard_Integer anIdx = 0; anIdx < myPlanarPolygons.Length(); ++anIdx)
|
||||
{
|
||||
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (anIdx);
|
||||
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value(anIdx);
|
||||
aSize += aPolygon->NbSubElements();
|
||||
}
|
||||
|
||||
theHArrayOfPnt = new TColgp_HArray1OfPnt (1, aSize);
|
||||
theHArrayOfPnt = new TColgp_HArray1OfPnt(1, aSize);
|
||||
Standard_Integer anOutputPntArrayIdx = 1;
|
||||
|
||||
for (Standard_Integer aPolygIdx = 0; aPolygIdx < myPlanarPolygons.Length(); ++aPolygIdx)
|
||||
{
|
||||
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx);
|
||||
Handle(TColgp_HArray1OfPnt) aPoints;
|
||||
aPolygon->Points3D (aPoints);
|
||||
Standard_Integer anUpper = aPolygIdx < myPlanarPolygons.Length() - 1 ? aPoints->Upper() : aPoints->Upper() + 1;
|
||||
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value(aPolygIdx);
|
||||
Handle(TColgp_HArray1OfPnt) aPoints;
|
||||
aPolygon->Points3D(aPoints);
|
||||
Standard_Integer anUpper =
|
||||
aPolygIdx < myPlanarPolygons.Length() - 1 ? aPoints->Upper() : aPoints->Upper() + 1;
|
||||
for (Standard_Integer aPntIter = 1; aPntIter < anUpper; ++aPntIter)
|
||||
{
|
||||
theHArrayOfPnt->SetValue (anOutputPntArrayIdx, aPoints->Value (aPntIter));
|
||||
theHArrayOfPnt->SetValue(anOutputPntArrayIdx, aPoints->Value(aPntIter));
|
||||
anOutputPntArrayIdx++;
|
||||
}
|
||||
aPoints.Nullify();
|
||||
@@ -220,10 +210,10 @@ Standard_Integer Select3D_InteriorSensitivePointSet::Size() const
|
||||
// purpose : Returns bounding box of planar convex polygon with index
|
||||
// theIdx
|
||||
//=======================================================================
|
||||
Select3D_BndBox3d Select3D_InteriorSensitivePointSet::Box (const Standard_Integer theIdx) const
|
||||
Select3D_BndBox3d Select3D_InteriorSensitivePointSet::Box(const Standard_Integer theIdx) const
|
||||
{
|
||||
Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theIdx);
|
||||
return myPlanarPolygons.Value (aPolygIdx)->BoundingBox();
|
||||
Standard_Integer aPolygIdx = myPolygonsIdxs->Value(theIdx);
|
||||
return myPlanarPolygons.Value(aPolygIdx)->BoundingBox();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -231,54 +221,56 @@ Select3D_BndBox3d Select3D_InteriorSensitivePointSet::Box (const Standard_Intege
|
||||
// purpose : Returns geometry center of planar convex polygon with index
|
||||
// theIdx in the vector along the given axis theAxis
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_InteriorSensitivePointSet::Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_Real Select3D_InteriorSensitivePointSet::Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
{
|
||||
const Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theIdx);
|
||||
const gp_Pnt aCOG = myPlanarPolygons.Value (aPolygIdx)->CenterOfGeometry();
|
||||
return aCOG.Coord (theAxis - 1);
|
||||
const Standard_Integer aPolygIdx = myPolygonsIdxs->Value(theIdx);
|
||||
const gp_Pnt aCOG = myPlanarPolygons.Value(aPolygIdx)->CenterOfGeometry();
|
||||
return aCOG.Coord(theAxis - 1);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Swap
|
||||
// purpose : Swaps items with indexes theIdx1 and theIdx2 in the vector
|
||||
//=======================================================================
|
||||
void Select3D_InteriorSensitivePointSet::Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2)
|
||||
void Select3D_InteriorSensitivePointSet::Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2)
|
||||
{
|
||||
Standard_Integer aPolygIdx1 = myPolygonsIdxs->Value (theIdx1);
|
||||
Standard_Integer aPolygIdx2 = myPolygonsIdxs->Value (theIdx2);
|
||||
Standard_Integer aPolygIdx1 = myPolygonsIdxs->Value(theIdx1);
|
||||
Standard_Integer aPolygIdx2 = myPolygonsIdxs->Value(theIdx2);
|
||||
|
||||
myPolygonsIdxs->ChangeValue (theIdx1) = aPolygIdx2;
|
||||
myPolygonsIdxs->ChangeValue (theIdx2) = aPolygIdx1;
|
||||
myPolygonsIdxs->ChangeValue(theIdx1) = aPolygIdx2;
|
||||
myPolygonsIdxs->ChangeValue(theIdx2) = aPolygIdx1;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : overlapsElement
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean )
|
||||
Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean)
|
||||
{
|
||||
Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theElemIdx);
|
||||
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx);
|
||||
Handle(TColgp_HArray1OfPnt) aPoints;
|
||||
aPolygon->Points3D (aPoints);
|
||||
return theMgr.OverlapsPolygon (aPoints->Array1(), Select3D_TOS_INTERIOR, thePickResult);
|
||||
Standard_Integer aPolygIdx = myPolygonsIdxs->Value(theElemIdx);
|
||||
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value(aPolygIdx);
|
||||
Handle(TColgp_HArray1OfPnt) aPoints;
|
||||
aPolygon->Points3D(aPoints);
|
||||
return theMgr.OverlapsPolygon(aPoints->Array1(), Select3D_TOS_INTERIOR, thePickResult);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : elementIsInside
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Select3D_InteriorSensitivePointSet::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
Standard_Boolean Select3D_InteriorSensitivePointSet::elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
{
|
||||
SelectBasics_PickResult aDummy;
|
||||
return overlapsElement (aDummy, theMgr, theElemIdx, theIsFullInside);
|
||||
return overlapsElement(aDummy, theMgr, theElemIdx, theIsFullInside);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -286,9 +278,10 @@ Standard_Boolean Select3D_InteriorSensitivePointSet::elementIsInside (SelectBasi
|
||||
// purpose : Calculates distance from the 3d projection of used-picked
|
||||
// screen point to center of the geometry
|
||||
// =======================================================================
|
||||
Standard_Real Select3D_InteriorSensitivePointSet::distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr)
|
||||
Standard_Real Select3D_InteriorSensitivePointSet::distanceToCOG(
|
||||
SelectBasics_SelectingVolumeManager& theMgr)
|
||||
{
|
||||
return theMgr.DistToGeometryCenter (myCOG);
|
||||
return theMgr.DistToGeometryCenter(myCOG);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -324,10 +317,11 @@ Standard_Integer Select3D_InteriorSensitivePointSet::NbSubElements() const
|
||||
// function : DumpJson
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Select3D_InteriorSensitivePointSet::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
void Select3D_InteriorSensitivePointSet::DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet)
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveSet)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBndBox)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myBndBox)
|
||||
}
|
||||
|
@@ -29,29 +29,31 @@ typedef NCollection_Vector<Handle(Select3D_SensitivePoly)> Select3D_VectorOfHPol
|
||||
class Select3D_InteriorSensitivePointSet : public Select3D_SensitiveSet
|
||||
{
|
||||
public:
|
||||
|
||||
//! Splits the given point set thePoints onto planar convex polygons
|
||||
Standard_EXPORT Select3D_InteriorSensitivePointSet (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints);
|
||||
Standard_EXPORT Select3D_InteriorSensitivePointSet(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints);
|
||||
|
||||
//! Initializes the given array theHArrayOfPnt by 3d coordinates of vertices of the
|
||||
//! whole point set
|
||||
Standard_EXPORT virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
|
||||
Standard_EXPORT virtual void GetPoints(Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
|
||||
|
||||
//! Returns the length of vector of planar convex polygons
|
||||
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of planar convex polygon with index theIdx
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns geometry center of planar convex polygon with index
|
||||
//! theIdx in the vector along the given axis theAxis
|
||||
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Swaps items with indexes theIdx1 and theIdx2 in the vector
|
||||
Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of the point set. If location
|
||||
//! transformation is set, it will be applied
|
||||
@@ -65,34 +67,36 @@ public:
|
||||
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_InteriorSensitivePointSet,Select3D_SensitiveSet)
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
|
||||
|
||||
protected:
|
||||
|
||||
//! Checks whether the planar convex polygon with index theIdx
|
||||
//! in myPlanarPolygons overlaps the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Checks whether the entity with index theIdx is inside the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Calculates distance from the 3d projection of used-picked
|
||||
//! screen point to center of the geometry
|
||||
Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Real distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Select3D_VectorOfHPoly myPlanarPolygons; //!< Vector of planar polygons
|
||||
Handle(TColStd_HArray1OfInteger) myPolygonsIdxs; //!< Indexes array for BVH calculation
|
||||
gp_Pnt myCOG; //!< Center of the point set
|
||||
Select3D_BndBox3d myBndBox; //!< Bounding box of the point set
|
||||
Select3D_VectorOfHPoly myPlanarPolygons; //!< Vector of planar polygons
|
||||
Handle(TColStd_HArray1OfInteger) myPolygonsIdxs; //!< Indexes array for BVH calculation
|
||||
gp_Pnt myCOG; //!< Center of the point set
|
||||
Select3D_BndBox3d myBndBox; //!< Bounding box of the point set
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
|
||||
|
@@ -24,11 +24,11 @@ struct Select3D_Pnt
|
||||
|
||||
operator gp_XYZ() const { return gp_XYZ(x, y, z); }
|
||||
|
||||
gp_Pnt operator= (const gp_Pnt& thePnt)
|
||||
gp_Pnt operator=(const gp_Pnt& thePnt)
|
||||
{
|
||||
x = RealToShortReal (thePnt.X());
|
||||
y = RealToShortReal (thePnt.Y());
|
||||
z = RealToShortReal (thePnt.Z());
|
||||
x = RealToShortReal(thePnt.X());
|
||||
y = RealToShortReal(thePnt.Y());
|
||||
z = RealToShortReal(thePnt.Z());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
@@ -21,11 +21,10 @@ class Select3D_PointData
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Constructs internal array of 3D points defined
|
||||
// by number of points theNbPoints
|
||||
Select3D_PointData (const Standard_Integer theNbPoints)
|
||||
: mynbpoints(theNbPoints)
|
||||
Select3D_PointData(const Standard_Integer theNbPoints)
|
||||
: mynbpoints(theNbPoints)
|
||||
{
|
||||
if (theNbPoints <= 0)
|
||||
throw Standard_ConstructionError("Select3D_PointData");
|
||||
@@ -34,15 +33,11 @@ public:
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~Select3D_PointData ()
|
||||
{
|
||||
delete [] mypolyg3d;
|
||||
}
|
||||
~Select3D_PointData() { delete[] mypolyg3d; }
|
||||
|
||||
// Sets Select3D_Pnt to internal array
|
||||
// of 3D points if theIndex is valid
|
||||
void SetPnt (const Standard_Integer theIndex,
|
||||
const Select3D_Pnt& theValue)
|
||||
void SetPnt(const Standard_Integer theIndex, const Select3D_Pnt& theValue)
|
||||
{
|
||||
if (theIndex < 0 || theIndex >= mynbpoints)
|
||||
throw Standard_OutOfRange("Select3D_PointData::SetPnt");
|
||||
@@ -51,8 +46,7 @@ public:
|
||||
|
||||
// Sets gp_Pnt to internal array
|
||||
// of 3D points if theIndex is valid
|
||||
void SetPnt (const Standard_Integer theIndex,
|
||||
const gp_Pnt& theValue)
|
||||
void SetPnt(const Standard_Integer theIndex, const gp_Pnt& theValue)
|
||||
{
|
||||
if (theIndex < 0 || theIndex >= mynbpoints)
|
||||
throw Standard_OutOfRange("Select3D_PointData::SetPnt");
|
||||
@@ -61,7 +55,7 @@ public:
|
||||
|
||||
// Returns 3D point from internal array
|
||||
// if theIndex is valid
|
||||
const Select3D_Pnt& Pnt (const Standard_Integer theIndex) const
|
||||
const Select3D_Pnt& Pnt(const Standard_Integer theIndex) const
|
||||
{
|
||||
if (theIndex < 0 || theIndex >= mynbpoints)
|
||||
throw Standard_OutOfRange("Select3D_PointData::Pnt");
|
||||
@@ -70,7 +64,7 @@ public:
|
||||
|
||||
// Returns 3D point from internal array
|
||||
// if theIndex is valid
|
||||
gp_Pnt Pnt3d (const Standard_Integer theIndex) const
|
||||
gp_Pnt Pnt3d(const Standard_Integer theIndex) const
|
||||
{
|
||||
if (theIndex < 0 || theIndex >= mynbpoints)
|
||||
throw Standard_OutOfRange("Select3D_PointData::Pnt");
|
||||
@@ -78,17 +72,13 @@ public:
|
||||
}
|
||||
|
||||
// Returns size of internal arrays
|
||||
Standard_Integer Size () const
|
||||
{
|
||||
return mynbpoints;
|
||||
}
|
||||
Standard_Integer Size() const { return mynbpoints; }
|
||||
|
||||
private:
|
||||
Select3D_PointData (const Select3D_PointData&);
|
||||
Select3D_PointData& operator= (const Select3D_PointData&);
|
||||
Select3D_PointData(const Select3D_PointData&);
|
||||
Select3D_PointData& operator=(const Select3D_PointData&);
|
||||
|
||||
private:
|
||||
|
||||
Select3D_Pnt* mypolyg3d;
|
||||
Standard_Integer mynbpoints;
|
||||
};
|
||||
|
@@ -16,43 +16,37 @@
|
||||
|
||||
#include <Select3D_SensitiveBox.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveBox,Select3D_SensitiveEntity)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveBox, Select3D_SensitiveEntity)
|
||||
|
||||
//==================================================
|
||||
// Function: Select3D_SensitiveBox
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitiveBox::Select3D_SensitiveBox (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Bnd_Box& theBox)
|
||||
: Select3D_SensitiveEntity (theOwnerId)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveBox::Select3D_SensitiveBox(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Bnd_Box& theBox)
|
||||
: Select3D_SensitiveEntity(theOwnerId)
|
||||
{
|
||||
Standard_Real aXMax, aYMax, aZMax;
|
||||
Standard_Real aXMin, aYMin, aZMin;
|
||||
theBox.Get (aXMin, aYMin, aZMin, aXMax, aYMax, aZMax);
|
||||
myBox = Select3D_BndBox3d (SelectMgr_Vec3 (aXMin, aYMin, aZMin),
|
||||
SelectMgr_Vec3 (aXMax, aYMax, aZMax));
|
||||
myCenter3d = (gp_XYZ (aXMin, aYMin, aZMin) + gp_XYZ (aXMax, aYMax, aZMax))
|
||||
* (1.0 / 2.0);
|
||||
theBox.Get(aXMin, aYMin, aZMin, aXMax, aYMax, aZMax);
|
||||
myBox =
|
||||
Select3D_BndBox3d(SelectMgr_Vec3(aXMin, aYMin, aZMin), SelectMgr_Vec3(aXMax, aYMax, aZMax));
|
||||
myCenter3d = (gp_XYZ(aXMin, aYMin, aZMin) + gp_XYZ(aXMax, aYMax, aZMax)) * (1.0 / 2.0);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Select3D_SensitiveBox
|
||||
// Purpose :
|
||||
//==================================================
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveBox::Select3D_SensitiveBox (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theXMin,
|
||||
const Standard_Real theYMin,
|
||||
const Standard_Real theZMin,
|
||||
const Standard_Real theXMax,
|
||||
const Standard_Real theYMax,
|
||||
const Standard_Real theZMax)
|
||||
: Select3D_SensitiveEntity (theOwnerId)
|
||||
Select3D_SensitiveBox::Select3D_SensitiveBox(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theXMin,
|
||||
const Standard_Real theYMin,
|
||||
const Standard_Real theZMin,
|
||||
const Standard_Real theXMax,
|
||||
const Standard_Real theYMax,
|
||||
const Standard_Real theZMax)
|
||||
: Select3D_SensitiveEntity(theOwnerId)
|
||||
{
|
||||
myBox = Select3D_BndBox3d (SelectMgr_Vec3 (theXMin, theYMin, theZMin),
|
||||
SelectMgr_Vec3 (theXMax, theYMax, theZMax));
|
||||
myCenter3d = (gp_XYZ (theXMin, theYMin, theZMin) + gp_XYZ (theXMax, theYMax, theZMax))
|
||||
* (1.0 / 2.0);
|
||||
myBox = Select3D_BndBox3d(SelectMgr_Vec3(theXMin, theYMin, theZMin),
|
||||
SelectMgr_Vec3(theXMax, theYMax, theZMax));
|
||||
myCenter3d =
|
||||
(gp_XYZ(theXMin, theYMin, theZMin) + gp_XYZ(theXMax, theYMax, theZMax)) * (1.0 / 2.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -64,17 +58,18 @@ Standard_Integer Select3D_SensitiveBox::NbSubElements() const
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveBox::GetConnected()
|
||||
{
|
||||
Bnd_Box aBox;
|
||||
aBox.Update (myBox.CornerMin().x(), myBox.CornerMin().y(), myBox.CornerMin().z(),
|
||||
myBox.CornerMax().x(), myBox.CornerMax().y(), myBox.CornerMax().z());
|
||||
Handle(Select3D_SensitiveBox) aNewEntity = new Select3D_SensitiveBox (myOwnerId, aBox);
|
||||
aBox.Update(myBox.CornerMin().x(),
|
||||
myBox.CornerMin().y(),
|
||||
myBox.CornerMin().z(),
|
||||
myBox.CornerMax().x(),
|
||||
myBox.CornerMax().y(),
|
||||
myBox.CornerMax().z());
|
||||
Handle(Select3D_SensitiveBox) aNewEntity = new Select3D_SensitiveBox(myOwnerId, aBox);
|
||||
|
||||
return aNewEntity;
|
||||
}
|
||||
@@ -83,21 +78,21 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveBox::GetConnected()
|
||||
// function : Matches
|
||||
// purpose : Checks whether the box overlaps current selecting volume
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveBox::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_Boolean Select3D_SensitiveBox::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
if (!theMgr.IsOverlapAllowed()) // check for inclusion
|
||||
{
|
||||
Standard_Boolean isInside = Standard_True;
|
||||
return theMgr.OverlapsBox (myBox.CornerMin(), myBox.CornerMax(), &isInside) && isInside;
|
||||
return theMgr.OverlapsBox(myBox.CornerMin(), myBox.CornerMax(), &isInside) && isInside;
|
||||
}
|
||||
|
||||
if (!theMgr.OverlapsBox (myBox.CornerMin(), myBox.CornerMax(), thePickResult)) // check for overlap
|
||||
if (!theMgr.OverlapsBox(myBox.CornerMin(), myBox.CornerMax(), thePickResult)) // check for overlap
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCenter3d));
|
||||
thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(myCenter3d));
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -121,14 +116,12 @@ Select3D_BndBox3d Select3D_SensitiveBox::BoundingBox()
|
||||
return myBox;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveBox::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
//=================================================================================================
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBox)
|
||||
void Select3D_SensitiveBox::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myBox)
|
||||
}
|
||||
|
@@ -24,10 +24,10 @@ class Select3D_SensitiveBox : public Select3D_SensitiveEntity
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveBox, Select3D_SensitiveEntity)
|
||||
public:
|
||||
|
||||
//! Constructs a sensitive box object defined by the
|
||||
//! owner theOwnerId, and the box theBox.
|
||||
Standard_EXPORT Select3D_SensitiveBox (const Handle(SelectMgr_EntityOwner)& theOwnerId, const Bnd_Box& theBox);
|
||||
Standard_EXPORT Select3D_SensitiveBox(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Bnd_Box& theBox);
|
||||
|
||||
//! Constructs a sensitive box object defined by the
|
||||
//! owner theOwnerId, and the coordinates theXmin, theYMin, theZMin, theXMax, theYMax, theZMax.
|
||||
@@ -35,13 +35,13 @@ public:
|
||||
//! the front lower left hand corner of the box,
|
||||
//! and theXMax, theYMax and theZMax define the maximum
|
||||
//! point in the back upper right hand corner of the box.
|
||||
Standard_EXPORT Select3D_SensitiveBox (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theXMin,
|
||||
const Standard_Real theYMin,
|
||||
const Standard_Real theZMin,
|
||||
const Standard_Real theXMax,
|
||||
const Standard_Real theYMax,
|
||||
const Standard_Real theZMax);
|
||||
Standard_EXPORT Select3D_SensitiveBox(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theXMin,
|
||||
const Standard_Real theYMin,
|
||||
const Standard_Real theZMin,
|
||||
const Standard_Real theXMax,
|
||||
const Standard_Real theYMax,
|
||||
const Standard_Real theZMax);
|
||||
|
||||
//! Returns the amount of sub-entities in sensitive
|
||||
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
|
||||
@@ -49,14 +49,19 @@ public:
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
|
||||
//! Checks whether the box overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
Bnd_Box Box() const
|
||||
{
|
||||
Bnd_Box aBox;
|
||||
aBox.Update (myBox.CornerMin().x(), myBox.CornerMin().y(), myBox.CornerMin().z(),
|
||||
myBox.CornerMax().x(), myBox.CornerMax().y(), myBox.CornerMax().z());
|
||||
aBox.Update(myBox.CornerMin().x(),
|
||||
myBox.CornerMin().y(),
|
||||
myBox.CornerMin().z(),
|
||||
myBox.CornerMax().x(),
|
||||
myBox.CornerMax().y(),
|
||||
myBox.CornerMax().z());
|
||||
|
||||
return aBox;
|
||||
}
|
||||
@@ -73,12 +78,12 @@ public:
|
||||
virtual Standard_Boolean ToBuildBVH() const Standard_OVERRIDE { return Standard_False; }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Select3D_BndBox3d myBox; //!< 3d coordinates of box corners
|
||||
gp_Pnt myCenter3d; //!< 3d coordinate of box's center
|
||||
Select3D_BndBox3d myBox; //!< 3d coordinates of box corners
|
||||
gp_Pnt myCenter3d; //!< 3d coordinate of box's center
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveBox, Select3D_SensitiveEntity)
|
||||
|
@@ -21,21 +21,21 @@
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCircle, Select3D_SensitiveEntity)
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_SensitiveCircle (constructor)
|
||||
//purpose : Definition of a sensitive circle
|
||||
// function : Select3D_SensitiveCircle (constructor)
|
||||
// purpose : Definition of a sensitive circle
|
||||
//=======================================================================
|
||||
Select3D_SensitiveCircle::Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Boolean theIsFilled)
|
||||
: Select3D_SensitiveEntity (theOwnerId)
|
||||
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Boolean theIsFilled)
|
||||
: Select3D_SensitiveEntity(theOwnerId)
|
||||
{
|
||||
myRadius = theCircle.Radius();
|
||||
myTrsf.SetTransformation (theCircle.Position(), gp::XOY());
|
||||
myTrsf.SetTransformation(theCircle.Position(), gp::XOY());
|
||||
|
||||
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
|
||||
if (mySensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
SetSensitivityFactor (6);
|
||||
SetSensitivityFactor(6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ Select3D_SensitiveCircle::Select3D_SensitiveCircle (const Handle(SelectMgr_Entit
|
||||
// function : Matches
|
||||
// purpose : Checks whether the circle overlaps current selecting volume
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_Boolean Select3D_SensitiveCircle::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
const Standard_Boolean aIsFilled = mySensType == Select3D_TOS_INTERIOR;
|
||||
|
||||
@@ -53,57 +53,50 @@ Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolume
|
||||
if (!theMgr.IsOverlapAllowed())
|
||||
{
|
||||
bool isInside = true;
|
||||
return theMgr.OverlapsCircle (myRadius, myTrsf, aIsFilled, &isInside) && isInside;
|
||||
return theMgr.OverlapsCircle(myRadius, myTrsf, aIsFilled, &isInside) && isInside;
|
||||
}
|
||||
else
|
||||
{
|
||||
return theMgr.OverlapsCircle (myRadius, myTrsf, aIsFilled, NULL);
|
||||
return theMgr.OverlapsCircle(myRadius, myTrsf, aIsFilled, NULL);
|
||||
}
|
||||
}
|
||||
if (!theMgr.OverlapsCircle (myRadius, myTrsf, aIsFilled, thePickResult))
|
||||
if (!theMgr.OverlapsCircle(myRadius, myTrsf, aIsFilled, thePickResult))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (CenterOfGeometry()));
|
||||
thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(CenterOfGeometry()));
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected()
|
||||
{
|
||||
Standard_Boolean anIsFilled = mySensType == Select3D_TOS_INTERIOR;
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveCircle (myOwnerId,
|
||||
Circle(),
|
||||
anIsFilled);
|
||||
Standard_Boolean anIsFilled = mySensType == Select3D_TOS_INTERIOR;
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity =
|
||||
new Select3D_SensitiveCircle(myOwnerId, Circle(), anIsFilled);
|
||||
return aNewEntity;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: BoundingBox
|
||||
// Purpose :
|
||||
//==================================================
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_BndBox3d Select3D_SensitiveCircle::BoundingBox()
|
||||
{
|
||||
Graphic3d_Mat4d aTrsf;
|
||||
myTrsf.GetMat4 (aTrsf);
|
||||
myTrsf.GetMat4(aTrsf);
|
||||
|
||||
Select3D_BndBox3d aBox (SelectMgr_Vec3 (-myRadius, -myRadius, 0),
|
||||
SelectMgr_Vec3 (myRadius, myRadius, 0));
|
||||
aBox.Transform (aTrsf);
|
||||
Select3D_BndBox3d aBox(SelectMgr_Vec3(-myRadius, -myRadius, 0),
|
||||
SelectMgr_Vec3(myRadius, myRadius, 0));
|
||||
aBox.Transform(aTrsf);
|
||||
|
||||
return aBox;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: CenterOfGeometry
|
||||
// Purpose :
|
||||
//==================================================
|
||||
//=================================================================================================
|
||||
|
||||
gp_Pnt Select3D_SensitiveCircle::CenterOfGeometry() const
|
||||
{
|
||||
return gp_Pnt (myTrsf.TranslationPart());
|
||||
return gp_Pnt(myTrsf.TranslationPart());
|
||||
}
|
||||
|
@@ -26,27 +26,29 @@ class Select3D_SensitiveCircle : public Select3D_SensitiveEntity
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveCircle, Select3D_SensitiveEntity)
|
||||
public:
|
||||
|
||||
//! Constructs the sensitive circle object defined by the
|
||||
//! owner theOwnerId, the circle theCircle and the boolean theIsFilled.
|
||||
Standard_EXPORT Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Boolean theIsFilled = Standard_False);
|
||||
Standard_EXPORT Select3D_SensitiveCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Boolean theIsFilled = Standard_False);
|
||||
|
||||
//! Constructs the sensitive circle object defined by the
|
||||
//! owner theOwnerId, the circle theCircle, the boolean
|
||||
//! theIsFilled and the number of points theNbPnts.
|
||||
Standard_DEPRECATED("Deprecated constructor, theNbPnts parameter will be ignored")
|
||||
Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Boolean theIsFilled,
|
||||
const Standard_Integer /*theNbPnts*/)
|
||||
: Select3D_SensitiveCircle (theOwnerId, theCircle, theIsFilled)
|
||||
{ }
|
||||
|
||||
Select3D_SensitiveCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Boolean theIsFilled,
|
||||
const Standard_Integer /*theNbPnts*/)
|
||||
: Select3D_SensitiveCircle(theOwnerId, theCircle, theIsFilled)
|
||||
{
|
||||
}
|
||||
|
||||
//! Checks whether the circle overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns a copy of this sensitive circle
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
@@ -69,13 +71,12 @@ public:
|
||||
const gp_Trsf& Transformation() const { return myTrsf; }
|
||||
|
||||
//! Returns circle
|
||||
gp_Circ Circle() const { return gp_Circ (gp::XOY().Transformed (myTrsf), myRadius); }
|
||||
gp_Circ Circle() const { return gp_Circ(gp::XOY().Transformed(myTrsf), myRadius); }
|
||||
|
||||
//! Returns circle radius
|
||||
Standard_Real Radius() const { return myRadius; }
|
||||
|
||||
private:
|
||||
|
||||
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: boundary or interior
|
||||
gp_Trsf myTrsf; //!< Circle transformation to apply
|
||||
Standard_Real myRadius; //!< Circle radius
|
||||
|
@@ -18,42 +18,36 @@
|
||||
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCurve,Select3D_SensitivePoly)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCurve, Select3D_SensitivePoly)
|
||||
|
||||
//==================================================
|
||||
// Function: Creation
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints)
|
||||
: Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveCurve::Select3D_SensitiveCurve(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints)
|
||||
: Select3D_SensitivePoly(theOwnerId, thePoints, Standard_True)
|
||||
|
||||
{
|
||||
SetSensitivityFactor (3);
|
||||
SetSensitivityFactor(3);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Creation
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints)
|
||||
: Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveCurve::Select3D_SensitiveCurve(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints)
|
||||
: Select3D_SensitivePoly(theOwnerId, thePoints, Standard_True)
|
||||
{
|
||||
SetSensitivityFactor (3);
|
||||
SetSensitivityFactor(3);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveCurve::GetConnected()
|
||||
{
|
||||
Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt (1, myPolyg.Size());
|
||||
Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt(1, myPolyg.Size());
|
||||
for (Standard_Integer anIndex = 1; anIndex <= myPolyg.Size(); ++anIndex)
|
||||
{
|
||||
aPoints->SetValue (anIndex, myPolyg.Pnt (anIndex-1));
|
||||
aPoints->SetValue(anIndex, myPolyg.Pnt(anIndex - 1));
|
||||
}
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveCurve (myOwnerId, aPoints);
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveCurve(myOwnerId, aPoints);
|
||||
return aNewEntity;
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <SelectMgr_SelectingVolumeManager.hxx>
|
||||
|
||||
|
||||
//! A framework to define a sensitive 3D curve.
|
||||
//! In some cases this class can raise Standard_ConstructionError and
|
||||
//! Standard_OutOfRange exceptions. For more details see Select3D_SensitivePoly.
|
||||
@@ -30,46 +29,43 @@ class Select3D_SensitiveCurve : public Select3D_SensitivePoly
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveCurve, Select3D_SensitivePoly)
|
||||
public:
|
||||
|
||||
//! Constructs a sensitive curve object defined by the
|
||||
//! owner theOwnerId, the curve theCurve, and the
|
||||
//! maximum number of points on the curve: theNbPnts.
|
||||
Select3D_SensitiveCurve (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Geom_Curve)& theCurve,
|
||||
const Standard_Integer theNbPnts = 17)
|
||||
: Select3D_SensitivePoly (theOwnerId, Standard_True, theNbPnts)
|
||||
Select3D_SensitiveCurve(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Geom_Curve)& theCurve,
|
||||
const Standard_Integer theNbPnts = 17)
|
||||
: Select3D_SensitivePoly(theOwnerId, Standard_True, theNbPnts)
|
||||
{
|
||||
loadPoints (theCurve, theNbPnts);
|
||||
loadPoints(theCurve, theNbPnts);
|
||||
mySFactor = 3;
|
||||
}
|
||||
|
||||
//! Constructs a sensitive curve object defined by the
|
||||
//! owner theOwnerId and the set of points ThePoints.
|
||||
Standard_EXPORT Select3D_SensitiveCurve (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints);
|
||||
Standard_EXPORT Select3D_SensitiveCurve(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints);
|
||||
|
||||
//! Creation of Sensitive Curve from Points.
|
||||
//! Warning : This Method should disappear in the next version...
|
||||
Standard_EXPORT Select3D_SensitiveCurve (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints);
|
||||
Standard_EXPORT Select3D_SensitiveCurve(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints);
|
||||
|
||||
//! Returns the copy of this
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
void loadPoints (const Handle(Geom_Curve)& theCurve,
|
||||
const Standard_Integer theNbPnts)
|
||||
void loadPoints(const Handle(Geom_Curve)& theCurve, const Standard_Integer theNbPnts)
|
||||
{
|
||||
const Standard_Real aStep = (theCurve->LastParameter() - theCurve->FirstParameter()) / (theNbPnts - 1);
|
||||
const Standard_Real aStep =
|
||||
(theCurve->LastParameter() - theCurve->FirstParameter()) / (theNbPnts - 1);
|
||||
Standard_Real aParam = theCurve->FirstParameter();
|
||||
for (Standard_Integer aPntIdx = 0; aPntIdx < myPolyg.Size(); ++aPntIdx)
|
||||
{
|
||||
myPolyg.SetPnt (aPntIdx, theCurve->Value (aParam));
|
||||
myPolyg.SetPnt(aPntIdx, theCurve->Value(aParam));
|
||||
aParam += aStep;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveCurve, Select3D_SensitivePoly)
|
||||
|
@@ -17,87 +17,89 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCylinder, Select3D_SensitiveEntity)
|
||||
|
||||
//==================================================
|
||||
// Function: Select3D_SensitiveSphere
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitiveCylinder::Select3D_SensitiveCylinder (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theBottomRad,
|
||||
const Standard_Real theTopRad,
|
||||
const Standard_Real theHeight,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Boolean theIsHollow)
|
||||
: Select3D_SensitiveEntity (theOwnerId),
|
||||
myTrsf (theTrsf),
|
||||
myBottomRadius (theBottomRad),
|
||||
myTopRadius (theTopRad),
|
||||
myHeight (theHeight),
|
||||
myIsHollow (theIsHollow)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveCylinder::Select3D_SensitiveCylinder(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theBottomRad,
|
||||
const Standard_Real theTopRad,
|
||||
const Standard_Real theHeight,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Boolean theIsHollow)
|
||||
: Select3D_SensitiveEntity(theOwnerId),
|
||||
myTrsf(theTrsf),
|
||||
myBottomRadius(theBottomRad),
|
||||
myTopRadius(theTopRad),
|
||||
myHeight(theHeight),
|
||||
myIsHollow(theIsHollow)
|
||||
{
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Matches
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean Select3D_SensitiveCylinder::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveCylinder::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point)
|
||||
{
|
||||
if (!theMgr.IsOverlapAllowed())
|
||||
{
|
||||
bool isInside = true;
|
||||
return theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, myIsHollow, &isInside) && isInside;
|
||||
return theMgr.OverlapsCylinder(myBottomRadius,
|
||||
myTopRadius,
|
||||
myHeight,
|
||||
myTrsf,
|
||||
myIsHollow,
|
||||
&isInside)
|
||||
&& isInside;
|
||||
}
|
||||
else
|
||||
{
|
||||
return theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, myIsHollow, NULL);
|
||||
return theMgr
|
||||
.OverlapsCylinder(myBottomRadius, myTopRadius, myHeight, myTrsf, myIsHollow, NULL);
|
||||
}
|
||||
}
|
||||
if (!theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, myIsHollow, thePickResult))
|
||||
if (!theMgr.OverlapsCylinder(myBottomRadius,
|
||||
myTopRadius,
|
||||
myHeight,
|
||||
myTrsf,
|
||||
myIsHollow,
|
||||
thePickResult))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (CenterOfGeometry()));
|
||||
thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(CenterOfGeometry()));
|
||||
return true;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: GetConnected
|
||||
// Purpose :
|
||||
//==================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveCylinder::GetConnected()
|
||||
{
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveCylinder (myOwnerId, myBottomRadius,
|
||||
myTopRadius, myHeight,
|
||||
myTrsf);
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity =
|
||||
new Select3D_SensitiveCylinder(myOwnerId, myBottomRadius, myTopRadius, myHeight, myTrsf);
|
||||
return aNewEntity;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: BoundingBox
|
||||
// Purpose :
|
||||
//==================================================
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_BndBox3d Select3D_SensitiveCylinder::BoundingBox()
|
||||
{
|
||||
Standard_Real aMaxRad = Max (myBottomRadius, myTopRadius);
|
||||
Standard_Real aMaxRad = Max(myBottomRadius, myTopRadius);
|
||||
Graphic3d_Mat4d aTrsf;
|
||||
myTrsf.GetMat4 (aTrsf);
|
||||
myTrsf.GetMat4(aTrsf);
|
||||
|
||||
Select3D_BndBox3d aBox (SelectMgr_Vec3 (-aMaxRad, -aMaxRad, 0),
|
||||
SelectMgr_Vec3 (aMaxRad, aMaxRad, myHeight));
|
||||
aBox.Transform (aTrsf);
|
||||
Select3D_BndBox3d aBox(SelectMgr_Vec3(-aMaxRad, -aMaxRad, 0),
|
||||
SelectMgr_Vec3(aMaxRad, aMaxRad, myHeight));
|
||||
aBox.Transform(aTrsf);
|
||||
|
||||
return aBox;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: CenterOfGeometry
|
||||
// Purpose :
|
||||
//==================================================
|
||||
//=================================================================================================
|
||||
|
||||
gp_Pnt Select3D_SensitiveCylinder::CenterOfGeometry() const
|
||||
{
|
||||
return gp_Pnt (0, 0, myHeight / 2).Transformed (myTrsf);
|
||||
return gp_Pnt(0, 0, myHeight / 2).Transformed(myTrsf);
|
||||
}
|
||||
|
@@ -21,26 +21,27 @@
|
||||
//! A framework to define selection by a sensitive cylinder or cone.
|
||||
class Select3D_SensitiveCylinder : public Select3D_SensitiveEntity
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT (Select3D_SensitiveCylinder, Select3D_SensitiveEntity)
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveCylinder, Select3D_SensitiveEntity)
|
||||
|
||||
public:
|
||||
//! Constructs a sensitive cylinder object defined by the owner theOwnerId,
|
||||
//! @param[in] theBottomRad cylinder bottom radius
|
||||
//! @param[in] theTopRad cylinder top radius
|
||||
//! @param[in] theHeight cylinder height
|
||||
Standard_EXPORT Select3D_SensitiveCylinder (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theBottomRad,
|
||||
const Standard_Real theTopRad,
|
||||
const Standard_Real theHeight,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Boolean theIsHollow = Standard_False);
|
||||
Standard_EXPORT Select3D_SensitiveCylinder(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Real theBottomRad,
|
||||
const Standard_Real theTopRad,
|
||||
const Standard_Real theHeight,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Boolean theIsHollow = Standard_False);
|
||||
|
||||
//! Checks whether the cylinder overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns the copy of this
|
||||
Standard_EXPORT virtual Handle (Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of the cylinder.
|
||||
//! If location transformation is set, it will be applied
|
||||
|
@@ -20,37 +20,34 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveEntity, Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_SensitiveEntity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Select3D_SensitiveEntity::Select3D_SensitiveEntity (const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
: myOwnerId (theOwnerId),
|
||||
mySFactor (2)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
: myOwnerId(theOwnerId),
|
||||
mySFactor(2)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveEntity::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
//=================================================================================================
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwnerId.get())
|
||||
void Select3D_SensitiveEntity::DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myOwnerId.get())
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myTrsfPers.get())
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, mySFactor)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, NbSubElements());
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, NbSubElements());
|
||||
|
||||
gp_Pnt aCenterOfGeometry = CenterOfGeometry();
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aCenterOfGeometry)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &aCenterOfGeometry)
|
||||
|
||||
Standard_Boolean aHasInitLocation = HasInitLocation();
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aHasInitLocation)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, aHasInitLocation)
|
||||
|
||||
gp_GTrsf anInvInitLocation = InvInitLocation();
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &anInvInitLocation)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &anInvInitLocation)
|
||||
}
|
||||
|
@@ -30,41 +30,45 @@ class Select3D_SensitiveEntity : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveEntity, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Returns pointer to owner of the entity
|
||||
const Handle(SelectMgr_EntityOwner)& OwnerId() const { return myOwnerId; }
|
||||
|
||||
//! Sets owner of the entity
|
||||
virtual void Set (const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
{
|
||||
myOwnerId = theOwnerId;
|
||||
}
|
||||
virtual void Set(const Handle(SelectMgr_EntityOwner)& theOwnerId) { myOwnerId = theOwnerId; }
|
||||
|
||||
//! allows a better sensitivity for a specific entity in selection algorithms useful for small sized entities.
|
||||
//! allows a better sensitivity for a specific entity in selection algorithms useful for small
|
||||
//! sized entities.
|
||||
Standard_Integer SensitivityFactor() const { return mySFactor; }
|
||||
|
||||
//! Allows to manage sensitivity of a particular sensitive entity
|
||||
void SetSensitivityFactor (const Standard_Integer theNewSens)
|
||||
void SetSensitivityFactor(const Standard_Integer theNewSens)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theNewSens >= 0, "Error! Selection sensitivity should not be negative value.");
|
||||
Standard_ASSERT_RAISE(theNewSens >= 0,
|
||||
"Error! Selection sensitivity should not be negative value.");
|
||||
mySFactor = theNewSens;
|
||||
}
|
||||
|
||||
//! Originally this method intended to return sensitive entity with new location aLocation,
|
||||
//! but currently sensitive entities do not hold a location,
|
||||
//! instead HasLocation() and Location() methods call corresponding entity owner's methods.
|
||||
//! Thus all entities returned by GetConnected() share the same location propagated from corresponding selectable object.
|
||||
//! You must redefine this function for any type of sensitive entity which can accept another connected sensitive entity.
|
||||
virtual Handle(Select3D_SensitiveEntity) GetConnected() { return Handle(Select3D_SensitiveEntity)(); }
|
||||
//! Thus all entities returned by GetConnected() share the same location propagated from
|
||||
//! corresponding selectable object. You must redefine this function for any type of sensitive
|
||||
//! entity which can accept another connected sensitive entity.
|
||||
virtual Handle(Select3D_SensitiveEntity) GetConnected()
|
||||
{
|
||||
return Handle(Select3D_SensitiveEntity)();
|
||||
}
|
||||
|
||||
//! Checks whether sensitive overlaps current selecting volume.
|
||||
//! Stores minimum depth, distance to center of geometry and closest point detected into thePickResult
|
||||
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) = 0;
|
||||
//! Stores minimum depth, distance to center of geometry and closest point detected into
|
||||
//! thePickResult
|
||||
virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) = 0;
|
||||
|
||||
//! Returns the number of sub-entities or elements in sensitive entity.
|
||||
//! Is used to determine if entity is complex and needs to pre-build BVH at the creation of sensitive entity step
|
||||
//! or is light-weighted so the tree can be build on demand with unnoticeable delay.
|
||||
//! Is used to determine if entity is complex and needs to pre-build BVH at the creation of
|
||||
//! sensitive entity step or is light-weighted so the tree can be build on demand with
|
||||
//! unnoticeable delay.
|
||||
virtual Standard_Integer NbSubElements() const = 0;
|
||||
|
||||
//! Returns bounding box of a sensitive with transformation applied
|
||||
@@ -80,39 +84,41 @@ public:
|
||||
virtual Standard_Boolean ToBuildBVH() const { return Standard_True; }
|
||||
|
||||
//! Clears up all resources and memory
|
||||
virtual void Clear() { Set (Handle(SelectMgr_EntityOwner)()); }
|
||||
virtual void Clear() { Set(Handle(SelectMgr_EntityOwner)()); }
|
||||
|
||||
//! Returns true if the shape corresponding to the entity has init location
|
||||
virtual Standard_Boolean HasInitLocation() const { return Standard_False; }
|
||||
|
||||
//! Returns inversed location transformation matrix if the shape corresponding to this entity has init location set.
|
||||
//! Otherwise, returns identity matrix.
|
||||
//! Returns inversed location transformation matrix if the shape corresponding to this entity has
|
||||
//! init location set. Otherwise, returns identity matrix.
|
||||
virtual gp_GTrsf InvInitLocation() const { return gp_GTrsf(); }
|
||||
|
||||
//! Return transformation persistence.
|
||||
const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
|
||||
|
||||
//! Set transformation persistence.
|
||||
virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
|
||||
virtual void SetTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
{
|
||||
myTrsfPers = theTrsfPers;
|
||||
}
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT Select3D_SensitiveEntity (const Handle(SelectMgr_EntityOwner)& theOwnerId);
|
||||
Standard_EXPORT Select3D_SensitiveEntity(const Handle(SelectMgr_EntityOwner)& theOwnerId);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(SelectMgr_EntityOwner) myOwnerId;
|
||||
Handle(SelectMgr_EntityOwner) myOwnerId;
|
||||
Handle(Graphic3d_TransformPers) myTrsfPers;
|
||||
Standard_Integer mySFactor;
|
||||
|
||||
Standard_Integer mySFactor;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveEntity, Standard_Transient)
|
||||
|
||||
Standard_DEPRECATED("Deprecated alias - Select3D_SensitiveEntity should be used instead")
|
||||
Standard_DEPRECATED("Deprecated alias - Select3D_SensitiveEntity should be used "
|
||||
"instead")
|
||||
typedef Select3D_SensitiveEntity SelectBasics_SensitiveEntity;
|
||||
|
||||
#endif // _Select3D_SensitiveEntity_HeaderFile
|
||||
|
@@ -18,45 +18,43 @@
|
||||
|
||||
#include <Select3D_InteriorSensitivePointSet.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveFace,Select3D_SensitiveEntity)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveFace, Select3D_SensitiveEntity)
|
||||
|
||||
//==================================================
|
||||
// Function: Hide this constructor to the next version...
|
||||
// Purpose : simply avoid interfering with the version update
|
||||
//==================================================
|
||||
Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints,
|
||||
const Select3D_TypeOfSensitivity theType)
|
||||
: Select3D_SensitiveEntity (theOwnerId),
|
||||
mySensType (theType)
|
||||
Select3D_SensitiveFace::Select3D_SensitiveFace(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints,
|
||||
const Select3D_TypeOfSensitivity theType)
|
||||
: Select3D_SensitiveEntity(theOwnerId),
|
||||
mySensType(theType)
|
||||
{
|
||||
if (mySensType == Select3D_TOS_INTERIOR)
|
||||
{
|
||||
myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints);
|
||||
myFacePoints = new Select3D_InteriorSensitivePointSet(theOwnerId, thePoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True);
|
||||
myFacePoints = new Select3D_SensitivePoly(theOwnerId, thePoints, Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Creation
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints,
|
||||
const Select3D_TypeOfSensitivity theType)
|
||||
: Select3D_SensitiveEntity (theOwnerId),
|
||||
mySensType (theType)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveFace::Select3D_SensitiveFace(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints,
|
||||
const Select3D_TypeOfSensitivity theType)
|
||||
: Select3D_SensitiveEntity(theOwnerId),
|
||||
mySensType(theType)
|
||||
{
|
||||
if (mySensType == Select3D_TOS_INTERIOR)
|
||||
{
|
||||
myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints->Array1());
|
||||
myFacePoints = new Select3D_InteriorSensitivePointSet(theOwnerId, thePoints->Array1());
|
||||
}
|
||||
else
|
||||
{
|
||||
myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints->Array1(), Standard_True);
|
||||
myFacePoints = new Select3D_SensitivePoly(theOwnerId, thePoints->Array1(), Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,17 +63,16 @@ Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwn
|
||||
// purpose : Initializes the given array theHArrayOfPnt by 3d
|
||||
// coordinates of vertices of the face
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveFace::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
|
||||
void Select3D_SensitiveFace::GetPoints(Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
|
||||
{
|
||||
if (myFacePoints->IsKind(STANDARD_TYPE(Select3D_SensitivePoly)))
|
||||
{
|
||||
Handle(Select3D_SensitivePoly)::DownCast (myFacePoints)->Points3D (theHArrayOfPnt);
|
||||
Handle(Select3D_SensitivePoly)::DownCast(myFacePoints)->Points3D(theHArrayOfPnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(Select3D_InteriorSensitivePointSet)::DownCast (myFacePoints)->GetPoints (theHArrayOfPnt);
|
||||
Handle(Select3D_InteriorSensitivePointSet)::DownCast(myFacePoints)->GetPoints(theHArrayOfPnt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -91,24 +88,22 @@ void Select3D_SensitiveFace::BVH()
|
||||
// function : Matches
|
||||
// purpose : Checks whether the face overlaps current selecting volume
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveFace::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_Boolean Select3D_SensitiveFace::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
return myFacePoints->Matches (theMgr, thePickResult);
|
||||
return myFacePoints->Matches(theMgr, thePickResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected()
|
||||
{
|
||||
// Create a copy of this
|
||||
Handle(TColgp_HArray1OfPnt) aPoints;
|
||||
GetPoints (aPoints);
|
||||
GetPoints(aPoints);
|
||||
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity =
|
||||
new Select3D_SensitiveFace (myOwnerId, aPoints, mySensType);
|
||||
new Select3D_SensitiveFace(myOwnerId, aPoints, mySensType);
|
||||
|
||||
return aNewEntity;
|
||||
}
|
||||
@@ -143,15 +138,13 @@ Standard_Integer Select3D_SensitiveFace::NbSubElements() const
|
||||
return myFacePoints->NbSubElements();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveFace::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
//=================================================================================================
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySensType)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFacePoints.get())
|
||||
void Select3D_SensitiveFace::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, mySensType)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myFacePoints.get())
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <SelectBasics_SelectingVolumeManager.hxx>
|
||||
|
||||
|
||||
//! Sensitive Entity to make a face selectable.
|
||||
//! In some cases this class can raise Standard_ConstructionError and
|
||||
//! Standard_OutOfRange exceptions. For more details see Select3D_SensitivePoly.
|
||||
@@ -30,30 +29,30 @@ class Select3D_SensitiveFace : public Select3D_SensitiveEntity
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveFace, Select3D_SensitiveEntity)
|
||||
public:
|
||||
//! Constructs a sensitive face object defined by the
|
||||
//! owner theOwnerId, the array of points thePoints, and
|
||||
//! the sensitivity type theType.
|
||||
//! The array of points is the outer polygon of the geometric face.
|
||||
Standard_EXPORT Select3D_SensitiveFace(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints,
|
||||
const Select3D_TypeOfSensitivity theType);
|
||||
|
||||
//! Constructs a sensitive face object defined by the
|
||||
//! owner theOwnerId, the array of points thePoints, and
|
||||
//! the sensitivity type theType.
|
||||
//! The array of points is the outer polygon of the geometric face.
|
||||
Standard_EXPORT Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints,
|
||||
const Select3D_TypeOfSensitivity theType);
|
||||
|
||||
//! Constructs a sensitive face object defined by the
|
||||
//! owner theOwnerId, the array of points thePoints, and
|
||||
//! the sensitivity type theType.
|
||||
//! The array of points is the outer polygon of the geometric face.
|
||||
Standard_EXPORT Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints,
|
||||
const Select3D_TypeOfSensitivity theType);
|
||||
Standard_EXPORT Select3D_SensitiveFace(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints,
|
||||
const Select3D_TypeOfSensitivity theType);
|
||||
|
||||
//! Initializes the given array theHArrayOfPnt by 3d
|
||||
//! coordinates of vertices of the face
|
||||
Standard_EXPORT void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
|
||||
Standard_EXPORT void GetPoints(Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
|
||||
|
||||
//! Checks whether the face overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
|
||||
@@ -69,20 +68,23 @@ public:
|
||||
Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
|
||||
|
||||
//! Returns TRUE if BVH tree is in invalidated state
|
||||
virtual Standard_Boolean ToBuildBVH() const Standard_OVERRIDE { return myFacePoints->ToBuildBVH(); }
|
||||
virtual Standard_Boolean ToBuildBVH() const Standard_OVERRIDE
|
||||
{
|
||||
return myFacePoints->ToBuildBVH();
|
||||
}
|
||||
|
||||
//! Returns the amount of sub-entities (points or planar convex polygons)
|
||||
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: interior or boundary
|
||||
// clang-format off
|
||||
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: interior or boundary
|
||||
// clang-format off
|
||||
Handle(Select3D_SensitiveSet) myFacePoints; //!< Wrapper for overlap detection created depending on sensitivity type
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveFace, Select3D_SensitiveEntity)
|
||||
|
@@ -16,145 +16,135 @@
|
||||
|
||||
#include <Select3D_SensitiveGroup.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveGroup,Select3D_SensitiveSet)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveGroup, Select3D_SensitiveSet)
|
||||
|
||||
//=======================================================================
|
||||
//function : Creation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Select3D_SensitiveGroup::Select3D_SensitiveGroup (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Boolean theIsMustMatchAll)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myMustMatchAll (theIsMustMatchAll),
|
||||
myToCheckOverlapAll (Standard_False),
|
||||
myCenter (0.0, 0.0, 0.0) {}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : Creation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Select3D_SensitiveGroup::Select3D_SensitiveGroup (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
Select3D_EntitySequence& theEntities,
|
||||
const Standard_Boolean theIsMustMatchAll)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myEntities (Max (1, theEntities.Size())),
|
||||
myMustMatchAll (theIsMustMatchAll),
|
||||
myToCheckOverlapAll (Standard_False),
|
||||
myCenter (0.0, 0.0, 0.0)
|
||||
Select3D_SensitiveGroup::Select3D_SensitiveGroup(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Boolean theIsMustMatchAll)
|
||||
: Select3D_SensitiveSet(theOwnerId),
|
||||
myMustMatchAll(theIsMustMatchAll),
|
||||
myToCheckOverlapAll(Standard_False),
|
||||
myCenter(0.0, 0.0, 0.0)
|
||||
{
|
||||
for (Select3D_EntitySequenceIter anIter (theEntities); anIter.More(); anIter.Next())
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveGroup::Select3D_SensitiveGroup(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
Select3D_EntitySequence& theEntities,
|
||||
const Standard_Boolean theIsMustMatchAll)
|
||||
: Select3D_SensitiveSet(theOwnerId),
|
||||
myEntities(Max(1, theEntities.Size())),
|
||||
myMustMatchAll(theIsMustMatchAll),
|
||||
myToCheckOverlapAll(Standard_False),
|
||||
myCenter(0.0, 0.0, 0.0)
|
||||
{
|
||||
for (Select3D_EntitySequenceIter anIter(theEntities); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(Select3D_SensitiveEntity)& anEntity = anIter.Value();
|
||||
const Standard_Integer aPrevExtent = myEntities.Extent();
|
||||
if (myEntities.Add (anEntity) <= aPrevExtent)
|
||||
const Handle(Select3D_SensitiveEntity)& anEntity = anIter.Value();
|
||||
const Standard_Integer aPrevExtent = myEntities.Extent();
|
||||
if (myEntities.Add(anEntity) <= aPrevExtent)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
myBndBox.Combine (anEntity->BoundingBox());
|
||||
myBVHPrimIndexes.Append (myEntities.Extent());
|
||||
myBndBox.Combine(anEntity->BoundingBox());
|
||||
myBVHPrimIndexes.Append(myEntities.Extent());
|
||||
myCenter.ChangeCoord() += anEntity->CenterOfGeometry().XYZ();
|
||||
}
|
||||
|
||||
myCenter.ChangeCoord().Divide (static_cast<Standard_Real> (myEntities.Extent()));
|
||||
myCenter.ChangeCoord().Divide(static_cast<Standard_Real>(myEntities.Extent()));
|
||||
|
||||
MarkDirty();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : No control of entities inside
|
||||
// function : Add
|
||||
// purpose : No control of entities inside
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveGroup::Add (Select3D_EntitySequence& theEntities)
|
||||
void Select3D_SensitiveGroup::Add(Select3D_EntitySequence& theEntities)
|
||||
{
|
||||
if (theEntities.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Pnt aCent (0.0, 0.0, 0.0);
|
||||
myEntities.ReSize (myEntities.Extent() + theEntities.Size());
|
||||
for (Select3D_EntitySequenceIter anIter (theEntities); anIter.More(); anIter.Next())
|
||||
gp_Pnt aCent(0.0, 0.0, 0.0);
|
||||
myEntities.ReSize(myEntities.Extent() + theEntities.Size());
|
||||
for (Select3D_EntitySequenceIter anIter(theEntities); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(Select3D_SensitiveEntity)& anEntity = anIter.Value();
|
||||
const Standard_Integer aPrevExtent = myEntities.Extent();
|
||||
if (myEntities.Add (anEntity) <= aPrevExtent)
|
||||
const Handle(Select3D_SensitiveEntity)& anEntity = anIter.Value();
|
||||
const Standard_Integer aPrevExtent = myEntities.Extent();
|
||||
if (myEntities.Add(anEntity) <= aPrevExtent)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
myBndBox.Combine (anEntity->BoundingBox());
|
||||
myBVHPrimIndexes.Append (myEntities.Extent());
|
||||
myBndBox.Combine(anEntity->BoundingBox());
|
||||
myBVHPrimIndexes.Append(myEntities.Extent());
|
||||
aCent.ChangeCoord() += anEntity->CenterOfGeometry().XYZ();
|
||||
}
|
||||
aCent.ChangeCoord().Divide (myEntities.Extent());
|
||||
myCenter = (myCenter.XYZ() + aCent.XYZ()).Multiplied (0.5);
|
||||
aCent.ChangeCoord().Divide(myEntities.Extent());
|
||||
myCenter = (myCenter.XYZ() + aCent.XYZ()).Multiplied(0.5);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveGroup::Add (const Handle(Select3D_SensitiveEntity)& theSensitive)
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveGroup::Add(const Handle(Select3D_SensitiveEntity)& theSensitive)
|
||||
{
|
||||
const Standard_Integer aPrevExtent = myEntities.Extent();
|
||||
if (myEntities.Add (theSensitive) <= aPrevExtent)
|
||||
if (myEntities.Add(theSensitive) <= aPrevExtent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myBVHPrimIndexes.Append (myEntities.Extent());
|
||||
myBndBox.Combine (theSensitive->BoundingBox());
|
||||
myBVHPrimIndexes.Append(myEntities.Extent());
|
||||
myBndBox.Combine(theSensitive->BoundingBox());
|
||||
myCenter.ChangeCoord() += theSensitive->CenterOfGeometry().XYZ();
|
||||
if (myEntities.Extent() >= 2)
|
||||
{
|
||||
myCenter.ChangeCoord().Multiply (0.5);
|
||||
myCenter.ChangeCoord().Multiply(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Remove
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveGroup::Remove (const Handle(Select3D_SensitiveEntity)& theSensitive)
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveGroup::Remove(const Handle(Select3D_SensitiveEntity)& theSensitive)
|
||||
{
|
||||
if (!myEntities.RemoveKey (theSensitive))
|
||||
if (!myEntities.RemoveKey(theSensitive))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myBndBox.Clear();
|
||||
myCenter = gp_Pnt (0.0, 0.0, 0.0);
|
||||
myCenter = gp_Pnt(0.0, 0.0, 0.0);
|
||||
myBVHPrimIndexes.Clear();
|
||||
for (Standard_Integer anIdx = 1; anIdx <= myEntities.Size(); ++anIdx)
|
||||
{
|
||||
const Handle(Select3D_SensitiveEntity)& anEntity = myEntities.FindKey (anIdx);
|
||||
myBndBox.Combine (anEntity->BoundingBox());
|
||||
const Handle(Select3D_SensitiveEntity)& anEntity = myEntities.FindKey(anIdx);
|
||||
myBndBox.Combine(anEntity->BoundingBox());
|
||||
myCenter.ChangeCoord() += anEntity->CenterOfGeometry().XYZ();
|
||||
myBVHPrimIndexes.Append (anIdx);
|
||||
myBVHPrimIndexes.Append(anIdx);
|
||||
}
|
||||
myCenter.ChangeCoord().Divide (static_cast<Standard_Real> (myEntities.Extent()));
|
||||
myCenter.ChangeCoord().Divide(static_cast<Standard_Real>(myEntities.Extent()));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsIn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveGroup::IsIn (const Handle(Select3D_SensitiveEntity)& theSensitive) const
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveGroup::IsIn(
|
||||
const Handle(Select3D_SensitiveEntity)& theSensitive) const
|
||||
{
|
||||
return myEntities.Contains (theSensitive);
|
||||
return myEntities.Contains(theSensitive);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveGroup::Clear()
|
||||
{
|
||||
myEntities.Clear();
|
||||
myBndBox.Clear();
|
||||
myCenter = gp_Pnt (0.0, 0.0, 0.0);
|
||||
myCenter = gp_Pnt(0.0, 0.0, 0.0);
|
||||
myBVHPrimIndexes.Clear();
|
||||
}
|
||||
|
||||
@@ -167,45 +157,43 @@ Standard_Integer Select3D_SensitiveGroup::NbSubElements() const
|
||||
return myEntities.Size();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveGroup::GetConnected()
|
||||
{
|
||||
Handle(Select3D_SensitiveGroup) aNewEntity = new Select3D_SensitiveGroup (myOwnerId, myMustMatchAll);
|
||||
Handle(Select3D_SensitiveGroup) aNewEntity =
|
||||
new Select3D_SensitiveGroup(myOwnerId, myMustMatchAll);
|
||||
Select3D_EntitySequence aConnectedEnt;
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter(myEntities); anEntityIter.More();
|
||||
anEntityIter.Next())
|
||||
{
|
||||
aConnectedEnt.Append (anEntityIter.Value()->GetConnected());
|
||||
aConnectedEnt.Append(anEntityIter.Value()->GetConnected());
|
||||
}
|
||||
aNewEntity->Add (aConnectedEnt);
|
||||
aNewEntity->Add(aConnectedEnt);
|
||||
return aNewEntity;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Matches
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveGroup::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
const Standard_Boolean toMatchAll = theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point
|
||||
&& myMustMatchAll;
|
||||
const Standard_Boolean toCheckAll = theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point
|
||||
&& myToCheckOverlapAll;
|
||||
const Standard_Boolean toMatchAll =
|
||||
theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point && myMustMatchAll;
|
||||
const Standard_Boolean toCheckAll =
|
||||
theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point && myToCheckOverlapAll;
|
||||
if (!toMatchAll && !toCheckAll)
|
||||
{
|
||||
return Select3D_SensitiveSet::Matches (theMgr, thePickResult);
|
||||
return Select3D_SensitiveSet::Matches(theMgr, thePickResult);
|
||||
}
|
||||
|
||||
SelectBasics_PickResult aPickResult;
|
||||
Standard_Boolean isFailed = Standard_False;
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
|
||||
Standard_Boolean isFailed = Standard_False;
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter(myEntities); anEntityIter.More();
|
||||
anEntityIter.Next())
|
||||
{
|
||||
const Handle(Select3D_SensitiveEntity)& aChild = anEntityIter.Value();
|
||||
if (!aChild->Matches (theMgr, aPickResult))
|
||||
if (!aChild->Matches(theMgr, aPickResult))
|
||||
{
|
||||
if (toMatchAll)
|
||||
{
|
||||
@@ -218,7 +206,7 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
|
||||
}
|
||||
else
|
||||
{
|
||||
thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
|
||||
thePickResult = SelectBasics_PickResult::Min(thePickResult, aPickResult);
|
||||
}
|
||||
}
|
||||
if (isFailed)
|
||||
@@ -230,16 +218,15 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveGroup::Set (const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
{
|
||||
Select3D_SensitiveEntity::Set (theOwnerId);
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveGroup::Set(const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
{
|
||||
Select3D_SensitiveEntity::Set(theOwnerId);
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter(myEntities); anEntityIter.More();
|
||||
anEntityIter.Next())
|
||||
{
|
||||
anEntityIter.Value()->Set (theOwnerId);
|
||||
anEntityIter.Value()->Set(theOwnerId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,9 +242,10 @@ Select3D_BndBox3d Select3D_SensitiveGroup::BoundingBox()
|
||||
|
||||
// do not apply the transformation because sensitives AABBs
|
||||
// are already transformed
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anEntityIter(myEntities); anEntityIter.More();
|
||||
anEntityIter.Next())
|
||||
{
|
||||
myBndBox.Combine (anEntityIter.Value()->BoundingBox());
|
||||
myBndBox.Combine(anEntityIter.Value()->BoundingBox());
|
||||
}
|
||||
|
||||
return myBndBox;
|
||||
@@ -277,10 +265,10 @@ gp_Pnt Select3D_SensitiveGroup::CenterOfGeometry() const
|
||||
// function : Box
|
||||
// purpose : Returns bounding box of sensitive entity with index theIdx
|
||||
//=======================================================================
|
||||
Select3D_BndBox3d Select3D_SensitiveGroup::Box (const Standard_Integer theIdx) const
|
||||
Select3D_BndBox3d Select3D_SensitiveGroup::Box(const Standard_Integer theIdx) const
|
||||
{
|
||||
const Standard_Integer anElemIdx = myBVHPrimIndexes.Value (theIdx);
|
||||
return myEntities.FindKey (anElemIdx)->BoundingBox();
|
||||
const Standard_Integer anElemIdx = myBVHPrimIndexes.Value(theIdx);
|
||||
return myEntities.FindKey(anElemIdx)->BoundingBox();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -288,11 +276,11 @@ Select3D_BndBox3d Select3D_SensitiveGroup::Box (const Standard_Integer theIdx) c
|
||||
// purpose : Returns geometry center of sensitive entity with index
|
||||
// theIdx in the vector along the given axis theAxis
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveGroup::Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_Real Select3D_SensitiveGroup::Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
{
|
||||
const Standard_Integer anElemIdx = myBVHPrimIndexes.Value (theIdx);
|
||||
const gp_Pnt aCenter = myEntities.FindKey (anElemIdx)->CenterOfGeometry();
|
||||
const Standard_Integer anElemIdx = myBVHPrimIndexes.Value(theIdx);
|
||||
const gp_Pnt aCenter = myEntities.FindKey(anElemIdx)->CenterOfGeometry();
|
||||
return theAxis == 0 ? aCenter.X() : (theAxis == 1 ? aCenter.Y() : aCenter.Z());
|
||||
}
|
||||
|
||||
@@ -300,14 +288,13 @@ Standard_Real Select3D_SensitiveGroup::Center (const Standard_Integer theIdx,
|
||||
// function : Swap
|
||||
// purpose : Swaps items with indexes theIdx1 and theIdx2 in the vector
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveGroup::Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2)
|
||||
void Select3D_SensitiveGroup::Swap(const Standard_Integer theIdx1, const Standard_Integer theIdx2)
|
||||
{
|
||||
const Standard_Integer anEntIdx1 = myBVHPrimIndexes.Value (theIdx1);
|
||||
const Standard_Integer anEntIdx2 = myBVHPrimIndexes.Value (theIdx2);
|
||||
const Standard_Integer anEntIdx1 = myBVHPrimIndexes.Value(theIdx1);
|
||||
const Standard_Integer anEntIdx2 = myBVHPrimIndexes.Value(theIdx2);
|
||||
|
||||
myBVHPrimIndexes.ChangeValue (theIdx1) = anEntIdx2;
|
||||
myBVHPrimIndexes.ChangeValue (theIdx2) = anEntIdx1;
|
||||
myBVHPrimIndexes.ChangeValue(theIdx1) = anEntIdx2;
|
||||
myBVHPrimIndexes.ChangeValue(theIdx2) = anEntIdx1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -324,13 +311,14 @@ Standard_Integer Select3D_SensitiveGroup::Size() const
|
||||
// purpose : Checks whether the entity with index theIdx overlaps the
|
||||
// current selecting volume
|
||||
// =======================================================================
|
||||
Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean )
|
||||
Standard_Boolean Select3D_SensitiveGroup::overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean)
|
||||
{
|
||||
const Standard_Integer aSensitiveIdx = myBVHPrimIndexes.Value (theElemIdx);
|
||||
if (myEntities.FindKey (aSensitiveIdx)->Matches (theMgr, thePickResult))
|
||||
const Standard_Integer aSensitiveIdx = myBVHPrimIndexes.Value(theElemIdx);
|
||||
if (myEntities.FindKey(aSensitiveIdx)->Matches(theMgr, thePickResult))
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -342,12 +330,13 @@ Standard_Boolean Select3D_SensitiveGroup::overlapsElement (SelectBasics_PickResu
|
||||
// function : elementIsInside
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
Standard_Boolean Select3D_SensitiveGroup::elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
{
|
||||
SelectBasics_PickResult aDummy;
|
||||
return overlapsElement (aDummy, theMgr, theElemIdx, theIsFullInside);
|
||||
return overlapsElement(aDummy, theMgr, theElemIdx, theIsFullInside);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -355,28 +344,30 @@ Standard_Boolean Select3D_SensitiveGroup::elementIsInside (SelectBasics_Selectin
|
||||
// purpose : Calculates distance from the 3d projection of used-picked
|
||||
// screen point to center of the geometry
|
||||
// =======================================================================
|
||||
Standard_Real Select3D_SensitiveGroup::distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr)
|
||||
Standard_Real Select3D_SensitiveGroup::distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr)
|
||||
{
|
||||
return theMgr.DistToGeometryCenter (CenterOfGeometry());
|
||||
return theMgr.DistToGeometryCenter(CenterOfGeometry());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : DumpJson
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Select3D_SensitiveGroup::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
void Select3D_SensitiveGroup::DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet)
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveSet)
|
||||
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next())
|
||||
for (Select3D_IndexedMapOfEntity::Iterator anIterator(myEntities); anIterator.More();
|
||||
anIterator.Next())
|
||||
{
|
||||
const Handle(Select3D_SensitiveEntity)& anEntity = anIterator.Value();
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anEntity.get())
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, anEntity.get())
|
||||
}
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMustMatchAll)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToCheckOverlapAll)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myMustMatchAll)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myToCheckOverlapAll)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBndBox)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myBndBox)
|
||||
}
|
||||
|
@@ -33,48 +33,50 @@ class Select3D_SensitiveGroup : public Select3D_SensitiveSet
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveGroup, Select3D_SensitiveSet)
|
||||
public:
|
||||
|
||||
//! Constructs an empty sensitive group object.
|
||||
//! This is a set of sensitive 3D entities. The sensitive
|
||||
//! entities will be defined using the function Add to fill
|
||||
//! the entity owner OwnerId. If MatchAll is false, nothing can be added.
|
||||
Standard_EXPORT Select3D_SensitiveGroup (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Boolean theIsMustMatchAll = Standard_True);
|
||||
Standard_EXPORT Select3D_SensitiveGroup(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Boolean theIsMustMatchAll = Standard_True);
|
||||
|
||||
//! Constructs a sensitive group object defined by the list
|
||||
//! TheList and the entity owner OwnerId. If MatchAll is false, nothing is done.
|
||||
Standard_EXPORT Select3D_SensitiveGroup (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
Select3D_EntitySequence& theEntities,
|
||||
const Standard_Boolean theIsMustMatchAll = Standard_True);
|
||||
Standard_EXPORT Select3D_SensitiveGroup(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
Select3D_EntitySequence& theEntities,
|
||||
const Standard_Boolean theIsMustMatchAll = Standard_True);
|
||||
|
||||
//! Gets group content
|
||||
const Select3D_IndexedMapOfEntity& Entities() const { return myEntities; }
|
||||
|
||||
//! Access entity by index [1, NbSubElements()].
|
||||
const Handle(Select3D_SensitiveEntity)& SubEntity (const Standard_Integer theIndex) const
|
||||
const Handle(Select3D_SensitiveEntity)& SubEntity(const Standard_Integer theIndex) const
|
||||
{
|
||||
return myEntities.FindKey (theIndex);
|
||||
return myEntities.FindKey(theIndex);
|
||||
}
|
||||
|
||||
//! Return last detected entity.
|
||||
Handle(Select3D_SensitiveEntity) LastDetectedEntity() const
|
||||
{
|
||||
const Standard_Integer anIndex = LastDetectedEntityIndex();
|
||||
return anIndex != -1 ? myEntities.FindKey (anIndex) : Handle(Select3D_SensitiveEntity)();
|
||||
return anIndex != -1 ? myEntities.FindKey(anIndex) : Handle(Select3D_SensitiveEntity)();
|
||||
}
|
||||
|
||||
//! Return index of last detected entity.
|
||||
Standard_Integer LastDetectedEntityIndex() const { return myDetectedIdx != -1 ? myBVHPrimIndexes.Value (myDetectedIdx) : -1; }
|
||||
Standard_Integer LastDetectedEntityIndex() const
|
||||
{
|
||||
return myDetectedIdx != -1 ? myBVHPrimIndexes.Value(myDetectedIdx) : -1;
|
||||
}
|
||||
|
||||
//! Adds the list of sensitive entities LL to the empty
|
||||
//! sensitive group object created at construction time.
|
||||
Standard_EXPORT void Add (Select3D_EntitySequence& theEntities);
|
||||
Standard_EXPORT void Add(Select3D_EntitySequence& theEntities);
|
||||
|
||||
//! Adds the sensitive entity aSensitive to the non-empty
|
||||
//! sensitive group object created at construction time.
|
||||
Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive);
|
||||
Standard_EXPORT void Add(const Handle(Select3D_SensitiveEntity)& theSensitive);
|
||||
|
||||
Standard_EXPORT void Remove (const Handle(Select3D_SensitiveEntity)& theSensitive);
|
||||
Standard_EXPORT void Remove(const Handle(Select3D_SensitiveEntity)& theSensitive);
|
||||
|
||||
//! Removes all sensitive entities from the list used at the
|
||||
//! time of construction, or added using the function Add.
|
||||
@@ -82,34 +84,34 @@ public:
|
||||
|
||||
//! Returns true if the sensitive entity aSensitive is in
|
||||
//! the list used at the time of construction, or added using the function Add.
|
||||
Standard_EXPORT Standard_Boolean IsIn (const Handle(Select3D_SensitiveEntity)& theSensitive) const;
|
||||
Standard_EXPORT Standard_Boolean IsIn(const Handle(Select3D_SensitiveEntity)& theSensitive) const;
|
||||
|
||||
//! Sets the requirement that all sensitive entities in the
|
||||
//! list used at the time of construction, or added using
|
||||
//! the function Add must be matched.
|
||||
void SetMatchType (const Standard_Boolean theIsMustMatchAll) { myMustMatchAll = theIsMustMatchAll; }
|
||||
void SetMatchType(const Standard_Boolean theIsMustMatchAll)
|
||||
{
|
||||
myMustMatchAll = theIsMustMatchAll;
|
||||
}
|
||||
|
||||
//! Returns true if all sensitive entities in the list used
|
||||
//! at the time of construction, or added using the function Add must be matched.
|
||||
Standard_Boolean MustMatchAll() const { return myMustMatchAll; }
|
||||
|
||||
//! Returns TRUE if all sensitive entities should be checked within rectangular/polygonal selection, FALSE by default.
|
||||
//! Can be useful for sensitive entities holding detection results as class property.
|
||||
Standard_Boolean ToCheckOverlapAll() const
|
||||
{
|
||||
return myToCheckOverlapAll;
|
||||
}
|
||||
//! Returns TRUE if all sensitive entities should be checked within rectangular/polygonal
|
||||
//! selection, FALSE by default. Can be useful for sensitive entities holding detection results as
|
||||
//! class property.
|
||||
Standard_Boolean ToCheckOverlapAll() const { return myToCheckOverlapAll; }
|
||||
|
||||
//! Returns TRUE if all sensitive entities should be checked within rectangular/polygonal selection, FALSE by default.
|
||||
//! Can be useful for sensitive entities holding detection results as class property.
|
||||
void SetCheckOverlapAll (Standard_Boolean theToCheckAll)
|
||||
{
|
||||
myToCheckOverlapAll = theToCheckAll;
|
||||
}
|
||||
//! Returns TRUE if all sensitive entities should be checked within rectangular/polygonal
|
||||
//! selection, FALSE by default. Can be useful for sensitive entities holding detection results as
|
||||
//! class property.
|
||||
void SetCheckOverlapAll(Standard_Boolean theToCheckAll) { myToCheckOverlapAll = theToCheckAll; }
|
||||
|
||||
//! Checks whether the group overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns the amount of sub-entities
|
||||
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
|
||||
@@ -117,7 +119,7 @@ public:
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
|
||||
//! Sets the owner for all entities in group
|
||||
Standard_EXPORT void Set (const Handle(SelectMgr_EntityOwner)& theOwnerId) Standard_OVERRIDE;
|
||||
Standard_EXPORT void Set(const Handle(SelectMgr_EntityOwner)& theOwnerId) Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of the group. If location transformation
|
||||
//! is set, it will be applied
|
||||
@@ -128,49 +130,54 @@ public:
|
||||
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of sensitive entity with index theIdx
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns geometry center of sensitive entity index theIdx in
|
||||
//! the vector along the given axis theAxis
|
||||
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Swaps items with indexes theIdx1 and theIdx2 in the vector
|
||||
Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns the length of vector of sensitive entities
|
||||
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Checks whether the entity with index theIdx overlaps the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Checks whether the entity with index theIdx is inside the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
|
||||
Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
|
||||
//! 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;
|
||||
|
||||
private:
|
||||
|
||||
Select3D_IndexedMapOfEntity myEntities; //!< Grouped sensitive entities
|
||||
// clang-format off
|
||||
Select3D_IndexedMapOfEntity myEntities; //!< Grouped sensitive entities
|
||||
// clang-format off
|
||||
Standard_Boolean myMustMatchAll; //!< Determines whether all entities in the group should be overlapped or not
|
||||
Standard_Boolean myToCheckOverlapAll; //!< flag to check overlapping with all entities within rectangular/polygonal selection
|
||||
gp_Pnt myCenter; //!< Center of geometry of the group
|
||||
mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the group
|
||||
NCollection_Vector<Standard_Integer> myBVHPrimIndexes; //!< Vector of sub-entities indexes for BVH tree build
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveGroup, Select3D_SensitiveEntity)
|
||||
|
@@ -16,43 +16,37 @@
|
||||
|
||||
#include <Select3D_SensitivePoint.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitivePoint,Select3D_SensitiveEntity)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitivePoint, Select3D_SensitiveEntity)
|
||||
|
||||
//==================================================
|
||||
// Function: Creation
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitivePoint::Select3D_SensitivePoint (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const gp_Pnt& thePoint)
|
||||
: Select3D_SensitiveEntity (theOwner)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitivePoint::Select3D_SensitivePoint(const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const gp_Pnt& thePoint)
|
||||
: Select3D_SensitiveEntity(theOwner)
|
||||
{
|
||||
SetSensitivityFactor (12);
|
||||
SetSensitivityFactor(12);
|
||||
myPoint = thePoint;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Matches
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean Select3D_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitivePoint::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
if (!theMgr.OverlapsPoint (myPoint, thePickResult))
|
||||
if (!theMgr.OverlapsPoint(myPoint, thePickResult))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
thePickResult.SetDistToGeomCenter (thePickResult.Depth());
|
||||
thePickResult.SetDistToGeomCenter(thePickResult.Depth());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitivePoint::GetConnected()
|
||||
{
|
||||
Handle(Select3D_SensitivePoint) aNewEntity = new Select3D_SensitivePoint (myOwnerId, myPoint);
|
||||
Handle(Select3D_SensitivePoint) aNewEntity = new Select3D_SensitivePoint(myOwnerId, myPoint);
|
||||
return aNewEntity;
|
||||
}
|
||||
|
||||
@@ -73,8 +67,8 @@ gp_Pnt Select3D_SensitivePoint::CenterOfGeometry() const
|
||||
//=======================================================================
|
||||
Select3D_BndBox3d Select3D_SensitivePoint::BoundingBox()
|
||||
{
|
||||
return Select3D_BndBox3d (SelectMgr_Vec3 (myPoint.X(), myPoint.Y(), myPoint.Z()),
|
||||
SelectMgr_Vec3 (myPoint.X(), myPoint.Y(), myPoint.Z()));
|
||||
return Select3D_BndBox3d(SelectMgr_Vec3(myPoint.X(), myPoint.Y(), myPoint.Z()),
|
||||
SelectMgr_Vec3(myPoint.X(), myPoint.Y(), myPoint.Z()));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -86,12 +80,11 @@ Standard_Integer Select3D_SensitivePoint::NbSubElements() const
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitivePoint::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitivePoint::DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
}
|
||||
|
@@ -25,10 +25,10 @@ class Select3D_SensitivePoint : public Select3D_SensitiveEntity
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitivePoint, Select3D_SensitiveEntity)
|
||||
public:
|
||||
|
||||
//! Constructs a sensitive point object defined by the
|
||||
//! owner OwnerId and the point Point.
|
||||
Standard_EXPORT Select3D_SensitivePoint (const Handle(SelectMgr_EntityOwner)& theOwnerId, const gp_Pnt& thePoint);
|
||||
Standard_EXPORT Select3D_SensitivePoint(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& thePoint);
|
||||
|
||||
//! Returns the amount of sub-entities in sensitive
|
||||
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
|
||||
@@ -36,8 +36,9 @@ public:
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
|
||||
//! Checks whether the point overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns the point used at the time of construction.
|
||||
const gp_Pnt& Point() const { return myPoint; }
|
||||
@@ -54,11 +55,11 @@ public:
|
||||
virtual Standard_Boolean ToBuildBVH() const Standard_OVERRIDE { return Standard_False; }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
gp_Pnt myPoint; //!< 3d coordinates of the point
|
||||
gp_Pnt myPoint; //!< 3d coordinates of the point
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitivePoint, Select3D_SensitiveEntity)
|
||||
|
@@ -15,215 +15,214 @@
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitivePoly,Select3D_SensitiveSet)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitivePoly, Select3D_SensitiveSet)
|
||||
|
||||
namespace
|
||||
{
|
||||
static Standard_Integer GetCircleNbPoints (const gp_Circ& theCircle,
|
||||
const Standard_Integer theNbPnts,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
const Standard_Boolean theIsFilled)
|
||||
static Standard_Integer GetCircleNbPoints(const gp_Circ& theCircle,
|
||||
const Standard_Integer theNbPnts,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
const Standard_Boolean theIsFilled)
|
||||
{
|
||||
// Check if number of points is invalid.
|
||||
// In this case myPolyg raises Standard_ConstructionError
|
||||
// exception (see constructor below).
|
||||
if (theNbPnts <= 0)
|
||||
{
|
||||
// Check if number of points is invalid.
|
||||
// In this case myPolyg raises Standard_ConstructionError
|
||||
// exception (see constructor below).
|
||||
if (theNbPnts <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (theCircle.Radius() > Precision::Confusion())
|
||||
{
|
||||
const Standard_Boolean isSector = theIsFilled && Abs (Abs (theU2 - theU1) - 2.0 * M_PI) > gp::Resolution();
|
||||
return 2 * theNbPnts + 1 + (isSector ? 2 : 0);
|
||||
}
|
||||
|
||||
// The radius is too small and circle degenerates into point
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Definition of circle polyline
|
||||
static void initCircle (Select3D_PointData& thePolygon,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
const Standard_Boolean theIsFilled,
|
||||
const Standard_Integer theNbPnts)
|
||||
if (theCircle.Radius() > Precision::Confusion())
|
||||
{
|
||||
const Standard_Real aStep = (theU2 - theU1) / theNbPnts;
|
||||
const Standard_Real aRadius = theCircle.Radius();
|
||||
Standard_Integer aPntIdx = 0;
|
||||
Standard_Real aCurU = theU1;
|
||||
gp_Pnt aP1;
|
||||
gp_Vec aV1;
|
||||
|
||||
const Standard_Boolean isSector = Abs (theU2 - theU1 - 2.0 * M_PI) > gp::Resolution();
|
||||
|
||||
if (isSector && theIsFilled) { thePolygon.SetPnt (aPntIdx++, theCircle.Location()); }
|
||||
|
||||
for (Standard_Integer anIndex = 1; anIndex <= theNbPnts; ++anIndex, aCurU += aStep)
|
||||
{
|
||||
ElCLib::CircleD1 (aCurU, theCircle.Position(), theCircle.Radius(), aP1, aV1);
|
||||
thePolygon.SetPnt (aPntIdx++, aP1);
|
||||
|
||||
aV1.Normalize();
|
||||
const gp_Pnt aP2 = aP1.XYZ() + aV1.XYZ() * Tan (aStep * 0.5) * aRadius;
|
||||
thePolygon.SetPnt (aPntIdx++, aP2);
|
||||
}
|
||||
aP1 = ElCLib::CircleValue (theU2, theCircle.Position(), theCircle.Radius());
|
||||
thePolygon.SetPnt (aPntIdx++, aP1);
|
||||
|
||||
if (isSector && theIsFilled) { thePolygon.SetPnt (aPntIdx++, theCircle.Location()); }
|
||||
const Standard_Boolean isSector =
|
||||
theIsFilled && Abs(Abs(theU2 - theU1) - 2.0 * M_PI) > gp::Resolution();
|
||||
return 2 * theNbPnts + 1 + (isSector ? 2 : 0);
|
||||
}
|
||||
|
||||
// The radius is too small and circle degenerates into point
|
||||
return 1;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Select3D_SensitivePoly
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints,
|
||||
const Standard_Boolean theIsBVHEnabled)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myPolyg (thePoints.Upper() - thePoints.Lower() + 1),
|
||||
mySensType (Select3D_TOS_BOUNDARY)
|
||||
//! Definition of circle polyline
|
||||
static void initCircle(Select3D_PointData& thePolygon,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
const Standard_Boolean theIsFilled,
|
||||
const Standard_Integer theNbPnts)
|
||||
{
|
||||
Standard_Integer aLowerIdx = thePoints.Lower();
|
||||
const Standard_Real aStep = (theU2 - theU1) / theNbPnts;
|
||||
const Standard_Real aRadius = theCircle.Radius();
|
||||
Standard_Integer aPntIdx = 0;
|
||||
Standard_Real aCurU = theU1;
|
||||
gp_Pnt aP1;
|
||||
gp_Vec aV1;
|
||||
|
||||
const Standard_Boolean isSector = Abs(theU2 - theU1 - 2.0 * M_PI) > gp::Resolution();
|
||||
|
||||
if (isSector && theIsFilled)
|
||||
{
|
||||
thePolygon.SetPnt(aPntIdx++, theCircle.Location());
|
||||
}
|
||||
|
||||
for (Standard_Integer anIndex = 1; anIndex <= theNbPnts; ++anIndex, aCurU += aStep)
|
||||
{
|
||||
ElCLib::CircleD1(aCurU, theCircle.Position(), theCircle.Radius(), aP1, aV1);
|
||||
thePolygon.SetPnt(aPntIdx++, aP1);
|
||||
|
||||
aV1.Normalize();
|
||||
const gp_Pnt aP2 = aP1.XYZ() + aV1.XYZ() * Tan(aStep * 0.5) * aRadius;
|
||||
thePolygon.SetPnt(aPntIdx++, aP2);
|
||||
}
|
||||
aP1 = ElCLib::CircleValue(theU2, theCircle.Position(), theCircle.Radius());
|
||||
thePolygon.SetPnt(aPntIdx++, aP1);
|
||||
|
||||
if (isSector && theIsFilled)
|
||||
{
|
||||
thePolygon.SetPnt(aPntIdx++, theCircle.Location());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitivePoly::Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints,
|
||||
const Standard_Boolean theIsBVHEnabled)
|
||||
: Select3D_SensitiveSet(theOwnerId),
|
||||
myPolyg(thePoints.Upper() - thePoints.Lower() + 1),
|
||||
mySensType(Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
Standard_Integer aLowerIdx = thePoints.Lower();
|
||||
Standard_Integer anUpperIdx = thePoints.Upper();
|
||||
gp_XYZ aPntSum (0.0, 0.0, 0.0);
|
||||
gp_XYZ aPntSum(0.0, 0.0, 0.0);
|
||||
|
||||
Select3D_BndBox3d aBndBox;
|
||||
for (Standard_Integer aIdx = aLowerIdx; aIdx <= anUpperIdx; ++aIdx)
|
||||
{
|
||||
aPntSum += thePoints.Value (aIdx).XYZ();
|
||||
const SelectMgr_Vec3 aPnt (thePoints.Value (aIdx).X(),
|
||||
thePoints.Value (aIdx).Y(),
|
||||
thePoints.Value (aIdx).Z());
|
||||
aBndBox.Add (aPnt);
|
||||
myPolyg.SetPnt (aIdx - aLowerIdx, thePoints.Value (aIdx));
|
||||
aPntSum += thePoints.Value(aIdx).XYZ();
|
||||
const SelectMgr_Vec3 aPnt(thePoints.Value(aIdx).X(),
|
||||
thePoints.Value(aIdx).Y(),
|
||||
thePoints.Value(aIdx).Z());
|
||||
aBndBox.Add(aPnt);
|
||||
myPolyg.SetPnt(aIdx - aLowerIdx, thePoints.Value(aIdx));
|
||||
}
|
||||
|
||||
myBndBox = aBndBox;
|
||||
myCOG = aPntSum / myPolyg.Size();
|
||||
myCOG = aPntSum / myPolyg.Size();
|
||||
|
||||
if (theIsBVHEnabled)
|
||||
{
|
||||
const Standard_Integer aPntsNum = myPolyg.Size();
|
||||
mySegmentIndexes = new TColStd_HArray1OfInteger (0, aPntsNum - 2);
|
||||
mySegmentIndexes = new TColStd_HArray1OfInteger(0, aPntsNum - 2);
|
||||
for (Standard_Integer aSegmIter = 0; aSegmIter < aPntsNum - 1; ++aSegmIter)
|
||||
{
|
||||
mySegmentIndexes->SetValue (aSegmIter, aSegmIter);
|
||||
mySegmentIndexes->SetValue(aSegmIter, aSegmIter);
|
||||
}
|
||||
}
|
||||
|
||||
myIsComputed = Standard_True;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Select3D_SensitivePoly
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints,
|
||||
const Standard_Boolean theIsBVHEnabled)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myPolyg (thePoints->Upper() - thePoints->Lower() + 1),
|
||||
mySensType (Select3D_TOS_BOUNDARY)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitivePoly::Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints,
|
||||
const Standard_Boolean theIsBVHEnabled)
|
||||
: Select3D_SensitiveSet(theOwnerId),
|
||||
myPolyg(thePoints->Upper() - thePoints->Lower() + 1),
|
||||
mySensType(Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
Standard_Integer aLowerIdx = thePoints->Lower();
|
||||
Standard_Integer aLowerIdx = thePoints->Lower();
|
||||
Standard_Integer anUpperIdx = thePoints->Upper();
|
||||
gp_XYZ aPntSum (0.0, 0.0, 0.0);
|
||||
gp_XYZ aPntSum(0.0, 0.0, 0.0);
|
||||
|
||||
Select3D_BndBox3d aBndBox;
|
||||
for (Standard_Integer aIdx = aLowerIdx; aIdx <= anUpperIdx; ++aIdx)
|
||||
{
|
||||
aPntSum += thePoints->Value (aIdx).XYZ();
|
||||
const SelectMgr_Vec3 aPnt (thePoints->Value (aIdx).X(),
|
||||
thePoints->Value (aIdx).Y(),
|
||||
thePoints->Value (aIdx).Z());
|
||||
aBndBox.Add (aPnt);
|
||||
myPolyg.SetPnt (aIdx - aLowerIdx, thePoints->Value (aIdx));
|
||||
aPntSum += thePoints->Value(aIdx).XYZ();
|
||||
const SelectMgr_Vec3 aPnt(thePoints->Value(aIdx).X(),
|
||||
thePoints->Value(aIdx).Y(),
|
||||
thePoints->Value(aIdx).Z());
|
||||
aBndBox.Add(aPnt);
|
||||
myPolyg.SetPnt(aIdx - aLowerIdx, thePoints->Value(aIdx));
|
||||
}
|
||||
|
||||
myBndBox = aBndBox;
|
||||
myCOG = aPntSum / myPolyg.Size();
|
||||
myCOG = aPntSum / myPolyg.Size();
|
||||
|
||||
if (theIsBVHEnabled)
|
||||
{
|
||||
const Standard_Integer aPntsNum = myPolyg.Size();
|
||||
mySegmentIndexes = new TColStd_HArray1OfInteger (0, aPntsNum - 2);
|
||||
mySegmentIndexes = new TColStd_HArray1OfInteger(0, aPntsNum - 2);
|
||||
for (Standard_Integer aSegmIter = 0; aSegmIter < aPntsNum - 1; ++aSegmIter)
|
||||
{
|
||||
mySegmentIndexes->SetValue (aSegmIter, aSegmIter);
|
||||
mySegmentIndexes->SetValue(aSegmIter, aSegmIter);
|
||||
}
|
||||
}
|
||||
|
||||
myIsComputed = Standard_True;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Creation
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Boolean theIsBVHEnabled,
|
||||
const Standard_Integer theNbPnts)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myPolyg (theNbPnts),
|
||||
mySensType (Select3D_TOS_BOUNDARY)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitivePoly::Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Boolean theIsBVHEnabled,
|
||||
const Standard_Integer theNbPnts)
|
||||
: Select3D_SensitiveSet(theOwnerId),
|
||||
myPolyg(theNbPnts),
|
||||
mySensType(Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
if (theIsBVHEnabled)
|
||||
{
|
||||
mySegmentIndexes = new TColStd_HArray1OfInteger (0, theNbPnts - 2);
|
||||
mySegmentIndexes = new TColStd_HArray1OfInteger(0, theNbPnts - 2);
|
||||
for (Standard_Integer aIdx = 0; aIdx < theNbPnts - 1; ++aIdx)
|
||||
{
|
||||
mySegmentIndexes->SetValue (aIdx, aIdx);
|
||||
mySegmentIndexes->SetValue(aIdx, aIdx);
|
||||
}
|
||||
}
|
||||
myCOG = gp_Pnt (RealLast(), RealLast(), RealLast());
|
||||
myCOG = gp_Pnt(RealLast(), RealLast(), RealLast());
|
||||
myIsComputed = Standard_False;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Creation
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
const Standard_Boolean theIsFilled,
|
||||
const Standard_Integer theNbPnts)
|
||||
: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetCircleNbPoints (theCircle, theNbPnts, theU1, theU2, theIsFilled))
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitivePoly::Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
const Standard_Boolean theIsFilled,
|
||||
const Standard_Integer theNbPnts)
|
||||
: Select3D_SensitivePoly(theOwnerId,
|
||||
!theIsFilled,
|
||||
GetCircleNbPoints(theCircle, theNbPnts, theU1, theU2, theIsFilled))
|
||||
{
|
||||
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
|
||||
|
||||
if (myPolyg.Size() != 1)
|
||||
{
|
||||
initCircle (myPolyg, theCircle, Min (theU1, theU2), Max (theU1, theU2), theIsFilled, theNbPnts);
|
||||
initCircle(myPolyg, theCircle, Min(theU1, theU2), Max(theU1, theU2), theIsFilled, theNbPnts);
|
||||
}
|
||||
else
|
||||
{
|
||||
myPolyg.SetPnt (0, theCircle.Position().Location());
|
||||
myPolyg.SetPnt(0, theCircle.Position().Location());
|
||||
}
|
||||
|
||||
if (!theIsFilled)
|
||||
{
|
||||
SetSensitivityFactor (6);
|
||||
SetSensitivityFactor(6);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Matches
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitivePoly::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitivePoly::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
if (mySensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
if (!Select3D_SensitiveSet::Matches (theMgr, thePickResult))
|
||||
if (!Select3D_SensitiveSet::Matches(theMgr, thePickResult))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -231,17 +230,18 @@ Standard_Boolean Select3D_SensitivePoly::Matches (SelectBasics_SelectingVolumeMa
|
||||
else if (mySensType == Select3D_TOS_INTERIOR)
|
||||
{
|
||||
Handle(TColgp_HArray1OfPnt) anArrayOfPnt;
|
||||
Points3D (anArrayOfPnt);
|
||||
Points3D(anArrayOfPnt);
|
||||
if (!theMgr.IsOverlapAllowed())
|
||||
{
|
||||
if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline)
|
||||
{
|
||||
SelectBasics_PickResult aDummy;
|
||||
return theMgr.OverlapsPolygon (anArrayOfPnt->Array1(), mySensType, aDummy);
|
||||
return theMgr.OverlapsPolygon(anArrayOfPnt->Array1(), mySensType, aDummy);
|
||||
}
|
||||
for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper(); ++aPntIdx)
|
||||
for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper();
|
||||
++aPntIdx)
|
||||
{
|
||||
if (!theMgr.OverlapsPoint (anArrayOfPnt->Value(aPntIdx)))
|
||||
if (!theMgr.OverlapsPoint(anArrayOfPnt->Value(aPntIdx)))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -249,11 +249,11 @@ Standard_Boolean Select3D_SensitivePoly::Matches (SelectBasics_SelectingVolumeMa
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
if (!theMgr.OverlapsPolygon (anArrayOfPnt->Array1(), Select3D_TOS_INTERIOR, thePickResult))
|
||||
if (!theMgr.OverlapsPolygon(anArrayOfPnt->Array1(), Select3D_TOS_INTERIOR, thePickResult))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
thePickResult.SetDistToGeomCenter (distanceToCOG(theMgr));
|
||||
thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
@@ -272,10 +272,8 @@ Select3D_BndBox3d Select3D_SensitivePoly::BoundingBox()
|
||||
Select3D_BndBox3d aBndBox;
|
||||
for (Standard_Integer aPntIter = 0; aPntIter < myPolyg.Size(); ++aPntIter)
|
||||
{
|
||||
SelectMgr_Vec3 aPnt (myPolyg.Pnt (aPntIter).x,
|
||||
myPolyg.Pnt (aPntIter).y,
|
||||
myPolyg.Pnt (aPntIter).z);
|
||||
aBndBox.Add (aPnt);
|
||||
SelectMgr_Vec3 aPnt(myPolyg.Pnt(aPntIter).x, myPolyg.Pnt(aPntIter).y, myPolyg.Pnt(aPntIter).z);
|
||||
aBndBox.Add(aPnt);
|
||||
}
|
||||
|
||||
myBndBox = aBndBox;
|
||||
@@ -301,23 +299,23 @@ Standard_Integer Select3D_SensitivePoly::Size() const
|
||||
// Purpose : Returns bounding box of segment with
|
||||
// index theIdx
|
||||
//==================================================
|
||||
Select3D_BndBox3d Select3D_SensitivePoly::Box (const Standard_Integer theIdx) const
|
||||
Select3D_BndBox3d Select3D_SensitivePoly::Box(const Standard_Integer theIdx) const
|
||||
{
|
||||
if (mySegmentIndexes.IsNull())
|
||||
return Select3D_BndBox3d (SelectMgr_Vec3 (RealLast()));
|
||||
return Select3D_BndBox3d(SelectMgr_Vec3(RealLast()));
|
||||
|
||||
const Standard_Integer aSegmentIdx = mySegmentIndexes->Value (theIdx);
|
||||
gp_Pnt aPnt1 = myPolyg.Pnt3d (aSegmentIdx);
|
||||
gp_Pnt aPnt2 = myPolyg.Pnt3d (aSegmentIdx + 1);
|
||||
const Standard_Integer aSegmentIdx = mySegmentIndexes->Value(theIdx);
|
||||
gp_Pnt aPnt1 = myPolyg.Pnt3d(aSegmentIdx);
|
||||
gp_Pnt aPnt2 = myPolyg.Pnt3d(aSegmentIdx + 1);
|
||||
|
||||
const SelectMgr_Vec3 aMinPnt (Min (aPnt1.X(), aPnt2.X()),
|
||||
Min (aPnt1.Y(), aPnt2.Y()),
|
||||
Min (aPnt1.Z(), aPnt2.Z()));
|
||||
const SelectMgr_Vec3 aMaxPnt (Max (aPnt1.X(), aPnt2.X()),
|
||||
Max (aPnt1.Y(), aPnt2.Y()),
|
||||
Max (aPnt1.Z(), aPnt2.Z()));
|
||||
const SelectMgr_Vec3 aMinPnt(Min(aPnt1.X(), aPnt2.X()),
|
||||
Min(aPnt1.Y(), aPnt2.Y()),
|
||||
Min(aPnt1.Z(), aPnt2.Z()));
|
||||
const SelectMgr_Vec3 aMaxPnt(Max(aPnt1.X(), aPnt2.X()),
|
||||
Max(aPnt1.Y(), aPnt2.Y()),
|
||||
Max(aPnt1.Z(), aPnt2.Z()));
|
||||
|
||||
return Select3D_BndBox3d (aMinPnt, aMaxPnt);
|
||||
return Select3D_BndBox3d(aMinPnt, aMaxPnt);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
@@ -326,14 +324,14 @@ Select3D_BndBox3d Select3D_SensitivePoly::Box (const Standard_Integer theIdx) co
|
||||
// entity index theIdx in the vector along
|
||||
// the given axis theAxis
|
||||
//==================================================
|
||||
Standard_Real Select3D_SensitivePoly::Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_Real Select3D_SensitivePoly::Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
{
|
||||
if (mySegmentIndexes.IsNull())
|
||||
return RealLast();
|
||||
|
||||
const Select3D_BndBox3d aBndBox = Box (theIdx);
|
||||
const SelectMgr_Vec3 aCenter = (aBndBox.CornerMin() + aBndBox.CornerMax()) * 0.5;
|
||||
const Select3D_BndBox3d aBndBox = Box(theIdx);
|
||||
const SelectMgr_Vec3 aCenter = (aBndBox.CornerMin() + aBndBox.CornerMax()) * 0.5;
|
||||
return theAxis == 0 ? aCenter.x() : (theAxis == 1 ? aCenter.y() : aCenter.z());
|
||||
}
|
||||
|
||||
@@ -342,16 +340,15 @@ Standard_Real Select3D_SensitivePoly::Center (const Standard_Integer theIdx,
|
||||
// Purpose : Swaps items with indexes theIdx1 and
|
||||
// theIdx2 in the vector
|
||||
//==================================================
|
||||
void Select3D_SensitivePoly::Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2)
|
||||
void Select3D_SensitivePoly::Swap(const Standard_Integer theIdx1, const Standard_Integer theIdx2)
|
||||
{
|
||||
if (mySegmentIndexes.IsNull())
|
||||
return;
|
||||
|
||||
const Standard_Integer aSegmentIdx1 = mySegmentIndexes->Value (theIdx1);
|
||||
const Standard_Integer aSegmentIdx2 = mySegmentIndexes->Value (theIdx2);
|
||||
mySegmentIndexes->ChangeValue (theIdx1) = aSegmentIdx2;
|
||||
mySegmentIndexes->ChangeValue (theIdx2) = aSegmentIdx1;
|
||||
const Standard_Integer aSegmentIdx1 = mySegmentIndexes->Value(theIdx1);
|
||||
const Standard_Integer aSegmentIdx2 = mySegmentIndexes->Value(theIdx2);
|
||||
mySegmentIndexes->ChangeValue(theIdx1) = aSegmentIdx2;
|
||||
mySegmentIndexes->ChangeValue(theIdx2) = aSegmentIdx1;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
@@ -360,10 +357,11 @@ void Select3D_SensitivePoly::Swap (const Standard_Integer theIdx1,
|
||||
// theIdx overlaps the current selecting
|
||||
// volume
|
||||
//==================================================
|
||||
Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
Standard_Boolean Select3D_SensitivePoly::overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
{
|
||||
if (mySegmentIndexes.IsNull())
|
||||
{
|
||||
@@ -374,33 +372,34 @@ Standard_Boolean Select3D_SensitivePoly::overlapsElement (SelectBasics_PickResul
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
const Standard_Integer aSegmentIdx = mySegmentIndexes->Value (theElemIdx);
|
||||
gp_Pnt aPnt1 = myPolyg.Pnt3d (aSegmentIdx);
|
||||
gp_Pnt aPnt2 = myPolyg.Pnt3d (aSegmentIdx + 1);
|
||||
return theMgr.OverlapsSegment (aPnt1, aPnt2, thePickResult);
|
||||
const Standard_Integer aSegmentIdx = mySegmentIndexes->Value(theElemIdx);
|
||||
gp_Pnt aPnt1 = myPolyg.Pnt3d(aSegmentIdx);
|
||||
gp_Pnt aPnt2 = myPolyg.Pnt3d(aSegmentIdx + 1);
|
||||
return theMgr.OverlapsSegment(aPnt1, aPnt2, thePickResult);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function : elementIsInside
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean Select3D_SensitivePoly::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitivePoly::elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
{
|
||||
if (theIsFullInside)
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
const Standard_Integer aSegmentIdx = mySegmentIndexes->Value (theElemIdx);
|
||||
const Standard_Integer aSegmentIdx = mySegmentIndexes->Value(theElemIdx);
|
||||
if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline)
|
||||
{
|
||||
SelectBasics_PickResult aDummy;
|
||||
return theMgr.OverlapsSegment (myPolyg.Pnt3d (aSegmentIdx + 0), myPolyg.Pnt3d (aSegmentIdx + 1), aDummy);
|
||||
return theMgr.OverlapsSegment(myPolyg.Pnt3d(aSegmentIdx + 0),
|
||||
myPolyg.Pnt3d(aSegmentIdx + 1),
|
||||
aDummy);
|
||||
}
|
||||
return theMgr.OverlapsPoint (myPolyg.Pnt3d (aSegmentIdx + 0))
|
||||
&& theMgr.OverlapsPoint (myPolyg.Pnt3d (aSegmentIdx + 1));
|
||||
return theMgr.OverlapsPoint(myPolyg.Pnt3d(aSegmentIdx + 0))
|
||||
&& theMgr.OverlapsPoint(myPolyg.Pnt3d(aSegmentIdx + 1));
|
||||
}
|
||||
|
||||
//==================================================
|
||||
@@ -409,20 +408,20 @@ Standard_Boolean Select3D_SensitivePoly::elementIsInside (SelectBasics_Selecting
|
||||
// projection of used-picked screen point
|
||||
// to center of the geometry
|
||||
//==================================================
|
||||
Standard_Real Select3D_SensitivePoly::distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr)
|
||||
Standard_Real Select3D_SensitivePoly::distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr)
|
||||
{
|
||||
if (!myIsComputed)
|
||||
{
|
||||
gp_XYZ aCenter (0.0, 0.0, 0.0);
|
||||
gp_XYZ aCenter(0.0, 0.0, 0.0);
|
||||
for (Standard_Integer aIdx = 0; aIdx < myPolyg.Size(); ++aIdx)
|
||||
{
|
||||
aCenter += myPolyg.Pnt (aIdx);
|
||||
aCenter += myPolyg.Pnt(aIdx);
|
||||
}
|
||||
myCOG = aCenter / myPolyg.Size();
|
||||
myCOG = aCenter / myPolyg.Size();
|
||||
myIsComputed = Standard_True;
|
||||
}
|
||||
|
||||
return theMgr.DistToGeometryCenter (myCOG);
|
||||
return theMgr.DistToGeometryCenter(myCOG);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
@@ -444,12 +443,12 @@ gp_Pnt Select3D_SensitivePoly::CenterOfGeometry() const
|
||||
{
|
||||
if (!myIsComputed)
|
||||
{
|
||||
gp_XYZ aCenter (0.0, 0.0, 0.0);
|
||||
gp_XYZ aCenter(0.0, 0.0, 0.0);
|
||||
for (Standard_Integer aIdx = 0; aIdx < myPolyg.Size(); ++aIdx)
|
||||
{
|
||||
aCenter += myPolyg.Pnt (aIdx);
|
||||
aCenter += myPolyg.Pnt(aIdx);
|
||||
}
|
||||
myCOG = aCenter / myPolyg.Size();
|
||||
myCOG = aCenter / myPolyg.Size();
|
||||
myIsComputed = Standard_True;
|
||||
}
|
||||
|
||||
@@ -460,11 +459,11 @@ gp_Pnt Select3D_SensitivePoly::CenterOfGeometry() const
|
||||
// function : DumpJson
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Select3D_SensitivePoly::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
void Select3D_SensitivePoly::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet)
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveSet)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBndBox)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsComputed)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myBndBox)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myIsComputed)
|
||||
}
|
||||
|
@@ -29,73 +29,70 @@ class Select3D_SensitivePoly : public Select3D_SensitiveSet
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitivePoly, Select3D_SensitiveSet)
|
||||
public:
|
||||
//! Constructs a sensitive face object defined by the
|
||||
//! owner OwnerId, the array of points ThePoints, and
|
||||
//! the sensitivity type Sensitivity.
|
||||
//! The array of points is the outer polygon of the geometric face.
|
||||
Standard_EXPORT Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints,
|
||||
const Standard_Boolean theIsBVHEnabled);
|
||||
|
||||
//! Constructs a sensitive face object defined by the
|
||||
//! owner OwnerId, the array of points ThePoints, and
|
||||
//! the sensitivity type Sensitivity.
|
||||
//! The array of points is the outer polygon of the geometric face.
|
||||
Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const TColgp_Array1OfPnt& thePoints,
|
||||
const Standard_Boolean theIsBVHEnabled);
|
||||
|
||||
//! Constructs a sensitive face object defined by the
|
||||
//! owner OwnerId, the array of points ThePoints, and
|
||||
//! the sensitivity type Sensitivity.
|
||||
//! The array of points is the outer polygon of the geometric face.
|
||||
Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints,
|
||||
const Standard_Boolean theIsBVHEnabled);
|
||||
Standard_EXPORT Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(TColgp_HArray1OfPnt)& thePoints,
|
||||
const Standard_Boolean theIsBVHEnabled);
|
||||
|
||||
//! Constructs the sensitive arc object defined by the
|
||||
//! owner theOwnerId, the circle theCircle, the parameters theU1
|
||||
//! and theU2, the boolean theIsFilled and the number of points theNbPnts.
|
||||
//! theU1 and theU2 define the first and last points of the arc on theCircle.
|
||||
Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
const Standard_Boolean theIsFilled = Standard_False,
|
||||
const Standard_Integer theNbPnts = 12);
|
||||
Standard_EXPORT Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
const Standard_Boolean theIsFilled = Standard_False,
|
||||
const Standard_Integer theNbPnts = 12);
|
||||
|
||||
//! Constructs a sensitive curve or arc object defined by the
|
||||
//! owner theOwnerId, the theIsBVHEnabled flag, and the
|
||||
//! maximum number of points on the curve: theNbPnts.
|
||||
Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Boolean theIsBVHEnabled,
|
||||
const Standard_Integer theNbPnts = 6);
|
||||
Standard_EXPORT Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Standard_Boolean theIsBVHEnabled,
|
||||
const Standard_Integer theNbPnts = 6);
|
||||
|
||||
//! Checks whether the poly overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns the amount of segments in poly
|
||||
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns the 3D points of the array used at construction time.
|
||||
void Points3D (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
|
||||
void Points3D(Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
|
||||
{
|
||||
Standard_Integer aSize = myPolyg.Size();
|
||||
theHArrayOfPnt = new TColgp_HArray1OfPnt (1,aSize);
|
||||
for(Standard_Integer anIndex = 1; anIndex <= aSize; anIndex++)
|
||||
theHArrayOfPnt = new TColgp_HArray1OfPnt(1, aSize);
|
||||
for (Standard_Integer anIndex = 1; anIndex <= aSize; anIndex++)
|
||||
{
|
||||
theHArrayOfPnt->SetValue (anIndex, myPolyg.Pnt (anIndex-1));
|
||||
theHArrayOfPnt->SetValue(anIndex, myPolyg.Pnt(anIndex - 1));
|
||||
}
|
||||
}
|
||||
|
||||
//! Return array bounds.
|
||||
void ArrayBounds (Standard_Integer& theLow,
|
||||
Standard_Integer& theUp) const
|
||||
void ArrayBounds(Standard_Integer& theLow, Standard_Integer& theUp) const
|
||||
{
|
||||
theLow = 0;
|
||||
theUp = myPolyg.Size() - 1;
|
||||
theUp = myPolyg.Size() - 1;
|
||||
}
|
||||
|
||||
//! Return point.
|
||||
gp_Pnt GetPoint3d (const Standard_Integer thePntIdx) const
|
||||
gp_Pnt GetPoint3d(const Standard_Integer thePntIdx) const
|
||||
{
|
||||
return (thePntIdx >= 0 && thePntIdx < myPolyg.Size())
|
||||
? myPolyg.Pnt (thePntIdx)
|
||||
: gp_Pnt();
|
||||
return (thePntIdx >= 0 && thePntIdx < myPolyg.Size()) ? myPolyg.Pnt(thePntIdx) : gp_Pnt();
|
||||
}
|
||||
|
||||
//! Returns bounding box of a polygon. If location
|
||||
@@ -110,47 +107,51 @@ public:
|
||||
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of segment with index theIdx
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns geometry center of sensitive entity index theIdx in the vector along
|
||||
//! the given axis theAxis
|
||||
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Swaps items with indexes theIdx1 and theIdx2 in the vector
|
||||
Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Checks whether the segment with index theIdx overlaps the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Checks whether the entity with index theIdx is inside the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Calculates distance from the 3d projection of used-picked screen point
|
||||
//! to center of the geometry
|
||||
Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Real distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Select3D_PointData myPolyg; //!< Points of the poly
|
||||
mutable gp_Pnt myCOG; //!< Center of the poly
|
||||
Handle(TColStd_HArray1OfInteger) mySegmentIndexes; //!< Segment indexes for BVH tree build
|
||||
Select3D_BndBox3d myBndBox; //!< Bounding box of the poly
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: boundary or interior
|
||||
mutable Standard_Boolean myIsComputed; //!< Is true if all the points and data structures of polygon are initialized
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitivePoly, Select3D_SensitiveSet)
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -29,16 +29,15 @@ class Select3D_SensitivePrimitiveArray : public Select3D_SensitiveSet
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructs an empty sensitive object.
|
||||
Standard_EXPORT Select3D_SensitivePrimitiveArray (const Handle(SelectMgr_EntityOwner)& theOwnerId);
|
||||
Standard_EXPORT Select3D_SensitivePrimitiveArray(const Handle(SelectMgr_EntityOwner)& theOwnerId);
|
||||
|
||||
//! Return patch size limit (1 by default).
|
||||
Standard_Integer PatchSizeMax() const { return myPatchSizeMax; }
|
||||
|
||||
//! Assign patch size limit.
|
||||
//! Should be set before initialization.
|
||||
void SetPatchSizeMax (const Standard_Integer thePatchSizeMax) { myPatchSizeMax = thePatchSizeMax; }
|
||||
void SetPatchSizeMax(const Standard_Integer thePatchSizeMax) { myPatchSizeMax = thePatchSizeMax; }
|
||||
|
||||
//! Maximum allowed distance between consequential elements in patch (ShortRealLast() by default).
|
||||
//! Has no effect on indexed triangulation.
|
||||
@@ -46,101 +45,128 @@ public:
|
||||
|
||||
//! Assign patch distance limit.
|
||||
//! Should be set before initialization.
|
||||
void SetPatchDistance (const float thePatchDistMax) { myPatchDistance = thePatchDistMax; }
|
||||
void SetPatchDistance(const float thePatchDistMax) { myPatchDistance = thePatchDistMax; }
|
||||
|
||||
//! Initialize the sensitive object from triangualtion.
|
||||
//! The sub-triangulation can be specified by arguments theIndexLower and theIndexUpper
|
||||
//! (these are for iterating theIndices, not to restrict the actual index values!).
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type
|
||||
//! Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theIndices index array defining triangulation
|
||||
//! @param theInitLoc location
|
||||
//! @param theIndexLower the theIndices range - first value (inclusive), starting from 0 and multiple by 3
|
||||
//! @param theIndexUpper the theIndices range - last value (inclusive), upto theIndices->NbElements-1 and multiple by 3
|
||||
//! @param theIndexLower the theIndices range - first value (inclusive), starting from 0 and
|
||||
//! multiple by 3
|
||||
//! @param theIndexUpper the theIndices range - last value (inclusive), upto
|
||||
//! theIndices->NbElements-1 and multiple by 3
|
||||
//! @param theToEvalMinMax compute bounding box within initialization
|
||||
//! @param theNbGroups number of groups to split the vertex array into several parts
|
||||
Standard_EXPORT bool InitTriangulation (const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Standard_Integer theIndexLower,
|
||||
const Standard_Integer theIndexUpper,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1);
|
||||
Standard_EXPORT bool InitTriangulation(const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Standard_Integer theIndexLower,
|
||||
const Standard_Integer theIndexUpper,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1);
|
||||
|
||||
//! Initialize the sensitive object from triangualtion.
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type
|
||||
//! Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theIndices index array defining triangulation
|
||||
//! @param theInitLoc location
|
||||
//! @param theToEvalMinMax compute bounding box within initialization
|
||||
//! @param theNbGroups number of groups to split the vertex array into several parts
|
||||
bool InitTriangulation (const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1)
|
||||
bool InitTriangulation(const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1)
|
||||
{
|
||||
const Standard_Integer anUpper = !theIndices.IsNull() ? (theIndices->NbElements - 1)
|
||||
: (!theVerts.IsNull() ? (theVerts->NbElements - 1) : 0);
|
||||
return InitTriangulation (theVerts, theIndices, theInitLoc, 0, anUpper, theToEvalMinMax, theNbGroups);
|
||||
const Standard_Integer anUpper = !theIndices.IsNull()
|
||||
? (theIndices->NbElements - 1)
|
||||
: (!theVerts.IsNull() ? (theVerts->NbElements - 1) : 0);
|
||||
return InitTriangulation(theVerts,
|
||||
theIndices,
|
||||
theInitLoc,
|
||||
0,
|
||||
anUpper,
|
||||
theToEvalMinMax,
|
||||
theNbGroups);
|
||||
}
|
||||
|
||||
//! Initialize the sensitive object from point set.
|
||||
//! The sub-set of points can be specified by arguments theIndexLower and theIndexUpper
|
||||
//! (these are for iterating theIndices, not to restrict the actual index values!).
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type
|
||||
//! Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theIndices index array defining points
|
||||
//! @param theInitLoc location
|
||||
//! @param theIndexLower the theIndices range - first value (inclusive), starting from 0
|
||||
//! @param theIndexUpper the theIndices range - last value (inclusive), upto theIndices->NbElements-1
|
||||
//! @param theIndexUpper the theIndices range - last value (inclusive), upto
|
||||
//! theIndices->NbElements-1
|
||||
//! @param theToEvalMinMax compute bounding box within initialization
|
||||
//! @param theNbGroups number of groups to split the vertex array into several parts
|
||||
Standard_EXPORT bool InitPoints (const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Standard_Integer theIndexLower,
|
||||
const Standard_Integer theIndexUpper,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1);
|
||||
Standard_EXPORT bool InitPoints(const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Standard_Integer theIndexLower,
|
||||
const Standard_Integer theIndexUpper,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1);
|
||||
|
||||
//! Initialize the sensitive object from point set.
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type
|
||||
//! Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theIndices index array to define subset of points
|
||||
//! @param theInitLoc location
|
||||
//! @param theToEvalMinMax compute bounding box within initialization
|
||||
//! @param theNbGroups number of groups to split the vertex array into several parts
|
||||
bool InitPoints (const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1)
|
||||
bool InitPoints(const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1)
|
||||
{
|
||||
const Standard_Integer anUpper = !theIndices.IsNull() ? (theIndices->NbElements - 1)
|
||||
: (!theVerts.IsNull() ? (theVerts->NbElements - 1) : 0);
|
||||
return InitPoints (theVerts, theIndices, theInitLoc, 0, anUpper, theToEvalMinMax, theNbGroups);
|
||||
const Standard_Integer anUpper = !theIndices.IsNull()
|
||||
? (theIndices->NbElements - 1)
|
||||
: (!theVerts.IsNull() ? (theVerts->NbElements - 1) : 0);
|
||||
return InitPoints(theVerts, theIndices, theInitLoc, 0, anUpper, theToEvalMinMax, theNbGroups);
|
||||
}
|
||||
|
||||
//! Initialize the sensitive object from point set.
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theVerts attributes array containing Graphic3d_TOA_POS with type
|
||||
//! Graphic3d_TOD_VEC3 or Graphic3d_TOD_VEC2
|
||||
//! @param theInitLoc location
|
||||
//! @param theToEvalMinMax compute bounding box within initialization
|
||||
//! @param theNbGroups number of groups to split the vertex array into several parts
|
||||
bool InitPoints (const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1)
|
||||
bool InitPoints(const Handle(Graphic3d_Buffer)& theVerts,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const bool theToEvalMinMax = true,
|
||||
const Standard_Integer theNbGroups = 1)
|
||||
{
|
||||
const Standard_Integer anUpper = !theVerts.IsNull() ? (theVerts->NbElements - 1) : 0;
|
||||
return InitPoints (theVerts, Handle(Graphic3d_IndexBuffer)(), theInitLoc, 0, anUpper, theToEvalMinMax, theNbGroups);
|
||||
return InitPoints(theVerts,
|
||||
Handle(Graphic3d_IndexBuffer)(),
|
||||
theInitLoc,
|
||||
0,
|
||||
anUpper,
|
||||
theToEvalMinMax,
|
||||
theNbGroups);
|
||||
}
|
||||
|
||||
//! Assign new not transformed bounding box.
|
||||
void SetMinMax (double theMinX, double theMinY, double theMinZ,
|
||||
double theMaxX, double theMaxY, double theMaxZ)
|
||||
void SetMinMax(double theMinX,
|
||||
double theMinY,
|
||||
double theMinZ,
|
||||
double theMaxX,
|
||||
double theMaxY,
|
||||
double theMaxZ)
|
||||
{
|
||||
myBndBox = Select3D_BndBox3d (SelectMgr_Vec3 (theMinX, theMinY, theMinZ),
|
||||
SelectMgr_Vec3 (theMaxX, theMaxY, theMaxZ));
|
||||
myBndBox = Select3D_BndBox3d(SelectMgr_Vec3(theMinX, theMinY, theMinZ),
|
||||
SelectMgr_Vec3(theMaxX, theMaxY, theMaxZ));
|
||||
if (!myGroups.IsNull())
|
||||
{
|
||||
for (Select3D_PrimArraySubGroupArray::Iterator aGroupIter (*myGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
for (Select3D_PrimArraySubGroupArray::Iterator aGroupIter(*myGroups); aGroupIter.More();
|
||||
aGroupIter.Next())
|
||||
{
|
||||
aGroupIter.Value()->myBndBox = myBndBox;
|
||||
}
|
||||
@@ -151,43 +177,50 @@ public:
|
||||
bool ToDetectElements() const { return myToDetectElem; }
|
||||
|
||||
//! Setup keeping of the index of last topmost detected element (axis picking).
|
||||
void SetDetectElements (bool theToDetect) { myToDetectElem = theToDetect; }
|
||||
void SetDetectElements(bool theToDetect) { myToDetectElem = theToDetect; }
|
||||
|
||||
//! Return flag to keep index map of last detected elements, FALSE by default (rectangle selection).
|
||||
//! Return flag to keep index map of last detected elements, FALSE by default (rectangle
|
||||
//! selection).
|
||||
bool ToDetectElementMap() const { return !myDetectedElemMap.IsNull(); }
|
||||
|
||||
//! Setup keeping of the index map of last detected elements (rectangle selection).
|
||||
Standard_EXPORT void SetDetectElementMap (bool theToDetect);
|
||||
Standard_EXPORT void SetDetectElementMap(bool theToDetect);
|
||||
|
||||
//! Return flag to keep index of last topmost detected node, FALSE by default.
|
||||
bool ToDetectNodes() const { return myToDetectNode; }
|
||||
|
||||
//! Setup keeping of the index of last topmost detected node (for axis picking).
|
||||
void SetDetectNodes (bool theToDetect) { myToDetectNode = theToDetect; }
|
||||
void SetDetectNodes(bool theToDetect) { myToDetectNode = theToDetect; }
|
||||
|
||||
//! Return flag to keep index map of last detected nodes, FALSE by default (rectangle selection).
|
||||
bool ToDetectNodeMap() const { return !myDetectedNodeMap.IsNull(); }
|
||||
|
||||
//! Setup keeping of the index map of last detected nodes (rectangle selection).
|
||||
Standard_EXPORT void SetDetectNodeMap (bool theToDetect);
|
||||
Standard_EXPORT void SetDetectNodeMap(bool theToDetect);
|
||||
|
||||
//! Return flag to keep index of last topmost detected edge, FALSE by default.
|
||||
bool ToDetectEdges() const { return myToDetectEdge; }
|
||||
|
||||
//! Setup keeping of the index of last topmost detected edge (axis picking).
|
||||
void SetDetectEdges (bool theToDetect) { myToDetectEdge = theToDetect; }
|
||||
void SetDetectEdges(bool theToDetect) { myToDetectEdge = theToDetect; }
|
||||
|
||||
//! Return last topmost detected element or -1 if undefined (axis picking).
|
||||
Standard_Integer LastDetectedElement() const { return myDetectedElem; }
|
||||
|
||||
//! Return the index map of last detected elements (rectangle selection).
|
||||
const Handle(TColStd_HPackedMapOfInteger)& LastDetectedElementMap() const { return myDetectedElemMap; }
|
||||
const Handle(TColStd_HPackedMapOfInteger)& LastDetectedElementMap() const
|
||||
{
|
||||
return myDetectedElemMap;
|
||||
}
|
||||
|
||||
//! Return last topmost detected node or -1 if undefined (axis picking).
|
||||
Standard_Integer LastDetectedNode() const { return myDetectedNode; }
|
||||
|
||||
//! Return the index map of last detected nodes (rectangle selection).
|
||||
const Handle(TColStd_HPackedMapOfInteger)& LastDetectedNodeMap() const { return myDetectedNodeMap; }
|
||||
const Handle(TColStd_HPackedMapOfInteger)& LastDetectedNodeMap() const
|
||||
{
|
||||
return myDetectedNodeMap;
|
||||
}
|
||||
|
||||
//! Return the first node of last topmost detected edge or -1 if undefined (axis picking).
|
||||
Standard_Integer LastDetectedEdgeNode1() const { return myDetectedEdgeNode1; }
|
||||
@@ -196,13 +229,14 @@ public:
|
||||
Standard_Integer LastDetectedEdgeNode2() const { return myDetectedEdgeNode2; }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Checks whether the sensitive entity is overlapped by current selecting volume.
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
|
||||
@@ -216,16 +250,18 @@ public:
|
||||
}
|
||||
|
||||
//! Returns bounding box of triangle/edge with index theIdx
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns geometry center of triangle/edge with index theIdx
|
||||
//! in array along the given axis theAxis
|
||||
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Swaps items with indexes theIdx1 and theIdx2 in array
|
||||
Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of the triangulation. If location
|
||||
//! transformation is set, it will be applied
|
||||
@@ -233,10 +269,7 @@ public:
|
||||
|
||||
//! Returns center of triangulation. If location transformation
|
||||
//! is set, it will be applied
|
||||
virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE
|
||||
{
|
||||
return myCDG3D;
|
||||
}
|
||||
virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE { return myCDG3D; }
|
||||
|
||||
//! Returns true if the shape corresponding to the entity has init location
|
||||
virtual Standard_Boolean HasInitLocation() const Standard_OVERRIDE
|
||||
@@ -246,19 +279,16 @@ public:
|
||||
|
||||
//! Returns inversed location transformation matrix if the shape corresponding
|
||||
//! to this entity has init location set. Otherwise, returns identity matrix.
|
||||
virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE
|
||||
{
|
||||
return myInvInitLocation;
|
||||
}
|
||||
virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE { return myInvInitLocation; }
|
||||
|
||||
//! Sets the owner for all entities in group
|
||||
Standard_EXPORT virtual void Set (const Handle(SelectMgr_EntityOwner)& theOwnerId) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Set(const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Builds BVH tree for sensitive set.
|
||||
Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Compute bounding box.
|
||||
Standard_EXPORT void computeBoundingBox();
|
||||
|
||||
@@ -267,45 +297,48 @@ protected:
|
||||
Standard_EXPORT Select3D_BndBox3d applyTransformation();
|
||||
|
||||
//! Auxiliary getter.
|
||||
const Graphic3d_Vec3& getPosVec3 (const Standard_Integer theIndex) const
|
||||
const Graphic3d_Vec3& getPosVec3(const Standard_Integer theIndex) const
|
||||
{
|
||||
return *reinterpret_cast<const Graphic3d_Vec3* >(myPosData + myPosStride * theIndex);
|
||||
return *reinterpret_cast<const Graphic3d_Vec3*>(myPosData + myPosStride * theIndex);
|
||||
}
|
||||
|
||||
//! Auxiliary getter.
|
||||
const Graphic3d_Vec2& getPosVec2 (const Standard_Integer theIndex) const
|
||||
const Graphic3d_Vec2& getPosVec2(const Standard_Integer theIndex) const
|
||||
{
|
||||
return *reinterpret_cast<const Graphic3d_Vec2* >(myPosData + myPosStride * theIndex);
|
||||
return *reinterpret_cast<const Graphic3d_Vec2*>(myPosData + myPosStride * theIndex);
|
||||
}
|
||||
|
||||
//! Checks whether the element with index theIdx overlaps the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
|
||||
Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
|
||||
//! 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;
|
||||
|
||||
//! Checks whether the entity with index theIdx is inside the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
typedef NCollection_Shared<NCollection_Array1<Handle(Select3D_SensitivePrimitiveArray)> > Select3D_PrimArraySubGroupArray;
|
||||
typedef NCollection_Shared<NCollection_Array1<Handle(Select3D_SensitivePrimitiveArray)>>
|
||||
Select3D_PrimArraySubGroupArray;
|
||||
struct Select3D_SensitivePrimitiveArray_InitFunctor;
|
||||
struct Select3D_SensitivePrimitiveArray_BVHFunctor;
|
||||
|
||||
private:
|
||||
Handle(Select3D_PrimArraySubGroupArray) myGroups; //!< sub-groups of sensitive entities
|
||||
|
||||
Handle(Select3D_PrimArraySubGroupArray) myGroups; //!< sub-groups of sensitive entities
|
||||
|
||||
Handle(Graphic3d_Buffer) myVerts; //!< source data - nodes position
|
||||
Handle(Graphic3d_IndexBuffer) myIndices; //!< source data - primitive indexes
|
||||
const Standard_Byte* myPosData; //!< position vertex attribute data
|
||||
// clang-format off
|
||||
Handle(Graphic3d_Buffer) myVerts; //!< source data - nodes position
|
||||
Handle(Graphic3d_IndexBuffer) myIndices; //!< source data - primitive indexes
|
||||
const Standard_Byte* myPosData; //!< position vertex attribute data
|
||||
// clang-format off
|
||||
Standard_Size myPosStride; //!< position vertex attribute stride in bytes
|
||||
Graphic3d_TypeOfPrimitiveArray myPrimType; //!< primitives type
|
||||
Standard_Integer myIndexLower; //!< index range - first index in myIndices (inclusive)
|
||||
@@ -330,12 +363,10 @@ private:
|
||||
bool myToDetectElem; //!< flag to keep info about last detected element
|
||||
bool myToDetectNode; //!< flag to keep info about last detected node
|
||||
bool myToDetectEdge; //!< flag to keep info about last detected edge
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitivePrimitiveArray, Select3D_SensitiveSet)
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitivePrimitiveArray, Select3D_SensitiveSet)
|
||||
|
@@ -18,56 +18,53 @@
|
||||
#include <gp_Vec.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSegment, Select3D_SensitiveEntity)
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSegment,Select3D_SensitiveEntity)
|
||||
//=================================================================================================
|
||||
|
||||
//=====================================================
|
||||
// Function : Create
|
||||
// Purpose : Constructor
|
||||
//=====================================================
|
||||
Select3D_SensitiveSegment::Select3D_SensitiveSegment (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theFirstPnt,
|
||||
const gp_Pnt& theLastPnt)
|
||||
: Select3D_SensitiveEntity (theOwnerId)
|
||||
Select3D_SensitiveSegment::Select3D_SensitiveSegment(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theFirstPnt,
|
||||
const gp_Pnt& theLastPnt)
|
||||
: Select3D_SensitiveEntity(theOwnerId)
|
||||
{
|
||||
mySFactor = 3;
|
||||
myStart = theFirstPnt;
|
||||
myEnd = theLastPnt;
|
||||
myStart = theFirstPnt;
|
||||
myEnd = theLastPnt;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Matches
|
||||
// purpose : Checks whether the segment overlaps current selecting volume
|
||||
// =======================================================================
|
||||
Standard_Boolean Select3D_SensitiveSegment::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_Boolean Select3D_SensitiveSegment::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
if (!theMgr.IsOverlapAllowed()) // check for inclusion
|
||||
{
|
||||
if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline)
|
||||
{
|
||||
return theMgr.OverlapsSegment (myStart, myEnd, thePickResult);
|
||||
return theMgr.OverlapsSegment(myStart, myEnd, thePickResult);
|
||||
}
|
||||
return theMgr.OverlapsPoint (myStart, thePickResult) && theMgr.OverlapsPoint (myEnd, thePickResult);
|
||||
return theMgr.OverlapsPoint(myStart, thePickResult)
|
||||
&& theMgr.OverlapsPoint(myEnd, thePickResult);
|
||||
}
|
||||
|
||||
if (!theMgr.OverlapsSegment (myStart, myEnd, thePickResult)) // check for overlap
|
||||
if (!theMgr.OverlapsSegment(myStart, myEnd, thePickResult)) // check for overlap
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(CenterOfGeometry()));
|
||||
thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(CenterOfGeometry()));
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveSegment::GetConnected()
|
||||
{
|
||||
Handle(Select3D_SensitiveSegment) aNewEntity =
|
||||
new Select3D_SensitiveSegment (myOwnerId, myStart, myEnd);
|
||||
new Select3D_SensitiveSegment(myOwnerId, myStart, myEnd);
|
||||
|
||||
return aNewEntity;
|
||||
}
|
||||
@@ -89,13 +86,13 @@ gp_Pnt Select3D_SensitiveSegment::CenterOfGeometry() const
|
||||
//=======================================================================
|
||||
Select3D_BndBox3d Select3D_SensitiveSegment::BoundingBox()
|
||||
{
|
||||
const SelectMgr_Vec3 aMinPnt (Min (myStart.X(), myEnd.X()),
|
||||
Min (myStart.Y(), myEnd.Y()),
|
||||
Min (myStart.Z(), myEnd.Z()));
|
||||
const SelectMgr_Vec3 aMaxPnt (Max (myStart.X(), myEnd.X()),
|
||||
Max (myStart.Y(), myEnd.Y()),
|
||||
Max (myStart.Z(), myEnd.Z()));
|
||||
return Select3D_BndBox3d (aMinPnt, aMaxPnt);
|
||||
const SelectMgr_Vec3 aMinPnt(Min(myStart.X(), myEnd.X()),
|
||||
Min(myStart.Y(), myEnd.Y()),
|
||||
Min(myStart.Z(), myEnd.Z()));
|
||||
const SelectMgr_Vec3 aMaxPnt(Max(myStart.X(), myEnd.X()),
|
||||
Max(myStart.Y(), myEnd.Y()),
|
||||
Max(myStart.Z(), myEnd.Z()));
|
||||
return Select3D_BndBox3d(aMinPnt, aMaxPnt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -107,18 +104,17 @@ Standard_Integer Select3D_SensitiveSegment::NbSubElements() const
|
||||
return 2;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveSegment::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
//=================================================================================================
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myStart)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myEnd)
|
||||
void Select3D_SensitiveSegment::DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myStart)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myEnd)
|
||||
|
||||
Select3D_BndBox3d aBoundingBox = ((Select3D_SensitiveSegment*)this)->BoundingBox();
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aBoundingBox)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &aBoundingBox)
|
||||
}
|
||||
|
@@ -26,18 +26,17 @@ class Select3D_SensitiveSegment : public Select3D_SensitiveEntity
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveSegment, Select3D_SensitiveEntity)
|
||||
public:
|
||||
|
||||
//! Constructs the sensitive segment object defined by
|
||||
//! the owner theOwnerId, the points theFirstPnt, theLastPnt
|
||||
Standard_EXPORT Select3D_SensitiveSegment (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theFirstPnt,
|
||||
const gp_Pnt& theLastPnt);
|
||||
Standard_EXPORT Select3D_SensitiveSegment(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theFirstPnt,
|
||||
const gp_Pnt& theLastPnt);
|
||||
|
||||
//! changes the start Point of the Segment;
|
||||
void SetStartPoint (const gp_Pnt& thePnt) { myStart = thePnt; }
|
||||
void SetStartPoint(const gp_Pnt& thePnt) { myStart = thePnt; }
|
||||
|
||||
//! changes the end point of the segment
|
||||
void SetEndPoint (const gp_Pnt& thePnt) { myEnd = thePnt; }
|
||||
void SetEndPoint(const gp_Pnt& thePnt) { myEnd = thePnt; }
|
||||
|
||||
//! gives the 3D start Point of the Segment
|
||||
const gp_Pnt& StartPoint() const { return myStart; }
|
||||
@@ -51,8 +50,9 @@ public:
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
|
||||
//! Checks whether the segment overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns center of the segment. If location transformation
|
||||
//! is set, it will be applied
|
||||
@@ -66,20 +66,19 @@ public:
|
||||
virtual Standard_Boolean ToBuildBVH() const Standard_OVERRIDE { return Standard_False; }
|
||||
|
||||
public:
|
||||
|
||||
//! changes the start Point of the Segment;
|
||||
void StartPoint (const gp_Pnt& thePnt) { myStart = thePnt; }
|
||||
void StartPoint(const gp_Pnt& thePnt) { myStart = thePnt; }
|
||||
|
||||
//! changes the end point of the segment
|
||||
void EndPoint (const gp_Pnt& thePnt) { myEnd = thePnt; }
|
||||
void EndPoint(const gp_Pnt& thePnt) { myEnd = thePnt; }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
gp_Pnt myStart; //!< Start point
|
||||
gp_Pnt myEnd; //!< End point
|
||||
gp_Pnt myStart; //!< Start point
|
||||
gp_Pnt myEnd; //!< End point
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveSegment, Select3D_SensitiveEntity)
|
||||
|
@@ -17,28 +17,27 @@
|
||||
|
||||
#include <BVH_LinearBuilder.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSet,Select3D_SensitiveEntity)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSet, Select3D_SensitiveEntity)
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Default BVH tree builder for sensitive set (optimal for large set of small primitives - for not too long construction time).
|
||||
static Handle(Select3D_BVHBuilder3d) THE_SENS_SET_BUILDER = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSmall, BVH_Constants_MaxTreeDepth);
|
||||
}
|
||||
//! Default BVH tree builder for sensitive set (optimal for large set of small primitives - for not
|
||||
//! too long construction time).
|
||||
static Handle(Select3D_BVHBuilder3d) THE_SENS_SET_BUILDER =
|
||||
new BVH_LinearBuilder<Standard_Real, 3>(BVH_Constants_LeafNodeSizeSmall,
|
||||
BVH_Constants_MaxTreeDepth);
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : DefaultBVHBuilder
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
const Handle(Select3D_BVHBuilder3d)& Select3D_SensitiveSet::DefaultBVHBuilder()
|
||||
{
|
||||
return THE_SENS_SET_BUILDER;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetDefaultBVHBuilder
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveSet::SetDefaultBVHBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder)
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveSet::SetDefaultBVHBuilder(const Handle(Select3D_BVHBuilder3d)& theBuilder)
|
||||
{
|
||||
THE_SENS_SET_BUILDER = theBuilder;
|
||||
}
|
||||
@@ -47,12 +46,12 @@ void Select3D_SensitiveSet::SetDefaultBVHBuilder (const Handle(Select3D_BVHBuild
|
||||
// function : Select3D_SensitiveSet
|
||||
// purpose : Creates new empty sensitive set and its content
|
||||
//=======================================================================
|
||||
Select3D_SensitiveSet::Select3D_SensitiveSet (const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
: Select3D_SensitiveEntity (theOwnerId),
|
||||
myDetectedIdx (-1)
|
||||
Select3D_SensitiveSet::Select3D_SensitiveSet(const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
: Select3D_SensitiveEntity(theOwnerId),
|
||||
myDetectedIdx(-1)
|
||||
{
|
||||
myContent.SetSensitiveSet (this);
|
||||
myContent.SetBuilder (THE_SENS_SET_BUILDER);
|
||||
myContent.SetSensitiveSet(this);
|
||||
myContent.SetBuilder(THE_SENS_SET_BUILDER);
|
||||
myContent.MarkDirty();
|
||||
}
|
||||
|
||||
@@ -67,37 +66,38 @@ void Select3D_SensitiveSet::BVH()
|
||||
|
||||
namespace
|
||||
{
|
||||
//! This structure describes the node in BVH
|
||||
struct NodeInStack
|
||||
//! This structure describes the node in BVH
|
||||
struct NodeInStack
|
||||
{
|
||||
NodeInStack(Standard_Integer theId = 0, Standard_Boolean theIsFullInside = false)
|
||||
: Id(theId),
|
||||
IsFullInside(theIsFullInside)
|
||||
{
|
||||
NodeInStack (Standard_Integer theId = 0,
|
||||
Standard_Boolean theIsFullInside = false) : Id (theId), IsFullInside (theIsFullInside) {}
|
||||
}
|
||||
|
||||
Standard_Integer Id; //!< node identifier
|
||||
// clang-format off
|
||||
Standard_Integer Id; //!< node identifier
|
||||
// clang-format off
|
||||
Standard_Boolean IsFullInside; //!< if the node is completely inside the current selection volume
|
||||
// clang-format on
|
||||
};
|
||||
}
|
||||
// clang-format on
|
||||
};
|
||||
} // namespace
|
||||
|
||||
//=======================================================================
|
||||
// function : processElements
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveSet::processElements (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theFirstElem,
|
||||
Standard_Integer theLastElem,
|
||||
Standard_Boolean theIsFullInside,
|
||||
Standard_Boolean theToCheckAllInside,
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
Standard_Integer& theMatchesNb)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveSet::processElements(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theFirstElem,
|
||||
Standard_Integer theLastElem,
|
||||
Standard_Boolean theIsFullInside,
|
||||
Standard_Boolean theToCheckAllInside,
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
Standard_Integer& theMatchesNb)
|
||||
{
|
||||
SelectBasics_PickResult aPickResult;
|
||||
for (Standard_Integer anIdx = theFirstElem; anIdx <= theLastElem; anIdx++)
|
||||
{
|
||||
if (!theMgr.IsOverlapAllowed()) // inclusion test
|
||||
{
|
||||
if (!elementIsInside (theMgr, anIdx, theIsFullInside))
|
||||
if (!elementIsInside(theMgr, anIdx, theIsFullInside))
|
||||
{
|
||||
if (theToCheckAllInside)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ Standard_Boolean Select3D_SensitiveSet::processElements (SelectBasics_SelectingV
|
||||
}
|
||||
else // overlap test
|
||||
{
|
||||
if (!overlapsElement (aPickResult, theMgr, anIdx, theIsFullInside))
|
||||
if (!overlapsElement(aPickResult, theMgr, anIdx, theIsFullInside))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -125,27 +125,23 @@ Standard_Boolean Select3D_SensitiveSet::processElements (SelectBasics_SelectingV
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Matches
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveSet::matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
Standard_Boolean theToCheckAllInside)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveSet::matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
Standard_Boolean theToCheckAllInside)
|
||||
{
|
||||
myDetectedIdx = -1;
|
||||
|
||||
|
||||
if (myContent.Size() < 1)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
const Select3D_BndBox3d& aGlobalBox = myContent.Box();
|
||||
Standard_Boolean isFullInside = Standard_True;
|
||||
const Select3D_BndBox3d& aGlobalBox = myContent.Box();
|
||||
Standard_Boolean isFullInside = Standard_True;
|
||||
|
||||
if (!theMgr.OverlapsBox (aGlobalBox.CornerMin(),
|
||||
aGlobalBox.CornerMax(),
|
||||
&isFullInside))
|
||||
if (!theMgr.OverlapsBox(aGlobalBox.CornerMin(), aGlobalBox.CornerMax(), &isFullInside))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -156,7 +152,13 @@ Standard_Boolean Select3D_SensitiveSet::matches (SelectBasics_SelectingVolumeMan
|
||||
if (toCheckFullInside && isFullInside)
|
||||
{
|
||||
Standard_Integer aSize = myContent.Size();
|
||||
if (!processElements (theMgr, 0, aSize - 1, Standard_True, theToCheckAllInside, thePickResult, aMatchesNb))
|
||||
if (!processElements(theMgr,
|
||||
0,
|
||||
aSize - 1,
|
||||
Standard_True,
|
||||
theToCheckAllInside,
|
||||
thePickResult,
|
||||
aMatchesNb))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -164,8 +166,8 @@ Standard_Boolean Select3D_SensitiveSet::matches (SelectBasics_SelectingVolumeMan
|
||||
else
|
||||
{
|
||||
const BVH_Tree<Standard_Real, 3, BVH_BinaryTree>* aBVH = myContent.GetBVH().get();
|
||||
NodeInStack aStack[BVH_Constants_MaxTreeDepth];
|
||||
NodeInStack aNode;
|
||||
NodeInStack aStack[BVH_Constants_MaxTreeDepth];
|
||||
NodeInStack aNode;
|
||||
|
||||
Standard_Integer aHead = -1;
|
||||
|
||||
@@ -175,17 +177,21 @@ Standard_Boolean Select3D_SensitiveSet::matches (SelectBasics_SelectingVolumeMan
|
||||
|
||||
if (aData.x() == 0) // is inner node
|
||||
{
|
||||
NodeInStack aLeft (aData.y(), toCheckFullInside), aRight(aData.z(), toCheckFullInside);
|
||||
NodeInStack aLeft(aData.y(), toCheckFullInside), aRight(aData.z(), toCheckFullInside);
|
||||
Standard_Boolean toCheckLft = Standard_True, toCheckRgh = Standard_True;
|
||||
if (!aNode.IsFullInside)
|
||||
{
|
||||
toCheckLft = theMgr.OverlapsBox (aBVH->MinPoint (aLeft.Id), aBVH->MaxPoint (aLeft.Id), toCheckFullInside ? &aLeft.IsFullInside : NULL);
|
||||
toCheckLft = theMgr.OverlapsBox(aBVH->MinPoint(aLeft.Id),
|
||||
aBVH->MaxPoint(aLeft.Id),
|
||||
toCheckFullInside ? &aLeft.IsFullInside : NULL);
|
||||
if (!toCheckLft)
|
||||
{
|
||||
aLeft.IsFullInside = Standard_False;
|
||||
}
|
||||
|
||||
toCheckRgh = theMgr.OverlapsBox (aBVH->MinPoint (aRight.Id), aBVH->MaxPoint (aRight.Id), toCheckFullInside ? &aRight.IsFullInside : NULL);
|
||||
toCheckRgh = theMgr.OverlapsBox(aBVH->MinPoint(aRight.Id),
|
||||
aBVH->MaxPoint(aRight.Id),
|
||||
toCheckFullInside ? &aRight.IsFullInside : NULL);
|
||||
if (!toCheckRgh)
|
||||
{
|
||||
aRight.IsFullInside = Standard_False;
|
||||
@@ -225,7 +231,13 @@ Standard_Boolean Select3D_SensitiveSet::matches (SelectBasics_SelectingVolumeMan
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!processElements (theMgr, aData.y(), aData.z(), aNode.IsFullInside, theToCheckAllInside, thePickResult, aMatchesNb))
|
||||
if (!processElements(theMgr,
|
||||
aData.y(),
|
||||
aData.z(),
|
||||
aNode.IsFullInside,
|
||||
theToCheckAllInside,
|
||||
thePickResult,
|
||||
aMatchesNb))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -240,11 +252,10 @@ Standard_Boolean Select3D_SensitiveSet::matches (SelectBasics_SelectingVolumeMan
|
||||
|
||||
if (aMatchesNb != -1)
|
||||
{
|
||||
thePickResult.SetDistToGeomCenter (distanceToCOG (theMgr));
|
||||
thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
|
||||
}
|
||||
|
||||
return aMatchesNb != -1
|
||||
|| (!theToCheckAllInside && !theMgr.IsOverlapAllowed());
|
||||
return aMatchesNb != -1 || (!theToCheckAllInside && !theMgr.IsOverlapAllowed());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -254,8 +265,7 @@ Standard_Boolean Select3D_SensitiveSet::matches (SelectBasics_SelectingVolumeMan
|
||||
//=======================================================================
|
||||
Select3D_BndBox3d Select3D_SensitiveSet::BoundingBox()
|
||||
{
|
||||
return Select3D_BndBox3d (SelectMgr_Vec3 (RealLast()),
|
||||
SelectMgr_Vec3 (RealFirst()));
|
||||
return Select3D_BndBox3d(SelectMgr_Vec3(RealLast()), SelectMgr_Vec3(RealFirst()));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -265,7 +275,7 @@ Select3D_BndBox3d Select3D_SensitiveSet::BoundingBox()
|
||||
//=======================================================================
|
||||
gp_Pnt Select3D_SensitiveSet::CenterOfGeometry() const
|
||||
{
|
||||
return gp_Pnt (RealLast(), RealLast(), RealLast());
|
||||
return gp_Pnt(RealLast(), RealLast(), RealLast());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -277,19 +287,17 @@ void Select3D_SensitiveSet::Clear()
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveSet::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveSet::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myContent)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myContent)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDetectedIdx)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myDetectedIdx)
|
||||
|
||||
Select3D_BndBox3d aBoundingBox = ((Select3D_SensitiveSet*)this)->BoundingBox();
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aBoundingBox)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &aBoundingBox)
|
||||
}
|
||||
|
@@ -32,40 +32,37 @@ class Select3D_SensitiveSet : public Select3D_SensitiveEntity
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveSet, Select3D_SensitiveEntity)
|
||||
public:
|
||||
|
||||
//! Return global instance to default BVH builder.
|
||||
Standard_EXPORT static const Handle(Select3D_BVHBuilder3d)& DefaultBVHBuilder();
|
||||
|
||||
//! Assign new BVH builder to be used by default for new sensitive sets (assigning is NOT thread-safe!).
|
||||
Standard_EXPORT static void SetDefaultBVHBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder);
|
||||
//! Assign new BVH builder to be used by default for new sensitive sets (assigning is NOT
|
||||
//! thread-safe!).
|
||||
Standard_EXPORT static void SetDefaultBVHBuilder(const Handle(Select3D_BVHBuilder3d)& theBuilder);
|
||||
|
||||
public:
|
||||
|
||||
//! Creates new empty sensitive set and its content
|
||||
Standard_EXPORT Select3D_SensitiveSet (const Handle(SelectMgr_EntityOwner)& theOwnerId);
|
||||
Standard_EXPORT Select3D_SensitiveSet(const Handle(SelectMgr_EntityOwner)& theOwnerId);
|
||||
|
||||
public:
|
||||
|
||||
//! Returns the amount of sub-entities of the complex entity
|
||||
virtual Standard_Integer Size() const = 0;
|
||||
|
||||
//! Returns bounding box of sub-entity with index theIdx in sub-entity list
|
||||
virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const = 0;
|
||||
virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const = 0;
|
||||
|
||||
//! Returns geometry center of sensitive entity index theIdx along the given axis theAxis
|
||||
virtual Standard_Real Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const = 0;
|
||||
virtual Standard_Real Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const = 0;
|
||||
|
||||
//! Swaps items with indexes theIdx1 and theIdx2
|
||||
virtual void Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) = 0;
|
||||
virtual void Swap(const Standard_Integer theIdx1, const Standard_Integer theIdx2) = 0;
|
||||
|
||||
//! Checks whether one or more entities of the set overlap current selecting volume.
|
||||
//! Implements the traverse of BVH tree built for the set
|
||||
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
|
||||
virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
|
||||
{
|
||||
return matches (theMgr, thePickResult, false);
|
||||
return matches(theMgr, thePickResult, false);
|
||||
}
|
||||
|
||||
//! Builds BVH tree for sensitive set.
|
||||
@@ -78,7 +75,10 @@ public:
|
||||
virtual Standard_Boolean ToBuildBVH() const Standard_OVERRIDE { return myContent.IsDirty(); }
|
||||
|
||||
//! Sets the method (builder) used to construct BVH.
|
||||
void SetBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder) { myContent.SetBuilder (theBuilder); }
|
||||
void SetBuilder(const Handle(Select3D_BVHBuilder3d)& theBuilder)
|
||||
{
|
||||
myContent.SetBuilder(theBuilder);
|
||||
}
|
||||
|
||||
//! Marks BVH tree of the set as outdated. It will be rebuild
|
||||
//! at the next call of BVH()
|
||||
@@ -99,72 +99,79 @@ public:
|
||||
Standard_Integer GetLeafNodeSize() const { return myContent.Builder()->LeafNodeSize(); }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Checks whether one or more entities of the set overlap current selecting volume.
|
||||
//! Implements the traverse of BVH tree built for the set
|
||||
//! @param theMgr selection manager
|
||||
//! @param thePickResult picking result (for picking by ray)
|
||||
//! @param theToCheckAllInside flag indicating that even with SelectMgr_SelectingVolumeManager::IsOverlapAllowed() returning FALSE
|
||||
//! the method will return TRUE if at least one sub-element is fully inside selection volume ::elementIsInside();
|
||||
//! this is useful for entities allowing local selection of sub-elements using single Owner object.
|
||||
Standard_EXPORT Standard_Boolean matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
Standard_Boolean theToCheckAllInside);
|
||||
//! @param theToCheckAllInside flag indicating that even with
|
||||
//! SelectMgr_SelectingVolumeManager::IsOverlapAllowed() returning FALSE
|
||||
//! the method will return TRUE if at least one sub-element is fully inside selection
|
||||
//! volume ::elementIsInside(); this is useful for entities allowing local selection of
|
||||
//! sub-elements using single Owner object.
|
||||
Standard_EXPORT Standard_Boolean matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
Standard_Boolean theToCheckAllInside);
|
||||
|
||||
//! Checks whether the entity with index theIdx (partially) overlaps the current selecting volume.
|
||||
//! @param[out] thePickResult picking result, should update minimum depth
|
||||
//! @param[in] theMgr selection manager
|
||||
//! @param[in] theElemIdx element index within BVH tree to check
|
||||
//! @param[in] theIsFullInside when TRUE indicates that entire BVH node is already inside selection volume (in case of rectangle selection);
|
||||
//! in this case algorithm might skip checking the element and just register it as detected
|
||||
virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) = 0;
|
||||
//! @param[in] theIsFullInside when TRUE indicates that entire BVH node is already inside
|
||||
//! selection volume (in case of rectangle selection);
|
||||
//! in this case algorithm might skip checking the element and just
|
||||
//! register it as detected
|
||||
virtual Standard_Boolean overlapsElement(SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) = 0;
|
||||
|
||||
//! Checks whether the entity with index theIdx is (fully) inside the current selecting volume
|
||||
//! @param[in] theMgr selection manager
|
||||
//! @param[in] theElemIdx element index within BVH tree to check
|
||||
//! @param[in] theIsFullInside when TRUE indicates that entire BVH node is already inside selection volume (in case of rectangle selection);
|
||||
//! in this case algorithm might skip checking the element and just register it as detected
|
||||
virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) = 0;
|
||||
//! @param[in] theIsFullInside when TRUE indicates that entire BVH node is already inside
|
||||
//! selection volume (in case of rectangle selection);
|
||||
//! in this case algorithm might skip checking the element and just
|
||||
//! register it as detected
|
||||
virtual Standard_Boolean elementIsInside(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) = 0;
|
||||
|
||||
//! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
|
||||
virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) = 0;
|
||||
//! Calculates distance from the 3d projection of used-picked screen point to center of the
|
||||
//! geometry
|
||||
virtual Standard_Real distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr) = 0;
|
||||
|
||||
//! Process elements overlapped by the selection volume
|
||||
//! @param theMgr selection manager
|
||||
//! @param theFirstElem index of the first element
|
||||
//! @param theLastElem index of the last element
|
||||
//! @param theIsFullInside when TRUE indicates that entire BVH node is already inside selection volume
|
||||
//! @param theIsFullInside when TRUE indicates that entire BVH node is already inside selection
|
||||
//! volume
|
||||
//! @param[out] thePickResult picking result (for picking by ray)
|
||||
//! @param[out] theMatchesNb number of processed elements
|
||||
//! @return FALSE if some element is outside the selection volume (if IsOverlapAllowed is FALSE); TRUE otherwise
|
||||
Standard_EXPORT Standard_Boolean processElements (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theFirstElem,
|
||||
Standard_Integer theLastElem,
|
||||
Standard_Boolean theIsFullInside,
|
||||
Standard_Boolean theToCheckAllInside,
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
Standard_Integer& theMatchesNb);
|
||||
//! @return FALSE if some element is outside the selection volume (if IsOverlapAllowed is FALSE);
|
||||
//! TRUE otherwise
|
||||
Standard_EXPORT Standard_Boolean processElements(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theFirstElem,
|
||||
Standard_Integer theLastElem,
|
||||
Standard_Boolean theIsFullInside,
|
||||
Standard_Boolean theToCheckAllInside,
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
Standard_Integer& theMatchesNb);
|
||||
|
||||
protected:
|
||||
|
||||
//! The purpose of this class is to provide a link between BVH_PrimitiveSet
|
||||
//! and Select3D_SensitiveSet instance to build BVH tree for set of sensitives.
|
||||
class BvhPrimitiveSet : public BVH_PrimitiveSet3d
|
||||
{
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
BvhPrimitiveSet()
|
||||
: BVH_PrimitiveSet3d(Handle(Select3D_BVHBuilder3d)()),
|
||||
mySensitiveSet(NULL)
|
||||
: BVH_PrimitiveSet3d(Handle(Select3D_BVHBuilder3d)()),
|
||||
mySensitiveSet(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -172,7 +179,7 @@ protected:
|
||||
~BvhPrimitiveSet() {}
|
||||
|
||||
//! Setup sensitivity set.
|
||||
void SetSensitiveSet (Select3D_SensitiveSet* theSensitiveSet)
|
||||
void SetSensitiveSet(Select3D_SensitiveSet* theSensitiveSet)
|
||||
{
|
||||
mySensitiveSet = theSensitiveSet;
|
||||
MarkDirty();
|
||||
@@ -182,35 +189,45 @@ protected:
|
||||
virtual Standard_Integer Size() const Standard_OVERRIDE { return mySensitiveSet->Size(); }
|
||||
|
||||
//! Returns bounding box of sensitive with index theIdx
|
||||
virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE { return mySensitiveSet->Box (theIdx); }
|
||||
virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const Standard_OVERRIDE
|
||||
{
|
||||
return mySensitiveSet->Box(theIdx);
|
||||
}
|
||||
|
||||
//! Make inherited method Box() visible to avoid CLang warning
|
||||
using BVH_PrimitiveSet3d::Box;
|
||||
|
||||
//! Returns center of sensitive with index theIdx in the set along the given axis theAxis
|
||||
virtual Standard_Real Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const Standard_OVERRIDE { return mySensitiveSet->Center (theIdx, theAxis); }
|
||||
virtual Standard_Real Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const Standard_OVERRIDE
|
||||
{
|
||||
return mySensitiveSet->Center(theIdx, theAxis);
|
||||
}
|
||||
|
||||
//! Swaps items with indexes theIdx1 and theIdx2 in the set
|
||||
virtual void Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE { mySensitiveSet->Swap (theIdx1, theIdx2); }
|
||||
virtual void Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE
|
||||
{
|
||||
mySensitiveSet->Swap(theIdx1, theIdx2);
|
||||
}
|
||||
|
||||
//! Returns the tree built for set of sensitives
|
||||
const opencascade::handle<BVH_Tree<Standard_Real, 3> >& GetBVH() { return BVH(); }
|
||||
const opencascade::handle<BVH_Tree<Standard_Real, 3>>& GetBVH() { return BVH(); }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const
|
||||
{ (void)theOStream; (void)theDepth; }
|
||||
void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const
|
||||
{
|
||||
(void)theOStream;
|
||||
(void)theDepth;
|
||||
}
|
||||
|
||||
protected:
|
||||
Select3D_SensitiveSet* mySensitiveSet; //!< Set of sensitive entities
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
BvhPrimitiveSet myContent; //!< A link between sensitive entity and BVH_PrimitiveSet
|
||||
Standard_Integer myDetectedIdx; //!< Index of detected primitive in BVH sorted primitive array
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveSet, Select3D_SensitiveEntity)
|
||||
|
@@ -21,13 +21,13 @@ IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSphere, Select3D_SensitiveEntity)
|
||||
// Function: Select3D_SensitiveSphere
|
||||
// Purpose :
|
||||
// ==================================================
|
||||
Select3D_SensitiveSphere::Select3D_SensitiveSphere (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theCenter,
|
||||
const Standard_Real theRadius)
|
||||
: Select3D_SensitiveEntity (theOwnerId),
|
||||
myCenter (theCenter),
|
||||
myLastDetectedPoint (RealLast(), RealLast(), RealLast()),
|
||||
myRadius (theRadius)
|
||||
Select3D_SensitiveSphere::Select3D_SensitiveSphere(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theCenter,
|
||||
const Standard_Real theRadius)
|
||||
: Select3D_SensitiveEntity(theOwnerId),
|
||||
myCenter(theCenter),
|
||||
myLastDetectedPoint(RealLast(), RealLast(), RealLast()),
|
||||
myRadius(theRadius)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,28 +35,28 @@ Select3D_SensitiveSphere::Select3D_SensitiveSphere (const Handle(SelectMgr_Entit
|
||||
// Function: Mathes
|
||||
// Purpose :
|
||||
// ==================================================
|
||||
Standard_Boolean Select3D_SensitiveSphere::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_Boolean Select3D_SensitiveSphere::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
myLastDetectedPoint = gp_Pnt (RealLast(), RealLast(), RealLast());
|
||||
myLastDetectedPoint = gp_Pnt(RealLast(), RealLast(), RealLast());
|
||||
if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point)
|
||||
{
|
||||
if (!theMgr.IsOverlapAllowed())
|
||||
{
|
||||
Standard_Boolean isInside = Standard_True;
|
||||
return theMgr.OverlapsSphere (myCenter, myRadius, &isInside) && isInside;
|
||||
return theMgr.OverlapsSphere(myCenter, myRadius, &isInside) && isInside;
|
||||
}
|
||||
else
|
||||
{
|
||||
return theMgr.OverlapsSphere (myCenter, myRadius, NULL);
|
||||
return theMgr.OverlapsSphere(myCenter, myRadius, NULL);
|
||||
}
|
||||
}
|
||||
if (!theMgr.OverlapsSphere (myCenter, myRadius, thePickResult))
|
||||
if (!theMgr.OverlapsSphere(myCenter, myRadius, thePickResult))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
myLastDetectedPoint = thePickResult.PickedPoint();
|
||||
thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (myCenter));
|
||||
thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(myCenter));
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,8 @@ Standard_Boolean Select3D_SensitiveSphere::Matches (SelectBasics_SelectingVolume
|
||||
// ==================================================
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveSphere::GetConnected()
|
||||
{
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveSphere (myOwnerId, myCenter, myRadius);
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity =
|
||||
new Select3D_SensitiveSphere(myOwnerId, myCenter, myRadius);
|
||||
return aNewEntity;
|
||||
}
|
||||
|
||||
@@ -76,7 +77,9 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveSphere::GetConnected()
|
||||
// ==================================================
|
||||
Select3D_BndBox3d Select3D_SensitiveSphere::BoundingBox()
|
||||
{
|
||||
const SelectMgr_Vec3 aMinPnt = SelectMgr_Vec3 (myCenter.X() - myRadius, myCenter.Y() - myRadius, myCenter.Z() - myRadius);
|
||||
const SelectMgr_Vec3 aMaxPnt = SelectMgr_Vec3 (myCenter.X() + myRadius, myCenter.Y() + myRadius, myCenter.Z() + myRadius);
|
||||
return Select3D_BndBox3d (aMinPnt, aMaxPnt);
|
||||
const SelectMgr_Vec3 aMinPnt =
|
||||
SelectMgr_Vec3(myCenter.X() - myRadius, myCenter.Y() - myRadius, myCenter.Z() - myRadius);
|
||||
const SelectMgr_Vec3 aMaxPnt =
|
||||
SelectMgr_Vec3(myCenter.X() + myRadius, myCenter.Y() + myRadius, myCenter.Z() + myRadius);
|
||||
return Select3D_BndBox3d(aMinPnt, aMaxPnt);
|
||||
}
|
||||
|
@@ -23,21 +23,20 @@ class Select3D_SensitiveSphere : public Select3D_SensitiveEntity
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveSphere, Select3D_SensitiveEntity)
|
||||
public:
|
||||
|
||||
//! Constructs a sensitive sphere object defined by the owner theOwnerId,
|
||||
//! the center of the sphere and it's radius.
|
||||
Standard_EXPORT Select3D_SensitiveSphere (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theCenter,
|
||||
const Standard_Real theRadius);
|
||||
Standard_EXPORT Select3D_SensitiveSphere(const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& theCenter,
|
||||
const Standard_Real theRadius);
|
||||
|
||||
//! Returns the radius of the sphere
|
||||
Standard_Real Radius() const { return myRadius; }
|
||||
|
||||
public:
|
||||
|
||||
//! Checks whether the sphere overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns the copy of this
|
||||
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
|
||||
@@ -61,7 +60,7 @@ public:
|
||||
//! Invalidate the position of detected point on the sphere.
|
||||
void ResetLastDetectedPoint()
|
||||
{
|
||||
myLastDetectedPoint = gp_Pnt (RealLast(), RealLast(), RealLast());
|
||||
myLastDetectedPoint = gp_Pnt(RealLast(), RealLast(), RealLast());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@@ -18,24 +18,23 @@
|
||||
|
||||
#include <TopLoc_Location.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveTriangle,Select3D_SensitiveEntity)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveTriangle, Select3D_SensitiveEntity)
|
||||
|
||||
//==================================================
|
||||
// Function: Creation
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Select3D_SensitiveTriangle::Select3D_SensitiveTriangle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& thePnt0,
|
||||
const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const Select3D_TypeOfSensitivity theType)
|
||||
: Select3D_SensitiveEntity (theOwnerId),
|
||||
mySensType (theType)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveTriangle::Select3D_SensitiveTriangle(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& thePnt0,
|
||||
const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const Select3D_TypeOfSensitivity theType)
|
||||
: Select3D_SensitiveEntity(theOwnerId),
|
||||
mySensType(theType)
|
||||
{
|
||||
myPoints[0] = thePnt0;
|
||||
myPoints[1] = thePnt1;
|
||||
myPoints[2] = thePnt2;
|
||||
myCentroid = (thePnt0.XYZ() + thePnt1.XYZ() + thePnt2.XYZ()) * (1.0 / 3.0);
|
||||
myCentroid = (thePnt0.XYZ() + thePnt1.XYZ() + thePnt2.XYZ()) * (1.0 / 3.0);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
@@ -43,39 +42,36 @@ Select3D_SensitiveTriangle::Select3D_SensitiveTriangle (const Handle(SelectMgr_E
|
||||
// Purpose : Checks whether the triangle overlaps
|
||||
// current selecting volume
|
||||
//==================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_Boolean Select3D_SensitiveTriangle::Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
if (!theMgr.IsOverlapAllowed())
|
||||
{
|
||||
if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline)
|
||||
{
|
||||
SelectBasics_PickResult aDummy;
|
||||
return theMgr.OverlapsTriangle (myPoints[0], myPoints[1], myPoints[2], mySensType, aDummy);
|
||||
return theMgr.OverlapsTriangle(myPoints[0], myPoints[1], myPoints[2], mySensType, aDummy);
|
||||
}
|
||||
return theMgr.OverlapsPoint (myPoints[0])
|
||||
&& theMgr.OverlapsPoint (myPoints[1])
|
||||
&& theMgr.OverlapsPoint (myPoints[2]);
|
||||
return theMgr.OverlapsPoint(myPoints[0]) && theMgr.OverlapsPoint(myPoints[1])
|
||||
&& theMgr.OverlapsPoint(myPoints[2]);
|
||||
}
|
||||
|
||||
if (!theMgr.OverlapsTriangle (myPoints[0], myPoints[1], myPoints[2], mySensType, thePickResult))
|
||||
if (!theMgr.OverlapsTriangle(myPoints[0], myPoints[1], myPoints[2], mySensType, thePickResult))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCentroid));
|
||||
thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(myCentroid));
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: GetConnected
|
||||
// Purpose :
|
||||
//==================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangle::GetConnected()
|
||||
{
|
||||
// Create a copy of this
|
||||
Handle(Select3D_SensitiveEntity) aNewEntity =
|
||||
new Select3D_SensitiveTriangle (myOwnerId, myPoints[0], myPoints[1], myPoints[2], mySensType);
|
||||
new Select3D_SensitiveTriangle(myOwnerId, myPoints[0], myPoints[1], myPoints[2], mySensType);
|
||||
|
||||
return aNewEntity;
|
||||
}
|
||||
@@ -88,30 +84,31 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangle::GetConnected()
|
||||
//==================================================
|
||||
Select3D_BndBox3d Select3D_SensitiveTriangle::BoundingBox()
|
||||
{
|
||||
const SelectMgr_Vec3 aMinPnt = SelectMgr_Vec3 (Min (myPoints[0].X(), Min (myPoints[1].X(), myPoints[2].X())),
|
||||
Min (myPoints[0].Y(), Min (myPoints[1].Y(), myPoints[2].Y())),
|
||||
Min (myPoints[0].Z(), Min (myPoints[1].Z(), myPoints[2].Z())));
|
||||
const SelectMgr_Vec3 aMaxPnt = SelectMgr_Vec3 (Max (myPoints[0].X(), Max (myPoints[1].X(), myPoints[2].X())),
|
||||
Max (myPoints[0].Y(), Max (myPoints[1].Y(), myPoints[2].Y())),
|
||||
Max (myPoints[0].Z(), Max (myPoints[1].Z(), myPoints[2].Z())));
|
||||
return Select3D_BndBox3d (aMinPnt, aMaxPnt);
|
||||
const SelectMgr_Vec3 aMinPnt =
|
||||
SelectMgr_Vec3(Min(myPoints[0].X(), Min(myPoints[1].X(), myPoints[2].X())),
|
||||
Min(myPoints[0].Y(), Min(myPoints[1].Y(), myPoints[2].Y())),
|
||||
Min(myPoints[0].Z(), Min(myPoints[1].Z(), myPoints[2].Z())));
|
||||
const SelectMgr_Vec3 aMaxPnt =
|
||||
SelectMgr_Vec3(Max(myPoints[0].X(), Max(myPoints[1].X(), myPoints[2].X())),
|
||||
Max(myPoints[0].Y(), Max(myPoints[1].Y(), myPoints[2].Y())),
|
||||
Max(myPoints[0].Z(), Max(myPoints[1].Z(), myPoints[2].Z())));
|
||||
return Select3D_BndBox3d(aMinPnt, aMaxPnt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveTriangle::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveTriangle::DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveEntity)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySensType)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, mySensType)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPoints[0])
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPoints[1])
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPoints[2])
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myPoints[0])
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myPoints[1])
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myPoints[2])
|
||||
|
||||
Select3D_BndBox3d aBoundingBox = ((Select3D_SensitiveTriangle*)this)->BoundingBox();
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aBoundingBox)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &aBoundingBox)
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@
|
||||
#include <Select3D_SensitivePoly.hxx>
|
||||
#include <SelectMgr_SelectingVolumeManager.hxx>
|
||||
|
||||
|
||||
//! A framework to define selection of triangles in a view.
|
||||
//! This comes into play in the detection of meshing and triangulation in surfaces.
|
||||
//! In some cases this class can raise Standard_ConstructionError and
|
||||
@@ -29,21 +28,22 @@
|
||||
class Select3D_SensitiveTriangle : public Select3D_SensitiveEntity
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructs a sensitive triangle object defined by the
|
||||
//! owner theOwnerId, the points P1, P2, P3, and the type of sensitivity Sensitivity.
|
||||
Standard_EXPORT Select3D_SensitiveTriangle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& thePnt0,
|
||||
const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const Select3D_TypeOfSensitivity theType = Select3D_TOS_INTERIOR);
|
||||
Standard_EXPORT Select3D_SensitiveTriangle(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Pnt& thePnt0,
|
||||
const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const Select3D_TypeOfSensitivity theType = Select3D_TOS_INTERIOR);
|
||||
|
||||
//! Checks whether the triangle overlaps current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns the 3D points P1, P2, P3 used at the time of construction.
|
||||
void Points3D (gp_Pnt& thePnt0, gp_Pnt& thePnt1, gp_Pnt& thePnt2) const
|
||||
void Points3D(gp_Pnt& thePnt0, gp_Pnt& thePnt1, gp_Pnt& thePnt2) const
|
||||
{
|
||||
thePnt0 = myPoints[0];
|
||||
thePnt1 = myPoints[1];
|
||||
@@ -69,14 +69,14 @@ public:
|
||||
virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE { return myCentroid; }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveTriangle,Select3D_SensitiveEntity)
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveTriangle, Select3D_SensitiveEntity)
|
||||
|
||||
private:
|
||||
|
||||
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: boundary or interior
|
||||
gp_Pnt myCentroid; //!< Center of triangle
|
||||
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: boundary or interior
|
||||
gp_Pnt myCentroid; //!< Center of triangle
|
||||
gp_Pnt myPoints[3];
|
||||
};
|
||||
|
||||
|
@@ -24,83 +24,85 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveTriangulation,Select3D_SensitiveSet)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveTriangulation, Select3D_SensitiveSet)
|
||||
|
||||
namespace
|
||||
{
|
||||
static Standard_Integer NbOfFreeEdges (const Handle(Poly_Triangulation)& theTriangulation)
|
||||
static Standard_Integer NbOfFreeEdges(const Handle(Poly_Triangulation)& theTriangulation)
|
||||
{
|
||||
Standard_Integer aNbFree = 0;
|
||||
Poly_Connect aPoly(theTriangulation);
|
||||
Standard_Integer aTriangleNodes[3];
|
||||
for (Standard_Integer aTrgIdx = 1; aTrgIdx <= theTriangulation->NbTriangles(); aTrgIdx++)
|
||||
{
|
||||
Standard_Integer aNbFree = 0;
|
||||
Poly_Connect aPoly (theTriangulation);
|
||||
Standard_Integer aTriangleNodes[3];
|
||||
for (Standard_Integer aTrgIdx = 1; aTrgIdx <= theTriangulation->NbTriangles(); aTrgIdx++)
|
||||
aPoly.Triangles(aTrgIdx, aTriangleNodes[0], aTriangleNodes[1], aTriangleNodes[2]);
|
||||
for (Standard_Integer aNodeIdx = 0; aNodeIdx < 3; ++aNodeIdx)
|
||||
{
|
||||
aPoly.Triangles (aTrgIdx, aTriangleNodes[0], aTriangleNodes[1], aTriangleNodes[2]);
|
||||
for (Standard_Integer aNodeIdx = 0; aNodeIdx < 3; ++aNodeIdx)
|
||||
if (aTriangleNodes[aNodeIdx] == 0)
|
||||
{
|
||||
if (aTriangleNodes[aNodeIdx] == 0)
|
||||
{
|
||||
++aNbFree;
|
||||
}
|
||||
++aNbFree;
|
||||
}
|
||||
}
|
||||
return aNbFree;
|
||||
}
|
||||
return aNbFree;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_SensitiveTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Poly_Triangulation)& theTrg,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Standard_Boolean theIsInterior)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myTriangul (theTrg),
|
||||
myInitLocation (theInitLoc),
|
||||
myPrimitivesNb (0)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Poly_Triangulation)& theTrg,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Standard_Boolean theIsInterior)
|
||||
: Select3D_SensitiveSet(theOwnerId),
|
||||
myTriangul(theTrg),
|
||||
myInitLocation(theInitLoc),
|
||||
myPrimitivesNb(0)
|
||||
{
|
||||
myInvInitLocation = myInitLocation.Transformation().Inverted();
|
||||
mySensType = theIsInterior ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
|
||||
myInvInitLocation = myInitLocation.Transformation().Inverted();
|
||||
mySensType = theIsInterior ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
|
||||
Standard_Integer aNbTriangles = 0;
|
||||
gp_XYZ aCenter (0.0, 0.0, 0.0);
|
||||
gp_XYZ aCenter(0.0, 0.0, 0.0);
|
||||
if (!theTrg->HasGeometry())
|
||||
{
|
||||
if (myTriangul->HasCachedMinMax())
|
||||
{
|
||||
aCenter = 0.5 * (myTriangul->CachedMinMax().CornerMin().XYZ()
|
||||
+ myTriangul->CachedMinMax().CornerMax().XYZ());
|
||||
aCenter = 0.5
|
||||
* (myTriangul->CachedMinMax().CornerMin().XYZ()
|
||||
+ myTriangul->CachedMinMax().CornerMax().XYZ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aNbTriangles = myTriangul->NbTriangles();
|
||||
myPrimitivesNb = theIsInterior ? aNbTriangles : NbOfFreeEdges (theTrg);
|
||||
myBVHPrimIndexes = new TColStd_HArray1OfInteger(0, myPrimitivesNb - 1);
|
||||
aNbTriangles = myTriangul->NbTriangles();
|
||||
myPrimitivesNb = theIsInterior ? aNbTriangles : NbOfFreeEdges(theTrg);
|
||||
myBVHPrimIndexes = new TColStd_HArray1OfInteger(0, myPrimitivesNb - 1);
|
||||
TColStd_Array1OfInteger& aBVHPrimIdxs = myBVHPrimIndexes->ChangeArray1();
|
||||
|
||||
if (!theIsInterior)
|
||||
{
|
||||
Standard_Integer anEdgeIdx = 1;
|
||||
myFreeEdges = new TColStd_HArray1OfInteger (1, 2 * myPrimitivesNb);
|
||||
Standard_Integer anEdgeIdx = 1;
|
||||
myFreeEdges = new TColStd_HArray1OfInteger(1, 2 * myPrimitivesNb);
|
||||
TColStd_Array1OfInteger& aFreeEdges = myFreeEdges->ChangeArray1();
|
||||
Poly_Connect aPoly (myTriangul);
|
||||
Standard_Integer aTriangle[3];
|
||||
Standard_Integer aTrNodeIdx[3];
|
||||
Poly_Connect aPoly(myTriangul);
|
||||
Standard_Integer aTriangle[3];
|
||||
Standard_Integer aTrNodeIdx[3];
|
||||
for (Standard_Integer aTriangleIdx = 1; aTriangleIdx <= aNbTriangles; aTriangleIdx++)
|
||||
{
|
||||
aPoly.Triangles (aTriangleIdx, aTriangle[0], aTriangle[1], aTriangle[2]);
|
||||
myTriangul->Triangle (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
|
||||
const gp_Pnt aTriNodes[3] = { myTriangul->Node (aTrNodeIdx[0]), myTriangul->Node (aTrNodeIdx[1]), myTriangul->Node (aTrNodeIdx[2]) };
|
||||
aCenter += (aTriNodes[0].XYZ() + aTriNodes[1].XYZ()+ aTriNodes[2].XYZ()) / 3.0;
|
||||
aPoly.Triangles(aTriangleIdx, aTriangle[0], aTriangle[1], aTriangle[2]);
|
||||
myTriangul->Triangle(aTriangleIdx).Get(aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
|
||||
const gp_Pnt aTriNodes[3] = {myTriangul->Node(aTrNodeIdx[0]),
|
||||
myTriangul->Node(aTrNodeIdx[1]),
|
||||
myTriangul->Node(aTrNodeIdx[2])};
|
||||
aCenter += (aTriNodes[0].XYZ() + aTriNodes[1].XYZ() + aTriNodes[2].XYZ()) / 3.0;
|
||||
for (Standard_Integer aVertIdx = 0; aVertIdx < 3; aVertIdx++)
|
||||
{
|
||||
Standard_Integer aNextVert = (aVertIdx + 1) % 3;
|
||||
if (aTriangle[aVertIdx] == 0)
|
||||
{
|
||||
aFreeEdges (anEdgeIdx) = aTrNodeIdx[aVertIdx];
|
||||
aFreeEdges (anEdgeIdx+1) = aTrNodeIdx[aNextVert];
|
||||
aFreeEdges(anEdgeIdx) = aTrNodeIdx[aVertIdx];
|
||||
aFreeEdges(anEdgeIdx + 1) = aTrNodeIdx[aNextVert];
|
||||
anEdgeIdx += 2;
|
||||
}
|
||||
}
|
||||
@@ -111,9 +113,11 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
|
||||
Standard_Integer aTrNodeIdx[3];
|
||||
for (Standard_Integer aTrIdx = 1; aTrIdx <= aNbTriangles; aTrIdx++)
|
||||
{
|
||||
myTriangul->Triangle (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
|
||||
const gp_Pnt aTriNodes[3] = { myTriangul->Node (aTrNodeIdx[0]), myTriangul->Node (aTrNodeIdx[1]), myTriangul->Node (aTrNodeIdx[2]) };
|
||||
aCenter += (aTriNodes[0].XYZ() + aTriNodes[1].XYZ()+ aTriNodes[2].XYZ()) / 3.0;
|
||||
myTriangul->Triangle(aTrIdx).Get(aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
|
||||
const gp_Pnt aTriNodes[3] = {myTriangul->Node(aTrNodeIdx[0]),
|
||||
myTriangul->Node(aTrNodeIdx[1]),
|
||||
myTriangul->Node(aTrNodeIdx[2])};
|
||||
aCenter += (aTriNodes[0].XYZ() + aTriNodes[1].XYZ() + aTriNodes[2].XYZ()) / 3.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,8 +131,9 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
|
||||
else
|
||||
{
|
||||
Standard_Integer aStartIdx = myFreeEdges->Lower();
|
||||
Standard_Integer anEndIdx = myFreeEdges->Upper();
|
||||
for (Standard_Integer aFreeEdgesIdx = aStartIdx; aFreeEdgesIdx <= anEndIdx; aFreeEdgesIdx += 2)
|
||||
Standard_Integer anEndIdx = myFreeEdges->Upper();
|
||||
for (Standard_Integer aFreeEdgesIdx = aStartIdx; aFreeEdgesIdx <= anEndIdx;
|
||||
aFreeEdgesIdx += 2)
|
||||
{
|
||||
aBVHPrimIdxs((aFreeEdgesIdx - aStartIdx) / 2) = (aFreeEdgesIdx - aStartIdx) / 2;
|
||||
}
|
||||
@@ -138,47 +143,48 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
|
||||
{
|
||||
aCenter /= aNbTriangles;
|
||||
}
|
||||
myCDG3D = gp_Pnt (aCenter);
|
||||
myCDG3D = gp_Pnt(aCenter);
|
||||
computeBoundingBox();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_SensitiveTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Poly_Triangulation)& theTrg,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Handle(TColStd_HArray1OfInteger)& theFreeEdges,
|
||||
const gp_Pnt& theCOG,
|
||||
const Standard_Boolean theIsInterior)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myTriangul (theTrg),
|
||||
myInitLocation (theInitLoc),
|
||||
myCDG3D (theCOG),
|
||||
myFreeEdges (theFreeEdges),
|
||||
myPrimitivesNb (0)
|
||||
//=================================================================================================
|
||||
|
||||
Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Poly_Triangulation)& theTrg,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Handle(TColStd_HArray1OfInteger)& theFreeEdges,
|
||||
const gp_Pnt& theCOG,
|
||||
const Standard_Boolean theIsInterior)
|
||||
: Select3D_SensitiveSet(theOwnerId),
|
||||
myTriangul(theTrg),
|
||||
myInitLocation(theInitLoc),
|
||||
myCDG3D(theCOG),
|
||||
myFreeEdges(theFreeEdges),
|
||||
myPrimitivesNb(0)
|
||||
{
|
||||
myInvInitLocation = myInitLocation.Transformation().Inverted();
|
||||
mySensType = theIsInterior ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
|
||||
mySensType = theIsInterior ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
|
||||
if (theTrg->HasGeometry())
|
||||
{
|
||||
myPrimitivesNb = theIsInterior ? theTrg->NbTriangles() : theFreeEdges->Length() / 2;
|
||||
myPrimitivesNb = theIsInterior ? theTrg->NbTriangles() : theFreeEdges->Length() / 2;
|
||||
myBVHPrimIndexes = new TColStd_HArray1OfInteger(0, myPrimitivesNb - 1);
|
||||
if (theIsInterior)
|
||||
{
|
||||
for (Standard_Integer aTriangleIdx = 1; aTriangleIdx <= myPrimitivesNb; ++aTriangleIdx)
|
||||
{
|
||||
myBVHPrimIndexes->SetValue (aTriangleIdx - 1, aTriangleIdx - 1);
|
||||
myBVHPrimIndexes->SetValue(aTriangleIdx - 1, aTriangleIdx - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Integer aStartIdx = myFreeEdges->Lower();
|
||||
Standard_Integer anEndIdx = myFreeEdges->Upper();
|
||||
for (Standard_Integer aFreeEdgesIdx = aStartIdx; aFreeEdgesIdx <= anEndIdx; aFreeEdgesIdx += 2)
|
||||
Standard_Integer anEndIdx = myFreeEdges->Upper();
|
||||
for (Standard_Integer aFreeEdgesIdx = aStartIdx; aFreeEdgesIdx <= anEndIdx;
|
||||
aFreeEdgesIdx += 2)
|
||||
{
|
||||
myBVHPrimIndexes->SetValue ((aFreeEdgesIdx - aStartIdx) / 2, (aFreeEdgesIdx - aStartIdx) / 2);
|
||||
myBVHPrimIndexes->SetValue((aFreeEdgesIdx - aStartIdx) / 2,
|
||||
(aFreeEdgesIdx - aStartIdx) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,56 +203,57 @@ Standard_Integer Select3D_SensitiveTriangulation::Size() const
|
||||
// function : Box
|
||||
// purpose : Returns bounding box of triangle/edge with index theIdx
|
||||
//=======================================================================
|
||||
Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer theIdx) const
|
||||
Select3D_BndBox3d Select3D_SensitiveTriangulation::Box(const Standard_Integer theIdx) const
|
||||
{
|
||||
Standard_Integer aPrimIdx = myBVHPrimIndexes->Value (theIdx);
|
||||
SelectMgr_Vec3 aMinPnt (RealLast());
|
||||
SelectMgr_Vec3 aMaxPnt (RealFirst());
|
||||
Standard_Integer aPrimIdx = myBVHPrimIndexes->Value(theIdx);
|
||||
SelectMgr_Vec3 aMinPnt(RealLast());
|
||||
SelectMgr_Vec3 aMaxPnt(RealFirst());
|
||||
|
||||
if (mySensType == Select3D_TOS_INTERIOR)
|
||||
{
|
||||
Standard_Integer aNode1, aNode2, aNode3;
|
||||
myTriangul->Triangle (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
|
||||
myTriangul->Triangle(aPrimIdx + 1).Get(aNode1, aNode2, aNode3);
|
||||
|
||||
const gp_Pnt aPnt1 = myTriangul->Node (aNode1);
|
||||
const gp_Pnt aPnt2 = myTriangul->Node (aNode2);
|
||||
const gp_Pnt aPnt3 = myTriangul->Node (aNode3);
|
||||
const gp_Pnt aPnt1 = myTriangul->Node(aNode1);
|
||||
const gp_Pnt aPnt2 = myTriangul->Node(aNode2);
|
||||
const gp_Pnt aPnt3 = myTriangul->Node(aNode3);
|
||||
|
||||
aMinPnt = SelectMgr_Vec3 (Min (aPnt1.X(), Min (aPnt2.X(), aPnt3.X())),
|
||||
Min (aPnt1.Y(), Min (aPnt2.Y(), aPnt3.Y())),
|
||||
Min (aPnt1.Z(), Min (aPnt2.Z(), aPnt3.Z())));
|
||||
aMaxPnt = SelectMgr_Vec3 (Max (aPnt1.X(), Max (aPnt2.X(), aPnt3.X())),
|
||||
Max (aPnt1.Y(), Max (aPnt2.Y(), aPnt3.Y())),
|
||||
Max (aPnt1.Z(), Max (aPnt2.Z(), aPnt3.Z())));
|
||||
aMinPnt = SelectMgr_Vec3(Min(aPnt1.X(), Min(aPnt2.X(), aPnt3.X())),
|
||||
Min(aPnt1.Y(), Min(aPnt2.Y(), aPnt3.Y())),
|
||||
Min(aPnt1.Z(), Min(aPnt2.Z(), aPnt3.Z())));
|
||||
aMaxPnt = SelectMgr_Vec3(Max(aPnt1.X(), Max(aPnt2.X(), aPnt3.X())),
|
||||
Max(aPnt1.Y(), Max(aPnt2.Y(), aPnt3.Y())),
|
||||
Max(aPnt1.Z(), Max(aPnt2.Z(), aPnt3.Z())));
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Integer aNodeIdx1 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx);
|
||||
Standard_Integer aNodeIdx2 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx + 1);
|
||||
const gp_Pnt aNode1 = myTriangul->Node (aNodeIdx1);
|
||||
const gp_Pnt aNode2 = myTriangul->Node (aNodeIdx2);
|
||||
Standard_Integer aNodeIdx1 = myFreeEdges->Value(myFreeEdges->Lower() + aPrimIdx);
|
||||
Standard_Integer aNodeIdx2 = myFreeEdges->Value(myFreeEdges->Lower() + aPrimIdx + 1);
|
||||
const gp_Pnt aNode1 = myTriangul->Node(aNodeIdx1);
|
||||
const gp_Pnt aNode2 = myTriangul->Node(aNodeIdx2);
|
||||
|
||||
aMinPnt = SelectMgr_Vec3 (Min (aNode1.X(), aNode2.X()),
|
||||
Min (aNode1.Y(), aNode2.Y()),
|
||||
Min (aNode1.Z(), aNode2.Z()));
|
||||
aMaxPnt = SelectMgr_Vec3 (Max (aNode1.X(), aNode2.X()),
|
||||
Max (aNode1.Y(), aNode2.Y()),
|
||||
Max (aNode1.Z(), aNode2.Z()));
|
||||
aMinPnt = SelectMgr_Vec3(Min(aNode1.X(), aNode2.X()),
|
||||
Min(aNode1.Y(), aNode2.Y()),
|
||||
Min(aNode1.Z(), aNode2.Z()));
|
||||
aMaxPnt = SelectMgr_Vec3(Max(aNode1.X(), aNode2.X()),
|
||||
Max(aNode1.Y(), aNode2.Y()),
|
||||
Max(aNode1.Z(), aNode2.Z()));
|
||||
}
|
||||
|
||||
return Select3D_BndBox3d (aMinPnt, aMaxPnt);
|
||||
return Select3D_BndBox3d(aMinPnt, aMaxPnt);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Matches
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::Matches(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
{
|
||||
if (myTriangul->HasGeometry())
|
||||
{
|
||||
return Select3D_SensitiveSet::Matches (theMgr, thePickResult);
|
||||
return Select3D_SensitiveSet::Matches(theMgr, thePickResult);
|
||||
}
|
||||
|
||||
Select3D_BndBox3d aBndBox = BoundingBox();
|
||||
@@ -258,13 +265,15 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches (SelectBasics_Selectin
|
||||
if (!theMgr.IsOverlapAllowed()) // check for inclusion
|
||||
{
|
||||
bool isInside = true;
|
||||
return theMgr.OverlapsBox (aBndBox.CornerMin(), aBndBox.CornerMax(), &isInside) && isInside;
|
||||
return theMgr.OverlapsBox(aBndBox.CornerMin(), aBndBox.CornerMax(), &isInside) && isInside;
|
||||
}
|
||||
if (!theMgr.OverlapsBox (aBndBox.CornerMin(), aBndBox.CornerMax(), thePickResult)) // check for overlap
|
||||
if (!theMgr.OverlapsBox(aBndBox.CornerMin(),
|
||||
aBndBox.CornerMax(),
|
||||
thePickResult)) // check for overlap
|
||||
{
|
||||
return false;
|
||||
}
|
||||
thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (myCDG3D));
|
||||
thePickResult.SetDistToGeomCenter(theMgr.DistToGeometryCenter(myCDG3D));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -273,11 +282,11 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches (SelectBasics_Selectin
|
||||
// purpose : Returns geometry center of triangle/edge with index theIdx
|
||||
// in array along the given axis theAxis
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveTriangulation::Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_Real Select3D_SensitiveTriangulation::Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
{
|
||||
const Select3D_BndBox3d& aBox = Box (theIdx);
|
||||
const SelectMgr_Vec3 aCenter = (aBox.CornerMin () + aBox.CornerMax ()) * 0.5;
|
||||
const Select3D_BndBox3d& aBox = Box(theIdx);
|
||||
const SelectMgr_Vec3 aCenter = (aBox.CornerMin() + aBox.CornerMax()) * 0.5;
|
||||
return aCenter[theAxis];
|
||||
}
|
||||
|
||||
@@ -285,46 +294,48 @@ Standard_Real Select3D_SensitiveTriangulation::Center (const Standard_Integer th
|
||||
// function : Swap
|
||||
// purpose : Swaps items with indexes theIdx1 and theIdx2 in array
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveTriangulation::Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2)
|
||||
void Select3D_SensitiveTriangulation::Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2)
|
||||
{
|
||||
Standard_Integer anElemIdx1 = myBVHPrimIndexes->Value (theIdx1);
|
||||
Standard_Integer anElemIdx2 = myBVHPrimIndexes->Value (theIdx2);
|
||||
Standard_Integer anElemIdx1 = myBVHPrimIndexes->Value(theIdx1);
|
||||
Standard_Integer anElemIdx2 = myBVHPrimIndexes->Value(theIdx2);
|
||||
|
||||
myBVHPrimIndexes->ChangeValue (theIdx1) = anElemIdx2;
|
||||
myBVHPrimIndexes->ChangeValue (theIdx2) = anElemIdx1;
|
||||
myBVHPrimIndexes->ChangeValue(theIdx1) = anElemIdx2;
|
||||
myBVHPrimIndexes->ChangeValue(theIdx2) = anElemIdx1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : LastDetectedTriangle
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool Select3D_SensitiveTriangulation::LastDetectedTriangle (Poly_Triangle& theTriangle) const
|
||||
//=================================================================================================
|
||||
|
||||
bool Select3D_SensitiveTriangulation::LastDetectedTriangle(Poly_Triangle& theTriangle) const
|
||||
{
|
||||
const Standard_Integer anIndex = LastDetectedTriangleIndex();
|
||||
if (anIndex != -1)
|
||||
{
|
||||
theTriangle = myTriangul->Triangle (anIndex);
|
||||
theTriangle = myTriangul->Triangle(anIndex);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : LastDetectedTriangle
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool Select3D_SensitiveTriangulation::LastDetectedTriangle (Poly_Triangle& theTriangle,
|
||||
gp_Pnt theTriNodes[3]) const
|
||||
//=================================================================================================
|
||||
|
||||
bool Select3D_SensitiveTriangulation::LastDetectedTriangle(Poly_Triangle& theTriangle,
|
||||
gp_Pnt theTriNodes[3]) const
|
||||
{
|
||||
if (!LastDetectedTriangle (theTriangle))
|
||||
if (!LastDetectedTriangle(theTriangle))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
theTriNodes[0] = myTriangul->Node (theTriangle.Value (1)).Transformed (myInitLocation.Transformation());;
|
||||
theTriNodes[1] = myTriangul->Node (theTriangle.Value (2)).Transformed (myInitLocation.Transformation());;
|
||||
theTriNodes[2] = myTriangul->Node (theTriangle.Value (3)).Transformed (myInitLocation.Transformation());;
|
||||
theTriNodes[0] =
|
||||
myTriangul->Node(theTriangle.Value(1)).Transformed(myInitLocation.Transformation());
|
||||
;
|
||||
theTriNodes[1] =
|
||||
myTriangul->Node(theTriangle.Value(2)).Transformed(myInitLocation.Transformation());
|
||||
;
|
||||
theTriNodes[2] =
|
||||
myTriangul->Node(theTriangle.Value(3)).Transformed(myInitLocation.Transformation());
|
||||
;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -333,83 +344,79 @@ bool Select3D_SensitiveTriangulation::LastDetectedTriangle (Poly_Triangle& theTr
|
||||
// purpose : Checks whether the element with index theIdx overlaps the
|
||||
// current selecting volume
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
{
|
||||
if (theIsFullInside)
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
const Standard_Integer aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx);
|
||||
const Standard_Integer aPrimitiveIdx = myBVHPrimIndexes->Value(theElemIdx);
|
||||
if (mySensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
Standard_Integer aSegmStartIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 1);
|
||||
Standard_Integer aSegmEndIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 2);
|
||||
Standard_Integer aSegmStartIdx = myFreeEdges->Value(aPrimitiveIdx * 2 + 1);
|
||||
Standard_Integer aSegmEndIdx = myFreeEdges->Value(aPrimitiveIdx * 2 + 2);
|
||||
|
||||
const gp_Pnt anEdgePnts[2] =
|
||||
{
|
||||
myTriangul->Node (aSegmStartIdx),
|
||||
myTriangul->Node (aSegmEndIdx)
|
||||
};
|
||||
TColgp_Array1OfPnt anEdgePntsArr (anEdgePnts[0], 1, 2);
|
||||
Standard_Boolean isMatched = theMgr.OverlapsPolygon (anEdgePntsArr, Select3D_TOS_BOUNDARY, thePickResult);
|
||||
const gp_Pnt anEdgePnts[2] = {myTriangul->Node(aSegmStartIdx), myTriangul->Node(aSegmEndIdx)};
|
||||
TColgp_Array1OfPnt anEdgePntsArr(anEdgePnts[0], 1, 2);
|
||||
Standard_Boolean isMatched =
|
||||
theMgr.OverlapsPolygon(anEdgePntsArr, Select3D_TOS_BOUNDARY, thePickResult);
|
||||
return isMatched;
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Integer aNode1, aNode2, aNode3;
|
||||
myTriangul->Triangle (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
|
||||
const gp_Pnt aPnt1 = myTriangul->Node (aNode1);
|
||||
const gp_Pnt aPnt2 = myTriangul->Node (aNode2);
|
||||
const gp_Pnt aPnt3 = myTriangul->Node (aNode3);
|
||||
return theMgr.OverlapsTriangle (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, thePickResult);
|
||||
myTriangul->Triangle(aPrimitiveIdx + 1).Get(aNode1, aNode2, aNode3);
|
||||
const gp_Pnt aPnt1 = myTriangul->Node(aNode1);
|
||||
const gp_Pnt aPnt2 = myTriangul->Node(aNode2);
|
||||
const gp_Pnt aPnt3 = myTriangul->Node(aNode3);
|
||||
return theMgr.OverlapsTriangle(aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, thePickResult);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function : elementIsInside
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside)
|
||||
{
|
||||
if (theIsFullInside)
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
const Standard_Integer aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx);
|
||||
const Standard_Integer aPrimitiveIdx = myBVHPrimIndexes->Value(theElemIdx);
|
||||
if (mySensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
const gp_Pnt aSegmPnt1 = myTriangul->Node (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
|
||||
const gp_Pnt aSegmPnt2 = myTriangul->Node (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
|
||||
const gp_Pnt aSegmPnt1 = myTriangul->Node(myFreeEdges->Value(aPrimitiveIdx * 2 + 1));
|
||||
const gp_Pnt aSegmPnt2 = myTriangul->Node(myFreeEdges->Value(aPrimitiveIdx * 2 + 2));
|
||||
if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline)
|
||||
{
|
||||
SelectBasics_PickResult aDummy;
|
||||
return theMgr.OverlapsSegment (aSegmPnt1, aSegmPnt2, aDummy);
|
||||
return theMgr.OverlapsSegment(aSegmPnt1, aSegmPnt2, aDummy);
|
||||
}
|
||||
return theMgr.OverlapsPoint (aSegmPnt1) && theMgr.OverlapsPoint (aSegmPnt2);
|
||||
return theMgr.OverlapsPoint(aSegmPnt1) && theMgr.OverlapsPoint(aSegmPnt2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Integer aNode1, aNode2, aNode3;
|
||||
myTriangul->Triangle (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
|
||||
myTriangul->Triangle(aPrimitiveIdx + 1).Get(aNode1, aNode2, aNode3);
|
||||
|
||||
const gp_Pnt aPnt1 = myTriangul->Node (aNode1);
|
||||
const gp_Pnt aPnt2 = myTriangul->Node (aNode2);
|
||||
const gp_Pnt aPnt3 = myTriangul->Node (aNode3);
|
||||
const gp_Pnt aPnt1 = myTriangul->Node(aNode1);
|
||||
const gp_Pnt aPnt2 = myTriangul->Node(aNode2);
|
||||
const gp_Pnt aPnt3 = myTriangul->Node(aNode3);
|
||||
if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline)
|
||||
{
|
||||
SelectBasics_PickResult aDummy;
|
||||
return theMgr.OverlapsTriangle (aPnt1, aPnt2, aPnt3, mySensType, aDummy);
|
||||
return theMgr.OverlapsTriangle(aPnt1, aPnt2, aPnt3, mySensType, aDummy);
|
||||
}
|
||||
return theMgr.OverlapsPoint (aPnt1)
|
||||
&& theMgr.OverlapsPoint (aPnt2)
|
||||
&& theMgr.OverlapsPoint (aPnt3);
|
||||
return theMgr.OverlapsPoint(aPnt1) && theMgr.OverlapsPoint(aPnt2)
|
||||
&& theMgr.OverlapsPoint(aPnt3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,20 +425,24 @@ Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_
|
||||
// purpose : Calculates distance from the 3d projection of used-picked
|
||||
// screen point to center of the geometry
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveTriangulation::distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr)
|
||||
Standard_Real Select3D_SensitiveTriangulation::distanceToCOG(
|
||||
SelectBasics_SelectingVolumeManager& theMgr)
|
||||
{
|
||||
return theMgr.DistToGeometryCenter (myCDG3D);
|
||||
return theMgr.DistToGeometryCenter(myCDG3D);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangulation::GetConnected()
|
||||
{
|
||||
Standard_Boolean isInterior = mySensType == Select3D_TOS_INTERIOR;
|
||||
Standard_Boolean isInterior = mySensType == Select3D_TOS_INTERIOR;
|
||||
Handle(Select3D_SensitiveTriangulation) aNewEntity =
|
||||
new Select3D_SensitiveTriangulation (myOwnerId, myTriangul, myInitLocation, myFreeEdges, myCDG3D, isInterior);
|
||||
new Select3D_SensitiveTriangulation(myOwnerId,
|
||||
myTriangul,
|
||||
myInitLocation,
|
||||
myFreeEdges,
|
||||
myCDG3D,
|
||||
isInterior);
|
||||
|
||||
return aNewEntity;
|
||||
}
|
||||
@@ -447,17 +458,17 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::applyTransformation()
|
||||
return myBndBox;
|
||||
|
||||
Select3D_BndBox3d aBndBox;
|
||||
for (Standard_Integer aX = 0; aX <=1; ++aX)
|
||||
for (Standard_Integer aX = 0; aX <= 1; ++aX)
|
||||
{
|
||||
for (Standard_Integer aY = 0; aY <=1; ++aY)
|
||||
for (Standard_Integer aY = 0; aY <= 1; ++aY)
|
||||
{
|
||||
for (Standard_Integer aZ = 0; aZ <= 1; ++aZ)
|
||||
{
|
||||
gp_Pnt aVertex = gp_Pnt (aX == 0 ? myBndBox.CornerMin().x() : myBndBox.CornerMax().x(),
|
||||
aY == 0 ? myBndBox.CornerMin().y() : myBndBox.CornerMax().y(),
|
||||
aZ == 0 ? myBndBox.CornerMin().z() : myBndBox.CornerMax().z());
|
||||
aVertex.Transform (myInitLocation.Transformation());
|
||||
aBndBox.Add (Select3D_Vec3 (aVertex.X(), aVertex.Y(), aVertex.Z()));
|
||||
gp_Pnt aVertex = gp_Pnt(aX == 0 ? myBndBox.CornerMin().x() : myBndBox.CornerMax().x(),
|
||||
aY == 0 ? myBndBox.CornerMin().y() : myBndBox.CornerMax().y(),
|
||||
aZ == 0 ? myBndBox.CornerMin().z() : myBndBox.CornerMax().z());
|
||||
aVertex.Transform(myInitLocation.Transformation());
|
||||
aBndBox.Add(Select3D_Vec3(aVertex.X(), aVertex.Y(), aVertex.Z()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -491,20 +502,20 @@ void Select3D_SensitiveTriangulation::computeBoundingBox()
|
||||
{
|
||||
// Use cached MeshData_Data bounding box if it exists
|
||||
Bnd_Box aCachedBox = myTriangul->CachedMinMax();
|
||||
myBndBox.Add (SelectMgr_Vec3 (aCachedBox.CornerMin().X(),
|
||||
aCachedBox.CornerMin().Y(),
|
||||
aCachedBox.CornerMin().Z()));
|
||||
myBndBox.Add (SelectMgr_Vec3 (aCachedBox.CornerMax().X(),
|
||||
aCachedBox.CornerMax().Y(),
|
||||
aCachedBox.CornerMax().Z()));
|
||||
myBndBox.Add(SelectMgr_Vec3(aCachedBox.CornerMin().X(),
|
||||
aCachedBox.CornerMin().Y(),
|
||||
aCachedBox.CornerMin().Z()));
|
||||
myBndBox.Add(SelectMgr_Vec3(aCachedBox.CornerMax().X(),
|
||||
aCachedBox.CornerMax().Y(),
|
||||
aCachedBox.CornerMax().Z()));
|
||||
return;
|
||||
}
|
||||
else if (myTriangul->HasGeometry())
|
||||
{
|
||||
for (Standard_Integer aNodeIdx = 1; aNodeIdx <= myTriangul->NbNodes(); ++aNodeIdx)
|
||||
{
|
||||
const gp_Pnt aNode = myTriangul->Node (aNodeIdx);
|
||||
myBndBox.Add (SelectMgr_Vec3 (aNode.X(), aNode.Y(), aNode.Z()));
|
||||
const gp_Pnt aNode = myTriangul->Node(aNodeIdx);
|
||||
myBndBox.Add(SelectMgr_Vec3(aNode.X(), aNode.Y(), aNode.Z()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -528,19 +539,15 @@ Standard_Integer Select3D_SensitiveTriangulation::NbSubElements() const
|
||||
return myTriangul->NbNodes();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasInitLocation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::HasInitLocation() const
|
||||
{
|
||||
return !myInitLocation.IsIdentity();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InvInitLocation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
gp_GTrsf Select3D_SensitiveTriangulation::InvInitLocation() const
|
||||
{
|
||||
return myInvInitLocation;
|
||||
@@ -550,14 +557,15 @@ gp_GTrsf Select3D_SensitiveTriangulation::InvInitLocation() const
|
||||
// function : DumpJson
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Select3D_SensitiveTriangulation::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
void Select3D_SensitiveTriangulation::DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet)
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveSet)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTriangul.get())
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myInitLocation)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySensType)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPrimitivesNb)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBndBox)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myTriangul.get())
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myInitLocation)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, mySensType)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myPrimitivesNb)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myBndBox)
|
||||
}
|
||||
|
@@ -28,14 +28,14 @@ class Select3D_SensitiveTriangulation : public Select3D_SensitiveSet
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveTriangulation, Select3D_SensitiveSet)
|
||||
public:
|
||||
|
||||
//! Constructs a sensitive triangulation object defined by
|
||||
//! the owner theOwnerId, the triangulation theTrg,
|
||||
//! the location theInitLoc, and the flag theIsInterior.
|
||||
Standard_EXPORT Select3D_SensitiveTriangulation (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Poly_Triangulation)& theTrg,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Standard_Boolean theIsInterior = Standard_True);
|
||||
Standard_EXPORT Select3D_SensitiveTriangulation(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Poly_Triangulation)& theTrg,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Standard_Boolean theIsInterior = Standard_True);
|
||||
|
||||
//! Constructs a sensitive triangulation object defined by
|
||||
//! the owner theOwnerId, the triangulation theTrg,
|
||||
@@ -43,36 +43,37 @@ public:
|
||||
//! theFreeEdges, the center of gravity theCOG, and the flag theIsInterior.
|
||||
//! As free edges and the center of gravity do not have
|
||||
//! to be computed later, this syntax reduces computation time.
|
||||
Standard_EXPORT Select3D_SensitiveTriangulation (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Poly_Triangulation)& theTrg,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Handle(TColStd_HArray1OfInteger)& theFreeEdges,
|
||||
const gp_Pnt& theCOG,
|
||||
const Standard_Boolean theIsInterior);
|
||||
public:
|
||||
Standard_EXPORT Select3D_SensitiveTriangulation(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const Handle(Poly_Triangulation)& theTrg,
|
||||
const TopLoc_Location& theInitLoc,
|
||||
const Handle(TColStd_HArray1OfInteger)& theFreeEdges,
|
||||
const gp_Pnt& theCOG,
|
||||
const Standard_Boolean theIsInterior);
|
||||
|
||||
public:
|
||||
//! Get last detected triangle.
|
||||
//! @param[out] theTriangle triangle node indexes
|
||||
//! @return TRUE if defined
|
||||
Standard_EXPORT bool LastDetectedTriangle (Poly_Triangle& theTriangle) const;
|
||||
Standard_EXPORT bool LastDetectedTriangle(Poly_Triangle& theTriangle) const;
|
||||
|
||||
//! Get last detected triangle.
|
||||
//! @param[out] theTriangle triangle node indexes
|
||||
//! @param[out] theTriNodes triangle nodes (with pre-applied transformation)
|
||||
//! @return TRUE if defined
|
||||
Standard_EXPORT bool LastDetectedTriangle (Poly_Triangle& theTriangle,
|
||||
gp_Pnt theTriNodes[3]) const;
|
||||
Standard_EXPORT bool LastDetectedTriangle(Poly_Triangle& theTriangle,
|
||||
gp_Pnt theTriNodes[3]) const;
|
||||
|
||||
//! Return index of last detected triangle within [1..NbTris] range, or -1 if undefined.
|
||||
Standard_Integer LastDetectedTriangleIndex() const
|
||||
{
|
||||
return (myDetectedIdx != -1 && mySensType == Select3D_TOS_INTERIOR && !myBVHPrimIndexes.IsNull())
|
||||
? myBVHPrimIndexes->Value (myDetectedIdx) + 1
|
||||
: -1;
|
||||
return (myDetectedIdx != -1 && mySensType == Select3D_TOS_INTERIOR
|
||||
&& !myBVHPrimIndexes.IsNull())
|
||||
? myBVHPrimIndexes->Value(myDetectedIdx) + 1
|
||||
: -1;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Returns the amount of nodes in triangulation
|
||||
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
|
||||
|
||||
@@ -84,16 +85,18 @@ public:
|
||||
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of triangle/edge with index theIdx
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns geometry center of triangle/edge with index theIdx
|
||||
//! in array along the given axis theAxis
|
||||
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Swaps items with indexes theIdx1 and theIdx2 in array
|
||||
Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of the triangulation. If location
|
||||
//! transformation is set, it will be applied
|
||||
@@ -113,14 +116,15 @@ public:
|
||||
const TopLoc_Location& GetInitLocation() const { return myInitLocation; }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
//! Checks whether one or more entities of the set overlap current selecting volume.
|
||||
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Compute bounding box.
|
||||
void computeBoundingBox();
|
||||
|
||||
@@ -129,34 +133,36 @@ protected:
|
||||
Select3D_BndBox3d applyTransformation();
|
||||
|
||||
private:
|
||||
|
||||
//! Checks whether the element with index theIdx overlaps the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
|
||||
Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
|
||||
//! 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;
|
||||
|
||||
//! Checks whether the entity with index theIdx is inside the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Poly_Triangulation) myTriangul;
|
||||
TopLoc_Location myInitLocation;
|
||||
gp_Pnt myCDG3D; //!< Center of the whole triangulation
|
||||
gp_Pnt myCDG3D; //!< Center of the whole triangulation
|
||||
Handle(TColStd_HArray1OfInteger) myFreeEdges;
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
Standard_Boolean mySensType; //!< Type of sensitivity: boundary or interior
|
||||
Standard_Integer myPrimitivesNb; //!< Amount of free edges or triangles depending on sensitivity type
|
||||
Handle(TColStd_HArray1OfInteger) myBVHPrimIndexes; //!< Indexes of edges or triangles for BVH build
|
||||
mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the whole triangulation
|
||||
// clang-format on
|
||||
gp_GTrsf myInvInitLocation;
|
||||
// clang-format on
|
||||
gp_GTrsf myInvInitLocation;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveTriangulation, Select3D_SensitiveSet)
|
||||
|
@@ -20,33 +20,29 @@
|
||||
|
||||
#include <Select3D_SensitiveSegment.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveWire, Select3D_SensitiveSet)
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveWire,Select3D_SensitiveSet)
|
||||
//=================================================================================================
|
||||
|
||||
//=====================================================
|
||||
// Function : Select3D_SensitiveWire
|
||||
// Purpose :
|
||||
//=====================================================
|
||||
Select3D_SensitiveWire::Select3D_SensitiveWire (const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myCenter (0.0, 0.0, 0.0)
|
||||
{}
|
||||
Select3D_SensitiveWire::Select3D_SensitiveWire(const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
: Select3D_SensitiveSet(theOwnerId),
|
||||
myCenter(0.0, 0.0, 0.0)
|
||||
{
|
||||
}
|
||||
|
||||
//=====================================================
|
||||
// Function : Add
|
||||
// Purpose :
|
||||
//=====================================================
|
||||
void Select3D_SensitiveWire::Add (const Handle(Select3D_SensitiveEntity)& theSensitive)
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveWire::Add(const Handle(Select3D_SensitiveEntity)& theSensitive)
|
||||
{
|
||||
if (!theSensitive.IsNull())
|
||||
myEntities.Append (theSensitive);
|
||||
myEntities.Append(theSensitive);
|
||||
|
||||
Select3D_BndBox3d aBndBox = theSensitive->BoundingBox();
|
||||
myBndBox.Combine (aBndBox);
|
||||
myBndBox.Combine(aBndBox);
|
||||
myCenter.ChangeCoord() += theSensitive->CenterOfGeometry().XYZ();
|
||||
if (myEntities.Length() != 1)
|
||||
myCenter.ChangeCoord().Divide (2.0);
|
||||
myEntityIndexes.Append (myEntities.Length() - 1);
|
||||
myCenter.ChangeCoord().Divide(2.0);
|
||||
myEntityIndexes.Append(myEntities.Length() - 1);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -71,10 +67,10 @@ Standard_Integer Select3D_SensitiveWire::Size() const
|
||||
// function : Box
|
||||
// purpose : Returns bounding box of sensitive entity with index theIdx
|
||||
//=======================================================================
|
||||
Select3D_BndBox3d Select3D_SensitiveWire::Box (const Standard_Integer theIdx) const
|
||||
Select3D_BndBox3d Select3D_SensitiveWire::Box(const Standard_Integer theIdx) const
|
||||
{
|
||||
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (theIdx);
|
||||
return myEntities.Value (aSensitiveIdx)->BoundingBox();
|
||||
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value(theIdx);
|
||||
return myEntities.Value(aSensitiveIdx)->BoundingBox();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -82,12 +78,12 @@ Select3D_BndBox3d Select3D_SensitiveWire::Box (const Standard_Integer theIdx) co
|
||||
// purpose : Returns geometry center of sensitive entity with index
|
||||
// theIdx in the vector along the given axis theAxis
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveWire::Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_Real Select3D_SensitiveWire::Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
{
|
||||
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (theIdx);
|
||||
const gp_Pnt& aCenter = myEntities.Value (aSensitiveIdx)->CenterOfGeometry();
|
||||
Standard_Real aCenterCoord = 0.0;
|
||||
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value(theIdx);
|
||||
const gp_Pnt& aCenter = myEntities.Value(aSensitiveIdx)->CenterOfGeometry();
|
||||
Standard_Real aCenterCoord = 0.0;
|
||||
aCenterCoord = theAxis == 0 ? aCenter.X() : (theAxis == 1 ? aCenter.Y() : aCenter.Z());
|
||||
|
||||
return aCenterCoord;
|
||||
@@ -97,13 +93,12 @@ Standard_Real Select3D_SensitiveWire::Center (const Standard_Integer theIdx,
|
||||
// function : Swap
|
||||
// purpose : Swaps items with indexes theIdx1 and theIdx2 in the vector
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveWire::Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2)
|
||||
void Select3D_SensitiveWire::Swap(const Standard_Integer theIdx1, const Standard_Integer theIdx2)
|
||||
{
|
||||
const Standard_Integer aSensitiveIdx1 = myEntityIndexes.Value (theIdx1);
|
||||
const Standard_Integer aSensitiveIdx2 = myEntityIndexes.Value (theIdx2);
|
||||
myEntityIndexes.ChangeValue (theIdx1) = aSensitiveIdx2;
|
||||
myEntityIndexes.ChangeValue (theIdx2) = aSensitiveIdx1;
|
||||
const Standard_Integer aSensitiveIdx1 = myEntityIndexes.Value(theIdx1);
|
||||
const Standard_Integer aSensitiveIdx2 = myEntityIndexes.Value(theIdx2);
|
||||
myEntityIndexes.ChangeValue(theIdx1) = aSensitiveIdx2;
|
||||
myEntityIndexes.ChangeValue(theIdx2) = aSensitiveIdx1;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -111,26 +106,28 @@ void Select3D_SensitiveWire::Swap (const Standard_Integer theIdx1,
|
||||
// purpose : Checks whether the entity with index theIdx overlaps the
|
||||
// current selecting volume
|
||||
// =======================================================================
|
||||
Standard_Boolean Select3D_SensitiveWire::overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean )
|
||||
Standard_Boolean Select3D_SensitiveWire::overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean)
|
||||
{
|
||||
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (theElemIdx);
|
||||
const Handle(Select3D_SensitiveEntity)& aSeg = myEntities.Value (aSensitiveIdx);
|
||||
return aSeg->Matches (theMgr, thePickResult);
|
||||
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value(theElemIdx);
|
||||
const Handle(Select3D_SensitiveEntity)& aSeg = myEntities.Value(aSensitiveIdx);
|
||||
return aSeg->Matches(theMgr, thePickResult);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : elementIsInside
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Select3D_SensitiveWire::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean )
|
||||
Standard_Boolean Select3D_SensitiveWire::elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean)
|
||||
{
|
||||
SelectBasics_PickResult aMatchResult;
|
||||
return myEntities.Value (myEntityIndexes.Value (theElemIdx))->Matches (theMgr, aMatchResult);
|
||||
return myEntities.Value(myEntityIndexes.Value(theElemIdx))->Matches(theMgr, aMatchResult);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -138,63 +135,56 @@ Standard_Boolean Select3D_SensitiveWire::elementIsInside (SelectBasics_Selecting
|
||||
// purpose : Calculates distance from the 3d projection of used-picked
|
||||
// screen point to center of the geometry
|
||||
// =======================================================================
|
||||
Standard_Real Select3D_SensitiveWire::distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr)
|
||||
Standard_Real Select3D_SensitiveWire::distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr)
|
||||
{
|
||||
return theMgr.DistToGeometryCenter (myCenter);
|
||||
return theMgr.DistToGeometryCenter(myCenter);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetConnected()
|
||||
{
|
||||
Handle(Select3D_SensitiveWire) aNewEntity = new Select3D_SensitiveWire (myOwnerId);
|
||||
Handle(Select3D_SensitiveWire) aNewEntity = new Select3D_SensitiveWire(myOwnerId);
|
||||
for (Standard_Integer anEntityIdx = 0; anEntityIdx < myEntities.Length(); anEntityIdx++)
|
||||
aNewEntity->Add (myEntities(anEntityIdx)->GetConnected());
|
||||
aNewEntity->Add(myEntities(anEntityIdx)->GetConnected());
|
||||
|
||||
return aNewEntity;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetEdges
|
||||
//purpose : returns the sensitive edges stored in this wire
|
||||
// function : GetEdges
|
||||
// purpose : returns the sensitive edges stored in this wire
|
||||
//=======================================================================
|
||||
const NCollection_Vector<Handle(Select3D_SensitiveEntity)>& Select3D_SensitiveWire::GetEdges()
|
||||
{
|
||||
return myEntities;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Function : GetLastDetected
|
||||
// Purpose :
|
||||
//=============================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetLastDetected() const
|
||||
{
|
||||
Handle(Select3D_SensitiveEntity) aRes;
|
||||
|
||||
if (myDetectedIdx >= 0 && myDetectedIdx < myEntities.Length())
|
||||
{
|
||||
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value (myDetectedIdx);
|
||||
aRes = myEntities.Value (aSensitiveIdx);
|
||||
const Standard_Integer aSensitiveIdx = myEntityIndexes.Value(myDetectedIdx);
|
||||
aRes = myEntities.Value(aSensitiveIdx);
|
||||
}
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveWire::Set (const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
//=================================================================================================
|
||||
|
||||
void Select3D_SensitiveWire::Set(const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
{
|
||||
Select3D_SensitiveEntity::Set (theOwnerId);
|
||||
Select3D_SensitiveEntity::Set(theOwnerId);
|
||||
|
||||
// Set TheOwnerId for each element of sensitive wire
|
||||
for (Standard_Integer anEntityIdx = 0; anEntityIdx < myEntities.Length(); ++anEntityIdx)
|
||||
{
|
||||
myEntities.Value (anEntityIdx)->Set (theOwnerId);
|
||||
myEntities.Value(anEntityIdx)->Set(theOwnerId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +200,7 @@ Select3D_BndBox3d Select3D_SensitiveWire::BoundingBox()
|
||||
|
||||
for (Standard_Integer aSensitiveIdx = 0; aSensitiveIdx < myEntities.Length(); ++aSensitiveIdx)
|
||||
{
|
||||
myBndBox.Combine (myEntities.Value (aSensitiveIdx)->BoundingBox());
|
||||
myBndBox.Combine(myEntities.Value(aSensitiveIdx)->BoundingBox());
|
||||
}
|
||||
|
||||
return myBndBox;
|
||||
@@ -230,15 +220,17 @@ gp_Pnt Select3D_SensitiveWire::CenterOfGeometry() const
|
||||
// function : DumpJson
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Select3D_SensitiveWire::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
void Select3D_SensitiveWire::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet)
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Select3D_SensitiveSet)
|
||||
|
||||
for (NCollection_Vector<Handle(Select3D_SensitiveEntity)>::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next())
|
||||
for (NCollection_Vector<Handle(Select3D_SensitiveEntity)>::Iterator anIterator(myEntities);
|
||||
anIterator.More();
|
||||
anIterator.Next())
|
||||
{
|
||||
const Handle(Select3D_SensitiveEntity)& anEntity = anIterator.Value();
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anEntity.get())
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, anEntity.get())
|
||||
}
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBndBox)
|
||||
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myBndBox)
|
||||
}
|
||||
|
@@ -24,13 +24,12 @@
|
||||
class Select3D_SensitiveWire : public Select3D_SensitiveSet
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructs a sensitive wire object defined by the
|
||||
//! owner theOwnerId
|
||||
Standard_EXPORT Select3D_SensitiveWire (const Handle(SelectMgr_EntityOwner)& theOwnerId);
|
||||
Standard_EXPORT Select3D_SensitiveWire(const Handle(SelectMgr_EntityOwner)& theOwnerId);
|
||||
|
||||
//! Adds the sensitive entity theSensitive to this framework.
|
||||
Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive);
|
||||
Standard_EXPORT void Add(const Handle(Select3D_SensitiveEntity)& theSensitive);
|
||||
|
||||
//! Returns the amount of sub-entities
|
||||
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
|
||||
@@ -41,7 +40,8 @@ public:
|
||||
Standard_EXPORT const NCollection_Vector<Handle(Select3D_SensitiveEntity)>& GetEdges();
|
||||
|
||||
//! Sets the owner for all entities in wire
|
||||
Standard_EXPORT virtual void Set (const Handle(SelectMgr_EntityOwner)& theOwnerId) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Set(const Handle(SelectMgr_EntityOwner)& theOwnerId)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT Handle(Select3D_SensitiveEntity) GetLastDetected() const;
|
||||
|
||||
@@ -57,46 +57,51 @@ public:
|
||||
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns bounding box of sensitive entity with index theIdx
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns geometry center of sensitive entity index theIdx in
|
||||
//! the vector along the given axis theAxis
|
||||
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIdx,
|
||||
const Standard_Integer theAxis) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Swaps items with indexes theIdx1 and theIdx2 in the vector
|
||||
Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Swap(const Standard_Integer theIdx1,
|
||||
const Standard_Integer theIdx2) Standard_OVERRIDE;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveWire,Select3D_SensitiveSet)
|
||||
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveWire, Select3D_SensitiveSet)
|
||||
|
||||
protected:
|
||||
|
||||
//! Checks whether the entity with index theIdx overlaps the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean overlapsElement(
|
||||
SelectBasics_PickResult& thePickResult,
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Checks whether the entity with index theIdx is inside the current selecting volume
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean elementIsInside(
|
||||
SelectBasics_SelectingVolumeManager& theMgr,
|
||||
Standard_Integer theElemIdx,
|
||||
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
|
||||
|
||||
//! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
|
||||
Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
|
||||
//! 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;
|
||||
|
||||
private:
|
||||
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
NCollection_Vector<Handle(Select3D_SensitiveEntity)> myEntities; //!< Vector of sub-entities
|
||||
NCollection_Vector<Standard_Integer> myEntityIndexes; //!< Indexes of entities for BVH build
|
||||
gp_Pnt myCenter; //!< Center of the whole wire
|
||||
mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the whole wire
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Select3D_SensitiveWire, Select3D_SensitiveEntity)
|
||||
|
@@ -19,8 +19,8 @@
|
||||
//! the boundary, or the exterior of a 3D sensitive entity which is sensitive.
|
||||
enum Select3D_TypeOfSensitivity
|
||||
{
|
||||
Select3D_TOS_INTERIOR,
|
||||
Select3D_TOS_BOUNDARY
|
||||
Select3D_TOS_INTERIOR,
|
||||
Select3D_TOS_BOUNDARY
|
||||
};
|
||||
|
||||
#endif // _Select3D_TypeOfSensitivity_HeaderFile
|
||||
|
Reference in New Issue
Block a user