Class PoissonDiskSubSampling
java.lang.Object
cz.fidentis.analyst.engines.sampling.impl.PointSamplingVisitorImpl
cz.fidentis.analyst.engines.sampling.impl.PoissonDiskSubSampling
- All Implemented Interfaces:
MeshVisitor
,PointSamplingVisitor
- Direct Known Subclasses:
PoissonDiskSubSamplingGPU
This downsampling algorithm evenly distributes samples over the mesh surface
while preserving at least a minimal distance d between samples. It generates
2D plane with poisson samples, iteratively project poisson samples onto the
mesh from different angles and filter valid projected poisson samples.
The minimal distance is approximated from required number of samples and number
of samples is on average +- 5% required number.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents uncovered region of plane, octree node -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final double
static final double
protected final MeshTriangle.Smoothing
-
Constructor Summary
ConstructorsConstructorDescriptionPoissonDiskSubSampling
(double minimalDistance, MeshTriangle.Smoothing smoothing) Constructor for required sample densityPoissonDiskSubSampling
(int max, MeshTriangle.Smoothing smoothing) Constructor for the maximum number of samples. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addSamplesToKdTree
(Set<MeshPoint> samples, KdTree kdTree) Adds samples to the KdTreeprotected List
<javax.vecmath.Point3d> createProjectorFromGrid
(javax.vecmath.Point2d[][] grid, javax.vecmath.Point3d meshCentroid, double projectorSize, double radius) Creates projector plane (parallel to XY plane) from grid .static int
distanceToNumSamples
(double minimalDistance) Estimates minimal distance from the given number of samples.filterRaysIntersections
(KdTree kdTree, Set<MeshPoint> intersections) Filters intersections not breaking minimal distance rule.protected javax.vecmath.Point2d[][]
generatePoissonSamples
(double minPlaneSize) Generate 2D Poisson-disk sample girdReturns a list of vertices reduced according to the strategy.boolean
Iftrue
, then the returned points samples are points from the original mesh.protected void
rotateProjectorPlane
(List<javax.vecmath.Point3d> projector, javax.vecmath.Point3d centroid, double thetaX, double thetaY) Rotates projector plane around mesh centroid in x,y-axis by given angles.void
setRequiredSamples
(int max) Changes the number of required samples.toString()
void
visitMeshFacet
(MeshFacet facet) The inspection method to be implemented by specific visitors.Methods inherited from class cz.fidentis.analyst.engines.sampling.impl.PointSamplingVisitorImpl
getRequiredSamples, setRealSamples
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface cz.fidentis.analyst.data.mesh.MeshVisitor
dispose, isThreadSafe
-
Field Details
-
facets
-
smoothing
-
PROJECTOR_MAX_ANGLE
public static final double PROJECTOR_MAX_ANGLE- See Also:
-
PROJECTOR_MIN_ROTATION
public static final double PROJECTOR_MIN_ROTATION- See Also:
-
MIN_PROJECTION_ITERATIONS
public static final int MIN_PROJECTION_ITERATIONS- See Also:
-
POISSON_MAX_ITERATIONS
public static final int POISSON_MAX_ITERATIONS- See Also:
-
-
Constructor Details
-
PoissonDiskSubSampling
Constructor for the maximum number of samples. The density (minimal distance between samples) is approximated so that the mean absolut percentage error (MAPE) of this approximation is ~ 5.27%, and the median absolute percentage error (MDAPE) is ~ 4.52%.- Parameters:
max
- Required number of samples. Must be bigger than zerosmoothing
- Surface samples can be equipped by interpolated normal and or adapted position to interpolate surface curvature. UseSmoothing.NONE
to simply get samples from triangle planes without normal vectors.- Throws:
IllegalArgumentException
- if the input parameter is wrong
-
PoissonDiskSubSampling
Constructor for required sample density. *- Parameters:
minimalDistance
- Minimal distance (i.e., the density of samples). Must be bigger than zerosmoothing
- Surface samples can be equipped by interpolated normal and or adapted position to interpolate surface curvature. UseSmoothing.NONE
to simply get samples from triangle planes without normal vectors.- Throws:
IllegalArgumentException
- if the input parameters are wrong
-
-
Method Details
-
setRequiredSamples
public void setRequiredSamples(int max) Description copied from interface:PointSamplingVisitor
Changes the number of required samples.- Specified by:
setRequiredSamples
in interfacePointSamplingVisitor
- Overrides:
setRequiredSamples
in classPointSamplingVisitorImpl
- Parameters:
max
- Maximal number of vertices. Must be bigger than zero
-
distanceToNumSamples
public static int distanceToNumSamples(double minimalDistance) Estimates minimal distance from the given number of samples.- Parameters:
minimalDistance
- Minimal distance- Returns:
- Approximate number of samples
-
isBackedByOrigMesh
public boolean isBackedByOrigMesh()Description copied from interface:PointSamplingVisitor
Iftrue
, then the returned points samples are points from the original mesh. Therefore, the transformation of the original mesh also transform these samples. Iffalse
, then new points are returned that are independent on the original mesh.- Specified by:
isBackedByOrigMesh
in interfacePointSamplingVisitor
- Specified by:
isBackedByOrigMesh
in classPointSamplingVisitorImpl
- Returns:
true
if the point samples include points of the original mesh
-
visitMeshFacet
Description copied from interface:MeshVisitor
The inspection method to be implemented by specific visitors.- Specified by:
visitMeshFacet
in interfaceMeshVisitor
- Specified by:
visitMeshFacet
in interfacePointSamplingVisitor
- Specified by:
visitMeshFacet
in classPointSamplingVisitorImpl
- Parameters:
facet
- Mesh facet to be visited.
-
getSamples
Description copied from interface:PointSamplingVisitor
Returns a list of vertices reduced according to the strategy. The returned mesh points are backed by original points.- Specified by:
getSamples
in interfacePointSamplingVisitor
- Specified by:
getSamples
in classPointSamplingVisitorImpl
- Returns:
- selected vertices of inspected meshes
-
toString
- Overrides:
toString
in classPointSamplingVisitorImpl
-
addSamplesToKdTree
Adds samples to the KdTree- Parameters:
samples
- samples to addkdTree
- tree to which samples are added
-
filterRaysIntersections
Filters intersections not breaking minimal distance rule.- Parameters:
kdTree
- tree with samplesintersections
- sample candidates- Returns:
- (valid) sample candidates
-
rotateProjectorPlane
protected void rotateProjectorPlane(List<javax.vecmath.Point3d> projector, javax.vecmath.Point3d centroid, double thetaX, double thetaY) Rotates projector plane around mesh centroid in x,y-axis by given angles.- Parameters:
projector
- samples in projector planecentroid
- mesh centroidthetaX
- angle to rotate around x-axisthetaY
- angle to rotate around y-axis
-
createProjectorFromGrid
protected List<javax.vecmath.Point3d> createProjectorFromGrid(javax.vecmath.Point2d[][] grid, javax.vecmath.Point3d meshCentroid, double projectorSize, double radius) Creates projector plane (parallel to XY plane) from grid .- Parameters:
grid
- grid with poisson samplesradius
- radius of bounding sphere- Returns:
- projector plane samples, first point is plane centroid not a poisson sample
-
generatePoissonSamples
protected javax.vecmath.Point2d[][] generatePoissonSamples(double minPlaneSize) Generate 2D Poisson-disk sample gird- Parameters:
minPlaneSize
- minimal side length of sampled plane- Returns:
- gird with generated points
-