1 // Created on: 2001-09-26
2 // Created by: Michael KLOKOV
3 // Copyright (c) 2001-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 _IntTools_MarkedRangeSet_HeaderFile
17 #define _IntTools_MarkedRangeSet_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
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;
32 //! class MarkedRangeSet provides continuous set of ranges marked with flags
33 class IntTools_MarkedRangeSet
42 Standard_EXPORT IntTools_MarkedRangeSet();
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);
50 //! Build set of ranges based on the array of progressive sorted values
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);
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);
63 //! Build set of ranges based on the array of progressive sorted values
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);
71 //! Inserts a new range marked with flag theFlag
72 //! It replace the existing ranges or parts of ranges
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);
79 //! Inserts a new range marked with flag theFlag
80 //! It replace the existing ranges or parts of ranges
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);
87 //! Inserts a new range marked with flag theFlag
88 //! It replace the existing ranges or parts of ranges
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);
96 //! Inserts a new range marked with flag theFlag
97 //! It replace the existing ranges or parts of ranges
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);
105 //! Set flag theFlag for range with index theIndex
106 Standard_EXPORT void SetFlag (const Standard_Integer theIndex, const Standard_Integer theFlag);
109 //! Returns flag of the range with index theIndex
110 Standard_EXPORT Standard_Integer Flag (const Standard_Integer theIndex) const;
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;
117 Standard_EXPORT const TColStd_SequenceOfInteger& GetIndices (const Standard_Real theValue);
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;
128 //! Returns number of ranges
129 Standard_Integer Length() const;
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;
149 TColStd_SequenceOfReal myRangeSetStorer;
150 Standard_Integer myRangeNumber;
151 TColStd_SequenceOfInteger myFlags;
152 TColStd_SequenceOfInteger myFoundIndices;
158 #include <IntTools_MarkedRangeSet.lxx>
164 #endif // _IntTools_MarkedRangeSet_HeaderFile