25c35042 |
1 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef OpenGl_ClippingIterator_Header |
15 | #define OpenGl_ClippingIterator_Header |
16 | |
17 | #include <OpenGl_Clipping.hxx> |
18 | |
19 | //! The iterator through clipping planes. |
20 | class OpenGl_ClippingIterator |
21 | { |
22 | public: |
23 | |
24 | //! Main constructor. |
25 | OpenGl_ClippingIterator(const OpenGl_Clipping& theClipping) |
26 | : myDisabled (&theClipping.myDisabledPlanes), |
27 | myCurrIndex (1) |
28 | { |
29 | myIter1.Init (theClipping.myPlanesGlobal); |
30 | myIter2.Init (theClipping.myPlanesLocal); |
31 | } |
32 | |
33 | //! Return true if iterator points to the valid clipping plane. |
34 | bool More() const { return myIter1.More() || myIter2.More(); } |
35 | |
36 | //! Go to the next clipping plane. |
37 | void Next() |
38 | { |
39 | ++myCurrIndex; |
40 | if (myIter1.More()) |
41 | { |
42 | myIter1.Next(); |
43 | } |
44 | else |
45 | { |
46 | myIter2.Next(); |
47 | } |
48 | } |
49 | |
50 | //! Return true if plane has been temporarily disabled either by Graphic3d_ClipPlane->IsOn() property or by temporary filter. |
51 | //! Beware that this method does NOT handle a Chain filter for Capping algorithm OpenGl_Clipping::CappedChain()! |
52 | bool IsDisabled() const { return myDisabled->Value (myCurrIndex) || !Value()->IsOn(); } |
53 | |
54 | //! Return the plane at current iterator position. |
55 | const Handle(Graphic3d_ClipPlane)& Value() const |
56 | { |
57 | return myIter1.More() |
58 | ? myIter1.Value() |
59 | : myIter2.Value(); |
60 | } |
61 | |
62 | //! Return true if plane from the global (view) list. |
63 | bool IsGlobal() const { return myIter1.More(); } |
64 | |
65 | //! Return the plane index. |
66 | Standard_Integer PlaneIndex() const { return myCurrIndex; } |
67 | |
68 | private: |
69 | |
70 | Graphic3d_SequenceOfHClipPlane::Iterator myIter1; |
71 | Graphic3d_SequenceOfHClipPlane::Iterator myIter2; |
72 | const NCollection_Vector<Standard_Boolean>* myDisabled; |
73 | Standard_Integer myCurrIndex; |
74 | |
75 | }; |
76 | |
77 | #endif // OpenGl_ClippingIterator_Header |