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 java.lang.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 equationV = (1/3)*ΣF[(CF⋅NF)*area(F)]
, whereF
represents each face in the region,CF
represents the centroid of the face, andNF
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:
- Polyhedron#Volume
-
-
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
Fields Modifier and Type Field Description private double
sumX
Centroid contribution x coordinate accumulator.private double
sumY
Centroid contribution y coordinate accumulator.private double
sumZ
Centroid contribution z coordinate accumulator.private double
volumeSum
Accumulator for boundary volume contributions.
-
Constructor Summary
Constructors Modifier Constructor Description private
RegionSizePropertiesVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addBoundaryContribution(HyperplaneSubset<Vector3D> boundary, boolean reverse)
Add the contribution of the given node cut boundary.AbstractRegionBSPTree.RegionSizeProperties<Vector3D>
getRegionSizeProperties()
Return the computed size properties for the visited region.BSPTreeVisitor.Result
visit(RegionBSPTree3D.RegionNode3D node)
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 Detail
-
volumeSum
private double volumeSum
Accumulator for boundary volume contributions.
-
sumX
private double sumX
Centroid contribution x coordinate accumulator.
-
sumY
private double sumY
Centroid contribution y coordinate accumulator.
-
sumZ
private double sumZ
Centroid contribution z coordinate accumulator.
-
-
Method Detail
-
visit
public BSPTreeVisitor.Result visit(RegionBSPTree3D.RegionNode3D node)
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
public AbstractRegionBSPTree.RegionSizeProperties<Vector3D> getRegionSizeProperties()
Return the computed size properties for the visited region.- Returns:
- the computed size properties for the visited region.
-
addBoundaryContribution
private void addBoundaryContribution(HyperplaneSubset<Vector3D> boundary, boolean reverse)
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.
-
-