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

0027816: Visualization - provide an API for overriding clipping planes list

Graphic3d_SequenceOfHClipPlane now inherits Standard_Transient.
PrsMgr_PresentableObject, Graphic3d_Structure, Graphic3d_CStructure,
V3d_View, OpenGl_View now manages the plane list by Handle.
The getters ::GetClipPlanes() has been removed,
setters taking non-handle ::SetClipPlanes() has been marked deprecated.

OpenGl_Structure::Render() and SelectMgr_ViewerSelector::checkOverlap()
now disable global (view) clipping planes for objects
with flags Graphic3d_TMF_TriedronPers and Graphic3d_TMF_2d
or with new flag Graphic3d_SequenceOfHClipPlane::ToOverrideGlobal().

OpenGl_Clipping now implements interface for managing clipping planes
without copying the sequences.
The filtering of duplicates is no more performed by OpenGl_Clipping
- application is responsible to not do this.
OpenGl_Clipping tries avoiding unnecessary allocations for managing
list of active planes.

MFC sample has been updated to use V3d_View::ClipPlanes() method.
This commit is contained in:
kgv
2016-09-14 13:44:47 +03:00
committed by bugmaster
parent ef444297f5
commit 3202bf1e9e
27 changed files with 691 additions and 606 deletions

View File

@@ -4,7 +4,6 @@ PrsMgr_ModedPresentation.cxx
PrsMgr_ModedPresentation.hxx
PrsMgr_PresentableObject.cxx
PrsMgr_PresentableObject.hxx
PrsMgr_PresentableObject.lxx
PrsMgr_PresentableObjectPointer.hxx
PrsMgr_Presentation.cxx
PrsMgr_Presentation.hxx

View File

@@ -422,7 +422,12 @@ Graphic3d_ZLayerId PrsMgr_PresentableObject::ZLayer() const
void PrsMgr_PresentableObject::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
{
// add to collection and process changes
myClipPlanes.Append (thePlane);
if (myClipPlanes.IsNull())
{
myClipPlanes = new Graphic3d_SequenceOfHClipPlane();
}
myClipPlanes->Append (thePlane);
UpdateClipping();
}
@@ -432,15 +437,19 @@ void PrsMgr_PresentableObject::AddClipPlane (const Handle(Graphic3d_ClipPlane)&
// =======================================================================
void PrsMgr_PresentableObject::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
{
if (myClipPlanes.IsNull())
{
return;
}
// remove from collection and process changes
Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (myClipPlanes);
for (; aPlaneIt.More(); aPlaneIt.Next())
for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*myClipPlanes); aPlaneIt.More(); aPlaneIt.Next())
{
const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
if (aPlane != thePlane)
continue;
myClipPlanes.Remove (aPlaneIt);
myClipPlanes->Remove (aPlaneIt);
UpdateClipping();
return;
}
@@ -450,7 +459,7 @@ void PrsMgr_PresentableObject::RemoveClipPlane (const Handle(Graphic3d_ClipPlane
// function : SetClipPlanes
// purpose :
// =======================================================================
void PrsMgr_PresentableObject::SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
void PrsMgr_PresentableObject::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
{
// change collection and process changes
myClipPlanes = thePlanes;
@@ -503,12 +512,3 @@ void PrsMgr_PresentableObject::SetMutable (const Standard_Boolean theIsMutable)
aModedPrs.Presentation()->Presentation()->SetMutable (theIsMutable);
}
}
// =======================================================================
// function : IsMutable
// purpose :
// =======================================================================
Standard_Boolean PrsMgr_PresentableObject::IsMutable() const
{
return myIsMutable;
}

View File

@@ -76,7 +76,7 @@ public:
Standard_EXPORT PrsMgr_Presentations& Presentations();
//! Returns information on whether the object accepts display in HLR mode or not.
PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const;
PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; }
//! Sets up Transform Persistence Mode for this object.
//! This function used to lock in object position, rotation and / or zooming relative to camera position.
@@ -107,7 +107,7 @@ public:
Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
//! @return transform persistence of the presentable object.
const Graphic3d_TransformPers& TransformPersistence() const;
const Graphic3d_TransformPers& TransformPersistence() const { return myTransformPersistence; }
Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
@@ -126,12 +126,12 @@ public:
//! Returns true if object has a transformation that is different from the identity.
Standard_EXPORT Standard_Boolean HasTransformation() const;
const gp_Trsf& LocalTransformation() const;
const gp_Trsf& Transformation() const;
const gp_GTrsf& InversedTransformation() const;
const gp_Trsf& LocalTransformation() const { return myLocalTransformation; }
const gp_Trsf& Transformation() const { return myTransformation; }
const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
//! resets local transformation to identity.
Standard_EXPORT virtual void ResetTransformation();
@@ -162,25 +162,32 @@ public:
Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
//! Set clip planes for graphical clipping for all display mode presentations.
//! The composition of clip planes truncates the rendering space to convex
//! volume. Please be aware that number of supported clip plane is limited.
//! The planes which exceed the limit are ignored. Besides of this, some
//! planes can be already set in view where the object is shown: the number
//! of these planes should be substracted from limit to predict the maximum
//! The composition of clip planes truncates the rendering space to convex volume.
//! Please be aware that number of supported clip plane is limited.
//! The planes which exceed the limit are ignored.
//! Besides of this, some planes can be already set in view where the object is shown:
//! the number of these planes should be subtracted from limit to predict the maximum
//! possible number of object clipping planes.
Standard_EXPORT virtual void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes);
Standard_EXPORT virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes);
Standard_DEPRECATED("This method is deprecated - overload taking Handle should be used instead")
void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
{
Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane (thePlanes);
SetClipPlanes (aPlanes);
}
//! Get clip planes.
//! @return set of previously added clip planes for all display mode presentations.
const Graphic3d_SequenceOfHClipPlane& GetClipPlanes() const;
const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myClipPlanes; }
//! Sets if the object has mutable nature (content or location will be changed regularly).
//! This method should be called before object displaying to take effect.
Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
//! Returns true if object has mutable nature (content or location are be changed regularly).
//! Mutable object will be managed in different way than static onces (another optimizations).
Standard_EXPORT Standard_Boolean IsMutable() const;
Standard_Boolean IsMutable() const { return myIsMutable; }
//! Makes theObject child of current object in scene hierarchy.
Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
@@ -189,13 +196,13 @@ public:
Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
//! Returns children of the current object.
const PrsMgr_ListOfPresentableObjects& Children() const;
const PrsMgr_ListOfPresentableObjects& Children() const { return myChildren; }
//! Returns true if object should have own presentations.
Standard_Boolean HasOwnPresentations() const;
Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; }
//! Returns parent of current object in scene hierarchy.
PrsMgr_PresentableObjectPointer Parent() const;
PrsMgr_PresentableObjectPointer Parent() const { return myParent; }
friend class PrsMgr_Presentation;
@@ -271,17 +278,17 @@ Standard_EXPORT virtual ~PrsMgr_PresentableObject();
//! implementation propagate clip planes to every presentation.
Standard_EXPORT virtual void UpdateClipping();
protected:
PrsMgr_Presentations myPresentations;
PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d;
Graphic3d_SequenceOfHClipPlane myClipPlanes;
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
Standard_Boolean myIsMutable;
Graphic3d_ZLayerId myZLayer;
Standard_Boolean myHasOwnPresentations;
private:
Graphic3d_TransformPers myTransformPersistence;
PrsMgr_PresentableObjectPointer myParent;
gp_Trsf myLocalTransformation;
@@ -290,14 +297,6 @@ private:
gp_Trsf myCombinedParentTransform;
PrsMgr_ListOfPresentableObjects myChildren;
};
#include <PrsMgr_PresentableObject.lxx>
#endif // _PrsMgr_PresentableObject_HeaderFile

View File

@@ -1,58 +0,0 @@
// Created on: 1997-07-04
// Created by: Robert COUBLANC
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
inline PrsMgr_TypeOfPresentation3d PrsMgr_PresentableObject::TypeOfPresentation3d() const
{return myTypeOfPresentation3d;}
inline const Graphic3d_TransformPers& PrsMgr_PresentableObject::TransformPersistence() const
{
return myTransformPersistence;
}
inline const gp_Trsf& PrsMgr_PresentableObject::LocalTransformation() const
{
return myLocalTransformation;
}
inline const gp_Trsf& PrsMgr_PresentableObject::Transformation() const
{
return myTransformation;
}
inline const gp_GTrsf& PrsMgr_PresentableObject::InversedTransformation() const
{
return myInvTransformation;
}
inline const PrsMgr_ListOfPresentableObjects& PrsMgr_PresentableObject::Children() const
{
return myChildren;
}
inline Standard_Boolean PrsMgr_PresentableObject::HasOwnPresentations() const
{
return myHasOwnPresentations;
}
inline PrsMgr_PresentableObjectPointer PrsMgr_PresentableObject::Parent() const
{
return myParent;
}
inline const Graphic3d_SequenceOfHClipPlane& PrsMgr_PresentableObject::GetClipPlanes() const
{
return myClipPlanes;
}

View File

@@ -371,7 +371,7 @@ void PrsMgr_PresentationManager::displayImmediate (const Handle(V3d_Viewer)& the
aShadowPrs = new Prs3d_PresentationShadow (myStructureManager,
Handle(Prs3d_Presentation)::DownCast (aViewDepPrs));
aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer());
aShadowPrs->SetClipPlanes (aViewDepPrs->GetClipPlanes());
aShadowPrs->SetClipPlanes (aViewDepPrs->ClipPlanes());
aShadowPrs->CStructure()->IsForHighlight = 1;
aShadowPrs->Highlight (Aspect_TOHM_COLOR, aPrs->HighlightColor());
myViewDependentImmediateList.Append (aShadowPrs);
@@ -626,7 +626,7 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)&
{
Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation());
aShadow->SetZLayer (theImmediateStructLayerId);
aShadow->SetClipPlanes (aPrs->Presentation()->GetClipPlanes());
aShadow->SetClipPlanes (aPrs->Presentation()->ClipPlanes());
aShadow->CStructure()->IsForHighlight = 1;
aShadow->Highlight (Aspect_TOHM_COLOR, theColor);
AddToImmediateList (aShadow);