1 // Created on: 2013-07-15
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Graphic3d_SequenceOfHClipPlane_HeaderFile
17 #define _Graphic3d_SequenceOfHClipPlane_HeaderFile
19 #include <NCollection_Sequence.hxx>
20 #include <Graphic3d_ClipPlane.hxx>
22 //! Class defines a Clipping Volume as a logical OR (disjunction) operation between Graphic3d_ClipPlane in sequence.
23 //! Each Graphic3d_ClipPlane represents either a single Plane clipping a halfspace (direction is specified by normal),
24 //! or a sub-chain of planes defining a logical AND (conjunction) operation.
25 //! Therefore, this collection allows defining a Clipping Volume through the limited set of Boolean operations between clipping Planes.
27 //! The Clipping Volume can be assigned either to entire View or to a specific Object;
28 //! in the latter case property ToOverrideGlobal() will specify if Object planes should override (suppress) globally defined ones
29 //! or extend their definition through logical OR (disjunction) operation.
31 //! Note that defining (many) planes will lead to performance degradation, and Graphics Driver may limit
32 //! the overall number of simultaneously active clipping planes - but at least 6 planes should be supported on all configurations.
33 class Graphic3d_SequenceOfHClipPlane : public Standard_Transient
35 DEFINE_STANDARD_RTTIEXT(Graphic3d_SequenceOfHClipPlane, Standard_Transient)
38 //! Iterator through clipping planes.
39 class Iterator : public NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator
43 Iterator (const Graphic3d_SequenceOfHClipPlane& thePlanes) : NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator (thePlanes.myItems) {}
44 Iterator (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { Init (thePlanes); }
46 void Init (const Graphic3d_SequenceOfHClipPlane& thePlanes) { NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator::Init (thePlanes.myItems); }
47 void Init (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
49 if (!thePlanes.IsNull())
51 NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator::Init (thePlanes->myItems);
62 //! Empty constructor.
63 Standard_EXPORT Graphic3d_SequenceOfHClipPlane();
65 //! Return true if local properties should override global properties.
66 Standard_Boolean ToOverrideGlobal() const { return myToOverrideGlobal; }
68 //! Setup flag defining if local properties should override global properties.
69 void SetOverrideGlobal (const Standard_Boolean theToOverride) { myToOverrideGlobal = theToOverride; }
71 //! Return TRUE if sequence is empty.
72 bool IsEmpty() const { return myItems.IsEmpty(); }
74 //! Return the number of items in sequence.
75 Standard_Integer Size() const { return myItems.Size(); }
78 //! @return TRUE if new item has been added (FALSE if item already existed)
79 Standard_EXPORT bool Append (const Handle(Graphic3d_ClipPlane)& theItem);
82 //! @return TRUE if item has been found and removed
83 Standard_EXPORT bool Remove (const Handle(Graphic3d_ClipPlane)& theItem);
86 void Remove (Iterator& theItem) { myItems.Remove (theItem); }
88 //! Clear the items out.
94 //! Return the first item in sequence.
95 const Handle(Graphic3d_ClipPlane)& First() const { return myItems.First(); }
97 //! Dumps the content of me into the stream
98 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
102 NCollection_Sequence<Handle(Graphic3d_ClipPlane)> myItems;
103 Standard_Boolean myToOverrideGlobal;
107 DEFINE_STANDARD_HANDLE(Graphic3d_SequenceOfHClipPlane, Standard_Transient)
109 #endif // _Graphic3d_SequenceOfHClipPlane_HeaderFile