0026506: Change class BRepLib_CheckCurveOnSurface
[occt.git] / src / IntTools / IntTools_MarkedRangeSet.hxx
1 // Created on: 2001-09-26
2 // Created by: Michael KLOKOV
3 // Copyright (c) 2001-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 _IntTools_MarkedRangeSet_HeaderFile
17 #define _IntTools_MarkedRangeSet_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
22
23 #include <TColStd_SequenceOfReal.hxx>
24 #include <Standard_Integer.hxx>
25 #include <TColStd_SequenceOfInteger.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Boolean.hxx>
28 class IntTools_CArray1OfReal;
29 class IntTools_Range;
30
31
32 //! class MarkedRangeSet provides continuous set of ranges marked with flags
33 class IntTools_MarkedRangeSet 
34 {
35 public:
36
37   DEFINE_STANDARD_ALLOC
38
39   
40
41   //! Empty constructor
42   Standard_EXPORT IntTools_MarkedRangeSet();
43   
44
45   //! build set of ranges which consists of one range with
46   //! boundary values theFirstBoundary and theLastBoundary
47   Standard_EXPORT IntTools_MarkedRangeSet(const Standard_Real theFirstBoundary, const Standard_Real theLastBoundary, const Standard_Integer theInitFlag);
48   
49
50   //! Build set of ranges based on the array of progressive sorted values
51   //!
52   //! Warning:
53   //! The constructor do not check if the values of array are not sorted
54   //! It should be checked before function invocation
55   Standard_EXPORT IntTools_MarkedRangeSet(const IntTools_CArray1OfReal& theSortedArray, const Standard_Integer theInitFlag);
56   
57
58   //! build set of ranges which consists of one range with
59   //! boundary values theFirstBoundary and theLastBoundary
60   Standard_EXPORT void SetBoundaries (const Standard_Real theFirstBoundary, const Standard_Real theLastBoundary, const Standard_Integer theInitFlag);
61   
62
63   //! Build set of ranges based on the array of progressive sorted values
64   //!
65   //! Warning:
66   //! The function do not check if the values of array are not sorted
67   //! It should be checked before function invocation
68   Standard_EXPORT void SetRanges (const IntTools_CArray1OfReal& theSortedArray, const Standard_Integer theInitFlag);
69   
70
71   //! Inserts a new range marked with flag theFlag
72   //! It replace the existing ranges or parts of ranges
73   //! and their flags.
74   //! Returns True if the range is inside the initial boundaries,
75   //! otherwise or in case of some error returns False
76   Standard_EXPORT Standard_Boolean InsertRange (const Standard_Real theFirstBoundary, const Standard_Real theLastBoundary, const Standard_Integer theFlag);
77   
78
79   //! Inserts a new range marked with flag theFlag
80   //! It replace the existing ranges or parts of ranges
81   //! and their flags.
82   //! Returns True if the range is inside the initial boundaries,
83   //! otherwise or in case of some error returns False
84   Standard_EXPORT Standard_Boolean InsertRange (const IntTools_Range& theRange, const Standard_Integer theFlag);
85   
86
87   //! Inserts a new range marked with flag theFlag
88   //! It replace the existing ranges or parts of ranges
89   //! and their flags.
90   //! The index theIndex is a position where the range will be inserted.
91   //! Returns True if the range is inside the initial boundaries,
92   //! otherwise or in case of some error returns False
93   Standard_EXPORT Standard_Boolean InsertRange (const Standard_Real theFirstBoundary, const Standard_Real theLastBoundary, const Standard_Integer theFlag, const Standard_Integer theIndex);
94   
95
96   //! Inserts a new range marked with flag theFlag
97   //! It replace the existing ranges or parts of ranges
98   //! and their flags.
99   //! The index theIndex is a position where the range will be inserted.
100   //! Returns True if the range is inside the initial boundaries,
101   //! otherwise or in case of some error returns False
102   Standard_EXPORT Standard_Boolean InsertRange (const IntTools_Range& theRange, const Standard_Integer theFlag, const Standard_Integer theIndex);
103   
104
105   //! Set flag theFlag for range with index theIndex
106   Standard_EXPORT void SetFlag (const Standard_Integer theIndex, const Standard_Integer theFlag);
107   
108
109   //! Returns flag of the range with index theIndex
110   Standard_EXPORT Standard_Integer Flag (const Standard_Integer theIndex) const;
111   
112
113   //! Returns index of range which contains theValue.
114   //! If theValue do not belong any range returns 0.
115   Standard_EXPORT Standard_Integer GetIndex (const Standard_Real theValue) const;
116   
117   Standard_EXPORT const TColStd_SequenceOfInteger& GetIndices (const Standard_Real theValue);
118   
119
120   //! Returns index of range which contains theValue
121   //! If theValue do not belong any range returns 0.
122   //! If UseLower is Standard_True then lower boundary of the range
123   //! can be equal to theValue, otherwise upper boundary of the range
124   //! can be equal to theValue.
125   Standard_EXPORT Standard_Integer GetIndex (const Standard_Real theValue, const Standard_Boolean UseLower) const;
126   
127
128   //! Returns number of ranges
129     Standard_Integer Length() const;
130   
131
132   //! Returns the range with index theIndex.
133   //! the Index can be from 1 to Length()
134   Standard_EXPORT IntTools_Range Range (const Standard_Integer theIndex) const;
135
136
137
138
139 protected:
140
141
142
143
144
145 private:
146
147
148
149   TColStd_SequenceOfReal myRangeSetStorer;
150   Standard_Integer myRangeNumber;
151   TColStd_SequenceOfInteger myFlags;
152   TColStd_SequenceOfInteger myFoundIndices;
153
154
155 };
156
157
158 #include <IntTools_MarkedRangeSet.lxx>
159
160
161
162
163
164 #endif // _IntTools_MarkedRangeSet_HeaderFile