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

0029729: Visualization, Graphic3d_ClipPlane - add support of clipping plane chains

Graphic3d_ClipPlane now can define a Chain of Planes (logical AND).
OpenGl_ShaderManager - added new GLSL sub-programs for clipping plane chains.
Bnd_Range::TrimFrom(), ::TrimTo() - added auxiliary methods for trimming the range.
SelectMgr_ViewClipRange now handles non-continuous clipping range.
Graphic3d_SequenceOfHClipPlane now aggregates NCollection_Sequence instead of inheritance.
OpenGl_CappingPlaneResource - triangulation has been adjusted to make front face following CCW order.
This commit is contained in:
kgv
2018-05-25 10:13:38 +03:00
committed by bugmaster
parent 012264339e
commit 25c35042b6
34 changed files with 1063 additions and 407 deletions

View File

@@ -16,6 +16,7 @@
#include <OpenGl_CappingAlgo.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_GlCore11.hxx>
#include <OpenGl_ClippingIterator.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
@@ -24,9 +25,6 @@
#include <OpenGl_View.hxx>
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Structure,Graphic3d_CStructure)
//! Auxiliary class for bounding box presentation
@@ -551,7 +549,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
}
// Collect clipping planes of structure scope
aCtx->ChangeClipping().SetLocalPlanes (aCtx, myClipPlanes);
aCtx->ChangeClipping().SetLocalPlanes (myClipPlanes);
// True if structure is fully clipped
bool isClipped = false;
@@ -562,7 +560,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
if (!myClipPlanes.IsNull()
&& myClipPlanes->ToOverrideGlobal())
{
aCtx->ChangeClipping().DisableGlobal (aCtx);
aCtx->ChangeClipping().DisableGlobal();
hasDisabled = aCtx->Clipping().HasDisabled();
}
else if (!myTrsfPers.IsNull())
@@ -583,9 +581,8 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
}
// check for clipping
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
if (aPlane->ProbePoint (aCheckPnt) == Graphic3d_ClipState_Out)
{
isClipped = true;
break;
@@ -593,7 +590,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
}
}
aCtx->ChangeClipping().DisableGlobal (aCtx);
aCtx->ChangeClipping().DisableGlobal();
hasDisabled = aCtx->Clipping().HasDisabled();
}
@@ -610,26 +607,15 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
continue;
}
// check for clipping
const Graphic3d_Vec4d& aPlaneEquation = aPlane->GetEquation();
const Graphic3d_Vec4d aMaxPnt (aPlaneEquation.x() > 0.0 ? aBBox.CornerMax().x() : aBBox.CornerMin().x(),
aPlaneEquation.y() > 0.0 ? aBBox.CornerMax().y() : aBBox.CornerMin().y(),
aPlaneEquation.z() > 0.0 ? aBBox.CornerMax().z() : aBBox.CornerMin().z(),
1.0);
if (aPlaneEquation.Dot (aMaxPnt) < 0.0) // max vertex is outside the half-space
const Graphic3d_ClipState aBoxState = aPlane->ProbeBox (aBBox);
if (aBoxState == Graphic3d_ClipState_Out)
{
isClipped = true;
break;
}
// check for no intersection (e.g. object is "entirely not clipped")
const Graphic3d_Vec4d aMinPnt (aPlaneEquation.x() > 0.0 ? aBBox.CornerMin().x() : aBBox.CornerMax().x(),
aPlaneEquation.y() > 0.0 ? aBBox.CornerMin().y() : aBBox.CornerMax().y(),
aPlaneEquation.z() > 0.0 ? aBBox.CornerMin().z() : aBBox.CornerMax().z(),
1.0);
if (aPlaneEquation.Dot (aMinPnt) > 0.0) // min vertex is inside the half-space
else if (aBoxState == Graphic3d_ClipState_In)
{
aCtx->ChangeClipping().SetEnabled (aCtx, aPlaneIt, Standard_False);
aCtx->ChangeClipping().SetEnabled (aPlaneIt, false);
hasDisabled = true;
}
}
@@ -667,9 +653,9 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
if (hasDisabled)
{
// enable planes that were previously disabled
aCtx->ChangeClipping().RestoreDisabled (aCtx);
aCtx->ChangeClipping().RestoreDisabled();
}
aCtx->ChangeClipping().SetLocalPlanes (aCtx, Handle(Graphic3d_SequenceOfHClipPlane)());
aCtx->ChangeClipping().SetLocalPlanes (Handle(Graphic3d_SequenceOfHClipPlane)());
if ((!myClipPlanes.IsNull() && !myClipPlanes->IsEmpty())
|| hasDisabled)
{