//! Redraws immediate structures in all views of the viewer given taking into account its visibility.
void RedrawImmediate (const Handle(V3d_Viewer)& theViewer) { myMainPM->RedrawImmediate (theViewer); }
+ //! Change state to reset V3d_View bounding boxes. It should be used after a clipping plane was changed
+ Standard_EXPORT void InvalidateBoundingBox();
+
public: //! @name management of active Selection Modes
//! Activates or deactivates the selection mode for specified object.
myMainPM->EndImmediateDraw (myMainVwr);
return Standard_True;
}
+
+//=======================================================================
+//function : InvalidateBoundingBox
+//purpose :
+//=======================================================================
+
+void AIS_InteractiveContext::InvalidateBoundingBox()
+{
+ const Handle(V3d_Viewer)& aCurViewer = CurrentViewer();
+ for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
+ {
+ anActiveViewIter.Value()->View()->InvalidateAllLayerBoundingBox();
+ }
+}
//! highlight flag is set to true
const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myHighlightStyle; }
+ //! Returns true if the structure is clipped with set planes
+ virtual Standard_Boolean IsClipped (const Handle(Graphic3d_SequenceOfHClipPlane)& theClipPlane) const = 0;
+
public:
//! Returns FALSE if the structure hits the current view volume, otherwise returns TRUE.
}
}
}
+// =======================================================================
+// function : InvalidateAllLayerBoundingBox
+// purpose :
+// =======================================================================
+void Graphic3d_CView::InvalidateAllLayerBoundingBox()
+{
+ for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
+ {
+ const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
+ aLayer->InvalidateBoundingBox();
+ }
+}
// =======================================================================
// function : ContainsFacet
Bnd_Box aBox = aLayer->BoundingBox (Identification(),
aCamera,
aWinSize.x(), aWinSize.y(),
- theToIncludeAuxiliary);
+ theToIncludeAuxiliary,
+ ClipPlanes());
aResult.Add (aBox);
}
return aResult;
//! Returns the bounding box of all structures displayed in the Z layer.
Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
+ //! Returns the bounding box of all structures displayed in the Z layer.
+ Standard_EXPORT virtual void InvalidateAllLayerBoundingBox();
+
//! Remove Z layer from the specified view. All structures
//! displayed at the moment in layer will be displayed in default layer
//! ( the bottom-level z layer ). To unset layer ID from associated
const Handle(Graphic3d_Camera)& theCamera,
Standard_Integer theWindowWidth,
Standard_Integer theWindowHeight,
- Standard_Boolean theToIncludeAuxiliary) const
+ Standard_Boolean theToIncludeAuxiliary,
+ const Handle(Graphic3d_SequenceOfHClipPlane)& theClipPlanes) const
{
updateBVH();
continue;
}
+ if (aStructure->IsClipped (theClipPlanes) || aStructure->IsClipped (aStructure->ClipPlanes()))
+ {
+ continue;
+ }
+
// "FitAll" operation ignores object with transform persistence parameter
// but adds transform persistence point in a bounding box of layer (only zoom pers. objects).
if (!aStructure->TransformPersistence().IsNull())
#include <NCollection_IndexedMap.hxx>
#include <NCollection_Sequence.hxx>
+class Graphic3d_SequenceOfHClipPlane;
+
//! Defines index map of structures.
typedef NCollection_IndexedMap<const Graphic3d_CStructure*> Graphic3d_IndexedMapOfStructure;
const Handle(Graphic3d_Camera)& theCamera,
Standard_Integer theWindowWidth,
Standard_Integer theWindowHeight,
- Standard_Boolean theToIncludeAuxiliary) const;
+ Standard_Boolean theToIncludeAuxiliary,
+ const Handle(Graphic3d_SequenceOfHClipPlane)& theClipPlanes = Handle(Graphic3d_SequenceOfHClipPlane)()) const;
//! Returns zoom-scale factor.
Standard_EXPORT Standard_Real considerZoomPersistenceObjects (Standard_Integer theViewId,
&& myInstancedStructure->IsRaytracable();
}
+// =======================================================================
+// function : IsClipped
+// purpose :
+// =======================================================================
+Standard_Boolean OpenGl_Structure::IsClipped (const Handle(Graphic3d_SequenceOfHClipPlane)& theClipPlane) const
+{
+ // True if structure is fully clipped
+ bool isClipped = false;
+ bool hasDisabled = false;
+
+ //const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
+ //if (aCtx->Clipping().IsClippingOrCappingOn())
+ {
+ const Graphic3d_BndBox3d& aBBox = BoundingBox();
+ if (!theClipPlane.IsNull()
+ && theClipPlane->ToOverrideGlobal())
+ {
+ //aCtx->ChangeClipping().DisableGlobal();
+ //hasDisabled = aCtx->Clipping().HasDisabled();
+ }
+ else if (!myTrsfPers.IsNull())
+ {
+ if (myTrsfPers->IsZoomOrRotate())
+ {
+ // 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 gp_Pnt anAnchor = myTrsfPers->AnchorPoint();
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (theClipPlane); aPlaneIt.More(); aPlaneIt.Next()/*, ++aPlaneId*/)
+ {
+ const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
+ //for (OpenGl_ClippingIterator aPlaneIt (aCtx->Clipping()); aPlaneIt.More() && aPlaneIt.IsGlobal(); aPlaneIt.Next())
+ ///for (OpenGl_ClippingIterator aPlaneIt (myClipPlanes); aPlaneIt.More() && aPlaneIt.IsGlobal(); aPlaneIt.Next())
+ //{
+ // const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
+ if (!aPlane->IsOn())
+ {
+ continue;
+ }
+
+ // check for clipping
+ const Graphic3d_Vec4d aCheckPnt (anAnchor.X(), anAnchor.Y(), anAnchor.Z(), 1.0);
+ if (aPlane->ProbePoint (aCheckPnt) == Graphic3d_ClipState_Out)
+ {
+ isClipped = true;
+ break;
+ }
+ }
+ }
+
+ //aCtx->ChangeClipping().DisableGlobal();
+ //hasDisabled = aCtx->Clipping().HasDisabled();
+ }
+
+ // Set of clipping planes that do not intersect the structure,
+ // and thus can be disabled to improve rendering performance
+ if (aBBox.IsValid()
+ && myTrsfPers.IsNull())
+ {
+ //for (OpenGl_ClippingIterator aPlaneIt (aCtx->Clipping()); aPlaneIt.More(); aPlaneIt.Next())
+ //{
+ // const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (theClipPlane); aPlaneIt.More(); aPlaneIt.Next()/*, ++aPlaneId*/)
+ {
+ const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
+ if (!aPlane->IsOn())//aPlaneIt.IsDisabled())
+ {
+ continue;
+ }
+
+ const Graphic3d_ClipState aBoxState = aPlane->ProbeBox (aBBox);
+ if (aBoxState == Graphic3d_ClipState_In)
+ {
+ //aCtx->ChangeClipping().SetEnabled (aPlaneIt, false);
+ //hasDisabled = true;
+ }
+ else if (aBoxState == Graphic3d_ClipState_Out && myBndBoxClipCheck)
+ {
+ isClipped = true;
+ break;
+ }
+ }
+ }
+ }
+ return isClipped;
+}
+
// =======================================================================
// function : UpdateRaytracableState
// purpose :
//! Is the structure ray-tracable (contains ray-tracable elements)?
Standard_Boolean IsRaytracable() const;
+ //! Returns true if the structure is clipped with set planes
+ Standard_EXPORT virtual Standard_Boolean IsClipped (const Handle(Graphic3d_SequenceOfHClipPlane)& theClipPlane) const;
+
//! Update render transformation matrix.
Standard_EXPORT virtual void updateLayerTransformation() Standard_OVERRIDE;
myZLayers.ChangePriority (aStruct, aLayerId, theNewPriority);
}
+//=======================================================================
+//function : SetClipPlanes
+//purpose :
+//=======================================================================
+void OpenGl_View::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
+{
+ myClipPlanes = thePlanes;
+
+ InvalidateAllLayerBoundingBox();
+}
+
//=======================================================================
//function : DiagnosticInformation
//purpose :
virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const Standard_OVERRIDE { return myClipPlanes; }
//! Sets list of clip planes for the view.
- virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) Standard_OVERRIDE { myClipPlanes = thePlanes; }
+ Standard_EXPORT virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) Standard_OVERRIDE;
//! Fill in the dictionary with diagnostic info.
//! Should be called within rendering thread.