1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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:
dpasukhi
2025-01-25 20:15:22 +00:00
parent dbba6f1289
commit a5a7b3185b
14005 changed files with 1273539 additions and 1195567 deletions

View File

@@ -36,277 +36,288 @@
namespace
{
//! Compute polyline of shrunk triangle.
static Handle(TColgp_HSequenceOfPnt) shrunkTriangle (const gp_Pnt* thePnts,
const gp_XYZ& theCenter)
//! Compute polyline of shrunk triangle.
static Handle(TColgp_HSequenceOfPnt) shrunkTriangle(const gp_Pnt* thePnts, const gp_XYZ& theCenter)
{
const gp_XYZ aV1 = theCenter + (thePnts[0].XYZ() - theCenter) * 0.9;
const gp_XYZ aV2 = theCenter + (thePnts[1].XYZ() - theCenter) * 0.9;
const gp_XYZ aV3 = theCenter + (thePnts[2].XYZ() - theCenter) * 0.9;
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
aPoints->Append(aV1);
aPoints->Append(aV2);
aPoints->Append(aV3);
aPoints->Append(aV1);
return aPoints;
}
//! Fill in triangulation polylines.
static void addTriangulation(Prs3d_NListOfSequenceOfPnt& theSeqLines,
Prs3d_NListOfSequenceOfPnt& theSeqFree,
const Handle(Select3D_SensitiveTriangulation)& theTri,
const gp_Trsf& theLoc)
{
gp_Trsf aTrsf = theLoc;
if (theTri->HasInitLocation())
{
const gp_XYZ aV1 = theCenter + (thePnts[0].XYZ() - theCenter) * 0.9;
const gp_XYZ aV2 = theCenter + (thePnts[1].XYZ() - theCenter) * 0.9;
const gp_XYZ aV3 = theCenter + (thePnts[2].XYZ() - theCenter) * 0.9;
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
aPoints->Append (aV1);
aPoints->Append (aV2);
aPoints->Append (aV3);
aPoints->Append (aV1);
return aPoints;
aTrsf = theLoc * theTri->GetInitLocation();
}
const Handle(Poly_Triangulation)& aPolyTri = theTri->Triangulation();
for (Standard_Integer aTriIter = 1; aTriIter <= aPolyTri->NbTriangles(); ++aTriIter)
{
const Poly_Triangle& aTri = aPolyTri->Triangle(aTriIter);
const gp_Pnt aPnts[3] = {aPolyTri->Node(aTri(1)).Transformed(aTrsf),
aPolyTri->Node(aTri(2)).Transformed(aTrsf),
aPolyTri->Node(aTri(3)).Transformed(aTrsf)};
const gp_XYZ aCenter = (aPnts[0].XYZ() + aPnts[1].XYZ() + aPnts[2].XYZ()) / 3.0;
theSeqLines.Append(shrunkTriangle(aPnts, aCenter));
}
//! Fill in triangulation polylines.
static void addTriangulation (Prs3d_NListOfSequenceOfPnt& theSeqLines,
Prs3d_NListOfSequenceOfPnt& theSeqFree,
const Handle(Select3D_SensitiveTriangulation)& theTri,
const gp_Trsf& theLoc)
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
Prs3d::AddFreeEdges(*aPoints, aPolyTri, aTrsf);
if (!aPoints->IsEmpty())
{
gp_Trsf aTrsf = theLoc;
if (theTri->HasInitLocation())
{
aTrsf = theLoc * theTri->GetInitLocation();
}
const Handle(Poly_Triangulation)& aPolyTri = theTri->Triangulation();
for (Standard_Integer aTriIter = 1; aTriIter <= aPolyTri->NbTriangles(); ++aTriIter)
{
const Poly_Triangle& aTri = aPolyTri->Triangle (aTriIter);
const gp_Pnt aPnts[3] =
{
aPolyTri->Node (aTri (1)).Transformed (aTrsf),
aPolyTri->Node (aTri (2)).Transformed (aTrsf),
aPolyTri->Node (aTri (3)).Transformed (aTrsf)
};
const gp_XYZ aCenter = (aPnts[0].XYZ() + aPnts[1].XYZ() + aPnts[2].XYZ()) / 3.0;
theSeqLines.Append (shrunkTriangle (aPnts, aCenter));
}
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
Prs3d::AddFreeEdges (*aPoints, aPolyTri, aTrsf);
if (!aPoints->IsEmpty())
{
theSeqFree.Append (aPoints);
}
}
//! Fill in bounding box polylines.
static void addBoundingBox (Prs3d_NListOfSequenceOfPnt& theSeqLines,
const Handle(Select3D_SensitiveBox)& theSensBox,
const gp_Trsf& theLoc)
{
Graphic3d_Vec3d aMin, aMax;
theSensBox->Box().Get (aMin.x(), aMin.y(), aMin.z(), aMax.x(), aMax.y(), aMax.z());
gp_Pnt aPnts[8] =
{
gp_Pnt(aMin.x(), aMin.y(), aMin.z()),
gp_Pnt(aMax.x(), aMin.y(), aMin.z()),
gp_Pnt(aMax.x(), aMax.y(), aMin.z()),
gp_Pnt(aMin.x(), aMax.y(), aMin.z()),
gp_Pnt(aMin.x(), aMin.y(), aMax.z()),
gp_Pnt(aMax.x(), aMin.y(), aMax.z()),
gp_Pnt(aMax.x(), aMax.y(), aMax.z()),
gp_Pnt(aMin.x(), aMax.y(), aMax.z())
};
for (Standard_Integer aPntIter = 0; aPntIter <= 7; ++aPntIter)
{
aPnts[aPntIter].Transform (theLoc);
}
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
for (Standard_Integer i = 0; i < 4; ++i)
{
aPoints->Append (aPnts[i]);
}
aPoints->Append (aPnts[0]);
theSeqLines.Append (aPoints);
}
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
for (Standard_Integer i = 4; i < 8; i++)
{
aPoints->Append (aPnts[i]);
}
aPoints->Append (aPnts[4]);
theSeqLines.Append (aPoints);
}
for (Standard_Integer i = 0; i < 4; i++)
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
aPoints->Append (aPnts[i]);
aPoints->Append (aPnts[i+4]);
theSeqLines.Append (aPoints);
}
}
//! Fill in circle polylines.
static void addCircle (Prs3d_NListOfSequenceOfPnt& theSeqLines,
const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Real theHeight = 0)
{
const Standard_Real anUStep = 0.1;
gp_XYZ aVec (0, 0, theHeight);
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
Geom_Circle aGeom (gp_Ax2(), theRadius);
for (Standard_Real anU = 0.0f; anU < (2.0 * M_PI + anUStep); anU += anUStep)
{
gp_Pnt aCircPnt = aGeom.Value (anU).Coord() + aVec;
aCircPnt.Transform (theTrsf);
aPoints->Append (aCircPnt);
}
theSeqLines.Append (aPoints);
}
//! Fill in cylinder polylines.
static void addCylinder (Prs3d_NListOfSequenceOfPnt& theSeqLines,
const Handle(Select3D_SensitiveCylinder)& theSensCyl,
const gp_Trsf& theLoc)
{
Handle(TColgp_HSequenceOfPnt) aVertLine1 = new TColgp_HSequenceOfPnt();
Handle(TColgp_HSequenceOfPnt) aVertLine2 = new TColgp_HSequenceOfPnt();
const gp_Trsf& aTrsf = theLoc.Multiplied (theSensCyl->Transformation());
const Standard_Real aHeight = theSensCyl->Height();
for (int aCircNum = 0; aCircNum < 3; aCircNum++)
{
Standard_Real aRadius = 0.5 * (2 - aCircNum) * theSensCyl->BottomRadius()
+ 0.5 * aCircNum * theSensCyl->TopRadius();
const gp_XYZ aVec (0, 0, aHeight * 0.5 * aCircNum);
if (aCircNum != 1)
{
aVertLine1->Append (gp_Pnt (gp_XYZ (aRadius, 0, 0) + aVec).Transformed (aTrsf));
aVertLine2->Append (gp_Pnt (gp_XYZ (-aRadius, 0, 0) + aVec).Transformed (aTrsf));
}
if (aRadius > Precision::Confusion())
{
addCircle (theSeqLines, aRadius, aTrsf, aVec.Z());
}
}
theSeqLines.Append (aVertLine1);
theSeqLines.Append (aVertLine2);
theSeqFree.Append(aPoints);
}
}
//=======================================================================
//function : ComputeSensitivePrs
//purpose :
//=======================================================================
void SelectMgr::ComputeSensitivePrs (const Handle(Graphic3d_Structure)& thePrs,
const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc,
const Handle(Graphic3d_TransformPers)& theTrsfPers)
//! Fill in bounding box polylines.
static void addBoundingBox(Prs3d_NListOfSequenceOfPnt& theSeqLines,
const Handle(Select3D_SensitiveBox)& theSensBox,
const gp_Trsf& theLoc)
{
thePrs->SetTransformPersistence (theTrsfPers);
Graphic3d_Vec3d aMin, aMax;
theSensBox->Box().Get(aMin.x(), aMin.y(), aMin.z(), aMax.x(), aMax.y(), aMax.z());
gp_Pnt aPnts[8] = {gp_Pnt(aMin.x(), aMin.y(), aMin.z()),
gp_Pnt(aMax.x(), aMin.y(), aMin.z()),
gp_Pnt(aMax.x(), aMax.y(), aMin.z()),
gp_Pnt(aMin.x(), aMax.y(), aMin.z()),
gp_Pnt(aMin.x(), aMin.y(), aMax.z()),
gp_Pnt(aMax.x(), aMin.y(), aMax.z()),
gp_Pnt(aMax.x(), aMax.y(), aMax.z()),
gp_Pnt(aMin.x(), aMax.y(), aMax.z())};
for (Standard_Integer aPntIter = 0; aPntIter <= 7; ++aPntIter)
{
aPnts[aPntIter].Transform(theLoc);
}
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
for (Standard_Integer i = 0; i < 4; ++i)
{
aPoints->Append(aPnts[i]);
}
aPoints->Append(aPnts[0]);
theSeqLines.Append(aPoints);
}
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
for (Standard_Integer i = 4; i < 8; i++)
{
aPoints->Append(aPnts[i]);
}
aPoints->Append(aPnts[4]);
theSeqLines.Append(aPoints);
}
for (Standard_Integer i = 0; i < 4; i++)
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
aPoints->Append(aPnts[i]);
aPoints->Append(aPnts[i + 4]);
theSeqLines.Append(aPoints);
}
}
//! Fill in circle polylines.
static void addCircle(Prs3d_NListOfSequenceOfPnt& theSeqLines,
const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Real theHeight = 0)
{
const Standard_Real anUStep = 0.1;
gp_XYZ aVec(0, 0, theHeight);
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
Geom_Circle aGeom(gp_Ax2(), theRadius);
for (Standard_Real anU = 0.0f; anU < (2.0 * M_PI + anUStep); anU += anUStep)
{
gp_Pnt aCircPnt = aGeom.Value(anU).Coord() + aVec;
aCircPnt.Transform(theTrsf);
aPoints->Append(aCircPnt);
}
theSeqLines.Append(aPoints);
}
//! Fill in cylinder polylines.
static void addCylinder(Prs3d_NListOfSequenceOfPnt& theSeqLines,
const Handle(Select3D_SensitiveCylinder)& theSensCyl,
const gp_Trsf& theLoc)
{
Handle(TColgp_HSequenceOfPnt) aVertLine1 = new TColgp_HSequenceOfPnt();
Handle(TColgp_HSequenceOfPnt) aVertLine2 = new TColgp_HSequenceOfPnt();
const gp_Trsf& aTrsf = theLoc.Multiplied(theSensCyl->Transformation());
const Standard_Real aHeight = theSensCyl->Height();
for (int aCircNum = 0; aCircNum < 3; aCircNum++)
{
Standard_Real aRadius =
0.5 * (2 - aCircNum) * theSensCyl->BottomRadius() + 0.5 * aCircNum * theSensCyl->TopRadius();
const gp_XYZ aVec(0, 0, aHeight * 0.5 * aCircNum);
if (aCircNum != 1)
{
aVertLine1->Append(gp_Pnt(gp_XYZ(aRadius, 0, 0) + aVec).Transformed(aTrsf));
aVertLine2->Append(gp_Pnt(gp_XYZ(-aRadius, 0, 0) + aVec).Transformed(aTrsf));
}
if (aRadius > Precision::Confusion())
{
addCircle(theSeqLines, aRadius, aTrsf, aVec.Z());
}
}
theSeqLines.Append(aVertLine1);
theSeqLines.Append(aVertLine2);
}
} // namespace
//=================================================================================================
void SelectMgr::ComputeSensitivePrs(const Handle(Graphic3d_Structure)& thePrs,
const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc,
const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
thePrs->SetTransformPersistence(theTrsfPers);
Prs3d_NListOfSequenceOfPnt aSeqLines, aSeqFree;
TColgp_SequenceOfPnt aSeqPoints;
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
TColgp_SequenceOfPnt aSeqPoints;
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
theSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(Select3D_SensitiveEntity)& anEnt = aSelEntIter.Value()->BaseSensitive();
if (Handle(Select3D_SensitiveBox) aSensBox = Handle(Select3D_SensitiveBox)::DownCast (anEnt))
if (Handle(Select3D_SensitiveBox) aSensBox = Handle(Select3D_SensitiveBox)::DownCast(anEnt))
{
addBoundingBox (aSeqLines, aSensBox, theLoc);
addBoundingBox(aSeqLines, aSensBox, theLoc);
}
else if (Handle(Select3D_SensitiveCylinder) aSensCyl = Handle(Select3D_SensitiveCylinder)::DownCast (anEnt))
else if (Handle(Select3D_SensitiveCylinder) aSensCyl =
Handle(Select3D_SensitiveCylinder)::DownCast(anEnt))
{
addCylinder (aSeqLines, aSensCyl, theLoc);
addCylinder(aSeqLines, aSensCyl, theLoc);
}
else if (Handle(Select3D_SensitiveCircle) aSensCircle = Handle(Select3D_SensitiveCircle)::DownCast (anEnt))
else if (Handle(Select3D_SensitiveCircle) aSensCircle =
Handle(Select3D_SensitiveCircle)::DownCast(anEnt))
{
addCircle (aSeqLines, aSensCircle->Radius(), theLoc.Multiplied (aSensCircle->Transformation()));
addCircle(aSeqLines, aSensCircle->Radius(), theLoc.Multiplied(aSensCircle->Transformation()));
}
else if (Handle(Select3D_SensitiveFace) aFace = Handle(Select3D_SensitiveFace)::DownCast(anEnt))
{
Handle(TColgp_HArray1OfPnt) aSensPnts;
aFace->GetPoints (aSensPnts);
aFace->GetPoints(aSensPnts);
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
for (TColgp_HArray1OfPnt::Iterator aPntIter (*aSensPnts); aPntIter.More(); aPntIter.Next())
for (TColgp_HArray1OfPnt::Iterator aPntIter(*aSensPnts); aPntIter.More(); aPntIter.Next())
{
aPoints->Append (aPntIter.Value().Transformed (theLoc));
aPoints->Append(aPntIter.Value().Transformed(theLoc));
}
aSeqLines.Append (aPoints);
aSeqLines.Append(aPoints);
}
else if (Handle(Select3D_SensitivePoly) aSensPoly = Handle(Select3D_SensitivePoly)::DownCast (anEnt))
else if (Handle(Select3D_SensitivePoly) aSensPoly =
Handle(Select3D_SensitivePoly)::DownCast(anEnt))
{
Standard_Integer aFrom = 0, aTo = 0;
aSensPoly->ArrayBounds (aFrom, aTo);
aSensPoly->ArrayBounds(aFrom, aTo);
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
for (Standard_Integer aPntIter = aFrom; aPntIter <= aTo; ++aPntIter)
{
aPoints->Append (aSensPoly->GetPoint3d (aPntIter).Transformed (theLoc));
aPoints->Append(aSensPoly->GetPoint3d(aPntIter).Transformed(theLoc));
}
aSeqLines.Append (aPoints);
aSeqLines.Append(aPoints);
}
else if (Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast(anEnt))
{
const NCollection_Vector<Handle(Select3D_SensitiveEntity)>& anEntities = aWire->GetEdges();
for (NCollection_Vector<Handle(Select3D_SensitiveEntity)>::Iterator aSubIter (anEntities); aSubIter.More(); aSubIter.Next())
for (NCollection_Vector<Handle(Select3D_SensitiveEntity)>::Iterator aSubIter(anEntities);
aSubIter.More();
aSubIter.Next())
{
const Handle(Select3D_SensitiveEntity)& aSubEnt = aSubIter.Value();
if (Handle(Select3D_SensitiveSegment) aSensSeg = Handle(Select3D_SensitiveSegment)::DownCast (aSubEnt))
if (Handle(Select3D_SensitiveSegment) aSensSeg =
Handle(Select3D_SensitiveSegment)::DownCast(aSubEnt))
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
aPoints->Append (aSensSeg->StartPoint().Transformed (theLoc));
aPoints->Append (aSensSeg->EndPoint() .Transformed (theLoc));
aSeqLines.Append (aPoints);
aPoints->Append(aSensSeg->StartPoint().Transformed(theLoc));
aPoints->Append(aSensSeg->EndPoint().Transformed(theLoc));
aSeqLines.Append(aPoints);
}
else if (Handle(Select3D_SensitivePoly) aSubSensPoly = Handle(Select3D_SensitivePoly)::DownCast (aSubEnt))
else if (Handle(Select3D_SensitivePoly) aSubSensPoly =
Handle(Select3D_SensitivePoly)::DownCast(aSubEnt))
{
Standard_Integer aFrom = 0, aTo = 0;
aSubSensPoly->ArrayBounds (aFrom, aTo);
aSubSensPoly->ArrayBounds(aFrom, aTo);
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
for (Standard_Integer aPntIter = aFrom; aPntIter <= aTo; ++aPntIter)
{
aPoints->Append (aSubSensPoly->GetPoint3d (aPntIter).Transformed (theLoc));
aPoints->Append(aSubSensPoly->GetPoint3d(aPntIter).Transformed(theLoc));
}
aSeqLines.Append (aPoints);
aSeqLines.Append(aPoints);
}
}
}
else if (Handle(Select3D_SensitiveSegment) aSensSeg = Handle(Select3D_SensitiveSegment)::DownCast(anEnt))
else if (Handle(Select3D_SensitiveSegment) aSensSeg =
Handle(Select3D_SensitiveSegment)::DownCast(anEnt))
{
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
aPoints->Append (aSensSeg->StartPoint().Transformed (theLoc));
aPoints->Append (aSensSeg->EndPoint() .Transformed (theLoc));
aSeqLines.Append (aPoints);
aPoints->Append(aSensSeg->StartPoint().Transformed(theLoc));
aPoints->Append(aSensSeg->EndPoint().Transformed(theLoc));
aSeqLines.Append(aPoints);
}
else if (Handle(Select3D_SensitivePoint) aSensPnt = Handle(Select3D_SensitivePoint)::DownCast(anEnt))
else if (Handle(Select3D_SensitivePoint) aSensPnt =
Handle(Select3D_SensitivePoint)::DownCast(anEnt))
{
aSeqPoints.Append (aSensPnt->Point().Transformed (theLoc));
aSeqPoints.Append(aSensPnt->Point().Transformed(theLoc));
}
else if (Handle(Select3D_SensitiveTriangulation) aSensTri = Handle(Select3D_SensitiveTriangulation)::DownCast (anEnt))
else if (Handle(Select3D_SensitiveTriangulation) aSensTri =
Handle(Select3D_SensitiveTriangulation)::DownCast(anEnt))
{
addTriangulation (aSeqLines, aSeqFree, aSensTri, theLoc);
addTriangulation(aSeqLines, aSeqFree, aSensTri, theLoc);
}
else if (Handle(Select3D_SensitiveTriangle) aSensTri1 = Handle(Select3D_SensitiveTriangle)::DownCast(anEnt))
else if (Handle(Select3D_SensitiveTriangle) aSensTri1 =
Handle(Select3D_SensitiveTriangle)::DownCast(anEnt))
{
gp_Pnt aPnts[3];
aSensTri1->Points3D (aPnts[0], aPnts[1], aPnts[2]);
aPnts[0].Transform (theLoc);
aPnts[1].Transform (theLoc);
aPnts[2].Transform (theLoc);
aSeqLines.Append (shrunkTriangle (aPnts, aSensTri1->Center3D().XYZ()));
aSensTri1->Points3D(aPnts[0], aPnts[1], aPnts[2]);
aPnts[0].Transform(theLoc);
aPnts[1].Transform(theLoc);
aPnts[2].Transform(theLoc);
aSeqLines.Append(shrunkTriangle(aPnts, aSensTri1->Center3D().XYZ()));
}
}
if (!aSeqPoints.IsEmpty())
{
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (aSeqPoints.Size());
for (TColgp_SequenceOfPnt::Iterator aPntIter (aSeqPoints); aPntIter.More(); aPntIter.Next())
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints =
new Graphic3d_ArrayOfPoints(aSeqPoints.Size());
for (TColgp_SequenceOfPnt::Iterator aPntIter(aSeqPoints); aPntIter.More(); aPntIter.Next())
{
anArrayOfPoints->AddVertex (aPntIter.Value());
anArrayOfPoints->AddVertex(aPntIter.Value());
}
Handle(Graphic3d_Group) aSensPntGroup = thePrs->NewGroup();
aSensPntGroup->SetPrimitivesAspect (new Graphic3d_AspectMarker3d (Aspect_TOM_O_PLUS, Quantity_NOC_INDIANRED3, 2.0));
aSensPntGroup->AddPrimitiveArray (anArrayOfPoints);
aSensPntGroup->SetPrimitivesAspect(
new Graphic3d_AspectMarker3d(Aspect_TOM_O_PLUS, Quantity_NOC_INDIANRED3, 2.0));
aSensPntGroup->AddPrimitiveArray(anArrayOfPoints);
}
if (!aSeqLines.IsEmpty())
{
Prs3d::AddPrimitivesGroup (thePrs, new Prs3d_LineAspect (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0), aSeqLines);
Prs3d::AddPrimitivesGroup(thePrs,
new Prs3d_LineAspect(Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0),
aSeqLines);
}
if (!aSeqFree.IsEmpty())
{
Prs3d::AddPrimitivesGroup (thePrs, new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 2.0), aSeqFree);
Prs3d::AddPrimitivesGroup(thePrs,
new Prs3d_LineAspect(Quantity_NOC_GREEN, Aspect_TOL_SOLID, 2.0),
aSeqFree);
}
}

View File

@@ -25,13 +25,12 @@ class gp_Trsf;
class SelectMgr
{
public:
//! Compute debug presentation for sensitive objects.
Standard_EXPORT static void ComputeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc,
const Handle(Graphic3d_TransformPers)& theTrsfPers);
Standard_EXPORT static void ComputeSensitivePrs(
const Handle(Graphic3d_Structure)& theStructure,
const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc,
const Handle(Graphic3d_TransformPers)& theTrsfPers);
};
#endif

View File

@@ -12,25 +12,21 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <SelectMgr_AndFilter.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Filter.hxx>
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_AndFilter,SelectMgr_CompositionFilter)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_AndFilter, SelectMgr_CompositionFilter)
SelectMgr_AndFilter::SelectMgr_AndFilter()
{
}
Standard_Boolean SelectMgr_AndFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const
SelectMgr_AndFilter::SelectMgr_AndFilter() {}
Standard_Boolean SelectMgr_AndFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const
{
SelectMgr_ListIteratorOfListOfFilter it(myFilters);
for ( ; it.More();it.Next())
if(!it.Value()->IsOk(anobj))
for (; it.More(); it.Next())
if (!it.Value()->IsOk(anobj))
return Standard_False;
return Standard_True;
}

View File

@@ -23,7 +23,6 @@
#include <SelectMgr_CompositionFilter.hxx>
class SelectMgr_EntityOwner;
class SelectMgr_AndFilter;
DEFINE_STANDARD_HANDLE(SelectMgr_AndFilter, SelectMgr_CompositionFilter)
@@ -33,35 +32,17 @@ class SelectMgr_AndFilter : public SelectMgr_CompositionFilter
{
public:
//! Constructs an empty selection filter object for two or
//! more types of entity.
Standard_EXPORT SelectMgr_AndFilter();
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean
IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(SelectMgr_AndFilter,SelectMgr_CompositionFilter)
DEFINE_STANDARD_RTTIEXT(SelectMgr_AndFilter, SelectMgr_CompositionFilter)
protected:
private:
};
#endif // _SelectMgr_AndFilter_HeaderFile

View File

@@ -20,40 +20,34 @@
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_AndOrFilter, SelectMgr_CompositionFilter)
//=============================================================================
//function : SelectMgr_AndOrFilter
//purpose :
//=============================================================================
SelectMgr_AndOrFilter::SelectMgr_AndOrFilter (const SelectMgr_FilterType theFilterType):
myFilterType (theFilterType)
//=================================================================================================
SelectMgr_AndOrFilter::SelectMgr_AndOrFilter(const SelectMgr_FilterType theFilterType)
: myFilterType(theFilterType)
{
}
//=============================================================================
//function : SetDisabledObjects
//purpose :
//=============================================================================
void SelectMgr_AndOrFilter::SetDisabledObjects (const Handle(Graphic3d_NMapOfTransient)& theObjects)
//=================================================================================================
void SelectMgr_AndOrFilter::SetDisabledObjects(const Handle(Graphic3d_NMapOfTransient)& theObjects)
{
myDisabledObjects = theObjects;
}
//=============================================================================
//function : IsOk
//purpose :
//=============================================================================
Standard_Boolean SelectMgr_AndOrFilter::IsOk (const Handle(SelectMgr_EntityOwner)& theObj) const
//=================================================================================================
Standard_Boolean SelectMgr_AndOrFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theObj) const
{
const SelectMgr_SelectableObject* aSelectable = theObj->Selectable().operator->();
if (!myDisabledObjects.IsNull() && myDisabledObjects->Contains (aSelectable))
if (!myDisabledObjects.IsNull() && myDisabledObjects->Contains(aSelectable))
{
return Standard_False;
}
for (SelectMgr_ListIteratorOfListOfFilter anIter(myFilters); anIter.More();anIter.Next())
for (SelectMgr_ListIteratorOfListOfFilter anIter(myFilters); anIter.More(); anIter.Next())
{
Standard_Boolean isOK = anIter.Value()->IsOk(theObj);
if(isOK && myFilterType == SelectMgr_FilterType_OR)
if (isOK && myFilterType == SelectMgr_FilterType_OR)
{
return Standard_True;
}

View File

@@ -30,15 +30,15 @@ class SelectMgr_AndOrFilter : public SelectMgr_CompositionFilter
{
public:
//! Constructs an empty selection filter.
Standard_EXPORT SelectMgr_AndOrFilter (const SelectMgr_FilterType theFilterType);
Standard_EXPORT SelectMgr_AndOrFilter(const SelectMgr_FilterType theFilterType);
//! Indicates that the selected Interactive Object passes the filter.
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& theObj) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theObj) const
Standard_OVERRIDE;
//! Disable selection of specified objects.
Standard_EXPORT void SetDisabledObjects (const Handle(Graphic3d_NMapOfTransient)& theObjects);
Standard_EXPORT void SetDisabledObjects(const Handle(Graphic3d_NMapOfTransient)& theObjects);
//! @return a selection filter type (@sa SelectMgr_FilterType).
SelectMgr_FilterType FilterType() const { return myFilterType; }
@@ -46,17 +46,17 @@ public:
//! Sets a selection filter type.
//! SelectMgr_FilterType_OR selection filter is used be default.
//! @param theFilterType the filter type.
void SetFilterType (const SelectMgr_FilterType theFilterType) { myFilterType = theFilterType; }
void SetFilterType(const SelectMgr_FilterType theFilterType) { myFilterType = theFilterType; }
DEFINE_STANDARD_RTTIEXT(SelectMgr_AndOrFilter, SelectMgr_CompositionFilter)
private:
Handle(Graphic3d_NMapOfTransient) myDisabledObjects; //!< disabled objects.
//! Selection isn't applied to these objects.
// clang-format off
Handle(Graphic3d_NMapOfTransient)
myDisabledObjects; //!< disabled objects.
//! Selection isn't applied to these objects.
// clang-format off
SelectMgr_FilterType myFilterType; //!< selection filter type. SelectMgr_TypeFilter_OR by default.
// clang-format on
// clang-format on
};
#endif // _SelectMgr_AndOrFilter_HeaderFile

File diff suppressed because it is too large Load Diff

View File

@@ -23,7 +23,6 @@
class SelectMgr_AxisIntersector : public SelectMgr_BaseIntersector
{
public:
//! Empty constructor
Standard_EXPORT SelectMgr_AxisIntersector();
@@ -31,7 +30,7 @@ public:
Standard_EXPORT virtual ~SelectMgr_AxisIntersector();
//! Initializes selecting axis according to the input one
Standard_EXPORT void Init (const gp_Ax1& theAxis);
Standard_EXPORT void Init(const gp_Ax1& theAxis);
//! Builds axis according to internal parameters.
//! NOTE: it should be called after Init() method
@@ -39,128 +38,145 @@ public:
//! Saves camera definition.
//! Do nothing for axis intersector (not applicable to this volume).
Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE;
Standard_EXPORT virtual void SetCamera(const Handle(Graphic3d_Camera)& theCamera)
Standard_OVERRIDE;
//! Returns FALSE (not applicable to this volume).
virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; }
//! IMPORTANT: Scaling doesn't make sense for this intersector.
//! Returns a copy of the intersector transformed using the matrix given.
//! Builder is an optional argument that represents corresponding settings for re-constructing transformed frustum from scratch.
//! Can be null if reconstruction is not expected furthermore.
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
//! Builder is an optional argument that represents corresponding settings for re-constructing
//! transformed frustum from scratch. Can be null if reconstruction is not expected furthermore.
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform(
const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
//! Returns a copy of the intersector transformed using the builder configuration given.
//! Builder is an argument that represents corresponding settings for re-constructing transformed frustum from scratch.
//! In this class, builder is not used and theBuilder parameter is ignored.
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
//! Builder is an argument that represents corresponding settings for re-constructing transformed
//! frustum from scratch. In this class, builder is not used and theBuilder parameter is ignored.
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder(
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
public:
//! Intersection test between defined axis and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
Standard_OVERRIDE;
//! Returns true if selecting axis intersects axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside) const
Standard_OVERRIDE;
//! Intersection test between defined axis and given point
Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint(
const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined axis and given point
Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint(const gp_Pnt& thePnt) const
Standard_OVERRIDE;
//! Intersection test between defined axis and given ordered set of points,
//! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon(
const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Checks if selecting axis intersects line segment
Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSegment(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined axis and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices
//! depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined axis and given sphere with center theCenter
//! and radius theRadius
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
//! Intersection test between defined axis and given sphere with center theCenter
//! and radius theRadius
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(
const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
public:
//! Measures distance between start axis point and given point theCOG.
Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Real DistToGeometryCenter(const gp_Pnt& theCOG) const
Standard_OVERRIDE;
//! Calculates the point on a axis ray that was detected during the run of selection algo by given depth
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
//! Calculates the point on a axis ray that was detected during the run of selection algo by given
//! depth
Standard_EXPORT virtual gp_Pnt DetectedPoint(const Standard_Real theDepth) const
Standard_OVERRIDE;
//! Returns near point along axis.
Standard_EXPORT virtual const gp_Pnt& GetNearPnt() const Standard_OVERRIDE;
@@ -172,38 +188,38 @@ public:
Standard_EXPORT virtual const gp_Dir& GetViewRayDirection() 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:
//! Returns true if selecting axis intersects axis-aligned bounding box
//! with minimum corner at point theBoxMin and maximum at point theBoxMax.
//! Also returns enter and leave time of axis-box intersection.
Standard_EXPORT Standard_Boolean hasIntersection (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const;
Standard_EXPORT Standard_Boolean hasIntersection(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const;
//! Returns true if selecting axis intersects point.
//! Also returns time of axis-point intersection.
Standard_EXPORT Standard_Boolean hasIntersection (const gp_Pnt& thePnt,
Standard_Real& theDepth) const;
Standard_EXPORT Standard_Boolean hasIntersection(const gp_Pnt& thePnt,
Standard_Real& theDepth) const;
//! Returns true if selecting axis intersects segment.
//! Also saves time of axis-segment intersection and intersection point as pick result.
Standard_EXPORT Standard_Boolean raySegmentDistance (const gp_Pnt& theSegPnt1,
const gp_Pnt& theSegPnt2,
SelectBasics_PickResult& thePickResult) const;
Standard_EXPORT Standard_Boolean raySegmentDistance(const gp_Pnt& theSegPnt1,
const gp_Pnt& theSegPnt2,
SelectBasics_PickResult& thePickResult) const;
//! Returns true if selecting axis intersects plane.
//! Also saves time of axis-plane intersection and intersection point as pick result.
Standard_EXPORT Standard_Boolean rayPlaneIntersection (const gp_Vec& thePlane,
const gp_Pnt& thePntOnPlane,
SelectBasics_PickResult& thePickResult) const;
Standard_EXPORT Standard_Boolean
rayPlaneIntersection(const gp_Vec& thePlane,
const gp_Pnt& thePntOnPlane,
SelectBasics_PickResult& thePickResult) const;
private:
gp_Ax1 myAxis;
};
#endif // _SelectMgr_AxisIntersector_HeaderFile

View File

@@ -18,43 +18,37 @@
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BVHThreadPool, Standard_Transient)
//==================================================
// Function: SelectMgr_BVHThreadPool
// Purpose :
//==================================================
SelectMgr_BVHThreadPool::SelectMgr_BVHThreadPool (Standard_Integer theNbThreads)
: myToStopBVHThread(Standard_False),
myWakeEvent(Standard_False),
myIdleEvent(Standard_True),
myIsStarted(Standard_False)
//=================================================================================================
SelectMgr_BVHThreadPool::SelectMgr_BVHThreadPool(Standard_Integer theNbThreads)
: myToStopBVHThread(Standard_False),
myWakeEvent(Standard_False),
myIdleEvent(Standard_True),
myIsStarted(Standard_False)
{
Standard_Integer aBVHThreadsNum = Max (1, theNbThreads);
myBVHThreads.Resize (1, aBVHThreadsNum, Standard_False);
Standard_Integer aBVHThreadsNum = Max(1, theNbThreads);
myBVHThreads.Resize(1, aBVHThreadsNum, Standard_False);
Standard_Boolean toCatchFpe = OSD::ToCatchFloatingSignals();
for (Standard_Integer i = myBVHThreads.Lower(); i <= myBVHThreads.Upper(); ++i)
{
BVHThread& aThread = myBVHThreads.ChangeValue(i);
aThread.SetFunction (&BVHThread::runThread);
aThread.myPool = this;
aThread.SetFunction(&BVHThread::runThread);
aThread.myPool = this;
aThread.myToCatchFpe = toCatchFpe;
}
}
//==================================================
// Function: ~SelectMgr_BVHThreadPool
// Purpose :
//==================================================
//=================================================================================================
SelectMgr_BVHThreadPool::~SelectMgr_BVHThreadPool()
{
StopThreads();
}
//==================================================
// Function: StopThreads
// Purpose :
//==================================================
//=================================================================================================
void SelectMgr_BVHThreadPool::StopThreads()
{
if (!myIsStarted)
@@ -68,25 +62,21 @@ void SelectMgr_BVHThreadPool::StopThreads()
myBVHThreads.ChangeValue(i).Wait();
}
myToStopBVHThread = Standard_False;
myIsStarted = Standard_False;
myIsStarted = Standard_False;
}
//==================================================
// Function: WaitThreads
// Purpose :
//==================================================
//=================================================================================================
void SelectMgr_BVHThreadPool::WaitThreads()
{
myIdleEvent.Wait();
Sentry aSentry (this);
Sentry aSentry(this);
}
//=======================================================================
//function : AddEntity
//purpose :
//=======================================================================
void SelectMgr_BVHThreadPool::AddEntity (const Handle(Select3D_SensitiveEntity)& theEntity)
//=================================================================================================
void SelectMgr_BVHThreadPool::AddEntity(const Handle(Select3D_SensitiveEntity)& theEntity)
{
if (!theEntity->ToBuildBVH())
{
@@ -94,8 +84,8 @@ void SelectMgr_BVHThreadPool::AddEntity (const Handle(Select3D_SensitiveEntity)&
}
{
Standard_Mutex::Sentry aSentry (myBVHListMutex);
myBVHToBuildList.Append (theEntity);
Standard_Mutex::Sentry aSentry(myBVHListMutex);
myBVHToBuildList.Append(theEntity);
myWakeEvent.Set();
myIdleEvent.Reset();
}
@@ -105,18 +95,16 @@ void SelectMgr_BVHThreadPool::AddEntity (const Handle(Select3D_SensitiveEntity)&
myIsStarted = Standard_True;
for (Standard_Integer i = myBVHThreads.Lower(); i <= myBVHThreads.Upper(); ++i)
{
myBVHThreads.ChangeValue(i).Run ((Standard_Address) (&myBVHThreads.ChangeValue(i)));
myBVHThreads.ChangeValue(i).Run((Standard_Address)(&myBVHThreads.ChangeValue(i)));
}
}
}
//=======================================================================
//function : performThread
//purpose :
//=======================================================================
//=================================================================================================
void SelectMgr_BVHThreadPool::BVHThread::performThread()
{
OSD::SetThreadLocalSignal (OSD::SignalMode(), myToCatchFpe);
OSD::SetThreadLocalSignal(OSD::SignalMode(), myToCatchFpe);
for (;;)
{
@@ -137,8 +125,8 @@ void SelectMgr_BVHThreadPool::BVHThread::performThread()
}
Handle(Select3D_SensitiveEntity) anEntity = myPool->myBVHToBuildList.First();
myPool->myBVHToBuildList.RemoveFirst();
Standard_Mutex::Sentry anEntry (myMutex);
Standard_Mutex::Sentry anEntry(myMutex);
myPool->myBVHListMutex.Unlock();
if (!anEntity.IsNull())
@@ -146,23 +134,23 @@ void SelectMgr_BVHThreadPool::BVHThread::performThread()
try
{
OCC_CATCH_SIGNALS
anEntity->BVH();
anEntity->BVH();
}
catch (Standard_Failure const& aFailure)
{
TCollection_AsciiString aMsg = TCollection_AsciiString (aFailure.DynamicType()->Name())
+ ": " + aFailure.GetMessageString();
Message::DefaultMessenger()->SendFail (aMsg);
TCollection_AsciiString aMsg = TCollection_AsciiString(aFailure.DynamicType()->Name())
+ ": " + aFailure.GetMessageString();
Message::DefaultMessenger()->SendFail(aMsg);
}
catch (std::exception& anStdException)
{
TCollection_AsciiString aMsg = TCollection_AsciiString (typeid(anStdException).name())
+ ": " + anStdException.what();
Message::DefaultMessenger()->SendFail (aMsg);
TCollection_AsciiString aMsg =
TCollection_AsciiString(typeid(anStdException).name()) + ": " + anStdException.what();
Message::DefaultMessenger()->SendFail(aMsg);
}
catch (...)
{
Message::DefaultMessenger()->SendFail ("Error: Unknown exception");
Message::DefaultMessenger()->SendFail("Error: Unknown exception");
}
}
}
@@ -172,7 +160,7 @@ void SelectMgr_BVHThreadPool::BVHThread::performThread()
// function : runThread
// purpose :
// =======================================================================
Standard_Address SelectMgr_BVHThreadPool::BVHThread::runThread (Standard_Address theTask)
Standard_Address SelectMgr_BVHThreadPool::BVHThread::runThread(Standard_Address theTask)
{
BVHThread* aThread = static_cast<BVHThread*>(theTask);
aThread->performThread();

View File

@@ -21,58 +21,56 @@
#include <Standard_Condition.hxx>
#include <Message_Messenger.hxx>
//! Class defining a thread pool for building BVH for the list of Select3D_SensitiveEntity within background thread(s).
//! Class defining a thread pool for building BVH for the list of Select3D_SensitiveEntity within
//! background thread(s).
class SelectMgr_BVHThreadPool : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(SelectMgr_BVHThreadPool, Standard_Transient)
public:
//! Main constructor
Standard_EXPORT SelectMgr_BVHThreadPool (Standard_Integer theNbThreads);
Standard_EXPORT SelectMgr_BVHThreadPool(Standard_Integer theNbThreads);
//! Destructor
Standard_EXPORT virtual ~SelectMgr_BVHThreadPool();
public:
//! Thread with back reference to thread pool and thread mutex in it.
class BVHThread : public OSD_Thread
{
friend class SelectMgr_BVHThreadPool;
public:
BVHThread()
: OSD_Thread(),
myPool(nullptr),
myMutex(),
myToCatchFpe (Standard_False)
{}
BVHThread(const BVHThread& theOther)
: OSD_Thread(theOther),
myPool(theOther.myPool),
myMutex(),
myToCatchFpe(theOther.myToCatchFpe)
{}
//! Returns mutex used for BVH building
Standard_Mutex& BVHMutex()
: OSD_Thread(),
myPool(nullptr),
myMutex(),
myToCatchFpe(Standard_False)
{
return myMutex;
}
//! Assignment operator.
BVHThread& operator= (const BVHThread& theCopy)
BVHThread(const BVHThread& theOther)
: OSD_Thread(theOther),
myPool(theOther.myPool),
myMutex(),
myToCatchFpe(theOther.myToCatchFpe)
{
Assign (theCopy);
}
//! Returns mutex used for BVH building
Standard_Mutex& BVHMutex() { return myMutex; }
//! Assignment operator.
BVHThread& operator=(const BVHThread& theCopy)
{
Assign(theCopy);
return *this;
}
//! Assignment operator.
void Assign (const BVHThread& theCopy)
void Assign(const BVHThread& theCopy)
{
OSD_Thread::Assign (theCopy);
myPool = theCopy.myPool;
OSD_Thread::Assign(theCopy);
myPool = theCopy.myPool;
myToCatchFpe = theCopy.myToCatchFpe;
}
@@ -81,18 +79,17 @@ public:
void performThread();
//! Method is executed in the context of thread.
static Standard_Address runThread (Standard_Address theTask);
static Standard_Address runThread(Standard_Address theTask);
private:
SelectMgr_BVHThreadPool* myPool;
Standard_Mutex myMutex;
bool myToCatchFpe;
Standard_Mutex myMutex;
bool myToCatchFpe;
};
public:
//! Queue a sensitive entity to build its BVH
Standard_EXPORT void AddEntity (const Handle(Select3D_SensitiveEntity)& theEntity);
Standard_EXPORT void AddEntity(const Handle(Select3D_SensitiveEntity)& theEntity);
//! Stops threads
Standard_EXPORT void StopThreads();
@@ -101,30 +98,22 @@ public:
Standard_EXPORT void WaitThreads();
//! Returns array of threads
NCollection_Array1<BVHThread>& Threads()
{
return myBVHThreads;
}
NCollection_Array1<BVHThread>& Threads() { return myBVHThreads; }
public:
//! Class providing a simple interface to mutexes for list of BVHThread
class Sentry
class Sentry
{
public:
//! Constructor - initializes the sentry object and locks list of mutexes immediately
Sentry (const Handle(SelectMgr_BVHThreadPool)& thePool)
: myPool (thePool)
Sentry(const Handle(SelectMgr_BVHThreadPool)& thePool)
: myPool(thePool)
{
Lock();
}
//! Destructor - unlocks list of mutexes if already locked.
~Sentry()
{
Unlock();
}
~Sentry() { Unlock(); }
//! Lock list of mutexes
void Lock()
@@ -151,17 +140,16 @@ public:
}
//! This method should not be called (prohibited).
Sentry (const Sentry &);
Sentry(const Sentry&);
//! This method should not be called (prohibited).
Sentry& operator = (const Sentry &);
Sentry& operator=(const Sentry&);
private:
Handle(SelectMgr_BVHThreadPool) myPool;
};
protected:
// clang-format off
// clang-format off
NCollection_List<Handle(Select3D_SensitiveEntity)> myBVHToBuildList; //!< list of queued sensitive entities
NCollection_Array1<BVHThread> myBVHThreads; //!< threads to build BVH
Standard_Boolean myToStopBVHThread; //!< flag to stop BVH threads
@@ -169,7 +157,7 @@ protected:
Standard_Condition myWakeEvent; //!< raises when any sensitive is added to the BVH list
Standard_Condition myIdleEvent; //!< raises when BVH list become empty
Standard_Boolean myIsStarted; //!< indicates that threads are running
// clang-format on
// clang-format on
};
#endif

View File

@@ -21,26 +21,22 @@
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum, SelectMgr_BaseIntersector)
//=======================================================================
// function : SelectMgr_BaseFrustum
// purpose :
//=======================================================================
//=================================================================================================
SelectMgr_BaseFrustum::SelectMgr_BaseFrustum()
: myPixelTolerance (2)
: myPixelTolerance(2)
{
myBuilder = new SelectMgr_FrustumBuilder();
}
//=======================================================================
// function : SetCamera
// purpose :
//=======================================================================
void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
//=================================================================================================
void SelectMgr_BaseFrustum::SetCamera(const Handle(Graphic3d_Camera)& theCamera)
{
SelectMgr_BaseIntersector::SetCamera (theCamera);
SelectMgr_BaseIntersector::SetCamera(theCamera);
if (!myBuilder.IsNull())
{
myBuilder->SetCamera (theCamera);
myBuilder->SetCamera(theCamera);
myBuilder->InvalidateViewport();
}
}
@@ -49,47 +45,40 @@ void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera
// function : SetViewport
// purpose : Passes viewport parameters to builder
//=======================================================================
void SelectMgr_BaseFrustum::SetViewport (const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight)
void SelectMgr_BaseFrustum::SetViewport(const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight)
{
myBuilder->SetViewport (theX, theY, theWidth, theHeight);
myBuilder->SetViewport(theX, theY, theWidth, theHeight);
}
//=======================================================================
// function : SetPixelTolerance
// purpose :
//=======================================================================
void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Integer theTol)
//=================================================================================================
void SelectMgr_BaseFrustum::SetPixelTolerance(const Standard_Integer theTol)
{
myPixelTolerance = theTol;
}
//=======================================================================
// function : SetWindowSize
// purpose :
//=======================================================================
void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight)
//=================================================================================================
void SelectMgr_BaseFrustum::SetWindowSize(const Standard_Integer theWidth,
const Standard_Integer theHeight)
{
myBuilder->SetWindowSize (theWidth, theHeight);
myBuilder->SetWindowSize(theWidth, theHeight);
}
//=======================================================================
// function : WindowSize
// purpose :
//=======================================================================
void SelectMgr_BaseFrustum::WindowSize (Standard_Integer& theWidth,
Standard_Integer& theHeight) const
//=================================================================================================
void SelectMgr_BaseFrustum::WindowSize(Standard_Integer& theWidth,
Standard_Integer& theHeight) const
{
myBuilder->WindowSize (theWidth, theHeight);
myBuilder->WindowSize(theWidth, theHeight);
}
//=======================================================================
// function : SetBuilder
// purpose :
//=======================================================================
void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder)
//=================================================================================================
void SelectMgr_BaseFrustum::SetBuilder(const Handle(SelectMgr_FrustumBuilder)& theBuilder)
{
myBuilder.Nullify();
myBuilder = theBuilder;
@@ -99,41 +88,44 @@ void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)&
}
}
//=======================================================================
// function : IsBoundariesIntersectSphere
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::IsBoundaryIntersectSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const gp_Dir& thePlaneNormal,
const TColgp_Array1OfPnt& theBoundaries,
Standard_Boolean& theBoundaryInside) const
//=================================================================================================
Standard_Boolean SelectMgr_BaseFrustum::IsBoundaryIntersectSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
const gp_Dir& thePlaneNormal,
const TColgp_Array1OfPnt& theBoundaries,
Standard_Boolean& theBoundaryInside) const
{
for (Standard_Integer anIdx = theBoundaries.Lower(); anIdx < theBoundaries.Upper(); ++anIdx)
{
const Standard_Integer aNextIdx = ((anIdx + 1) == theBoundaries.Upper()) ? theBoundaries.Lower() : (anIdx + 1);
const gp_Pnt aPnt1 = theBoundaries.Value (anIdx);
const gp_Pnt aPnt2 = theBoundaries.Value (aNextIdx);
if (aPnt1.Distance (aPnt2) < Precision::Confusion())
const Standard_Integer aNextIdx =
((anIdx + 1) == theBoundaries.Upper()) ? theBoundaries.Lower() : (anIdx + 1);
const gp_Pnt aPnt1 = theBoundaries.Value(anIdx);
const gp_Pnt aPnt2 = theBoundaries.Value(aNextIdx);
if (aPnt1.Distance(aPnt2) < Precision::Confusion())
{
continue;
}
// Projections of the points on the plane
const gp_Pnt aPntProj1 = aPnt1.XYZ() - thePlaneNormal.XYZ() * aPnt1.XYZ().Dot (thePlaneNormal.XYZ());
const gp_Pnt aPntProj2 = aPnt2.XYZ() - thePlaneNormal.XYZ() * aPnt2.XYZ().Dot (thePlaneNormal.XYZ());
if (aPntProj1.Distance (theCenter) < theRadius || aPntProj2.Distance (theCenter) < theRadius) // polygon intersects the sphere
const gp_Pnt aPntProj1 =
aPnt1.XYZ() - thePlaneNormal.XYZ() * aPnt1.XYZ().Dot(thePlaneNormal.XYZ());
const gp_Pnt aPntProj2 =
aPnt2.XYZ() - thePlaneNormal.XYZ() * aPnt2.XYZ().Dot(thePlaneNormal.XYZ());
if (aPntProj1.Distance(theCenter) < theRadius
|| aPntProj2.Distance(theCenter) < theRadius) // polygon intersects the sphere
{
theBoundaryInside = Standard_True;
return Standard_True;
}
gp_Dir aRayDir (gp_Vec (aPntProj1, aPntProj2));
gp_Dir aRayDir(gp_Vec(aPntProj1, aPntProj2));
Standard_Real aTimeEnter = 0.0, aTimeLeave = 0.0;
if (RaySphereIntersection (theCenter, theRadius, aPntProj1, aRayDir, aTimeEnter, aTimeLeave))
if (RaySphereIntersection(theCenter, theRadius, aPntProj1, aRayDir, aTimeEnter, aTimeLeave))
{
if ((aTimeEnter > 0 && aTimeEnter < aPntProj1.Distance (aPntProj2))
|| (aTimeLeave > 0 && aTimeLeave < aPntProj1.Distance (aPntProj2)))
if ((aTimeEnter > 0 && aTimeEnter < aPntProj1.Distance(aPntProj2))
|| (aTimeLeave > 0 && aTimeLeave < aPntProj1.Distance(aPntProj2)))
{
return Standard_True; // polygon crosses the sphere
}
@@ -142,15 +134,13 @@ Standard_Boolean SelectMgr_BaseFrustum::IsBoundaryIntersectSphere (const gp_Pnt&
return Standard_False;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void SelectMgr_BaseFrustum::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_BaseFrustum)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_BaseIntersector)
//=================================================================================================
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPixelTolerance)
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myBuilder)
void SelectMgr_BaseFrustum::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN(theOStream, SelectMgr_BaseFrustum)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, SelectMgr_BaseIntersector)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myPixelTolerance)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myBuilder)
}

View File

@@ -26,7 +26,6 @@
class SelectMgr_BaseFrustum : public SelectMgr_BaseIntersector
{
public:
//! Creates new selecting volume with pixel tolerance set to 2,
//! orthographic camera and empty frustum builder
Standard_EXPORT SelectMgr_BaseFrustum();
@@ -35,34 +34,38 @@ public:
virtual ~SelectMgr_BaseFrustum() {}
//! Nullifies the builder created in the constructor and copies the pointer given
Standard_EXPORT void SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder);
Standard_EXPORT void SetBuilder(const Handle(SelectMgr_FrustumBuilder)& theBuilder);
//! Saves camera definition and passes it to builder
Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE;
Standard_EXPORT virtual void SetCamera(const Handle(Graphic3d_Camera)& theCamera)
Standard_OVERRIDE;
Standard_EXPORT virtual void SetPixelTolerance (const Standard_Integer theTol) Standard_OVERRIDE;
Standard_EXPORT virtual void SetPixelTolerance(const Standard_Integer theTol) Standard_OVERRIDE;
Standard_EXPORT virtual void SetWindowSize (const Standard_Integer theWidth,
const Standard_Integer theHeight) Standard_OVERRIDE;
Standard_EXPORT virtual void SetWindowSize(const Standard_Integer theWidth,
const Standard_Integer theHeight) Standard_OVERRIDE;
Standard_EXPORT virtual void WindowSize (Standard_Integer& theWidth,
Standard_Integer& theHeight) const Standard_OVERRIDE;
Standard_EXPORT virtual void WindowSize(Standard_Integer& theWidth,
Standard_Integer& theHeight) const Standard_OVERRIDE;
//! Passes viewport parameters to builder
Standard_EXPORT virtual void SetViewport (const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight) Standard_OVERRIDE;
Standard_EXPORT virtual void SetViewport(const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight) Standard_OVERRIDE;
//! Checks whether the boundary of the current volume selection intersects with a sphere or are there it's boundaries lying inside the sphere
Standard_EXPORT Standard_Boolean IsBoundaryIntersectSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const gp_Dir& thePlaneNormal,
const TColgp_Array1OfPnt& theBoundaries,
Standard_Boolean& theBoundaryInside) const;
//! Checks whether the boundary of the current volume selection intersects with a sphere or are
//! there it's boundaries lying inside the sphere
Standard_EXPORT Standard_Boolean
IsBoundaryIntersectSphere(const gp_Pnt& theCenter,
const Standard_Real theRadius,
const gp_Dir& thePlaneNormal,
const TColgp_Array1OfPnt& theBoundaries,
Standard_Boolean& theBoundaryInside) const;
//! 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(SelectMgr_BaseFrustum, SelectMgr_BaseIntersector)

View File

@@ -20,141 +20,111 @@
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseIntersector, Standard_Transient)
//=======================================================================
// function : SelectMgr_BaseIntersector
// purpose :
//=======================================================================
//=================================================================================================
SelectMgr_BaseIntersector::SelectMgr_BaseIntersector()
: mySelectionType (SelectMgr_SelectionType_Unknown)
: mySelectionType(SelectMgr_SelectionType_Unknown)
{
//
}
//=======================================================================
// function : ~SelectMgr_BaseIntersector
// purpose :
//=======================================================================
//=================================================================================================
SelectMgr_BaseIntersector::~SelectMgr_BaseIntersector()
{
//
}
//=======================================================================
// function : SetCamera
// purpose :
//=======================================================================
void SelectMgr_BaseIntersector::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
//=================================================================================================
void SelectMgr_BaseIntersector::SetCamera(const Handle(Graphic3d_Camera)& theCamera)
{
myCamera = theCamera;
}
//=======================================================================
// function : SetPixelTolerance
// purpose :
//=======================================================================
void SelectMgr_BaseIntersector::SetPixelTolerance (const Standard_Integer)
//=================================================================================================
void SelectMgr_BaseIntersector::SetPixelTolerance(const Standard_Integer) {}
//=================================================================================================
void SelectMgr_BaseIntersector::WindowSize(Standard_Integer&, Standard_Integer&) const {}
//=================================================================================================
void SelectMgr_BaseIntersector::SetWindowSize(const Standard_Integer, const Standard_Integer) {}
//=================================================================================================
void SelectMgr_BaseIntersector::SetViewport(const Standard_Real,
const Standard_Real,
const Standard_Real,
const Standard_Real)
{
}
//=======================================================================
// function : WindowSize
// purpose :
//=======================================================================
void SelectMgr_BaseIntersector::WindowSize (Standard_Integer&,
Standard_Integer&) const
{
}
//=================================================================================================
//=======================================================================
// function : SetWindowSize
// purpose :
//=======================================================================
void SelectMgr_BaseIntersector::SetWindowSize (const Standard_Integer,
const Standard_Integer)
{
}
//=======================================================================
// function : SetViewport
// purpose :
//=======================================================================
void SelectMgr_BaseIntersector::SetViewport (const Standard_Real,
const Standard_Real,
const Standard_Real,
const Standard_Real)
{
}
//=======================================================================
// function : GetNearPnt
// purpose :
//=======================================================================
const gp_Pnt& SelectMgr_BaseIntersector::GetNearPnt() const
{
static const gp_Pnt anEmptyPnt;
return anEmptyPnt;
}
//=======================================================================
// function : GetFarPnt
// purpose :
//=======================================================================
//=================================================================================================
const gp_Pnt& SelectMgr_BaseIntersector::GetFarPnt() const
{
static const gp_Pnt anEmptyPnt(RealLast(), RealLast(), RealLast());
return anEmptyPnt;
}
//=======================================================================
// function : GetViewRayDirection
// purpose :
//=======================================================================
//=================================================================================================
const gp_Dir& SelectMgr_BaseIntersector::GetViewRayDirection() const
{
static const gp_Dir anEmptyDir;
return anEmptyDir;
}
//=======================================================================
// function : GetMousePosition
// purpose :
//=======================================================================
//=================================================================================================
const gp_Pnt2d& SelectMgr_BaseIntersector::GetMousePosition() const
{
static const gp_Pnt2d aPnt(RealLast(), RealLast());
return aPnt;
}
//=======================================================================
// function : RaySphereIntersection
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_BaseIntersector::RaySphereIntersection (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const
//=================================================================================================
Standard_Boolean SelectMgr_BaseIntersector::RaySphereIntersection(const gp_Pnt& theCenter,
const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const
{
// to find the intersection of the ray (theLoc, theRayDir) and sphere with theCenter(x0, y0, z0) and theRadius(R), you need to solve the equation
// (x' - x0)^2 + (y' - y0)^2 + (z' - z0)^2 = R^2, where P(x',y',z') = theLoc(x,y,z) + theRayDir(vx,vy,vz) * T
// at the end of solving, you receive a square equation with respect to T
// T^2 * (vx^2 + vy^2 + vz^2) + 2 * T * (vx*(x - x0) + vy*(y - y0) + vz*(z - z0)) + ((x-x0)^2 + (y-y0)^2 + (z-z0)^2 -R^2) = 0 (= A*T^2 + K*T + C)
// and find T by discriminant D = K^2 - A*C
const Standard_Real anA = theRayDir.Dot (theRayDir);
const Standard_Real aK = theRayDir.X() * (theLoc.X() - theCenter.X())
+ theRayDir.Y() * (theLoc.Y() - theCenter.Y())
+ theRayDir.Z() * (theLoc.Z() - theCenter.Z());
const Standard_Real aC = theLoc.Distance (theCenter) * theLoc.Distance (theCenter) - theRadius * theRadius;
// to find the intersection of the ray (theLoc, theRayDir) and sphere with theCenter(x0, y0, z0)
// and theRadius(R), you need to solve the equation (x' - x0)^2 + (y' - y0)^2 + (z' - z0)^2 = R^2,
// where P(x',y',z') = theLoc(x,y,z) + theRayDir(vx,vy,vz) * T at the end of solving, you receive
// a square equation with respect to T T^2 * (vx^2 + vy^2 + vz^2) + 2 * T * (vx*(x - x0) + vy*(y -
// y0) + vz*(z - z0)) + ((x-x0)^2 + (y-y0)^2 + (z-z0)^2 -R^2) = 0 (= A*T^2 + K*T + C) and find T
// by discriminant D = K^2 - A*C
const Standard_Real anA = theRayDir.Dot(theRayDir);
const Standard_Real aK = theRayDir.X() * (theLoc.X() - theCenter.X())
+ theRayDir.Y() * (theLoc.Y() - theCenter.Y())
+ theRayDir.Z() * (theLoc.Z() - theCenter.Z());
const Standard_Real aC =
theLoc.Distance(theCenter) * theLoc.Distance(theCenter) - theRadius * theRadius;
const Standard_Real aDiscr = aK * aK - anA * aC;
if (aDiscr < 0)
{
return Standard_False;
}
const Standard_Real aTime1 = (-aK - Sqrt (aDiscr)) / anA;
const Standard_Real aTime2 = (-aK + Sqrt (aDiscr)) / anA;
if (Abs (aTime1) < Abs (aTime2))
const Standard_Real aTime1 = (-aK - Sqrt(aDiscr)) / anA;
const Standard_Real aTime2 = (-aK + Sqrt(aDiscr)) / anA;
if (Abs(aTime1) < Abs(aTime2))
{
theTimeEnter = aTime1;
theTimeLeave = aTime2;
@@ -167,36 +137,35 @@ Standard_Boolean SelectMgr_BaseIntersector::RaySphereIntersection (const gp_Pnt&
return Standard_True;
}
//=======================================================================
// function : RayCylinderIntersection
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_BaseIntersector::RayCylinderIntersection (const Standard_Real theBottomRadius,
const Standard_Real theTopRadius,
const Standard_Real theHeight,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsHollow,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const
//=================================================================================================
Standard_Boolean SelectMgr_BaseIntersector::RayCylinderIntersection(
const Standard_Real theBottomRadius,
const Standard_Real theTopRadius,
const Standard_Real theHeight,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsHollow,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const
{
Standard_Integer aNbIntersections = 0;
Standard_Real anIntersections[4] = { RealLast(), RealLast(), RealLast(), RealLast() };
Standard_Integer aNbIntersections = 0;
Standard_Real anIntersections[4] = {RealLast(), RealLast(), RealLast(), RealLast()};
// Check intersections with end faces
// point of intersection theRayDir and z = 0
if (!theIsHollow && theRayDir.Z() != 0)
{
const Standard_Real aTime1 = (0 - theLoc.Z()) / theRayDir.Z();
const Standard_Real aX1 = theLoc.X() + theRayDir.X() * aTime1;
const Standard_Real anY1 = theLoc.Y() + theRayDir.Y() * aTime1;
const Standard_Real aX1 = theLoc.X() + theRayDir.X() * aTime1;
const Standard_Real anY1 = theLoc.Y() + theRayDir.Y() * aTime1;
if (aX1 * aX1 + anY1 * anY1 <= theBottomRadius * theBottomRadius)
{
anIntersections[aNbIntersections++] = aTime1;
}
// point of intersection theRayDir and z = theHeight
const Standard_Real aTime2 = (theHeight - theLoc.Z()) / theRayDir.Z();
const Standard_Real aX2 = theLoc.X() + theRayDir.X() * aTime2;
const Standard_Real anY2 = theLoc.Y() + theRayDir.Y() * aTime2;
const Standard_Real aX2 = theLoc.X() + theRayDir.X() * aTime2;
const Standard_Real anY2 = theLoc.Y() + theRayDir.Y() * aTime2;
if (aX2 * aX2 + anY2 * anY2 <= theTopRadius * theTopRadius)
{
anIntersections[aNbIntersections++] = aTime2;
@@ -205,43 +174,43 @@ Standard_Boolean SelectMgr_BaseIntersector::RayCylinderIntersection (const Stand
// ray intersection with cone / truncated cone
if (theTopRadius != theBottomRadius)
{
const Standard_Real aTriangleHeight = Min (theBottomRadius, theTopRadius) * theHeight /
(Abs (theBottomRadius - theTopRadius));
const Standard_Real aTriangleHeight =
Min(theBottomRadius, theTopRadius) * theHeight / (Abs(theBottomRadius - theTopRadius));
gp_Ax3 aSystem;
if (theBottomRadius > theTopRadius)
{
aSystem.SetLocation (gp_Pnt (0, 0, theHeight + aTriangleHeight));
aSystem.SetDirection (-gp::DZ());
aSystem.SetLocation(gp_Pnt(0, 0, theHeight + aTriangleHeight));
aSystem.SetDirection(-gp::DZ());
}
else
{
aSystem.SetLocation (gp_Pnt (0, 0, -aTriangleHeight));
aSystem.SetDirection (gp::DZ());
aSystem.SetLocation(gp_Pnt(0, 0, -aTriangleHeight));
aSystem.SetDirection(gp::DZ());
}
gp_Trsf aTrsfCone;
aTrsfCone.SetTransformation (gp_Ax3(), aSystem);
const gp_Pnt aPnt (theLoc.Transformed (aTrsfCone));
const gp_Dir aDir (theRayDir.Transformed (aTrsfCone));
const Standard_Real aMaxRad = Max (theBottomRadius, theTopRadius);
aTrsfCone.SetTransformation(gp_Ax3(), aSystem);
const gp_Pnt aPnt(theLoc.Transformed(aTrsfCone));
const gp_Dir aDir(theRayDir.Transformed(aTrsfCone));
const Standard_Real aMaxRad = Max(theBottomRadius, theTopRadius);
const Standard_Real aConeHeight = theHeight + aTriangleHeight;
// solving quadratic equation anA * T^2 + 2 * aK * T + aC = 0
const Standard_Real anA = aDir.X() * aDir.X() / (aMaxRad * aMaxRad)
+ aDir.Y() * aDir.Y() / (aMaxRad * aMaxRad)
- aDir.Z() * aDir.Z() / (aConeHeight * aConeHeight);
+ aDir.Y() * aDir.Y() / (aMaxRad * aMaxRad)
- aDir.Z() * aDir.Z() / (aConeHeight * aConeHeight);
const Standard_Real aK = aDir.X() * aPnt.X() / (aMaxRad * aMaxRad)
+ aDir.Y() * aPnt.Y() / (aMaxRad * aMaxRad)
- aDir.Z() * aPnt.Z() / (aConeHeight * aConeHeight);
+ aDir.Y() * aPnt.Y() / (aMaxRad * aMaxRad)
- aDir.Z() * aPnt.Z() / (aConeHeight * aConeHeight);
const Standard_Real aC = aPnt.X() * aPnt.X() / (aMaxRad * aMaxRad)
+ aPnt.Y() * aPnt.Y() / (aMaxRad * aMaxRad)
- aPnt.Z() * aPnt.Z() / (aConeHeight * aConeHeight);
+ aPnt.Y() * aPnt.Y() / (aMaxRad * aMaxRad)
- aPnt.Z() * aPnt.Z() / (aConeHeight * aConeHeight);
Standard_Real aDiscr = aK * aK - anA * aC;
if (aDiscr > 0)
{
const Standard_Real aTimeEnterCone = (-aK - Sqrt (aDiscr)) / anA;
const Standard_Real aTimeLeaveCone = (-aK + Sqrt (aDiscr)) / anA;
const Standard_Real aZFromRoot1 = aPnt.Z() + aTimeEnterCone * aDir.Z();
const Standard_Real aZFromRoot2 = aPnt.Z() + aTimeLeaveCone * aDir.Z();
const Standard_Real aTimeEnterCone = (-aK - Sqrt(aDiscr)) / anA;
const Standard_Real aTimeLeaveCone = (-aK + Sqrt(aDiscr)) / anA;
const Standard_Real aZFromRoot1 = aPnt.Z() + aTimeEnterCone * aDir.Z();
const Standard_Real aZFromRoot2 = aPnt.Z() + aTimeLeaveCone * aDir.Z();
if (aZFromRoot1 > aTriangleHeight && aZFromRoot1 < aConeHeight)
{
@@ -255,18 +224,18 @@ Standard_Boolean SelectMgr_BaseIntersector::RayCylinderIntersection (const Stand
}
else // ray intersection with cylinder
{
const gp_Pnt2d aLoc2d (theLoc.X(), theLoc.Y());
const gp_Vec2d aRayDir2d (theRayDir.X(), theRayDir.Y());
const gp_Pnt2d aLoc2d(theLoc.X(), theLoc.Y());
const gp_Vec2d aRayDir2d(theRayDir.X(), theRayDir.Y());
// solving quadratic equation anA * T^2 + 2 * aK * T + aC = 0
const Standard_Real anA = aRayDir2d.Dot (aRayDir2d);
const Standard_Real aK = aLoc2d.XY().Dot (aRayDir2d.XY());
const Standard_Real aC = aLoc2d.XY().Dot (aLoc2d.XY()) - theTopRadius * theTopRadius;
const Standard_Real anA = aRayDir2d.Dot(aRayDir2d);
const Standard_Real aK = aLoc2d.XY().Dot(aRayDir2d.XY());
const Standard_Real aC = aLoc2d.XY().Dot(aLoc2d.XY()) - theTopRadius * theTopRadius;
const Standard_Real aDiscr = aK * aK - anA * aC;
if (aDiscr > 0)
{
const Standard_Real aRoot1 = (-aK + Sqrt (aDiscr)) / anA;
const Standard_Real aRoot2 = (-aK - Sqrt (aDiscr)) / anA;
const Standard_Real aRoot1 = (-aK + Sqrt(aDiscr)) / anA;
const Standard_Real aRoot2 = (-aK - Sqrt(aDiscr)) / anA;
const Standard_Real aZFromRoot1 = theLoc.Z() + aRoot1 * theRayDir.Z();
const Standard_Real aZFromRoot2 = theLoc.Z() + aRoot2 * theRayDir.Z();
if (aZFromRoot1 > 0 && aZFromRoot1 < theHeight)
@@ -284,7 +253,7 @@ Standard_Boolean SelectMgr_BaseIntersector::RayCylinderIntersection (const Stand
return false;
}
std::sort (anIntersections, anIntersections + aNbIntersections);
std::sort(anIntersections, anIntersections + aNbIntersections);
theTimeEnter = anIntersections[0];
if (aNbIntersections > 1)
{
@@ -293,25 +262,24 @@ Standard_Boolean SelectMgr_BaseIntersector::RayCylinderIntersection (const Stand
return true;
}
//=======================================================================
// function : RayCircleIntersection
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_BaseIntersector::RayCircleIntersection (const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsFilled,
Standard_Real& theTime) const
//=================================================================================================
Standard_Boolean SelectMgr_BaseIntersector::RayCircleIntersection(
const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsFilled,
Standard_Real& theTime) const
{
if (theRayDir.Z() != 0)
{
const Standard_Real aTime = (0 - theLoc.Z()) / theRayDir.Z();
const Standard_Real aX1 = theLoc.X() + theRayDir.X() * aTime;
const Standard_Real anY1 = theLoc.Y() + theRayDir.Y() * aTime;
const Standard_Real aX1 = theLoc.X() + theRayDir.X() * aTime;
const Standard_Real anY1 = theLoc.Y() + theRayDir.Y() * aTime;
const Standard_Real aK = aX1 * aX1 + anY1 * anY1;
if ((theIsFilled && aK <= theRadius * theRadius)
|| (!theIsFilled && Abs (sqrt (aK) - theRadius) <= Precision::Confusion()))
|| (!theIsFilled && Abs(sqrt(aK) - theRadius) <= Precision::Confusion()))
{
theTime = aTime;
return true;
@@ -320,32 +288,26 @@ Standard_Boolean SelectMgr_BaseIntersector::RayCircleIntersection (const Standar
return false;
}
//=======================================================================
// function : DistToGeometryCenter
// purpose :
//=======================================================================
Standard_Real SelectMgr_BaseIntersector::DistToGeometryCenter (const gp_Pnt&) const
//=================================================================================================
Standard_Real SelectMgr_BaseIntersector::DistToGeometryCenter(const gp_Pnt&) const
{
return RealLast();
}
//=======================================================================
// function : DetectedPoint
// purpose :
//=======================================================================
gp_Pnt SelectMgr_BaseIntersector::DetectedPoint (const Standard_Real) const
//=================================================================================================
gp_Pnt SelectMgr_BaseIntersector::DetectedPoint(const Standard_Real) const
{
return gp_Pnt(RealLast(), RealLast(), RealLast());
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void SelectMgr_BaseIntersector::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
//=================================================================================================
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySelectionType)
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCamera)
void SelectMgr_BaseIntersector::DumpJson(Standard_OStream& theOStream, Standard_Integer) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, mySelectionType)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myCamera)
}

View File

@@ -37,7 +37,6 @@ class SelectMgr_ViewClipRange;
class SelectMgr_BaseIntersector : public Standard_Transient
{
public:
//! Creates new empty selecting volume
Standard_EXPORT SelectMgr_BaseIntersector();
@@ -51,55 +50,59 @@ public:
SelectMgr_SelectionType GetSelectionType() const { return mySelectionType; }
public:
//! Checks if it is possible to scale this intersector.
virtual Standard_Boolean IsScalable() const = 0;
//! Sets pixel tolerance.
//! It makes sense only for scalable intersectors (built on a single point).
//! This method does nothing for the base class.
Standard_EXPORT virtual void SetPixelTolerance (const Standard_Integer theTol);
Standard_EXPORT virtual void SetPixelTolerance(const Standard_Integer theTol);
//! Note that this method does not perform any checks on type of the frustum.
//! @param[in] theScaleFactor scale factor for new intersector or negative value if undefined;
//! IMPORTANT: scaling makes sense only for scalable ::IsScalable() intersectors (built on a single point)!
//! IMPORTANT: scaling makes sense only for scalable ::IsScalable()
//! intersectors (built on a single point)!
//! @param[in] theTrsf transformation for new intersector or gp_Identity if undefined
//! @param[in] theBuilder an optional argument that represents corresponding settings for re-constructing transformed frustum from scratch;
//! @param[in] theBuilder an optional argument that represents corresponding settings for
//! re-constructing transformed frustum from scratch;
//! could be NULL if reconstruction is not expected furthermore
//! @return a copy of the frustum resized according to the scale factor given and transforms it using the matrix given
virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const = 0;
//! @return a copy of the frustum resized according to the scale factor given and transforms it
//! using the matrix given
virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform(
const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const = 0;
//! @param[in] theBuilder argument that represents corresponding settings for re-constructing transformed frustum from scratch;
//! @param[in] theBuilder argument that represents corresponding settings for re-constructing
//! transformed frustum from scratch;
//! should NOT be NULL.
//! @return a copy of the frustum with the input builder assigned
virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const = 0;
virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder(
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const = 0;
public:
//! Return camera definition.
const Handle(Graphic3d_Camera)& Camera() const { return myCamera; }
//! Saves camera definition.
Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
Standard_EXPORT virtual void SetCamera(const Handle(Graphic3d_Camera)& theCamera);
//! Returns current window size.
//! This method doesn't set any output values for the base class.
Standard_EXPORT virtual void WindowSize (Standard_Integer& theWidth,
Standard_Integer& theHeight) const;
Standard_EXPORT virtual void WindowSize(Standard_Integer& theWidth,
Standard_Integer& theHeight) const;
//! Sets current window size.
//! This method does nothing for the base class.
Standard_EXPORT virtual void SetWindowSize (const Standard_Integer theWidth,
const Standard_Integer theHeight);
Standard_EXPORT virtual void SetWindowSize(const Standard_Integer theWidth,
const Standard_Integer theHeight);
//! Sets viewport parameters.
//! This method does nothing for the base class.
Standard_EXPORT virtual void SetViewport (const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight);
Standard_EXPORT virtual void SetViewport(const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight);
//! Returns near point of intersector.
//! This method returns zero point for the base class.
@@ -120,137 +123,139 @@ public:
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector.
//! This method only clears input vector for the base class.
virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
virtual void GetPlanes(NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
{
thePlaneEquations.Clear();
}
public:
//! SAT intersection test between defined volume and given axis-aligned box
virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt
virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside = NULL) const = 0;
virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside = NULL) const = 0;
//! Intersection test between defined volume and given point
virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
virtual Standard_Boolean OverlapsPoint(const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Intersection test between defined volume and given point
//! Does not perform depth calculation, so this method is defined as helper function for inclusion test.
//! Therefore, its implementation makes sense only for rectangular frustum with box selection mode activated.
virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const = 0;
//! Does not perform depth calculation, so this method is defined as helper function for inclusion
//! test. Therefore, its implementation makes sense only for rectangular frustum with box
//! selection mode activated.
virtual Standard_Boolean OverlapsPoint(const gp_Pnt& thePnt) const = 0;
//! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type
virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
virtual Standard_Boolean OverlapsPolygon(const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Checks if line segment overlaps selecting frustum
virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
virtual Standard_Boolean OverlapsSegment(const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! SAT intersection test between defined volume and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices
//! depending on given sensitivity type
virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
virtual Standard_Boolean OverlapsTriangle(const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by sphere with center theCenter
//! and radius theRadius
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const = 0;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const = 0;
//! Returns true if selecting volume is overlapped by sphere with center theCenter
//! and radius theRadius
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
virtual Standard_Boolean OverlapsCylinder(const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const = 0;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
virtual Standard_Boolean OverlapsCylinder(const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const = 0;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
virtual Standard_Boolean OverlapsCircle(const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const = 0;
virtual Standard_Boolean OverlapsCircle(const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const = 0;
public:
//! Measures distance between 3d projection of user-picked
//! screen point and given point theCOG.
//! It makes sense only for intersectors built on a single point.
//! This method returns infinite value for the base class.
Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const;
Standard_EXPORT virtual Standard_Real DistToGeometryCenter(const gp_Pnt& theCOG) const;
//! Calculates the point on a view ray that was detected during the run of selection algo by given depth.
//! It makes sense only for intersectors built on a single point.
//! This method returns infinite point for the base class.
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const;
//! Calculates the point on a view ray that was detected during the run of selection algo by given
//! depth. It makes sense only for intersectors built on a single point. This method returns
//! infinite point for the base class.
Standard_EXPORT virtual gp_Pnt DetectedPoint(const Standard_Real theDepth) const;
//! 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;
//! Checks whether the ray that starts at the point theLoc and directs with the direction theRayDir intersects
//! with the sphere with center at theCenter and radius TheRadius
Standard_EXPORT virtual Standard_Boolean RaySphereIntersection (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const;
//! Checks whether the ray that starts at the point theLoc and directs with the direction
//! theRayDir intersects with the sphere with center at theCenter and radius TheRadius
Standard_EXPORT virtual Standard_Boolean RaySphereIntersection(const gp_Pnt& theCenter,
const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const;
//! Checks whether the ray that starts at the point theLoc and directs with the direction theRayDir intersects
//! with the hollow cylinder (or cone)
//! Checks whether the ray that starts at the point theLoc and directs with the direction
//! theRayDir intersects with the hollow cylinder (or cone)
//! @param[in] theBottomRadius the bottom cylinder radius
//! @param[in] theTopRadius the top cylinder radius
//! @param[in] theHeight the cylinder height
@@ -259,36 +264,36 @@ public:
//! @param[in] theIsHollow true if the cylinder is hollow
//! @param[out] theTimeEnter the entering the intersection
//! @param[out] theTimeLeave the leaving the intersection
Standard_EXPORT virtual Standard_Boolean RayCylinderIntersection (const Standard_Real theBottomRadius,
const Standard_Real theTopRadius,
const Standard_Real theHeight,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsHollow,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const;
Standard_EXPORT virtual Standard_Boolean RayCylinderIntersection(
const Standard_Real theBottomRadius,
const Standard_Real theTopRadius,
const Standard_Real theHeight,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsHollow,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const;
//! Checks whether the ray that starts at the point theLoc and directs with the direction theRayDir intersects
//! with the circle
//! Checks whether the ray that starts at the point theLoc and directs with the direction
//! theRayDir intersects with the circle
//! @param[in] theRadius the circle radius
//! @param[in] theLoc the location of the ray
//! @param[in] theRayDir the ray direction
//! @param[in] theIsFilled true if it's a circle, false if it's a circle outline
//! @param[out] theTime the intersection
Standard_EXPORT virtual Standard_Boolean RayCircleIntersection (const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsFilled,
Standard_Real& theTime) const;
Standard_EXPORT virtual Standard_Boolean RayCircleIntersection(const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsFilled,
Standard_Real& theTime) const;
DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseIntersector,Standard_Transient)
DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseIntersector, Standard_Transient)
protected:
// clang-format off
// clang-format off
Handle(Graphic3d_Camera) myCamera; //!< camera definition (if builder isn't NULL it is the same as its camera)
// clang-format on
SelectMgr_SelectionType mySelectionType; //!< type of selection
// clang-format on
SelectMgr_SelectionType mySelectionType; //!< type of selection
};
#endif // _SelectMgr_BaseIntersector_HeaderFile

View File

@@ -14,13 +14,12 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <SelectMgr_CompositionFilter.hxx>
#include <SelectMgr_Filter.hxx>
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_CompositionFilter,SelectMgr_Filter)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_CompositionFilter, SelectMgr_Filter)
void SelectMgr_CompositionFilter::Add(const Handle(SelectMgr_Filter)& afilter)
{
@@ -30,15 +29,16 @@ void SelectMgr_CompositionFilter::Add(const Handle(SelectMgr_Filter)& afilter)
void SelectMgr_CompositionFilter::Remove(const Handle(SelectMgr_Filter)& afilter)
{
SelectMgr_ListIteratorOfListOfFilter It(myFilters);
for(;It.More();It.Next()){
if (afilter==It.Value()){
for (; It.More(); It.Next())
{
if (afilter == It.Value())
{
myFilters.Remove(It);
return;
}
}
}
Standard_Boolean SelectMgr_CompositionFilter::IsEmpty() const
{
return myFilters.IsEmpty();
@@ -47,26 +47,25 @@ Standard_Boolean SelectMgr_CompositionFilter::IsEmpty() const
Standard_Boolean SelectMgr_CompositionFilter::IsIn(const Handle(SelectMgr_Filter)& afilter) const
{
SelectMgr_ListIteratorOfListOfFilter It(myFilters);
for(;It.More();It.Next())
if (afilter==It.Value())
for (; It.More(); It.Next())
if (afilter == It.Value())
return Standard_True;
return Standard_False;
}
void SelectMgr_CompositionFilter::Clear()
void SelectMgr_CompositionFilter::Clear()
{
myFilters.Clear();
}
Standard_Boolean SelectMgr_CompositionFilter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const
{
SelectMgr_ListIteratorOfListOfFilter It(myFilters);
for(;It.More();It.Next()){
for (; It.More(); It.Next())
{
if (It.Value()->ActsOn(aStandardMode))
return Standard_True;
}
return Standard_False;
}

View File

@@ -29,19 +29,18 @@ class SelectMgr_CompositionFilter : public SelectMgr_Filter
{
public:
//! Adds the filter afilter to a filter object created by a
//! filter class inheriting this framework.
Standard_EXPORT void Add (const Handle(SelectMgr_Filter)& afilter);
Standard_EXPORT void Add(const Handle(SelectMgr_Filter)& afilter);
//! Removes the filter aFilter from this framework.
Standard_EXPORT void Remove (const Handle(SelectMgr_Filter)& aFilter);
Standard_EXPORT void Remove(const Handle(SelectMgr_Filter)& aFilter);
//! Returns true if this framework is empty.
Standard_EXPORT Standard_Boolean IsEmpty() const;
//! Returns true if the filter aFilter is in this framework.
Standard_EXPORT Standard_Boolean IsIn (const Handle(SelectMgr_Filter)& aFilter) const;
Standard_EXPORT Standard_Boolean IsIn(const Handle(SelectMgr_Filter)& aFilter) const;
//! Returns the list of stored filters from this framework.
const SelectMgr_ListOfFilter& StoredFilters() const { return myFilters; }
@@ -49,14 +48,13 @@ public:
//! Clears the filters used in this framework.
Standard_EXPORT void Clear();
Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aStandardMode) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aStandardMode) const
Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(SelectMgr_CompositionFilter,SelectMgr_Filter)
DEFINE_STANDARD_RTTIEXT(SelectMgr_CompositionFilter, SelectMgr_Filter)
protected:
SelectMgr_ListOfFilter myFilters;
};
#endif // _SelectMgr_CompositionFilter_HeaderFile

View File

@@ -18,54 +18,46 @@
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_EntityOwner, Standard_Transient)
//==================================================
// Function: SelectMgr_EntityOwner
// Purpose :
//==================================================
SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Standard_Integer thePriority)
: mySelectable (NULL),
mypriority (thePriority),
myIsSelected (Standard_False),
myFromDecomposition (Standard_False)
//=================================================================================================
SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Standard_Integer thePriority)
: mySelectable(NULL),
mypriority(thePriority),
myIsSelected(Standard_False),
myFromDecomposition(Standard_False)
{
//
}
//==================================================
// Function: SelectMgr_EntityOwner
// Purpose :
//==================================================
SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_SelectableObject)& theSelObj,
const Standard_Integer thePriority)
: mySelectable (theSelObj.get()),
mypriority (thePriority),
myIsSelected (Standard_False),
myFromDecomposition (Standard_False)
//=================================================================================================
SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& theSelObj,
const Standard_Integer thePriority)
: mySelectable(theSelObj.get()),
mypriority(thePriority),
myIsSelected(Standard_False),
myFromDecomposition(Standard_False)
{
//
}
//==================================================
// Function: SelectMgr_EntityOwner
// Purpose :
//==================================================
SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
const Standard_Integer thePriority)
: mySelectable (theOwner->mySelectable),
mypriority (thePriority),
myIsSelected (Standard_False),
myFromDecomposition (Standard_False)
//=================================================================================================
SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Handle(SelectMgr_EntityOwner)& theOwner,
const Standard_Integer thePriority)
: mySelectable(theOwner->mySelectable),
mypriority(thePriority),
myIsSelected(Standard_False),
myFromDecomposition(Standard_False)
{
//
}
//=======================================================================
//function : HilightWithColor
//purpose :
//=======================================================================
void SelectMgr_EntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode)
//=================================================================================================
void SelectMgr_EntityOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode)
{
if (mySelectable == NULL)
{
@@ -74,12 +66,14 @@ void SelectMgr_EntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationMa
if (IsAutoHilight())
{
const Graphic3d_ZLayerId aHiLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : mySelectable->ZLayer();
thePM->Color (mySelectable, theStyle, theMode, NULL, aHiLayer);
const Graphic3d_ZLayerId aHiLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN
? theStyle->ZLayer()
: mySelectable->ZLayer();
thePM->Color(mySelectable, theStyle, theMode, NULL, aHiLayer);
}
else
{
mySelectable->HilightOwnerWithColor (thePM, theStyle, this);
mySelectable->HilightOwnerWithColor(thePM, theStyle, this);
}
}
@@ -87,41 +81,34 @@ void SelectMgr_EntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationMa
// function : Select
// purpose :
// =======================================================================
Standard_Boolean SelectMgr_EntityOwner::Select (const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theIsDetected) const
Standard_Boolean SelectMgr_EntityOwner::Select(const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theIsDetected) const
{
switch (theSelScheme)
{
case AIS_SelectionScheme_UNKNOWN:
{
case AIS_SelectionScheme_UNKNOWN: {
return myIsSelected;
}
case AIS_SelectionScheme_Replace:
{
case AIS_SelectionScheme_Replace: {
return theIsDetected;
}
case AIS_SelectionScheme_Add:
{
case AIS_SelectionScheme_Add: {
return !myIsSelected || theIsDetected || IsForcedHilight();
}
case AIS_SelectionScheme_Remove:
{
case AIS_SelectionScheme_Remove: {
return myIsSelected && !theIsDetected;
}
case AIS_SelectionScheme_XOR:
{
case AIS_SelectionScheme_XOR: {
if (theIsDetected)
{
return !myIsSelected && !IsForcedHilight();
}
return myIsSelected;
}
case AIS_SelectionScheme_Clear:
{
case AIS_SelectionScheme_Clear: {
return Standard_False;
}
case AIS_SelectionScheme_ReplaceExtra:
{
case AIS_SelectionScheme_ReplaceExtra: {
return theIsDetected;
}
}
@@ -132,14 +119,14 @@ Standard_Boolean SelectMgr_EntityOwner::Select (const AIS_SelectionScheme theSel
// function : DumpJson
// purpose :
// =======================================================================
void SelectMgr_EntityOwner::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
void SelectMgr_EntityOwner::DumpJson(Standard_OStream& theOStream, Standard_Integer) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, this)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, this)
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mySelectable)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mypriority)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsSelected)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFromDecomposition)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, mySelectable)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, mypriority)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myIsSelected)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myFromDecomposition)
}

View File

@@ -27,31 +27,34 @@ class V3d_Viewer;
//! A framework to define classes of owners of sensitive primitives.
//! The owner is the link between application and selection data structures.
//! For the application to make its own objects selectable, it must define owner classes inheriting this framework.
//! For the application to make its own objects selectable, it must define owner classes inheriting
//! this framework.
class SelectMgr_EntityOwner : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(SelectMgr_EntityOwner, Standard_Transient)
public:
//! Initializes the selection priority aPriority.
Standard_EXPORT SelectMgr_EntityOwner(const Standard_Integer aPriority = 0);
//! Constructs a framework with the selectable object
//! anSO being attributed the selection priority aPriority.
Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO, const Standard_Integer aPriority = 0);
Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO,
const Standard_Integer aPriority = 0);
//! Constructs a framework from existing one
//! anSO being attributed the selection priority aPriority.
Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aPriority = 0);
Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_EntityOwner)& theOwner,
const Standard_Integer aPriority = 0);
//! Return selection priority (within range [0-9]) for results with the same depth; 0 by default.
//! Example - selection of shapes:
//! the owners are selectable objects (presentations) a user can give vertex priority [3], edges [2] faces [1] shape [0],
//! so that if during selection one vertex one edge and one face are simultaneously detected, the vertex will only be hilighted.
//! the owners are selectable objects (presentations) a user can give vertex priority [3], edges
//! [2] faces [1] shape [0], so that if during selection one vertex one edge and one face are
//! simultaneously detected, the vertex will only be hilighted.
Standard_Integer Priority() const { return mypriority; }
//! Sets the selectable priority of the owner within range [0-9].
void SetPriority (Standard_Integer thePriority) { mypriority = thePriority; }
void SetPriority(Standard_Integer thePriority) { mypriority = thePriority; }
//! Returns true if there is a selectable object to serve as an owner.
Standard_Boolean HasSelectable() const { return mySelectable != NULL; }
@@ -60,7 +63,10 @@ public:
virtual Handle(SelectMgr_SelectableObject) Selectable() const { return mySelectable; }
//! Sets the selectable object.
virtual void SetSelectable (const Handle(SelectMgr_SelectableObject)& theSelObj) { mySelectable = theSelObj.get(); }
virtual void SetSelectable(const Handle(SelectMgr_SelectableObject)& theSelObj)
{
mySelectable = theSelObj.get();
}
//! Handle mouse button click event.
//! Does nothing by default and returns FALSE.
@@ -69,121 +75,124 @@ public:
//! @param theModifiers key modifiers
//! @param theIsDoubleClick flag indicating double mouse click
//! @return TRUE if object handled click
virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick)
virtual Standard_Boolean HandleMouseClick(const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick)
{
(void )thePoint; (void )theButton; (void )theModifiers; (void )theIsDoubleClick;
(void)thePoint;
(void)theButton;
(void)theModifiers;
(void)theIsDoubleClick;
return Standard_False;
}
//! Returns true if the presentation manager highlights selections corresponding to the selection mode.
virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode = 0) const
//! Returns true if the presentation manager highlights selections corresponding to the selection
//! mode.
virtual Standard_Boolean IsHilighted(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode = 0) const
{
return mySelectable != NULL
&& thePrsMgr->IsHighlighted (mySelectable, theMode);
return mySelectable != NULL && thePrsMgr->IsHighlighted(mySelectable, theMode);
}
//! Highlights selectable object's presentation with display mode in presentation manager with given highlight style.
//! Also a check for auto-highlight is performed - if selectable object manages highlighting on its own,
//! execution will be passed to SelectMgr_SelectableObject::HilightOwnerWithColor method.
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode = 0);
//! Removes highlighting from the owner of a detected selectable object in the presentation manager.
//! This object could be the owner of a sensitive primitive.
//! Highlights selectable object's presentation with display mode in presentation manager with
//! given highlight style. Also a check for auto-highlight is performed - if selectable object
//! manages highlighting on its own, execution will be passed to
//! SelectMgr_SelectableObject::HilightOwnerWithColor method.
Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode = 0);
//! Removes highlighting from the owner of a detected selectable object in the presentation
//! manager. This object could be the owner of a sensitive primitive.
//! @param thePrsMgr presentation manager
//! @param theMode obsolete argument for compatibility, should be ignored by implementations
virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode = 0)
virtual void Unhilight(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode = 0)
{
(void )theMode;
(void)theMode;
if (mySelectable != NULL)
{
thePrsMgr->Unhighlight (mySelectable);
thePrsMgr->Unhighlight(mySelectable);
}
}
//! Clears the owners matching the value of the selection
//! mode aMode from the presentation manager object aPM.
virtual void Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode = 0) /// TODO
virtual void Clear(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode = 0) /// TODO
{
(void )thePrsMgr;
(void )theMode;
(void)thePrsMgr;
(void)theMode;
}
//! Returns TRUE if selectable has transformation.
virtual Standard_Boolean HasLocation() const { return mySelectable != NULL && mySelectable->HasTransformation(); }
virtual Standard_Boolean HasLocation() const
{
return mySelectable != NULL && mySelectable->HasTransformation();
}
//! Returns transformation of selectable.
virtual TopLoc_Location Location() const
{
return mySelectable != NULL && mySelectable->HasTransformation()
? TopLoc_Location(mySelectable->Transformation())
: TopLoc_Location();
? TopLoc_Location(mySelectable->Transformation())
: TopLoc_Location();
}
//! Change owner location (callback for handling change of location of selectable object).
virtual void SetLocation (const TopLoc_Location& theLocation)
{
(void )theLocation;
}
virtual void SetLocation(const TopLoc_Location& theLocation) { (void)theLocation; }
//! @return Standard_True if the owner is selected.
Standard_Boolean IsSelected() const { return myIsSelected; }
//! Set the state of the owner.
//! @param[in] theIsSelected shows if owner is selected.
void SetSelected (const Standard_Boolean theIsSelected) { myIsSelected = theIsSelected; }
void SetSelected(const Standard_Boolean theIsSelected) { myIsSelected = theIsSelected; }
//! If the object needs to be selected, it returns true.
//! @param[in] theSelScheme selection scheme
//! @param[in] theIsDetected flag of object detection
Standard_EXPORT Standard_Boolean Select (const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theIsDetected) const;
Standard_EXPORT Standard_Boolean Select(const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theIsDetected) const;
//! Returns selection state.
Standard_DEPRECATED ("Deprecated method - IsSelected() should be used instead")
Standard_DEPRECATED("Deprecated method - IsSelected() should be used instead")
Standard_Integer State() const { return myIsSelected ? 1 : 0; }
//! Set the state of the owner.
//! The method is deprecated. Use SetSelected() instead.
void State (const Standard_Integer theStatus) { myIsSelected = (theStatus == 1); }
void State(const Standard_Integer theStatus) { myIsSelected = (theStatus == 1); }
//! if owner is not auto hilighted, for group contains many such owners will be called one method HilightSelected of SelectableObject
//! if owner is not auto hilighted, for group contains many such owners will be called one method
//! HilightSelected of SelectableObject
virtual Standard_Boolean IsAutoHilight() const
{
return mySelectable == NULL
|| mySelectable->IsAutoHilight();
return mySelectable == NULL || mySelectable->IsAutoHilight();
}
//! if this method returns TRUE the owner will always call method Hilight for SelectableObject when the owner is detected.
//! By default it always return FALSE.
//! if this method returns TRUE the owner will always call method Hilight for SelectableObject
//! when the owner is detected. By default it always return FALSE.
virtual Standard_Boolean IsForcedHilight() const { return Standard_False; }
//! Set Z layer ID and update all presentations.
virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId)
{
(void )theLayerId;
}
//! Implements immediate application of location transformation of parent object to dynamic highlight structure
virtual void UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer,
const Handle(PrsMgr_PresentationManager)& theManager,
const Standard_Integer theDispMode)
//! Set Z layer ID and update all presentations.
virtual void SetZLayer(const Graphic3d_ZLayerId theLayerId) { (void)theLayerId; }
//! Implements immediate application of location transformation of parent object to dynamic
//! highlight structure
virtual void UpdateHighlightTrsf(const Handle(V3d_Viewer)& theViewer,
const Handle(PrsMgr_PresentationManager)& theManager,
const Standard_Integer theDispMode)
{
if (mySelectable != NULL)
{
theManager->UpdateHighlightTrsf (theViewer, mySelectable, theDispMode);
theManager->UpdateHighlightTrsf(theViewer, mySelectable, theDispMode);
}
}
//! Returns true if pointer to selectable object of this owner is equal to the given one
Standard_Boolean IsSameSelectable (const Handle(SelectMgr_SelectableObject)& theOther) const
Standard_Boolean IsSameSelectable(const Handle(SelectMgr_SelectableObject)& theOther) const
{
return mySelectable == theOther.get();
}
@@ -192,30 +201,33 @@ public:
Standard_Boolean ComesFromDecomposition() const { return myFromDecomposition; }
//! Sets flag indicating this owner points to a part of object (TRUE) or to entire object (FALSE).
void SetComesFromDecomposition (const Standard_Boolean theIsFromDecomposition) { myFromDecomposition = theIsFromDecomposition; }
void SetComesFromDecomposition(const Standard_Boolean theIsFromDecomposition)
{
myFromDecomposition = theIsFromDecomposition;
}
//! 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;
public:
//! Sets the selectable object.
Standard_DEPRECATED ("Deprecated method - SetSelectable() should be used instead")
void Set (const Handle(SelectMgr_SelectableObject)& theSelObj) { SetSelectable (theSelObj); }
Standard_DEPRECATED("Deprecated method - SetSelectable() should be used instead")
void Set(const Handle(SelectMgr_SelectableObject)& theSelObj) { SetSelectable(theSelObj); }
//! sets the selectable priority of the owner
Standard_DEPRECATED ("Deprecated method - SetPriority() should be used instead")
void Set (const Standard_Integer thePriority) { SetPriority (thePriority); }
Standard_DEPRECATED("Deprecated method - SetPriority() should be used instead")
void Set(const Standard_Integer thePriority) { SetPriority(thePriority); }
protected:
SelectMgr_SelectableObject* mySelectable; //!< raw pointer to selectable object
// clang-format off
SelectMgr_SelectableObject* mySelectable; //!< raw pointer to selectable object
// clang-format off
Standard_Integer mypriority; //!< selection priority (for result with the same depth)
Standard_Boolean myIsSelected; //!< flag indicating selected state
Standard_Boolean myFromDecomposition; //!< flag indicating this owner points to a part of object (TRUE) or to entire object (FALSE)
// clang-format on
// clang-format on
};
DEFINE_STANDARD_HANDLE(SelectMgr_EntityOwner, Standard_Transient)

View File

@@ -14,12 +14,13 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Filter.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Filter,Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Filter, Standard_Transient)
Standard_Boolean SelectMgr_Filter::ActsOn(const TopAbs_ShapeEnum /*aStandardMode*/) const
{return Standard_False;}
Standard_Boolean SelectMgr_Filter::ActsOn(const TopAbs_ShapeEnum /*aStandardMode*/) const
{
return Standard_False;
}

View File

@@ -24,7 +24,6 @@
#include <TopAbs_ShapeEnum.hxx>
class SelectMgr_EntityOwner;
class SelectMgr_Filter;
DEFINE_STANDARD_HANDLE(SelectMgr_Filter, Standard_Transient)
@@ -41,8 +40,6 @@ class SelectMgr_Filter : public Standard_Transient
{
public:
//! Indicates that the selected Interactive Object
//! passes the filter. The owner, anObj, can be either
//! direct or user. A direct owner is the corresponding
@@ -57,35 +54,19 @@ public:
//! framework, and the daughter class is to be used in
//! an AIS local context, you will need to implement the
//! virtual function ActsOn.
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const = 0;
Standard_EXPORT virtual Standard_Boolean IsOk(
const Handle(SelectMgr_EntityOwner)& anObj) const = 0;
//! Returns true in an AIS local context, if this filter
//! operates on a type of subshape defined in a filter
//! class inheriting this framework.
//! This function completes IsOk in an AIS local context.
Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aStandardMode) const;
Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aStandardMode) const;
DEFINE_STANDARD_RTTIEXT(SelectMgr_Filter,Standard_Transient)
DEFINE_STANDARD_RTTIEXT(SelectMgr_Filter, Standard_Transient)
protected:
private:
};
#endif // _SelectMgr_Filter_HeaderFile

View File

@@ -18,9 +18,9 @@
#include <SelectMgr_BaseFrustum.hxx>
//! This is an internal class containing representation of rectangular selecting frustum, created in case
//! of point and box selection, and algorithms for overlap detection between selecting
//! frustum and sensitive entities. The principle of frustum calculation:
//! This is an internal class containing representation of rectangular selecting frustum, created in
//! case of point and box selection, and algorithms for overlap detection between selecting frustum
//! and sensitive entities. The principle of frustum calculation:
//! - for point selection: on a near view frustum plane rectangular neighborhood of
//! user-picked point is created according to the pixel tolerance
//! given and then this rectangle is projected onto far view frustum
@@ -49,117 +49,115 @@ template <int N>
class SelectMgr_Frustum : public SelectMgr_BaseFrustum
{
public:
SelectMgr_Frustum() : SelectMgr_BaseFrustum()
SelectMgr_Frustum()
: SelectMgr_BaseFrustum()
{
memset (myMaxOrthoVertsProjections, 0, sizeof (myMaxOrthoVertsProjections));
memset (myMinOrthoVertsProjections, 0, sizeof (myMinOrthoVertsProjections));
memset (myMaxVertsProjections, 0, sizeof (myMaxVertsProjections));
memset (myMinVertsProjections, 0, sizeof (myMinVertsProjections));
memset(myMaxOrthoVertsProjections, 0, sizeof(myMaxOrthoVertsProjections));
memset(myMinOrthoVertsProjections, 0, sizeof(myMinOrthoVertsProjections));
memset(myMaxVertsProjections, 0, sizeof(myMaxVertsProjections));
memset(myMinVertsProjections, 0, sizeof(myMinVertsProjections));
}
//! Dumps the content of me into the stream
inline virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
inline virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
// SAT Tests for different objects
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt
Standard_Boolean hasBoxOverlap (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside = NULL) const;
Standard_Boolean hasBoxOverlap(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside = NULL) const;
//! SAT intersection test between defined volume and given point
Standard_Boolean hasPointOverlap (const gp_Pnt& thePnt) const;
Standard_Boolean hasPointOverlap(const gp_Pnt& thePnt) const;
//! SAT intersection test between defined volume and given segment
Standard_Boolean hasSegmentOverlap (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2) const;
Standard_Boolean hasSegmentOverlap(const gp_Pnt& thePnt1, const gp_Pnt& thePnt2) const;
//! SAT intersection test between frustum given and planar convex polygon represented as ordered point set
Standard_Boolean hasPolygonOverlap (const TColgp_Array1OfPnt& theArrayOfPnts,
gp_Vec& theNormal) const;
//! SAT intersection test between frustum given and planar convex polygon represented as ordered
//! point set
Standard_Boolean hasPolygonOverlap(const TColgp_Array1OfPnt& theArrayOfPnts,
gp_Vec& theNormal) const;
//! SAT intersection test between defined volume and given triangle
Standard_Boolean hasTriangleOverlap (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
gp_Vec& theNormal) const;
Standard_Boolean hasTriangleOverlap(const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
gp_Vec& theNormal) const;
//! Intersection test between defined volume and given sphere
Standard_Boolean hasSphereOverlap (const gp_Pnt& thePnt1,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const;
Standard_Boolean hasSphereOverlap(const gp_Pnt& thePnt1,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const;
//! Intersection test between defined volume and given cylinder (or cone).
Standard_Boolean hasCylinderOverlap (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const;
Standard_Boolean hasCylinderOverlap(const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const;
//! Intersection test between defined volume and given circle.
Standard_Boolean hasCircleOverlap (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const;
Standard_Boolean hasCircleOverlap(const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const;
//! Returns True if all vertices (theVertices) are inside the top and bottom sides of the cylinder.
Standard_Boolean isInsideCylinderEndFace (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
//! Returns True if all vertices (theVertices) are inside the top and bottom sides of the
//! cylinder.
Standard_Boolean isInsideCylinderEndFace(const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
//! Checking whether the point thePnt is inside the shape with borders theVertices.
//! thePnt and theVertices lie in the same plane.
Standard_Boolean isDotInside (const gp_Pnt& thePnt,
const TColgp_Array1OfPnt& theVertices) const;
Standard_Boolean isDotInside(const gp_Pnt& thePnt, const TColgp_Array1OfPnt& theVertices) const;
private:
//! Return true if one segment enclosed between the points thePnt1Seg1 and thePnt2Seg1
//! intersects another segment that enclosed between thePnt1Seg2 and thePnt2Seg2.
Standard_Boolean isSegmentsIntersect (const gp_Pnt& thePnt1Seg1,
const gp_Pnt& thePnt2Seg1,
const gp_Pnt& thePnt1Seg2,
const gp_Pnt& thePnt2Seg2) const;
Standard_Boolean isSegmentsIntersect(const gp_Pnt& thePnt1Seg1,
const gp_Pnt& thePnt2Seg1,
const gp_Pnt& thePnt1Seg2,
const gp_Pnt& thePnt2Seg2) const;
//! Checking whether the borders theVertices of the shape intersect
//! the cylinder (or cone) end face with the center theCenter and radius theRadius
Standard_Boolean isIntersectCircle (const Standard_Real theRadius,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
Standard_Boolean isIntersectCircle(const Standard_Real theRadius,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
//! Checks if AABB and frustum are separated along the given axis
Standard_Boolean isSeparated (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
const gp_XYZ& theDirect,
Standard_Boolean* theInside) const;
Standard_Boolean isSeparated(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
const gp_XYZ& theDirect,
Standard_Boolean* theInside) const;
//! Checks if triangle and frustum are separated along the given axis
Standard_Boolean isSeparated (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
const gp_XYZ& theAxis) const;
Standard_Boolean isSeparated(const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
const gp_XYZ& theAxis) const;
protected:
gp_Vec myPlanes[N + 2]; //!< Plane equations
gp_Pnt myVertices[N * 2]; //!< Vertices coordinates
gp_Vec myPlanes[N + 2]; //!< Plane equations
gp_Pnt myVertices[N * 2]; //!< Vertices coordinates
// clang-format off
// clang-format off
Standard_Real myMaxVertsProjections[N + 2]; //!< Cached projections of vertices onto frustum plane directions
Standard_Real myMinVertsProjections[N + 2]; //!< Cached projections of vertices onto frustum plane directions
Standard_Real myMaxOrthoVertsProjections[3]; //!< Cached projections of vertices onto directions of ortho unit vectors
Standard_Real myMinOrthoVertsProjections[3]; //!< Cached projections of vertices onto directions of ortho unit vectors
// clang-format on
// clang-format on
gp_Vec myEdgeDirs[6]; //!< Cached edge directions
gp_Vec myEdgeDirs[6]; //!< Cached edge directions
};
#include <SelectMgr_Frustum.lxx>

File diff suppressed because it is too large Load Diff

View File

@@ -15,29 +15,26 @@
#include <SelectMgr_FrustumBuilder.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_FrustumBuilder,Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_FrustumBuilder, Standard_Transient)
#define DOT(A, B) (A.x() * B.x() + A.y() * B.y() + A.z() * B.z())
#define LENGTH(A) (std::sqrt (A.x() * A.x() + A.y() * A.y() + A.z() * A.z()))
#define LENGTH(A) (std::sqrt(A.x() * A.x() + A.y() * A.y() + A.z() * A.z()))
//=======================================================================
// function : SelectMgr_FrustumBuilder
// purpose : Creates new frustum builder with empty matrices
//=======================================================================
SelectMgr_FrustumBuilder::SelectMgr_FrustumBuilder()
: myWidth (INT_MAX),
myHeight (INT_MAX),
myIsViewportSet (Standard_False)
: myWidth(INT_MAX),
myHeight(INT_MAX),
myIsViewportSet(Standard_False)
{
//
}
//=======================================================================
// function : SetCamera
// purpose :
//=======================================================================
void SelectMgr_FrustumBuilder::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
//=================================================================================================
void SelectMgr_FrustumBuilder::SetCamera(const Handle(Graphic3d_Camera)& theCamera)
{
myCamera = theCamera;
}
@@ -46,10 +43,10 @@ void SelectMgr_FrustumBuilder::SetCamera (const Handle(Graphic3d_Camera)& theCam
// function : SetWindowSize
// purpose : Stores current window width and height
//=======================================================================
void SelectMgr_FrustumBuilder::SetWindowSize (const Standard_Integer theWidth,
const Standard_Integer theHeight)
void SelectMgr_FrustumBuilder::SetWindowSize(const Standard_Integer theWidth,
const Standard_Integer theHeight)
{
myWidth = theWidth;
myWidth = theWidth;
myHeight = theHeight;
}
@@ -57,30 +54,26 @@ void SelectMgr_FrustumBuilder::SetWindowSize (const Standard_Integer theWidth,
// function : SetViewport
// purpose : Stores current viewport coordinates
//=======================================================================
void SelectMgr_FrustumBuilder::SetViewport (const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight)
void SelectMgr_FrustumBuilder::SetViewport(const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight)
{
myViewport = NCollection_Vec4<Standard_Real> (theX, theY, theWidth, theHeight);
myViewport = NCollection_Vec4<Standard_Real>(theX, theY, theWidth, theHeight);
myIsViewportSet = Standard_True;
}
//=======================================================================
// function : WindowSize
// purpose :
//=======================================================================
void SelectMgr_FrustumBuilder::WindowSize (Standard_Integer& theWidth,
Standard_Integer& theHeight) const
//=================================================================================================
void SelectMgr_FrustumBuilder::WindowSize(Standard_Integer& theWidth,
Standard_Integer& theHeight) const
{
theWidth = myWidth;
theWidth = myWidth;
theHeight = myHeight;
}
//=======================================================================
// function : InvalidateViewport
// purpose :
//=======================================================================
//=================================================================================================
void SelectMgr_FrustumBuilder::InvalidateViewport()
{
myIsViewportSet = Standard_False;
@@ -91,11 +84,12 @@ void SelectMgr_FrustumBuilder::InvalidateViewport()
// purpose : Calculates signed distance between plane with equation
// theEq and point thePnt
//=======================================================================
Standard_Real SelectMgr_FrustumBuilder::SignedPlanePntDist (const SelectMgr_Vec3& theEq,
const SelectMgr_Vec3& thePnt) const
Standard_Real SelectMgr_FrustumBuilder::SignedPlanePntDist(const SelectMgr_Vec3& theEq,
const SelectMgr_Vec3& thePnt) const
{
const Standard_Real aNormLength = LENGTH (theEq);
const Standard_Real anInvNormLength = aNormLength < Precision::Confusion() ? 0.0 : 1.0 / aNormLength;
const Standard_Real aNormLength = LENGTH(theEq);
const Standard_Real anInvNormLength =
aNormLength < Precision::Confusion() ? 0.0 : 1.0 / aNormLength;
const Standard_Real anA = theEq.x() * anInvNormLength;
const Standard_Real aB = theEq.y() * anInvNormLength;
const Standard_Real aC = theEq.z() * anInvNormLength;
@@ -108,9 +102,9 @@ Standard_Real SelectMgr_FrustumBuilder::SignedPlanePntDist (const SelectMgr_Vec3
// theZ = 0 - near plane,
// theZ = 1 - far plane
// =======================================================================
gp_Pnt SelectMgr_FrustumBuilder::ProjectPntOnViewPlane (const Standard_Real& theX,
const Standard_Real& theY,
const Standard_Real& theZ) const
gp_Pnt SelectMgr_FrustumBuilder::ProjectPntOnViewPlane(const Standard_Real& theX,
const Standard_Real& theY,
const Standard_Real& theZ) const
{
if (myCamera.IsNull())
{
@@ -120,15 +114,17 @@ gp_Pnt SelectMgr_FrustumBuilder::ProjectPntOnViewPlane (const Standard_Real& the
gp_Pnt anXYZ;
if (!myIsViewportSet)
{
anXYZ.SetCoord (2.0 * theX / myWidth - 1.0,
(myHeight - 1 - theY) / myHeight * 2.0 - 1.0,
myCamera->IsZeroToOneDepth() ? theZ : (2.0 * theZ - 1.0));
anXYZ.SetCoord(2.0 * theX / myWidth - 1.0,
(myHeight - 1 - theY) / myHeight * 2.0 - 1.0,
myCamera->IsZeroToOneDepth() ? theZ : (2.0 * theZ - 1.0));
}
else
{
anXYZ.SetCoord (2.0 * (theX - myWidth * myViewport.x()) / (myWidth * (myViewport.z() - myViewport.x())) - 1.0,
2.0 * (theY - myHeight * myViewport.y()) / (myHeight * (myViewport.w() - myViewport.y())) - 1.0,
theZ);
anXYZ.SetCoord(
2.0 * (theX - myWidth * myViewport.x()) / (myWidth * (myViewport.z() - myViewport.x())) - 1.0,
2.0 * (theY - myHeight * myViewport.y()) / (myHeight * (myViewport.w() - myViewport.y()))
- 1.0,
theZ);
}
return myCamera->UnProject (anXYZ);
return myCamera->UnProject(anXYZ);
}

View File

@@ -33,44 +33,42 @@ public:
const Handle(Graphic3d_Camera)& Camera() const { return myCamera; }
//! Stores current camera
Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
Standard_EXPORT void SetCamera(const Handle(Graphic3d_Camera)& theCamera);
//! Stores current window width and height
Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth,
const Standard_Integer theHeight);
Standard_EXPORT void SetWindowSize(const Standard_Integer theWidth,
const Standard_Integer theHeight);
//! Stores current viewport coordinates
Standard_EXPORT void SetViewport (const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight);
Standard_EXPORT void SetViewport(const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight);
Standard_EXPORT void InvalidateViewport();
Standard_EXPORT void WindowSize (Standard_Integer& theWidth,
Standard_Integer& theHeight) const;
Standard_EXPORT void WindowSize(Standard_Integer& theWidth, Standard_Integer& theHeight) const;
//! Calculates signed distance between plane with equation
//! theEq and point thePnt
Standard_EXPORT Standard_Real SignedPlanePntDist (const SelectMgr_Vec3& theEq,
const SelectMgr_Vec3& thePnt) const;
Standard_EXPORT Standard_Real SignedPlanePntDist(const SelectMgr_Vec3& theEq,
const SelectMgr_Vec3& thePnt) const;
//! Projects 2d screen point onto view frustum plane:
//! theZ = 0 - near plane,
//! theZ = 1 - far plane
Standard_EXPORT gp_Pnt ProjectPntOnViewPlane (const Standard_Real& theX,
const Standard_Real& theY,
const Standard_Real& theZ) const;
Standard_EXPORT gp_Pnt ProjectPntOnViewPlane(const Standard_Real& theX,
const Standard_Real& theY,
const Standard_Real& theZ) const;
DEFINE_STANDARD_RTTIEXT(SelectMgr_FrustumBuilder,Standard_Transient)
DEFINE_STANDARD_RTTIEXT(SelectMgr_FrustumBuilder, Standard_Transient)
private:
Handle(Graphic3d_Camera) myCamera;
Standard_Integer myWidth;
Standard_Integer myHeight;
NCollection_Vec4<Standard_Real> myViewport;
Standard_Boolean myIsViewportSet;
Handle(Graphic3d_Camera) myCamera;
Standard_Integer myWidth;
Standard_Integer myHeight;
NCollection_Vec4<Standard_Real> myViewport;
Standard_Boolean myIsViewportSet;
};
DEFINE_STANDARD_HANDLE(SelectMgr_FrustumBuilder, Standard_Transient)

View File

@@ -21,6 +21,7 @@
#include <SelectMgr_SortCriterion.hxx>
#include <NCollection_IndexedDataMap.hxx>
typedef NCollection_IndexedDataMap<Handle(SelectMgr_EntityOwner), SelectMgr_SortCriterion> SelectMgr_IndexedDataMapOfOwnerCriterion;
typedef NCollection_IndexedDataMap<Handle(SelectMgr_EntityOwner), SelectMgr_SortCriterion>
SelectMgr_IndexedDataMapOfOwnerCriterion;
#endif

View File

@@ -21,6 +21,7 @@
class SelectMgr_EntityOwner;
typedef NCollection_Shared< NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)> > SelectMgr_IndexedMapOfOwner;
typedef NCollection_Shared<NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)>>
SelectMgr_IndexedMapOfOwner;
#endif // _SelectMgr_IndexedMapOfOwner_HeaderFile

View File

@@ -11,7 +11,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef SelectMgr_ListIteratorOfListOfFilter_HeaderFile
#define SelectMgr_ListIteratorOfListOfFilter_HeaderFile

View File

@@ -20,8 +20,7 @@
#include <SelectMgr_Filter.hxx>
#include <NCollection_List.hxx>
typedef NCollection_List<Handle(SelectMgr_Filter)> SelectMgr_ListOfFilter;
typedef NCollection_List<Handle(SelectMgr_Filter)> SelectMgr_ListOfFilter;
typedef NCollection_List<Handle(SelectMgr_Filter)>::Iterator SelectMgr_ListIteratorOfListOfFilter;
#endif

View File

@@ -12,35 +12,29 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_OrFilter.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_OrFilter,SelectMgr_CompositionFilter)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_OrFilter, SelectMgr_CompositionFilter)
//=============================================================================
//function : SelectMgr_OrFilter
//purpose :
//=============================================================================
SelectMgr_OrFilter::SelectMgr_OrFilter()
{
}
//=================================================================================================
//=============================================================================
//function : IsOk
//purpose :
//=============================================================================
Standard_Boolean SelectMgr_OrFilter::IsOk (const Handle(SelectMgr_EntityOwner)& theObj) const
SelectMgr_OrFilter::SelectMgr_OrFilter() {}
//=================================================================================================
Standard_Boolean SelectMgr_OrFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theObj) const
{
if (myFilters.IsEmpty())
{
return Standard_True;
}
for (SelectMgr_ListIteratorOfListOfFilter aFilterIter (myFilters); aFilterIter.More(); aFilterIter.Next())
for (SelectMgr_ListIteratorOfListOfFilter aFilterIter(myFilters); aFilterIter.More();
aFilterIter.Next())
{
if (aFilterIter.Value()->IsOk (theObj))
if (aFilterIter.Value()->IsOk(theObj))
{
return Standard_True;
}

View File

@@ -23,7 +23,6 @@
#include <SelectMgr_CompositionFilter.hxx>
class SelectMgr_EntityOwner;
class SelectMgr_OrFilter;
DEFINE_STANDARD_HANDLE(SelectMgr_OrFilter, SelectMgr_CompositionFilter)
@@ -33,23 +32,15 @@ class SelectMgr_OrFilter : public SelectMgr_CompositionFilter
{
public:
//! Constructs an empty or selection filter.
Standard_EXPORT SelectMgr_OrFilter();
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(SelectMgr_OrFilter,SelectMgr_CompositionFilter)
Standard_EXPORT Standard_Boolean
IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(SelectMgr_OrFilter, SelectMgr_CompositionFilter)
protected:
};
#endif // _SelectMgr_OrFilter_HeaderFile

View File

@@ -14,11 +14,14 @@
#ifndef _SelectMgr_PickingStrategy_HeaderFile
#define _SelectMgr_PickingStrategy_HeaderFile
//! Enumeration defines picking strategy - which entities detected by picking line will be accepted, considering selection filters.
//! Enumeration defines picking strategy - which entities detected by picking line will be accepted,
//! considering selection filters.
enum SelectMgr_PickingStrategy
{
SelectMgr_PickingStrategy_FirstAcceptable, //!< the first detected entity passing selection filter is accepted (e.g. any)
SelectMgr_PickingStrategy_OnlyTopmost //!< only topmost detected entity passing selection filter is accepted
SelectMgr_PickingStrategy_FirstAcceptable, //!< the first detected entity passing selection filter
//!< is accepted (e.g. any)
SelectMgr_PickingStrategy_OnlyTopmost //!< only topmost detected entity passing selection filter
//!< is accepted
};
#endif // _SelectMgr_PickingStrategy_HeaderFile

File diff suppressed because it is too large Load Diff

View File

@@ -32,26 +32,33 @@
class SelectMgr_RectangularFrustum : public SelectMgr_Frustum<4>
{
public:
//! Auxiliary structure to define selection primitive (point or box)
//! In case of point selection min and max points are identical.
struct SelectionRectangle
{
SelectionRectangle()
: myMinPnt(gp_Pnt2d(RealLast(), RealLast())),
myMaxPnt(gp_Pnt2d(RealLast(), RealLast())) {}
: myMinPnt(gp_Pnt2d(RealLast(), RealLast())),
myMaxPnt(gp_Pnt2d(RealLast(), RealLast()))
{
}
const gp_Pnt2d& MousePos() const { return myMinPnt; }
void SetMousePos (const gp_Pnt2d& thePos) { myMinPnt = thePos; myMaxPnt = thePos; }
void SetMousePos(const gp_Pnt2d& thePos)
{
myMinPnt = thePos;
myMaxPnt = thePos;
}
const gp_Pnt2d& MinPnt() const { return myMinPnt; }
void SetMinPnt (const gp_Pnt2d& theMinPnt) { myMinPnt = theMinPnt; }
void SetMinPnt(const gp_Pnt2d& theMinPnt) { myMinPnt = theMinPnt; }
const gp_Pnt2d& MaxPnt() const { return myMaxPnt; }
void SetMaxPnt (const gp_Pnt2d& theMaxPnt) { myMaxPnt = theMaxPnt; }
void SetMaxPnt(const gp_Pnt2d& theMaxPnt) { myMaxPnt = theMaxPnt; }
private:
gp_Pnt2d myMinPnt;
gp_Pnt2d myMaxPnt;
};
@@ -60,23 +67,22 @@ public:
Standard_EXPORT SelectMgr_RectangularFrustum();
//! Initializes volume according to the point and given pixel tolerance
Standard_EXPORT void Init (const gp_Pnt2d& thePoint);
Standard_EXPORT void Init(const gp_Pnt2d& thePoint);
//! Initializes volume according to the selected rectangle
Standard_EXPORT void Init (const gp_Pnt2d& theMinPnt,
const gp_Pnt2d& theMaxPnt);
Standard_EXPORT void Init(const gp_Pnt2d& theMinPnt, const gp_Pnt2d& theMaxPnt);
//! Returns True if Frustum (theVertices) intersects the circle.
Standard_EXPORT Standard_Boolean isIntersectCircle (const Standard_Real theRadius,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
Standard_EXPORT Standard_Boolean isIntersectCircle(const Standard_Real theRadius,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
//! Returns True if Seg1 (thePnt1Seg1, thePnt2Seg1) and Seg2 (thePnt1Seg2, thePnt2Seg2) intersect.
Standard_EXPORT Standard_Boolean isSegmentsIntersect (const gp_Pnt& thePnt1Seg1,
const gp_Pnt& thePnt2Seg1,
const gp_Pnt& thePnt1Seg2,
const gp_Pnt& thePnt2Seg2) const;
Standard_EXPORT Standard_Boolean isSegmentsIntersect(const gp_Pnt& thePnt1Seg1,
const gp_Pnt& thePnt2Seg1,
const gp_Pnt& thePnt1Seg2,
const gp_Pnt& thePnt2Seg2) const;
//! Builds volume according to internal parameters.
//! NOTE: it should be called after Init() method
@@ -93,121 +99,140 @@ public:
//! There are no default parameters, but in case if:
//! - transformation only is needed: @theScaleFactor must be initialized as any negative value;
//! - scale only is needed: @theTrsf must be set to gp_Identity.
//! Builder is an optional argument that represents corresponding settings for re-constructing transformed
//! frustum from scratch. Can be null if reconstruction is not expected furthermore.
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
//! Builder is an optional argument that represents corresponding settings for re-constructing
//! transformed frustum from scratch. Can be null if reconstruction is not expected furthermore.
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform(
const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
//! Returns a copy of the frustum using the given frustum builder configuration.
//! Returned frustum should be re-constructed before being used.
//! @param[in] theBuilder argument that represents corresponding settings for re-constructing transformed frustum from scratch;
//! @param[in] theBuilder argument that represents corresponding settings for re-constructing
//! transformed frustum from scratch;
//! should NOT be NULL.
//! @return a copy of the frustum with the input builder assigned
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder(
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
// SAT Tests for different objects
//! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside) const
Standard_OVERRIDE;
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint(
const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint(const gp_Pnt& thePnt) const
Standard_OVERRIDE;
//! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon(
const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSegment(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! SAT intersection test between defined volume and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices
//! depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined volume and given sphere
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined volume and given sphere
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside) const
Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(
const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked
//! screen point and given point theCOG.
//! It makes sense only for frustums built on a single point.
Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Real DistToGeometryCenter(const gp_Pnt& theCOG) const
Standard_OVERRIDE;
//! Calculates the point on a view ray that was detected during the run of selection algo by given depth
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
//! Calculates the point on a view ray that was detected during the run of selection algo by given
//! depth
Standard_EXPORT virtual gp_Pnt DetectedPoint(const Standard_Real theDepth) const
Standard_OVERRIDE;
//! A set of helper functions that return rectangular selecting frustum data
const gp_Pnt* GetVertices() const { return myVertices; }
@@ -230,41 +255,46 @@ public:
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
Standard_EXPORT virtual void GetPlanes(
NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) 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:
Standard_EXPORT void segmentSegmentDistance(const gp_Pnt& theSegPnt1,
const gp_Pnt& theSegPnt2,
SelectBasics_PickResult& thePickResult) const;
Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1,
const gp_Pnt& theSegPnt2,
SelectBasics_PickResult& thePickResult) const;
Standard_EXPORT bool segmentPlaneIntersection (const gp_Vec& thePlane,
const gp_Pnt& thePntOnPlane,
SelectBasics_PickResult& thePickResult) const;
Standard_EXPORT bool segmentPlaneIntersection(const gp_Vec& thePlane,
const gp_Pnt& thePntOnPlane,
SelectBasics_PickResult& thePickResult) const;
private:
void cacheVertexProjections (SelectMgr_RectangularFrustum* theFrustum) const;
void cacheVertexProjections(SelectMgr_RectangularFrustum* theFrustum) const;
private:
enum { LeftTopNear, LeftTopFar,
LeftBottomNear, LeftBottomFar,
RightTopNear, RightTopFar,
RightBottomNear, RightBottomFar };
enum
{
LeftTopNear,
LeftTopFar,
LeftBottomNear,
LeftBottomFar,
RightTopNear,
RightTopFar,
RightBottomNear,
RightBottomFar
};
private:
// clang-format off
// clang-format off
SelectionRectangle mySelRectangle; //!< parameters for selection by point or box (it is used to build frustum)
gp_Pnt myNearPickedPnt; //!< 3d projection of user-picked selection point onto near view plane
gp_Pnt myFarPickedPnt; //!< 3d projection of user-picked selection point onto far view plane
gp_Dir myViewRayDir; //!< view ray direction
Standard_Real myScale; //!< Scale factor of applied transformation, if there was any
// clang-format on
// clang-format on
};
#endif // _SelectMgr_RectangularFrustum_HeaderFile

View File

@@ -26,23 +26,21 @@
#include <Standard_NotImplemented.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectableObject,PrsMgr_PresentableObject)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectableObject, PrsMgr_PresentableObject)
namespace
{
static const Handle(SelectMgr_Selection) THE_NULL_SELECTION;
static const Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER;
}
static const Handle(SelectMgr_Selection) THE_NULL_SELECTION;
static const Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER;
} // namespace
//==================================================
// Function: SelectMgr_SelectableObject
// Purpose :
//==================================================
//=================================================================================================
SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: PrsMgr_PresentableObject (aTypeOfPresentation3d),
myGlobalSelMode (0),
myAutoHilight (Standard_True)
SelectMgr_SelectableObject::SelectMgr_SelectableObject(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: PrsMgr_PresentableObject(aTypeOfPresentation3d),
myGlobalSelMode(0),
myAutoHilight(Standard_True)
{
//
}
@@ -53,7 +51,8 @@ SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPrese
//==================================================
SelectMgr_SelectableObject::~SelectMgr_SelectableObject()
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
aSelIter.Value()->Clear();
}
@@ -71,9 +70,10 @@ SelectMgr_SelectableObject::~SelectMgr_SelectableObject()
//==================================================
void SelectMgr_SelectableObject::RecomputePrimitives()
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
RecomputePrimitives (aSelIter.Value()->Mode());
RecomputePrimitives(aSelIter.Value()->Mode());
}
}
@@ -87,78 +87,76 @@ void SelectMgr_SelectableObject::RecomputePrimitives()
// TO UPDATE SELECTION properly from outside classes,
// use method UpdateSelection.
//==================================================
void SelectMgr_SelectableObject::RecomputePrimitives (const Standard_Integer theMode)
void SelectMgr_SelectableObject::RecomputePrimitives(const Standard_Integer theMode)
{
SelectMgr_SelectableObject* aSelParent = dynamic_cast<SelectMgr_SelectableObject* > (Parent());
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
SelectMgr_SelectableObject* aSelParent = dynamic_cast<SelectMgr_SelectableObject*>(Parent());
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
if (aSel->Mode() == theMode)
{
aSel->Clear();
ComputeSelection (aSel, theMode);
aSel->UpdateStatus (SelectMgr_TOU_Partial);
aSel->UpdateBVHStatus (SelectMgr_TBU_Renew);
ComputeSelection(aSel, theMode);
aSel->UpdateStatus(SelectMgr_TOU_Partial);
aSel->UpdateBVHStatus(SelectMgr_TBU_Renew);
if (theMode == 0 && aSelParent != NULL)
{
if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner())
{
SetAssemblyOwner (anAsmOwner, theMode);
SetAssemblyOwner(anAsmOwner, theMode);
}
}
return;
}
}
Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode);
ComputeSelection (aNewSel, theMode);
Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection(theMode);
ComputeSelection(aNewSel, theMode);
if (theMode == 0 && aSelParent != NULL)
{
if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner())
{
SetAssemblyOwner (anAsmOwner, theMode);
SetAssemblyOwner(anAsmOwner, theMode);
}
}
aNewSel->UpdateStatus (SelectMgr_TOU_Partial);
aNewSel->UpdateBVHStatus (SelectMgr_TBU_Add);
aNewSel->UpdateStatus(SelectMgr_TOU_Partial);
aNewSel->UpdateBVHStatus(SelectMgr_TBU_Add);
myselections.Append (aNewSel);
myselections.Append(aNewSel);
}
//==================================================
// Function: ClearSelections
// Purpose :
//==================================================
void SelectMgr_SelectableObject::ClearSelections (const Standard_Boolean theToUpdate)
//=================================================================================================
void SelectMgr_SelectableObject::ClearSelections(const Standard_Boolean theToUpdate)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
aSel->Clear();
aSel->UpdateBVHStatus (SelectMgr_TBU_Remove);
aSel->UpdateBVHStatus(SelectMgr_TBU_Remove);
if (theToUpdate)
{
aSel->UpdateStatus (SelectMgr_TOU_Full);
aSel->UpdateStatus(SelectMgr_TOU_Full);
}
}
}
//=================================================================================================
//==================================================
// Function: Selection
// Purpose :
//==================================================
const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject::Selection (const Standard_Integer theMode) const
const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject::Selection(
const Standard_Integer theMode) const
{
if (theMode == -1)
{
return THE_NULL_SELECTION;
}
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
if (aSel->Mode() == theMode)
@@ -169,189 +167,175 @@ const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject::Selection (const
return THE_NULL_SELECTION;
}
//==================================================
// Function: AddSelection
// Purpose :
//==================================================
//=================================================================================================
void SelectMgr_SelectableObject::AddSelection (const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode)
void SelectMgr_SelectableObject::AddSelection(const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode)
{
if(theSel->IsEmpty())
if (theSel->IsEmpty())
{
ComputeSelection(theSel, theMode);
theSel->UpdateStatus(SelectMgr_TOU_Partial);
theSel->UpdateBVHStatus (SelectMgr_TBU_Add);
theSel->UpdateBVHStatus(SelectMgr_TBU_Add);
}
Standard_Boolean isReplaced = Standard_False;
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
if (aSelIter.Value()->Mode() == theMode)
{
isReplaced = Standard_True;
myselections.Remove (aSelIter);
myselections.Remove(aSelIter);
break;
}
}
myselections.Append (theSel);
myselections.Append(theSel);
if (isReplaced)
{
myselections.Last()->UpdateBVHStatus (SelectMgr_TBU_Renew);
myselections.Last()->UpdateBVHStatus(SelectMgr_TBU_Renew);
}
if (theMode == 0)
{
SelectMgr_SelectableObject* aSelParent = dynamic_cast<SelectMgr_SelectableObject* > (Parent());
SelectMgr_SelectableObject* aSelParent = dynamic_cast<SelectMgr_SelectableObject*>(Parent());
if (aSelParent != NULL)
{
if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner())
{
SetAssemblyOwner (anAsmOwner, theMode);
SetAssemblyOwner(anAsmOwner, theMode);
}
}
}
}
//=======================================================================
//function : ReSetTransformation
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::ResetTransformation()
//=================================================================================================
void SelectMgr_SelectableObject::ResetTransformation()
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
aSel->UpdateStatus (SelectMgr_TOU_Partial);
aSel->UpdateBVHStatus (SelectMgr_TBU_None);
aSel->UpdateStatus(SelectMgr_TOU_Partial);
aSel->UpdateBVHStatus(SelectMgr_TBU_None);
}
PrsMgr_PresentableObject::ResetTransformation();
}
//=======================================================================
//function : UpdateTransformation
//purpose :
//=======================================================================
//=================================================================================================
void SelectMgr_SelectableObject::UpdateTransformation()
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
aSelIter.Value()->UpdateStatus (SelectMgr_TOU_Partial);
aSelIter.Value()->UpdateStatus(SelectMgr_TOU_Partial);
}
PrsMgr_PresentableObject::UpdateTransformation();
if (!mySelectionPrs.IsNull())
{
mySelectionPrs->SetTransformation (TransformationGeom());
mySelectionPrs->SetTransformation(TransformationGeom());
}
if (!myHilightPrs.IsNull())
{
myHilightPrs->SetTransformation (TransformationGeom());
myHilightPrs->SetTransformation(TransformationGeom());
}
}
//=======================================================================
//function : UpdateTransformation
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::UpdateTransformations (const Handle(SelectMgr_Selection)& theSel)
//=================================================================================================
void SelectMgr_SelectableObject::UpdateTransformations(const Handle(SelectMgr_Selection)& theSel)
{
const TopLoc_Location aSelfLocation (Transformation());
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
const TopLoc_Location aSelfLocation(Transformation());
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
theSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
if (const Handle(Select3D_SensitiveEntity)& aSensEntity = aSelEntIter.Value()->BaseSensitive())
{
if (const Handle(SelectMgr_EntityOwner)& aEOwner = aSensEntity->OwnerId())
{
aEOwner->SetLocation (aSelfLocation);
aEOwner->SetLocation(aSelfLocation);
}
}
}
}
//=======================================================================
//function : HilightSelected
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::HilightSelected (const Handle(PrsMgr_PresentationManager)&,
const SelectMgr_SequenceOfOwner&)
//=================================================================================================
void SelectMgr_SelectableObject::HilightSelected(const Handle(PrsMgr_PresentationManager)&,
const SelectMgr_SequenceOfOwner&)
{
throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightSelected");
}
//=======================================================================
//function : ClearSelected
//purpose :
//=======================================================================
//=================================================================================================
void SelectMgr_SelectableObject::ClearSelected()
{
if(!mySelectionPrs.IsNull())
if (!mySelectionPrs.IsNull())
{
mySelectionPrs->Clear();
}
}
//=======================================================================
//function : ClearDynamicHighlight
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager)& theMgr)
//=================================================================================================
void SelectMgr_SelectableObject::ClearDynamicHighlight(
const Handle(PrsMgr_PresentationManager)& theMgr)
{
theMgr->ClearImmediateDraw();
}
//=======================================================================
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Drawer)&,
const Handle(SelectMgr_EntityOwner)&)
//=================================================================================================
void SelectMgr_SelectableObject::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Drawer)&,
const Handle(SelectMgr_EntityOwner)&)
{
throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightOwnerWithColor");
}
//=======================================================================
//function : GetHilightPresentation
//purpose :
//=======================================================================
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager)& theMgr)
//=================================================================================================
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation(
const Handle(PrsMgr_PresentationManager)& theMgr)
{
if (myHilightPrs.IsNull() && !theMgr.IsNull())
{
myHilightPrs = new Prs3d_Presentation (theMgr->StructureManager());
myHilightPrs->SetTransformPersistence (TransformPersistence());
myHilightPrs->SetClipPlanes (myClipPlanes);
myHilightPrs->SetTransformation (TransformationGeom());
myHilightPrs = new Prs3d_Presentation(theMgr->StructureManager());
myHilightPrs->SetTransformPersistence(TransformPersistence());
myHilightPrs->SetClipPlanes(myClipPlanes);
myHilightPrs->SetTransformation(TransformationGeom());
}
return myHilightPrs;
}
//=======================================================================
//function : GetSelectPresentation
//purpose :
//=======================================================================
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (const Handle(PrsMgr_PresentationManager)& theMgr)
//=================================================================================================
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation(
const Handle(PrsMgr_PresentationManager)& theMgr)
{
if (mySelectionPrs.IsNull() && !theMgr.IsNull())
{
mySelectionPrs = new Prs3d_Presentation (theMgr->StructureManager());
mySelectionPrs->SetTransformPersistence (TransformPersistence());
mySelectionPrs->SetClipPlanes (myClipPlanes);
mySelectionPrs->SetTransformation (TransformationGeom());
mySelectionPrs = new Prs3d_Presentation(theMgr->StructureManager());
mySelectionPrs->SetTransformPersistence(TransformPersistence());
mySelectionPrs->SetClipPlanes(myClipPlanes);
mySelectionPrs->SetTransformation(TransformationGeom());
}
return mySelectionPrs;
}
//=======================================================================
//function : ErasePresentations
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::ErasePresentations (Standard_Boolean theToRemove)
//=================================================================================================
void SelectMgr_SelectableObject::ErasePresentations(Standard_Boolean theToRemove)
{
if (!mySelectionPrs.IsNull())
{
@@ -373,143 +357,161 @@ void SelectMgr_SelectableObject::ErasePresentations (Standard_Boolean theToRemov
}
}
//=======================================================================
//function : SetZLayer
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId)
//=================================================================================================
void SelectMgr_SelectableObject::SetZLayer(const Graphic3d_ZLayerId theLayerId)
{
// update own presentations
PrsMgr_PresentableObject::SetZLayer (theLayerId);
PrsMgr_PresentableObject::SetZLayer(theLayerId);
// update selection presentations
if (!mySelectionPrs.IsNull())
mySelectionPrs->SetZLayer (theLayerId);
mySelectionPrs->SetZLayer(theLayerId);
if (!myHilightPrs.IsNull())
myHilightPrs->SetZLayer (theLayerId);
myHilightPrs->SetZLayer(theLayerId);
// update all entity owner presentations
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
if (const Handle(Select3D_SensitiveEntity)& aEntity = aSelEntIter.Value()->BaseSensitive())
{
if (const Handle(SelectMgr_EntityOwner)& aOwner = aEntity->OwnerId())
{
aOwner->SetZLayer (theLayerId);
aOwner->SetZLayer(theLayerId);
}
}
}
}
}
//=======================================================================
//function : UpdateClipping
//purpose :
//=======================================================================
//=================================================================================================
void SelectMgr_SelectableObject::UpdateClipping()
{
PrsMgr_PresentableObject::UpdateClipping();
if (!mySelectionPrs.IsNull())
{
mySelectionPrs->SetClipPlanes (myClipPlanes);
mySelectionPrs->SetClipPlanes(myClipPlanes);
}
if (!myHilightPrs.IsNull())
{
myHilightPrs->SetClipPlanes (myClipPlanes);
myHilightPrs->SetClipPlanes(myClipPlanes);
}
}
//=======================================================================
//function : updateSelection
//purpose : Sets update status FULL to selections of the object. Must be
// function : updateSelection
// purpose : Sets update status FULL to selections of the object. Must be
// used as the only method of UpdateSelection from outer classes
// to prevent BVH structures from being outdated.
//=======================================================================
void SelectMgr_SelectableObject::updateSelection (const Standard_Integer theMode)
void SelectMgr_SelectableObject::updateSelection(const Standard_Integer theMode)
{
if (theMode == -1)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
aSel->UpdateStatus (SelectMgr_TOU_Full);
aSel->UpdateStatus(SelectMgr_TOU_Full);
}
return;
}
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
if (aSel->Mode() == theMode)
{
aSel->UpdateStatus (SelectMgr_TOU_Full);
aSel->UpdateStatus(SelectMgr_TOU_Full);
return;
}
}
}
//=======================================================================
//function : SetAssemblyOwner
//purpose : Sets common entity owner for assembly sensitive object entities
// function : SetAssemblyOwner
// purpose : Sets common entity owner for assembly sensitive object entities
//=======================================================================
void SelectMgr_SelectableObject::SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
const Standard_Integer theMode)
void SelectMgr_SelectableObject::SetAssemblyOwner(const Handle(SelectMgr_EntityOwner)& theOwner,
const Standard_Integer theMode)
{
if (theMode == -1)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
aSelEntIter.Value()->BaseSensitive()->Set (theOwner);
aSelEntIter.Value()->BaseSensitive()->Set(theOwner);
}
}
return;
}
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
if (aSel->Mode() == theMode)
{
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
aSelEntIter.Value()->BaseSensitive()->Set (theOwner);
aSelEntIter.Value()->BaseSensitive()->Set(theOwner);
}
return;
}
}
}
//=======================================================================
//function : BndBoxOfSelected
//purpose :
//=======================================================================
Bnd_Box SelectMgr_SelectableObject::BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners)
//=================================================================================================
Bnd_Box SelectMgr_SelectableObject::BndBoxOfSelected(
const Handle(SelectMgr_IndexedMapOfOwner)& theOwners)
{
if (theOwners->IsEmpty())
return Bnd_Box();
Bnd_Box aBnd;
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(myselections); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
if (aSel->GetSelectionState() != SelectMgr_SOS_Activated)
continue;
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(SelectMgr_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
if (theOwners->Contains (anOwner))
const Handle(SelectMgr_EntityOwner)& anOwner =
aSelEntIter.Value()->BaseSensitive()->OwnerId();
if (theOwners->Contains(anOwner))
{
Select3D_BndBox3d aBox = aSelEntIter.Value()->BaseSensitive()->BoundingBox();
aBnd.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
aBnd.Update(aBox.CornerMin().x(),
aBox.CornerMin().y(),
aBox.CornerMin().z(),
aBox.CornerMax().x(),
aBox.CornerMax().y(),
aBox.CornerMax().z());
}
}
}
@@ -518,24 +520,21 @@ Bnd_Box SelectMgr_SelectableObject::BndBoxOfSelected (const Handle(SelectMgr_Ind
}
//=======================================================================
//function : GlobalSelOwner
//purpose : Returns entity owner corresponding to selection of the object as a whole
// function : GlobalSelOwner
// purpose : Returns entity owner corresponding to selection of the object as a whole
//=======================================================================
Handle(SelectMgr_EntityOwner) SelectMgr_SelectableObject::GlobalSelOwner() const
{
const Handle(SelectMgr_Selection)& aGlobalSel = Selection (myGlobalSelMode);
if (!aGlobalSel.IsNull()
&& !aGlobalSel->IsEmpty())
const Handle(SelectMgr_Selection)& aGlobalSel = Selection(myGlobalSelMode);
if (!aGlobalSel.IsNull() && !aGlobalSel->IsEmpty())
{
return aGlobalSel->Entities().First()->BaseSensitive()->OwnerId();
}
return THE_NULL_ENTITYOWNER;
}
//=======================================================================
//function : GetAssemblyOwner
//purpose :
//=======================================================================
//=================================================================================================
const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwner() const
{
return THE_NULL_ENTITYOWNER;
@@ -545,21 +544,23 @@ const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwne
// function : DumpJson
// purpose :
// =======================================================================
void SelectMgr_SelectableObject::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
void SelectMgr_SelectableObject::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, PrsMgr_PresentableObject)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, PrsMgr_PresentableObject)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySelectionPrs.get())
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myHilightPrs.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, mySelectionPrs.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myHilightPrs.get())
for (SelectMgr_SequenceOfSelection::Iterator anIterator (myselections); anIterator.More(); anIterator.Next())
for (SelectMgr_SequenceOfSelection::Iterator anIterator(myselections); anIterator.More();
anIterator.Next())
{
const Handle(SelectMgr_Selection)& aSelection = anIterator.Value();
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aSelection.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, aSelection.get())
}
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGlobalSelMode)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myGlobalSelMode)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myAutoHilight)
}

View File

@@ -26,36 +26,40 @@
class SelectMgr_EntityOwner;
//! A framework to supply the structure of the object to be selected.
//! At the first pick, this structure is created by calling the appropriate algorithm and retaining this framework for further picking.
//! This abstract framework is inherited in Application Interactive Services (AIS), notably in AIS_InteractiveObject.
//! Consequently, 3D selection should be handled by the relevant daughter classes and their member functions in AIS.
//! This is particularly true in the creation of new interactive objects.
//! At the first pick, this structure is created by calling the appropriate algorithm and retaining
//! this framework for further picking. This abstract framework is inherited in Application
//! Interactive Services (AIS), notably in AIS_InteractiveObject. Consequently, 3D selection should
//! be handled by the relevant daughter classes and their member functions in AIS. This is
//! particularly true in the creation of new interactive objects.
//!
//! Key interface methods to be implemented by every Selectable Object:
//! * Presentable Object (PrsMgr_PresentableObject)
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects.
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive
//! Object or class of Interactive Objects.
//! - AcceptDisplayMode() accepting display modes implemented by this object;
//! - Compute() computing presentation for the given display mode index;
//! * Selectable Object (SelectMgr_SelectableObject)
//! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects.
//! Consider defining an enumeration of supported Selection Mode indexes for particular
//! Interactive Object or class of Interactive Objects.
//! - ComputeSelection() computing selectable entities for the given selection mode index.
class SelectMgr_SelectableObject : public PrsMgr_PresentableObject
{
DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectableObject, PrsMgr_PresentableObject)
friend class SelectMgr_SelectionManager;
public:
public:
//! Clears all selections of the object
Standard_EXPORT virtual ~SelectMgr_SelectableObject();
//! Computes sensitive primitives for the given selection mode - key interface method of Selectable Object.
//! Computes sensitive primitives for the given selection mode - key interface method of
//! Selectable Object.
//! @param theSelection selection to fill
//! @param theMode selection mode to create sensitive primitives
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) = 0;
virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) = 0;
//! Informs the graphic context that the interactive Object may be decomposed into sub-shapes for dynamic selection.
//! The most used Interactive Object is AIS_Shape.
//! Informs the graphic context that the interactive Object may be decomposed into sub-shapes for
//! dynamic selection. The most used Interactive Object is AIS_Shape.
virtual Standard_Boolean AcceptShapeDecomposition() const { return Standard_False; }
//! Re-computes the sensitive primitives for all modes. IMPORTANT: Do not use
@@ -63,47 +67,54 @@ public:
//! This method does not take into account necessary BVH updates, but may invalidate the pointers
//! it refers to. TO UPDATE SELECTION properly from outside classes, use method UpdateSelection.
Standard_EXPORT void RecomputePrimitives();
//! Re-computes the sensitive primitives which correspond to the <theMode>th selection mode.
//! IMPORTANT: Do not use this method to update selection primitives except implementing custom selection manager!
//! selection manager! This method does not take into account necessary BVH updates, but may invalidate
//! the pointers it refers to. TO UPDATE SELECTION properly from outside classes, use method UpdateSelection.
Standard_EXPORT void RecomputePrimitives (const Standard_Integer theMode);
//! IMPORTANT: Do not use this method to update selection primitives except implementing custom
//! selection manager! selection manager! This method does not take into account necessary BVH
//! updates, but may invalidate the pointers it refers to. TO UPDATE SELECTION properly from
//! outside classes, use method UpdateSelection.
Standard_EXPORT void RecomputePrimitives(const Standard_Integer theMode);
//! Adds the selection aSelection with the selection mode
//! index aMode to this framework.
Standard_EXPORT void AddSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode);
Standard_EXPORT void AddSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode);
//! Empties all the selections in the SelectableObject
//! <update> parameter defines whether all object's
//! selections should be flagged for further update or not.
//! This improved method can be used to recompute an
//! object's selection (without redisplaying the object
//! completely) when some selection mode is activated not for the first time.
Standard_EXPORT void ClearSelections (const Standard_Boolean update = Standard_False);
//! Returns the selection having specified selection mode or NULL.
Standard_EXPORT const Handle(SelectMgr_Selection)& Selection (const Standard_Integer theMode) const;
Standard_EXPORT void ClearSelections(const Standard_Boolean update = Standard_False);
//! Returns true if a selection corresponding to the selection mode theMode was computed for this object.
Standard_Boolean HasSelection (const Standard_Integer theMode) const { return !Selection (theMode).IsNull(); }
//! Returns the selection having specified selection mode or NULL.
Standard_EXPORT const Handle(SelectMgr_Selection)& Selection(
const Standard_Integer theMode) const;
//! Returns true if a selection corresponding to the selection mode theMode was computed for this
//! object.
Standard_Boolean HasSelection(const Standard_Integer theMode) const
{
return !Selection(theMode).IsNull();
}
//! Return the sequence of selections.
const SelectMgr_SequenceOfSelection& Selections() const { return myselections; }
Standard_EXPORT void ResetTransformation() Standard_OVERRIDE;
//! Recomputes the location of the selection aSelection.
Standard_EXPORT virtual void UpdateTransformation() Standard_OVERRIDE;
//! Updates locations in all sensitive entities from <aSelection>
//! and in corresponding entity owners.
Standard_EXPORT virtual void UpdateTransformations (const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT virtual void UpdateTransformations(const Handle(SelectMgr_Selection)& aSelection);
//! Method which draws selected owners ( for fast presentation draw )
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const SelectMgr_SequenceOfOwner& theSeq);
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const SelectMgr_SequenceOfOwner& theSeq);
//! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void ClearSelected();
@@ -113,50 +124,58 @@ public:
//! Clears or invalidates dynamic highlight presentation.
//! By default it clears immediate draw of given presentation
//! manager.
Standard_EXPORT virtual void ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager)& theMgr);
Standard_EXPORT virtual void ClearDynamicHighlight(
const Handle(PrsMgr_PresentationManager)& theMgr);
//! Method which hilight an owner belonging to
//! this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner);
//! If returns True, the old mechanism for highlighting selected objects is used (HilightSelected Method may be empty).
//! If returns False, the HilightSelected method will be fully responsible for highlighting selected entity owners belonging to this selectable object.
Standard_EXPORT virtual void HilightOwnerWithColor(
const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner);
//! If returns True, the old mechanism for highlighting selected objects is used (HilightSelected
//! Method may be empty). If returns False, the HilightSelected method will be fully responsible
//! for highlighting selected entity owners belonging to this selectable object.
virtual Standard_Boolean IsAutoHilight() const { return myAutoHilight; }
//! Set AutoHilight property to true or false.
virtual void SetAutoHilight (const Standard_Boolean theAutoHilight) { myAutoHilight = theAutoHilight; }
virtual void SetAutoHilight(const Standard_Boolean theAutoHilight)
{
myAutoHilight = theAutoHilight;
}
//! Creates or returns existing presentation for highlighting detected object.
//! @param thePrsMgr presentation manager to create new presentation
//! @return existing or newly created presentation (when thePrsMgr is not NULL)
Standard_EXPORT Handle(Prs3d_Presentation) GetHilightPresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr);
Standard_EXPORT Handle(Prs3d_Presentation) GetHilightPresentation(
const Handle(PrsMgr_PresentationManager)& thePrsMgr);
//! Creates or returns existing presentation for highlighting selected object.
//! @param thePrsMgr presentation manager to create new presentation
//! @return existing or newly created presentation (when thePrsMgr is not NULL)
Standard_EXPORT Handle(Prs3d_Presentation) GetSelectPresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr);
Standard_EXPORT Handle(Prs3d_Presentation) GetSelectPresentation(
const Handle(PrsMgr_PresentationManager)& thePrsMgr);
//! Removes presentations returned by GetHilightPresentation() and GetSelectPresentation().
Standard_EXPORT virtual void ErasePresentations (Standard_Boolean theToRemove);
Standard_EXPORT virtual void ErasePresentations(Standard_Boolean theToRemove);
//! Set Z layer ID and update all presentations of the selectable object.
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
//! Sets update status FULL to selections of the object. Must be used as the only method of UpdateSelection
//! from outer classes to prevent BVH structures from being outdated.
void UpdateSelection (const Standard_Integer theMode = -1)
{
updateSelection (theMode);
}
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower
//! layers.
Standard_EXPORT virtual void SetZLayer(const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
//! Sets update status FULL to selections of the object. Must be used as the only method of
//! UpdateSelection from outer classes to prevent BVH structures from being outdated.
void UpdateSelection(const Standard_Integer theMode = -1) { updateSelection(theMode); }
//! Sets common entity owner for assembly sensitive object entities
Standard_EXPORT void SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer theMode = -1);
Standard_EXPORT void SetAssemblyOwner(const Handle(SelectMgr_EntityOwner)& theOwner,
const Standard_Integer theMode = -1);
//! Returns a bounding box of sensitive entities with the owners given if they are a part of activated selection
Standard_EXPORT Bnd_Box BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners);
//! Returns a bounding box of sensitive entities with the owners given if they are a part of
//! activated selection
Standard_EXPORT Bnd_Box BndBoxOfSelected(const Handle(SelectMgr_IndexedMapOfOwner)& theOwners);
//! Returns the mode for selection of object as a whole; 0 by default.
Standard_Integer GlobalSelectionMode() const { return myGlobalSelMode; }
@@ -168,15 +187,16 @@ public:
Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const;
//! 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:
//! Protected empty constructor.
Standard_EXPORT SelectMgr_SelectableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
Standard_EXPORT SelectMgr_SelectableObject(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
//! Override global selection mode.
void setGlobalSelMode (const Standard_Integer theMode)
void setGlobalSelMode(const Standard_Integer theMode)
{
myGlobalSelMode = theMode > 0 ? theMode : 0;
}
@@ -185,19 +205,18 @@ protected:
Standard_EXPORT virtual void UpdateClipping() Standard_OVERRIDE;
//! Sets update status FULL to selections of the object.
//! Must be used as the only method of UpdateSelection from outer classes to prevent BVH structures from being outdated.
Standard_EXPORT virtual void updateSelection (const Standard_Integer theMode);
//! Must be used as the only method of UpdateSelection from outer classes to prevent BVH
//! structures from being outdated.
Standard_EXPORT virtual void updateSelection(const Standard_Integer theMode);
protected:
SelectMgr_SequenceOfSelection myselections; //!< list of selections
// clang-format off
SelectMgr_SequenceOfSelection myselections; //!< list of selections
// clang-format off
Handle(Prs3d_Presentation) mySelectionPrs; //!< optional presentation for highlighting selected object
Handle(Prs3d_Presentation) myHilightPrs; //!< optional presentation for highlighting detected object
// clang-format on
Standard_Integer myGlobalSelMode; //!< global selection mode
Standard_Boolean myAutoHilight; //!< auto-highlighting flag defining
// clang-format on
Standard_Integer myGlobalSelMode; //!< global selection mode
Standard_Boolean myAutoHilight; //!< auto-highlighting flag defining
};
DEFINE_STANDARD_HANDLE(SelectMgr_SelectableObject, PrsMgr_PresentableObject)

View File

@@ -21,224 +21,225 @@
namespace
{
//! Short-cut definition of indexed data map of selectable objects
typedef NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)> ObjectsMap;
//! Short-cut definition of indexed data map of selectable objects
typedef NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)> ObjectsMap;
//-------------------------------------------------------------------------------------
// Adaptor over regular objects subset of SelectMgr_SelectableObjectSet for BVH builder
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
// Adaptor over regular objects subset of SelectMgr_SelectableObjectSet for BVH builder
//-------------------------------------------------------------------------------------
//! This class provides direct access to fields of SelectMgr_SelectableObjectSet
//! so the BVH builder could explicitly arrange objects in the map as necessary
//! to provide synchronization of indexes with constructed BVH tree.
class BVHBuilderAdaptorRegular : public BVH_Set<Standard_Real, 3>
//! This class provides direct access to fields of SelectMgr_SelectableObjectSet
//! so the BVH builder could explicitly arrange objects in the map as necessary
//! to provide synchronization of indexes with constructed BVH tree.
class BVHBuilderAdaptorRegular : public BVH_Set<Standard_Real, 3>
{
public:
//! Construct adaptor.
BVHBuilderAdaptorRegular(ObjectsMap& theObjects)
: myObjects(theObjects) {};
//! Returns bounding box of object with index theIndex
virtual Select3D_BndBox3d Box(const Standard_Integer theIndex) const Standard_OVERRIDE
{
public:
const Handle(SelectMgr_SelectableObject)& anObject = myObjects.FindKey(theIndex + 1);
Bnd_Box aBox;
anObject->BoundingBox(aBox);
if (aBox.IsVoid())
return Select3D_BndBox3d();
//! Construct adaptor.
BVHBuilderAdaptorRegular (ObjectsMap& theObjects) : myObjects (theObjects) {};
return Select3D_BndBox3d(
SelectMgr_Vec3(aBox.CornerMin().X(), aBox.CornerMin().Y(), aBox.CornerMin().Z()),
SelectMgr_Vec3(aBox.CornerMax().X(), aBox.CornerMax().Y(), aBox.CornerMax().Z()));
}
//! Returns bounding box of object with index theIndex
virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE
//! Returns bounding box of the whole subset.
virtual Select3D_BndBox3d Box() const Standard_OVERRIDE
{
if (!myBox.IsValid())
{
const Handle(SelectMgr_SelectableObject)& anObject = myObjects.FindKey (theIndex + 1);
Bnd_Box aBox;
anObject->BoundingBox (aBox);
if (aBox.IsVoid())
return Select3D_BndBox3d();
return Select3D_BndBox3d (SelectMgr_Vec3 (aBox.CornerMin().X(), aBox.CornerMin().Y(), aBox.CornerMin().Z()),
SelectMgr_Vec3 (aBox.CornerMax().X(), aBox.CornerMax().Y(), aBox.CornerMax().Z()));
myBox = BVH_Set<Standard_Real, 3>::Box();
}
return myBox;
}
//! Returns bounding box of the whole subset.
virtual Select3D_BndBox3d Box() const Standard_OVERRIDE
//! Make inherited method Box() visible to avoid CLang warning
using BVH_Set<Standard_Real, 3>::Box;
//! Returns center of object with index theIndex in the set
//! along the given axis theAxis
virtual Standard_Real Center(const Standard_Integer theIndex,
const Standard_Integer theAxis) const Standard_OVERRIDE
{
const Select3D_BndBox3d aBndBox = Box(theIndex);
return (aBndBox.CornerMin()[theAxis] + aBndBox.CornerMax()[theAxis]) * 0.5;
}
//! Returns size of objects set.
virtual Standard_Integer Size() const Standard_OVERRIDE { return myObjects.Size(); }
//! Swaps items with indexes theIndex1 and theIndex2 in the set
virtual void Swap(const Standard_Integer theIndex1,
const Standard_Integer theIndex2) Standard_OVERRIDE
{
myObjects.Swap(theIndex1 + 1, theIndex2 + 1);
}
private:
BVHBuilderAdaptorRegular& operator=(const BVHBuilderAdaptorRegular&) { return *this; }
private:
ObjectsMap& myObjects;
mutable Select3D_BndBox3d myBox;
};
//----------------------------------------------------------------------------------------
// Adaptor over persistent objects subset of SelectMgr_SelectableObjectSet for BVH builder
//----------------------------------------------------------------------------------------
//! This class provides direct access to fields of SelectMgr_SelectableObjectSet
//! so the BVH builder could explicitly arrange objects in the map as necessary
//! to provide synchronization of indexes with constructed BVH tree.
class BVHBuilderAdaptorPersistent : public BVH_Set<Standard_Real, 3>
{
public:
//! Construct adaptor.
//! @param theCamera, theProjectionMat, theWorldViewMat,
//! theWidth, theHeight [in] view properties used for computation of
//! bounding boxes within the world view camera space.
BVHBuilderAdaptorPersistent(ObjectsMap& theObjects,
const Handle(Graphic3d_Camera)& theCamera,
const Graphic3d_Mat4d& theProjectionMat,
const Graphic3d_Mat4d& theWorldViewMat,
const Graphic3d_Vec2i& theWinSize)
: myObjects(theObjects)
{
myBoundings.ReSize(myObjects.Size());
for (Standard_Integer anI = 1; anI <= myObjects.Size(); ++anI)
{
if (!myBox.IsValid())
const Handle(SelectMgr_SelectableObject)& anObject = myObjects(anI);
Bnd_Box aBoundingBox;
anObject->BoundingBox(aBoundingBox);
if (!aBoundingBox.IsVoid() && !anObject->TransformPersistence().IsNull())
{
myBox = BVH_Set<Standard_Real, 3>::Box();
anObject->TransformPersistence()->Apply(theCamera,
theProjectionMat,
theWorldViewMat,
theWinSize.x(),
theWinSize.y(),
aBoundingBox);
}
return myBox;
}
//! Make inherited method Box() visible to avoid CLang warning
using BVH_Set<Standard_Real, 3>::Box;
//! Returns center of object with index theIndex in the set
//! along the given axis theAxis
virtual Standard_Real Center (const Standard_Integer theIndex,
const Standard_Integer theAxis) const Standard_OVERRIDE
{
const Select3D_BndBox3d aBndBox = Box (theIndex);
return (aBndBox.CornerMin()[theAxis] +
aBndBox.CornerMax()[theAxis]) * 0.5;
}
//! Returns size of objects set.
virtual Standard_Integer Size() const Standard_OVERRIDE
{
return myObjects.Size();
}
//! Swaps items with indexes theIndex1 and theIndex2 in the set
virtual void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2) Standard_OVERRIDE
{
myObjects.Swap (theIndex1 + 1, theIndex2 + 1);
}
private:
BVHBuilderAdaptorRegular& operator=(const BVHBuilderAdaptorRegular&) { return *this; }
private:
ObjectsMap& myObjects;
mutable Select3D_BndBox3d myBox;
};
//----------------------------------------------------------------------------------------
// Adaptor over persistent objects subset of SelectMgr_SelectableObjectSet for BVH builder
//----------------------------------------------------------------------------------------
//! This class provides direct access to fields of SelectMgr_SelectableObjectSet
//! so the BVH builder could explicitly arrange objects in the map as necessary
//! to provide synchronization of indexes with constructed BVH tree.
class BVHBuilderAdaptorPersistent : public BVH_Set<Standard_Real, 3>
{
public:
//! Construct adaptor.
//! @param theCamera, theProjectionMat, theWorldViewMat,
//! theWidth, theHeight [in] view properties used for computation of
//! bounding boxes within the world view camera space.
BVHBuilderAdaptorPersistent (ObjectsMap& theObjects,
const Handle(Graphic3d_Camera)& theCamera,
const Graphic3d_Mat4d& theProjectionMat,
const Graphic3d_Mat4d& theWorldViewMat,
const Graphic3d_Vec2i& theWinSize)
: myObjects (theObjects)
{
myBoundings.ReSize (myObjects.Size());
for (Standard_Integer anI = 1; anI <= myObjects.Size(); ++anI)
// processing presentations with own transform persistence
for (PrsMgr_Presentations::Iterator aPrsIter(anObject->Presentations()); aPrsIter.More();
aPrsIter.Next())
{
const Handle(SelectMgr_SelectableObject)& anObject = myObjects (anI);
Bnd_Box aBoundingBox;
anObject->BoundingBox (aBoundingBox);
if (!aBoundingBox.IsVoid()
&& !anObject->TransformPersistence().IsNull())
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value();
if (!aPrs3d->CStructure()->HasGroupTransformPersistence())
{
anObject->TransformPersistence()->Apply (theCamera,
theProjectionMat, theWorldViewMat,
theWinSize.x(), theWinSize.y(),
aBoundingBox);
continue;
}
// processing presentations with own transform persistence
for (PrsMgr_Presentations::Iterator aPrsIter (anObject->Presentations()); aPrsIter.More(); aPrsIter.Next())
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter(aPrs3d->Groups()); aGroupIter.More();
aGroupIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value();
if (!aPrs3d->CStructure()->HasGroupTransformPersistence())
const Handle(Graphic3d_Group)& aGroup = aGroupIter.Value();
const Graphic3d_BndBox4f& aBndBox = aGroup->BoundingBox();
if (aGroup->TransformPersistence().IsNull() || !aBndBox.IsValid())
{
continue;
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Groups()); aGroupIter.More(); aGroupIter.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIter.Value();
const Graphic3d_BndBox4f& aBndBox = aGroup->BoundingBox();
if (aGroup->TransformPersistence().IsNull()
|| !aBndBox.IsValid())
{
continue;
}
Bnd_Box aGroupBox;
aGroupBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
aGroup->TransformPersistence()->Apply (theCamera,
theProjectionMat, theWorldViewMat,
theWinSize.x(), theWinSize.y(),
aGroupBox);
aBoundingBox.Add (aGroupBox);
}
}
if (aBoundingBox.IsVoid())
{
myBoundings.Add (new Select3D_HBndBox3d());
}
else
{
const gp_Pnt aMin = aBoundingBox.CornerMin();
const gp_Pnt aMax = aBoundingBox.CornerMax();
myBoundings.Add (new Select3D_HBndBox3d (Select3D_Vec3 (aMin.X(), aMin.Y(), aMin.Z()),
Select3D_Vec3 (aMax.X(), aMax.Y(), aMax.Z())));
Bnd_Box aGroupBox;
aGroupBox.Update(aBndBox.CornerMin().x(),
aBndBox.CornerMin().y(),
aBndBox.CornerMin().z(),
aBndBox.CornerMax().x(),
aBndBox.CornerMax().y(),
aBndBox.CornerMax().z());
aGroup->TransformPersistence()->Apply(theCamera,
theProjectionMat,
theWorldViewMat,
theWinSize.x(),
theWinSize.y(),
aGroupBox);
aBoundingBox.Add(aGroupBox);
}
}
}
//! Returns bounding box of object with index theIndex
virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE
{
return *myBoundings (theIndex + 1);
}
//! Returns bounding box of the whole subset.
virtual Select3D_BndBox3d Box() const Standard_OVERRIDE
{
if (!myBox.IsValid())
if (aBoundingBox.IsVoid())
{
myBox = BVH_Set<Standard_Real, 3>::Box();
myBoundings.Add(new Select3D_HBndBox3d());
}
else
{
const gp_Pnt aMin = aBoundingBox.CornerMin();
const gp_Pnt aMax = aBoundingBox.CornerMax();
myBoundings.Add(new Select3D_HBndBox3d(Select3D_Vec3(aMin.X(), aMin.Y(), aMin.Z()),
Select3D_Vec3(aMax.X(), aMax.Y(), aMax.Z())));
}
return myBox;
}
}
//! Make inherited method Box() visible to avoid CLang warning
using BVH_Set<Standard_Real, 3>::Box;
//! Returns bounding box of object with index theIndex
virtual Select3D_BndBox3d Box(const Standard_Integer theIndex) const Standard_OVERRIDE
{
return *myBoundings(theIndex + 1);
}
//! Returns center of object with index theIndex in the set
//! along the given axis theAxis
virtual Standard_Real Center (const Standard_Integer theIndex,
const Standard_Integer theAxis) const Standard_OVERRIDE
//! Returns bounding box of the whole subset.
virtual Select3D_BndBox3d Box() const Standard_OVERRIDE
{
if (!myBox.IsValid())
{
const Select3D_BndBox3d& aBoundingBox = *myBoundings (theIndex + 1);
return (aBoundingBox.CornerMin()[theAxis] + aBoundingBox.CornerMax()[theAxis]) * 0.5;
myBox = BVH_Set<Standard_Real, 3>::Box();
}
return myBox;
}
//! Returns size of objects set.
virtual Standard_Integer Size() const Standard_OVERRIDE
{
return myObjects.Size();
}
//! Make inherited method Box() visible to avoid CLang warning
using BVH_Set<Standard_Real, 3>::Box;
//! Swaps items with indexes theIndex1 and theIndex2 in the set
virtual void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2) Standard_OVERRIDE
{
const Standard_Integer aStructIdx1 = theIndex1 + 1;
const Standard_Integer aStructIdx2 = theIndex2 + 1;
//! Returns center of object with index theIndex in the set
//! along the given axis theAxis
virtual Standard_Real Center(const Standard_Integer theIndex,
const Standard_Integer theAxis) const Standard_OVERRIDE
{
const Select3D_BndBox3d& aBoundingBox = *myBoundings(theIndex + 1);
myObjects.Swap (aStructIdx1, aStructIdx2);
myBoundings.Swap (aStructIdx1, aStructIdx2);
}
return (aBoundingBox.CornerMin()[theAxis] + aBoundingBox.CornerMax()[theAxis]) * 0.5;
}
private:
BVHBuilderAdaptorPersistent& operator=(const BVHBuilderAdaptorPersistent&) { return *this; }
//! Returns size of objects set.
virtual Standard_Integer Size() const Standard_OVERRIDE { return myObjects.Size(); }
private:
ObjectsMap& myObjects;
mutable Select3D_BndBox3d myBox;
typedef NCollection_Shared<Select3D_BndBox3d> Select3D_HBndBox3d;
NCollection_IndexedMap<Handle(Select3D_HBndBox3d)> myBoundings;
};
//! Swaps items with indexes theIndex1 and theIndex2 in the set
virtual void Swap(const Standard_Integer theIndex1,
const Standard_Integer theIndex2) Standard_OVERRIDE
{
const Standard_Integer aStructIdx1 = theIndex1 + 1;
const Standard_Integer aStructIdx2 = theIndex2 + 1;
static const Graphic3d_Mat4d SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT;
}
myObjects.Swap(aStructIdx1, aStructIdx2);
myBoundings.Swap(aStructIdx1, aStructIdx2);
}
private:
BVHBuilderAdaptorPersistent& operator=(const BVHBuilderAdaptorPersistent&) { return *this; }
private:
ObjectsMap& myObjects;
mutable Select3D_BndBox3d myBox;
typedef NCollection_Shared<Select3D_BndBox3d> Select3D_HBndBox3d;
NCollection_IndexedMap<Handle(Select3D_HBndBox3d)> myBoundings;
};
static const Graphic3d_Mat4d SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT;
} // namespace
//=================================================================================================
//=============================================================================
// Function: Constructor
// Purpose :
//=============================================================================
SelectMgr_SelectableObjectSet::SelectMgr_SelectableObjectSet()
{
myBVH[BVHSubset_ortho2dPersistent] = new BVH_Tree<Standard_Real, 3>();
@@ -247,11 +248,22 @@ SelectMgr_SelectableObjectSet::SelectMgr_SelectableObjectSet()
myBVH[BVHSubset_3dPersistent] = new BVH_Tree<Standard_Real, 3>();
myBVH[BVHSubset_3d] = new BVH_Tree<Standard_Real, 3>();
myBuilder[BVHSubset_ortho2dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
myBuilder[BVHSubset_ortho3dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
myBuilder[BVHSubset_2dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
myBuilder[BVHSubset_3dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
myBuilder[BVHSubset_3d] = new BVH_BinnedBuilder<Standard_Real, 3, 4> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth, Standard_True);
myBuilder[BVHSubset_ortho2dPersistent] =
new BVH_LinearBuilder<Standard_Real, 3>(BVH_Constants_LeafNodeSizeSingle,
BVH_Constants_MaxTreeDepth);
myBuilder[BVHSubset_ortho3dPersistent] =
new BVH_LinearBuilder<Standard_Real, 3>(BVH_Constants_LeafNodeSizeSingle,
BVH_Constants_MaxTreeDepth);
myBuilder[BVHSubset_2dPersistent] =
new BVH_LinearBuilder<Standard_Real, 3>(BVH_Constants_LeafNodeSizeSingle,
BVH_Constants_MaxTreeDepth);
myBuilder[BVHSubset_3dPersistent] =
new BVH_LinearBuilder<Standard_Real, 3>(BVH_Constants_LeafNodeSizeSingle,
BVH_Constants_MaxTreeDepth);
myBuilder[BVHSubset_3d] =
new BVH_BinnedBuilder<Standard_Real, 3, 4>(BVH_Constants_LeafNodeSizeSingle,
BVH_Constants_MaxTreeDepth,
Standard_True);
myIsDirty[BVHSubset_ortho2dPersistent] = Standard_False;
myIsDirty[BVHSubset_ortho3dPersistent] = Standard_False;
@@ -260,17 +272,16 @@ SelectMgr_SelectableObjectSet::SelectMgr_SelectableObjectSet()
myIsDirty[BVHSubset_3d] = Standard_False;
}
//=============================================================================
// Function: Append
// Purpose :
//=============================================================================
Standard_Boolean SelectMgr_SelectableObjectSet::Append (const Handle(SelectMgr_SelectableObject)& theObject)
//=================================================================================================
Standard_Boolean SelectMgr_SelectableObjectSet::Append(
const Handle(SelectMgr_SelectableObject)& theObject)
{
// get an appropriate BVH subset to insert the object into it
const Standard_Integer aSubsetIdx = appropriateSubset (theObject);
const Standard_Integer aSubsetIdx = appropriateSubset(theObject);
// check that the object is excluded from other subsets
if (currentSubset (theObject) != -1)
if (currentSubset(theObject) != -1)
{
return Standard_False;
}
@@ -278,7 +289,7 @@ Standard_Boolean SelectMgr_SelectableObjectSet::Append (const Handle(SelectMgr_S
// try adding it into the appropriate object subset
const Standard_Integer aSize = myObjects[aSubsetIdx].Size();
if (aSize < myObjects[aSubsetIdx].Add (theObject))
if (aSize < myObjects[aSubsetIdx].Add(theObject))
{
myIsDirty[aSubsetIdx] = Standard_True;
@@ -288,16 +299,15 @@ Standard_Boolean SelectMgr_SelectableObjectSet::Append (const Handle(SelectMgr_S
return Standard_False;
}
//=============================================================================
// Function: Remove
// Purpose :
//=============================================================================
Standard_Boolean SelectMgr_SelectableObjectSet::Remove (const Handle(SelectMgr_SelectableObject)& theObject)
//=================================================================================================
Standard_Boolean SelectMgr_SelectableObjectSet::Remove(
const Handle(SelectMgr_SelectableObject)& theObject)
{
// remove object from the first found subset
for (Standard_Integer aSubsetIdx = 0; aSubsetIdx < BVHSubsetNb; ++aSubsetIdx)
{
const Standard_Integer anIndex = myObjects[aSubsetIdx].FindIndex (theObject);
const Standard_Integer anIndex = myObjects[aSubsetIdx].FindIndex(theObject);
if (anIndex != 0)
{
@@ -305,7 +315,7 @@ Standard_Boolean SelectMgr_SelectableObjectSet::Remove (const Handle(SelectMgr_S
if (anIndex != aSize)
{
myObjects[aSubsetIdx].Swap (anIndex, aSize);
myObjects[aSubsetIdx].Swap(anIndex, aSize);
}
myObjects[aSubsetIdx].RemoveLast();
@@ -318,14 +328,13 @@ Standard_Boolean SelectMgr_SelectableObjectSet::Remove (const Handle(SelectMgr_S
return Standard_False;
}
//=============================================================================
// Function: ChangeSubset
// Purpose :
//=============================================================================
void SelectMgr_SelectableObjectSet::ChangeSubset (const Handle(SelectMgr_SelectableObject)& theObject)
//=================================================================================================
void SelectMgr_SelectableObjectSet::ChangeSubset(
const Handle(SelectMgr_SelectableObject)& theObject)
{
// do not do anything is object is not in the map
const Standard_Integer aCurrSubsetIdx = currentSubset (theObject);
const Standard_Integer aCurrSubsetIdx = currentSubset(theObject);
if (aCurrSubsetIdx < 0)
{
@@ -333,7 +342,7 @@ void SelectMgr_SelectableObjectSet::ChangeSubset (const Handle(SelectMgr_Selecta
}
// check whether the subset need to be changed at all
const Standard_Integer aSubsetIdx = appropriateSubset (theObject);
const Standard_Integer aSubsetIdx = appropriateSubset(theObject);
if (aCurrSubsetIdx == aSubsetIdx)
{
@@ -341,27 +350,25 @@ void SelectMgr_SelectableObjectSet::ChangeSubset (const Handle(SelectMgr_Selecta
}
// replace object in the maps
Remove (theObject);
Append (theObject);
Remove(theObject);
Append(theObject);
}
//=============================================================================
// Function: UpdateBVH
// Purpose :
//=============================================================================
void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& theCam,
const Graphic3d_Vec2i& theWinSize)
//=================================================================================================
void SelectMgr_SelectableObjectSet::UpdateBVH(const Handle(Graphic3d_Camera)& theCam,
const Graphic3d_Vec2i& theWinSize)
{
// -----------------------------------------
// check and update 3D BVH tree if necessary
// -----------------------------------------
if (!IsEmpty (BVHSubset_3d) && myIsDirty[BVHSubset_3d])
if (!IsEmpty(BVHSubset_3d) && myIsDirty[BVHSubset_3d])
{
// construct adaptor over private fields to provide direct access for the BVH builder
BVHBuilderAdaptorRegular anAdaptor (myObjects[BVHSubset_3d]);
BVHBuilderAdaptorRegular anAdaptor(myObjects[BVHSubset_3d]);
// update corresponding BVH tree data structure
myBuilder[BVHSubset_3d]->Build (&anAdaptor, myBVH[BVHSubset_3d].get(), anAdaptor.Box());
myBuilder[BVHSubset_3d]->Build(&anAdaptor, myBVH[BVHSubset_3d].get(), anAdaptor.Box());
// release dirty state
myIsDirty[BVHSubset_3d] = Standard_False;
@@ -369,85 +376,99 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
if (!theCam.IsNull())
{
const Standard_Boolean isWinSizeChanged = myLastWinSize != theWinSize;
const Graphic3d_Mat4d& aProjMat = theCam->ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = theCam->OrientationMatrix();
const Graphic3d_WorldViewProjState& aViewState = theCam->WorldViewProjState();
const Standard_Boolean isWinSizeChanged = myLastWinSize != theWinSize;
const Graphic3d_Mat4d& aProjMat = theCam->ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = theCam->OrientationMatrix();
const Graphic3d_WorldViewProjState& aViewState = theCam->WorldViewProjState();
// -----------------------------------------------------
// check and update 3D persistence BVH tree if necessary
// -----------------------------------------------------
if (!IsEmpty (BVHSubset_3dPersistent)
&& (myIsDirty[BVHSubset_3dPersistent]
|| myLastViewState.IsChanged (aViewState)
|| isWinSizeChanged))
if (!IsEmpty(BVHSubset_3dPersistent)
&& (myIsDirty[BVHSubset_3dPersistent] || myLastViewState.IsChanged(aViewState)
|| isWinSizeChanged))
{
// construct adaptor over private fields to provide direct access for the BVH builder
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_3dPersistent],
theCam, aProjMat, aWorldViewMat, theWinSize);
BVHBuilderAdaptorPersistent anAdaptor(myObjects[BVHSubset_3dPersistent],
theCam,
aProjMat,
aWorldViewMat,
theWinSize);
// update corresponding BVH tree data structure
myBuilder[BVHSubset_3dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_3dPersistent].get(), anAdaptor.Box());
myBuilder[BVHSubset_3dPersistent]->Build(&anAdaptor,
myBVH[BVHSubset_3dPersistent].get(),
anAdaptor.Box());
}
// -----------------------------------------------------
// check and update 2D persistence BVH tree if necessary
// -----------------------------------------------------
if (!IsEmpty (BVHSubset_2dPersistent)
&& (myIsDirty[BVHSubset_2dPersistent]
|| myLastViewState.IsProjectionChanged (aViewState)
|| isWinSizeChanged))
if (!IsEmpty(BVHSubset_2dPersistent)
&& (myIsDirty[BVHSubset_2dPersistent] || myLastViewState.IsProjectionChanged(aViewState)
|| isWinSizeChanged))
{
// construct adaptor over private fields to provide direct access for the BVH builder
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_2dPersistent],
theCam, aProjMat, SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theWinSize);
BVHBuilderAdaptorPersistent anAdaptor(myObjects[BVHSubset_2dPersistent],
theCam,
aProjMat,
SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT,
theWinSize);
// update corresponding BVH tree data structure
myBuilder[BVHSubset_2dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_2dPersistent].get(), anAdaptor.Box());
myBuilder[BVHSubset_2dPersistent]->Build(&anAdaptor,
myBVH[BVHSubset_2dPersistent].get(),
anAdaptor.Box());
}
// -------------------------------------------------------------------
// check and update 3D orthographic persistence BVH tree if necessary
// -------------------------------------------------------------------
if (!IsEmpty (BVHSubset_ortho3dPersistent)
&& (myIsDirty[BVHSubset_ortho3dPersistent]
|| myLastViewState.IsChanged (aViewState)
|| isWinSizeChanged))
if (!IsEmpty(BVHSubset_ortho3dPersistent)
&& (myIsDirty[BVHSubset_ortho3dPersistent] || myLastViewState.IsChanged(aViewState)
|| isWinSizeChanged))
{
// clang-format off
// clang-format off
Handle(Graphic3d_Camera) aNewOrthoCam = new Graphic3d_Camera (*theCam); // If OrthoPers, copy camera and set to orthographic projection
// clang-format on
aNewOrthoCam->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
// clang-format on
aNewOrthoCam->SetProjectionType(Graphic3d_Camera::Projection_Orthographic);
// construct adaptor over private fields to provide direct access for the BVH builder
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_ortho3dPersistent],
aNewOrthoCam, aNewOrthoCam->ProjectionMatrix(),
aNewOrthoCam->OrientationMatrix(), theWinSize);
BVHBuilderAdaptorPersistent anAdaptor(myObjects[BVHSubset_ortho3dPersistent],
aNewOrthoCam,
aNewOrthoCam->ProjectionMatrix(),
aNewOrthoCam->OrientationMatrix(),
theWinSize);
// update corresponding BVH tree data structure
myBuilder[BVHSubset_ortho3dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_ortho3dPersistent].get(), anAdaptor.Box());
myBuilder[BVHSubset_ortho3dPersistent]->Build(&anAdaptor,
myBVH[BVHSubset_ortho3dPersistent].get(),
anAdaptor.Box());
}
// -------------------------------------------------------------------
// check and update 2D orthographic persistence BVH tree if necessary
// -------------------------------------------------------------------
if (!IsEmpty (BVHSubset_ortho2dPersistent)
&& (myIsDirty[BVHSubset_ortho2dPersistent]
|| myLastViewState.IsProjectionChanged (aViewState)
|| isWinSizeChanged))
if (!IsEmpty(BVHSubset_ortho2dPersistent)
&& (myIsDirty[BVHSubset_ortho2dPersistent]
|| myLastViewState.IsProjectionChanged(aViewState) || isWinSizeChanged))
{
// clang-format off
// clang-format off
Handle(Graphic3d_Camera) aNewOrthoCam = new Graphic3d_Camera (*theCam); // If OrthoPers, copy camera and set to orthographic projection
// clang-format on
aNewOrthoCam->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
// clang-format on
aNewOrthoCam->SetProjectionType(Graphic3d_Camera::Projection_Orthographic);
// construct adaptor over private fields to provide direct access for the BVH builder
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_ortho2dPersistent],
aNewOrthoCam, aNewOrthoCam->ProjectionMatrix(),
SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theWinSize);
BVHBuilderAdaptorPersistent anAdaptor(myObjects[BVHSubset_ortho2dPersistent],
aNewOrthoCam,
aNewOrthoCam->ProjectionMatrix(),
SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT,
theWinSize);
// update corresponding BVH tree data structure
myBuilder[BVHSubset_ortho2dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_ortho2dPersistent].get(), anAdaptor.Box());
myBuilder[BVHSubset_ortho2dPersistent]->Build(&anAdaptor,
myBVH[BVHSubset_ortho2dPersistent].get(),
anAdaptor.Box());
}
// release dirty state for every subset
@@ -464,10 +485,8 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
myLastWinSize = theWinSize;
}
//=============================================================================
// Function: MarkDirty
// Purpose :
//=============================================================================
//=================================================================================================
void SelectMgr_SelectableObjectSet::MarkDirty()
{
myIsDirty[BVHSubset_3d] = Standard_True;
@@ -476,29 +495,30 @@ void SelectMgr_SelectableObjectSet::MarkDirty()
myIsDirty[BVHSubset_ortho3dPersistent] = Standard_True;
myIsDirty[BVHSubset_ortho2dPersistent] = Standard_True;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void SelectMgr_SelectableObjectSet::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
//=================================================================================================
void SelectMgr_SelectableObjectSet::DumpJson(Standard_OStream& theOStream, Standard_Integer) const
{
for (Standard_Integer aSubsetIdx = 0; aSubsetIdx < BVHSubsetNb; ++aSubsetIdx)
{
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aSubsetIdx)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, aSubsetIdx)
Standard_Boolean IsDirty = myIsDirty[aSubsetIdx];
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsDirty)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, IsDirty)
for (NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)>::Iterator anObjectIt (myObjects[aSubsetIdx]);
anObjectIt.More(); anObjectIt.Next())
for (NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)>::Iterator anObjectIt(
myObjects[aSubsetIdx]);
anObjectIt.More();
anObjectIt.Next())
{
const Handle(SelectMgr_SelectableObject)& SelectableObject = anObjectIt.Value();
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, SelectableObject.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, SelectableObject.get())
}
TCollection_AsciiString separator;
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, separator)
OCCT_DUMP_FIELD_VALUE_STRING(theOStream, separator)
}
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLastWinSize.x())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLastWinSize.y())
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myLastWinSize.x())
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myLastWinSize.y())
}

View File

@@ -20,37 +20,39 @@
#include <Select3D_BVHBuilder3d.hxx>
#include <SelectMgr_SelectableObject.hxx>
//! The purpose of this class is to organize all selectable objects into data structure, allowing to build
//! set of BVH trees for each transformation persistence subclass of selectable objects. This allow to minify
//! number of updates for BVH trees - for example 2D persistent object subclass depends only on camera's projection
//! and the corresponding BVH tree needs to be updated when camera's projection parameters change, while another
//! tree for non-persistent objects can be left unchanged in this case.
//! The purpose of this class is to organize all selectable objects into data structure, allowing to
//! build set of BVH trees for each transformation persistence subclass of selectable objects. This
//! allow to minify number of updates for BVH trees - for example 2D persistent object subclass
//! depends only on camera's projection and the corresponding BVH tree needs to be updated when
//! camera's projection parameters change, while another tree for non-persistent objects can be left
//! unchanged in this case.
class SelectMgr_SelectableObjectSet
{
public:
//! This enumeration declares names for subsets of selectable objects. Each subset has independent BVH tree.
//! The class maintains subsets of selectable objects by their persistence flag. This allows to restric
//! rebuilding of the trees for particular subset when the camera change does not implicitly require it:
//! - BVHSubset_3d refers to the subset of normal world-space 3D objects. Associated BVH tree does not depend
//! on the camera's state at all.
//! This subset uses binned BVH builder with 32 bins and 1 element per leaf.
//! - BVHSubset_3dPersistent refers to the subset of 3D persistent selectable objects (rotate, pan, zoom persistence).
//! Associated BVH tree needs to be updated when either the camera's projection and position change.
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
//! - BVHSubset_2dPersistent refers to the subset of 2D persistent selectable objects. Associated BVH tree
//! needs to be updated only when camera's projection changes. Bounding volumes for this object subclass
//! is represented directly in eye space coordinates.
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
//! - BVHSubset_ortho3dPersistent refers to the subset of 3D persistent selectable objects (rotate, pan, zoom persistence)
//! that contains `Graphic3d_TMF_OrthoPers` persistence mode.
//! Associated BVH tree needs to be updated when either the camera's projection and position change.
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
//! This enumeration declares names for subsets of selectable objects. Each subset has independent
//! BVH tree. The class maintains subsets of selectable objects by their persistence flag. This
//! allows to restric rebuilding of the trees for particular subset when the camera change does
//! not implicitly require it:
//! - BVHSubset_3d refers to the subset of normal world-space 3D objects. Associated BVH tree does
//! not depend on the camera's state at all. This subset uses binned BVH builder with 32 bins and
//! 1 element per leaf.
//! - BVHSubset_3dPersistent refers to the subset of 3D persistent selectable objects (rotate,
//! pan, zoom persistence). Associated BVH tree needs to be updated when either the camera's
//! projection and position change. This subset uses linear BVH builder with 32 levels of depth
//! and 1 element per leaf.
//! - BVHSubset_2dPersistent refers to the subset of 2D persistent selectable objects. Associated
//! BVH tree needs to be updated only when camera's projection changes. Bounding volumes for this
//! object subclass is represented directly in eye space coordinates. This subset uses linear BVH
//! builder with 32 levels of depth and 1 element per leaf.
//! - BVHSubset_ortho3dPersistent refers to the subset of 3D persistent selectable objects
//! (rotate, pan, zoom persistence) that contains `Graphic3d_TMF_OrthoPers` persistence mode.
//! Associated BVH tree needs to be updated when either the camera's projection and position
//! change. This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
//! - BVHSubset_ortho2dPersistent refers to the subset of 2D persistent selectable objects
//! that contains `Graphic3d_TMF_OrthoPers` persistence mode. Associated BVH tree
//! needs to be updated only when camera's projection changes. Bounding volumes for this object subclass
//! is represented directly in eye space coordinates.
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
//! needs to be updated only when camera's projection changes. Bounding volumes for this object
//! subclass is represented directly in eye space coordinates. This subset uses linear BVH builder
//! with 32 levels of depth and 1 element per leaf.
enum BVHSubset
{
BVHSubset_3d,
@@ -62,7 +64,6 @@ public:
};
public:
//! Class to iterate sequentually over all objects from every subset.
class Iterator
{
@@ -70,19 +71,22 @@ public:
typedef NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)>::Iterator ObjectMapIterator;
public:
//! Default constructor without initialization.
Iterator() : mySet (NULL), mySubsetIdx (BVHSubsetNb) {}
Iterator()
: mySet(NULL),
mySubsetIdx(BVHSubsetNb)
{
}
//! Constructs and initializes the iterator.
Iterator (const SelectMgr_SelectableObjectSet& theSet) { Init (theSet); }
Iterator(const SelectMgr_SelectableObjectSet& theSet) { Init(theSet); }
//! Initializes the iterator.
void Init (const SelectMgr_SelectableObjectSet& theSet)
void Init(const SelectMgr_SelectableObjectSet& theSet)
{
mySet = &theSet;
mySubsetIdx = 0;
mySubsetIt = ObjectMapIterator (theSet.myObjects[mySubsetIdx]);
mySubsetIt = ObjectMapIterator(theSet.myObjects[mySubsetIdx]);
More();
}
@@ -97,7 +101,7 @@ public:
{
return Standard_False;
}
mySubsetIt = ObjectMapIterator (mySet->myObjects[++mySubsetIdx]);
mySubsetIt = ObjectMapIterator(mySet->myObjects[++mySubsetIdx]);
return More();
}
@@ -109,95 +113,95 @@ public:
private:
const SelectMgr_SelectableObjectSet* mySet;
Standard_Integer mySubsetIdx;
ObjectMapIterator mySubsetIt;
Standard_Integer mySubsetIdx;
ObjectMapIterator mySubsetIt;
};
public:
//! Creates new empty objects set and initializes BVH tree builders for each subset.
Standard_EXPORT SelectMgr_SelectableObjectSet();
//! Releases resources of selectable object set.
virtual ~SelectMgr_SelectableObjectSet() { }
virtual ~SelectMgr_SelectableObjectSet() {}
//! Adds the new selectable object to the set. The selectable object is placed into one of the
//! predefined subsets depending on its persistence type. After adding an object, this method
//! marks the corresponding BVH tree for rebuild.
//! @return true if selectable object is added, otherwise returns false (selectable object is already in the set).
Standard_EXPORT Standard_Boolean Append (const Handle(SelectMgr_SelectableObject)& theObject);
//! @return true if selectable object is added, otherwise returns false (selectable object is
//! already in the set).
Standard_EXPORT Standard_Boolean Append(const Handle(SelectMgr_SelectableObject)& theObject);
//! Removes the selectable object from the set. The selectable object is removed from the subset
//! it has been placed into. After removing an object, this method marks the corresponding
//! BVH tree for rebuild.
//! @return true if selectable object is removed, otherwise returns false (selectable object is not in the set).
Standard_EXPORT Standard_Boolean Remove (const Handle(SelectMgr_SelectableObject)& theObject);
//! @return true if selectable object is removed, otherwise returns false (selectable object is
//! not in the set).
Standard_EXPORT Standard_Boolean Remove(const Handle(SelectMgr_SelectableObject)& theObject);
//! Performs necessary updates when object's persistence types changes.
//! This method should be called right after changing transformation persistence flags of the
//! objects and before updating BVH tree - to provide up-to-date state of the object set.
Standard_EXPORT void ChangeSubset (const Handle(SelectMgr_SelectableObject)& theObject);
Standard_EXPORT void ChangeSubset(const Handle(SelectMgr_SelectableObject)& theObject);
//! Updates outdated BVH trees and remembers the last state of the
//! camera view-projection matrices and viewport (window) dimensions.
Standard_EXPORT void UpdateBVH (const Handle(Graphic3d_Camera)& theCam,
const Graphic3d_Vec2i& theWinSize);
Standard_EXPORT void UpdateBVH(const Handle(Graphic3d_Camera)& theCam,
const Graphic3d_Vec2i& theWinSize);
//! Marks every BVH subset for update.
Standard_EXPORT void MarkDirty();
//! Returns true if this objects set contains theObject given.
Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const
Standard_Boolean Contains(const Handle(SelectMgr_SelectableObject)& theObject) const
{
return myObjects[BVHSubset_3d].Contains (theObject)
|| myObjects[BVHSubset_3dPersistent].Contains (theObject)
|| myObjects[BVHSubset_2dPersistent].Contains (theObject)
|| myObjects[BVHSubset_ortho3dPersistent].Contains (theObject)
|| myObjects[BVHSubset_ortho2dPersistent].Contains (theObject);
return myObjects[BVHSubset_3d].Contains(theObject)
|| myObjects[BVHSubset_3dPersistent].Contains(theObject)
|| myObjects[BVHSubset_2dPersistent].Contains(theObject)
|| myObjects[BVHSubset_ortho3dPersistent].Contains(theObject)
|| myObjects[BVHSubset_ortho2dPersistent].Contains(theObject);
}
//! Returns true if the object set does not contain any selectable objects.
Standard_Boolean IsEmpty() const
{
return myObjects[BVHSubset_3d].IsEmpty()
&& myObjects[BVHSubset_3dPersistent].IsEmpty()
&& myObjects[BVHSubset_2dPersistent].IsEmpty()
&& myObjects[BVHSubset_ortho3dPersistent].IsEmpty()
&& myObjects[BVHSubset_ortho2dPersistent].IsEmpty();
return myObjects[BVHSubset_3d].IsEmpty() && myObjects[BVHSubset_3dPersistent].IsEmpty()
&& myObjects[BVHSubset_2dPersistent].IsEmpty()
&& myObjects[BVHSubset_ortho3dPersistent].IsEmpty()
&& myObjects[BVHSubset_ortho2dPersistent].IsEmpty();
}
//! Returns true if the specified object subset is empty.
Standard_Boolean IsEmpty (const BVHSubset theSubset) const
Standard_Boolean IsEmpty(const BVHSubset theSubset) const
{
return myObjects[theSubset].IsEmpty();
}
//! Returns object from subset theSubset by theIndex given. The method allows to get selectable object
//! referred by the index of an element of the subset's BVH tree.
const Handle(SelectMgr_SelectableObject)& GetObjectById (const BVHSubset theSubset,
const Standard_Integer theIndex) const
//! Returns object from subset theSubset by theIndex given. The method allows to get selectable
//! object referred by the index of an element of the subset's BVH tree.
const Handle(SelectMgr_SelectableObject)& GetObjectById(const BVHSubset theSubset,
const Standard_Integer theIndex) const
{
return myObjects[theSubset].FindKey (theIndex + 1);
return myObjects[theSubset].FindKey(theIndex + 1);
}
//! Returns computed BVH for the theSubset given.
const opencascade::handle<BVH_Tree<Standard_Real, 3> >& BVH(const BVHSubset theSubset) const
const opencascade::handle<BVH_Tree<Standard_Real, 3>>& BVH(const BVHSubset theSubset) const
{
return myBVH[theSubset];
}
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
Standard_EXPORT void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
private:
//! Returns an appropriate subset of theObject given depending on its persistence type.
Standard_Integer appropriateSubset (const Handle(SelectMgr_SelectableObject)& theObject)
Standard_Integer appropriateSubset(const Handle(SelectMgr_SelectableObject)& theObject)
{
if (theObject->TransformPersistence().IsNull())
{
const PrsMgr_Presentations& aPresentations = theObject->Presentations();
for (PrsMgr_Presentations::Iterator aPrsIter (aPresentations); aPrsIter.More(); aPrsIter.Next())
for (PrsMgr_Presentations::Iterator aPrsIter(aPresentations); aPrsIter.More();
aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue();
if (aPrs3d->CStructure()->HasGroupTransformPersistence())
@@ -226,11 +230,11 @@ private:
}
//! Returns current subset of theObject given.
Standard_Integer currentSubset (const Handle(SelectMgr_SelectableObject)& theObject)
Standard_Integer currentSubset(const Handle(SelectMgr_SelectableObject)& theObject)
{
for (Standard_Integer aSubsetIdx = 0; aSubsetIdx < BVHSubsetNb; ++aSubsetIdx)
{
if (myObjects[aSubsetIdx].Contains (theObject))
if (myObjects[aSubsetIdx].Contains(theObject))
{
return aSubsetIdx;
}
@@ -239,15 +243,14 @@ private:
}
private:
// clang-format off
// clang-format off
NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)> myObjects[BVHSubsetNb]; //!< Map of objects for each subset
opencascade::handle<BVH_Tree<Standard_Real, 3> > myBVH[BVHSubsetNb]; //!< BVH tree computed for each subset
Handle(Select3D_BVHBuilder3d) myBuilder[BVHSubsetNb]; //!< Builder allocated for each subset
Standard_Boolean myIsDirty[BVHSubsetNb]; //!< Dirty flag for each subset
Graphic3d_WorldViewProjState myLastViewState; //!< Last view-projection state used for construction of BVH
Graphic3d_Vec2i myLastWinSize; //!< Last viewport's (window's) width used for construction of BVH
// clang-format on
// clang-format on
friend class Iterator;
};

View File

@@ -28,8 +28,8 @@
// purpose : Creates instances of all available selecting volume types
//=======================================================================
SelectMgr_SelectingVolumeManager::SelectMgr_SelectingVolumeManager()
: myActiveSelectingVolume (NULL),
myToAllowOverlap (Standard_False)
: myActiveSelectingVolume(NULL),
myToAllowOverlap(Standard_False)
{
}
@@ -48,9 +48,10 @@ SelectMgr_SelectingVolumeManager::SelectMgr_SelectingVolumeManager()
// re-constructing transformed frustum from scratch. Can be null if reconstruction
// is not needed furthermore in the code.
//=======================================================================
SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTransform (const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTransform(
const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
{
SelectMgr_SelectingVolumeManager aMgr;
if (myActiveSelectingVolume.IsNull())
@@ -58,41 +59,42 @@ SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTrans
return aMgr;
}
aMgr.myActiveSelectingVolume = myActiveSelectingVolume->ScaleAndTransform (theScaleFactor, theTrsf, theBuilder);
aMgr.myToAllowOverlap = myToAllowOverlap;
aMgr.myViewClipPlanes = myViewClipPlanes;
aMgr.myActiveSelectingVolume =
myActiveSelectingVolume->ScaleAndTransform(theScaleFactor, theTrsf, theBuilder);
aMgr.myToAllowOverlap = myToAllowOverlap;
aMgr.myViewClipPlanes = myViewClipPlanes;
aMgr.myObjectClipPlanes = myObjectClipPlanes;
aMgr.myViewClipRange = myViewClipRange;
aMgr.myViewClipRange = myViewClipRange;
return aMgr;
}
//=======================================================================
// function : CopyWithBuilder
// purpose : Returns a copy of the selecting volume manager and its active frustum re-constructed using the passed builder.
// Builder is an argument that represents corresponding settings for re-constructing transformed
// frustum from scratch.
// purpose : Returns a copy of the selecting volume manager and its active frustum re-constructed
// using the passed builder.
// Builder is an argument that represents corresponding settings for re-constructing
// transformed frustum from scratch.
//=======================================================================
SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::CopyWithBuilder(
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
{
SelectMgr_SelectingVolumeManager aMgr;
aMgr.myToAllowOverlap = myToAllowOverlap;
aMgr.myViewClipPlanes = myViewClipPlanes;
aMgr.myToAllowOverlap = myToAllowOverlap;
aMgr.myViewClipPlanes = myViewClipPlanes;
aMgr.myObjectClipPlanes = myObjectClipPlanes;
aMgr.myViewClipRange = myViewClipRange;
aMgr.myViewClipRange = myViewClipRange;
if (!myActiveSelectingVolume.IsNull())
{
aMgr.myActiveSelectingVolume = myActiveSelectingVolume->CopyWithBuilder (theBuilder);
aMgr.myActiveSelectingVolume = myActiveSelectingVolume->CopyWithBuilder(theBuilder);
aMgr.BuildSelectingVolume();
}
return aMgr;
}
//=======================================================================
// function : GetActiveSelectionType
// purpose :
//=======================================================================
//=================================================================================================
Standard_Integer SelectMgr_SelectingVolumeManager::GetActiveSelectionType() const
{
if (myActiveSelectingVolume.IsNull())
@@ -102,10 +104,8 @@ Standard_Integer SelectMgr_SelectingVolumeManager::GetActiveSelectionType() cons
return myActiveSelectingVolume->GetSelectionType();
}
//=======================================================================
// function : Camera
// purpose :
//=======================================================================
//=================================================================================================
const Handle(Graphic3d_Camera)& SelectMgr_SelectingVolumeManager::Camera() const
{
if (myActiveSelectingVolume.IsNull())
@@ -116,177 +116,167 @@ const Handle(Graphic3d_Camera)& SelectMgr_SelectingVolumeManager::Camera() const
return myActiveSelectingVolume->Camera();
}
//=======================================================================
// function : SetCamera
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::SetCamera(const Handle(Graphic3d_Camera)& theCamera)
{
Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
"SelectMgr_SelectingVolumeManager::SetCamera() should be called after initialization of selection volume ");
myActiveSelectingVolume->SetCamera (theCamera);
"SelectMgr_SelectingVolumeManager::SetCamera() should be called after "
"initialization of selection volume ");
myActiveSelectingVolume->SetCamera(theCamera);
}
//=======================================================================
// function : WindowSize
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const
//=================================================================================================
void SelectMgr_SelectingVolumeManager::WindowSize(Standard_Integer& theWidth,
Standard_Integer& theHeight) const
{
if (myActiveSelectingVolume.IsNull())
{
return;
}
myActiveSelectingVolume->WindowSize (theWidth, theHeight);
myActiveSelectingVolume->WindowSize(theWidth, theHeight);
}
//=======================================================================
// function : SetWindowSize
// purpose : Updates window size in all selecting volumes
//=======================================================================
void SelectMgr_SelectingVolumeManager::SetWindowSize (const Standard_Integer theWidth,
const Standard_Integer theHeight)
void SelectMgr_SelectingVolumeManager::SetWindowSize(const Standard_Integer theWidth,
const Standard_Integer theHeight)
{
Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
"SelectMgr_SelectingVolumeManager::SetWindowSize() should be called after initialization of selection volume ");
myActiveSelectingVolume->SetWindowSize (theWidth, theHeight);
"SelectMgr_SelectingVolumeManager::SetWindowSize() should be called after "
"initialization of selection volume ");
myActiveSelectingVolume->SetWindowSize(theWidth, theHeight);
}
//=======================================================================
// function : SetCamera
// purpose : Updates viewport in all selecting volumes
//=======================================================================
void SelectMgr_SelectingVolumeManager::SetViewport (const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight)
void SelectMgr_SelectingVolumeManager::SetViewport(const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight)
{
Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
"SelectMgr_SelectingVolumeManager::SetViewport() should be called after initialization of selection volume ");
myActiveSelectingVolume->SetViewport (theX, theY, theWidth, theHeight);
"SelectMgr_SelectingVolumeManager::SetViewport() should be called after "
"initialization of selection volume ");
myActiveSelectingVolume->SetViewport(theX, theY, theWidth, theHeight);
}
//=======================================================================
// function : SetPixelTolerance
// purpose : Updates pixel tolerance in all selecting volumes
//=======================================================================
void SelectMgr_SelectingVolumeManager::SetPixelTolerance (const Standard_Integer theTolerance)
void SelectMgr_SelectingVolumeManager::SetPixelTolerance(const Standard_Integer theTolerance)
{
Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
"SelectMgr_SelectingVolumeManager::SetPixelTolerance() should be called after initialization of selection volume ");
myActiveSelectingVolume->SetPixelTolerance (theTolerance);
"SelectMgr_SelectingVolumeManager::SetPixelTolerance() should be called "
"after initialization of selection volume ");
myActiveSelectingVolume->SetPixelTolerance(theTolerance);
}
//=======================================================================
// function : InitPointSelectingVolume
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::InitPointSelectingVolume (const gp_Pnt2d& thePoint)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::InitPointSelectingVolume(const gp_Pnt2d& thePoint)
{
Handle(SelectMgr_RectangularFrustum) aPntVolume = Handle(SelectMgr_RectangularFrustum)::DownCast(myActiveSelectingVolume);
Handle(SelectMgr_RectangularFrustum) aPntVolume =
Handle(SelectMgr_RectangularFrustum)::DownCast(myActiveSelectingVolume);
if (aPntVolume.IsNull())
{
aPntVolume = new SelectMgr_RectangularFrustum();
}
aPntVolume->Init (thePoint);
aPntVolume->Init(thePoint);
myActiveSelectingVolume = aPntVolume;
}
//=======================================================================
// function : InitBoxSelectingVolume
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::InitBoxSelectingVolume (const gp_Pnt2d& theMinPt,
const gp_Pnt2d& theMaxPt)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::InitBoxSelectingVolume(const gp_Pnt2d& theMinPt,
const gp_Pnt2d& theMaxPt)
{
Handle(SelectMgr_RectangularFrustum) aBoxVolume = Handle(SelectMgr_RectangularFrustum)::DownCast(myActiveSelectingVolume);
Handle(SelectMgr_RectangularFrustum) aBoxVolume =
Handle(SelectMgr_RectangularFrustum)::DownCast(myActiveSelectingVolume);
if (aBoxVolume.IsNull())
{
aBoxVolume = new SelectMgr_RectangularFrustum();
}
aBoxVolume->Init (theMinPt, theMaxPt);
aBoxVolume->Init(theMinPt, theMaxPt);
myActiveSelectingVolume = aBoxVolume;
}
//=======================================================================
// function : InitPolylineSelectingVolume
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::InitPolylineSelectingVolume (const TColgp_Array1OfPnt2d& thePoints)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::InitPolylineSelectingVolume(
const TColgp_Array1OfPnt2d& thePoints)
{
Handle(SelectMgr_TriangularFrustumSet) aPolylineVolume = Handle(SelectMgr_TriangularFrustumSet)::DownCast(myActiveSelectingVolume);
Handle(SelectMgr_TriangularFrustumSet) aPolylineVolume =
Handle(SelectMgr_TriangularFrustumSet)::DownCast(myActiveSelectingVolume);
if (aPolylineVolume.IsNull())
{
aPolylineVolume = new SelectMgr_TriangularFrustumSet();
}
aPolylineVolume->Init (thePoints);
aPolylineVolume->Init(thePoints);
myActiveSelectingVolume = aPolylineVolume;
aPolylineVolume->SetAllowOverlapDetection (IsOverlapAllowed());
aPolylineVolume->SetAllowOverlapDetection(IsOverlapAllowed());
}
//=======================================================================
// function : InitAxisSelectingVolume
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::InitAxisSelectingVolume (const gp_Ax1& theAxis)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::InitAxisSelectingVolume(const gp_Ax1& theAxis)
{
Handle(SelectMgr_AxisIntersector) anAxisVolume = Handle(SelectMgr_AxisIntersector)::DownCast(myActiveSelectingVolume);
Handle(SelectMgr_AxisIntersector) anAxisVolume =
Handle(SelectMgr_AxisIntersector)::DownCast(myActiveSelectingVolume);
if (anAxisVolume.IsNull())
{
anAxisVolume = new SelectMgr_AxisIntersector();
}
anAxisVolume->Init (theAxis);
anAxisVolume->Init(theAxis);
myActiveSelectingVolume = anAxisVolume;
}
//=======================================================================
// function : InitSelectingVolume
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::InitSelectingVolume(const Handle(SelectMgr_BaseIntersector)& theVolume)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::InitSelectingVolume(
const Handle(SelectMgr_BaseIntersector)& theVolume)
{
myActiveSelectingVolume = theVolume;
}
//=======================================================================
// function : BuildSelectingVolume
// purpose :
//=======================================================================
//=================================================================================================
void SelectMgr_SelectingVolumeManager::BuildSelectingVolume()
{
Standard_ASSERT_RAISE (!myActiveSelectingVolume.IsNull(),
"SelectMgr_SelectingVolumeManager::BuildSelectingVolume() should be called after initialization of active selection volume.");
Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
"SelectMgr_SelectingVolumeManager::BuildSelectingVolume() should be called "
"after initialization of active selection volume.");
myActiveSelectingVolume->Build();
}
//=======================================================================
// function : BuildSelectingVolume
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const gp_Pnt2d& thePoint)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::BuildSelectingVolume(const gp_Pnt2d& thePoint)
{
InitPointSelectingVolume (thePoint);
InitPointSelectingVolume(thePoint);
myActiveSelectingVolume->Build();
}
//=======================================================================
// function : BuildSelectingVolume
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const gp_Pnt2d& theMinPt,
const gp_Pnt2d& theMaxPt)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::BuildSelectingVolume(const gp_Pnt2d& theMinPt,
const gp_Pnt2d& theMaxPt)
{
InitBoxSelectingVolume (theMinPt, theMaxPt);
InitBoxSelectingVolume(theMinPt, theMaxPt);
myActiveSelectingVolume->Build();
}
//=======================================================================
// function : BuildSelectingVolume
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const TColgp_Array1OfPnt2d& thePoints)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::BuildSelectingVolume(const TColgp_Array1OfPnt2d& thePoints)
{
InitPolylineSelectingVolume (thePoints);
InitPolylineSelectingVolume(thePoints);
myActiveSelectingVolume->Build();
}
@@ -295,61 +285,63 @@ void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const TColgp_Array1
// purpose : SAT intersection test between defined volume and
// given axis-aligned box
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
SelectBasics_PickResult& thePickResult) const
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsBox(
const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsBox (theBoxMin, theBoxMax, myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsBox(theBoxMin, theBoxMax, myViewClipRange, thePickResult);
}
//=======================================================================
// function : OverlapsBox
// purpose : Intersection test between defined volume and given point
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside) const
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsBox (theBoxMin, theBoxMax, theInside);
return myActiveSelectingVolume->OverlapsBox(theBoxMin, theBoxMax, theInside);
}
//=======================================================================
// function : OverlapsPoint
// purpose : Intersection test between defined volume and given point
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPoint (const gp_Pnt& thePnt,
SelectBasics_PickResult& thePickResult) const
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPoint(
const gp_Pnt& thePnt,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsPoint (thePnt, myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsPoint(thePnt, myViewClipRange, thePickResult);
}
//=======================================================================
// function : OverlapsPoint
// purpose : Intersection test between defined volume and given point
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPoint (const gp_Pnt& thePnt) const
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPoint(const gp_Pnt& thePnt) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsPoint (thePnt);
return myActiveSelectingVolume->OverlapsPoint(thePnt);
}
//=======================================================================
@@ -359,33 +351,37 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPoint (const gp_Pnt&
// may be considered of interior part or boundary line defined
// by segments depending on given sensitivity type
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
Standard_Integer theSensType,
SelectBasics_PickResult& thePickResult) const
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPolygon(
const TColgp_Array1OfPnt& theArrayOfPnts,
Standard_Integer theSensType,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsPolygon (theArrayOfPnts, (Select3D_TypeOfSensitivity)theSensType,
myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsPolygon(theArrayOfPnts,
(Select3D_TypeOfSensitivity)theSensType,
myViewClipRange,
thePickResult);
}
//=======================================================================
// function : OverlapsSegment
// purpose : Checks if line segment overlaps selecting volume
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsSegment (const gp_Pnt& thePt1,
const gp_Pnt& thePt2,
SelectBasics_PickResult& thePickResult) const
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsSegment(
const gp_Pnt& thePt1,
const gp_Pnt& thePt2,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsSegment (thePt1, thePt2, myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsSegment(thePt1, thePt2, myViewClipRange, thePickResult);
}
//=======================================================================
@@ -395,119 +391,129 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsSegment (const gp_Pnt
// boundary line defined by triangle vertices depending on
// given sensitivity type
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsTriangle (const gp_Pnt& thePt1,
const gp_Pnt& thePt2,
const gp_Pnt& thePt3,
Standard_Integer theSensType,
SelectBasics_PickResult& thePickResult) const
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsTriangle(
const gp_Pnt& thePt1,
const gp_Pnt& thePt2,
const gp_Pnt& thePt3,
Standard_Integer theSensType,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsTriangle (thePt1, thePt2, thePt3, (Select3D_TypeOfSensitivity)theSensType,
myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsTriangle(thePt1,
thePt2,
thePt3,
(Select3D_TypeOfSensitivity)theSensType,
myViewClipRange,
thePickResult);
}
//=======================================================================
// function : OverlapsSphere
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
SelectBasics_PickResult& thePickResult) const
//=================================================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsSphere (theCenter, theRadius, myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsSphere(theCenter,
theRadius,
myViewClipRange,
thePickResult);
}
//=======================================================================
// function : OverlapsSphere
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside) const
//=================================================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsSphere(const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside) const
{
if (myActiveSelectingVolume.IsNull())
{
return Standard_False;
}
return myActiveSelectingVolume->OverlapsSphere (theCenter, theRadius, theInside);
return myActiveSelectingVolume->OverlapsSphere(theCenter, theRadius, theInside);
}
//=======================================================================
// function : OverlapsCylinder
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
SelectBasics_PickResult& thePickResult) const
//=================================================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return false;
}
return myActiveSelectingVolume->OverlapsCylinder (theBottomRad, theTopRad, theHeight, theTrsf,
theIsHollow, myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsCylinder(theBottomRad,
theTopRad,
theHeight,
theTrsf,
theIsHollow,
myViewClipRange,
thePickResult);
}
//=======================================================================
// function : OverlapsCylinder
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
//=================================================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
if (myActiveSelectingVolume.IsNull())
{
return false;
}
return myActiveSelectingVolume->OverlapsCylinder (theBottomRad, theTopRad, theHeight,
theTrsf, theIsHollow, theInside);
return myActiveSelectingVolume
->OverlapsCylinder(theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow, theInside);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
SelectBasics_PickResult& thePickResult) const
//=================================================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCircle(
const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return false;
}
return myActiveSelectingVolume->OverlapsCircle (theRadius, theTrsf, theIsFilled, myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsCircle(theRadius,
theTrsf,
theIsFilled,
myViewClipRange,
thePickResult);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
//=================================================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCircle(
const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
{
if (myActiveSelectingVolume.IsNull())
{
return false;
}
return myActiveSelectingVolume->OverlapsCircle (theRadius, theTrsf, theIsFilled, theInside);
return myActiveSelectingVolume->OverlapsCircle(theRadius, theTrsf, theIsFilled, theInside);
}
//=======================================================================
@@ -515,13 +521,13 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCircle (const Standar
// purpose : Measures distance between 3d projection of user-picked
// screen point and given point theCOG
//=======================================================================
Standard_Real SelectMgr_SelectingVolumeManager::DistToGeometryCenter (const gp_Pnt& theCOG) const
Standard_Real SelectMgr_SelectingVolumeManager::DistToGeometryCenter(const gp_Pnt& theCOG) const
{
if (myActiveSelectingVolume.IsNull())
{
return RealLast();
}
return myActiveSelectingVolume->DistToGeometryCenter (theCOG);
return myActiveSelectingVolume->DistToGeometryCenter(theCOG);
}
// =======================================================================
@@ -530,11 +536,12 @@ Standard_Real SelectMgr_SelectingVolumeManager::DistToGeometryCenter (const gp_P
// the run of selection algo by given depth. Is valid for point
// selection only
// =======================================================================
gp_Pnt SelectMgr_SelectingVolumeManager::DetectedPoint (const Standard_Real theDepth) const
gp_Pnt SelectMgr_SelectingVolumeManager::DetectedPoint(const Standard_Real theDepth) const
{
Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
"SelectMgr_SelectingVolumeManager::DetectedPoint() should be called after initialization of selection volume");
return myActiveSelectingVolume->DetectedPoint (theDepth);
"SelectMgr_SelectingVolumeManager::DetectedPoint() should be called after "
"initialization of selection volume");
return myActiveSelectingVolume->DetectedPoint(theDepth);
}
//=======================================================================
@@ -543,24 +550,20 @@ gp_Pnt SelectMgr_SelectingVolumeManager::DetectedPoint (const Standard_Real theD
// be detected, otherwise the algorithm will mark both included
// and overlapped entities as matched
//=======================================================================
void SelectMgr_SelectingVolumeManager::AllowOverlapDetection (const Standard_Boolean theIsToAllow)
void SelectMgr_SelectingVolumeManager::AllowOverlapDetection(const Standard_Boolean theIsToAllow)
{
myToAllowOverlap = theIsToAllow;
}
//=======================================================================
// function : IsOverlapAllowed
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::IsOverlapAllowed() const
{
return myToAllowOverlap || GetActiveSelectionType() == SelectMgr_SelectionType_Point;
}
//=======================================================================
// function : GetVertices
// purpose :
//=======================================================================
//=================================================================================================
const gp_Pnt* SelectMgr_SelectingVolumeManager::GetVertices() const
{
if (myActiveSelectingVolume.IsNull())
@@ -568,7 +571,7 @@ const gp_Pnt* SelectMgr_SelectingVolumeManager::GetVertices() const
return NULL;
}
const SelectMgr_RectangularFrustum* aRectFrustum =
static_cast<const SelectMgr_RectangularFrustum*> (myActiveSelectingVolume.get());
static_cast<const SelectMgr_RectangularFrustum*>(myActiveSelectingVolume.get());
if (aRectFrustum == NULL)
{
return NULL;
@@ -576,10 +579,8 @@ const gp_Pnt* SelectMgr_SelectingVolumeManager::GetVertices() const
return aRectFrustum->GetVertices();
}
//=======================================================================
// function : GetNearPickedPnt
// purpose :
//=======================================================================
//=================================================================================================
gp_Pnt SelectMgr_SelectingVolumeManager::GetNearPickedPnt() const
{
if (myActiveSelectingVolume.IsNull())
@@ -589,10 +590,8 @@ gp_Pnt SelectMgr_SelectingVolumeManager::GetNearPickedPnt() const
return myActiveSelectingVolume->GetNearPnt();
}
//=======================================================================
// function : GetFarPickedPnt
// purpose :
//=======================================================================
//=================================================================================================
gp_Pnt SelectMgr_SelectingVolumeManager::GetFarPickedPnt() const
{
if (myActiveSelectingVolume.IsNull())
@@ -602,10 +601,8 @@ gp_Pnt SelectMgr_SelectingVolumeManager::GetFarPickedPnt() const
return myActiveSelectingVolume->GetFarPnt();
}
//=======================================================================
// function : GetViewRayDirection
// purpose :
//=======================================================================
//=================================================================================================
gp_Dir SelectMgr_SelectingVolumeManager::GetViewRayDirection() const
{
if (myActiveSelectingVolume.IsNull())
@@ -615,10 +612,8 @@ gp_Dir SelectMgr_SelectingVolumeManager::GetViewRayDirection() const
return myActiveSelectingVolume->GetViewRayDirection();
}
//=======================================================================
// function : IsScalableActiveVolume
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::IsScalableActiveVolume() const
{
if (myActiveSelectingVolume.IsNull())
@@ -628,10 +623,8 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::IsScalableActiveVolume() cons
return myActiveSelectingVolume->IsScalable();
}
//=======================================================================
// function : GetMousePosition
// purpose :
//=======================================================================
//=================================================================================================
gp_Pnt2d SelectMgr_SelectingVolumeManager::GetMousePosition() const
{
if (myActiveSelectingVolume.IsNull())
@@ -641,27 +634,25 @@ gp_Pnt2d SelectMgr_SelectingVolumeManager::GetMousePosition() const
return myActiveSelectingVolume->GetMousePosition();
}
//=======================================================================
// function : GetPlanes
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
//=================================================================================================
void SelectMgr_SelectingVolumeManager::GetPlanes(
NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
{
if (myActiveSelectingVolume.IsNull())
{
thePlaneEquations.Clear();
return;
}
return myActiveSelectingVolume->GetPlanes (thePlaneEquations);
return myActiveSelectingVolume->GetPlanes(thePlaneEquations);
}
//=======================================================================
// function : SetViewClipping
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes,
const SelectMgr_SelectingVolumeManager* theWorldSelMgr)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::SetViewClipping(
const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes,
const SelectMgr_SelectingVolumeManager* theWorldSelMgr)
{
myViewClipPlanes = theViewPlanes;
myObjectClipPlanes = theObjPlanes;
@@ -670,47 +661,46 @@ void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_S
return;
}
const SelectMgr_SelectingVolumeManager* aWorldSelMgr = theWorldSelMgr != NULL ? theWorldSelMgr : this;
const SelectMgr_SelectingVolumeManager* aWorldSelMgr =
theWorldSelMgr != NULL ? theWorldSelMgr : this;
myViewClipRange.SetVoid();
if (!theViewPlanes.IsNull()
&& !theViewPlanes->IsEmpty())
if (!theViewPlanes.IsNull() && !theViewPlanes->IsEmpty())
{
myViewClipRange.AddClippingPlanes (*theViewPlanes,
myViewClipRange.AddClippingPlanes(
*theViewPlanes,
gp_Ax1(aWorldSelMgr->myActiveSelectingVolume->GetNearPnt(),
aWorldSelMgr->myActiveSelectingVolume->GetViewRayDirection()));
}
if (!theObjPlanes.IsNull()
&& !theObjPlanes->IsEmpty())
if (!theObjPlanes.IsNull() && !theObjPlanes->IsEmpty())
{
myViewClipRange.AddClippingPlanes (*theObjPlanes,
myViewClipRange.AddClippingPlanes(
*theObjPlanes,
gp_Ax1(aWorldSelMgr->myActiveSelectingVolume->GetNearPnt(),
aWorldSelMgr->myActiveSelectingVolume->GetViewRayDirection()));
}
}
//=======================================================================
// function : SetViewClipping
// purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther)
//=================================================================================================
void SelectMgr_SelectingVolumeManager::SetViewClipping(
const SelectMgr_SelectingVolumeManager& theOther)
{
myViewClipPlanes = theOther.myViewClipPlanes;
myObjectClipPlanes = theOther.myObjectClipPlanes;
myViewClipRange = theOther.myViewClipRange;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void SelectMgr_SelectingVolumeManager::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
//=================================================================================================
void SelectMgr_SelectingVolumeManager::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_SelectingVolumeManager)
OCCT_DUMP_CLASS_BEGIN(theOStream, SelectMgr_SelectingVolumeManager)
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myActiveSelectingVolume.get())
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myViewClipPlanes.get())
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myObjectClipPlanes.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myActiveSelectingVolume.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myViewClipPlanes.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myObjectClipPlanes.get())
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myViewClipRange)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToAllowOverlap)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myViewClipRange)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myToAllowOverlap)
}

View File

@@ -35,27 +35,25 @@
class SelectMgr_SelectingVolumeManager : public SelectBasics_SelectingVolumeManager
{
public:
//! Creates instances of all available selecting volume types
Standard_EXPORT SelectMgr_SelectingVolumeManager();
virtual ~SelectMgr_SelectingVolumeManager() {}
//! Creates, initializes and activates rectangular selecting frustum for point selection
Standard_EXPORT void InitPointSelectingVolume (const gp_Pnt2d& thePoint);
Standard_EXPORT void InitPointSelectingVolume(const gp_Pnt2d& thePoint);
//! Creates, initializes and activates rectangular selecting frustum for box selection
Standard_EXPORT void InitBoxSelectingVolume (const gp_Pnt2d& theMinPt,
const gp_Pnt2d& theMaxPt);
Standard_EXPORT void InitBoxSelectingVolume(const gp_Pnt2d& theMinPt, const gp_Pnt2d& theMaxPt);
//! Creates, initializes and activates set of triangular selecting frustums for polyline selection
Standard_EXPORT void InitPolylineSelectingVolume (const TColgp_Array1OfPnt2d& thePoints);
Standard_EXPORT void InitPolylineSelectingVolume(const TColgp_Array1OfPnt2d& thePoints);
//! Creates and activates axis selector for point selection
Standard_EXPORT void InitAxisSelectingVolume (const gp_Ax1& theAxis);
Standard_EXPORT void InitAxisSelectingVolume(const gp_Ax1& theAxis);
//! Sets as active the custom selecting volume
Standard_EXPORT void InitSelectingVolume (const Handle(SelectMgr_BaseIntersector)& theVolume);
Standard_EXPORT void InitSelectingVolume(const Handle(SelectMgr_BaseIntersector)& theVolume);
//! Builds previously initialized selecting volume.
Standard_EXPORT void BuildSelectingVolume();
@@ -75,145 +73,161 @@ public:
//! There are no default parameters, but in case if:
//! - transformation only is needed: @theScaleFactor must be initialized as any negative value;
//! - scale only is needed: @theTrsf must be set to gp_Identity.
//! Builder is an optional argument that represents corresponding settings for re-constructing transformed
//! frustum from scratch. Can be null if reconstruction is not expected furthermore.
Standard_EXPORT virtual SelectMgr_SelectingVolumeManager ScaleAndTransform (const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const;
//! Builder is an optional argument that represents corresponding settings for re-constructing
//! transformed frustum from scratch. Can be null if reconstruction is not expected furthermore.
Standard_EXPORT virtual SelectMgr_SelectingVolumeManager ScaleAndTransform(
const Standard_Integer theScaleFactor,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const;
//! Returns a copy of the selecting volume manager and its active frustum re-constructed using the passed builder.
//! Builder is an argument that represents corresponding settings for re-constructing transformed
//! frustum from scratch.
Standard_EXPORT virtual SelectMgr_SelectingVolumeManager CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const;
//! Returns a copy of the selecting volume manager and its active frustum re-constructed using the
//! passed builder. Builder is an argument that represents corresponding settings for
//! re-constructing transformed frustum from scratch.
Standard_EXPORT virtual SelectMgr_SelectingVolumeManager CopyWithBuilder(
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const;
public:
//! Returns current camera definition.
Standard_EXPORT const Handle(Graphic3d_Camera)& Camera() const;
//! Updates camera projection and orientation matrices in all selecting volumes
//! Note: this method should be called after selection volume building
//! else exception will be thrown
Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
Standard_EXPORT void SetCamera(const Handle(Graphic3d_Camera)& theCamera);
//! Updates viewport in all selecting volumes
//! Note: this method should be called after selection volume building
//! else exception will be thrown
Standard_EXPORT void SetViewport (const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight);
Standard_EXPORT void SetViewport(const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theWidth,
const Standard_Real theHeight);
//! Updates pixel tolerance in all selecting volumes
//! Note: this method should be called after selection volume building
//! else exception will be thrown
Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance);
Standard_EXPORT void SetPixelTolerance(const Standard_Integer theTolerance);
//! Returns window size
Standard_EXPORT void WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
Standard_EXPORT void WindowSize(Standard_Integer& theWidth, Standard_Integer& theHeight) const;
//! Updates window size in all selecting volumes
//! Note: this method should be called after selection volume building
//! else exception will be thrown
Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight);
Standard_EXPORT void SetWindowSize(const Standard_Integer theWidth,
const Standard_Integer theHeight);
//! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
SelectBasics_PickResult& thePickResult) const
Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint(
const gp_Pnt& thePnt,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint(const gp_Pnt& thePnt) const
Standard_OVERRIDE;
//! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPts,
Standard_Integer theSensType,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon(
const TColgp_Array1OfPnt& theArrayOfPts,
Standard_Integer theSensType,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSegment(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! SAT intersection test between defined volume and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices
//! depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Standard_Integer theSensType,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Standard_Integer theSensType,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined volume and given sphere
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined volume and given sphere
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(
const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked
//! screen point and given point theCOG
Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Real DistToGeometryCenter(const gp_Pnt& theCOG) const
Standard_OVERRIDE;
//! Calculates the point on a view ray that was detected during the run of selection algo by given depth.
//! Throws exception if active selection type is not Point.
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
//! Calculates the point on a view ray that was detected during the run of selection algo by given
//! depth. Throws exception if active selection type is not Point.
Standard_EXPORT virtual gp_Pnt DetectedPoint(const Standard_Real theDepth) const
Standard_OVERRIDE;
//! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will
//! mark both included and overlapped entities as matched
Standard_EXPORT virtual void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
//! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the
//! algorithm will mark both included and overlapped entities as matched
Standard_EXPORT virtual void AllowOverlapDetection(const Standard_Boolean theIsToAllow);
Standard_EXPORT virtual Standard_Boolean IsOverlapAllowed() const Standard_OVERRIDE;
@@ -221,25 +235,28 @@ public:
const Handle(Graphic3d_SequenceOfHClipPlane)& ViewClipping() const { return myViewClipPlanes; }
//! Return object clipping planes.
const Handle(Graphic3d_SequenceOfHClipPlane)& ObjectClipping() const { return myObjectClipPlanes; }
const Handle(Graphic3d_SequenceOfHClipPlane)& ObjectClipping() const
{
return myObjectClipPlanes;
}
//! Valid for point selection only!
//! Computes depth range for clipping planes.
//! @param[in] theViewPlanes global view planes
//! @param[in] theObjPlanes object planes
//! @param[in] theWorldSelMgr selection volume in world space for computing clipping plane ranges
Standard_EXPORT void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes,
const SelectMgr_SelectingVolumeManager* theWorldSelMgr);
Standard_EXPORT void SetViewClipping(const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes,
const SelectMgr_SelectingVolumeManager* theWorldSelMgr);
//! Copy clipping planes from another volume manager.
Standard_EXPORT void SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther);
Standard_EXPORT void SetViewClipping(const SelectMgr_SelectingVolumeManager& theOther);
//! Return clipping range.
const SelectMgr_ViewClipRange& ViewClipRanges() const { return myViewClipRange; }
//! Set clipping range.
void SetViewClipRanges (const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
void SetViewClipRanges(const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
//! A set of helper functions that return rectangular selecting frustum data
Standard_EXPORT const gp_Pnt* GetVertices() const;
@@ -264,36 +281,40 @@ public:
Standard_EXPORT virtual Standard_Boolean IsScalableActiveVolume() const Standard_OVERRIDE;
//! Returns mouse coordinates for Point selection mode.
//! @return infinite point in case of unsupport of mouse position for this active selection volume.
//! @return infinite point in case of unsupport of mouse position for this active selection
//! volume.
Standard_EXPORT virtual gp_Pnt2d GetMousePosition() const Standard_OVERRIDE;
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
Standard_EXPORT virtual void GetPlanes(
NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) 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;
public:
Standard_DEPRECATED(
"Deprecated method - InitPointSelectingVolume() and Build() methods should be used instead")
Standard_EXPORT void BuildSelectingVolume(const gp_Pnt2d& thePoint);
Standard_DEPRECATED("Deprecated method - InitPointSelectingVolume() and Build() methods should be used instead")
Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& thePoint);
Standard_DEPRECATED(
"Deprecated method - InitBoxSelectingVolume() and Build() should be used instead")
Standard_EXPORT void BuildSelectingVolume(const gp_Pnt2d& theMinPt, const gp_Pnt2d& theMaxPt);
Standard_DEPRECATED("Deprecated method - InitBoxSelectingVolume() and Build() should be used instead")
Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& theMinPt,
const gp_Pnt2d& theMaxPt);
Standard_DEPRECATED("Deprecated method - InitPolylineSelectingVolume() and Build() should be used instead")
Standard_EXPORT void BuildSelectingVolume (const TColgp_Array1OfPnt2d& thePoints);
Standard_DEPRECATED(
"Deprecated method - InitPolylineSelectingVolume() and Build() should be used instead")
Standard_EXPORT void BuildSelectingVolume(const TColgp_Array1OfPnt2d& thePoints);
private:
Handle(SelectMgr_BaseIntersector) myActiveSelectingVolume;
// clang-format off
Handle(SelectMgr_BaseIntersector) myActiveSelectingVolume;
// clang-format off
Handle(Graphic3d_SequenceOfHClipPlane) myViewClipPlanes; //!< view clipping planes
Handle(Graphic3d_SequenceOfHClipPlane) myObjectClipPlanes; //!< object clipping planes
SelectMgr_ViewClipRange myViewClipRange;
Standard_Boolean myToAllowOverlap; //!< Defines if partially overlapped entities will me detected or not
// clang-format on
// clang-format on
};
#endif

View File

@@ -19,78 +19,75 @@
#include <SelectMgr_EntityOwner.hxx>
#include <Standard_NullObject.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Selection,Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Selection, Standard_Transient)
//==================================================
// Function: SelectMgr_Selection
// Purpose :
//==================================================
SelectMgr_Selection::SelectMgr_Selection (const Standard_Integer theModeIdx)
: myMode (theModeIdx),
mySelectionState (SelectMgr_SOS_Unknown),
myBVHUpdateStatus (SelectMgr_TBU_None),
mySensFactor (2),
myIsCustomSens (Standard_False)
{}
//=================================================================================================
SelectMgr_Selection::SelectMgr_Selection(const Standard_Integer theModeIdx)
: myMode(theModeIdx),
mySelectionState(SelectMgr_SOS_Unknown),
myBVHUpdateStatus(SelectMgr_TBU_None),
mySensFactor(2),
myIsCustomSens(Standard_False)
{
}
SelectMgr_Selection::~SelectMgr_Selection()
{
Destroy();
}
//==================================================
// Function: Destroy
// Purpose :
//==================================================
//=================================================================================================
void SelectMgr_Selection::Destroy()
{
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anEntityIter(myEntities);
anEntityIter.More();
anEntityIter.Next())
{
Handle(SelectMgr_SensitiveEntity)& anEntity = anEntityIter.ChangeValue();
anEntity->BaseSensitive()->Set (NULL);
anEntity->BaseSensitive()->Set(NULL);
}
mySensFactor = 2;
}
//==================================================
// Function: ADD
// Purpose :
//==================================================
void SelectMgr_Selection::Add (const Handle(Select3D_SensitiveEntity)& theSensitive)
//=================================================================================================
void SelectMgr_Selection::Add(const Handle(Select3D_SensitiveEntity)& theSensitive)
{
// if input is null: in debug mode raise exception
Standard_NullObject_Raise_if (theSensitive.IsNull(), "Null sensitive entity is added to the selection");
Standard_NullObject_Raise_if(theSensitive.IsNull(),
"Null sensitive entity is added to the selection");
if (theSensitive.IsNull())
{
// in release mode do not add
return;
}
Handle(SelectMgr_SensitiveEntity) anEntity = new SelectMgr_SensitiveEntity (theSensitive);
myEntities.Append (anEntity);
if (mySelectionState == SelectMgr_SOS_Activated
&& !anEntity->IsActiveForSelection())
Handle(SelectMgr_SensitiveEntity) anEntity = new SelectMgr_SensitiveEntity(theSensitive);
myEntities.Append(anEntity);
if (mySelectionState == SelectMgr_SOS_Activated && !anEntity->IsActiveForSelection())
{
anEntity->SetActiveForSelection();
}
if (myIsCustomSens)
{
anEntity->BaseSensitive()->SetSensitivityFactor (mySensFactor);
anEntity->BaseSensitive()->SetSensitivityFactor(mySensFactor);
}
else
{
mySensFactor = Max (mySensFactor, anEntity->BaseSensitive()->SensitivityFactor());
mySensFactor = Max(mySensFactor, anEntity->BaseSensitive()->SensitivityFactor());
}
}
}
//=================================================================================================
//==================================================
// Function: Clear
// Purpose :
//==================================================
void SelectMgr_Selection::Clear()
{
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anEntityIter(myEntities);
anEntityIter.More();
anEntityIter.Next())
{
Handle(SelectMgr_SensitiveEntity)& anEntity = anEntityIter.ChangeValue();
anEntity->Clear();
@@ -105,14 +102,16 @@ void SelectMgr_Selection::Clear()
// IMPORTANT: This method does not update any outer selection structures, so for
// proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
//==================================================
void SelectMgr_Selection::SetSensitivity (const Standard_Integer theNewSens)
void SelectMgr_Selection::SetSensitivity(const Standard_Integer theNewSens)
{
mySensFactor = theNewSens;
mySensFactor = theNewSens;
myIsCustomSens = Standard_True;
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anEntityIter (myEntities); anEntityIter.More(); anEntityIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anEntityIter(myEntities);
anEntityIter.More();
anEntityIter.Next())
{
Handle(SelectMgr_SensitiveEntity)& anEntity = anEntityIter.ChangeValue();
anEntity->BaseSensitive()->SetSensitivityFactor (theNewSens);
anEntity->BaseSensitive()->SetSensitivityFactor(theNewSens);
}
}
@@ -120,12 +119,14 @@ void SelectMgr_Selection::SetSensitivity (const Standard_Integer theNewSens)
// function : DumpJson
// purpose :
// =======================================================================
void SelectMgr_Selection::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
void SelectMgr_Selection::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
NCollection_Map<Handle(SelectMgr_EntityOwner)> anOwners;
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIterator(myEntities);
anIterator.More();
anIterator.Next())
{
const Handle(SelectMgr_SensitiveEntity)& anEntity = anIterator.Value();
if (anEntity.IsNull() || anEntity->BaseSensitive().IsNull())
@@ -133,22 +134,24 @@ void SelectMgr_Selection::DumpJson (Standard_OStream& theOStream, Standard_Integ
continue;
}
const Handle(SelectMgr_EntityOwner)& anOwner = anEntity->BaseSensitive()->OwnerId();
if (anOwners.Add (anOwner))
if (anOwners.Add(anOwner))
{
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anOwner.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, anOwner.get())
}
}
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIterator(myEntities);
anIterator.More();
anIterator.Next())
{
const Handle(SelectMgr_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, myMode)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySelectionState)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySensFactor)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUpdateStatus)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myBVHUpdateStatus)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsCustomSens)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myMode)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, mySelectionState)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, mySensFactor)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myUpdateStatus)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myBVHUpdateStatus)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myIsCustomSens)
}

View File

@@ -63,10 +63,9 @@ class SelectMgr_Selection : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection, Standard_Transient)
public:
//! Constructs a selection object defined by the selection mode IdMode.
//! The default setting 0 is the selection mode for a shape in its entirety.
Standard_EXPORT SelectMgr_Selection (const Standard_Integer theModeIdx = 0);
Standard_EXPORT SelectMgr_Selection(const Standard_Integer theModeIdx = 0);
Standard_EXPORT ~SelectMgr_Selection();
@@ -74,7 +73,7 @@ public:
//! Adds the sensitive primitive to the list of stored entities in this object.
//! Raises NullObject if the primitive is a null handle.
Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive);
Standard_EXPORT void Add(const Handle(Select3D_SensitiveEntity)& theSensitive);
//! empties the selection from all the stored entities
Standard_EXPORT void Clear();
@@ -86,7 +85,10 @@ public:
Standard_Integer Mode() const { return myMode; }
//! Return entities.
const NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& Entities() const { return myEntities; }
const NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& Entities() const
{
return myEntities;
}
//! Return entities.
NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& ChangeEntities() { return myEntities; }
@@ -99,9 +101,9 @@ public:
//! - none.
SelectMgr_TypeOfUpdate UpdateStatus() const { return myUpdateStatus; }
void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; }
void UpdateStatus(const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; }
void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; }
void UpdateBVHStatus(const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; }
SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const { return myBVHUpdateStatus; }
@@ -109,7 +111,10 @@ public:
SelectMgr_StateOfSelection GetSelectionState() const { return mySelectionState; }
//! Sets status of selection
void SetSelectionState (const SelectMgr_StateOfSelection theState) const { mySelectionState = theState; }
void SetSelectionState(const SelectMgr_StateOfSelection theState) const
{
mySelectionState = theState;
}
//! Returns sensitivity of the selection
Standard_Integer Sensitivity() const { return mySensFactor; }
@@ -117,13 +122,13 @@ public:
//! Changes sensitivity of the selection and all its entities to the given value.
//! IMPORTANT: This method does not update any outer selection structures, so for
//! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens);
Standard_EXPORT void SetSensitivity(const Standard_Integer theNewSens);
//! 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;
private:
NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
Standard_Integer myMode;
SelectMgr_TypeOfUpdate myUpdateStatus;

View File

@@ -17,440 +17,458 @@
namespace
{
//! Help class for filling pixel with random color.
class GeneratedEntityColorFiller : public SelectMgr_SelectionImageFiller
//! Help class for filling pixel with random color.
class GeneratedEntityColorFiller : public SelectMgr_SelectionImageFiller
{
public:
GeneratedEntityColorFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller(thePixMap, theSelector)
{
public:
GeneratedEntityColorFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller (thePixMap, theSelector)
// generate per-entity colors in the order as they have been activated
for (SelectMgr_SelectableObjectSet::Iterator anObjIter(theSelector->SelectableObjects());
anObjIter.More();
anObjIter.Next())
{
// generate per-entity colors in the order as they have been activated
for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelector->SelectableObjects()); anObjIter.More(); anObjIter.Next())
const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(anObj->Selections()); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
if (!myMapEntityColors.IsBound(aSens->BaseSensitive()))
{
const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
if (!myMapEntityColors.IsBound (aSens->BaseSensitive()))
{
Quantity_Color aColor;
randomPastelColor (aColor);
myMapEntityColors.Bind (aSens->BaseSensitive(), aColor);
}
Quantity_Color aColor;
randomPastelColor(aColor);
myMapEntityColors.Bind(aSens->BaseSensitive(), aColor);
}
}
}
}
}
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
if (thePicked < 1 || thePicked > myMainSel->NbPicked())
{
if (thePicked < 1
|| thePicked > myMainSel->NbPicked())
{
myImage->SetPixelColor (theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
return;
}
const Handle(Select3D_SensitiveEntity)& aPickedEntity = myMainSel->PickedEntity (thePicked);
Quantity_Color aColor (Quantity_NOC_BLACK);
myMapEntityColors.Find (aPickedEntity, aColor);
myImage->SetPixelColor (theCol, theRow, aColor);
myImage->SetPixelColor(theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
return;
}
protected:
NCollection_DataMap<Handle(Select3D_SensitiveEntity), Quantity_Color> myMapEntityColors;
};
const Handle(Select3D_SensitiveEntity)& aPickedEntity = myMainSel->PickedEntity(thePicked);
Quantity_Color aColor(Quantity_NOC_BLACK);
myMapEntityColors.Find(aPickedEntity, aColor);
myImage->SetPixelColor(theCol, theRow, aColor);
}
//! Help class for filling pixel with random color.
class GeneratedEntityTypeColorFiller : public SelectMgr_SelectionImageFiller
protected:
NCollection_DataMap<Handle(Select3D_SensitiveEntity), Quantity_Color> myMapEntityColors;
};
//! Help class for filling pixel with random color.
class GeneratedEntityTypeColorFiller : public SelectMgr_SelectionImageFiller
{
public:
GeneratedEntityTypeColorFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller(thePixMap, theSelector)
{
public:
GeneratedEntityTypeColorFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller (thePixMap, theSelector)
// generate per-entity colors in the order as they have been activated
for (SelectMgr_SelectableObjectSet::Iterator anObjIter(theSelector->SelectableObjects());
anObjIter.More();
anObjIter.Next())
{
// generate per-entity colors in the order as they have been activated
for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelector->SelectableObjects()); anObjIter.More(); anObjIter.Next())
const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(anObj->Selections()); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
if (!myMapEntityColors.IsBound(aSens->BaseSensitive()->DynamicType()))
{
const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
if (!myMapEntityColors.IsBound (aSens->BaseSensitive()->DynamicType()))
{
Quantity_Color aColor;
randomPastelColor (aColor);
myMapEntityColors.Bind (aSens->BaseSensitive()->DynamicType(), aColor);
}
Quantity_Color aColor;
randomPastelColor(aColor);
myMapEntityColors.Bind(aSens->BaseSensitive()->DynamicType(), aColor);
}
}
}
}
}
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
if (thePicked < 1
|| thePicked > myMainSel->NbPicked())
{
myImage->SetPixelColor (theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
return;
}
const Handle(Select3D_SensitiveEntity)& aPickedEntity = myMainSel->PickedEntity (thePicked);
Quantity_Color aColor (Quantity_NOC_BLACK);
myMapEntityColors.Find (aPickedEntity->DynamicType(), aColor);
myImage->SetPixelColor (theCol, theRow, aColor);
}
protected:
NCollection_DataMap<Handle(Standard_Type), Quantity_Color> myMapEntityColors;
};
//! Help class for filling pixel with normalized depth of ray.
class NormalizedDepthFiller : public SelectMgr_SelectionImageFiller
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
public:
NormalizedDepthFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector,
const Standard_Boolean theToInverse)
: SelectMgr_SelectionImageFiller (thePixMap, theSelector),
myDepthMin ( RealLast()),
myDepthMax (-RealLast()),
myToInverse(theToInverse)
if (thePicked < 1 || thePicked > myMainSel->NbPicked())
{
myUnnormImage.InitZero (Image_Format_GrayF, thePixMap.SizeX(), thePixMap.SizeY());
myImage->SetPixelColor(theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
return;
}
//! Accumulate the data.
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
const Handle(Select3D_SensitiveEntity)& aPickedEntity = myMainSel->PickedEntity(thePicked);
Quantity_Color aColor(Quantity_NOC_BLACK);
myMapEntityColors.Find(aPickedEntity->DynamicType(), aColor);
myImage->SetPixelColor(theCol, theRow, aColor);
}
protected:
NCollection_DataMap<Handle(Standard_Type), Quantity_Color> myMapEntityColors;
};
//! Help class for filling pixel with normalized depth of ray.
class NormalizedDepthFiller : public SelectMgr_SelectionImageFiller
{
public:
NormalizedDepthFiller(Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector,
const Standard_Boolean theToInverse)
: SelectMgr_SelectionImageFiller(thePixMap, theSelector),
myDepthMin(RealLast()),
myDepthMax(-RealLast()),
myToInverse(theToInverse)
{
myUnnormImage.InitZero(Image_Format_GrayF, thePixMap.SizeX(), thePixMap.SizeY());
}
//! Accumulate the data.
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
if (myUnnormImage.IsEmpty())
{
if (myUnnormImage.IsEmpty())
{
return;
}
if (thePicked < 1
|| thePicked > myMainSel->NbPicked())
{
myUnnormImage.ChangeValue<float> (theRow, theCol) = ShortRealLast();
return;
}
const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked);
myUnnormImage.ChangeValue<float> (theRow, theCol) = float(aSortCriterion.Depth);
myDepthMin = Min (myDepthMin, aSortCriterion.Depth);
myDepthMax = Max (myDepthMax, aSortCriterion.Depth);
return;
}
//! Normalize the depth values.
virtual void Flush() Standard_OVERRIDE
if (thePicked < 1 || thePicked > myMainSel->NbPicked())
{
float aFrom = 0.0f;
float aDelta = 1.0f;
if (myDepthMin <= myDepthMax)
myUnnormImage.ChangeValue<float>(theRow, theCol) = ShortRealLast();
return;
}
const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData(thePicked);
myUnnormImage.ChangeValue<float>(theRow, theCol) = float(aSortCriterion.Depth);
myDepthMin = Min(myDepthMin, aSortCriterion.Depth);
myDepthMax = Max(myDepthMax, aSortCriterion.Depth);
}
//! Normalize the depth values.
virtual void Flush() Standard_OVERRIDE
{
float aFrom = 0.0f;
float aDelta = 1.0f;
if (myDepthMin <= myDepthMax)
{
aFrom = float(myDepthMin);
aDelta = float(myDepthMax) - float(myDepthMin);
if (aDelta <= ShortRealEpsilon())
{
aFrom = float(myDepthMin);
aDelta = float(myDepthMax) - float(myDepthMin);
if (aDelta <= ShortRealEpsilon())
aDelta = 1.0f;
}
}
for (Standard_Size aRowIter = 0; aRowIter < myUnnormImage.SizeY(); ++aRowIter)
{
for (Standard_Size aColIter = 0; aColIter < myUnnormImage.SizeX(); ++aColIter)
{
float aDepth = myUnnormImage.Value<float>(aRowIter, aColIter);
if (aDepth <= -ShortRealLast() || aDepth >= ShortRealLast())
{
aDelta = 1.0f;
myImage->SetPixelColor(Standard_Integer(aColIter),
Standard_Integer(aRowIter),
Quantity_ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f));
continue;
}
}
for (Standard_Size aRowIter = 0; aRowIter < myUnnormImage.SizeY(); ++aRowIter)
{
for (Standard_Size aColIter = 0; aColIter < myUnnormImage.SizeX(); ++aColIter)
{
float aDepth = myUnnormImage.Value<float> (aRowIter, aColIter);
if (aDepth <= -ShortRealLast()
|| aDepth >= ShortRealLast())
{
myImage->SetPixelColor (Standard_Integer(aColIter), Standard_Integer(aRowIter),
Quantity_ColorRGBA (0.0f, 0.0f, 0.0f, 1.0f));
continue;
}
float aNormDepth = (aDepth - aFrom) / aDelta;
if (myToInverse)
{
aNormDepth = 1.0f - aNormDepth;
}
myImage->SetPixelColor (Standard_Integer(aColIter), Standard_Integer(aRowIter),
Quantity_ColorRGBA (aNormDepth, aNormDepth, aNormDepth, 1.0f));
float aNormDepth = (aDepth - aFrom) / aDelta;
if (myToInverse)
{
aNormDepth = 1.0f - aNormDepth;
}
myImage->SetPixelColor(Standard_Integer(aColIter),
Standard_Integer(aRowIter),
Quantity_ColorRGBA(aNormDepth, aNormDepth, aNormDepth, 1.0f));
}
}
}
private:
Image_PixMap myUnnormImage;
Standard_Real myDepthMin;
Standard_Real myDepthMax;
Standard_Boolean myToInverse;
};
private:
Image_PixMap myUnnormImage;
Standard_Real myDepthMin;
Standard_Real myDepthMax;
Standard_Boolean myToInverse;
};
//! Help class for filling pixel with unnormalized depth of ray.
class UnnormalizedDepthFiller : public SelectMgr_SelectionImageFiller
//! Help class for filling pixel with unnormalized depth of ray.
class UnnormalizedDepthFiller : public SelectMgr_SelectionImageFiller
{
public:
UnnormalizedDepthFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller(thePixMap, theSelector)
{
public:
UnnormalizedDepthFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller (thePixMap, theSelector) {}
}
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
if (thePicked < 1 || thePicked > myMainSel->NbPicked())
{
if (thePicked < 1
|| thePicked > myMainSel->NbPicked())
{
myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (0.0f, 0.0f, 0.0f, 1.0f));
return;
}
const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked);
const float aDepth = float(aSortCriterion.Depth);
myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (Graphic3d_Vec4 (aDepth, aDepth, aDepth, 1.0f)));
myImage->SetPixelColor(theCol, theRow, Quantity_ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f));
return;
}
};
//! Help class for filling pixel with color of detected object.
class GeneratedOwnerColorFiller : public SelectMgr_SelectionImageFiller
const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData(thePicked);
const float aDepth = float(aSortCriterion.Depth);
myImage->SetPixelColor(theCol,
theRow,
Quantity_ColorRGBA(Graphic3d_Vec4(aDepth, aDepth, aDepth, 1.0f)));
}
};
//! Help class for filling pixel with color of detected object.
class GeneratedOwnerColorFiller : public SelectMgr_SelectionImageFiller
{
public:
GeneratedOwnerColorFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller(thePixMap, theSelector)
{
public:
GeneratedOwnerColorFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller (thePixMap, theSelector)
// generate per-owner colors in the order as they have been activated
for (SelectMgr_SelectableObjectSet::Iterator anObjIter(theSelector->SelectableObjects());
anObjIter.More();
anObjIter.Next())
{
// generate per-owner colors in the order as they have been activated
for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelector->SelectableObjects()); anObjIter.More(); anObjIter.Next())
const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(anObj->Selections()); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
const Handle(SelectMgr_EntityOwner)& anOwner = aSens->BaseSensitive()->OwnerId();
if (!myMapOwnerColors.IsBound(anOwner))
{
const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
const Handle(SelectMgr_EntityOwner)& anOwner = aSens->BaseSensitive()->OwnerId();
if (!myMapOwnerColors.IsBound (anOwner))
{
Quantity_Color aColor;
randomPastelColor (aColor);
myMapOwnerColors.Bind (anOwner, aColor);
}
Quantity_Color aColor;
randomPastelColor(aColor);
myMapOwnerColors.Bind(anOwner, aColor);
}
}
}
}
}
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
if (thePicked < 1 || thePicked > myMainSel->NbPicked())
{
if (thePicked < 1
|| thePicked > myMainSel->NbPicked())
{
myImage->SetPixelColor (theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
return;
}
const Handle(SelectMgr_EntityOwner)& aPickedOwner = myMainSel->Picked (thePicked);
Quantity_Color aColor (Quantity_NOC_BLACK);
myMapOwnerColors.Find (aPickedOwner, aColor);
myImage->SetPixelColor (theCol, theRow, aColor);
myImage->SetPixelColor(theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
return;
}
protected:
NCollection_DataMap<Handle(SelectMgr_EntityOwner), Quantity_Color> myMapOwnerColors;
};
const Handle(SelectMgr_EntityOwner)& aPickedOwner = myMainSel->Picked(thePicked);
Quantity_Color aColor(Quantity_NOC_BLACK);
myMapOwnerColors.Find(aPickedOwner, aColor);
myImage->SetPixelColor(theCol, theRow, aColor);
}
//! Help class for filling pixel with random color for each selection mode.
class GeneratedSelModeColorFiller : public SelectMgr_SelectionImageFiller
protected:
NCollection_DataMap<Handle(SelectMgr_EntityOwner), Quantity_Color> myMapOwnerColors;
};
//! Help class for filling pixel with random color for each selection mode.
class GeneratedSelModeColorFiller : public SelectMgr_SelectionImageFiller
{
public:
GeneratedSelModeColorFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller(thePixMap, theSelector)
{
public:
GeneratedSelModeColorFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller (thePixMap, theSelector)
{
// generate standard modes in proper order, consider custom objects would use similar scheme
// clang-format off
// generate standard modes in proper order, consider custom objects would use similar scheme
// clang-format off
myMapSelectionModeColors.Bind ( 0, Quantity_NOC_WHITE); // default (entire object selection)
// clang-format on
myMapSelectionModeColors.Bind ( 1, Quantity_NOC_YELLOW); // TopAbs_VERTEX
myMapSelectionModeColors.Bind ( 2, Quantity_NOC_GREEN); // TopAbs_EDGE
myMapSelectionModeColors.Bind ( 3, Quantity_NOC_RED); // TopAbs_WIRE
myMapSelectionModeColors.Bind ( 4, Quantity_NOC_BLUE1); // TopAbs_FACE
myMapSelectionModeColors.Bind ( 5, Quantity_NOC_CYAN1); // TopAbs_SHELL
myMapSelectionModeColors.Bind ( 6, Quantity_NOC_PURPLE); // TopAbs_SOLID
myMapSelectionModeColors.Bind ( 7, Quantity_NOC_MAGENTA1); // TopAbs_COMPSOLID
myMapSelectionModeColors.Bind ( 8, Quantity_NOC_BROWN); // TopAbs_COMPOUND
myMapSelectionModeColors.Bind (0x0010, Quantity_NOC_PINK); // MeshVS_SMF_Volume
myMapSelectionModeColors.Bind (0x001E, Quantity_NOC_LIMEGREEN); // MeshVS_SMF_Element
myMapSelectionModeColors.Bind (0x001F, Quantity_NOC_DARKOLIVEGREEN); // MeshVS_SMF_All
myMapSelectionModeColors.Bind (0x0100, Quantity_NOC_GOLD); // MeshVS_SMF_Group
// clang-format on
myMapSelectionModeColors.Bind(1, Quantity_NOC_YELLOW); // TopAbs_VERTEX
myMapSelectionModeColors.Bind(2, Quantity_NOC_GREEN); // TopAbs_EDGE
myMapSelectionModeColors.Bind(3, Quantity_NOC_RED); // TopAbs_WIRE
myMapSelectionModeColors.Bind(4, Quantity_NOC_BLUE1); // TopAbs_FACE
myMapSelectionModeColors.Bind(5, Quantity_NOC_CYAN1); // TopAbs_SHELL
myMapSelectionModeColors.Bind(6, Quantity_NOC_PURPLE); // TopAbs_SOLID
myMapSelectionModeColors.Bind(7, Quantity_NOC_MAGENTA1); // TopAbs_COMPSOLID
myMapSelectionModeColors.Bind(8, Quantity_NOC_BROWN); // TopAbs_COMPOUND
myMapSelectionModeColors.Bind(0x0010, Quantity_NOC_PINK); // MeshVS_SMF_Volume
myMapSelectionModeColors.Bind(0x001E, Quantity_NOC_LIMEGREEN); // MeshVS_SMF_Element
myMapSelectionModeColors.Bind(0x001F, Quantity_NOC_DARKOLIVEGREEN); // MeshVS_SMF_All
myMapSelectionModeColors.Bind(0x0100, Quantity_NOC_GOLD); // MeshVS_SMF_Group
}
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
if (thePicked < 1 || thePicked > myMainSel->NbPicked())
{
myImage->SetPixelColor(theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
return;
}
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
Standard_Integer aSelectionMode = -1;
const Handle(SelectMgr_SelectableObject)& aSelectable =
myMainSel->Picked(thePicked)->Selectable();
const Handle(Select3D_SensitiveEntity)& anEntity = myMainSel->PickedEntity(thePicked);
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(aSelectable->Selections());
aSelIter.More();
aSelIter.Next())
{
if (thePicked < 1
|| thePicked > myMainSel->NbPicked())
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSelection->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
myImage->SetPixelColor (theCol, theRow, Quantity_Color (Quantity_NOC_BLACK));
return;
}
Standard_Integer aSelectionMode = -1;
const Handle(SelectMgr_SelectableObject)& aSelectable = myMainSel->Picked (thePicked)->Selectable();
const Handle(Select3D_SensitiveEntity)& anEntity = myMainSel->PickedEntity (thePicked);
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (aSelectable->Selections()); aSelIter.More(); aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
if (aSelEntIter.Value()->BaseSensitive() == anEntity)
{
if (aSelEntIter.Value()->BaseSensitive() == anEntity)
{
aSelectionMode = aSelection->Mode();
break;
}
aSelectionMode = aSelection->Mode();
break;
}
}
if (aSelectionMode == -1)
{
myImage->SetPixelColor (theCol, theRow, Quantity_Color (Quantity_NOC_BLACK));
return;
}
if (!myMapSelectionModeColors.IsBound (aSelectionMode))
{
Quantity_Color aColor;
randomPastelColor (aColor);
myMapSelectionModeColors.Bind (aSelectionMode, aColor);
}
const Quantity_Color& aColor = myMapSelectionModeColors.Find (aSelectionMode);
myImage->SetPixelColor (theCol, theRow, aColor);
}
if (aSelectionMode == -1)
{
myImage->SetPixelColor(theCol, theRow, Quantity_Color(Quantity_NOC_BLACK));
return;
}
protected:
NCollection_DataMap<Standard_Integer, Quantity_Color> myMapSelectionModeColors;
};
//! Help class for filling pixel with color of detected shape.
class DetectedObjectColorFiller : public SelectMgr_SelectionImageFiller
{
public:
DetectedObjectColorFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller (thePixMap, theSelector) {}
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
if (!myMapSelectionModeColors.IsBound(aSelectionMode))
{
Quantity_Color aColor (Quantity_NOC_BLACK);
if (thePicked > 0
&& thePicked <= myMainSel->NbPicked())
{
const Handle(SelectMgr_SelectableObject)& aSelectable = myMainSel->Picked (thePicked)->Selectable();
aColor = aSelectable->Attributes()->Color();
}
myImage->SetPixelColor (theCol, theRow, aColor);
Quantity_Color aColor;
randomPastelColor(aColor);
myMapSelectionModeColors.Bind(aSelectionMode, aColor);
}
};
//! Help class for filling pixel with normal direction value.
class SurfaceNormalFiller : public SelectMgr_SelectionImageFiller
const Quantity_Color& aColor = myMapSelectionModeColors.Find(aSelectionMode);
myImage->SetPixelColor(theCol, theRow, aColor);
}
protected:
NCollection_DataMap<Standard_Integer, Quantity_Color> myMapSelectionModeColors;
};
//! Help class for filling pixel with color of detected shape.
class DetectedObjectColorFiller : public SelectMgr_SelectionImageFiller
{
public:
DetectedObjectColorFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller(thePixMap, theSelector)
{
public:
SurfaceNormalFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller (thePixMap, theSelector) {}
}
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
Quantity_Color aColor(Quantity_NOC_BLACK);
if (thePicked > 0 && thePicked <= myMainSel->NbPicked())
{
if (thePicked <= 0
|| thePicked > myMainSel->NbPicked())
const Handle(SelectMgr_SelectableObject)& aSelectable =
myMainSel->Picked(thePicked)->Selectable();
aColor = aSelectable->Attributes()->Color();
}
myImage->SetPixelColor(theCol, theRow, aColor);
}
};
//! Help class for filling pixel with normal direction value.
class SurfaceNormalFiller : public SelectMgr_SelectionImageFiller
{
public:
SurfaceNormalFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
: SelectMgr_SelectionImageFiller(thePixMap, theSelector)
{
}
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) Standard_OVERRIDE
{
if (thePicked <= 0 || thePicked > myMainSel->NbPicked())
{
myImage->SetPixelColor(theCol, theRow, Quantity_NOC_BLACK);
}
else
{
const SelectMgr_SortCriterion& aPickedData = myMainSel->PickedData(thePicked);
Graphic3d_Vec3 aNormal = aPickedData.Normal;
aNormal.Normalize();
if (aNormal.Modulus() > 0.0f)
{
myImage->SetPixelColor (theCol, theRow, Quantity_NOC_BLACK);
myImage->SetPixelColor(theCol,
theRow,
Quantity_ColorRGBA(aNormal.x() * 0.5f + 0.5f,
aNormal.y() * 0.5f + 0.5f,
aNormal.z() * 0.5f + 0.5f,
1.0f));
}
else
{
const SelectMgr_SortCriterion& aPickedData = myMainSel->PickedData (thePicked);
Graphic3d_Vec3 aNormal = aPickedData.Normal;
aNormal.Normalize();
if (aNormal.Modulus() > 0.0f)
{
myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (aNormal.x() * 0.5f + 0.5f,
aNormal.y() * 0.5f + 0.5f,
aNormal.z() * 0.5f + 0.5f, 1.0f));
}
else
{
myImage->SetPixelColor (theCol, theRow, Quantity_NOC_BLACK);
}
myImage->SetPixelColor(theCol, theRow, Quantity_NOC_BLACK);
}
}
};
}
}
};
} // namespace
// =======================================================================
// function : CreateFiller
// purpose :
// =======================================================================
Handle(SelectMgr_SelectionImageFiller) SelectMgr_SelectionImageFiller::CreateFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector,
StdSelect_TypeOfSelectionImage theType)
Handle(SelectMgr_SelectionImageFiller) SelectMgr_SelectionImageFiller::CreateFiller(
Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector,
StdSelect_TypeOfSelectionImage theType)
{
switch (theType)
{
case StdSelect_TypeOfSelectionImage_NormalizedDepth:
case StdSelect_TypeOfSelectionImage_NormalizedDepthInverted:
{
return new NormalizedDepthFiller (thePixMap, theSelector, theType == StdSelect_TypeOfSelectionImage_NormalizedDepthInverted);
case StdSelect_TypeOfSelectionImage_NormalizedDepthInverted: {
return new NormalizedDepthFiller(thePixMap,
theSelector,
theType
== StdSelect_TypeOfSelectionImage_NormalizedDepthInverted);
}
case StdSelect_TypeOfSelectionImage_UnnormalizedDepth:
{
return new UnnormalizedDepthFiller (thePixMap, theSelector);
case StdSelect_TypeOfSelectionImage_UnnormalizedDepth: {
return new UnnormalizedDepthFiller(thePixMap, theSelector);
}
case StdSelect_TypeOfSelectionImage_ColoredDetectedObject:
{
return new DetectedObjectColorFiller (thePixMap, theSelector);
case StdSelect_TypeOfSelectionImage_ColoredDetectedObject: {
return new DetectedObjectColorFiller(thePixMap, theSelector);
}
case StdSelect_TypeOfSelectionImage_ColoredEntity:
{
return new GeneratedEntityColorFiller (thePixMap, theSelector);
case StdSelect_TypeOfSelectionImage_ColoredEntity: {
return new GeneratedEntityColorFiller(thePixMap, theSelector);
}
case StdSelect_TypeOfSelectionImage_ColoredEntityType:
{
return new GeneratedEntityTypeColorFiller (thePixMap, theSelector);
case StdSelect_TypeOfSelectionImage_ColoredEntityType: {
return new GeneratedEntityTypeColorFiller(thePixMap, theSelector);
}
case StdSelect_TypeOfSelectionImage_ColoredOwner:
{
return new GeneratedOwnerColorFiller (thePixMap, theSelector);
case StdSelect_TypeOfSelectionImage_ColoredOwner: {
return new GeneratedOwnerColorFiller(thePixMap, theSelector);
}
case StdSelect_TypeOfSelectionImage_ColoredSelectionMode:
{
return new GeneratedSelModeColorFiller (thePixMap, theSelector);
case StdSelect_TypeOfSelectionImage_ColoredSelectionMode: {
return new GeneratedSelModeColorFiller(thePixMap, theSelector);
}
case StdSelect_TypeOfSelectionImage_SurfaceNormal:
{
return new SurfaceNormalFiller (thePixMap, theSelector);
case StdSelect_TypeOfSelectionImage_SurfaceNormal: {
return new SurfaceNormalFiller(thePixMap, theSelector);
}
}
return Handle(SelectMgr_SelectionImageFiller)();

View File

@@ -27,35 +27,35 @@ class SelectMgr_SelectionImageFiller : public Standard_Transient
{
public:
//! Create filler of specified type.
static Handle(SelectMgr_SelectionImageFiller) CreateFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector,
StdSelect_TypeOfSelectionImage theType);
static Handle(SelectMgr_SelectionImageFiller) CreateFiller(
Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector,
StdSelect_TypeOfSelectionImage theType);
public:
//! Main constructor.
SelectMgr_SelectionImageFiller (Image_PixMap& thePixMap,
SelectMgr_ViewerSelector* theSelector)
: myImage (&thePixMap),
myMainSel(theSelector) {}
SelectMgr_SelectionImageFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
: myImage(&thePixMap),
myMainSel(theSelector)
{
}
//! Fill pixel at specified position.
virtual void Fill (const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) = 0;
virtual void Fill(const Standard_Integer theCol,
const Standard_Integer theRow,
const Standard_Integer thePicked) = 0;
//! Flush results into final image.
virtual void Flush() {}
protected:
//! Find the new unique random color.
void randomPastelColor (Quantity_Color& theColor)
void randomPastelColor(Quantity_Color& theColor)
{
for (;;)
{
nextRandomPastelColor (theColor);
if (myUniqueColors.Add (theColor))
nextRandomPastelColor(theColor);
if (myUniqueColors.Add(theColor))
{
return;
}
@@ -63,18 +63,18 @@ protected:
}
//! Fills the given color as random.
void nextRandomPastelColor (Quantity_Color& theColor)
void nextRandomPastelColor(Quantity_Color& theColor)
{
theColor = Quantity_Color (Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
Quantity_TOC_sRGB);
theColor = Quantity_Color(Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
Quantity_TOC_sRGB);
}
protected:
Image_PixMap* myImage;
SelectMgr_ViewerSelector* myMainSel;
math_BullardGenerator myBullardGenerator;
Image_PixMap* myImage;
SelectMgr_ViewerSelector* myMainSel;
math_BullardGenerator myBullardGenerator;
NCollection_Map<Quantity_Color> myUniqueColors;
};

View File

@@ -22,133 +22,131 @@
#include <StdSelect_BRepSelectionTool.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectionManager,Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectionManager, Standard_Transient)
//==================================================
// Function: Create
// Purpose :
//==================================================
SelectMgr_SelectionManager::SelectMgr_SelectionManager (const Handle(SelectMgr_ViewerSelector)& theSelector)
: mySelector (theSelector)
//=================================================================================================
SelectMgr_SelectionManager::SelectMgr_SelectionManager(
const Handle(SelectMgr_ViewerSelector)& theSelector)
: mySelector(theSelector)
{
//
}
//==================================================
// Function: Contains
// Purpose :
//==================================================
Standard_Boolean SelectMgr_SelectionManager::Contains (const Handle(SelectMgr_SelectableObject)& theObject) const
//=================================================================================================
Standard_Boolean SelectMgr_SelectionManager::Contains(
const Handle(SelectMgr_SelectableObject)& theObject) const
{
return myGlobal.Contains (theObject);
return myGlobal.Contains(theObject);
}
//==================================================
// Function: Load
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Load (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
//=================================================================================================
void SelectMgr_SelectionManager::Load(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
{
if (myGlobal.Contains(theObject))
return;
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter(theObject->Children());
anChildrenIter.More();
anChildrenIter.Next())
{
Load (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode);
Load(Handle(SelectMgr_SelectableObject)::DownCast(anChildrenIter.Value()), theMode);
}
if (!theObject->HasOwnPresentations())
return;
myGlobal.Add(theObject);
if (!mySelector->Contains (theObject) && theObject->HasOwnPresentations())
if (!mySelector->Contains(theObject) && theObject->HasOwnPresentations())
{
mySelector->AddSelectableObject (theObject);
mySelector->AddSelectableObject(theObject);
}
if (theMode != -1)
loadMode (theObject, theMode);
loadMode(theObject, theMode);
}
//==================================================
// Function: Remove
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject)& theObject)
//=================================================================================================
void SelectMgr_SelectionManager::Remove(const Handle(SelectMgr_SelectableObject)& theObject)
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter(theObject->Children());
anChildrenIter.More();
anChildrenIter.Next())
{
Remove (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()));
Remove(Handle(SelectMgr_SelectableObject)::DownCast(anChildrenIter.Value()));
}
if (!theObject->HasOwnPresentations())
return;
if (myGlobal.Contains (theObject))
if (myGlobal.Contains(theObject))
{
if (mySelector->Contains (theObject))
if (mySelector->Contains(theObject))
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(theObject->Selections());
aSelIter.More();
aSelIter.Next())
{
mySelector->RemoveSelectionOfObject (theObject, aSelIter.Value());
aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove);
mySelector->Deactivate (aSelIter.Value());
mySelector->RemoveSelectionOfObject(theObject, aSelIter.Value());
aSelIter.Value()->UpdateBVHStatus(SelectMgr_TBU_Remove);
mySelector->Deactivate(aSelIter.Value());
}
mySelector->RemoveSelectableObject (theObject);
mySelector->RemoveSelectableObject(theObject);
}
myGlobal.Remove (theObject);
myGlobal.Remove(theObject);
}
theObject->ClearSelections();
}
//==================================================
// Function: Activate
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
//=================================================================================================
void SelectMgr_SelectionManager::Activate(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
{
if (theMode == -1)
return;
for (PrsMgr_ListOfPresentableObjectsIter anChildIter (theObject->Children()); anChildIter.More(); anChildIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anChildIter(theObject->Children()); anChildIter.More();
anChildIter.Next())
{
Handle(SelectMgr_SelectableObject) aChild = Handle(SelectMgr_SelectableObject)::DownCast (anChildIter.Value());
Handle(SelectMgr_SelectableObject) aChild =
Handle(SelectMgr_SelectableObject)::DownCast(anChildIter.Value());
if (aChild->DisplayStatus() != PrsMgr_DisplayStatus_Erased)
{
Activate (aChild, theMode);
Activate(aChild, theMode);
}
}
if (!theObject->HasOwnPresentations())
return;
Standard_Boolean isComputed = Standard_False;
if (const Handle(SelectMgr_Selection)& aSelOld = theObject->Selection (theMode))
if (const Handle(SelectMgr_Selection)& aSelOld = theObject->Selection(theMode))
{
isComputed = !aSelOld->IsEmpty();
}
if (!isComputed)
{
loadMode (theObject, theMode);
loadMode(theObject, theMode);
}
const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode);
const Handle(SelectMgr_Selection)& aSelection = theObject->Selection(theMode);
switch (aSelection->UpdateStatus())
{
case SelectMgr_TOU_Full:
{
if (theObject->HasSelection (theMode))
case SelectMgr_TOU_Full: {
if (theObject->HasSelection(theMode))
{
mySelector->RemoveSelectionOfObject (theObject, aSelection);
mySelector->RemoveSelectionOfObject(theObject, aSelection);
}
theObject->RecomputePrimitives (theMode);
theObject->RecomputePrimitives(theMode);
// pass through SelectMgr_TOU_Partial
}
Standard_FALLTHROUGH
case SelectMgr_TOU_Partial:
{
theObject->UpdateTransformations (aSelection);
Standard_FALLTHROUGH
case SelectMgr_TOU_Partial: {
theObject->UpdateTransformations(aSelection);
mySelector->RebuildObjectsTree();
break;
}
@@ -160,40 +158,38 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
switch (aSelection->BVHUpdateStatus())
{
case SelectMgr_TBU_Add:
case SelectMgr_TBU_Renew:
{
mySelector->AddSelectionToObject (theObject, aSelection);
case SelectMgr_TBU_Renew: {
mySelector->AddSelectionToObject(theObject, aSelection);
break;
}
case SelectMgr_TBU_Remove:
{
case SelectMgr_TBU_Remove: {
if (aSelection->GetSelectionState() == SelectMgr_SOS_Deactivated)
{
mySelector->AddSelectionToObject (theObject, aSelection);
mySelector->AddSelectionToObject(theObject, aSelection);
}
break;
}
default:
break;
}
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
aSelection->UpdateBVHStatus(SelectMgr_TBU_None);
if (myGlobal.Contains (theObject))
if (myGlobal.Contains(theObject))
{
mySelector->Activate (theObject->Selection (theMode));
mySelector->Activate(theObject->Selection(theMode));
}
}
//==================================================
// Function: Deactivate
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Deactivate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
//=================================================================================================
void SelectMgr_SelectionManager::Deactivate(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter(theObject->Children());
anChildrenIter.More();
anChildrenIter.Next())
{
Deactivate (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode);
Deactivate(Handle(SelectMgr_SelectableObject)::DownCast(anChildrenIter.Value()), theMode);
}
if (!theObject->HasOwnPresentations())
{
@@ -204,30 +200,32 @@ void SelectMgr_SelectionManager::Deactivate (const Handle(SelectMgr_SelectableOb
return;
}
const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode);
const Handle(SelectMgr_Selection)& aSel = theObject->Selection(theMode);
if (theMode == -1)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(theObject->Selections()); aSelIter.More();
aSelIter.Next())
{
mySelector->Deactivate (aSelIter.Value());
mySelector->Deactivate(aSelIter.Value());
}
}
else if (!aSel.IsNull())
{
mySelector->Deactivate (aSel);
mySelector->Deactivate(aSel);
}
}
//=======================================================================
//function : IsActivated
//purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectionManager::IsActivated (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode) const
//=================================================================================================
Standard_Boolean SelectMgr_SelectionManager::IsActivated(
const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode) const
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter(theObject->Children());
anChildrenIter.More();
anChildrenIter.Next())
{
if (IsActivated (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode))
if (IsActivated(Handle(SelectMgr_SelectableObject)::DownCast(anChildrenIter.Value()), theMode))
return Standard_True;
}
if (!theObject->HasOwnPresentations())
@@ -241,9 +239,10 @@ Standard_Boolean SelectMgr_SelectionManager::IsActivated (const Handle(SelectMgr
if (theMode == -1)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(theObject->Selections()); aSelIter.More();
aSelIter.Next())
{
if (mySelector->Status (aSelIter.Value()) == SelectMgr_SOS_Activated)
if (mySelector->Status(aSelIter.Value()) == SelectMgr_SOS_Activated)
{
return Standard_True;
}
@@ -251,27 +250,30 @@ Standard_Boolean SelectMgr_SelectionManager::IsActivated (const Handle(SelectMgr
return Standard_False;
}
const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode);
const Handle(SelectMgr_Selection)& aSelection = theObject->Selection(theMode);
if (aSelection.IsNull())
{
return Standard_False;
}
return !aSelection.IsNull()
&& mySelector->Status (aSelection) == SelectMgr_SOS_Activated;
return !aSelection.IsNull() && mySelector->Status(aSelection) == SelectMgr_SOS_Activated;
}
//=======================================================================
//function : ClearSelectionStructures
//purpose : Removes sensitive entities from all viewer selectors
// function : ClearSelectionStructures
// purpose : Removes sensitive entities from all viewer selectors
// after method Clear() was called to the selection they belonged to
// or it was recomputed somehow
//=======================================================================
void SelectMgr_SelectionManager::ClearSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode)
void SelectMgr_SelectionManager::ClearSelectionStructures(
const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObj->Children()); anChildrenIter.More(); anChildrenIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter(theObj->Children());
anChildrenIter.More();
anChildrenIter.Next())
{
ClearSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode);
ClearSelectionStructures(Handle(SelectMgr_SelectableObject)::DownCast(anChildrenIter.Value()),
theMode);
}
if (!theObj->HasOwnPresentations())
@@ -285,35 +287,40 @@ void SelectMgr_SelectionManager::ClearSelectionStructures (const Handle(SelectMg
if (theMode != -1)
{
if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode))
if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection(theMode))
{
mySelector->RemoveSelectionOfObject (theObj, aSelection);
aSelection->UpdateBVHStatus (SelectMgr_TBU_Add);
mySelector->RemoveSelectionOfObject(theObj, aSelection);
aSelection->UpdateBVHStatus(SelectMgr_TBU_Add);
}
}
else
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObj->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(theObj->Selections()); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
mySelector->RemoveSelectionOfObject (theObj, aSelection);
aSelection->UpdateBVHStatus (SelectMgr_TBU_Add);
mySelector->RemoveSelectionOfObject(theObj, aSelection);
aSelection->UpdateBVHStatus(SelectMgr_TBU_Add);
}
}
mySelector->RebuildObjectsTree();
}
//=======================================================================
//function : RestoreSelectionStructuress
//purpose : Re-adds newely calculated sensitive entities of recomputed selection
// function : RestoreSelectionStructuress
// purpose : Re-adds newely calculated sensitive entities of recomputed selection
// defined by mode theMode to all viewer selectors contained that selection.
//=======================================================================
void SelectMgr_SelectionManager::RestoreSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode)
void SelectMgr_SelectionManager::RestoreSelectionStructures(
const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObj->Children()); anChildrenIter.More(); anChildrenIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter(theObj->Children());
anChildrenIter.More();
anChildrenIter.Next())
{
RestoreSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode);
RestoreSelectionStructures(Handle(SelectMgr_SelectableObject)::DownCast(anChildrenIter.Value()),
theMode);
}
if (!theObj->HasOwnPresentations())
{
@@ -326,144 +333,148 @@ void SelectMgr_SelectionManager::RestoreSelectionStructures (const Handle(Select
if (theMode != -1)
{
if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode))
if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection(theMode))
{
mySelector->AddSelectionToObject (theObj, aSelection);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
mySelector->AddSelectionToObject(theObj, aSelection);
aSelection->UpdateBVHStatus(SelectMgr_TBU_None);
}
}
else
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObj->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(theObj->Selections()); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
mySelector->AddSelectionToObject (theObj, aSelection);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
mySelector->AddSelectionToObject(theObj, aSelection);
aSelection->UpdateBVHStatus(SelectMgr_TBU_None);
}
}
mySelector->RebuildObjectsTree();
}
//==================================================
// Function: recomputeSelectionMode
// Purpose :
//==================================================
void SelectMgr_SelectionManager::recomputeSelectionMode (const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
theSelection->UpdateStatus (SelectMgr_TOU_Full);
//=================================================================================================
ClearSelectionStructures (theObject, theMode);
theObject->RecomputePrimitives (theMode);
RestoreSelectionStructures (theObject, theMode);
theSelection->UpdateStatus (SelectMgr_TOU_None);
theSelection->UpdateBVHStatus (SelectMgr_TBU_None);
void SelectMgr_SelectionManager::recomputeSelectionMode(
const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
theSelection->UpdateStatus(SelectMgr_TOU_Full);
ClearSelectionStructures(theObject, theMode);
theObject->RecomputePrimitives(theMode);
RestoreSelectionStructures(theObject, theMode);
theSelection->UpdateStatus(SelectMgr_TOU_None);
theSelection->UpdateBVHStatus(SelectMgr_TBU_None);
}
//==================================================
// Function: Update
// Purpose :
//==================================================
void SelectMgr_SelectionManager::RecomputeSelection (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Boolean theIsForce,
const Standard_Integer theMode)
//=================================================================================================
void SelectMgr_SelectionManager::RecomputeSelection(
const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Boolean theIsForce,
const Standard_Integer theMode)
{
if (theIsForce)
{
if (theMode == -1)
{
ClearSelectionStructures (theObject);
ClearSelectionStructures(theObject);
theObject->RecomputePrimitives();
theObject->UpdateTransformation();
RestoreSelectionStructures (theObject);
RestoreSelectionStructures(theObject);
}
else if (theObject->HasSelection (theMode))
else if (theObject->HasSelection(theMode))
{
ClearSelectionStructures (theObject, theMode);
theObject->RecomputePrimitives (theMode);
ClearSelectionStructures(theObject, theMode);
theObject->RecomputePrimitives(theMode);
theObject->UpdateTransformation();
RestoreSelectionStructures (theObject, theMode);
RestoreSelectionStructures(theObject, theMode);
}
return;
}
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter(theObject->Children());
anChildrenIter.More();
anChildrenIter.Next())
{
RecomputeSelection (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theIsForce, theMode);
RecomputeSelection(Handle(SelectMgr_SelectableObject)::DownCast(anChildrenIter.Value()),
theIsForce,
theMode);
}
if (!theObject->HasOwnPresentations())
{
return;
}
if (!myGlobal.Contains (theObject))
if (!myGlobal.Contains(theObject))
{
return;
}
if (theMode == -1)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(theObject->Selections()); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
const Standard_Integer aSelMode = aSelection->Mode();
recomputeSelectionMode (theObject, aSelection, aSelMode);
const Standard_Integer aSelMode = aSelection->Mode();
recomputeSelectionMode(theObject, aSelection, aSelMode);
}
}
else
{
if (const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode))
if (const Handle(SelectMgr_Selection)& aSelection = theObject->Selection(theMode))
{
recomputeSelectionMode (theObject, aSelection, theMode);
recomputeSelectionMode(theObject, aSelection, theMode);
}
}
}
//=======================================================================
//function : Update
//purpose : Selections are recalculated if they are flagged
// function : Update
// purpose : Selections are recalculated if they are flagged
// "TO RECALCULATE" and activated in one of selectors.
// If ForceUpdate = True, and they are "TO RECALCULATE"
// This is done without caring for the state of activation.
//=======================================================================
void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Boolean theIsForce)
void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Boolean theIsForce)
{
for (PrsMgr_ListOfPresentableObjectsIter aChildIter (theObject->Children()); aChildIter.More(); aChildIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter aChildIter(theObject->Children()); aChildIter.More();
aChildIter.Next())
{
Update (Handle(SelectMgr_SelectableObject)::DownCast (aChildIter.Value()), theIsForce);
Update(Handle(SelectMgr_SelectableObject)::DownCast(aChildIter.Value()), theIsForce);
}
if (!theObject->HasOwnPresentations())
{
return;
}
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(theObject->Selections()); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
if (theIsForce || mySelector->Status (aSelection) == SelectMgr_SOS_Activated)
if (theIsForce || mySelector->Status(aSelection) == SelectMgr_SOS_Activated)
{
switch (aSelection->UpdateStatus())
{
case SelectMgr_TOU_Full:
{
ClearSelectionStructures (theObject, aSelection->Mode());
theObject->RecomputePrimitives (aSelection->Mode()); // no break on purpose...
RestoreSelectionStructures (theObject, aSelection->Mode());
case SelectMgr_TOU_Full: {
ClearSelectionStructures(theObject, aSelection->Mode());
theObject->RecomputePrimitives(aSelection->Mode()); // no break on purpose...
RestoreSelectionStructures(theObject, aSelection->Mode());
// pass through SelectMgr_TOU_Partial
}
Standard_FALLTHROUGH
case SelectMgr_TOU_Partial:
{
theObject->UpdateTransformations (aSelection);
Standard_FALLTHROUGH
case SelectMgr_TOU_Partial: {
theObject->UpdateTransformations(aSelection);
mySelector->RebuildObjectsTree();
break;
}
default:
break;
}
aSelection->UpdateStatus (SelectMgr_TOU_None);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
aSelection->UpdateStatus(SelectMgr_TOU_None);
aSelection->UpdateBVHStatus(SelectMgr_TBU_None);
}
}
}
@@ -472,139 +483,142 @@ void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject
// Function: loadMode
// Purpose : Private Method
//==================================================
void SelectMgr_SelectionManager::loadMode (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
void SelectMgr_SelectionManager::loadMode(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
{
if (theMode == -1)
{
return;
}
if (const Handle(SelectMgr_Selection)& aSelOld = theObject->Selection (theMode))
if (const Handle(SelectMgr_Selection)& aSelOld = theObject->Selection(theMode))
{
if (aSelOld->IsEmpty())
{
if (aSelOld->BVHUpdateStatus() == SelectMgr_TBU_Remove)
{
Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode);
theObject->AddSelection (aNewSel, theMode);
aNewSel->UpdateBVHStatus (SelectMgr_TBU_Remove);
aNewSel->SetSelectionState (SelectMgr_SOS_Deactivated);
Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection(theMode);
theObject->AddSelection(aNewSel, theMode);
aNewSel->UpdateBVHStatus(SelectMgr_TBU_Remove);
aNewSel->SetSelectionState(SelectMgr_SOS_Deactivated);
buildBVH (aNewSel);
buildBVH(aNewSel);
}
}
return;
}
Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode);
theObject->AddSelection (aNewSel, theMode);
if (myGlobal.Contains (theObject))
Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection(theMode);
theObject->AddSelection(aNewSel, theMode);
if (myGlobal.Contains(theObject))
{
mySelector->AddSelectionToObject (theObject, aNewSel);
aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
mySelector->AddSelectionToObject(theObject, aNewSel);
aNewSel->UpdateBVHStatus(SelectMgr_TBU_None);
}
buildBVH (aNewSel);
buildBVH(aNewSel);
}
//==================================================
// Function: buildBVH
// Purpose : Private Method
//==================================================
void SelectMgr_SelectionManager::buildBVH (const Handle(SelectMgr_Selection)& theSelection)
void SelectMgr_SelectionManager::buildBVH(const Handle(SelectMgr_Selection)& theSelection)
{
if (mySelector->ToPrebuildBVH())
{
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIter (theSelection->Entities()); anIter.More(); anIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIter(
theSelection->Entities());
anIter.More();
anIter.Next())
{
const Handle(Select3D_SensitiveEntity)& anEntity = anIter.Value()->BaseSensitive();
mySelector->QueueBVHBuild (anEntity);
mySelector->QueueBVHBuild(anEntity);
if (Handle(Select3D_SensitiveGroup) aGroup = Handle(Select3D_SensitiveGroup)::DownCast (anEntity))
if (Handle(Select3D_SensitiveGroup) aGroup =
Handle(Select3D_SensitiveGroup)::DownCast(anEntity))
{
for (Select3D_IndexedMapOfEntity::Iterator aSubEntitiesIter (aGroup->Entities()); aSubEntitiesIter.More(); aSubEntitiesIter.Next())
for (Select3D_IndexedMapOfEntity::Iterator aSubEntitiesIter(aGroup->Entities());
aSubEntitiesIter.More();
aSubEntitiesIter.Next())
{
const Handle(Select3D_SensitiveEntity)& aSubEntity = aSubEntitiesIter.Value();
mySelector->QueueBVHBuild (aSubEntity);
mySelector->QueueBVHBuild(aSubEntity);
}
}
}
}
else
{
StdSelect_BRepSelectionTool::PreBuildBVH (theSelection);
StdSelect_BRepSelectionTool::PreBuildBVH(theSelection);
}
}
//=======================================================================
//function : SetUpdateMode
//purpose :
//=======================================================================
void SelectMgr_SelectionManager::SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject,
const SelectMgr_TypeOfUpdate theType)
//=================================================================================================
void SelectMgr_SelectionManager::SetUpdateMode(const Handle(SelectMgr_SelectableObject)& theObject,
const SelectMgr_TypeOfUpdate theType)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(theObject->Selections()); aSelIter.More();
aSelIter.Next())
{
aSelIter.Value()->UpdateStatus (theType);
aSelIter.Value()->UpdateStatus(theType);
}
}
//=======================================================================
//function : SetUpdateMode
//purpose :
//=======================================================================
void SelectMgr_SelectionManager::SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const SelectMgr_TypeOfUpdate theType)
//=================================================================================================
void SelectMgr_SelectionManager::SetUpdateMode(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const SelectMgr_TypeOfUpdate theType)
{
if (const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode))
if (const Handle(SelectMgr_Selection)& aSel = theObject->Selection(theMode))
{
aSel->UpdateStatus (theType);
aSel->UpdateStatus(theType);
}
}
//=======================================================================
//function : SetSelectionSensitivity
//purpose : Allows to manage sensitivity of a particular selection of interactive object theObject and
// function : SetSelectionSensitivity
// purpose : Allows to manage sensitivity of a particular selection of interactive object theObject
// and
// changes previous sensitivity value of all sensitive entities in selection with theMode
// to the given theNewSensitivity.
//=======================================================================
void SelectMgr_SelectionManager::SetSelectionSensitivity (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Standard_Integer theNewSens)
void SelectMgr_SelectionManager::SetSelectionSensitivity(
const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
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.");
if (theObject.IsNull())
{
return;
}
const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode);
const Handle(SelectMgr_Selection)& aSel = theObject->Selection(theMode);
if (aSel.IsNull())
{
return;
}
const Standard_Integer aPrevSens = aSel->Sensitivity();
aSel->SetSensitivity (theNewSens);
if (myGlobal.Contains (theObject)
&& mySelector->Contains (theObject))
aSel->SetSensitivity(theNewSens);
if (myGlobal.Contains(theObject) && mySelector->Contains(theObject))
{
mySelector->myTolerances.Decrement (aPrevSens);
mySelector->myTolerances.Add (theNewSens);
mySelector->myTolerances.Decrement(aPrevSens);
mySelector->myTolerances.Add(theNewSens);
}
}
//=======================================================================
//function : UpdateSelection
//purpose :
//=======================================================================
void SelectMgr_SelectionManager::UpdateSelection (const Handle(SelectMgr_SelectableObject)& theObject)
//=================================================================================================
void SelectMgr_SelectionManager::UpdateSelection(
const Handle(SelectMgr_SelectableObject)& theObject)
{
if (myGlobal.Contains (theObject)
&& mySelector->Contains (theObject))
if (myGlobal.Contains(theObject) && mySelector->Contains(theObject))
{
mySelector->MoveSelectableObject (theObject);
mySelector->MoveSelectableObject(theObject);
}
}

View File

@@ -29,103 +29,107 @@ class SelectMgr_SelectionManager : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectionManager, Standard_Transient)
public:
//! Constructs an empty selection manager object.
Standard_EXPORT SelectMgr_SelectionManager (const Handle(SelectMgr_ViewerSelector)& theSelector);
Standard_EXPORT SelectMgr_SelectionManager(const Handle(SelectMgr_ViewerSelector)& theSelector);
//! Return the Selector.
const Handle(SelectMgr_ViewerSelector)& Selector() const { return mySelector; }
//! Returns true if the manager contains the selectable object theObject.
Standard_EXPORT Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const;
//! Loads and computes selection mode theMode (if it is not equal to -1) in global context and adds selectable
//! object to BVH tree. If the object theObject has an already calculated selection with mode theMode and it was removed,
//! the selection will be recalculated.
Standard_EXPORT void Load (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = -1);
//! Removes selectable object theObject from all viewer selectors it was added to previously, removes it from all contexts
//! and clears all computed selections of theObject.
Standard_EXPORT void Remove (const Handle(SelectMgr_SelectableObject)& theObject);
//! Activates the selection mode theMode in the selector theSelector for the selectable object anObject.
//! By default, theMode is equal to 0. If theSelector is set to default (NULL), the selection with the mode theMode
//! will be activated in all the viewers available.
Standard_EXPORT void Activate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = 0);
//! Deactivates mode theMode of theObject in theSelector. If theMode value is set to default (-1), all
//! active selection modes will be deactivated. Likewise, if theSelector value is set to default (NULL), theMode
//! will be deactivated in all viewer selectors.
Standard_EXPORT void Deactivate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = -1);
//! Returns true if the selection with theMode is active for the selectable object theObject and selector theSelector.
//! If all parameters are set to default values, it returns it there is any active selection in any known viewer selector for
//! object theObject.
Standard_EXPORT Standard_Boolean IsActivated (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = -1) const;
Standard_EXPORT Standard_Boolean
Contains(const Handle(SelectMgr_SelectableObject)& theObject) const;
//! Loads and computes selection mode theMode (if it is not equal to -1) in global context and
//! adds selectable object to BVH tree. If the object theObject has an already calculated
//! selection with mode theMode and it was removed, the selection will be recalculated.
Standard_EXPORT void Load(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = -1);
//! Removes selectable object theObject from all viewer selectors it was added to previously,
//! removes it from all contexts and clears all computed selections of theObject.
Standard_EXPORT void Remove(const Handle(SelectMgr_SelectableObject)& theObject);
//! Activates the selection mode theMode in the selector theSelector for the selectable object
//! anObject. By default, theMode is equal to 0. If theSelector is set to default (NULL), the
//! selection with the mode theMode will be activated in all the viewers available.
Standard_EXPORT void Activate(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = 0);
//! Deactivates mode theMode of theObject in theSelector. If theMode value is set to default (-1),
//! all active selection modes will be deactivated. Likewise, if theSelector value is set to
//! default (NULL), theMode will be deactivated in all viewer selectors.
Standard_EXPORT void Deactivate(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = -1);
//! Returns true if the selection with theMode is active for the selectable object theObject and
//! selector theSelector. If all parameters are set to default values, it returns it there is any
//! active selection in any known viewer selector for object theObject.
Standard_EXPORT Standard_Boolean IsActivated(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = -1) const;
//! Removes sensitive entities from all viewer selectors
//! after method Clear() was called to the selection they belonged to
//! or it was recomputed somehow.
Standard_EXPORT void ClearSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode = -1);
Standard_EXPORT void ClearSelectionStructures(const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode = -1);
//! Re-adds newly calculated sensitive entities of recomputed selection
//! defined by mode theMode to all viewer selectors contained that selection.
Standard_EXPORT void RestoreSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode = -1);
//! Recomputes activated selections of theObject for all known viewer selectors according to theMode specified.
//! If theMode is set to default (-1), then all activated selections will be recomputed. If theIsForce is set to true,
//! then selection mode theMode for object theObject will be recomputed regardless of its activation status.
Standard_EXPORT void RecomputeSelection (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Boolean theIsForce = Standard_False, const Standard_Integer theMode = -1);
//! Updates all selections of theObject in all viewer selectors according to its current update status.
//! If theIsForce is set to true, the call is equal to recomputation.
Standard_EXPORT void Update (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Boolean theIsForce = Standard_True);
Standard_EXPORT void RestoreSelectionStructures(const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode = -1);
//! Recomputes activated selections of theObject for all known viewer selectors according to
//! theMode specified. If theMode is set to default (-1), then all activated selections will be
//! recomputed. If theIsForce is set to true, then selection mode theMode for object theObject
//! will be recomputed regardless of its activation status.
Standard_EXPORT void RecomputeSelection(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Boolean theIsForce = Standard_False,
const Standard_Integer theMode = -1);
//! Updates all selections of theObject in all viewer selectors according to its current update
//! status. If theIsForce is set to true, the call is equal to recomputation.
Standard_EXPORT void Update(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Boolean theIsForce = Standard_True);
//! Sets type of update of all selections of theObject to the given theType.
Standard_EXPORT void SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject, const SelectMgr_TypeOfUpdate theType);
Standard_EXPORT void SetUpdateMode(const Handle(SelectMgr_SelectableObject)& theObject,
const SelectMgr_TypeOfUpdate theType);
//! Sets type of update of selection with theMode of theObject to the given theType.
Standard_EXPORT void SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode, const SelectMgr_TypeOfUpdate theType);
Standard_EXPORT void SetUpdateMode(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const SelectMgr_TypeOfUpdate theType);
//! Allows to manage sensitivity of a particular selection of interactive object theObject and
//! changes previous sensitivity value of all sensitive entities in selection with theMode
//! to the given theNewSensitivity.
Standard_EXPORT void SetSelectionSensitivity (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Standard_Integer theNewSens);
Standard_EXPORT void SetSelectionSensitivity(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Standard_Integer theNewSens);
//! Re-adds selectable object in BVHs in all viewer selectors.
Standard_EXPORT void UpdateSelection (const Handle(SelectMgr_SelectableObject)& theObj);
Standard_EXPORT void UpdateSelection(const Handle(SelectMgr_SelectableObject)& theObj);
protected:
//! Recomputes given selection mode and updates BVHs in all viewer selectors
Standard_EXPORT void recomputeSelectionMode (const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode);
Standard_EXPORT void recomputeSelectionMode(const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode);
private:
//! Loads and creates selection structures for object theObject with mode theMode in specified
//! viewer selector theSelector. If theSelector is set to default value (NULL), the selection mode
//! created will be added to all known viewer selectors.
Standard_EXPORT void loadMode (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode);
Standard_EXPORT void loadMode(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode);
//! In multi-thread mode queues sensitive entities to build its BVH in separate threads.
//! Otherwise, builds BVH for heavyweight entities immediately.
Standard_EXPORT void buildBVH (const Handle(SelectMgr_Selection)& theSelection);
Standard_EXPORT void buildBVH(const Handle(SelectMgr_Selection)& theSelection);
private:
Handle(SelectMgr_ViewerSelector) mySelector;
NCollection_Map<Handle(SelectMgr_SelectableObject)> myGlobal;
};
DEFINE_STANDARD_HANDLE(SelectMgr_SelectionManager, Standard_Transient)

View File

@@ -18,9 +18,9 @@
enum SelectMgr_SelectionType
{
SelectMgr_SelectionType_Unknown = -1, //!< undefined selection type
SelectMgr_SelectionType_Point, //!< selection by point (frustum with some tolerance or axis)
SelectMgr_SelectionType_Box, //!< rectangle selection
SelectMgr_SelectionType_Polyline //!< polygonal selection
SelectMgr_SelectionType_Point, //!< selection by point (frustum with some tolerance or axis)
SelectMgr_SelectionType_Box, //!< rectangle selection
SelectMgr_SelectionType_Polyline //!< polygonal selection
};
#endif // _SelectMgr_SelectionType_HeaderFile

View File

@@ -15,17 +15,17 @@
#include <SelectMgr_SensitiveEntity.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SensitiveEntity,Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SensitiveEntity, Standard_Transient)
//=======================================================================
// function : SelectMgr_SensitiveEntity
// purpose : Creates new inactive for selection object with base entity
// theEntity
//=======================================================================
SelectMgr_SensitiveEntity::SelectMgr_SensitiveEntity (const Handle(Select3D_SensitiveEntity)& theEntity)
: mySensitive (theEntity),
myIsActiveForSelection (Standard_False)
SelectMgr_SensitiveEntity::SelectMgr_SensitiveEntity(
const Handle(Select3D_SensitiveEntity)& theEntity)
: mySensitive(theEntity),
myIsActiveForSelection(Standard_False)
{
//
}
@@ -44,10 +44,11 @@ void SelectMgr_SensitiveEntity::Clear()
// function : DumpJson
// purpose :
// =======================================================================
void SelectMgr_SensitiveEntity::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
void SelectMgr_SensitiveEntity::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySensitive.get())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsActiveForSelection)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, mySensitive.get())
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myIsActiveForSelection)
}

View File

@@ -25,9 +25,8 @@
class SelectMgr_SensitiveEntity : public Standard_Transient
{
public:
//! Creates new inactive for selection object with base entity theEntity
Standard_EXPORT SelectMgr_SensitiveEntity (const Handle(Select3D_SensitiveEntity)& theEntity);
Standard_EXPORT SelectMgr_SensitiveEntity(const Handle(Select3D_SensitiveEntity)& theEntity);
~SelectMgr_SensitiveEntity() {}
@@ -48,14 +47,14 @@ public:
void SetActiveForSelection() const { myIsActiveForSelection = Standard_True; }
//! 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;
DEFINE_STANDARD_RTTIEXT(SelectMgr_SensitiveEntity,Standard_Transient) // Type definition
DEFINE_STANDARD_RTTIEXT(SelectMgr_SensitiveEntity, Standard_Transient) // Type definition
private:
Handle(Select3D_SensitiveEntity) mySensitive; //!< Related SelectBasics entity
mutable Standard_Boolean myIsActiveForSelection; //!< Selection activity status
Handle(Select3D_SensitiveEntity) mySensitive; //!< Related SelectBasics entity
mutable Standard_Boolean myIsActiveForSelection; //!< Selection activity status
};
DEFINE_STANDARD_HANDLE(SelectMgr_SensitiveEntity, Standard_Transient)

View File

@@ -21,12 +21,11 @@
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SensitiveEntitySet, BVH_PrimitiveSet3d)
//=======================================================================
// function : SelectMgr_SensitiveEntitySet
// purpose :
//=======================================================================
SelectMgr_SensitiveEntitySet::SelectMgr_SensitiveEntitySet (const Handle(Select3D_BVHBuilder3d)& theBuilder)
: BVH_PrimitiveSet3d (theBuilder)
//=================================================================================================
SelectMgr_SensitiveEntitySet::SelectMgr_SensitiveEntitySet(
const Handle(Select3D_BVHBuilder3d)& theBuilder)
: BVH_PrimitiveSet3d(theBuilder)
{
myNbEntityWithPersistence = 0;
}
@@ -35,17 +34,17 @@ SelectMgr_SensitiveEntitySet::SelectMgr_SensitiveEntitySet (const Handle(Select3
// function : Append
// purpose : Adds new entity to the set and marks BVH tree for rebuild
//=======================================================================
void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_SensitiveEntity)& theEntity)
void SelectMgr_SensitiveEntitySet::Append(const Handle(SelectMgr_SensitiveEntity)& theEntity)
{
if (!theEntity->BaseSensitive()->IsKind (STANDARD_TYPE(Select3D_SensitiveEntity)))
if (!theEntity->BaseSensitive()->IsKind(STANDARD_TYPE(Select3D_SensitiveEntity)))
{
theEntity->ResetSelectionActiveStatus();
return;
}
const Standard_Integer anExtent = mySensitives.Extent();
if (mySensitives.Add (theEntity) > anExtent)
if (mySensitives.Add(theEntity) > anExtent)
{
addOwner (theEntity->BaseSensitive()->OwnerId());
addOwner(theEntity->BaseSensitive()->OwnerId());
}
if (!theEntity->BaseSensitive()->TransformPersistence().IsNull())
{
@@ -59,21 +58,24 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_SensitiveEntit
// purpose : Adds every entity of selection theSelection to the set
// and marks BVH tree for rebuild
//=======================================================================
void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_Selection)& theSelection)
void SelectMgr_SensitiveEntitySet::Append(const Handle(SelectMgr_Selection)& theSelection)
{
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
theSelection->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(SelectMgr_SensitiveEntity)& aSensEnt = aSelEntIter.Value();
if (!aSensEnt->BaseSensitive()->IsKind (STANDARD_TYPE(Select3D_SensitiveEntity)))
if (!aSensEnt->BaseSensitive()->IsKind(STANDARD_TYPE(Select3D_SensitiveEntity)))
{
aSensEnt->ResetSelectionActiveStatus();
continue;
}
const Standard_Integer anExtent = mySensitives.Extent();
if (mySensitives.Add (aSensEnt) > anExtent)
if (mySensitives.Add(aSensEnt) > anExtent)
{
addOwner (aSensEnt->BaseSensitive()->OwnerId());
addOwner(aSensEnt->BaseSensitive()->OwnerId());
}
if (!aSensEnt->BaseSensitive()->TransformPersistence().IsNull())
{
@@ -88,12 +90,15 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_Selection)& th
// purpose : Removes every entity of selection theSelection from the set
// and marks BVH tree for rebuild
//=======================================================================
void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& theSelection)
void SelectMgr_SensitiveEntitySet::Remove(const Handle(SelectMgr_Selection)& theSelection)
{
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
theSelection->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(SelectMgr_SensitiveEntity)& aSensEnt = aSelEntIter.Value();
const Standard_Integer anEntIdx = mySensitives.FindIndex (aSensEnt);
const Standard_Integer anEntIdx = mySensitives.FindIndex(aSensEnt);
if (anEntIdx == 0)
{
continue;
@@ -101,7 +106,7 @@ void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& th
if (anEntIdx != mySensitives.Size())
{
Swap (anEntIdx - 1, mySensitives.Size() - 1);
Swap(anEntIdx - 1, mySensitives.Size() - 1);
}
if (!aSensEnt->BaseSensitive()->TransformPersistence().IsNull())
{
@@ -109,7 +114,7 @@ void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& th
}
mySensitives.RemoveLast();
removeOwner (aSensEnt->BaseSensitive()->OwnerId());
removeOwner(aSensEnt->BaseSensitive()->OwnerId());
}
MarkDirty();
@@ -119,9 +124,9 @@ void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& th
// function : Box
// purpose : Returns bounding box of entity with index theIdx
//=======================================================================
Select3D_BndBox3d SelectMgr_SensitiveEntitySet::Box (const Standard_Integer theIndex) const
Select3D_BndBox3d SelectMgr_SensitiveEntitySet::Box(const Standard_Integer theIndex) const
{
const Handle(Select3D_SensitiveEntity)& aSensitive = GetSensitiveById (theIndex)->BaseSensitive();
const Handle(Select3D_SensitiveEntity)& aSensitive = GetSensitiveById(theIndex)->BaseSensitive();
if (!aSensitive->TransformPersistence().IsNull())
{
return Select3D_BndBox3d();
@@ -135,14 +140,13 @@ Select3D_BndBox3d SelectMgr_SensitiveEntitySet::Box (const Standard_Integer theI
// purpose : Returns geometry center of sensitive entity index theIdx
// along the given axis theAxis
//=======================================================================
Standard_Real SelectMgr_SensitiveEntitySet::Center (const Standard_Integer theIndex,
const Standard_Integer theAxis) const
Standard_Real SelectMgr_SensitiveEntitySet::Center(const Standard_Integer theIndex,
const Standard_Integer theAxis) const
{
const Handle(Select3D_SensitiveEntity)& aSensitive = GetSensitiveById (theIndex)->BaseSensitive();
const gp_Pnt aCenter = aSensitive->CenterOfGeometry();
Standard_Real aCenterCoord = 0.0;
aCenterCoord = theAxis == 0 ? aCenter.X() :
(theAxis == 1 ? aCenter.Y() : aCenter.Z());
const Handle(Select3D_SensitiveEntity)& aSensitive = GetSensitiveById(theIndex)->BaseSensitive();
const gp_Pnt aCenter = aSensitive->CenterOfGeometry();
Standard_Real aCenterCoord = 0.0;
aCenterCoord = theAxis == 0 ? aCenter.X() : (theAxis == 1 ? aCenter.Y() : aCenter.Z());
return aCenterCoord;
}
@@ -151,10 +155,10 @@ Standard_Real SelectMgr_SensitiveEntitySet::Center (const Standard_Integer theIn
// function : Swap
// purpose : Swaps items with indexes theIdx1 and theIdx2
//=======================================================================
void SelectMgr_SensitiveEntitySet::Swap (const Standard_Integer theIndex1,
const Standard_Integer theIndex2)
void SelectMgr_SensitiveEntitySet::Swap(const Standard_Integer theIndex1,
const Standard_Integer theIndex2)
{
mySensitives.Swap (theIndex1 + 1, theIndex2 + 1);
mySensitives.Swap(theIndex1 + 1, theIndex2 + 1);
}
//=======================================================================
@@ -170,42 +174,38 @@ Standard_Integer SelectMgr_SensitiveEntitySet::Size() const
// function : GetSensitiveById
// purpose : Returns the entity with index theIndex in the set
//=======================================================================
const Handle(SelectMgr_SensitiveEntity)& SelectMgr_SensitiveEntitySet::GetSensitiveById
(const Standard_Integer theIndex) const
const Handle(SelectMgr_SensitiveEntity)& SelectMgr_SensitiveEntitySet::GetSensitiveById(
const Standard_Integer theIndex) const
{
return mySensitives.FindKey (theIndex + 1);
return mySensitives.FindKey(theIndex + 1);
}
//=======================================================================
// function : addOwner
// purpose :
//=======================================================================
void SelectMgr_SensitiveEntitySet::addOwner (const Handle(SelectMgr_EntityOwner)& theOwner)
//=================================================================================================
void SelectMgr_SensitiveEntitySet::addOwner(const Handle(SelectMgr_EntityOwner)& theOwner)
{
if (!theOwner.IsNull())
{
if (Standard_Integer* aNumber = myOwnersMap.ChangeSeek (theOwner))
if (Standard_Integer* aNumber = myOwnersMap.ChangeSeek(theOwner))
{
++(*aNumber);
}
else
{
myOwnersMap.Bind (theOwner, 1);
myOwnersMap.Bind(theOwner, 1);
}
}
}
//=======================================================================
// function : removeOwner
// purpose :
//=======================================================================
void SelectMgr_SensitiveEntitySet::removeOwner (const Handle(SelectMgr_EntityOwner)& theOwner)
//=================================================================================================
void SelectMgr_SensitiveEntitySet::removeOwner(const Handle(SelectMgr_EntityOwner)& theOwner)
{
if (Standard_Integer* aNumber = !theOwner.IsNull() ? myOwnersMap.ChangeSeek (theOwner) : NULL)
if (Standard_Integer* aNumber = !theOwner.IsNull() ? myOwnersMap.ChangeSeek(theOwner) : NULL)
{
if (--(*aNumber) == 0)
{
myOwnersMap.UnBind (theOwner);
myOwnersMap.UnBind(theOwner);
}
}
}

View File

@@ -32,43 +32,45 @@ class SelectMgr_SensitiveEntitySet : public BVH_PrimitiveSet3d
{
DEFINE_STANDARD_RTTIEXT(SelectMgr_SensitiveEntitySet, BVH_PrimitiveSet3d)
public:
//! Empty constructor.
Standard_EXPORT SelectMgr_SensitiveEntitySet (const Handle(Select3D_BVHBuilder3d)& theBuilder);
Standard_EXPORT SelectMgr_SensitiveEntitySet(const Handle(Select3D_BVHBuilder3d)& theBuilder);
virtual ~SelectMgr_SensitiveEntitySet() {}
//! Adds new entity to the set and marks BVH tree for rebuild
Standard_EXPORT void Append (const Handle(SelectMgr_SensitiveEntity)& theEntity);
Standard_EXPORT void Append(const Handle(SelectMgr_SensitiveEntity)& theEntity);
//! Adds every entity of selection theSelection to the set and marks
//! BVH tree for rebuild
Standard_EXPORT void Append (const Handle(SelectMgr_Selection)& theSelection);
Standard_EXPORT void Append(const Handle(SelectMgr_Selection)& theSelection);
//! Removes every entity of selection theSelection from the set
//! and marks BVH tree for rebuild
Standard_EXPORT void Remove (const Handle(SelectMgr_Selection)& theSelection);
Standard_EXPORT void Remove(const Handle(SelectMgr_Selection)& theSelection);
//! Returns bounding box of entity with index theIdx
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIndex) const
Standard_OVERRIDE;
//! Make inherited method Box() visible to avoid CLang warning
using BVH_PrimitiveSet3d::Box;
//! Returns geometry center of sensitive entity index theIdx
//! along the given axis theAxis
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIndex,
const Standard_Integer theAxis) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIndex,
const Standard_Integer theAxis) const
Standard_OVERRIDE;
//! Swaps items with indexes theIdx1 and theIdx2
Standard_EXPORT virtual void Swap (const Standard_Integer theIndex1,
const Standard_Integer theIndex2) Standard_OVERRIDE;
Standard_EXPORT virtual void Swap(const Standard_Integer theIndex1,
const Standard_Integer theIndex2) Standard_OVERRIDE;
//! Returns the amount of entities
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
//! Returns the entity with index theIndex in the set
Standard_EXPORT const Handle(SelectMgr_SensitiveEntity)& GetSensitiveById (const Standard_Integer theIndex) const;
Standard_EXPORT const Handle(SelectMgr_SensitiveEntity)& GetSensitiveById(
const Standard_Integer theIndex) const;
//! Returns map of entities.
const SelectMgr_IndexedMapOfHSensitive& Sensitives() const { return mySensitives; }
@@ -80,20 +82,18 @@ public:
Standard_Boolean HasEntityWithPersistence() const { return myNbEntityWithPersistence > 0; }
protected:
//! Adds entity owner to the map of owners (or increases its counter if it is already there).
Standard_EXPORT void addOwner (const Handle(SelectMgr_EntityOwner)& theOwner);
Standard_EXPORT void addOwner(const Handle(SelectMgr_EntityOwner)& theOwner);
//! Decreases counter of owner in the map of owners (or removes it from the map if counter == 0).
Standard_EXPORT void removeOwner (const Handle(SelectMgr_EntityOwner)& theOwner);
Standard_EXPORT void removeOwner(const Handle(SelectMgr_EntityOwner)& theOwner);
private:
// clang-format off
// clang-format off
SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH
SelectMgr_MapOfOwners myOwnersMap; //!< Map of entity owners and its corresponding number of sensitives
Standard_Integer myNbEntityWithPersistence; //!< number of sensitive entities that have own transform persistence
// clang-format on
// clang-format on
};
#endif // _SelectMgr_SensitiveEntitySet_HeaderFile

View File

@@ -23,5 +23,4 @@ class SelectMgr_EntityOwner;
typedef NCollection_Sequence<Handle(SelectMgr_EntityOwner)> SelectMgr_SequenceOfOwner;
#endif

View File

@@ -13,7 +13,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _SelectMgr_SequenceOfSelection_HeaderFile
#define _SelectMgr_SequenceOfSelection_HeaderFile

View File

@@ -23,40 +23,41 @@
//! This class provides data and criterion for sorting candidate
//! entities in the process of interactive selection by mouse click
class SelectMgr_SortCriterion
class SelectMgr_SortCriterion
{
public:
Handle(Select3D_SensitiveEntity) Entity; //!< detected entity
gp_Pnt Point; //!< 3D point
Graphic3d_Vec3 Normal; //!< surface normal or 0 vector if undefined
Standard_Real Depth; //!< distance from the view plane to the entity
// clang-format off
gp_Pnt Point; //!< 3D point
Graphic3d_Vec3 Normal; //!< surface normal or 0 vector if undefined
Standard_Real Depth; //!< distance from the view plane to the entity
// clang-format off
Standard_Real MinDist; //!< distance from the clicked point to the entity on the view plane
Standard_Real Tolerance; //!< tolerance used for selecting candidates
Standard_Integer SelectionPriority; //!< selection priority
Standard_Integer DisplayPriority; //!< display priority
Standard_Integer ZLayerPosition; //!< ZLayer rendering order index, stronger than a depth
Standard_Integer NbOwnerMatches; //!< overall number of entities collected for the same owner
// clang-format on
Standard_Boolean IsPreferPriority; //!< flag to signal comparison to be done over priority
// clang-format on
Standard_Boolean IsPreferPriority; //!< flag to signal comparison to be done over priority
public:
DEFINE_STANDARD_ALLOC
//! Empty constructor.
SelectMgr_SortCriterion()
: Depth (0.0),
MinDist (0.0),
Tolerance(0.0),
SelectionPriority (0),
DisplayPriority(0),
ZLayerPosition (0),
NbOwnerMatches (0),
IsPreferPriority (Standard_False) {}
: Depth(0.0),
MinDist(0.0),
Tolerance(0.0),
SelectionPriority(0),
DisplayPriority(0),
ZLayerPosition(0),
NbOwnerMatches(0),
IsPreferPriority(Standard_False)
{
}
//! Compare with another item by depth, priority and minDist.
bool IsCloserDepth (const SelectMgr_SortCriterion& theOther) const
bool IsCloserDepth(const SelectMgr_SortCriterion& theOther) const
{
// the object within different ZLayer groups can not be compared by depth
if (ZLayerPosition != theOther.ZLayerPosition)
@@ -65,7 +66,7 @@ public:
}
// closest object is selected if their depths are not equal within tolerance
if (Abs (Depth - theOther.Depth) > Tolerance + theOther.Tolerance)
if (Abs(Depth - theOther.Depth) > Tolerance + theOther.Tolerance)
{
return Depth < theOther.Depth;
}
@@ -73,19 +74,19 @@ public:
Standard_Real aCos = 1.0;
if (Normal.Modulus() > 0 && theOther.Normal.Modulus() > 0)
{
gp_Dir aNormal (Normal.x(), Normal.y(), Normal.z());
gp_Dir anOtherNormal (theOther.Normal.x(), theOther.Normal.y(), theOther.Normal.z());
aCos = Abs (Cos (aNormal.Angle (anOtherNormal)));
gp_Dir aNormal(Normal.x(), Normal.y(), Normal.z());
gp_Dir anOtherNormal(theOther.Normal.x(), theOther.Normal.y(), theOther.Normal.z());
aCos = Abs(Cos(aNormal.Angle(anOtherNormal)));
}
Standard_Real aDepth = Depth - Tolerance;
Standard_Real aDepth = Depth - Tolerance;
Standard_Real anOtherDepth = theOther.Depth - theOther.Tolerance;
// Comparison depths taking into account tolerances occurs when the surfaces are parallel
// or have the same sensitivity and the angle between them is less than 60 degrees.
if (Abs (aDepth - anOtherDepth) > Precision::Confusion())
if (Abs(aDepth - anOtherDepth) > Precision::Confusion())
{
if ((aCos > 0.5 && Abs (Tolerance - theOther.Tolerance) < Precision::Confusion())
|| Abs (aCos - 1.0) < Precision::Confusion())
if ((aCos > 0.5 && Abs(Tolerance - theOther.Tolerance) < Precision::Confusion())
|| Abs(aCos - 1.0) < Precision::Confusion())
{
return aDepth < anOtherDepth;
}
@@ -103,12 +104,12 @@ public:
}
// if priorities are equal, one closest to the mouse
return SelectionPriority == theOther.SelectionPriority
&& MinDist < theOther.MinDist;
return SelectionPriority == theOther.SelectionPriority && MinDist < theOther.MinDist;
}
//! Compare with another item using old logic (OCCT version <= 6.3.1) with priority considered preceding depth.
bool IsHigherPriority (const SelectMgr_SortCriterion& theOther) const
//! Compare with another item using old logic (OCCT version <= 6.3.1) with priority considered
//! preceding depth.
bool IsHigherPriority(const SelectMgr_SortCriterion& theOther) const
{
// the object within different ZLayer groups can not be compared by depth
if (ZLayerPosition != theOther.ZLayerPosition)
@@ -126,15 +127,14 @@ public:
return DisplayPriority > theOther.DisplayPriority;
}
//if (Abs (Depth - theOther.Depth) <= (Tolerance + theOther.Tolerance))
if (Abs (Depth - theOther.Depth) <= Precision::Confusion())
// if (Abs (Depth - theOther.Depth) <= (Tolerance + theOther.Tolerance))
if (Abs(Depth - theOther.Depth) <= Precision::Confusion())
{
return MinDist < theOther.MinDist;
}
return Depth < theOther.Depth;
}
};
#endif // _SelectMgr_SortCriterion_HeaderFile

View File

@@ -20,10 +20,12 @@
//! different state of a Selection in a ViewerSelector...
enum SelectMgr_StateOfSelection
{
SelectMgr_SOS_Any = -2, //!< ANY selection state (for querying selections)
SelectMgr_SOS_Unknown = -1, //!< selection, which has never been in SelectMgr_SOS_Activated state (almost the same thing as SelectMgr_SOS_Deactivated)
SelectMgr_SOS_Deactivated = 0, //!< deactivated selection, once been in SelectMgr_SOS_Activated state
SelectMgr_SOS_Activated, //!< activated selection
SelectMgr_SOS_Any = -2, //!< ANY selection state (for querying selections)
SelectMgr_SOS_Unknown = -1, //!< selection, which has never been in SelectMgr_SOS_Activated state
//!< (almost the same thing as SelectMgr_SOS_Deactivated)
SelectMgr_SOS_Deactivated =
0, //!< deactivated selection, once been in SelectMgr_SOS_Activated state
SelectMgr_SOS_Activated, //!< activated selection
};
#endif // _SelectMgr_StateOfSelection_HeaderFile

View File

@@ -13,77 +13,71 @@
#include <SelectMgr_ToleranceMap.hxx>
//=======================================================================
// function: SelectMgr_ToleranceMap
// purpose :
//=======================================================================
//=================================================================================================
SelectMgr_ToleranceMap::SelectMgr_ToleranceMap()
: myLargestKey (-1),
myCustomTolerance (-1)
: myLargestKey(-1),
myCustomTolerance(-1)
{
//
}
//=======================================================================
// function: ~SelectMgr_ToleranceMap
// purpose :
//=======================================================================
//=================================================================================================
SelectMgr_ToleranceMap::~SelectMgr_ToleranceMap()
{
myTolerances.Clear();
}
//=======================================================================
// function: Add
// purpose :
//=======================================================================
void SelectMgr_ToleranceMap::Add (const Standard_Integer& theTolerance)
//=================================================================================================
void SelectMgr_ToleranceMap::Add(const Standard_Integer& theTolerance)
{
if (Standard_Integer* aFreq = myTolerances.ChangeSeek (theTolerance))
if (Standard_Integer* aFreq = myTolerances.ChangeSeek(theTolerance))
{
++(*aFreq);
if (*aFreq == 1 && theTolerance != myLargestKey)
{
myLargestKey = Max (theTolerance, myLargestKey);
myLargestKey = Max(theTolerance, myLargestKey);
}
return;
}
myTolerances.Bind (theTolerance, 1);
myTolerances.Bind(theTolerance, 1);
if (myTolerances.Extent() == 1)
{
myLargestKey = theTolerance;
}
else
{
myLargestKey = Max (theTolerance, myLargestKey);
myLargestKey = Max(theTolerance, myLargestKey);
}
}
//=======================================================================
// function: Decrement
// purpose :
//=======================================================================
void SelectMgr_ToleranceMap::Decrement (const Standard_Integer& theTolerance)
//=================================================================================================
void SelectMgr_ToleranceMap::Decrement(const Standard_Integer& theTolerance)
{
Standard_Integer* aFreq = myTolerances.ChangeSeek (theTolerance);
Standard_Integer* aFreq = myTolerances.ChangeSeek(theTolerance);
if (aFreq == NULL)
{
return;
}
Standard_ProgramError_Raise_if (*aFreq == 0, "SelectMgr_ToleranceMap::Decrement() - internal error");
Standard_ProgramError_Raise_if(*aFreq == 0,
"SelectMgr_ToleranceMap::Decrement() - internal error");
--(*aFreq);
if (theTolerance == myLargestKey
&& *aFreq == 0)
if (theTolerance == myLargestKey && *aFreq == 0)
{
myLargestKey = -1;
for (NCollection_DataMap<Standard_Integer, Standard_Integer>::Iterator anIter (myTolerances); anIter.More(); anIter.Next())
for (NCollection_DataMap<Standard_Integer, Standard_Integer>::Iterator anIter(myTolerances);
anIter.More();
anIter.Next())
{
if (anIter.Value() != 0)
{
myLargestKey = Max (myLargestKey, anIter.Key());
myLargestKey = Max(myLargestKey, anIter.Key());
}
}
}

View File

@@ -16,13 +16,14 @@
#include <NCollection_DataMap.hxx>
//! An internal class for calculation of current largest tolerance value which will be applied for creation of selecting frustum by default.
//! Each time the selection set is deactivated, maximum tolerance value will be recalculated.
//! If a user enables custom precision using StdSelect_ViewerSelector3d::SetPixelTolerance, it will be applied to all sensitive entities without any checks.
//! An internal class for calculation of current largest tolerance value which will be applied for
//! creation of selecting frustum by default. Each time the selection set is deactivated, maximum
//! tolerance value will be recalculated. If a user enables custom precision using
//! StdSelect_ViewerSelector3d::SetPixelTolerance, it will be applied to all sensitive entities
//! without any checks.
class SelectMgr_ToleranceMap
{
public:
//! Sets tolerance values to -1.0
Standard_EXPORT SelectMgr_ToleranceMap();
@@ -30,11 +31,11 @@ public:
//! Adds the value given to map, checks if the current tolerance value
//! should be replaced by theTolerance
Standard_EXPORT void Add (const Standard_Integer& theTolerance);
Standard_EXPORT void Add(const Standard_Integer& theTolerance);
//! Decrements a counter of the tolerance given, checks if the current tolerance value
//! should be recalculated
Standard_EXPORT void Decrement (const Standard_Integer& theTolerance);
Standard_EXPORT void Decrement(const Standard_Integer& theTolerance);
//! Returns a current tolerance that must be applied
Standard_Integer Tolerance() const
@@ -43,13 +44,11 @@ public:
{
return 2; // default tolerance value
}
return myCustomTolerance < 0
? myLargestKey
: myLargestKey + myCustomTolerance;
return myCustomTolerance < 0 ? myLargestKey : myLargestKey + myCustomTolerance;
}
//! Sets tolerance to the given one and disables adaptive checks
void SetCustomTolerance (const Standard_Integer theTolerance) { myCustomTolerance = theTolerance; }
void SetCustomTolerance(const Standard_Integer theTolerance) { myCustomTolerance = theTolerance; }
//! Unsets a custom tolerance and enables adaptive checks
void ResetDefaults() { myCustomTolerance = -1; }

View File

@@ -22,20 +22,20 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_TriangularFrustum, Standard_Transient)
namespace
{
void computeFrustumNormals (const gp_Vec* theEdges, gp_Vec* theNormals)
{
// V0V1
theNormals[0] = theEdges[0].Crossed (theEdges[3]);
// V1V2
theNormals[1] = theEdges[1].Crossed (theEdges[4]);
// V0V2
theNormals[2] = theEdges[0].Crossed (theEdges[5]);
// Near
theNormals[3] = theEdges[3].Crossed (theEdges[4]);
// Far
theNormals[4] = -theNormals[3];
}
void computeFrustumNormals(const gp_Vec* theEdges, gp_Vec* theNormals)
{
// V0V1
theNormals[0] = theEdges[0].Crossed(theEdges[3]);
// V1V2
theNormals[1] = theEdges[1].Crossed(theEdges[4]);
// V0V2
theNormals[2] = theEdges[0].Crossed(theEdges[5]);
// Near
theNormals[3] = theEdges[3].Crossed(theEdges[4]);
// Far
theNormals[4] = -theNormals[3];
}
} // namespace
// =======================================================================
// function : SelectMgr_TriangularFrustum
@@ -60,18 +60,19 @@ SelectMgr_TriangularFrustum::~SelectMgr_TriangularFrustum()
// purpose : Caches projection of frustum's vertices onto its plane directions
// and {i, j, k}
// =======================================================================
void SelectMgr_TriangularFrustum::cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum) const
void SelectMgr_TriangularFrustum::cacheVertexProjections(
SelectMgr_TriangularFrustum* theFrustum) const
{
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < 5; ++aPlaneIdx)
{
Standard_Real aMax = -DBL_MAX;
Standard_Real aMin = DBL_MAX;
Standard_Real aMax = -DBL_MAX;
Standard_Real aMin = DBL_MAX;
const gp_XYZ& aPlane = theFrustum->myPlanes[aPlaneIdx].XYZ();
for (Standard_Integer aVertIdx = 0; aVertIdx < 6; ++aVertIdx)
{
Standard_Real aProjection = aPlane.Dot (theFrustum->myVertices[aVertIdx].XYZ());
aMax = Max (aMax, aProjection);
aMin = Min (aMin, aProjection);
Standard_Real aProjection = aPlane.Dot(theFrustum->myVertices[aVertIdx].XYZ());
aMax = Max(aMax, aProjection);
aMin = Min(aMin, aProjection);
}
theFrustum->myMaxVertsProjections[aPlaneIdx] = aMax;
theFrustum->myMinVertsProjections[aPlaneIdx] = aMin;
@@ -80,49 +81,51 @@ void SelectMgr_TriangularFrustum::cacheVertexProjections (SelectMgr_TriangularFr
for (Standard_Integer aDim = 0; aDim < 3; ++aDim)
{
Standard_Real aMax = -DBL_MAX;
Standard_Real aMin = DBL_MAX;
Standard_Real aMin = DBL_MAX;
for (Standard_Integer aVertIdx = 0; aVertIdx < 6; ++aVertIdx)
{
Standard_Real aProjection = theFrustum->myVertices[aVertIdx].XYZ().GetData()[aDim];
aMax = Max (aMax, aProjection);
aMin = Min (aMin, aProjection);
aMax = Max(aMax, aProjection);
aMin = Min(aMin, aProjection);
}
theFrustum->myMaxOrthoVertsProjections[aDim] = aMax;
theFrustum->myMinOrthoVertsProjections[aDim] = aMin;
}
}
//=======================================================================
// function : Init
// purpose :
//=======================================================================
void SelectMgr_TriangularFrustum::Init (const gp_Pnt2d& theP1,
const gp_Pnt2d& theP2,
const gp_Pnt2d& theP3)
//=================================================================================================
void SelectMgr_TriangularFrustum::Init(const gp_Pnt2d& theP1,
const gp_Pnt2d& theP2,
const gp_Pnt2d& theP3)
{
mySelTriangle.Points[0] = theP1;
mySelTriangle.Points[1] = theP2;
mySelTriangle.Points[2] = theP3;
}
//=======================================================================
// function : Build
// purpose :
//=======================================================================
//=================================================================================================
void SelectMgr_TriangularFrustum::Build()
{
// V0_Near
myVertices[0] = myBuilder->ProjectPntOnViewPlane (mySelTriangle.Points[0].X(), mySelTriangle.Points[0].Y(), 0.0);
myVertices[0] =
myBuilder->ProjectPntOnViewPlane(mySelTriangle.Points[0].X(), mySelTriangle.Points[0].Y(), 0.0);
// V1_Near
myVertices[1] = myBuilder->ProjectPntOnViewPlane (mySelTriangle.Points[1].X(), mySelTriangle.Points[1].Y(), 0.0);
myVertices[1] =
myBuilder->ProjectPntOnViewPlane(mySelTriangle.Points[1].X(), mySelTriangle.Points[1].Y(), 0.0);
// V2_Near
myVertices[2] = myBuilder->ProjectPntOnViewPlane (mySelTriangle.Points[2].X(), mySelTriangle.Points[2].Y(), 0.0);
myVertices[2] =
myBuilder->ProjectPntOnViewPlane(mySelTriangle.Points[2].X(), mySelTriangle.Points[2].Y(), 0.0);
// V0_Far
myVertices[3] = myBuilder->ProjectPntOnViewPlane (mySelTriangle.Points[0].X(), mySelTriangle.Points[0].Y(), 1.0);
myVertices[3] =
myBuilder->ProjectPntOnViewPlane(mySelTriangle.Points[0].X(), mySelTriangle.Points[0].Y(), 1.0);
// V1_Far
myVertices[4] = myBuilder->ProjectPntOnViewPlane (mySelTriangle.Points[1].X(), mySelTriangle.Points[1].Y(), 1.0);
myVertices[4] =
myBuilder->ProjectPntOnViewPlane(mySelTriangle.Points[1].X(), mySelTriangle.Points[1].Y(), 1.0);
// V2_Far
myVertices[5] = myBuilder->ProjectPntOnViewPlane (mySelTriangle.Points[2].X(), mySelTriangle.Points[2].Y(), 1.0);
myVertices[5] =
myBuilder->ProjectPntOnViewPlane(mySelTriangle.Points[2].X(), mySelTriangle.Points[2].Y(), 1.0);
// V0_Near - V0_Far
myEdgeDirs[0] = myVertices[0].XYZ() - myVertices[3].XYZ();
@@ -137,9 +140,9 @@ void SelectMgr_TriangularFrustum::Build()
// V1_Near - V0_Near
myEdgeDirs[5] = myVertices[2].XYZ() - myVertices[0].XYZ();
computeFrustumNormals (myEdgeDirs, myPlanes);
computeFrustumNormals(myEdgeDirs, myPlanes);
cacheVertexProjections (this);
cacheVertexProjections(this);
}
//=======================================================================
@@ -153,17 +156,18 @@ void SelectMgr_TriangularFrustum::Build()
// as any negative value;
// - scale only is needed: @theTrsf must be set to gp_Identity.
//=======================================================================
Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::ScaleAndTransform (const Standard_Integer,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)&) const
Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::ScaleAndTransform(
const Standard_Integer,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)&) const
{
Handle(SelectMgr_TriangularFrustum) aRes = new SelectMgr_TriangularFrustum();
aRes->SetCamera (myCamera);
aRes->SetCamera(myCamera);
for (Standard_Integer anIt = 0; anIt < 6; anIt++)
{
gp_Pnt aPoint = myVertices[anIt];
theTrsf.Transforms (aPoint.ChangeCoord());
theTrsf.Transforms(aPoint.ChangeCoord());
aRes->myVertices[anIt] = aPoint;
}
@@ -180,9 +184,9 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::ScaleAndTransform
// V1_Near - V0_Near
aRes->myEdgeDirs[5] = aRes->myVertices[2].XYZ() - aRes->myVertices[0].XYZ();
computeFrustumNormals (aRes->myEdgeDirs, aRes->myPlanes);
computeFrustumNormals(aRes->myEdgeDirs, aRes->myPlanes);
cacheVertexProjections (aRes.get());
cacheVertexProjections(aRes.get());
aRes->mySelTriangle = mySelTriangle;
@@ -194,11 +198,12 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::ScaleAndTransform
// purpose : Returns a copy of the frustum using the given frustum builder configuration.
// Returned frustum should be re-constructed before being used.
//=======================================================================
Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::CopyWithBuilder(
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
{
Handle(SelectMgr_TriangularFrustum) aRes = new SelectMgr_TriangularFrustum();
aRes->mySelTriangle = mySelTriangle;
aRes->SetBuilder (theBuilder);
aRes->mySelTriangle = mySelTriangle;
aRes->SetBuilder(theBuilder);
return aRes;
}
@@ -208,12 +213,13 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::CopyWithBuilder (
// purpose : SAT intersection test between defined volume and
// given axis-aligned box
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsBox (const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsBox(
const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
return hasBoxOverlap (theMinPt, theMaxPt);
return hasBoxOverlap(theMinPt, theMaxPt);
}
// =======================================================================
@@ -222,22 +228,23 @@ Standard_Boolean SelectMgr_TriangularFrustum::OverlapsBox (const SelectMgr_Vec3&
// axis-aligned bounding box with minimum corner at point
// theMinPt and maximum at point theMaxPt
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsBox (const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
Standard_Boolean* /*theInside*/) const
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsBox(const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
Standard_Boolean* /*theInside*/) const
{
return hasBoxOverlap (theMinPt, theMaxPt, NULL);
return hasBoxOverlap(theMinPt, theMaxPt, NULL);
}
// =======================================================================
// function : OverlapsPoint
// purpose : Intersection test between defined volume and given point
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsPoint (const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsPoint(
const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
return hasPointOverlap (thePnt);
return hasPointOverlap(thePnt);
}
// =======================================================================
@@ -247,10 +254,11 @@ Standard_Boolean SelectMgr_TriangularFrustum::OverlapsPoint (const gp_Pnt& thePn
// may be considered of interior part or boundary line defined
// by segments depending on given sensitivity type
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsPolygon(
const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
@@ -258,9 +266,9 @@ Standard_Boolean SelectMgr_TriangularFrustum::OverlapsPolygon (const TColgp_Arra
const Standard_Integer anUpper = theArrayOfPnts.Upper();
for (Standard_Integer aPtIdx = aLower; aPtIdx <= anUpper; ++aPtIdx)
{
const gp_Pnt& aStartPt = theArrayOfPnts.Value (aPtIdx);
const gp_Pnt& aEndPt = theArrayOfPnts.Value (aPtIdx == anUpper ? aLower : (aPtIdx + 1));
if (!hasSegmentOverlap (aStartPt, aEndPt))
const gp_Pnt& aStartPt = theArrayOfPnts.Value(aPtIdx);
const gp_Pnt& aEndPt = theArrayOfPnts.Value(aPtIdx == anUpper ? aLower : (aPtIdx + 1));
if (!hasSegmentOverlap(aStartPt, aEndPt))
{
return Standard_False;
}
@@ -268,8 +276,8 @@ Standard_Boolean SelectMgr_TriangularFrustum::OverlapsPolygon (const TColgp_Arra
}
else if (theSensType == Select3D_TOS_INTERIOR)
{
gp_Vec aNorm (gp_XYZ (RealLast(), RealLast(), RealLast()));
return hasPolygonOverlap (theArrayOfPnts, aNorm);
gp_Vec aNorm(gp_XYZ(RealLast(), RealLast(), RealLast()));
return hasPolygonOverlap(theArrayOfPnts, aNorm);
}
return Standard_False;
@@ -279,12 +287,13 @@ Standard_Boolean SelectMgr_TriangularFrustum::OverlapsPolygon (const TColgp_Arra
// function : OverlapsSegment
// purpose : Checks if line segment overlaps selecting frustum
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsSegment (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsSegment(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
return hasSegmentOverlap (thePnt1, thePnt2);
return hasSegmentOverlap(thePnt1, thePnt2);
}
// =======================================================================
@@ -294,113 +303,107 @@ Standard_Boolean SelectMgr_TriangularFrustum::OverlapsSegment (const gp_Pnt& the
// boundary line defined by triangle vertices depending on
// given sensitivity type
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsTriangle (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsTriangle(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 };
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 3);
return OverlapsPolygon (aPntsArray, Select3D_TOS_BOUNDARY, theClipRange, thePickResult);
const gp_Pnt aPntsArrayBuf[3] = {thePnt1, thePnt2, thePnt3};
const TColgp_Array1OfPnt aPntsArray(aPntsArrayBuf[0], 1, 3);
return OverlapsPolygon(aPntsArray, Select3D_TOS_BOUNDARY, theClipRange, thePickResult);
}
else if (theSensType == Select3D_TOS_INTERIOR)
{
gp_Vec aNorm (gp_XYZ (RealLast(), RealLast(), RealLast()));
return hasTriangleOverlap (thePnt1, thePnt2, thePnt3, aNorm);
gp_Vec aNorm(gp_XYZ(RealLast(), RealLast(), RealLast()));
return hasTriangleOverlap(thePnt1, thePnt2, thePnt3, aNorm);
}
return Standard_True;
}
//=======================================================================
// function : OverlapsSphere
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside) const
{
(void) theInside;
return hasBoxOverlap (SelectMgr_Vec3 (theCenter.X() - theRadius, theCenter.Y() - theRadius, theCenter.Z() - theRadius),
SelectMgr_Vec3 (theCenter.X() + theRadius, theCenter.Y() + theRadius, theCenter.Z() + theRadius), NULL);
}
//=================================================================================================
//=======================================================================
// function : OverlapsSphere
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
(void )theClipRange;
(void )thePickResult;
return hasSphereOverlap (theCenter, theRadius);
}
//=======================================================================
// function : OverlapsCylinder
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
(void)theClipRange;
(void)thePickResult;
return hasCylinderOverlap (theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow);
}
//=======================================================================
// function : OverlapsCylinder
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
(void) theInside;
return hasCylinderOverlap (theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
(void)theClipRange;
(void)thePickResult;
return hasCircleOverlap (theRadius, theTrsf, theIsFilled);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsSphere(const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside) const
{
(void)theInside;
return hasCircleOverlap (theRadius, theTrsf, theIsFilled);
return hasBoxOverlap(
SelectMgr_Vec3(theCenter.X() - theRadius, theCenter.Y() - theRadius, theCenter.Z() - theRadius),
SelectMgr_Vec3(theCenter.X() + theRadius, theCenter.Y() + theRadius, theCenter.Z() + theRadius),
NULL);
}
//=================================================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
(void)theClipRange;
(void)thePickResult;
return hasSphereOverlap(theCenter, theRadius);
}
//=================================================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
(void)theClipRange;
(void)thePickResult;
return hasCylinderOverlap(theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow);
}
//=================================================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCylinder(const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
(void)theInside;
return hasCylinderOverlap(theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow);
}
//=================================================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCircle(
const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
(void)theClipRange;
(void)thePickResult;
return hasCircleOverlap(theRadius, theTrsf, theIsFilled);
}
//=================================================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCircle(const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
{
(void)theInside;
return hasCircleOverlap(theRadius, theTrsf, theIsFilled);
}
// =======================================================================
@@ -417,26 +420,26 @@ void SelectMgr_TriangularFrustum::Clear()
// function : GetPlanes
// purpose :
// =======================================================================
void SelectMgr_TriangularFrustum::GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
void SelectMgr_TriangularFrustum::GetPlanes(
NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
{
SelectMgr_Vec4 aPlaneEquation;
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < 5; ++aPlaneIdx)
{
const gp_Vec& aNorm = myPlanes[aPlaneIdx];
aPlaneEquation.x() = aNorm.X();
aPlaneEquation.y() = aNorm.Y();
aPlaneEquation.z() = aNorm.Z();
aPlaneEquation.w() = - (aNorm.XYZ().Dot (myVertices[aPlaneIdx % 2 == 0 ? aPlaneIdx : 1].XYZ()));
thePlaneEquations.Append (aPlaneEquation);
aPlaneEquation.x() = aNorm.X();
aPlaneEquation.y() = aNorm.Y();
aPlaneEquation.z() = aNorm.Z();
aPlaneEquation.w() = -(aNorm.XYZ().Dot(myVertices[aPlaneIdx % 2 == 0 ? aPlaneIdx : 1].XYZ()));
thePlaneEquations.Append(aPlaneEquation);
}
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void SelectMgr_TriangularFrustum::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
//=================================================================================================
void SelectMgr_TriangularFrustum::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_TriangularFrustum)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_Frustum)
OCCT_DUMP_CLASS_BEGIN(theOStream, SelectMgr_TriangularFrustum)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, SelectMgr_Frustum)
}

View File

@@ -19,13 +19,13 @@
#include <SelectMgr_Frustum.hxx>
//! This class contains representation of triangular selecting frustum, created in case
//! of polyline selection, and algorithms for overlap detection between selecting frustum and sensitive entities.
//! Overlap detection tests are implemented according to the terms of separating axis theorem (SAT).
//! NOTE: the object of this class can be created only as part of SelectMgr_TriangularFrustumSet.
//! of polyline selection, and algorithms for overlap detection between selecting frustum and
//! sensitive entities. Overlap detection tests are implemented according to the terms of separating
//! axis theorem (SAT). NOTE: the object of this class can be created only as part of
//! SelectMgr_TriangularFrustumSet.
class SelectMgr_TriangularFrustum : public SelectMgr_Frustum<3>
{
public:
//! Auxiliary structure to define selection triangle
struct SelectionTriangle
{
@@ -33,14 +33,11 @@ public:
};
public:
//! Destructor.
Standard_EXPORT virtual ~SelectMgr_TriangularFrustum();
//! Initializes selection triangle by input points
Standard_EXPORT void Init (const gp_Pnt2d& theP1,
const gp_Pnt2d& theP2,
const gp_Pnt2d& theP3);
Standard_EXPORT void Init(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2, const gp_Pnt2d& theP3);
//! Creates new triangular frustum with bases of triangles with vertices theP1, theP2 and theP3
//! projections onto near and far view frustum planes (only for triangular frustums)
@@ -51,38 +48,43 @@ public:
virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; }
//! Returns a copy of the frustum transformed according to the matrix given
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScale,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform(
const Standard_Integer theScale,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
//! Returns a copy of the frustum using the given frustum builder configuration.
//! Returned frustum should be re-constructed before being used.
//! @param[in] theBuilder argument that represents corresponding settings for re-constructing transformed frustum from scratch;
//! @param[in] theBuilder argument that represents corresponding settings for re-constructing
//! transformed frustum from scratch;
//! should NOT be NULL.
//! @return a copy of the frustum with the input builder assigned
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder(
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
public: //! @name SAT Tests for different objects
//! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! with minimum corner at point theMinPt and maximum at point theMaxPt
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
Standard_Boolean* theInside) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
Standard_Boolean* theInside) const
Standard_OVERRIDE;
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint(
const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Always returns FALSE (not applicable to this selector).
virtual Standard_Boolean OverlapsPoint (const gp_Pnt& ) const Standard_OVERRIDE
virtual Standard_Boolean OverlapsPoint(const gp_Pnt&) const Standard_OVERRIDE
{
return Standard_False;
}
@@ -90,107 +92,113 @@ public: //! @name SAT Tests for different objects
//! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon(
const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSegment(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! SAT intersection test between defined volume and given triangle. The test may
//! be considered of interior part or boundary line defined by triangle vertices
//! depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by sphere with center theCenter
//! and radius theRadius
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by sphere with center theCenter
//! and radius theRadius
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(
const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
public:
//! Nullifies the handle to corresponding builder instance to prevent memory leaks
Standard_EXPORT void Clear();
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
Standard_EXPORT virtual void GetPlanes(
NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) 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:
//! Creates an empty triangular frustum.
Standard_EXPORT SelectMgr_TriangularFrustum();
private:
void cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum) const;
void cacheVertexProjections(SelectMgr_TriangularFrustum* theFrustum) const;
protected:
// clang-format off
// clang-format off
SelectionTriangle mySelTriangle; //!< parameters of selection triangle (it is used to build triangle frustum)
// clang-format on
// clang-format on
public:
DEFINE_STANDARD_RTTIEXT(SelectMgr_TriangularFrustum, SelectMgr_Frustum<3>)
friend class SelectMgr_TriangularFrustumSet;
};

File diff suppressed because it is too large Load Diff

View File

@@ -24,14 +24,13 @@ typedef NCollection_List<Handle(SelectMgr_TriangularFrustum)> SelectMgr_TriangFr
//! This class is used to handle polyline selection. The main principle of polyline selection
//! algorithm is to split the polygon defined by polyline onto triangles.
//! Than each of them is considered as a base for triangular frustum building.
//! In other words, each triangle vertex will be projected from 2d screen space to 3d world space onto near and far view frustum planes.
//! Thus, the projected triangles make up the bases of selecting frustum.
//! When the set of such frustums is created, the function determining
//! selection iterates through triangular frustum set and searches for overlap with any frustum.
//! In other words, each triangle vertex will be projected from 2d screen space to 3d world space
//! onto near and far view frustum planes. Thus, the projected triangles make up the bases of
//! selecting frustum. When the set of such frustums is created, the function determining selection
//! iterates through triangular frustum set and searches for overlap with any frustum.
class SelectMgr_TriangularFrustumSet : public SelectMgr_BaseFrustum
{
public:
//! Auxiliary structure to define selection polyline
struct SelectionPolyline
{
@@ -39,7 +38,6 @@ public:
};
public:
//! Constructor.
SelectMgr_TriangularFrustumSet();
@@ -47,155 +45,176 @@ public:
Standard_EXPORT virtual ~SelectMgr_TriangularFrustumSet();
//! Initializes set of triangular frustums by polyline
Standard_EXPORT void Init (const TColgp_Array1OfPnt2d& thePoints);
Standard_EXPORT void Init(const TColgp_Array1OfPnt2d& thePoints);
//! Meshes polygon bounded by polyline. Than organizes a set of triangular frustums,
//! where each triangle's projection onto near and far view frustum planes is considered as a frustum base
//! NOTE: it should be called after Init() method
//! where each triangle's projection onto near and far view frustum planes is considered as a
//! frustum base NOTE: it should be called after Init() method
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
//! Returns FALSE (not applicable to this volume).
virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; }
//! Returns a copy of the frustum with all sub-volumes transformed according to the matrix given
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScale,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform(
const Standard_Integer theScale,
const gp_GTrsf& theTrsf,
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
//! Returns a copy of the frustum using the given frustum builder configuration.
//! Returned frustum should be re-constructed before being used.
//! @param[in] theBuilder argument that represents corresponding settings for re-constructing transformed frustum from scratch;
//! @param[in] theBuilder argument that represents corresponding settings for re-constructing
//! transformed frustum from scratch;
//! should NOT be NULL.
//! @return a copy of the frustum with the input builder assigned
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder(
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
public:
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
Standard_Boolean* theInside) const
Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
Standard_Boolean* theInside) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPoint(
const gp_Pnt& thePnt,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Always returns FALSE (not applicable to this selector).
virtual Standard_Boolean OverlapsPoint (const gp_Pnt& ) const Standard_OVERRIDE
virtual Standard_Boolean OverlapsPoint(const gp_Pnt&) const Standard_OVERRIDE
{
return Standard_False;
}
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsPolygon(
const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSegment(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsTriangle(
const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
public:
//! Calculates the point on a view ray that was detected during the run of selection algo by given depth
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
//! Calculates the point on a view ray that was detected during the run of selection algo by given
//! depth
Standard_EXPORT virtual gp_Pnt DetectedPoint(const Standard_Real theDepth) const
Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by sphere with center theCenter
//! and radius theRadius
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(const gp_Pnt& theCenter,
const Standard_Real theRadius,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by sphere with center theCenter
//! and radius theRadius
Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean OverlapsSphere(
const gp_Pnt& theCenter,
const Standard_Real theRadius,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(
const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
//! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCircle(const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const
Standard_OVERRIDE;
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
Standard_EXPORT virtual void GetPlanes(
NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
//! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will
//! mark both included and overlapped entities as matched
Standard_EXPORT virtual void SetAllowOverlapDetection (const Standard_Boolean theIsToAllow);
//! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the
//! algorithm will mark both included and overlapped entities as matched
Standard_EXPORT virtual void SetAllowOverlapDetection(const Standard_Boolean theIsToAllow);
//! 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:
//! Checks whether the segment intersects with the boundary of the current volume selection
Standard_EXPORT Standard_Boolean isIntersectBoundary (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2) const;
Standard_EXPORT Standard_Boolean isIntersectBoundary(const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2) const;
//! Checks whether the circle intersects with the boundary of the current volume selection
Standard_EXPORT Standard_Boolean isIntersectBoundary (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled) const;
Standard_EXPORT Standard_Boolean isIntersectBoundary(const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled) const;
//! Checks whether the triangle intersects with a segment
Standard_EXPORT static Standard_Boolean segmentTriangleIntersection (const gp_Pnt &theOrig, const gp_Vec& theDir,
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3);
Standard_EXPORT static Standard_Boolean segmentTriangleIntersection(const gp_Pnt& theOrig,
const gp_Vec& theDir,
const gp_Pnt& theV1,
const gp_Pnt& theV2,
const gp_Pnt& theV3);
Standard_EXPORT static Standard_Boolean segmentSegmentIntersection (const gp_Pnt& theStartPnt1,
const gp_Pnt& theEndPnt1,
const gp_Pnt& theStartPnt2,
const gp_Pnt& theEndPnt2);
Standard_EXPORT static Standard_Boolean segmentSegmentIntersection(const gp_Pnt& theStartPnt1,
const gp_Pnt& theEndPnt1,
const gp_Pnt& theStartPnt2,
const gp_Pnt& theEndPnt2);
Standard_EXPORT static Standard_Boolean pointInTriangle (const gp_Pnt& thePnt,
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3);
Standard_EXPORT static Standard_Boolean pointInTriangle(const gp_Pnt& thePnt,
const gp_Pnt& theV1,
const gp_Pnt& theV2,
const gp_Pnt& theV3);
private:
SelectMgr_TriangFrustums myFrustums; //!< set of triangular frustums
// clang-format off
SelectMgr_TriangFrustums myFrustums; //!< set of triangular frustums
// clang-format off
SelectionPolyline mySelPolyline; //!< parameters of selection polyline (it is used to build triangle frustum set)
TColgp_Array1OfPnt myBoundaryPoints; //!< boundary points
//! 1_____2
@@ -205,7 +224,7 @@ private:
//! | / \ |
//! 8|/_________\|7
Standard_Boolean myToAllowOverlap; //!< flag to detect only fully included sensitives or not
// clang-format on
// clang-format on
};
#endif // _SelectMgr_TriangularFrustumSet_HeaderFile

View File

@@ -18,21 +18,21 @@
#define _SelectMgr_TypeOfBVHUpdate_HeaderFile
//! Keeps track for BVH update state for each SelectMgr_Selection entity in a following way:
//! - Add : 2nd level BVH does not contain any of the selection's sensitive entities and they must be
//! added;
//! - Add : 2nd level BVH does not contain any of the selection's sensitive entities and they
//! must be added;
//! - Remove : all sensitive entities of the selection must be removed from 2nd level BVH;
//! - Renew : 2nd level BVH already contains sensitives of the selection, but the its complete update
//! and removal is required. Therefore, sensitives of the selection with this type of update
//! - Renew : 2nd level BVH already contains sensitives of the selection, but the its complete
//! update and removal is required. Therefore, sensitives of the selection with this type of update
//! must be removed from 2nd level BVH and added after recomputation.
//! - Invalidate : the 2nd level BVH needs to be rebuilt;
//! - None : entities of the selection are up to date.
enum SelectMgr_TypeOfBVHUpdate
{
SelectMgr_TBU_Add,
SelectMgr_TBU_Remove,
SelectMgr_TBU_Renew,
SelectMgr_TBU_Invalidate,
SelectMgr_TBU_None
SelectMgr_TBU_Add,
SelectMgr_TBU_Remove,
SelectMgr_TBU_Renew,
SelectMgr_TBU_Invalidate,
SelectMgr_TBU_None
};
#endif // _SelectMgr_TypeOfBVHUpdate_HeaderFile

View File

@@ -14,13 +14,17 @@
#ifndef _SelectMgr_TypeOfDepthTolerance_HeaderFile
#define _SelectMgr_TypeOfDepthTolerance_HeaderFile
//! Define the type of depth tolerance for considering picked entities to lie on the same depth (distance from eye to entity).
//! Define the type of depth tolerance for considering picked entities to lie on the same depth
//! (distance from eye to entity).
//! @sa SelectMgr_SortCriterion, SelectMgr_ViewerSelector
enum SelectMgr_TypeOfDepthTolerance
{
SelectMgr_TypeOfDepthTolerance_Uniform, //!< use a predefined tolerance value (defined in 3D world scale) to compare any entities
SelectMgr_TypeOfDepthTolerance_UniformPixels, //!< use a predefined tolerance value (defined in pixels) to compare any entities
SelectMgr_TypeOfDepthTolerance_SensitivityFactor, //!< use sensitivity factor (in pixels) assigned to specific entity
SelectMgr_TypeOfDepthTolerance_Uniform, //!< use a predefined tolerance value (defined in 3D world
//!< scale) to compare any entities
SelectMgr_TypeOfDepthTolerance_UniformPixels, //!< use a predefined tolerance value (defined in
//!< pixels) to compare any entities
SelectMgr_TypeOfDepthTolerance_SensitivityFactor, //!< use sensitivity factor (in pixels) assigned
//!< to specific entity
};
#endif // _SelectMgr_TypeOfDepthTolerance_HeaderFile

View File

@@ -23,9 +23,9 @@
//! - none.
enum SelectMgr_TypeOfUpdate
{
SelectMgr_TOU_Full,
SelectMgr_TOU_Partial,
SelectMgr_TOU_None
SelectMgr_TOU_Full,
SelectMgr_TOU_Partial,
SelectMgr_TOU_None
};
#endif // _SelectMgr_TypeOfUpdate_HeaderFile

View File

@@ -19,27 +19,26 @@
#include <NCollection_Vec3.hxx>
#include <NCollection_Vec4.hxx>
typedef NCollection_Vec3<Standard_Real> SelectMgr_Vec3;
typedef NCollection_Vec4<Standard_Real> SelectMgr_Vec4;
typedef NCollection_Mat4<Standard_Real> SelectMgr_Mat4;
typedef NCollection_Vec3<Standard_Real> SelectMgr_Vec3;
typedef NCollection_Vec4<Standard_Real> SelectMgr_Vec4;
typedef NCollection_Mat4<Standard_Real> SelectMgr_Mat4;
namespace SelectMgr_MatOp
{
inline SelectMgr_Vec3 Transform (const gp_Trsf& theTrsf,
const SelectMgr_Vec3& theVec)
inline SelectMgr_Vec3 Transform(const gp_Trsf& theTrsf, const SelectMgr_Vec3& theVec)
{
SelectMgr_Vec3 aRes(0.0);
for (Standard_Integer aRow = 1; aRow <= 3; ++aRow)
{
SelectMgr_Vec3 aRes (0.0);
for (Standard_Integer aRow = 1; aRow <= 3; ++aRow)
for (Standard_Integer aCol = 1; aCol <= 3; ++aCol)
{
for (Standard_Integer aCol = 1; aCol <= 3; ++aCol)
{
aRes[aRow - 1] += theVec[aCol - 1] * theTrsf.Value (aRow, aCol);
}
aRes[aRow - 1] += theTrsf.Value (aRow, 4);
aRes[aRow - 1] += theVec[aCol - 1] * theTrsf.Value(aRow, aCol);
}
return aRes;
aRes[aRow - 1] += theTrsf.Value(aRow, 4);
}
return aRes;
}
} // namespace SelectMgr_MatOp
#endif // _SelectMgr_VectorTypes_HeaderFile

View File

@@ -19,14 +19,15 @@
// function : AddClippingPlanes
// purpose :
// =======================================================================
void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes,
const gp_Ax1& thePickRay)
void SelectMgr_ViewClipRange::AddClippingPlanes(const Graphic3d_SequenceOfHClipPlane& thePlanes,
const gp_Ax1& thePickRay)
{
const gp_Dir& aViewRayDir = thePickRay.Direction();
const gp_Pnt& aNearPnt = thePickRay.Location();
Graphic3d_Vec4d aPlaneABCD;
for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next())
for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt(thePlanes); aPlaneIt.More();
aPlaneIt.Next())
{
const Handle(Graphic3d_ClipPlane)& aClipPlane = aPlaneIt.Value();
if (!aClipPlane->IsOn())
@@ -34,19 +35,20 @@ void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClip
continue;
}
Bnd_Range aSubRange (RealFirst(), RealLast());
for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipPlane.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get())
Bnd_Range aSubRange(RealFirst(), RealLast());
for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipPlane.get(); aSubPlaneIter != NULL;
aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get())
{
const gp_Pln aGeomPlane = aSubPlaneIter->ToPlane();
aGeomPlane.Coefficients (aPlaneABCD[0], aPlaneABCD[1], aPlaneABCD[2], aPlaneABCD[3]);
aGeomPlane.Coefficients(aPlaneABCD[0], aPlaneABCD[1], aPlaneABCD[2], aPlaneABCD[3]);
const gp_XYZ& aPlaneDirXYZ = aGeomPlane.Axis().Direction().XYZ();
Standard_Real aDotProduct = aViewRayDir.XYZ().Dot (aPlaneDirXYZ);
Standard_Real aDistance = -aNearPnt.XYZ().Dot (aPlaneDirXYZ) - aPlaneABCD[3];
Standard_Real aDistToPln = 0.0;
Standard_Real aDotProduct = aViewRayDir.XYZ().Dot(aPlaneDirXYZ);
Standard_Real aDistance = -aNearPnt.XYZ().Dot(aPlaneDirXYZ) - aPlaneABCD[3];
Standard_Real aDistToPln = 0.0;
// check whether the pick line is parallel to clip plane
if (Abs (aDotProduct) < Precision::Angular())
if (Abs(aDotProduct) < Precision::Angular())
{
if (aDistance < 0.0)
{
@@ -61,7 +63,7 @@ void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClip
const Standard_Real aParam = aDistance / aDotProduct;
const gp_Pnt anIntersectionPnt = aNearPnt.XYZ() + aViewRayDir.XYZ() * aParam;
aDistToPln = anIntersectionPnt.Distance (aNearPnt);
aDistToPln = anIntersectionPnt.Distance(aNearPnt);
if (aParam < 0.0)
{
// the plane is "behind" the ray
@@ -74,30 +76,29 @@ void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClip
{
if (aDotProduct < 0.0)
{
ChangeUnclipRange().TrimTo (aDistToPln);
ChangeUnclipRange().TrimTo(aDistToPln);
}
else
{
ChangeUnclipRange().TrimFrom (aDistToPln);
ChangeUnclipRange().TrimFrom(aDistToPln);
}
}
else
{
if (aDotProduct < 0.0)
{
aSubRange.TrimFrom (aDistToPln);
aSubRange.TrimFrom(aDistToPln);
}
else
{
aSubRange.TrimTo (aDistToPln);
aSubRange.TrimTo(aDistToPln);
}
}
}
if (!aSubRange.IsVoid()
&& aClipPlane->IsChain())
if (!aSubRange.IsVoid() && aClipPlane->IsChain())
{
AddClipSubRange (aSubRange);
AddClipSubRange(aSubRange);
}
}
}
@@ -106,14 +107,15 @@ void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClip
// function : DumpJson
// purpose :
// =======================================================================
void SelectMgr_ViewClipRange::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
void SelectMgr_ViewClipRange::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_ViewClipRange)
OCCT_DUMP_CLASS_BEGIN(theOStream, SelectMgr_ViewClipRange)
for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter)
{
Bnd_Range aClipRange = myClipRanges[aRangeIter];
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aClipRange)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &aClipRange)
}
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUnclipRange)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myUnclipRange)
}

View File

@@ -33,49 +33,46 @@ class SelectMgr_ViewClipRange
{
public:
//! Creates an empty clip range.
SelectMgr_ViewClipRange()
{
SetVoid();
}
SelectMgr_ViewClipRange() { SetVoid(); }
//! Check if the given depth is not within clipping range(s),
//! e.g. TRUE means depth is clipped.
Standard_Boolean IsClipped (const Standard_Real theDepth) const
Standard_Boolean IsClipped(const Standard_Real theDepth) const
{
if (myUnclipRange.IsOut (theDepth))
if (myUnclipRange.IsOut(theDepth))
{
return Standard_True;
}
for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter)
{
if (!myClipRanges[aRangeIter].IsOut (theDepth))
if (!myClipRanges[aRangeIter].IsOut(theDepth))
{
return Standard_True;
}
}
return Standard_False;
}
//! Calculates the min not clipped value from the range.
//! Returns FALSE if the whole range is clipped.
Standard_Boolean GetNearestDepth (const Bnd_Range& theRange, Standard_Real& theDepth) const
Standard_Boolean GetNearestDepth(const Bnd_Range& theRange, Standard_Real& theDepth) const
{
if (!myUnclipRange.IsVoid() && myUnclipRange.IsOut (theRange))
if (!myUnclipRange.IsVoid() && myUnclipRange.IsOut(theRange))
{
return false;
}
Bnd_Range aCommonClipRange;
theRange.GetMin (theDepth);
theRange.GetMin(theDepth);
if (!myUnclipRange.IsVoid() && myUnclipRange.IsOut (theDepth))
if (!myUnclipRange.IsVoid() && myUnclipRange.IsOut(theDepth))
{
myUnclipRange.GetMin (theDepth);
myUnclipRange.GetMin(theDepth);
}
for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter)
{
if (!myClipRanges[aRangeIter].IsOut (theDepth))
if (!myClipRanges[aRangeIter].IsOut(theDepth))
{
aCommonClipRange = myClipRanges[aRangeIter];
break;
@@ -89,44 +86,41 @@ public:
for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter)
{
if (!aCommonClipRange.IsOut (myClipRanges[aRangeIter]))
if (!aCommonClipRange.IsOut(myClipRanges[aRangeIter]))
{
aCommonClipRange.Add (myClipRanges[aRangeIter]);
aCommonClipRange.Add(myClipRanges[aRangeIter]);
}
}
aCommonClipRange.GetMax (theDepth);
aCommonClipRange.GetMax(theDepth);
return !theRange.IsOut (theDepth);
return !theRange.IsOut(theDepth);
}
public:
//! Clears clipping range.
void SetVoid()
{
myClipRanges.resize (0);
myUnclipRange = Bnd_Range (RealFirst(), RealLast());
myClipRanges.resize(0);
myUnclipRange = Bnd_Range(RealFirst(), RealLast());
}
//! Add clipping planes. Planes and picking ray should be defined in the same coordinate system.
Standard_EXPORT void AddClippingPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes,
const gp_Ax1& thePickRay);
Standard_EXPORT void AddClippingPlanes(const Graphic3d_SequenceOfHClipPlane& thePlanes,
const gp_Ax1& thePickRay);
//! Returns the main unclipped range; [-inf, inf] by default.
Bnd_Range& ChangeUnclipRange() { return myUnclipRange; }
//! Adds a clipping sub-range (for clipping chains).
void AddClipSubRange (const Bnd_Range& theRange) { myClipRanges.push_back (theRange); }
void AddClipSubRange(const Bnd_Range& theRange) { myClipRanges.push_back(theRange); }
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
Standard_EXPORT void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
private:
std::vector<Bnd_Range> myClipRanges;
Bnd_Range myUnclipRange;
Bnd_Range myUnclipRange;
};
#endif // _SelectMgr_ViewClipRange_HeaderFile

File diff suppressed because it is too large Load Diff

View File

@@ -42,10 +42,15 @@ class V3d_View;
#ifdef Status
#undef Status
#endif
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_SensitiveEntitySet) > SelectMgr_MapOfObjectSensitives;
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_SensitiveEntitySet) >::Iterator SelectMgr_MapOfObjectSensitivesIterator;
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject),
Handle(SelectMgr_SensitiveEntitySet)>
SelectMgr_MapOfObjectSensitives;
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject),
Handle(SelectMgr_SensitiveEntitySet)>::Iterator
SelectMgr_MapOfObjectSensitivesIterator;
typedef NCollection_DataMap<Standard_Integer, SelectMgr_SelectingVolumeManager> SelectMgr_FrustumCache;
typedef NCollection_DataMap<Standard_Integer, SelectMgr_SelectingVolumeManager>
SelectMgr_FrustumCache;
//! A framework to define finding, sorting the sensitive
//! primitives in a view. Services are also provided to
@@ -81,8 +86,8 @@ class SelectMgr_ViewerSelector : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(SelectMgr_ViewerSelector, Standard_Transient)
friend class SelectMgr_SelectionManager;
public:
public:
//! Constructs an empty selector object.
Standard_EXPORT SelectMgr_ViewerSelector();
@@ -90,7 +95,7 @@ public:
Standard_Integer CustomPixelTolerance() const { return myTolerances.CustomTolerance(); }
//! Sets the pixel tolerance <theTolerance>.
Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance);
Standard_EXPORT void SetPixelTolerance(const Standard_Integer theTolerance);
//! Returns the largest sensitivity of picking
Standard_Real Sensitivity() const { return myTolerances.Tolerance(); }
@@ -105,33 +110,34 @@ public:
//! and which is the closest to the last successful mouse position.
Handle(SelectMgr_EntityOwner) OnePicked() const
{
return mystored.IsEmpty()
? Handle(SelectMgr_EntityOwner)()
: Picked (1);
return mystored.IsEmpty() ? Handle(SelectMgr_EntityOwner)() : Picked(1);
}
//! Return the flag determining precedence of picked depth (distance from eye to entity) over entity priority in sorted results; TRUE by default.
//! When flag is TRUE, priority will be considered only if entities have the same depth within the tolerance.
//! When flag is FALSE, entities with higher priority will be in front regardless of their depth (like x-ray).
//! Return the flag determining precedence of picked depth (distance from eye to entity) over
//! entity priority in sorted results; TRUE by default. When flag is TRUE, priority will be
//! considered only if entities have the same depth within the tolerance. When flag is FALSE,
//! entities with higher priority will be in front regardless of their depth (like x-ray).
bool ToPickClosest() const { return myToPreferClosest; }
//! Set flag determining precedence of picked depth over entity priority in sorted results.
void SetPickClosest (bool theToPreferClosest) { myToPreferClosest = theToPreferClosest; }
void SetPickClosest(bool theToPreferClosest) { myToPreferClosest = theToPreferClosest; }
//! Return the type of tolerance for considering two entities having a similar depth (distance from eye to entity);
//! SelectMgr_TypeOfDepthTolerance_SensitivityFactor by default.
//! Return the type of tolerance for considering two entities having a similar depth (distance
//! from eye to entity); SelectMgr_TypeOfDepthTolerance_SensitivityFactor by default.
SelectMgr_TypeOfDepthTolerance DepthToleranceType() const { return myDepthTolType; }
//! Return the tolerance for considering two entities having a similar depth (distance from eye to entity).
//! Return the tolerance for considering two entities having a similar depth (distance from eye to
//! entity).
Standard_Real DepthTolerance() const { return myDepthTolerance; }
//! Set the tolerance for considering two entities having a similar depth (distance from eye to entity).
//! Set the tolerance for considering two entities having a similar depth (distance from eye to
//! entity).
//! @param[in] theType type of tolerance value
//! @param[in] theTolerance tolerance value in 3D scale (SelectMgr_TypeOfDepthTolerance_Uniform)
//! or in pixels (SelectMgr_TypeOfDepthTolerance_UniformPixels);
//! value is ignored in case of SelectMgr_TypeOfDepthTolerance_SensitivityFactor
void SetDepthTolerance (SelectMgr_TypeOfDepthTolerance theType,
Standard_Real theTolerance)
//! value is ignored in case of
//! SelectMgr_TypeOfDepthTolerance_SensitivityFactor
void SetDepthTolerance(SelectMgr_TypeOfDepthTolerance theType, Standard_Real theTolerance)
{
myDepthTolType = theType;
myDepthTolerance = theTolerance;
@@ -148,89 +154,101 @@ public:
//! Returns the entity Owner for the object picked at specified position.
//! @param theRank rank of detected object within range 1...NbPicked()
Standard_EXPORT Handle(SelectMgr_EntityOwner) Picked (const Standard_Integer theRank) const;
Standard_EXPORT Handle(SelectMgr_EntityOwner) Picked(const Standard_Integer theRank) const;
//! Returns the Entity for the object picked at specified position.
//! @param theRank rank of detected object within range 1...NbPicked()
Standard_EXPORT const SelectMgr_SortCriterion& PickedData (const Standard_Integer theRank) const;
Standard_EXPORT const SelectMgr_SortCriterion& PickedData(const Standard_Integer theRank) const;
//! Returns the Entity for the object picked at specified position.
//! @param theRank rank of detected object within range 1...NbPicked()
const Handle(Select3D_SensitiveEntity)& PickedEntity (const Standard_Integer theRank) const { return PickedData (theRank).Entity; }
const Handle(Select3D_SensitiveEntity)& PickedEntity(const Standard_Integer theRank) const
{
return PickedData(theRank).Entity;
}
//! Returns the 3D point (intersection of picking axis with the object nearest to eye)
//! for the object picked at specified position.
//! @param theRank rank of detected object within range 1...NbPicked()
gp_Pnt PickedPoint (const Standard_Integer theRank) const { return PickedData (theRank).Point; }
gp_Pnt PickedPoint(const Standard_Integer theRank) const { return PickedData(theRank).Point; }
//! Remove picked entities associated with specified object.
Standard_EXPORT Standard_Boolean RemovePicked (const Handle(SelectMgr_SelectableObject)& theObject);
Standard_EXPORT Standard_Boolean
RemovePicked(const Handle(SelectMgr_SelectableObject)& theObject);
Standard_EXPORT Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const;
Standard_EXPORT Standard_Boolean
Contains(const Handle(SelectMgr_SelectableObject)& theObject) const;
//! Returns the default builder used to construct BVH of entity set.
const Handle(Select3D_BVHBuilder3d) EntitySetBuilder() { return myEntitySetBuilder; }
//! Sets the default builder used to construct BVH of entity set.
//! The new builder will be also assigned for already defined objects, but computed BVH trees will not be invalidated.
Standard_EXPORT void SetEntitySetBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder);
//! The new builder will be also assigned for already defined objects, but computed BVH trees will
//! not be invalidated.
Standard_EXPORT void SetEntitySetBuilder(const Handle(Select3D_BVHBuilder3d)& theBuilder);
//! Returns the list of selection modes ModeList found in
//! this selector for the selectable object aSelectableObject.
//! Returns true if aSelectableObject is referenced inside
//! this selector; returns false if the object is not present
//! in this selector.
Standard_EXPORT Standard_Boolean Modes (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
TColStd_ListOfInteger& theModeList,
const SelectMgr_StateOfSelection theWantedState = SelectMgr_SOS_Any) const;
Standard_EXPORT Standard_Boolean
Modes(const Handle(SelectMgr_SelectableObject)& theSelectableObject,
TColStd_ListOfInteger& theModeList,
const SelectMgr_StateOfSelection theWantedState = SelectMgr_SOS_Any) const;
//! Returns true if the selectable object
//! aSelectableObject having the selection mode aMode
//! is active in this selector.
Standard_EXPORT Standard_Boolean IsActive (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
const Standard_Integer theMode) const;
Standard_EXPORT Standard_Boolean
IsActive(const Handle(SelectMgr_SelectableObject)& theSelectableObject,
const Standard_Integer theMode) const;
//! Returns true if the selectable object
//! aSelectableObject having the selection mode aMode
//! is in this selector.
Standard_EXPORT Standard_Boolean IsInside (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
const Standard_Integer theMode) const;
Standard_EXPORT Standard_Boolean
IsInside(const Handle(SelectMgr_SelectableObject)& theSelectableObject,
const Standard_Integer theMode) const;
//! Returns the selection status Status of the selection aSelection.
Standard_EXPORT SelectMgr_StateOfSelection Status (const Handle(SelectMgr_Selection)& theSelection) const;
Standard_EXPORT SelectMgr_StateOfSelection
Status(const Handle(SelectMgr_Selection)& theSelection) const;
Standard_EXPORT TCollection_AsciiString Status (const Handle(SelectMgr_SelectableObject)& theSelectableObject) const;
Standard_EXPORT TCollection_AsciiString
Status(const Handle(SelectMgr_SelectableObject)& theSelectableObject) const;
//! Returns the list of active entity owners
Standard_EXPORT void ActiveOwners (NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners) const;
Standard_EXPORT void ActiveOwners(
NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners) const;
//! Adds new object to the map of selectable objects
Standard_EXPORT void AddSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject);
Standard_EXPORT void AddSelectableObject(const Handle(SelectMgr_SelectableObject)& theObject);
//! Adds new selection to the object and builds its BVH tree
Standard_EXPORT void AddSelectionToObject (const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_Selection)& theSelection);
Standard_EXPORT void AddSelectionToObject(const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_Selection)& theSelection);
//! Moves existing object from set of not transform persistence objects
//! to set of transform persistence objects (or vice versa).
Standard_EXPORT void MoveSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject);
Standard_EXPORT void MoveSelectableObject(const Handle(SelectMgr_SelectableObject)& theObject);
//! Removes selectable object from map of selectable ones
Standard_EXPORT void RemoveSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject);
Standard_EXPORT void RemoveSelectableObject(const Handle(SelectMgr_SelectableObject)& theObject);
//! Removes selection of the object and marks its BVH tree for rebuild
Standard_EXPORT void RemoveSelectionOfObject (const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_Selection)& theSelection);
Standard_EXPORT void RemoveSelectionOfObject(const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_Selection)& theSelection);
//! Marks BVH of selectable objects for rebuild. Parameter theIsForce set as true
//! guarantees that 1st level BVH for the viewer selector will be rebuilt during this call
Standard_EXPORT void RebuildObjectsTree (const Standard_Boolean theIsForce = Standard_False);
Standard_EXPORT void RebuildObjectsTree(const Standard_Boolean theIsForce = Standard_False);
//! Marks BVH of sensitive entities of particular selectable object for rebuild. Parameter
//! theIsForce set as true guarantees that 2nd level BVH for the object given will be
//! rebuilt during this call
Standard_EXPORT void RebuildSensitivesTree (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Boolean theIsForce = Standard_False);
Standard_EXPORT void RebuildSensitivesTree(const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Boolean theIsForce = Standard_False);
//! Returns instance of selecting volume manager of the viewer selector
SelectMgr_SelectingVolumeManager& GetManager() { return mySelectingVolumeMgr; }
@@ -242,36 +260,34 @@ public:
Standard_EXPORT void ResetSelectionActivationStatus();
//! Is used for rectangular selection only
//! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will
//! mark both included and overlapped entities as matched
Standard_EXPORT void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
//! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the
//! algorithm will mark both included and overlapped entities as matched
Standard_EXPORT void AllowOverlapDetection(const Standard_Boolean theIsToAllow);
public:
//! Picks the sensitive entity at the pixel coordinates of
//! the mouse <theXPix> and <theYPix>. The selector looks for touched areas and owners.
Standard_EXPORT void Pick (const Standard_Integer theXPix,
const Standard_Integer theYPix,
const Handle(V3d_View)& theView);
Standard_EXPORT void Pick(const Standard_Integer theXPix,
const Standard_Integer theYPix,
const Handle(V3d_View)& theView);
//! Picks the sensitive entity according to the minimum
//! and maximum pixel values <theXPMin>, <theYPMin>, <theXPMax>
//! and <theYPMax> defining a 2D area for selection in the 3D view aView.
Standard_EXPORT void Pick (const Standard_Integer theXPMin,
const Standard_Integer theYPMin,
const Standard_Integer theXPMax,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView);
Standard_EXPORT void Pick(const Standard_Integer theXPMin,
const Standard_Integer theYPMin,
const Standard_Integer theXPMax,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView);
//! pick action - input pixel values for polyline selection for selection.
Standard_EXPORT void Pick (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView);
Standard_EXPORT void Pick(const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView);
//! Picks the sensitive entity according to the input axis.
//! This is geometric intersection 3D objects by axis
//! (camera parameters are ignored and objects with transform persistence are skipped).
Standard_EXPORT void Pick (const gp_Ax1& theAxis,
const Handle(V3d_View)& theView);
Standard_EXPORT void Pick(const gp_Ax1& theAxis, const Handle(V3d_View)& theView);
//! Dump of detection results into image.
//! This method performs axis picking for each pixel in the image
@@ -280,30 +296,29 @@ public:
//! @param theView 3D view defining camera position
//! @param theType type of image to define
//! @param thePickedIndex index of picked entity (1 means topmost)
Standard_EXPORT Standard_Boolean ToPixMap (Image_PixMap& theImage,
const Handle(V3d_View)& theView,
const StdSelect_TypeOfSelectionImage theType,
const Standard_Integer thePickedIndex = 1);
Standard_EXPORT Standard_Boolean ToPixMap(Image_PixMap& theImage,
const Handle(V3d_View)& theView,
const StdSelect_TypeOfSelectionImage theType,
const Standard_Integer thePickedIndex = 1);
public:
//! Displays sensitives in view <theView>.
Standard_EXPORT void DisplaySensitive (const Handle(V3d_View)& theView);
Standard_EXPORT void DisplaySensitive(const Handle(V3d_View)& theView);
Standard_EXPORT void ClearSensitive (const Handle(V3d_View)& theView);
Standard_EXPORT void ClearSensitive(const Handle(V3d_View)& theView);
Standard_EXPORT void DisplaySensitive (const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theTrsf,
const Handle(V3d_View)& theView,
const Standard_Boolean theToClearOthers = Standard_True);
Standard_EXPORT void DisplaySensitive(const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theTrsf,
const Handle(V3d_View)& theView,
const Standard_Boolean theToClearOthers = Standard_True);
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
Standard_EXPORT void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
public:
//! Enables/disables building BVH for sensitives in separate threads
Standard_EXPORT void SetToPrebuildBVH(Standard_Boolean theToPrebuild, Standard_Integer theThreadsNum = -1);
Standard_EXPORT void SetToPrebuildBVH(Standard_Boolean theToPrebuild,
Standard_Integer theThreadsNum = -1);
//! Queues a sensitive entity to build its BVH
Standard_EXPORT void QueueBVHBuild(const Handle(Select3D_SensitiveEntity)& theEntity);
@@ -312,99 +327,93 @@ public:
Standard_EXPORT void WaitForBVHBuild();
//! Returns TRUE if building BVH for sensitives in separate threads is enabled
Standard_Boolean ToPrebuildBVH() const
{
return myToPrebuildBVH;
}
Standard_Boolean ToPrebuildBVH() const { return myToPrebuildBVH; }
protected:
//! Traverses BVH containing all added selectable objects and
//! finds candidates for further search of overlap
Standard_EXPORT void TraverseSensitives (const Standard_Integer theViewId = -1);
Standard_EXPORT void TraverseSensitives(const Standard_Integer theViewId = -1);
//! Internal function that checks if there is possible overlap between some entity of selectable object theObject and
//! current selecting volume.
//! Internal function that checks if there is possible overlap between some entity of selectable
//! object theObject and current selecting volume.
//! @param[in] theObject the selectable object for traversal.
//! @param[in] theMgr the (un)transformed copy of the selecting volume manager representing active selection frustum.
//! @param theCamera, theProjectionMat, theWorldViewMat[in] the source camera and matrices for theMgr given.
//! @param[in] theWinSize viewport (window) dimensions for evaluating
//! @param[in] theMgr the (un)transformed copy of the selecting volume manager representing
//! active selection frustum.
//! @param theCamera, theProjectionMat, theWorldViewMat[in] the source camera and matrices for
//! theMgr given.
//! @param[in] theWinSize viewport (window) dimensions for evaluating
//! object's transformation persistence.
Standard_EXPORT void traverseObject (const Handle(SelectMgr_SelectableObject)& theObject,
const SelectMgr_SelectingVolumeManager& theMgr,
const Handle(Graphic3d_Camera)& theCamera,
const Graphic3d_Mat4d& theProjectionMat,
const Graphic3d_Mat4d& theWorldViewMat,
const Graphic3d_Vec2i& theWinSize);
Standard_EXPORT void traverseObject(const Handle(SelectMgr_SelectableObject)& theObject,
const SelectMgr_SelectingVolumeManager& theMgr,
const Handle(Graphic3d_Camera)& theCamera,
const Graphic3d_Mat4d& theProjectionMat,
const Graphic3d_Mat4d& theWorldViewMat,
const Graphic3d_Vec2i& theWinSize);
//! Internal function that checks if a particular sensitive
//! entity theEntity overlaps current selecting volume precisely
Standard_EXPORT void checkOverlap (const Handle(Select3D_SensitiveEntity)& theEntity,
const gp_GTrsf& theInversedTrsf,
SelectMgr_SelectingVolumeManager& theMgr);
Standard_EXPORT void checkOverlap(const Handle(Select3D_SensitiveEntity)& theEntity,
const gp_GTrsf& theInversedTrsf,
SelectMgr_SelectingVolumeManager& theMgr);
//! Update z-layers order map.
Standard_EXPORT void updateZLayers (const Handle(V3d_View)& theView);
Standard_EXPORT void updateZLayers(const Handle(V3d_View)& theView);
private:
//! Checks if the entity given requires to scale current selecting frustum
Standard_Boolean isToScaleFrustum (const Handle(Select3D_SensitiveEntity)& theEntity);
Standard_Boolean isToScaleFrustum(const Handle(Select3D_SensitiveEntity)& theEntity);
//! In case if custom tolerance is set, this method will return sum of entity sensitivity and
//! custom tolerance. Otherwise, pure entity sensitivity factor will be returned.
Standard_Integer sensitivity (const Handle(Select3D_SensitiveEntity)& theEntity) const;
Standard_Integer sensitivity(const Handle(Select3D_SensitiveEntity)& theEntity) const;
void Activate (const Handle(SelectMgr_Selection)& theSelection);
void Activate(const Handle(SelectMgr_Selection)& theSelection);
void Deactivate (const Handle(SelectMgr_Selection)& theSelection);
void Deactivate(const Handle(SelectMgr_Selection)& theSelection);
//! removes a Selection from the Selector
void Remove (const Handle(SelectMgr_Selection)& aSelection);
//! Internal function that checks if a current selecting frustum needs to be scaled and transformed for the entity and performs necessary calculations.
void computeFrustum (const Handle(Select3D_SensitiveEntity)& theEnt,
const SelectMgr_SelectingVolumeManager& theMgrGlobal,
const SelectMgr_SelectingVolumeManager& theMgrObject,
const gp_GTrsf& theInvTrsf,
SelectMgr_FrustumCache& theCachedMgrs,
SelectMgr_SelectingVolumeManager& theResMgr);
void Remove(const Handle(SelectMgr_Selection)& aSelection);
//! Internal function that checks if a current selecting frustum needs to be scaled and
//! transformed for the entity and performs necessary calculations.
void computeFrustum(const Handle(Select3D_SensitiveEntity)& theEnt,
const SelectMgr_SelectingVolumeManager& theMgrGlobal,
const SelectMgr_SelectingVolumeManager& theMgrObject,
const gp_GTrsf& theInvTrsf,
SelectMgr_FrustumCache& theCachedMgrs,
SelectMgr_SelectingVolumeManager& theResMgr);
private:
//! Compute 3d position for detected entity.
void updatePoint3d (SelectMgr_SortCriterion& theCriterion,
const SelectBasics_PickResult& thePickResult,
const Handle(Select3D_SensitiveEntity)& theEntity,
const gp_GTrsf& theInversedTrsf,
const SelectMgr_SelectingVolumeManager& theMgr) const;
void updatePoint3d(SelectMgr_SortCriterion& theCriterion,
const SelectBasics_PickResult& thePickResult,
const Handle(Select3D_SensitiveEntity)& theEntity,
const gp_GTrsf& theInversedTrsf,
const SelectMgr_SelectingVolumeManager& theMgr) const;
protected:
Standard_Real myDepthTolerance;
SelectMgr_TypeOfDepthTolerance myDepthTolType;
Standard_Boolean myToPreferClosest;
SelectMgr_IndexedDataMapOfOwnerCriterion mystored;
SelectMgr_SelectingVolumeManager mySelectingVolumeMgr;
mutable SelectMgr_SelectableObjectSet mySelectableObjects;
SelectMgr_ToleranceMap myTolerances;
Standard_Real myDepthTolerance;
SelectMgr_TypeOfDepthTolerance myDepthTolType;
Standard_Boolean myToPreferClosest;
SelectMgr_IndexedDataMapOfOwnerCriterion mystored;
SelectMgr_SelectingVolumeManager mySelectingVolumeMgr;
mutable SelectMgr_SelectableObjectSet mySelectableObjects;
SelectMgr_ToleranceMap myTolerances;
NCollection_DataMap<Graphic3d_ZLayerId, Standard_Integer> myZLayerOrderMap;
Handle(Select3D_BVHBuilder3d) myEntitySetBuilder;
gp_Pnt myCameraEye;
gp_Dir myCameraDir;
Standard_Real myCameraScale;
Handle(Select3D_BVHBuilder3d) myEntitySetBuilder;
gp_Pnt myCameraEye;
gp_Dir myCameraDir;
Standard_Real myCameraScale;
Standard_Boolean myToPrebuildBVH;
Handle(SelectMgr_BVHThreadPool) myBVHThreadPool;
Standard_Boolean myToPrebuildBVH;
Handle(SelectMgr_BVHThreadPool) myBVHThreadPool;
mutable TColStd_Array1OfInteger myIndexes;
mutable Standard_Boolean myIsSorted;
Standard_Boolean myIsLeftChildQueuedFirst;
SelectMgr_MapOfObjectSensitives myMapOfObjectSensitives;
Graphic3d_SequenceOfStructure myStructs; //!< list of debug presentations
mutable TColStd_Array1OfInteger myIndexes;
mutable Standard_Boolean myIsSorted;
Standard_Boolean myIsLeftChildQueuedFirst;
SelectMgr_MapOfObjectSensitives myMapOfObjectSensitives;
Graphic3d_SequenceOfStructure myStructs; //!< list of debug presentations
};
DEFINE_STANDARD_HANDLE(SelectMgr_ViewerSelector, Standard_Transient)