1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0032015: Visualization - Select3D_SensitiveTriangulation::myDetectedIdx is inaccessible

Added Select3D_SensitiveTriangulation::LastDetectedTriangle() property.
This commit is contained in:
kgv 2020-12-22 16:12:57 +03:00 committed by bugmaster
parent b81b237fa4
commit 73dc2d3ae5
3 changed files with 67 additions and 8 deletions

View File

@ -254,6 +254,39 @@ void Select3D_SensitiveTriangulation::Swap (const Standard_Integer theIdx1,
myBVHPrimIndexes->ChangeValue (theIdx2) = anElemIdx1;
}
//=======================================================================
// function : LastDetectedTriangle
// purpose :
//=======================================================================
bool Select3D_SensitiveTriangulation::LastDetectedTriangle (Poly_Triangle& theTriangle) const
{
const Standard_Integer anIndex = LastDetectedTriangleIndex();
if (anIndex != -1)
{
theTriangle = myTriangul->Triangle (anIndex);
return true;
}
return false;
}
//=======================================================================
// function : LastDetectedTriangle
// purpose :
//=======================================================================
bool Select3D_SensitiveTriangulation::LastDetectedTriangle (Poly_Triangle& theTriangle,
gp_Pnt theTriNodes[3]) const
{
if (!LastDetectedTriangle (theTriangle))
{
return false;
}
theTriNodes[0] = myTriangul->Nodes().Value (theTriangle.Value (1)).Transformed (myInitLocation.Transformation());;
theTriNodes[1] = myTriangul->Nodes().Value (theTriangle.Value (2)).Transformed (myInitLocation.Transformation());;
theTriNodes[2] = myTriangul->Nodes().Value (theTriangle.Value (3)).Transformed (myInitLocation.Transformation());;
return true;
}
//=======================================================================
// function : overlapsElement
// purpose : Checks whether the element with index theIdx overlaps the

View File

@ -53,6 +53,29 @@ public:
const Handle(TColStd_HArray1OfInteger)& theFreeEdges,
const gp_Pnt& theCOG,
const Standard_Boolean theIsInterior);
public:
//! Get last detected triangle.
//! @param theTriangle [out] triangle node indexes
//! @return TRUE if defined
Standard_EXPORT bool LastDetectedTriangle (Poly_Triangle& theTriangle) const;
//! Get last detected triangle.
//! @param theTriangle [out] triangle node indexes
//! @param theTriNodes [out] triangle nodes (with pre-applied transformation)
//! @return TRUE if defined
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;
}
public:
//! Returns the amount of nodes in triangulation
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
@ -118,7 +141,7 @@ private:
Standard_Integer theElemIdx,
Standard_Boolean theIsFullInside) Standard_OVERRIDE;
private:
protected:
Handle(Poly_Triangulation) myTriangul;
TopLoc_Location myInitLocation;

View File

@ -60,6 +60,7 @@
#include <Prs3d_PointAspect.hxx>
#include <Select3D_SensitiveWire.hxx>
#include <Select3D_SensitivePrimitiveArray.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <StdSelect_ViewerSelector3d.hxx>
@ -5514,30 +5515,32 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
<< " (" << anEntity->DynamicType()->Name() << ")"
<< "\n";
Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (!aBRepOwner.IsNull())
if (Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner))
{
theDI << " Detected Shape: "
<< aBRepOwner->Shape().TShape()->DynamicType()->Name()
<< "\n";
}
Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast (anEntity);
if (!aWire.IsNull())
if (Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast (anEntity))
{
Handle(Select3D_SensitiveEntity) aSen = aWire->GetLastDetected();
theDI << " Detected Child: "
<< aSen->DynamicType()->Name()
<< "\n";
}
Handle(Select3D_SensitivePrimitiveArray) aPrimArr = Handle(Select3D_SensitivePrimitiveArray)::DownCast (anEntity);
if (!aPrimArr.IsNull())
else if (Handle(Select3D_SensitivePrimitiveArray) aPrimArr = Handle(Select3D_SensitivePrimitiveArray)::DownCast (anEntity))
{
theDI << " Detected Element: "
<< aPrimArr->LastDetectedElement()
<< "\n";
}
else if (Handle(Select3D_SensitiveTriangulation) aTriSens = Handle(Select3D_SensitiveTriangulation)::DownCast (anEntity))
{
theDI << " Detected Triangle: "
<< aTriSens->LastDetectedTriangleIndex()
<< "\n";
}
}
return 0;
}