Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-12-01 10:16:32

0001 // Created on: 2001-09-26
0002 // Created by: Michael KLOKOV
0003 // Copyright (c) 2001-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _IntTools_MarkedRangeSet_HeaderFile
0017 #define _IntTools_MarkedRangeSet_HeaderFile
0018 
0019 #include <NCollection_Array1.hxx>
0020 #include <NCollection_Sequence.hxx>
0021 #include <Standard_Integer.hxx>
0022 
0023 class IntTools_Range;
0024 
0025 //! class MarkedRangeSet provides continuous set of ranges marked with flags
0026 class IntTools_MarkedRangeSet
0027 {
0028 public:
0029   DEFINE_STANDARD_ALLOC
0030 
0031   //! Empty constructor
0032   Standard_EXPORT IntTools_MarkedRangeSet();
0033 
0034   //! build set of ranges which consists of one range with
0035   //! boundary values theFirstBoundary and theLastBoundary
0036   Standard_EXPORT IntTools_MarkedRangeSet(const double theFirstBoundary,
0037                                           const double theLastBoundary,
0038                                           const int    theInitFlag);
0039 
0040   //! Build set of ranges based on the array of progressive sorted values
0041   //!
0042   //! Warning:
0043   //! The constructor do not check if the values of array are not sorted
0044   //! It should be checked before function invocation
0045   Standard_EXPORT IntTools_MarkedRangeSet(const NCollection_Array1<double>& theSortedArray,
0046                                           const int                         theInitFlag);
0047 
0048   //! build set of ranges which consists of one range with
0049   //! boundary values theFirstBoundary and theLastBoundary
0050   Standard_EXPORT void SetBoundaries(const double theFirstBoundary,
0051                                      const double theLastBoundary,
0052                                      const int    theInitFlag);
0053 
0054   //! Build set of ranges based on the array of progressive sorted values
0055   //!
0056   //! Warning:
0057   //! The function do not check if the values of array are not sorted
0058   //! It should be checked before function invocation
0059   Standard_EXPORT void SetRanges(const NCollection_Array1<double>& theSortedArray,
0060                                  const int                         theInitFlag);
0061 
0062   //! Inserts a new range marked with flag theFlag
0063   //! It replace the existing ranges or parts of ranges
0064   //! and their flags.
0065   //! Returns True if the range is inside the initial boundaries,
0066   //! otherwise or in case of some error returns False
0067   Standard_EXPORT bool InsertRange(const double theFirstBoundary,
0068                                    const double theLastBoundary,
0069                                    const int    theFlag);
0070 
0071   //! Inserts a new range marked with flag theFlag
0072   //! It replace the existing ranges or parts of ranges
0073   //! and their flags.
0074   //! Returns True if the range is inside the initial boundaries,
0075   //! otherwise or in case of some error returns False
0076   Standard_EXPORT bool InsertRange(const IntTools_Range& theRange, const int theFlag);
0077 
0078   //! Inserts a new range marked with flag theFlag
0079   //! It replace the existing ranges or parts of ranges
0080   //! and their flags.
0081   //! The index theIndex is a position where the range will be inserted.
0082   //! Returns True if the range is inside the initial boundaries,
0083   //! otherwise or in case of some error returns False
0084   Standard_EXPORT bool InsertRange(const double theFirstBoundary,
0085                                    const double theLastBoundary,
0086                                    const int    theFlag,
0087                                    const int    theIndex);
0088 
0089   //! Inserts a new range marked with flag theFlag
0090   //! It replace the existing ranges or parts of ranges
0091   //! and their flags.
0092   //! The index theIndex is a position where the range will be inserted.
0093   //! Returns True if the range is inside the initial boundaries,
0094   //! otherwise or in case of some error returns False
0095   Standard_EXPORT bool InsertRange(const IntTools_Range& theRange,
0096                                    const int             theFlag,
0097                                    const int             theIndex);
0098 
0099   //! Set flag theFlag for range with index theIndex
0100   Standard_EXPORT void SetFlag(const int theIndex, const int theFlag);
0101 
0102   //! Returns flag of the range with index theIndex
0103   Standard_EXPORT int Flag(const int theIndex) const;
0104 
0105   //! Returns index of range which contains theValue.
0106   //! If theValue do not belong any range returns 0.
0107   Standard_EXPORT int GetIndex(const double theValue) const;
0108 
0109   Standard_EXPORT const NCollection_Sequence<int>& GetIndices(const double theValue);
0110 
0111   //! Returns index of range which contains theValue
0112   //! If theValue do not belong any range returns 0.
0113   //! If UseLower is true then lower boundary of the range
0114   //! can be equal to theValue, otherwise upper boundary of the range
0115   //! can be equal to theValue.
0116   Standard_EXPORT int GetIndex(const double theValue, const bool UseLower) const;
0117 
0118   //! Returns number of ranges
0119   int Length() const { return myRangeNumber; }
0120 
0121   //! Returns the range with index theIndex.
0122   //! the Index can be from 1 to Length()
0123   Standard_EXPORT IntTools_Range Range(const int theIndex) const;
0124 
0125 private:
0126   NCollection_Sequence<double> myRangeSetStorer;
0127   int                          myRangeNumber;
0128   NCollection_Sequence<int>    myFlags;
0129   NCollection_Sequence<int>    myFoundIndices;
0130 };
0131 
0132 #endif // _IntTools_MarkedRangeSet_HeaderFile