46 const scalar nearestDistSqr,
54 for (
direction dir = 0; dir < vector::nComponents; dir++)
56 scalar d0 = p0[dir] - sample[dir];
57 scalar d1 = p1[dir] - sample[dir];
59 if ((d0 > 0) != (d1 > 0))
64 else if (
mag(d0) <
mag(d1))
73 if (distSqr > nearestDistSqr)
90 const scalar nearestDistSqr,
109 if (octant & treeBoundBox::RIGHTHALF)
118 if (octant & treeBoundBox::TOPHALF)
127 if (octant & treeBoundBox::FRONTHALF)
138 return overlaps(mid, other, nearestDistSqr, sample);
156 for (
direction octant = 0; octant < 8; octant++)
169 for (
direction octant = 0; octant < 8; octant++)
171 subBbs[octant] = bb.
subBbox(octant);
176 label shapeI = indices()[i];
178 for (
direction octant = 0; octant < 8; octant++)
180 if (shapes_.overlaps(shapeI, subBbs[octant]))
182 result[octant]().append(shapeI);
195 const label contentI,
196 const label parentNodeIndex,
197 const label octantToBeDivided
209 bb.
min()[0] >= bb.
max()[0] + tol
210 || bb.
min()[1] >= bb.
max()[1] + tol
211 || bb.
min()[2] >= bb.
max()[2] + tol
215 <<
"Badly formed bounding box:" << bb
223 divide(indices, bb, dividedIndices);
228 bool replaced =
false;
230 for (
direction octant = 0; octant < dividedIndices.size(); octant++)
234 if (subIndices().size())
238 contents_[contentI]().transfer(subIndices());
239 nod.
subNodes_[octant] = contentPlusOctant(contentI, octant);
247 label sz = contents_.size();
257 contents_[sz]().transfer(subIndices());
259 nod.
subNodes_[octant] = contentPlusOctant(sz, octant);
265 nod.
subNodes_[octant] = emptyPlusOctant(octant);
270 if (parentNodeIndex != -1)
274 label sz = nodes_.size();
278 nodes_[parentNodeIndex].subNodes_[octantToBeDivided]
279 = nodePlusOctant(sz, octantToBeDivided);
290 const label contentI,
291 const label parentIndex,
298 contents_[contentI]().size() > minSize_
299 && nLevels < maxLevels_
303 node nod =
divide(subBb, contentI, parentIndex, octant);
310 for (
direction subOct = 0; subOct < 8; subOct++)
314 if (isContent(subNodeLabel))
318 const label subContentI = getContent(subNodeLabel);
320 const label parentNodeIndex = nodes_.size() - 1;
345 const node& nod = nodes_[nodeI];
358 subType = calcVolumeType(getNode(index));
360 else if (isContent(index))
364 subType = volumeType::MIXED;
374 shapes_.getVolumeType(*
this, subBb.
midpoint())
379 nodeTypes_.set((nodeI<<3)+octant, subType);
383 if (myType == volumeType::UNKNOWN)
387 else if (subType != myType)
389 myType = volumeType::MIXED;
403 const node& nod = nodes_[nodeI];
405 direction octant = nod.bb_.subOctant(sample);
409 if (octantType == volumeType::INSIDE)
413 else if (octantType == volumeType::OUTSIDE)
417 else if (octantType == volumeType::UNKNOWN)
422 else if (octantType == volumeType::MIXED)
424 labelBits index = nod.subNodes_[octant];
429 volumeType subType = getVolumeType(getNode(index), sample);
433 else if (isContent(index))
436 return volumeType(shapes_.getVolumeType(*
this, sample));
443 <<
"Sample:" << sample <<
" node:" << nodeI
444 <<
" with bb:" << nodes_[nodeI].bb_ <<
nl
445 <<
"Empty subnode has invalid volume type MIXED."
448 return volumeType::UNKNOWN;
454 <<
"Sample:" << sample <<
" at node:" << nodeI
455 <<
" octant:" << octant
456 <<
" with bb:" << nod.bb_.subBbox(octant) <<
nl
457 <<
"Node has invalid volume type " << octantType
460 return volumeType::UNKNOWN;
468 const vector& outsideNormal,
472 if ((outsideNormal&vec) >= 0)
474 return volumeType::OUTSIDE;
478 return volumeType::INSIDE;
495 scalar& nearestDistSqr,
496 label& nearestShapeI,
500 const node& nod = nodes_[nodeI];
504 nod.bb_.searchOrder(sample, octantOrder);
515 label subNodeI = getNode(index);
519 if (overlaps(subBb.
min(), subBb.
max(), nearestDistSqr, sample))
532 else if (isContent(index))
547 contents_[getContent(index)],
568 label& nearestShapeI,
573 const node& nod = nodes_[nodeI];
605 else if (isContent(index))
613 contents_[getContent(index)],
630 const label parentNodeI,
635 const node& nod = nodes_[parentNodeI];
641 return nodes_[getNode(index)].bb_;
658 const bool pushInside
662 const vector perturbVec = perturbTol_*bb.
span();
664 point perturbedPt(pt);
671 for (
direction dir = 0; dir < vector::nComponents; dir++)
673 if (
mag(pt[dir]-bb.
min()[dir]) <
mag(perturbVec[dir]))
676 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
677 perturbedPt[dir] = bb.
min()[dir] + perturbDist;
679 else if (
mag(pt[dir]-bb.
max()[dir]) <
mag(perturbVec[dir]))
682 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
683 perturbedPt[dir] = bb.
max()[dir] - perturbDist;
689 for (
direction dir = 0; dir < vector::nComponents; dir++)
691 if (
mag(pt[dir]-bb.
min()[dir]) <
mag(perturbVec[dir]))
693 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
694 perturbedPt[dir] = bb.
min()[dir] - perturbDist;
696 else if (
mag(pt[dir]-bb.
max()[dir]) <
mag(perturbVec[dir]))
698 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
699 perturbedPt[dir] = bb.
max()[dir] + perturbDist;
706 if (pushInside != bb.
contains(perturbedPt))
709 <<
"pushed point:" << pt
710 <<
" to:" << perturbedPt
711 <<
" wanted side:" << pushInside
712 <<
" obtained side:" << bb.
contains(perturbedPt)
727 const treeBoundBox& bb,
730 const bool pushInside
734 const vector perturbVec = perturbTol_*bb.span();
736 point perturbedPt(pt);
747 if (faceID & treeBoundBox::LEFTBIT)
751 perturbedPt[0] = bb.min()[0] + (perturbVec[0] + ROOTVSMALL);
755 perturbedPt[0] = bb.min()[0] - (perturbVec[0] + ROOTVSMALL);
758 else if (faceID & treeBoundBox::RIGHTBIT)
762 perturbedPt[0] = bb.max()[0] - (perturbVec[0] + ROOTVSMALL);
766 perturbedPt[0] = bb.max()[0] + (perturbVec[0] + ROOTVSMALL);
770 if (faceID & treeBoundBox::BOTTOMBIT)
774 perturbedPt[1] = bb.min()[1] + (perturbVec[1] + ROOTVSMALL);
778 perturbedPt[1] = bb.min()[1] - (perturbVec[1] + ROOTVSMALL);
781 else if (faceID & treeBoundBox::TOPBIT)
785 perturbedPt[1] = bb.max()[1] - (perturbVec[1] + ROOTVSMALL);
789 perturbedPt[1] = bb.max()[1] + (perturbVec[1] + ROOTVSMALL);
793 if (faceID & treeBoundBox::BACKBIT)
797 perturbedPt[2] = bb.min()[2] + (perturbVec[2] + ROOTVSMALL);
801 perturbedPt[2] = bb.min()[2] - (perturbVec[2] + ROOTVSMALL);
804 else if (faceID & treeBoundBox::FRONTBIT)
808 perturbedPt[2] = bb.max()[2] - (perturbVec[2] + ROOTVSMALL);
812 perturbedPt[2] = bb.max()[2] + (perturbVec[2] + ROOTVSMALL);
818 if (pushInside != bb.contains(perturbedPt))
821 <<
"pushed point:" << pt <<
" on face:" << faceString(faceID)
822 <<
" to:" << perturbedPt
823 <<
" wanted side:" << pushInside
824 <<
" obtained side:" << bb.contains(perturbedPt)
850 <<
" bb:" << bb <<
endl
865 if (ptFaceID & treeBoundBox::LEFTBIT)
867 faceIndices[nFaces++] = treeBoundBox::LEFT;
869 else if (ptFaceID & treeBoundBox::RIGHTBIT)
871 faceIndices[nFaces++] = treeBoundBox::RIGHT;
874 if (ptFaceID & treeBoundBox::BOTTOMBIT)
876 faceIndices[nFaces++] = treeBoundBox::BOTTOM;
878 else if (ptFaceID & treeBoundBox::TOPBIT)
880 faceIndices[nFaces++] = treeBoundBox::TOP;
883 if (ptFaceID & treeBoundBox::BACKBIT)
885 faceIndices[nFaces++] = treeBoundBox::BACK;
887 else if (ptFaceID & treeBoundBox::FRONTBIT)
889 faceIndices[nFaces++] = treeBoundBox::FRONT;
902 else if (nFaces == 1)
905 keepFaceID = faceIndices[0];
912 keepFaceID = faceIndices[0];
913 scalar maxInproduct =
mag(treeBoundBox::faceNormals[keepFaceID] & dir);
918 scalar
s =
mag(treeBoundBox::faceNormals[
face] & dir);
919 if (
s > maxInproduct)
935 if (keepFaceID == treeBoundBox::LEFT)
938 faceID = treeBoundBox::LEFTBIT;
940 else if (keepFaceID == treeBoundBox::RIGHT)
943 faceID = treeBoundBox::RIGHTBIT;
945 else if (keepFaceID == treeBoundBox::BOTTOM)
948 faceID = treeBoundBox::BOTTOMBIT;
950 else if (keepFaceID == treeBoundBox::TOP)
953 faceID = treeBoundBox::TOPBIT;
955 else if (keepFaceID == treeBoundBox::BACK)
958 faceID = treeBoundBox::BACKBIT;
960 else if (keepFaceID == treeBoundBox::FRONT)
963 faceID = treeBoundBox::FRONTBIT;
972 <<
"Pushed point from " << pt
973 <<
" on face:" << ptFaceID <<
" of bb:" << bb <<
endl
975 <<
" on face:" << faceID
976 <<
" which is not consistent with geometric face "
983 <<
" bb:" << bb <<
endl
984 <<
"does not contain perturbed point "
1193 template<
class Type>
1203 parentNodeI = nodes_[nodeI].parent_;
1205 if (parentNodeI == -1)
1211 const node& parentNode = nodes_[parentNodeI];
1220 if (isNode(index) && getNode(index) == nodeI)
1227 if (parentOctant == 255)
1230 <<
"Problem: no parent found for octant:" << octant
1231 <<
" node:" << nodeI
1243 template<
class Type>
1252 label oldNodeI = nodeI;
1260 const direction X = treeBoundBox::RIGHTHALF;
1262 const direction Z = treeBoundBox::FRONTHALF;
1267 if ((faceID & treeBoundBox::LEFTBIT) != 0)
1273 else if ((faceID & treeBoundBox::RIGHTBIT) != 0)
1278 if ((faceID & treeBoundBox::BOTTOMBIT) != 0)
1284 else if ((faceID & treeBoundBox::TOPBIT) != 0)
1290 if ((faceID & treeBoundBox::BACKBIT) != 0)
1295 else if ((faceID & treeBoundBox::FRONTBIT) != 0)
1327 while (wantedValue != (octant & octantMask))
1333 if (wantedValue & X)
1353 if (wantedValue &
Y)
1370 if (wantedValue & Z)
1390 walkToParent(nodeI, octant, parentNodeI, parentOctant);
1392 if (parentNodeI == -1)
1407 nodeI = parentNodeI;
1408 octant = parentOctant;
1414 octant ^= octantMask;
1428 <<
" ended up in node:" << nodeI
1429 <<
" octant:" << octant
1430 <<
" with bb:" << subBb
1438 labelBits index = nodes_[nodeI].subNodes_[octant];
1444 nodeI = getNode(
node);
1445 octant = getOctant(
node);
1453 if (nodeI == oldNodeI && octant == oldOctant)
1456 <<
"Did not go to neighbour when searching for " <<
facePoint
1458 <<
" starting from face:" << faceString(faceID)
1459 <<
" node:" << nodeI
1460 <<
" octant:" << octant
1469 <<
" ended up in node:" << nodeI
1470 <<
" octant:" << octant
1481 template<
class Type>
1493 if (faceID & treeBoundBox::LEFTBIT)
1495 if (!desc.empty()) desc +=
"+";
1498 if (faceID & treeBoundBox::RIGHTBIT)
1500 if (!desc.empty()) desc +=
"+";
1503 if (faceID & treeBoundBox::BOTTOMBIT)
1505 if (!desc.empty()) desc +=
"+";
1508 if (faceID & treeBoundBox::TOPBIT)
1510 if (!desc.empty()) desc +=
"+";
1513 if (faceID & treeBoundBox::BACKBIT)
1515 if (!desc.empty()) desc +=
"+";
1518 if (faceID & treeBoundBox::FRONTBIT)
1520 if (!desc.empty()) desc +=
"+";
1533 template<
class Type>
1537 const point& treeStart,
1553 if (octantBb.
posBits(start) != 0)
1556 <<
"Node:" << nodeI <<
" octant:" << octant
1557 <<
" bb:" << octantBb <<
endl
1563 const node& nod = nodes_[nodeI];
1567 if (isContent(index))
1569 const labelList& indices = contents_[getContent(index)];
1579 label shapeI = indices[elemI];
1582 bool hit = shapes_.intersects(shapeI, start, end, pt);
1603 point nearestPoint(end);
1607 label shapeI = indices[elemI];
1610 bool hit = shapes_.intersects
1676 point perturbedEnd(pushPoint(octantBb, end,
false));
1696 template<
class Type>
1700 const point& treeStart,
1701 const point& treeEnd,
1702 const label startNodeI,
1707 const vector treeVec(treeEnd - treeStart);
1710 label nodeI = startNodeI;
1715 Pout<<
"findLine : treeStart:" << treeStart
1716 <<
" treeEnd:" << treeEnd <<
endl
1718 <<
" octant:" << octant
1719 <<
" bb:" << subBbox(nodeI, octant) <<
endl;
1727 for (; i < 100000; i++)
1732 const treeBoundBox octantBb(subBbox(nodeI, octant));
1748 <<
" at current:" << hitInfo.
rawPoint()
1749 <<
" (perturbed:" << startPoint <<
")" <<
endl
1750 <<
" node:" << nodeI
1751 <<
" octant:" << octant
1752 <<
" bb:" << subBbox(nodeI, octant) <<
endl;
1783 if (hitFaceID == 0 || hitInfo.
rawPoint() == treeEnd)
1790 point perturbedPoint
1803 Pout<<
" iter:" << i
1804 <<
" hit face:" << faceString(hitFaceID)
1806 <<
" node:" << nodeI
1807 <<
" octant:" << octant
1808 <<
" bb:" << subBbox(nodeI, octant) <<
nl
1809 <<
" walking to neighbour containing:" << perturbedPoint
1818 bool ok = walkToNeighbour
1835 const treeBoundBox octantBb(subBbox(nodeI, octant));
1837 <<
" to neighbour node:" << nodeI
1838 <<
" octant:" << octant
1839 <<
" face:" << faceString(octantBb.faceBits(hitInfo.
rawPoint()))
1840 <<
" of octantBb:" << octantBb <<
endl
1864 <<
"Got stuck in loop raytracing from:" << treeStart
1865 <<
" to:" << treeEnd <<
endl
1866 <<
"inside top box:" << subBbox(startNodeI, startOctant)
1872 <<
"Got stuck in loop raytracing from:" << treeStart
1873 <<
" to:" << treeEnd <<
endl
1874 <<
"inside top box:" << subBbox(startNodeI, startOctant)
1884 template<
class Type>
1904 if ((startBit & endBit) != 0)
1913 point trackStart(start);
1914 point trackEnd(end);
1919 if (!treeBb.
intersects(start, end, trackStart))
1928 if (!treeBb.
intersects(end, trackStart, trackEnd))
1936 labelBits index = findNode(0, trackStart);
1938 label parentNodeI = getNode(index);
1955 template<
class Type>
1963 const node& nod = nodes_[nodeI];
1972 const treeBoundBox& subBb = nodes_[getNode(index)].bb_;
1976 findBox(getNode(index), searchBox, elements);
1979 else if (isContent(index))
1985 const labelList& indices = contents_[getContent(index)];
1989 label shapeI = indices[i];
1991 if (shapes_.overlaps(shapeI, searchBox))
2002 template<
class Type>
2006 const point& centre,
2007 const scalar radiusSqr,
2011 const node& nod = nodes_[nodeI];
2020 const treeBoundBox& subBb = nodes_[getNode(index)].bb_;
2022 if (subBb.
overlaps(centre, radiusSqr))
2024 findSphere(getNode(index), centre, radiusSqr, elements);
2027 else if (isContent(index))
2031 if (subBb.
overlaps(centre, radiusSqr))
2033 const labelList& indices = contents_[getContent(index)];
2037 label shapeI = indices[i];
2039 if (shapes_.overlaps(shapeI, centre, radiusSqr))
2050 template<
class Type>
2051 template<
class CompareOp>
2054 const scalar nearDist,
2065 const vector nearSpan(nearDist, nearDist, nearDist);
2067 if (tree1.
isNode(index1))
2076 if (tree2.
isNode(index2))
2143 if (tree2.
isNode(index2))
2186 label shape1 = indices1[i];
2190 label shape2 = indices2[j];
2192 if ((&tree1 != &tree2) || (shape1 != shape2))
2225 template<
class Type>
2236 label nodeI = getNode(index);
2238 const node& nod = nodes_[nodeI];
2242 nElems += countElements(nod.
subNodes_[octant]);
2245 else if (isContent(index))
2247 nElems += contents_[getContent(index)]().size();
2258 template<
class Type>
2270 labelBits index = nodes_[nodeI].subNodes_[octant];
2276 subBb = nodes_[getNode(index)].bb_;
2278 else if (isContent(index) || isEmpty(index))
2280 subBb = nodes_[nodeI].bb_.
subBbox(octant);
2283 Pout<<
"dumpContentNode : writing node:" << nodeI <<
" octant:" << octant
2291 const point& pt = bbPoints[i];
2293 str<<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
2296 forAll(treeBoundBox::edges, i)
2298 const edge&
e = treeBoundBox::edges[i];
2300 str<<
"l " <<
e[0] + 1 <<
' ' <<
e[1] + 1 <<
nl;
2307 template<
class Type>
2312 const label maxLevels,
2313 const scalar maxLeafRatio,
2314 const scalar maxDuplicity
2319 maxLevels_(maxLevels),
2321 maxLeafRatio_(maxLeafRatio),
2322 minSize_(
label(maxLeafRatio)),
2323 maxDuplicity_(maxDuplicity),
2324 nodes_(
label(shapes.size() / maxLeafRatio_)),
2325 contents_(
label(shapes.size() / maxLeafRatio_)),
2328 if (shapes_.size() == 0)
2333 insert(0, shapes_.size());
2344 template<
class Type>
2351 template<
class Type>
2354 const point& sample,
2355 const scalar startDistSqr
2358 scalar nearestDistSqr = startDistSqr;
2359 label nearestShapeI = -1;
2360 point nearestPoint = vector::zero;
2375 return pointIndexHit(nearestShapeI != -1, nearestPoint, nearestShapeI);
2379 template<
class Type>
2387 label nearestShapeI = -1;
2405 nearestPoint = vector::zero;
2408 return pointIndexHit(nearestShapeI != -1, nearestPoint, nearestShapeI);
2413 template<
class Type>
2420 return findLine(
false, start, end);
2425 template<
class Type>
2432 return findLine(
true, start, end);
2436 template<
class Type>
2447 findBox(0, searchBox, elements);
2450 return elements.
toc();
2454 template<
class Type>
2457 const point& centre,
2458 const scalar radiusSqr
2466 findSphere(0, centre, radiusSqr, elements);
2469 return elements.
toc();
2474 template<
class Type>
2484 return nodePlusOctant(nodeI, 0);
2487 const node& nod = nodes_[nodeI];
2494 <<
"Cannot find " << sample <<
" in node " << nodeI
2506 return findNode(getNode(index), sample);
2508 else if (isContent(index))
2511 return nodePlusOctant(nodeI, octant);
2516 return nodePlusOctant(nodeI, octant);
2521 template<
class Type>
2529 const node& nod = nodes_[getNode(index)];
2534 if (isContent(contentIndex))
2536 labelList indices = contents_[getContent(contentIndex)];
2540 label shapeI = indices[elemI];
2542 if (shapes_.contains(shapeI, sample))
2553 template<
class Type>
2561 const node& nod = nodes_[getNode(index)];
2566 if (isContent(contentIndex))
2568 return contents_[getContent(contentIndex)];
2572 return emptyList<label>();
2578 template<
class Type>
2586 return volumeType::UNKNOWN;
2589 if (nodeTypes_.size() != 8*nodes_.size())
2593 nodeTypes_.setSize(8*nodes_.size());
2594 nodeTypes_ = volumeType::UNKNOWN;
2609 if (
type == volumeType::UNKNOWN)
2613 else if (
type == volumeType::MIXED)
2617 else if (
type == volumeType::INSIDE)
2621 else if (
type == volumeType::OUTSIDE)
2631 Pout<<
"dynamicIndexedOctree<Type>::getVolumeType : "
2633 <<
" nodes_:" << nodes_.size()
2634 <<
" nodeTypes_:" << nodeTypes_.size()
2635 <<
" nUNKNOWN:" << nUNKNOWN
2636 <<
" nMIXED:" << nMIXED
2637 <<
" nINSIDE:" << nINSIDE
2638 <<
" nOUTSIDE:" << nOUTSIDE
2643 return getVolumeType(0, sample);
2647 template<
class Type>
2648 template<
class CompareOp>
2651 const scalar nearDist,
2661 nodePlusOctant(0, 0),
2664 nodePlusOctant(0, 0),
2671 template<
class Type>
2674 if (startIndex == endIndex)
2689 contents_[0]().append(0);
2694 nodes_.append(topNode);
2701 for (
label pI = startIndex; pI < endIndex; ++pI)
2705 if (!insertIndex(0, pI, nLevels))
2710 nLevelsMax_ =
max(nLevels, nLevelsMax_);
2717 template<
class Type>
2720 const label nodIndex,
2725 bool shapeInserted =
false;
2727 for (
direction octant = 0; octant < 8; octant++)
2729 const labelBits& subNodeLabel = nodes_[nodIndex].subNodes_[octant];
2731 if (isNode(subNodeLabel))
2733 const treeBoundBox& subBb = nodes_[getNode(subNodeLabel)].bb_;
2735 if (shapes().overlaps(index, subBb))
2739 if (insertIndex(getNode(subNodeLabel), index, nLevels))
2741 shapeInserted =
true;
2745 else if (isContent(subNodeLabel))
2749 if (shapes().overlaps(index, subBb))
2751 const label contentI = getContent(subNodeLabel);
2753 contents_[contentI]().append(index);
2755 recursiveSubDivision
2764 shapeInserted =
true;
2771 if (shapes().overlaps(index, subBb))
2773 label sz = contents_.size();
2780 contents_[sz]().append(index);
2782 nodes_[nodIndex].subNodes_[octant]
2783 = contentPlusOctant(sz, octant);
2786 shapeInserted =
true;
2790 return shapeInserted;
2794 template<
class Type>
2802 removeIndex(0, index);
2808 template<
class Type>
2811 const label nodIndex,
2815 label totalContents = 0;
2817 for (
direction octant = 0; octant < 8; octant++)
2819 const labelBits& subNodeLabel = nodes_[nodIndex].subNodes_[octant];
2821 if (isNode(subNodeLabel))
2823 const treeBoundBox& subBb = nodes_[getNode(subNodeLabel)].bb_;
2825 if (shapes().overlaps(index, subBb))
2828 label childContentsSize
2829 = removeIndex(getNode(subNodeLabel), index);
2831 totalContents += childContentsSize;
2833 if (childContentsSize == 0)
2835 nodes_[nodIndex].subNodes_[octant]
2836 = emptyPlusOctant(octant);
2845 else if (isContent(subNodeLabel))
2849 const label contentI = getContent(subNodeLabel);
2851 if (shapes().overlaps(index, subBb))
2859 const label oldIndex = contentList[pI];
2861 if (oldIndex != index)
2863 newContent.
append(oldIndex);
2867 newContent.shrink();
2869 if (newContent.size() == 0)
2872 nodes_[nodIndex].subNodes_[octant]
2873 = emptyPlusOctant(octant);
2879 totalContents += contents_[contentI]().size();
2887 return totalContents;
2892 template<
class Type>
2896 const bool printContents,
2900 const node& nod = nodes_[nodeI];
2903 os <<
"nodeI:" << nodeI <<
" bb:" << bb <<
nl
2905 <<
"n:" << countElements(nodePlusOctant(nodeI, 0)) <<
nl;
2916 label subNodeI = getNode(index);
2918 os <<
"octant:" << octant
2919 <<
" node: n:" << countElements(index)
2920 <<
" bb:" << subBb <<
endl;
2922 string oldPrefix = os.
prefix();
2923 os.
prefix() =
" " + oldPrefix;
2925 print(os, printContents, subNodeI);
2929 else if (isContent(index))
2931 const labelList& indices = contents_[getContent(index)];
2938 os <<
"octant:" << octant
2939 <<
" content: n:" << indices.
size()
2947 os <<
' ' << indices[j];
2959 os <<
"octant:" << octant <<
" empty:" << subBb <<
endl;
2965 template<
class Type>
2971 nEntries += contents_[i]().size();
2974 Pout<<
"indexedOctree<Type>::indexedOctree"
2975 <<
" : finished construction of tree of:" << shapes().typeName
2977 <<
" bounding box: " << this->bb() <<
nl
2978 <<
" shapes: " << shapes().size() <<
nl
2979 <<
" treeNodes: " << nodes_.size() <<
nl
2980 <<
" nEntries: " << nEntries <<
nl
2981 <<
" levels/maxLevels: " << nLevelsMax_ <<
"/" << maxLevels_ <<
nl
2982 <<
" minSize: " << minSize_ <<
nl
2983 <<
" per treeLeaf: "
2984 << scalar(nEntries)/contents_.size() <<
nl
2985 <<
" per shape (duplicity):"
2986 << scalar(nEntries)/shapes().size() <<
nl
2992 template<
class Type>
3001 template<
class Type>
3005 os << t.
bb() << token::SPACE << t.
nodes() <<
endl;