Go to the documentation of this file.
39 const bool writeLinesOnly,
56 os <<
"l " <<
e[0] + vertI + 1 <<
' ' <<
e[1] + vertI + 1 <<
nl;
68 os <<
' ' <<
f[fp] + vertI + 1;
81 const bool leavesOnly,
82 const bool writeLinesOnly,
91 if (!leavesOnly || nodeI < 0)
93 writeOBJ(writeLinesOnly, bb, vertI, os);
104 nodes[nodeI].first(),
115 nodes[nodeI].second(),
128 const bool equalBinSize,
146 scalar maxSpan = span[maxDir];
147 for (
label dirI = 1; dirI < 3; dirI++)
149 if (span[dirI] > maxSpan)
151 maxSpan = span[dirI];
168 const label objI = objectIDs[i];
169 const Type& obj = objects[objI];
173 const label pointI = obj[pI];
174 if (isUsedPoint.
set(pointI))
194 scalar divMin =
divide + tolerance_*maxSpan;
195 scalar divMax =
divide - tolerance_*maxSpan;
208 const label objI = objectIDs[i];
209 const Type& obj = objects[objI];
211 bool intoMin =
false;
212 bool intoMax =
false;
216 const label pointI = obj[pI];
218 if (pt[maxDir] < divMin)
222 if (pt[maxDir] > divMax)
231 minBinObjectIDs.
append(objI);
238 maxBinObjectIDs.
append(objI);
246 if (minBinObjectIDs.size())
250 if (maxBinObjectIDs.size())
260 if (minBinObjectIDs.size() > minLeafSize_ && level < maxLevel_)
269 minI = -addressing.size() - 1;
270 addressing.
append(minBinObjectIDs);
274 if (maxBinObjectIDs.size() > minLeafSize_ && level < maxLevel_)
283 maxI = -addressing.size() - 1;
284 addressing.
append(maxBinObjectIDs);
343 const bool equalBinSize,
344 const label maxLevel,
345 const label minLeafSize
349 minLeafSize_(minLeafSize),
359 DynamicList<Pair<treeBoundBox> > bbs(maxLevel);
360 DynamicList<labelPair> nodes(maxLevel);
361 DynamicList<labelList> addr(maxLevel);
364 treeBoundBox topBb(
points);
404 DynamicList<treeBoundBox>
boundBoxes(2*bbs.size());
405 DynamicList<labelList>
addressing(2*addr.size());
408 if (nodes[nodeI].first() < 0)
413 if (nodes[nodeI].second() < 0)
491 reinterpret_cast<const char*
>(&tree.
maxLevel_),
499 os.
check(
"Ostream& operator<<(Ostream&, const AABBTree<Type>&)");
518 reinterpret_cast<char*
>(&tree.maxLevel_),
519 sizeof(tree.maxLevel_)
520 +
sizeof(tree.minLeafSize_)
522 is >> tree.boundBoxes_
526 is.
check(
"Istream& operator>>(Istream&, AABBTree<Type>&)");
streamFormat format() const
Return current stream format.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
const point & max() const
Maximum describing the bounding box.
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
tmp< pointField > points() const
Vertex coordinates. In octant coding.
bool pointInside(const point &pt) const
Determine whether a point is inside the bounding boxes.
void inflate(const scalar s)
Inflate box by factor*mag(span) in all dimensions.
void set(const PackedList< 1 > &)
Set specified bits.
Standard boundBox + 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
Determine whether a bounding box overlaps the tree bounding.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
const List< treeBoundBox > & boundBoxes() const
Return the bounding boxes making up the tree.
List< treeBoundBox > boundBoxes_
Bounding boxes making up the tree.
static const edgeList edges
Edge to point addressing.
void writeOBJ(const bool writeLinesOnly, const treeBoundBox &bb, label &vertI, Ostream &os) const
Write OBJ file of bounding box.
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
Create the bounding boxes by interrogating points.
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
vector span() const
The bounding box span (from minimum to maximum)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void append(const T &)
Append an element at the end of the list.
virtual Ostream & write(const token &)=0
Write next token to stream.
static const faceList faces
Face to point addressing.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
const point & min() const
Minimum describing the bounding box.
Ostream & operator<<(Ostream &, const edgeMesh &)
AABBTree()
Null constructor.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
label maxLevel_
Maximum tree level.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
bool contains(const vector &dir, const point &) const
Contains point (inside or on edge) and moving in direction.
An ordered pair of two objects of type <T> with first() and second() elements.
const List< labelList > & addressing() const
Return the contents addressing.
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...
const dimensionedScalar e
Elementary charge.
Istream & operator>>(Istream &, edgeMesh &)
A bounding box defined in terms of the points at its extremities.
bool empty() const
Return true if the UList is empty (ie, size() is zero).
label minLeafSize_
Minimum points per leaf.
A face is a list of labels corresponding to mesh vertices.
bool overlaps(const boundBox &) const
Overlaps other bounding box?
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label size() const
Return the number of elements in the UList.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Pair< label > labelPair
Label pair.
List< labelList > addressing_
Leaf adressing.
virtual Istream & read(token &)=0
Return next token from stream.