1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0027945: Visualization - handle correctly view clipping planes within zoom-persistent objects

OpenGl_Structure::Render() and SelectMgr_ViewerSelector::checkOverlap()
now clip entire zoom/rotate persistence object
by checking anchor point with global clipping planes.

Image dump has been added to the new test case.
This commit is contained in:
kgv
2016-10-13 14:01:19 +03:00
committed by apn
parent a8122531ce
commit 8b1441e374
5 changed files with 148 additions and 7 deletions

View File

@@ -60,6 +60,7 @@ SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTrans
= mySelectingVolumes[myActiveSelectionType / 2]->ScaleAndTransform (theScaleFactor, theTrsf);
aMgr.myToAllowOverlap = myToAllowOverlap;
aMgr.mySelectingVolumes[myActiveSelectionType / 2]->SetBuilder (theBuilder);
aMgr.myViewClipPlanes = myViewClipPlanes;
return aMgr;
}
@@ -469,6 +470,7 @@ gp_Pnt SelectMgr_SelectingVolumeManager::GetFarPickedPnt() const
//=======================================================================
void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
{
myViewClipPlanes = thePlanes;
if (myActiveSelectionType != Point)
return;

View File

@@ -170,6 +170,9 @@ public:
Standard_EXPORT virtual Standard_Boolean IsOverlapAllowed() const Standard_OVERRIDE;
//! Return view clipping planes.
const Handle(Graphic3d_SequenceOfHClipPlane)& ViewClipping() const { return myViewClipPlanes; }
//! Valid for point selection only!
//! Computes depth range for global (defined for the whole view) clipping planes.
Standard_EXPORT void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes);
@@ -196,8 +199,9 @@ public:
private:
enum { Frustum, FrustumSet, VolumeTypesNb }; //!< Defines the amount of available selecting volumes
Handle(SelectMgr_BaseFrustum) mySelectingVolumes[VolumeTypesNb]; //!< Array of selecting volumes
Standard_Boolean myToAllowOverlap; //!< Defines if partially overlapped entities will me detected or not
Handle(SelectMgr_BaseFrustum) mySelectingVolumes[VolumeTypesNb]; //!< Array of selecting volumes
Handle(Graphic3d_SequenceOfHClipPlane) myViewClipPlanes; //!< view clipping planes
Standard_Boolean myToAllowOverlap; //!< Defines if partially overlapped entities will me detected or not
};
#endif
#endif

View File

@@ -176,12 +176,44 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive
if (!anOwner.IsNull())
{
aSelectable = anOwner->Selectable();
if ((!aSelectable->TransformPersistence().IsNull() && aSelectable->TransformPersistence()->IsTrihedronOr2d())
|| (!aSelectable->ClipPlanes().IsNull() && aSelectable->ClipPlanes()->ToOverrideGlobal()))
if (!aSelectable->ClipPlanes().IsNull()
&& aSelectable->ClipPlanes()->ToOverrideGlobal())
{
theMgr.SetViewClippingEnabled (Standard_False);
toRestoresViewClipEnabled = Standard_True;
}
else if (!aSelectable->TransformPersistence().IsNull())
{
if (aSelectable->TransformPersistence()->IsZoomOrRotate()
&& !theMgr.ViewClipping().IsNull())
{
// Zoom/rotate persistence object lives in two worlds at the same time.
// Global clipping planes can not be trivially applied without being converted
// into local space of transformation persistence object.
// As more simple alternative - just clip entire object by its anchor point defined in the world space.
const Handle(Graphic3d_SequenceOfHClipPlane)& aViewPlanes = theMgr.ViewClipping();
const gp_Pnt anAnchor = aSelectable->TransformPersistence()->AnchorPoint();
for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aViewPlanes); aPlaneIt.More(); aPlaneIt.Next())
{
const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
if (!aPlane->IsOn())
{
continue;
}
const Graphic3d_Vec4d& aPlaneEquation = aPlane->GetEquation();
const Graphic3d_Vec4d aCheckPnt (anAnchor.X(), anAnchor.Y(), anAnchor.Z(), 1.0);
if (aPlaneEquation.Dot (aCheckPnt) < 0.0) // vertex is outside the half-space
{
return;
}
}
}
theMgr.SetViewClippingEnabled (Standard_False);
toRestoresViewClipEnabled = Standard_True;
}
}
SelectBasics_PickResult aPickResult;