4269bd1b |
1 | // Created on: 2013-07-15 |
2 | // Created by: Anton POLETAEV |
d5f74e42 |
3 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
4269bd1b |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
4269bd1b |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
4269bd1b |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
4269bd1b |
15 | |
51b10cd4 |
16 | #ifndef _Graphic3d_SequenceOfHClipPlane_HeaderFile |
17 | #define _Graphic3d_SequenceOfHClipPlane_HeaderFile |
4269bd1b |
18 | |
51b10cd4 |
19 | #include <NCollection_Sequence.hxx> |
4269bd1b |
20 | #include <Graphic3d_ClipPlane.hxx> |
21 | |
25c35042 |
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. |
26 | //! |
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. |
30 | //! |
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 |
3202bf1e |
34 | { |
25c35042 |
35 | DEFINE_STANDARD_RTTIEXT(Graphic3d_SequenceOfHClipPlane, Standard_Transient) |
36 | public: |
37 | |
38 | //! Iterator through clipping planes. |
39 | class Iterator : public NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator |
40 | { |
41 | public: |
42 | Iterator() {} |
43 | Iterator (const Graphic3d_SequenceOfHClipPlane& thePlanes) : NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator (thePlanes.myItems) {} |
44 | Iterator (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { Init (thePlanes); } |
45 | |
46 | void Init (const Graphic3d_SequenceOfHClipPlane& thePlanes) { NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator::Init (thePlanes.myItems); } |
47 | void Init (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) |
48 | { |
49 | if (!thePlanes.IsNull()) |
50 | { |
51 | NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator::Init (thePlanes->myItems); |
52 | } |
53 | else |
54 | { |
55 | *this = Iterator(); |
56 | } |
57 | } |
58 | }; |
59 | |
3202bf1e |
60 | public: |
4269bd1b |
61 | |
3202bf1e |
62 | //! Empty constructor. |
25c35042 |
63 | Standard_EXPORT Graphic3d_SequenceOfHClipPlane(); |
3202bf1e |
64 | |
65 | //! Return true if local properties should override global properties. |
66 | Standard_Boolean ToOverrideGlobal() const { return myToOverrideGlobal; } |
67 | |
68 | //! Setup flag defining if local properties should override global properties. |
69 | void SetOverrideGlobal (const Standard_Boolean theToOverride) { myToOverrideGlobal = theToOverride; } |
70 | |
25c35042 |
71 | //! Return TRUE if sequence is empty. |
72 | bool IsEmpty() const { return myItems.IsEmpty(); } |
73 | |
74 | //! Return the number of items in sequence. |
75 | Standard_Integer Size() const { return myItems.Size(); } |
76 | |
77 | //! Append a plane. |
78 | //! @return TRUE if new item has been added (FALSE if item already existed) |
79 | Standard_EXPORT bool Append (const Handle(Graphic3d_ClipPlane)& theItem); |
80 | |
81 | //! Remove a plane. |
82 | //! @return TRUE if item has been found and removed |
83 | Standard_EXPORT bool Remove (const Handle(Graphic3d_ClipPlane)& theItem); |
84 | |
85 | //! Remove a plane. |
86 | void Remove (Iterator& theItem) { myItems.Remove (theItem); } |
87 | |
88 | //! Clear the items out. |
89 | void Clear() |
90 | { |
91 | myItems.Clear(); |
92 | } |
93 | |
94 | //! Return the first item in sequence. |
95 | const Handle(Graphic3d_ClipPlane)& First() const { return myItems.First(); } |
96 | |
bc73b006 |
97 | //! Dumps the content of me into the stream |
98 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; |
99 | |
25c35042 |
100 | protected: |
3202bf1e |
101 | |
25c35042 |
102 | NCollection_Sequence<Handle(Graphic3d_ClipPlane)> myItems; |
3202bf1e |
103 | Standard_Boolean myToOverrideGlobal; |
104 | |
105 | }; |
106 | |
107 | DEFINE_STANDARD_HANDLE(Graphic3d_SequenceOfHClipPlane, Standard_Transient) |
108 | |
109 | #endif // _Graphic3d_SequenceOfHClipPlane_HeaderFile |