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)
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];
183 bb.
min()[0] >= bb.
max()[0] + tol
184 || bb.
min()[1] >= bb.
max()[1] + tol
185 || bb.
min()[2] >= bb.
max()[2] + tol
189 <<
"Badly formed bounding box:" << bb
197 divide(indices, bb, dividedIndices);
202 bool replaced =
false;
204 for (
direction octant = 0; octant < dividedIndices.
size(); octant++)
206 labelList& subIndices = dividedIndices[octant];
208 if (subIndices.
size())
212 contents[contentI].
transfer(subIndices);
213 nod.subNodes_[octant] = contentPlusOctant(contentI, octant);
220 label sz = contents.size();
223 nod.subNodes_[octant] = contentPlusOctant(sz, octant);
229 nod.subNodes_[octant] = emptyPlusOctant(octant);
251 for (
label nodeI = 0; nodeI < currentSize; nodeI++)
256 octant < nodes[nodeI].subNodes_.
size();
260 labelBits index = nodes[nodeI].subNodes_[octant];
266 else if (isContent(index))
268 label contentI = getContent(index);
270 if (contents[contentI].size() > minSize)
275 const node& nod = nodes[nodeI];
278 node subNode(
divide(bb, contents, contentI));
279 subNode.parent_ = nodeI;
282 nodes[nodeI].subNodes_[octant] = nodePlusOctant(sz, octant);
297 const label compactLevel,
305 const node& nod = nodes[nodeI];
309 if (level < compactLevel)
311 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
317 nNodes += compactContents
330 else if (level == compactLevel)
333 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
337 if (isContent(index))
339 label contentI = getContent(index);
341 compactedContents[compactI].
transfer(contents[contentI]);
344 nodes[nodeI].subNodes_[octant] =
345 contentPlusOctant(compactI, octant);
349 else if (isNode(index))
368 const node& nod = nodes_[nodeI];
372 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
381 subType = calcVolumeType(getNode(index));
383 else if (isContent(index))
387 subType = volumeType::MIXED;
395 subType = shapes_.getVolumeType(*
this, subBb.
midpoint());
399 nodeTypes_.set((nodeI<<3)+octant, subType);
403 if (myType == volumeType::UNKNOWN)
407 else if (subType != myType)
409 myType = volumeType::MIXED;
423 const node& nod = nodes_[nodeI];
425 direction octant = nod.bb_.subOctant(sample);
429 if (octantType == volumeType::INSIDE)
433 else if (octantType == volumeType::OUTSIDE)
437 else if (octantType == volumeType::UNKNOWN)
442 else if (octantType == volumeType::MIXED)
444 labelBits index = nod.subNodes_[octant];
449 volumeType subType = getVolumeType(getNode(index), sample);
453 else if (isContent(index))
456 return volumeType(shapes_.getVolumeType(*
this, sample));
463 <<
"Sample:" << sample <<
" node:" << nodeI
464 <<
" with bb:" << nodes_[nodeI].bb_ <<
nl
465 <<
"Empty subnode has invalid volume type MIXED."
468 return volumeType::UNKNOWN;
474 <<
"Sample:" << sample <<
" at node:" << nodeI
475 <<
" octant:" << octant
476 <<
" with bb:" << nod.bb_.subBbox(octant) <<
nl
477 <<
"Node has invalid volume type " << octantType
480 return volumeType::UNKNOWN;
488 const vector& outsideNormal,
492 if ((outsideNormal&vec) >= 0)
494 return volumeType::OUTSIDE;
498 return volumeType::INSIDE;
511 template<
class FindNearestOp>
517 scalar& nearestDistSqr,
518 label& nearestShapeI,
521 const FindNearestOp& fnOp
524 const node& nod = nodes_[nodeI];
528 nod.bb_.searchOrder(sample, octantOrder);
539 label subNodeI = getNode(index);
543 if (overlaps(subBb.
min(), subBb.
max(), nearestDistSqr, sample))
558 else if (isContent(index))
573 contents_[getContent(index)],
588 template<
class FindNearestOp>
595 label& nearestShapeI,
599 const FindNearestOp& fnOp
602 const node& nod = nodes_[nodeI];
607 nod.bb_.searchOrder(
ln.centre(), octantOrder);
636 else if (isContent(index))
644 contents_[getContent(index)],
661 const label parentNodeI,
666 const node& nod = nodes_[parentNodeI];
672 return nodes_[getNode(index)].bb_;
677 return nod.bb_.subBbox(octant);
689 const bool pushInside
693 const vector perturbVec = perturbTol_*bb.
span();
695 point perturbedPt(pt);
702 for (
direction dir = 0; dir < vector::nComponents; dir++)
704 if (
mag(pt[dir]-bb.
min()[dir]) <
mag(perturbVec[dir]))
707 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
708 perturbedPt[dir] = bb.
min()[dir] + perturbDist;
710 else if (
mag(pt[dir]-bb.
max()[dir]) <
mag(perturbVec[dir]))
713 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
714 perturbedPt[dir] = bb.
max()[dir] - perturbDist;
720 for (
direction dir = 0; dir < vector::nComponents; dir++)
722 if (
mag(pt[dir]-bb.
min()[dir]) <
mag(perturbVec[dir]))
724 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
725 perturbedPt[dir] = bb.
min()[dir] - perturbDist;
727 else if (
mag(pt[dir]-bb.
max()[dir]) <
mag(perturbVec[dir]))
729 scalar perturbDist = perturbVec[dir] + ROOTVSMALL;
730 perturbedPt[dir] = bb.
max()[dir] + perturbDist;
737 if (pushInside != bb.
contains(perturbedPt))
740 <<
"pushed point:" << pt
741 <<
" to:" << perturbedPt
742 <<
" wanted side:" << pushInside
743 <<
" obtained side:" << bb.
contains(perturbedPt)
758 const treeBoundBox& bb,
761 const bool pushInside
765 const vector perturbVec = perturbTol_*bb.span();
767 point perturbedPt(pt);
778 if (faceID & treeBoundBox::LEFTBIT)
782 perturbedPt[0] = bb.min()[0] + (perturbVec[0] + ROOTVSMALL);
786 perturbedPt[0] = bb.min()[0] - (perturbVec[0] + ROOTVSMALL);
789 else if (faceID & treeBoundBox::RIGHTBIT)
793 perturbedPt[0] = bb.max()[0] - (perturbVec[0] + ROOTVSMALL);
797 perturbedPt[0] = bb.max()[0] + (perturbVec[0] + ROOTVSMALL);
801 if (faceID & treeBoundBox::BOTTOMBIT)
805 perturbedPt[1] = bb.min()[1] + (perturbVec[1] + ROOTVSMALL);
809 perturbedPt[1] = bb.min()[1] - (perturbVec[1] + ROOTVSMALL);
812 else if (faceID & treeBoundBox::TOPBIT)
816 perturbedPt[1] = bb.max()[1] - (perturbVec[1] + ROOTVSMALL);
820 perturbedPt[1] = bb.max()[1] + (perturbVec[1] + ROOTVSMALL);
824 if (faceID & treeBoundBox::BACKBIT)
828 perturbedPt[2] = bb.min()[2] + (perturbVec[2] + ROOTVSMALL);
832 perturbedPt[2] = bb.min()[2] - (perturbVec[2] + ROOTVSMALL);
835 else if (faceID & treeBoundBox::FRONTBIT)
839 perturbedPt[2] = bb.max()[2] - (perturbVec[2] + ROOTVSMALL);
843 perturbedPt[2] = bb.max()[2] + (perturbVec[2] + ROOTVSMALL);
849 if (pushInside != bb.contains(perturbedPt))
852 <<
"pushed point:" << pt <<
" on face:" << faceString(faceID)
853 <<
" to:" << perturbedPt
854 <<
" wanted side:" << pushInside
855 <<
" obtained side:" << bb.contains(perturbedPt)
881 <<
" bb:" << bb <<
endl
896 if (ptFaceID & treeBoundBox::LEFTBIT)
898 faceIndices[nFaces++] = treeBoundBox::LEFT;
900 else if (ptFaceID & treeBoundBox::RIGHTBIT)
902 faceIndices[nFaces++] = treeBoundBox::RIGHT;
905 if (ptFaceID & treeBoundBox::BOTTOMBIT)
907 faceIndices[nFaces++] = treeBoundBox::BOTTOM;
909 else if (ptFaceID & treeBoundBox::TOPBIT)
911 faceIndices[nFaces++] = treeBoundBox::TOP;
914 if (ptFaceID & treeBoundBox::BACKBIT)
916 faceIndices[nFaces++] = treeBoundBox::BACK;
918 else if (ptFaceID & treeBoundBox::FRONTBIT)
920 faceIndices[nFaces++] = treeBoundBox::FRONT;
933 else if (nFaces == 1)
936 keepFaceID = faceIndices[0];
943 keepFaceID = faceIndices[0];
944 scalar maxInproduct =
mag(treeBoundBox::faceNormals[keepFaceID] & dir);
949 scalar
s =
mag(treeBoundBox::faceNormals[
face] & dir);
950 if (
s > maxInproduct)
966 if (keepFaceID == treeBoundBox::LEFT)
969 faceID = treeBoundBox::LEFTBIT;
971 else if (keepFaceID == treeBoundBox::RIGHT)
974 faceID = treeBoundBox::RIGHTBIT;
976 else if (keepFaceID == treeBoundBox::BOTTOM)
979 faceID = treeBoundBox::BOTTOMBIT;
981 else if (keepFaceID == treeBoundBox::TOP)
984 faceID = treeBoundBox::TOPBIT;
986 else if (keepFaceID == treeBoundBox::BACK)
989 faceID = treeBoundBox::BACKBIT;
991 else if (keepFaceID == treeBoundBox::FRONT)
994 faceID = treeBoundBox::FRONTBIT;
1003 <<
"Pushed point from " << pt
1004 <<
" on face:" << ptFaceID <<
" of bb:" << bb <<
endl
1006 <<
" on face:" << faceID
1007 <<
" which is not consistent with geometric face "
1014 <<
" bb:" << bb <<
endl
1015 <<
"does not contain perturbed point "
1224 template<
class Type>
1234 parentNodeI = nodes_[nodeI].parent_;
1236 if (parentNodeI == -1)
1242 const node& parentNode = nodes_[parentNodeI];
1247 for (
direction i = 0; i < parentNode.subNodes_.size(); i++)
1249 labelBits index = parentNode.subNodes_[i];
1251 if (isNode(index) && getNode(index) == nodeI)
1258 if (parentOctant == 255)
1261 <<
"Problem: no parent found for octant:" << octant
1262 <<
" node:" << nodeI
1274 template<
class Type>
1283 label oldNodeI = nodeI;
1291 const direction X = treeBoundBox::RIGHTHALF;
1293 const direction Z = treeBoundBox::FRONTHALF;
1298 if ((faceID & treeBoundBox::LEFTBIT) != 0)
1304 else if ((faceID & treeBoundBox::RIGHTBIT) != 0)
1309 if ((faceID & treeBoundBox::BOTTOMBIT) != 0)
1315 else if ((faceID & treeBoundBox::TOPBIT) != 0)
1321 if ((faceID & treeBoundBox::BACKBIT) != 0)
1326 else if ((faceID & treeBoundBox::FRONTBIT) != 0)
1358 while (wantedValue != (octant & octantMask))
1364 if (wantedValue & X)
1384 if (wantedValue &
Y)
1401 if (wantedValue & Z)
1421 walkToParent(nodeI, octant, parentNodeI, parentOctant);
1423 if (parentNodeI == -1)
1438 nodeI = parentNodeI;
1439 octant = parentOctant;
1445 octant ^= octantMask;
1459 <<
" ended up in node:" << nodeI
1460 <<
" octant:" << octant
1461 <<
" with bb:" << subBb
1469 labelBits index = nodes_[nodeI].subNodes_[octant];
1475 nodeI = getNode(node);
1476 octant = getOctant(node);
1484 if (nodeI == oldNodeI && octant == oldOctant)
1487 <<
"Did not go to neighbour when searching for " <<
facePoint
1489 <<
" starting from face:" << faceString(faceID)
1490 <<
" node:" << nodeI
1491 <<
" octant:" << octant
1500 <<
" ended up in node:" << nodeI
1501 <<
" octant:" << octant
1512 template<
class Type>
1524 if (faceID & treeBoundBox::LEFTBIT)
1526 if (!desc.empty()) desc +=
"+";
1529 if (faceID & treeBoundBox::RIGHTBIT)
1531 if (!desc.empty()) desc +=
"+";
1534 if (faceID & treeBoundBox::BOTTOMBIT)
1536 if (!desc.empty()) desc +=
"+";
1539 if (faceID & treeBoundBox::TOPBIT)
1541 if (!desc.empty()) desc +=
"+";
1544 if (faceID & treeBoundBox::BACKBIT)
1546 if (!desc.empty()) desc +=
"+";
1549 if (faceID & treeBoundBox::FRONTBIT)
1551 if (!desc.empty()) desc +=
"+";
1564 template<
class Type>
1565 template<
class FindIntersectOp>
1569 const point& treeStart,
1580 const FindIntersectOp& fiOp
1587 if (octantBb.
posBits(start) != 0)
1590 <<
"Node:" << nodeI <<
" octant:" << octant
1591 <<
" bb:" << octantBb <<
endl
1596 const node& nod = nodes_[nodeI];
1598 labelBits index = nod.subNodes_[octant];
1600 if (isContent(index))
1602 const labelList& indices = contents_[getContent(index)];
1612 label shapeI = indices[elemI];
1615 bool hit = fiOp(shapeI, start, end, pt);
1636 point nearestPoint(end);
1640 label shapeI = indices[elemI];
1643 bool hit = fiOp(shapeI, start, nearestPoint, pt);
1703 point perturbedEnd(pushPoint(octantBb, end,
false));
1725 template<
class Type>
1726 template<
class FindIntersectOp>
1730 const point& treeStart,
1731 const point& treeEnd,
1732 const label startNodeI,
1734 const FindIntersectOp& fiOp,
1738 const vector treeVec(treeEnd - treeStart);
1741 label nodeI = startNodeI;
1746 Pout<<
"findLine : treeStart:" << treeStart
1747 <<
" treeEnd:" << treeEnd <<
endl
1749 <<
" octant:" << octant
1750 <<
" bb:" << subBbox(nodeI, octant) <<
endl;
1758 for (; i < 100000; i++)
1779 <<
" at current:" << hitInfo.
rawPoint()
1780 <<
" (perturbed:" << startPoint <<
")" <<
endl
1781 <<
" node:" << nodeI
1782 <<
" octant:" << octant
1783 <<
" bb:" << subBbox(nodeI, octant) <<
endl;
1816 if (hitFaceID == 0 || hitInfo.
rawPoint() == treeEnd)
1823 point perturbedPoint
1836 Pout<<
" iter:" << i
1837 <<
" hit face:" << faceString(hitFaceID)
1839 <<
" node:" << nodeI
1840 <<
" octant:" << octant
1841 <<
" bb:" << subBbox(nodeI, octant) <<
nl
1842 <<
" walking to neighbour containing:" << perturbedPoint
1851 bool ok = walkToNeighbour
1870 <<
" to neighbour node:" << nodeI
1871 <<
" octant:" << octant
1873 <<
" of octantBb:" << octantBb <<
endl
1898 <<
"Got stuck in loop raytracing from:" << treeStart
1899 <<
" to:" << treeEnd <<
endl
1900 <<
"inside top box:" << subBbox(startNodeI, startOctant)
1906 <<
"Got stuck in loop raytracing from:" << treeStart
1907 <<
" to:" << treeEnd <<
endl
1908 <<
"inside top box:" << subBbox(startNodeI, startOctant)
1918 template<
class Type>
1919 template<
class FindIntersectOp>
1925 const FindIntersectOp& fiOp
1940 if ((startBit & endBit) != 0)
1949 point trackStart(start);
1950 point trackEnd(end);
1955 if (!treeBb.
intersects(start, end, trackStart))
1964 if (!treeBb.
intersects(end, trackStart, trackEnd))
1972 labelBits index = findNode(0, trackStart);
1974 label parentNodeI = getNode(index);
1992 template<
class Type>
2000 const node& nod = nodes_[nodeI];
2003 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
2005 labelBits index = nod.subNodes_[octant];
2009 const treeBoundBox& subBb = nodes_[getNode(index)].bb_;
2013 findBox(getNode(index), searchBox, elements);
2016 else if (isContent(index))
2022 const labelList& indices = contents_[getContent(index)];
2026 label shapeI = indices[i];
2028 if (shapes_.overlaps(shapeI, searchBox))
2039 template<
class Type>
2043 const point& centre,
2044 const scalar radiusSqr,
2048 const node& nod = nodes_[nodeI];
2051 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
2053 labelBits index = nod.subNodes_[octant];
2057 const treeBoundBox& subBb = nodes_[getNode(index)].bb_;
2059 if (subBb.
overlaps(centre, radiusSqr))
2061 findSphere(getNode(index), centre, radiusSqr, elements);
2064 else if (isContent(index))
2068 if (subBb.
overlaps(centre, radiusSqr))
2070 const labelList& indices = contents_[getContent(index)];
2074 label shapeI = indices[i];
2076 if (shapes_.overlaps(shapeI, centre, radiusSqr))
2087 template<
class Type>
2088 template<
class CompareOp>
2091 const scalar nearDist,
2102 const vector nearSpan(nearDist, nearDist, nearDist);
2104 if (tree1.
isNode(index1))
2106 const node& nod1 = tree1.
nodes()[tree1.
getNode(index1)];
2113 if (tree2.
isNode(index2))
2117 const node& nod2 = tree2.
nodes()[tree2.
getNode(index2)];
2119 for (
direction i2 = 0; i2 < nod2.subNodes_.size(); i2++)
2121 labelBits subIndex2 = nod2.subNodes_[i2];
2147 for (
direction i1 = 0; i1 < nod1.subNodes_.size(); i1++)
2149 labelBits subIndex1 = nod1.subNodes_[i1];
2180 if (tree2.
isNode(index2))
2187 for (
direction i2 = 0; i2 < nod2.subNodes_.size(); i2++)
2189 labelBits subIndex2 = nod2.subNodes_[i2];
2223 label shape1 = indices1[i];
2227 label shape2 = indices2[j];
2229 if ((&tree1 != &tree2) || (shape1 != shape2))
2262 template<
class Type>
2273 label nodeI = getNode(index);
2275 const node& nod = nodes_[nodeI];
2277 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
2279 nElems += countElements(nod.subNodes_[octant]);
2282 else if (isContent(index))
2284 nElems += contents_[getContent(index)].size();
2295 template<
class Type>
2307 labelBits index = nodes_[nodeI].subNodes_[octant];
2313 subBb = nodes_[getNode(index)].bb_;
2315 else if (isContent(index) || isEmpty(index))
2317 subBb = nodes_[nodeI].bb_.
subBbox(octant);
2320 Pout<<
"dumpContentNode : writing node:" << nodeI <<
" octant:" << octant
2328 const point& pt = bbPoints[i];
2330 str<<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
2333 forAll(treeBoundBox::edges, i)
2335 const edge&
e = treeBoundBox::edges[i];
2337 str<<
"l " <<
e[0] + 1 <<
' ' <<
e[1] + 1 <<
nl;
2344 template<
class Type>
2354 template<
class Type>
2364 contents_(contents),
2369 template<
class Type>
2374 const label maxLevels,
2375 const scalar maxLeafRatio,
2376 const scalar maxDuplicity
2387 Pout<<
"indexedOctree<Type>::indexedOctree:" <<
nl
2388 <<
" shapes:" << shapes.size() <<
nl
2389 <<
" bb:" << bb <<
nl
2394 if (shapes.size() == 0)
2405 node topNode(
divide(bb, contents, 0));
2414 for (; nLevels < maxLevels; nLevels++)
2420 nEntries += contents[i].size();
2425 Pout<<
"indexedOctree<Type>::indexedOctree:" <<
nl
2426 <<
" nLevels:" << nLevels <<
nl
2427 <<
" nEntries per treeLeaf:" << nEntries/contents.size()
2429 <<
" nEntries per shape (duplicity):"
2430 << nEntries/shapes.size()
2439 nEntries > maxDuplicity*shapes.size()
2447 label nOldNodes = nodes.size();
2450 label(maxLeafRatio),
2455 if (nOldNodes == nodes.size())
2469 contents_.setSize(contents.size());
2476 label nNodes = compactContents
2487 if (compactI == 0 && nNodes == 0)
2493 if (compactI == contents_.size())
2501 nodes_.transfer(nodes);
2509 nEntries += contents_[i].size();
2515 Pout<<
"indexedOctree<Type>::indexedOctree"
2516 <<
" : finished construction of tree of:" << shapes.typeName
2518 <<
" bb:" << this->bb() <<
nl
2519 <<
" shapes:" << shapes.size() <<
nl
2520 <<
" nLevels:" << nLevels <<
nl
2521 <<
" treeNodes:" << nodes_.size() <<
nl
2522 <<
" nEntries:" << nEntries <<
nl
2524 << scalar(nEntries)/contents.size() <<
nl
2525 <<
" per shape (duplicity):"
2526 << scalar(nEntries)/shapes.size() <<
nl
2527 <<
" total memory:" << memSize-oldMemSize
2533 template<
class Type>
2549 template<
class Type>
2577 template<
class Type>
2580 const point& sample,
2581 const scalar startDistSqr
2588 typename Type::findNearestOp(*
this)
2593 template<
class Type>
2594 template<
class FindNearestOp>
2597 const point& sample,
2598 const scalar startDistSqr,
2600 const FindNearestOp& fnOp
2603 scalar nearestDistSqr = startDistSqr;
2604 label nearestShapeI = -1;
2605 point nearestPoint = vector::zero;
2622 return pointIndexHit(nearestShapeI != -1, nearestPoint, nearestShapeI);
2626 template<
class Type>
2639 typename Type::findNearestOp(*
this)
2644 template<
class Type>
2645 template<
class FindNearestOp>
2652 const FindNearestOp& fnOp
2655 label nearestShapeI = -1;
2656 point nearestPoint = vector::zero;
2674 return pointIndexHit(nearestShapeI != -1, nearestPoint, nearestShapeI);
2679 template<
class Type>
2691 typename Type::findIntersectOp(*
this)
2697 template<
class Type>
2709 typename Type::findIntersectOp(*
this)
2715 template<
class Type>
2716 template<
class FindIntersectOp>
2721 const FindIntersectOp& fiOp
2724 return findLine(
false, start, end, fiOp);
2729 template<
class Type>
2730 template<
class FindIntersectOp>
2735 const FindIntersectOp& fiOp
2738 return findLine(
true, start, end, fiOp);
2742 template<
class Type>
2753 findBox(0, searchBox, elements);
2756 return elements.
toc();
2760 template<
class Type>
2763 const point& centre,
2764 const scalar radiusSqr
2772 findSphere(0, centre, radiusSqr, elements);
2775 return elements.
toc();
2780 template<
class Type>
2790 return nodePlusOctant(nodeI, 0);
2793 const node& nod = nodes_[nodeI];
2797 if (!nod.bb_.contains(sample))
2800 <<
"Cannot find " << sample <<
" in node " << nodeI
2805 direction octant = nod.bb_.subOctant(sample);
2807 labelBits index = nod.subNodes_[octant];
2812 return findNode(getNode(index), sample);
2814 else if (isContent(index))
2817 return nodePlusOctant(nodeI, octant);
2822 return nodePlusOctant(nodeI, octant);
2827 template<
class Type>
2832 const node& nod = nodes_[getNode(index)];
2834 labelBits contentIndex = nod.subNodes_[getOctant(index)];
2837 if (isContent(contentIndex))
2839 labelList indices = contents_[getContent(contentIndex)];
2843 label shapeI = indices[elemI];
2845 if (shapes_.contains(shapeI, sample))
2856 template<
class Type>
2864 const node& nod = nodes_[getNode(index)];
2866 labelBits contentIndex = nod.subNodes_[getOctant(index)];
2869 if (isContent(contentIndex))
2871 return contents_[getContent(contentIndex)];
2875 return emptyList<label>();
2881 template<
class Type>
2889 return volumeType::UNKNOWN;
2899 if (nodeTypes_.size() != 8*nodes_.size())
2903 nodeTypes_.setSize(8*nodes_.size());
2904 nodeTypes_ = volumeType::UNKNOWN;
2919 if (
type == volumeType::UNKNOWN)
2923 else if (
type == volumeType::MIXED)
2927 else if (
type == volumeType::INSIDE)
2931 else if (
type == volumeType::OUTSIDE)
2941 Pout<<
"indexedOctree<Type>::getVolumeType : "
2943 <<
" nodes_:" << nodes_.size()
2944 <<
" nodeTypes_:" << nodeTypes_.size()
2945 <<
" nUNKNOWN:" << nUNKNOWN
2946 <<
" nMIXED:" << nMIXED
2947 <<
" nINSIDE:" << nINSIDE
2948 <<
" nOUTSIDE:" << nOUTSIDE
2953 return getVolumeType(0, sample);
2957 template<
class Type>
2958 template<
class CompareOp>
2961 const scalar nearDist,
2971 nodePlusOctant(0, 0),
2974 nodePlusOctant(0, 0),
2982 template<
class Type>
2986 const bool printContents,
2990 const node& nod = nodes_[nodeI];
2993 os <<
"nodeI:" << nodeI <<
" bb:" << bb <<
nl
2994 <<
"parent:" << nod.parent_ <<
nl
2995 <<
"n:" << countElements(nodePlusOctant(nodeI, 0)) <<
nl;
2997 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
3001 labelBits index = nod.subNodes_[octant];
3006 label subNodeI = getNode(index);
3008 os <<
"octant:" << octant
3009 <<
" node: n:" << countElements(index)
3010 <<
" bb:" << subBb <<
endl;
3012 string oldPrefix = os.
prefix();
3013 os.
prefix() =
" " + oldPrefix;
3015 print(os, printContents, subNodeI);
3019 else if (isContent(index))
3021 const labelList& indices = contents_[getContent(index)];
3028 os <<
"octant:" << octant
3029 <<
" content: n:" << indices.
size()
3037 os <<
' ' << indices[j];
3049 os <<
"octant:" << octant <<
" empty:" << subBb <<
endl;
3056 template<
class Type>
3065 template<
class Type>
3069 os << t.
bb() << token::SPACE << t.
nodes()