47 const scalar nearestDistSqr,
53 return bb.
overlaps(sample, nearestDistSqr);
64 const scalar nearestDistSqr,
83 if (octant & treeBoundBox::RIGHTHALF)
92 if (octant & treeBoundBox::TOPHALF)
101 if (octant & treeBoundBox::FRONTHALF)
110 const point mid(0.5*(min+max));
112 return overlaps(mid, other, nearestDistSqr, sample);
131 for (
direction octant = 0; octant < subIndices.
size(); octant++)
133 subIndices[octant].setCapacity(indices.
size()/8);
140 subBbs[octant] = bb.
subBbox(octant);
145 label shapeI = indices[i];
147 for (
direction octant = 0; octant < 8; octant++)
149 if (shapes_.overlaps(shapeI, subBbs[octant]))
151 subIndices[octant].
append(shapeI);
157 for (
direction octant = 0; octant < subIndices.
size(); octant++)
159 result[octant].
transfer(subIndices[octant]);
174 const labelList& indices = contents[contentI];
180 bb.
min()[0] >= bb.
max()[0]
181 || bb.
min()[1] >= bb.
max()[1]
182 || bb.
min()[2] >= bb.
max()[2]
186 <<
"Badly formed bounding box:" << bb
194 divide(indices, bb, dividedIndices);
199 bool replaced =
false;
201 for (
direction octant = 0; octant < dividedIndices.
size(); octant++)
203 labelList& subIndices = dividedIndices[octant];
205 if (subIndices.
size())
209 contents[contentI].
transfer(subIndices);
210 nod.
subNodes_[octant] = contentPlusOctant(contentI, octant);
220 nod.
subNodes_[octant] = contentPlusOctant(sz, octant);
226 nod.
subNodes_[octant] = emptyPlusOctant(octant);
248 for (
label nodeI = 0; nodeI < currentSize; nodeI++)
253 octant < nodes[nodeI].subNodes_.
size();
257 labelBits index = nodes[nodeI].subNodes_[octant];
263 else if (isContent(index))
265 label contentI = getContent(index);
267 if (contents[contentI].size() > minSize)
272 const node& nod = nodes[nodeI];
276 subNode.parent_ = nodeI;
279 nodes[nodeI].subNodes_[octant] = nodePlusOctant(sz, octant);
294 const label compactLevel,
302 const node& nod = nodes[nodeI];
306 if (level < compactLevel)
314 nNodes += compactContents
327 else if (level == compactLevel)
334 if (isContent(index))
336 label contentI = getContent(index);
338 compactedContents[compactI].
transfer(contents[contentI]);
341 nodes[nodeI].subNodes_[octant] =
342 contentPlusOctant(compactI, octant);
346 else if (isNode(index))
365 const node& nod = nodes_[nodeI];
378 subType = calcVolumeType(getNode(index));
380 else if (isContent(index))
384 subType = volumeType::MIXED;
392 subType = shapes_.getVolumeType(*
this, subBb.
midpoint());
396 nodeTypes_.set((nodeI<<3)+octant, subType);
400 if (myType == volumeType::UNKNOWN)
404 else if (subType != myType)
406 myType = volumeType::MIXED;
420 const node& nod = nodes_[nodeI];
426 if (octantType == volumeType::INSIDE)
430 else if (octantType == volumeType::OUTSIDE)
434 else if (octantType == volumeType::UNKNOWN)
439 else if (octantType == volumeType::MIXED)
446 volumeType subType = getVolumeType(getNode(index), sample);
450 else if (isContent(index))
453 return volumeType(shapes_.getVolumeType(*
this, sample));
461 "indexedOctree<Type>::getVolumeType" 462 "(const label, const point&)" 463 ) <<
"Sample:" << sample <<
" node:" << nodeI
464 <<
" with bb:" << nodes_[nodeI].bb_ <<
nl 465 <<
"Empty subnode has invalid volume type MIXED." 468 return volumeType::UNKNOWN;
475 "indexedOctree<Type>::getVolumeType" 476 "(const label, const point&)" 477 ) <<
"Sample:" << sample <<
" at node:" << nodeI
478 <<
" octant:" << octant
480 <<
"Node has invalid volume type " << octantType
483 return volumeType::UNKNOWN;
491 const vector& outsideNormal,
495 if ((outsideNormal&vec) >= 0)
497 return volumeType::OUTSIDE;
501 return volumeType::INSIDE;
514 template<
class FindNearestOp>
520 scalar& nearestDistSqr,
521 label& nearestShapeI,
524 const FindNearestOp& fnOp
527 const node& nod = nodes_[nodeI];
542 label subNodeI = getNode(index);
546 if (overlaps(subBb.
min(), subBb.
max(), nearestDistSqr, sample))
561 else if (isContent(index))
576 contents_[getContent(index)],
591 template<
class FindNearestOp>
598 label& nearestShapeI,
602 const FindNearestOp& fnOp
605 const node& nod = nodes_[nodeI];
639 else if (isContent(index))
643 if (subBb.overlaps(tightest))
647 contents_[getContent(index)],
664 const label parentNodeI,
669 const node& nod = nodes_[parentNodeI];
675 return nodes_[getNode(index)].bb_;
692 const bool pushInside
696 const vector perturbVec = perturbTol_*bb.
span();
698 point perturbedPt(pt);
705 for (
direction dir = 0; dir < vector::nComponents; dir++)
707 if (
mag(pt[dir]-bb.
min()[dir]) <
mag(perturbVec[dir]))
710 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
711 perturbedPt[dir] = bb.
min()[dir] + perturbDist;
713 else if (
mag(pt[dir]-bb.
max()[dir]) <
mag(perturbVec[dir]))
716 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
717 perturbedPt[dir] = bb.
max()[dir] - perturbDist;
723 for (
direction dir = 0; dir < vector::nComponents; dir++)
725 if (
mag(pt[dir]-bb.
min()[dir]) <
mag(perturbVec[dir]))
727 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
728 perturbedPt[dir] = bb.
min()[dir] - perturbDist;
730 else if (
mag(pt[dir]-bb.
max()[dir]) <
mag(perturbVec[dir]))
732 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
733 perturbedPt[dir] = bb.
max()[dir] + perturbDist;
740 if (pushInside != bb.
contains(perturbedPt))
743 <<
"pushed point:" << pt
744 <<
" to:" << perturbedPt
745 <<
" wanted side:" << pushInside
746 <<
" obtained side:" << bb.
contains(perturbedPt)
764 const bool pushInside
768 const vector perturbVec = perturbTol_*bb.
span();
770 point perturbedPt(pt);
781 if (faceID & treeBoundBox::LEFTBIT)
785 perturbedPt[0] = bb.
min()[0] + (perturbVec[0] + ROOTVSMALL);
789 perturbedPt[0] = bb.
min()[0] - (perturbVec[0] + ROOTVSMALL);
792 else if (faceID & treeBoundBox::RIGHTBIT)
796 perturbedPt[0] = bb.
max()[0] - (perturbVec[0] + ROOTVSMALL);
800 perturbedPt[0] = bb.
max()[0] + (perturbVec[0] + ROOTVSMALL);
804 if (faceID & treeBoundBox::BOTTOMBIT)
808 perturbedPt[1] = bb.
min()[1] + (perturbVec[1] + ROOTVSMALL);
812 perturbedPt[1] = bb.
min()[1] - (perturbVec[1] + ROOTVSMALL);
815 else if (faceID & treeBoundBox::TOPBIT)
819 perturbedPt[1] = bb.
max()[1] - (perturbVec[1] + ROOTVSMALL);
823 perturbedPt[1] = bb.
max()[1] + (perturbVec[1] + ROOTVSMALL);
827 if (faceID & treeBoundBox::BACKBIT)
831 perturbedPt[2] = bb.
min()[2] + (perturbVec[2] + ROOTVSMALL);
835 perturbedPt[2] = bb.
min()[2] - (perturbVec[2] + ROOTVSMALL);
838 else if (faceID & treeBoundBox::FRONTBIT)
842 perturbedPt[2] = bb.
max()[2] - (perturbVec[2] + ROOTVSMALL);
846 perturbedPt[2] = bb.
max()[2] + (perturbVec[2] + ROOTVSMALL);
852 if (pushInside != bb.
contains(perturbedPt))
855 <<
"pushed point:" << pt <<
" on face:" << faceString(faceID)
856 <<
" to:" << perturbedPt
857 <<
" wanted side:" << pushInside
858 <<
" obtained side:" << bb.
contains(perturbedPt)
883 FatalErrorIn(
"indexedOctree<Type>::pushPointIntoFace(..)")
884 <<
" bb:" << bb <<
endl 899 if (ptFaceID & treeBoundBox::LEFTBIT)
901 faceIndices[nFaces++] = treeBoundBox::LEFT;
903 else if (ptFaceID & treeBoundBox::RIGHTBIT)
905 faceIndices[nFaces++] = treeBoundBox::RIGHT;
908 if (ptFaceID & treeBoundBox::BOTTOMBIT)
910 faceIndices[nFaces++] = treeBoundBox::BOTTOM;
912 else if (ptFaceID & treeBoundBox::TOPBIT)
914 faceIndices[nFaces++] = treeBoundBox::TOP;
917 if (ptFaceID & treeBoundBox::BACKBIT)
919 faceIndices[nFaces++] = treeBoundBox::BACK;
921 else if (ptFaceID & treeBoundBox::FRONTBIT)
923 faceIndices[nFaces++] = treeBoundBox::FRONT;
936 else if (nFaces == 1)
939 keepFaceID = faceIndices[0];
946 keepFaceID = faceIndices[0];
947 scalar maxInproduct =
mag(treeBoundBox::faceNormals[keepFaceID] & dir);
952 scalar
s =
mag(treeBoundBox::faceNormals[face] & dir);
953 if (s > maxInproduct)
969 if (keepFaceID == treeBoundBox::LEFT)
971 facePoint.
x() = bb.
min().
x();
972 faceID = treeBoundBox::LEFTBIT;
974 else if (keepFaceID == treeBoundBox::RIGHT)
976 facePoint.
x() = bb.
max().
x();
977 faceID = treeBoundBox::RIGHTBIT;
979 else if (keepFaceID == treeBoundBox::BOTTOM)
981 facePoint.
y() = bb.
min().
y();
982 faceID = treeBoundBox::BOTTOMBIT;
984 else if (keepFaceID == treeBoundBox::TOP)
986 facePoint.
y() = bb.
max().
y();
987 faceID = treeBoundBox::TOPBIT;
989 else if (keepFaceID == treeBoundBox::BACK)
991 facePoint.
z() = bb.
min().
z();
992 faceID = treeBoundBox::BACKBIT;
994 else if (keepFaceID == treeBoundBox::FRONT)
996 facePoint.
z() = bb.
max().
z();
997 faceID = treeBoundBox::FRONTBIT;
1003 if (faceID != bb.
faceBits(facePoint))
1005 FatalErrorIn(
"indexedOctree<Type>::pushPointIntoFace(..)")
1006 <<
"Pushed point from " << pt
1007 <<
" on face:" << ptFaceID <<
" of bb:" << bb <<
endl 1008 <<
"onto " << facePoint
1009 <<
" on face:" << faceID
1010 <<
" which is not consistent with geometric face " 1014 if (bb.
posBits(facePoint) != 0)
1016 FatalErrorIn(
"indexedOctree<Type>::pushPointIntoFace(..)")
1017 <<
" bb:" << bb <<
endl 1018 <<
"does not contain perturbed point " 1227 template<
class Type>
1237 parentNodeI = nodes_[nodeI].parent_;
1239 if (parentNodeI == -1)
1245 const node& parentNode = nodes_[parentNodeI];
1254 if (isNode(index) && getNode(index) == nodeI)
1261 if (parentOctant == 255)
1264 <<
"Problem: no parent found for octant:" << octant
1265 <<
" node:" << nodeI
1277 template<
class Type>
1280 const point& facePoint,
1286 label oldNodeI = nodeI;
1294 const direction X = treeBoundBox::RIGHTHALF;
1296 const direction Z = treeBoundBox::FRONTHALF;
1301 if ((faceID & treeBoundBox::LEFTBIT) != 0)
1307 else if ((faceID & treeBoundBox::RIGHTBIT) != 0)
1312 if ((faceID & treeBoundBox::BOTTOMBIT) != 0)
1318 else if ((faceID & treeBoundBox::TOPBIT) != 0)
1324 if ((faceID & treeBoundBox::BACKBIT) != 0)
1329 else if ((faceID & treeBoundBox::FRONTBIT) != 0)
1361 while (wantedValue != (octant & octantMask))
1367 if (wantedValue & X)
1387 if (wantedValue & Y)
1404 if (wantedValue & Z)
1424 walkToParent(nodeI, octant, parentNodeI, parentOctant);
1426 if (parentNodeI == -1)
1441 nodeI = parentNodeI;
1442 octant = parentOctant;
1448 octant ^= octantMask;
1460 FatalErrorIn(
"indexedOctree<Type>::walkToNeighbour(..)")
1461 <<
"When searching for " << facePoint
1462 <<
" ended up in node:" << nodeI
1463 <<
" octant:" << octant
1464 <<
" with bb:" << subBb
1472 labelBits index = nodes_[nodeI].subNodes_[octant];
1478 nodeI = getNode(node);
1479 octant = getOctant(node);
1487 if (nodeI == oldNodeI && octant == oldOctant)
1489 FatalErrorIn(
"indexedOctree<Type>::walkToNeighbour(..)")
1490 <<
"Did not go to neighbour when searching for " << facePoint
1492 <<
" starting from face:" << faceString(faceID)
1493 <<
" node:" << nodeI
1494 <<
" octant:" << octant
1501 FatalErrorIn(
"indexedOctree<Type>::walkToNeighbour(..)")
1502 <<
"When searching for " << facePoint
1503 <<
" ended up in node:" << nodeI
1504 <<
" octant:" << octant
1515 template<
class Type>
1527 if (faceID & treeBoundBox::LEFTBIT)
1529 if (!desc.empty()) desc +=
"+";
1532 if (faceID & treeBoundBox::RIGHTBIT)
1534 if (!desc.empty()) desc +=
"+";
1537 if (faceID & treeBoundBox::BOTTOMBIT)
1539 if (!desc.empty()) desc +=
"+";
1542 if (faceID & treeBoundBox::TOPBIT)
1544 if (!desc.empty()) desc +=
"+";
1547 if (faceID & treeBoundBox::BACKBIT)
1549 if (!desc.empty()) desc +=
"+";
1552 if (faceID & treeBoundBox::FRONTBIT)
1554 if (!desc.empty()) desc +=
"+";
1567 template<
class Type>
1568 template<
class FindIntersectOp>
1572 const point& treeStart,
1583 const FindIntersectOp& fiOp
1590 if (octantBb.
posBits(start) != 0)
1593 <<
"Node:" << nodeI <<
" octant:" << octant
1594 <<
" bb:" << octantBb <<
endl 1599 const node& nod = nodes_[nodeI];
1603 if (isContent(index))
1605 const labelList& indices = contents_[getContent(index)];
1615 label shapeI = indices[elemI];
1618 bool hit = fiOp(shapeI, start, end, pt);
1639 point nearestPoint(end);
1643 label shapeI = indices[elemI];
1646 bool hit = fiOp(shapeI, start, nearestPoint, pt);
1706 point perturbedEnd(pushPoint(octantBb, end,
false));
1728 template<
class Type>
1729 template<
class FindIntersectOp>
1733 const point& treeStart,
1734 const point& treeEnd,
1735 const label startNodeI,
1737 const FindIntersectOp& fiOp,
1741 const vector treeVec(treeEnd - treeStart);
1744 label nodeI = startNodeI;
1749 Pout<<
"findLine : treeStart:" << treeStart
1750 <<
" treeEnd:" << treeEnd <<
endl 1752 <<
" octant:" << octant
1753 <<
" bb:" << subBbox(nodeI, octant) <<
endl;
1761 for (; i < 100000; i++)
1782 <<
" at current:" << hitInfo.
rawPoint()
1783 <<
" (perturbed:" << startPoint <<
")" <<
endl 1784 <<
" node:" << nodeI
1785 <<
" octant:" << octant
1786 <<
" bb:" << subBbox(nodeI, octant) <<
endl;
1819 if (hitFaceID == 0 || hitInfo.
rawPoint() == treeEnd)
1826 point perturbedPoint
1839 Pout<<
" iter:" << i
1840 <<
" hit face:" << faceString(hitFaceID)
1842 <<
" node:" << nodeI
1843 <<
" octant:" << octant
1844 <<
" bb:" << subBbox(nodeI, octant) <<
nl 1845 <<
" walking to neighbour containing:" << perturbedPoint
1854 bool ok = walkToNeighbour
1873 <<
" to neighbour node:" << nodeI
1874 <<
" octant:" << octant
1876 <<
" of octantBb:" << octantBb <<
endl 1901 <<
"Got stuck in loop raytracing from:" << treeStart
1902 <<
" to:" << treeEnd <<
endl 1903 <<
"inside top box:" << subBbox(startNodeI, startOctant)
1908 WarningIn(
"indexedOctree<Type>::findLine(..)")
1909 <<
"Got stuck in loop raytracing from:" << treeStart
1910 <<
" to:" << treeEnd <<
endl 1911 <<
"inside top box:" << subBbox(startNodeI, startOctant)
1921 template<
class Type>
1922 template<
class FindIntersectOp>
1928 const FindIntersectOp& fiOp
1943 if ((startBit & endBit) != 0)
1952 point trackStart(start);
1953 point trackEnd(end);
1958 if (!treeBb.
intersects(start, end, trackStart))
1967 if (!treeBb.
intersects(end, trackStart, trackEnd))
1975 labelBits index = findNode(0, trackStart);
1977 label parentNodeI = getNode(index);
1995 template<
class Type>
2003 const node& nod = nodes_[nodeI];
2012 const treeBoundBox& subBb = nodes_[getNode(index)].bb_;
2016 findBox(getNode(index), searchBox, elements);
2019 else if (isContent(index))
2023 if (subBb.overlaps(searchBox))
2025 const labelList& indices = contents_[getContent(index)];
2029 label shapeI = indices[i];
2031 if (shapes_.overlaps(shapeI, searchBox))
2042 template<
class Type>
2046 const point& centre,
2047 const scalar radiusSqr,
2051 const node& nod = nodes_[nodeI];
2060 const treeBoundBox& subBb = nodes_[getNode(index)].bb_;
2062 if (subBb.
overlaps(centre, radiusSqr))
2064 findSphere(getNode(index), centre, radiusSqr, elements);
2067 else if (isContent(index))
2071 if (subBb.overlaps(centre, radiusSqr))
2073 const labelList& indices = contents_[getContent(index)];
2077 label shapeI = indices[i];
2079 if (shapes_.overlaps(shapeI, centre, radiusSqr))
2090 template<
class Type>
2091 template<
class CompareOp>
2094 const scalar nearDist,
2105 const vector nearSpan(nearDist, nearDist, nearDist);
2107 if (tree1.
isNode(index1))
2116 if (tree2.
isNode(index2))
2183 if (tree2.
isNode(index2))
2226 label shape1 = indices1[i];
2230 label shape2 = indices2[j];
2232 if ((&tree1 != &tree2) || (shape1 != shape2))
2265 template<
class Type>
2276 label nodeI = getNode(index);
2278 const node& nod = nodes_[nodeI];
2282 nElems += countElements(nod.
subNodes_[octant]);
2285 else if (isContent(index))
2287 nElems += contents_[getContent(index)].size();
2298 template<
class Type>
2310 labelBits index = nodes_[nodeI].subNodes_[octant];
2316 subBb = nodes_[getNode(index)].bb_;
2318 else if (isContent(index) || isEmpty(index))
2320 subBb = nodes_[nodeI].bb_.
subBbox(octant);
2323 Pout<<
"dumpContentNode : writing node:" << nodeI <<
" octant:" << octant
2331 const point& pt = bbPoints[i];
2333 str<<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
2336 forAll(treeBoundBox::edges, i)
2338 const edge&
e = treeBoundBox::edges[i];
2340 str<<
"l " << e[0] + 1 <<
' ' << e[1] + 1 <<
nl;
2347 template<
class Type>
2357 template<
class Type>
2367 contents_(contents),
2372 template<
class Type>
2377 const label maxLevels,
2378 const scalar maxLeafRatio,
2379 const scalar maxDuplicity
2390 Pout<<
"indexedOctree<Type>::indexedOctree:" <<
nl 2391 <<
" shapes:" << shapes.size() <<
nl 2392 <<
" bb:" << bb <<
nl 2397 if (shapes.size() == 0)
2408 node topNode(divide(bb, contents, 0));
2417 for (; nLevels < maxLevels; nLevels++)
2423 nEntries += contents[i].
size();
2428 Pout<<
"indexedOctree<Type>::indexedOctree:" <<
nl 2429 <<
" nLevels:" << nLevels <<
nl 2430 <<
" nEntries per treeLeaf:" << nEntries/contents.
size()
2432 <<
" nEntries per shape (duplicity):" 2433 << nEntries/shapes.size()
2442 nEntries > maxDuplicity*shapes.size()
2453 label(maxLeafRatio),
2458 if (nOldNodes == nodes.
size())
2479 label nNodes = compactContents
2490 if (compactI == 0 && nNodes == 0)
2496 if (compactI == contents_.
size())
2504 nodes_.transfer(nodes);
2512 nEntries += contents_[i].
size();
2518 Pout<<
"indexedOctree<Type>::indexedOctree" 2519 <<
" : finished construction of tree of:" << shapes.typeName
2521 <<
" bb:" << this->
bb() <<
nl 2522 <<
" shapes:" << shapes.size() <<
nl 2523 <<
" nLevels:" << nLevels <<
nl 2524 <<
" treeNodes:" << nodes_.size() <<
nl 2525 <<
" nEntries:" << nEntries <<
nl 2527 << scalar(nEntries)/contents.
size() <<
nl 2528 <<
" per shape (duplicity):" 2529 << scalar(nEntries)/shapes.size() <<
nl 2530 <<
" total memory:" << memSize-oldMemSize
2536 template<
class Type>
2552 template<
class Type>
2580 template<
class Type>
2583 const point& sample,
2584 const scalar startDistSqr
2591 typename Type::findNearestOp(*
this)
2596 template<
class Type>
2597 template<
class FindNearestOp>
2600 const point& sample,
2601 const scalar startDistSqr,
2603 const FindNearestOp& fnOp
2606 scalar nearestDistSqr = startDistSqr;
2607 label nearestShapeI = -1;
2625 return pointIndexHit(nearestShapeI != -1, nearestPoint, nearestShapeI);
2629 template<
class Type>
2642 typename Type::findNearestOp(*
this)
2647 template<
class Type>
2648 template<
class FindNearestOp>
2655 const FindNearestOp& fnOp
2658 label nearestShapeI = -1;
2677 return pointIndexHit(nearestShapeI != -1, nearestPoint, nearestShapeI);
2682 template<
class Type>
2694 typename Type::findIntersectOp(*
this)
2700 template<
class Type>
2712 typename Type::findIntersectOp(*
this)
2718 template<
class Type>
2719 template<
class FindIntersectOp>
2724 const FindIntersectOp& fiOp
2727 return findLine(
false, start, end, fiOp);
2732 template<
class Type>
2733 template<
class FindIntersectOp>
2738 const FindIntersectOp& fiOp
2741 return findLine(
true, start, end, fiOp);
2745 template<
class Type>
2756 findBox(0, searchBox, elements);
2759 return elements.
toc();
2763 template<
class Type>
2766 const point& centre,
2767 const scalar radiusSqr
2775 findSphere(0, centre, radiusSqr, elements);
2778 return elements.
toc();
2783 template<
class Type>
2793 return nodePlusOctant(nodeI, 0);
2796 const node& nod = nodes_[nodeI];
2803 <<
"Cannot find " << sample <<
" in node " << nodeI
2820 return nodePlusOctant(nodeI, octant);
2825 return nodePlusOctant(nodeI, octant);
2830 template<
class Type>
2846 label shapeI = indices[elemI];
2848 if (shapes_.contains(shapeI, sample))
2859 template<
class Type>
2878 return emptyList<label>();
2884 template<
class Type>
2902 if (nodeTypes_.
size() != 8*nodes_.size())
2906 nodeTypes_.
setSize(8*nodes_.size());
2944 Pout<<
"indexedOctree<Type>::getVolumeType : " 2946 <<
" nodes_:" << nodes_.size()
2947 <<
" nodeTypes_:" << nodeTypes_.
size()
2948 <<
" nUNKNOWN:" << nUNKNOWN
2949 <<
" nMIXED:" << nMIXED
2950 <<
" nINSIDE:" << nINSIDE
2951 <<
" nOUTSIDE:" << nOUTSIDE
2956 return getVolumeType(0, sample);
2960 template<
class Type>
2961 template<
class CompareOp>
2964 const scalar nearDist,
2974 nodePlusOctant(0, 0),
2977 nodePlusOctant(0, 0),
2985 template<
class Type>
2989 const bool printContents,
2993 const node& nod = nodes_[nodeI];
2996 os <<
"nodeI:" << nodeI <<
" bb:" << bb <<
nl 2998 <<
"n:" << countElements(nodePlusOctant(nodeI, 0)) <<
nl;
3011 os <<
"octant:" << octant
3012 <<
" node: n:" << countElements(index)
3013 <<
" bb:" << subBb <<
endl;
3015 string oldPrefix = os.
prefix();
3016 os.
prefix() =
" " + oldPrefix;
3018 print(os, printContents, subNodeI);
3028 writeOBJ(nodeI, octant);
3031 os <<
"octant:" << octant
3032 <<
" content: n:" << indices.
size()
3040 os <<
' ' << indices[j];
3049 writeOBJ(nodeI, octant);
3052 os <<
"octant:" << octant <<
" empty:" << subBb <<
endl;
3059 template<
class Type>
3068 template<
class Type>
3069 Foam::Ostream& Foam::operator<<(Ostream& os, const indexedOctree<Type>& t)
bool intersects(const point &overallStart, const vector &overallVec, const point &start, const point &end, point &pt, direction &ptBits) const
Intersects segment; set point to intersection position and face,.
const string & prefix() const
Return the prefix of the stream.
void transfer(List< T > &)
Transfer contents of the argument List into this.
const point & min() const
Minimum describing the bounding box.
static label getContent(const labelBits i)
static scalar & perturbTol()
Get the perturbation tolerance.
int size() const
Access the stored memory size (VmSize in /proc/<pid>/status)
Memory usage information for the process running this object.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject( name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE ))
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
dimensioned< scalar > mag(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
bool contains(const vector &dir, const point &) const
Contains point (inside or on edge) and moving in direction.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
const Type & shapes() const
Reference to shape.
const Point & rawPoint() const
Return point with no checking.
const labelListList & contents() const
List of all contents (referenced by those nodes that are.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
const treeBoundBox & bb() const
Top bounding box.
FixedList< labelBits, 8 > subNodes_
IDs of the 8 nodes on all sides of the mid point.
vector span() const
The bounding box span (from minimum to maximum)
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
direction subOctant(const point &pt) const
Returns octant number given point and the calculated midpoint.
static bool isNode(const labelBits i)
void clear()
Clear the addressed list, i.e. set the size to zero.
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Standard boundBox + extra functionality for use in octree.
A 29bits label and 3bits direction packed into single label.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
labelBits findNode(const label nodeI, const point &) const
Find deepest node (as parent+octant) containing point. Starts.
Various functions to operate on Lists.
PointIndexHit< point > pointIndexHit
label size() const
Number of entries.
bool hit() const
Is there a hit.
A 1D vector of objects of type <T> with a fixed size <Size>.
tmp< pointField > points() const
Vertex coordinates. In octant coding.
treeBoundBox bb_
Bounding box of this node.
label size() const
Return the number of elements in the FixedList.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label parent_
Parent node (index into nodes_ of tree)
label facePoint(const int facei, const block &block, const label i, const label j)
static label getNode(const labelBits i)
A face is a list of labels corresponding to mesh vertices.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void setSize(const label, const unsigned int &val=0u)
Alias for resize()
#define WarningIn(functionName)
Report a warning using Foam::Warning.
const dimensionedScalar e
Elementary charge.
void searchOrder(const point &pt, FixedList< direction, 8 > &octantOrder) const
Calculates optimal order to look for nearest to point.
PtrList< volScalarField > & Y
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const fileName & name() const
Return the name of the stream.
bool good() const
Return true if next operation might succeed.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Tree node. Has up pointer and down pointers.
indexedOctree(const Type &shapes)
Construct null.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
direction faceBits(const point &) const
Code position of point on bounding box faces.
static direction getOctant(const labelBits i)
const point & max() const
Maximum describing the bounding box.
List< Key > toc() const
Return the table of contents.
errorManip< error > abort(error &err)
void setIndex(const label index)
direction posBits(const point &) const
Position of point relative to bounding box.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A bounding box defined in terms of the points at its extremities.
Non-pointer based hierarchical recursive searching.
point midpoint() const
The midpoint of the bounding box.
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
bool write(Ostream &os) const
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void setPoint(const Point &p)
List< label > labelList
A List of labels.
Point centre() const
Return centre (centroid)
const List< node > & nodes() const
List of all nodes.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
treeBoundBox subBbox(const direction) const
Sub box given by octant number. Midpoint calculated.
void append(const T &)
Append an element at the end of the list.
Version of OSstream which prints a prefix on each line.
void print(prefixOSstream &, const bool printContents, const label) const
Print tree. Either print all indices (printContent = true) or.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
static bool isContent(const labelBits i)
bool overlaps(const boundBox &) const
Overlaps/touches boundingBox?
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
prefixOSstream Pout(cout,"Pout")
unsigned int get(const label) const
Get value at index I.
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
bool insert(const Key &key)
Insert a new entry.