mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030058: Visualization, Select3D_SensitivePrimitiveArray - the selection is not fast enough
Select3D_SensitiveSet::Matches() has been improved to check if BVH node is fully included by selection volume and pass this information to overlapsElement()/elementIsInside() interfaces to avoid expensive partial overlapping checks for individual elements. Select3D_SensitivePrimitiveArray implements this new interface to improve partial overlapping performance. Select3D_SensitivePrimitiveArray::Matches() now handles rectangle selection for sub-elements when Elements map is defined. Added missing const to SelectMgr_BaseFrustum::Overlaps() methods. AIS_PointCloud has been extended with new selection mode for collecting selected nodes Draw Harness command vdrawparray has been extended with an option -shape allowing to create a triangulation from tessellated shape.
This commit is contained in:
@@ -32,8 +32,140 @@
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <StdPrs_BndBox.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud,AIS_InteractiveObject)
|
||||
//=======================================================================
|
||||
//function : AIS_PointCloudOwner
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_PointCloudOwner::AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin)
|
||||
: SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theOrigin, 5),
|
||||
myDetPoints (new TColStd_HPackedMapOfInteger()),
|
||||
mySelPoints (new TColStd_HPackedMapOfInteger())
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ~AIS_PointCloudOwner
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_PointCloudOwner::~AIS_PointCloudOwner()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightWithColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_PointCloudOwner::IsForcedHilight() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightWithColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer )
|
||||
{
|
||||
Handle(AIS_PointCloud) anObj = Handle(AIS_PointCloud)::DownCast (Selectable());
|
||||
if (anObj.IsNull())
|
||||
{
|
||||
throw Standard_ProgramError ("Internal Error within AIS_PointCloud::PointsOwner!");
|
||||
}
|
||||
|
||||
const Handle(TColStd_HPackedMapOfInteger)& aMap = thePrsMgr->IsImmediateModeOn()
|
||||
? myDetPoints
|
||||
: mySelPoints;
|
||||
Handle(Prs3d_Presentation) aPrs = thePrsMgr->IsImmediateModeOn()
|
||||
? anObj->GetHilightPresentation(thePrsMgr)
|
||||
: anObj->GetSelectPresentation (thePrsMgr);
|
||||
const Graphic3d_ZLayerId aZLayer = theStyle->ZLayer() != -1
|
||||
? theStyle->ZLayer()
|
||||
: (thePrsMgr->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : anObj->ZLayer());
|
||||
aMap->ChangeMap().Clear();
|
||||
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_SensitiveEntity)& aSelEnt = aSelEntIter.Value();
|
||||
if (aSelEnt->BaseSensitive()->OwnerId() == this)
|
||||
{
|
||||
if (Handle(Select3D_SensitivePrimitiveArray) aSensitive = Handle(Select3D_SensitivePrimitiveArray)::DownCast (aSelEnt->BaseSensitive()))
|
||||
{
|
||||
aMap->ChangeMap() = aSensitive->LastDetectedElementMap()->Map();
|
||||
if (aSensitive->LastDetectedElement() != -1)
|
||||
{
|
||||
aMap->ChangeMap().Add (aSensitive->LastDetectedElement());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aPrs->Clear();
|
||||
if (aPrs->GetZLayer() != aZLayer)
|
||||
{
|
||||
aPrs->SetZLayer (aZLayer);
|
||||
}
|
||||
if (aMap->Map().IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(Graphic3d_ArrayOfPoints) anAllPoints = anObj->GetPoints();
|
||||
if (anAllPoints.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (aMap->Map().Extent());
|
||||
for (TColStd_PackedMapOfInteger::Iterator aPntIter (aMap->Map()); aPntIter.More(); aPntIter.Next())
|
||||
{
|
||||
const gp_Pnt aPnt = anAllPoints->Vertice (aPntIter.Key() + 1);
|
||||
aPoints->AddVertex (aPnt);
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (theStyle->PointAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aPoints);
|
||||
if (thePrsMgr->IsImmediateModeOn())
|
||||
{
|
||||
thePrsMgr->AddToImmediateList (aPrs);
|
||||
}
|
||||
else
|
||||
{
|
||||
aPrs->Display();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Unhilight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_PointCloudOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer )
|
||||
{
|
||||
if (Handle(Prs3d_Presentation) aPrs = Selectable()->GetSelectPresentation (Handle(PrsMgr_PresentationManager3d)()))
|
||||
{
|
||||
aPrs->Erase();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_PointCloudOwner::Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode)
|
||||
{
|
||||
SelectMgr_EntityOwner::Clear (thePrsMgr, theMode);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: AIS_PointCloud
|
||||
@@ -46,6 +178,8 @@ AIS_PointCloud::AIS_PointCloud()
|
||||
|
||||
SetDisplayMode (AIS_PointCloud::DM_Points);
|
||||
SetHilightMode (AIS_PointCloud::DM_BndBox);
|
||||
|
||||
myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 1.0));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -432,14 +566,22 @@ void AIS_PointCloud::ComputeSelection (const Handle(SelectMgr_Selection)& theSel
|
||||
switch (theMode)
|
||||
{
|
||||
case SM_Points:
|
||||
case SM_SubsetOfPoints:
|
||||
{
|
||||
const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints();
|
||||
if (!aPoints.IsNull()
|
||||
&& !aPoints->Attributes().IsNull())
|
||||
{
|
||||
if (theMode == SM_SubsetOfPoints)
|
||||
{
|
||||
anOwner = new AIS_PointCloudOwner (this);
|
||||
}
|
||||
|
||||
// split large point clouds into several groups
|
||||
const Standard_Integer aNbGroups = aPoints->Attributes()->NbElements > 500000 ? 8 : 1;
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anOwner);
|
||||
aSensitive->SetDetectElements (true);
|
||||
aSensitive->SetDetectElementMap (theMode == SM_SubsetOfPoints);
|
||||
aSensitive->SetSensitivityFactor (8);
|
||||
aSensitive->InitPoints (aPoints->Attributes(), aPoints->Indices(), TopLoc_Location(), true, aNbGroups);
|
||||
aSensitive->BVH();
|
||||
|
@@ -21,14 +21,11 @@
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <Graphic3d_ArrayOfPoints.hxx>
|
||||
#include <Quantity_HArray1OfColor.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <TColgp_HArray1OfDir.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
|
||||
class AIS_PointCloud;
|
||||
DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject)
|
||||
class TColStd_HPackedMapOfInteger;
|
||||
|
||||
//! Interactive object for set of points.
|
||||
//! The presentation supports two display modes:
|
||||
@@ -43,7 +40,7 @@ DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject)
|
||||
//! hilight mode, e.g. 100);
|
||||
class AIS_PointCloud : public AIS_InteractiveObject
|
||||
{
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Display modes supported by this Point Cloud object
|
||||
@@ -56,8 +53,9 @@ public:
|
||||
//! Selection modes supported by this Point Cloud object
|
||||
enum SelectionMode
|
||||
{
|
||||
SM_Points = 0, //!< detected by points
|
||||
SM_BndBox = 2 //!< detected by bounding box
|
||||
SM_Points = 0, //!< detected by points
|
||||
SM_SubsetOfPoints = 1, //!< detect point(s) within Point Cloud rather than object as whole
|
||||
SM_BndBox = 2, //!< detected by bounding box
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -121,10 +119,45 @@ private:
|
||||
Handle(Graphic3d_ArrayOfPoints) myPoints; //!< points array for presentation
|
||||
Bnd_Box myBndBox; //!< bounding box for presentation
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject)
|
||||
|
||||
//! Custom owner for highlighting selected points.
|
||||
class AIS_PointCloudOwner : public SelectMgr_EntityOwner
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
|
||||
public:
|
||||
//! Main constructor.
|
||||
Standard_EXPORT AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin);
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_PointCloud,AIS_InteractiveObject)
|
||||
//! Destructor.
|
||||
Standard_EXPORT virtual ~AIS_PointCloudOwner();
|
||||
|
||||
//! Return selected points.
|
||||
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()).
|
||||
const Handle(TColStd_HPackedMapOfInteger)& SelectedPoints() const { return mySelPoints; }
|
||||
|
||||
//! Return last detected points.
|
||||
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()).
|
||||
const Handle(TColStd_HPackedMapOfInteger)& DetectedPoints() const { return myDetPoints; }
|
||||
|
||||
//! Always update dynamic highlighting.
|
||||
Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE;
|
||||
|
||||
//! Handle dynamic highlighting.
|
||||
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Removes highlighting.
|
||||
Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Clears presentation.
|
||||
Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
protected:
|
||||
Handle(TColStd_HPackedMapOfInteger) myDetPoints; //!< last detected points
|
||||
Handle(TColStd_HPackedMapOfInteger) mySelPoints; //!< selected points
|
||||
};
|
||||
|
||||
#endif // _AIS_PointCloud_HeaderFile
|
||||
|
Reference in New Issue
Block a user