56 void Foam::labelRanges::insertBefore
59 const labelRange&
range 65 label nElem = list.size();
69 Info<<
"before insert " 70 << nElem <<
" elements, insert at " <<
insert <<
nl 78 Info<<
"copy between " << nElem <<
" and " <<
insert <<
nl;
81 for (label i = nElem-1; i >=
insert; --i)
85 Info<<
"copy from " << (i) <<
" to " << (i+1) <<
nl;
101 void Foam::labelRanges::purgeEmpty()
103 auto& list = ranges_;
110 if (!list[elemi].empty())
114 list[nElem] = list[elemi];
137 auto& list = ranges_;
143 else if (list.empty())
145 list.push_back(
range);
152 labelRange& currRange = list[elemi];
154 if (currRange.overlaps(
range,
true))
157 currRange.join(
range);
160 for (; elemi < list.size()-1; ++elemi)
162 labelRange& nextRange = list[elemi+1];
163 if (currRange.overlaps(nextRange,
true))
165 currRange.join(nextRange);
179 else if (
range < currRange)
181 insertBefore(elemi,
range);
189 list.push_back(
range);
197 auto& list = ranges_;
200 if (
range.empty() || list.empty())
207 labelRange& currRange = list[elemi];
209 if (
range.min() > currRange.min())
211 if (
range.max() < currRange.max())
217 Info<<
"Fragment removal ";
223 label
lower = currRange.min();
230 upper = currRange.max();
233 currRange.clampSize();
235 insertBefore(elemi, fragment);
249 else if (
range.min() <= currRange.max())
255 Info<<
"RHS removal ";
260 const label
lower = currRange.min();
264 currRange.clampSize();
274 else if (
range.min() <= currRange.min())
276 if (
range.max() >= currRange.min())
282 Info<<
"LHS removal ";
288 const label
upper = currRange.max();
291 currRange.clampSize();
314 if (
range.size() > 0)
316 total +=
range.size();
323 return List<label>();
326 List<label> result(total);
328 auto* iter = result.begin();
330 for (
const labelRange&
range : ranges_)
332 const label len =
range.size();
336 std::iota(iter, (iter + len),
range.start());
349 if (i < 0)
return -1;
355 if (subIdx <
range.size())
357 return (
range.start() + subIdx);
361 subIdx -=
range.size();
373 return ranges_.readList(is);
383 return ranges_.writeList(
os, shortLen);
395 return list.writeList
398 Detail::ListPolicy::short_length<labelRange>::value
labelRanges()=default
Default construct.
label operator[](const label i) const
Return the value at linear index 'i', -1 for out-of-range.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
srcOptions insert("case", fileName(rootDirSource/caseDirSource))
A range or interval of labels defined by a start and a size.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
Istream & readList(Istream &is)
Read List of labelRange from Istream, discarding contents.
static int debug
Debugging.
#define forAll(list, i)
Loop across all elements in list.
bool add(const labelRange &range)
Add the range to the list.
Istream & operator>>(Istream &, directionInfo &)
List< label > labels() const
Return flattened list of all range labels.
bool remove(const labelRange &range)
Remove the range from the list.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
static Ostream & printRange(Ostream &os, const labelRange &range)
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
messageStream Info
Information stream (stdout output on master, null elsewhere)
A list of labelRange with constrained list capabilities.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List of labelRange, with line-breaks in ASCII when length exceeds shortLen. ...