Go to the documentation of this file.
42 const bool writeLinesOnly,
49 for (
const point& pt : pts)
58 os <<
"l " <<
e[0] + vertI + 1 <<
' ' <<
e[1] + vertI + 1 <<
nl;
66 for (
const label fpi :
f)
68 os <<
' ' << fpi + vertI + 1;
81 const bool leavesOnly,
82 const bool writeLinesOnly,
91 if (!leavesOnly || nodeI < 0)
104 nodes[nodeI].first(),
115 nodes[nodeI].second(),
128 const bool equalBinSize,
130 const List<Type>& objects,
132 const DynamicList<label>& objectIDs,
133 const treeBoundBox& bb,
136 DynamicList<Pair<treeBoundBox>>& bbs,
137 DynamicList<labelPair>& nodes,
138 DynamicList<labelList>& addressing
141 const vector span = bb.span();
146 scalar maxSpan = span[maxDir];
147 for (label dirI = 1; dirI < 3; ++dirI)
149 if (span[dirI] > maxSpan)
151 maxSpan = span[dirI];
163 bitSet isUsedPoint(
points.size());
166 for (
const label objI : objectIDs)
168 const Type& obj = objects[objI];
170 for (
const label pointI : obj)
172 if (isUsedPoint.set(pointI))
188 divide = bb.min()[maxDir] + 0.5*maxSpan;
192 scalar divMin =
divide + tolerance_*maxSpan;
193 scalar divMax =
divide - tolerance_*maxSpan;
198 DynamicList<label> minBinObjectIDs(objectIDs.size());
199 treeBoundBox minBb(boundBox::invertedBox);
201 DynamicList<label> maxBinObjectIDs(objectIDs.size());
202 treeBoundBox maxBb(boundBox::invertedBox);
204 for (
const label objI : objectIDs)
206 const Type& obj = objects[objI];
208 bool intoMin =
false;
209 bool intoMax =
false;
211 for (
const label pointI : obj)
214 if (pt[maxDir] < divMin)
218 if (pt[maxDir] > divMax)
228 minBinObjectIDs.append(objI);
233 maxBinObjectIDs.append(objI);
239 if (minBinObjectIDs.size())
243 if (maxBinObjectIDs.size())
248 minBinObjectIDs.shrink();
249 maxBinObjectIDs.shrink();
253 if (minBinObjectIDs.size() > minLeafSize_ && level < maxLevel_)
262 minI = -addressing.size() - 1;
263 addressing.append(minBinObjectIDs);
267 if (maxBinObjectIDs.size() > minLeafSize_ && level < maxLevel_)
276 maxI = -addressing.size() - 1;
277 addressing.append(maxBinObjectIDs);
281 bbs(nodeI) = Pair<treeBoundBox>(minBb, maxBb);
334 const UList<Type>& objects,
336 const bool equalBinSize,
337 const label maxLevel,
338 const label minLeafSize
342 minLeafSize_(minLeafSize),
352 DynamicList<Pair<treeBoundBox>> bbs(maxLevel);
353 DynamicList<labelPair> nodes(maxLevel);
354 DynamicList<labelList> addr(maxLevel);
357 treeBoundBox topBb(
points);
360 DynamicList<label> objectIDs(
identity(objects.size()));
397 DynamicList<treeBoundBox>
boundBoxes(2*bbs.size());
398 DynamicList<labelList>
addressing(2*addr.size());
402 if (nodes[nodeI].first() < 0)
407 if (nodes[nodeI].second() < 0)
420 bitSet checked(objects.size());
423 for (
const auto&
id : box)
429 const label unsetSize = checked.count(
false);
433 Info<<
"*** Problem: IDs not set: " << unsetSize <<
endl;
473 for (
const treeBoundBox& bb : boundBoxes_)
475 if (bb.overlaps(bbIn))
501 reinterpret_cast<const char*
>(&tree.maxLevel_),
502 sizeof(tree.maxLevel_)
503 +
sizeof(tree.minLeafSize_)
505 os << tree.boundBoxes_
520 >> tree.minLeafSize_;
532 is >> tree.boundBoxes_
vectorField pointField
pointField is a vectorField.
bool overlaps(const boundBox &bb) const
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
tmp< pointField > points() const
bool pointInside(const point &pt) const
void inflate(const scalar s)
Standard boundBox with extra functionality for use in octree.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool overlaps(const boundBox &bbIn) const
streamFormat format() const noexcept
const List< treeBoundBox > & boundBoxes() const
void set(const bitSet &bitset)
List< treeBoundBox > boundBoxes_
void append(const T &val)
Istream & operator>>(Istream &, directionInfo &)
Ostream & endl(Ostream &os)
static const edgeList edges
void writeOBJ(const bool writeLinesOnly, const treeBoundBox &bb, label &vertI, Ostream &os) const
virtual Ostream & write(const char c)
DynamicList< T, SizeMin > & shrink()
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
Pair< label > labelPair
A pair of labels.
void writeOBJ(const bool leavesOnly, const bool writeLinesOnly, const treeBoundBox &bb, const label nodeI, const List< Pair< treeBoundBox >> &bbs, const List< Pair< label >> &nodes, label &vertI, Ostream &os) const
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Generic templated field type.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
static const faceList faces
DynamicList< T, SizeMin > & append(const T &val)
void transfer(List< T > &list)
const point & min() const
bool empty() const noexcept
virtual bool check(const char *operation) const
OBJstream os(runTime.globalPath()/outputName)
Vector< scalar > vector
A scalar version of the templated Vector.
@ ASCII
"ascii" (normal default)
virtual bool beginRawRead()=0
bool contains(const vector &dir, const point &) const
An ordered pair of two objects of type <T> with first() and second() elements.
const List< labelList > & addressing() const
Templated tree of axis-aligned bounding boxes (AABB)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void createBoxes(const bool equalBinSize, const label level, const List< Type > &objects, const pointField &points, const DynamicList< label > &objectIDs, const treeBoundBox &bb, const label nodeI, DynamicList< Pair< treeBoundBox >> &bbs, DynamicList< labelPair > &nodes, DynamicList< labelList > &addressing) const
const dimensionedScalar e
labelList identity(const label len, label start=0)
A bounding box defined in terms of min/max extrema points.
A face is a list of labels corresponding to mesh vertices.
label readRawLabel(Istream &is)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
vector point
Point is a vector.
List< labelList > addressing_
void add(const boundBox &bb)