0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / SelectMgr / SelectMgr_ViewClipRange.hxx
1 // Created on: 2015-12-15
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _SelectMgr_ViewClipRange_HeaderFile
17 #define _SelectMgr_ViewClipRange_HeaderFile
18
19 #include <Bnd_Range.hxx>
20 #include <Standard_TypeDef.hxx>
21
22 //! Class for handling depth clipping range.
23 //! It is used to perform checks in case if global (for the whole view)
24 //! clipping planes are defined inside of SelectMgr_RectangularFrustum class methods.
25 class SelectMgr_ViewClipRange
26 {
27 public:
28   //! Creates an empty clip range.
29   SelectMgr_ViewClipRange()
30   {
31     SetVoid();
32   }
33
34   //! Check if the given depth is not within clipping range(s),
35   //! e.g. TRUE means depth is clipped.
36   Standard_Boolean IsClipped (const Standard_Real theDepth) const
37   {
38     if (myUnclipRange.IsOut (theDepth))
39     {
40       return Standard_True;
41     }
42     for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter)
43     {
44       if (!myClipRanges[aRangeIter].IsOut (theDepth))
45       {
46         return Standard_True;
47       }
48     }
49     return Standard_False;
50   }
51
52   //! Clears clipping range.
53   void SetVoid()
54   {
55     myClipRanges.resize (0);
56     myUnclipRange = Bnd_Range (RealFirst(), RealLast());
57   }
58
59   //! Returns the main unclipped range; [-inf, inf] by default.
60   Bnd_Range& ChangeUnclipRange() { return myUnclipRange; }
61
62   //! Adds a clipping sub-range (for clipping chains).
63   void AddClipSubRange (const Bnd_Range& theRange) { myClipRanges.push_back (theRange); }
64
65 private:
66
67   std::vector<Bnd_Range> myClipRanges;
68   Bnd_Range myUnclipRange;
69
70 };
71
72 #endif // _SelectMgr_ViewClipRange_HeaderFile