Class RegionBSPTree3D.RegionSizePropertiesVisitor
java.lang.Object
org.apache.commons.geometry.euclidean.threed.RegionBSPTree3D.RegionSizePropertiesVisitor
- All Implemented Interfaces:
BSPTreeVisitor<Vector3D,
RegionBSPTree3D.RegionNode3D>
- Enclosing class:
RegionBSPTree3D
private static final class RegionBSPTree3D.RegionSizePropertiesVisitor
extends Object
implements BSPTreeVisitor<Vector3D,RegionBSPTree3D.RegionNode3D>
Visitor for computing geometric properties for 3D BSP tree instances.
The volume of the region is computed using the equation
V = (1/3)*ΣF[(CF⋅NF)*area(F)]
,
where F
represents each face in the region, CF
represents the centroid of the face, and NF
represents the
normal of the face. (More details can be found in the article
here.)
This essentially splits up the region into pyramids with a 2D face forming
the base of each pyramid. The centroid is computed in a similar way. The centroid
of each pyramid is calculated using the fact that it is located 3/4 of the way along the
line from the apex to the base. The region centroid then becomes the volume-weighted
average of these pyramid centers.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor
BSPTreeVisitor.ClosestFirstVisitor<P extends Point<P>,
N extends BSPTree.Node<P, N>>, BSPTreeVisitor.FarthestFirstVisitor<P extends Point<P>, N extends BSPTree.Node<P, N>>, BSPTreeVisitor.Order, BSPTreeVisitor.Result, BSPTreeVisitor.TargetPointVisitor<P extends Point<P>, N extends BSPTree.Node<P, N>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double
Centroid contribution x coordinate accumulator.private double
Centroid contribution y coordinate accumulator.private double
Centroid contribution z coordinate accumulator.private double
Accumulator for boundary volume contributions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addBoundaryContribution
(HyperplaneSubset<Vector3D> boundary, boolean reverse) Add the contribution of the given node cut boundary.Return the computed size properties for the visited region.Visit a node in a BSP tree.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor
visitOrder
-
Field Details
-
volumeSum
private double volumeSumAccumulator for boundary volume contributions. -
sumX
private double sumXCentroid contribution x coordinate accumulator. -
sumY
private double sumYCentroid contribution y coordinate accumulator. -
sumZ
private double sumZCentroid contribution z coordinate accumulator.
-
-
Constructor Details
-
RegionSizePropertiesVisitor
private RegionSizePropertiesVisitor()
-
-
Method Details
-
visit
Visit a node in a BSP tree. This method is called for both internal nodes and leaf nodes.- Specified by:
visit
in interfaceBSPTreeVisitor<Vector3D,
RegionBSPTree3D.RegionNode3D> - Parameters:
node
- the node being visited- Returns:
- the result of the visit operation
-
getRegionSizeProperties
Return the computed size properties for the visited region.- Returns:
- the computed size properties for the visited region.
-
addBoundaryContribution
Add the contribution of the given node cut boundary. Ifreverse
is true, the volume of the contribution is reversed before being added to the total.- Parameters:
boundary
- node cut boundaryreverse
- if true, the boundary contribution is reversed before being added to the total.
-