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

public class PoissonDiskSubSampling extends PointSamplingVisitorImpl
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.
  • Field Details

  • Constructor Details

    • PoissonDiskSubSampling

      public PoissonDiskSubSampling(int max, MeshTriangle.Smoothing smoothing)
      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 zero
      smoothing - Surface samples can be equipped by interpolated normal and or adapted position to interpolate surface curvature. Use Smoothing.NONE to simply get samples from triangle planes without normal vectors.
      Throws:
      IllegalArgumentException - if the input parameter is wrong
    • PoissonDiskSubSampling

      public PoissonDiskSubSampling(double minimalDistance, MeshTriangle.Smoothing smoothing)
      Constructor for required sample density. *
      Parameters:
      minimalDistance - Minimal distance (i.e., the density of samples). Must be bigger than zero
      smoothing - Surface samples can be equipped by interpolated normal and or adapted position to interpolate surface curvature. Use Smoothing.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 interface PointSamplingVisitor
      Overrides:
      setRequiredSamples in class PointSamplingVisitorImpl
      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
      If true, then the returned points samples are points from the original mesh. Therefore, the transformation of the original mesh also transform these samples. If false, then new points are returned that are independent on the original mesh.
      Specified by:
      isBackedByOrigMesh in interface PointSamplingVisitor
      Specified by:
      isBackedByOrigMesh in class PointSamplingVisitorImpl
      Returns:
      true if the point samples include points of the original mesh
    • visitMeshFacet

      public void visitMeshFacet(MeshFacet facet)
      Description copied from interface: MeshVisitor
      The inspection method to be implemented by specific visitors.
      Specified by:
      visitMeshFacet in interface MeshVisitor
      Specified by:
      visitMeshFacet in interface PointSamplingVisitor
      Specified by:
      visitMeshFacet in class PointSamplingVisitorImpl
      Parameters:
      facet - Mesh facet to be visited.
    • getSamples

      public List<MeshPoint> 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 interface PointSamplingVisitor
      Specified by:
      getSamples in class PointSamplingVisitorImpl
      Returns:
      selected vertices of inspected meshes
    • toString

      public String toString()
      Overrides:
      toString in class PointSamplingVisitorImpl
    • addSamplesToKdTree

      protected void addSamplesToKdTree(Set<MeshPoint> samples, KdTree kdTree)
      Adds samples to the KdTree
      Parameters:
      samples - samples to add
      kdTree - tree to which samples are added
    • filterRaysIntersections

      protected Set<MeshPoint> filterRaysIntersections(KdTree kdTree, Set<MeshPoint> intersections)
      Filters intersections not breaking minimal distance rule.
      Parameters:
      kdTree - tree with samples
      intersections - 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 plane
      centroid - mesh centroid
      thetaX - angle to rotate around x-axis
      thetaY - 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 samples
      radius - 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