Class ClosestSurfacePointsImpl

java.lang.Object
cz.fidentis.analyst.engines.point2surface.impl.ClosestSurfacePointsImpl
All Implemented Interfaces:
KdTreeVisitor, PointToSurfaceDistanceVisitor

public class ClosestSurfacePointsImpl extends Object implements KdTreeVisitor, PointToSurfaceDistanceVisitor
This visitor finds the minimal distance between a given 3D point and triangular meshes The minimal distance is computed between the 3D point and triangles of the mesh facets, i.e., the closest point at the triangle surface is found. This method is only a bit slower than the computation of the distance to mesh vertices, but more precise.

Attention: This visitor suppose that the k-d trees store mesh vertices (not triangle centroids).

Use with caution! This visitor finds the closest mesh vertex first and then explores triangles around the vertex to find the closest triangle. It is more optimal than computing the distance to all triangles, but it works only for rather flat surfaces. It is okay for models of human faces where the "wrinkly" parts are considered noise and we aim to remove them from further processing anyway.

  • Constructor Details

    • ClosestSurfacePointsImpl

      public ClosestSurfacePointsImpl(javax.vecmath.Point3d point, boolean checkOverlay)
      Constructor.
      Parameters:
      point - A 3D point from which distance is computed. Must not be null
      checkOverlay - If true and the closest point to the given 3D reference point lies on the boundary of the mesh stored in the k-d tree, then the reference point is considered "outside" of the mesh and the distance is set to infinity.
      Throws:
      IllegalArgumentException - if some parameter is wrong
  • Method Details

    • getNearestPoints

      public Map<MeshFacet,List<MeshPoint>> getNearestPoints()
      Description copied from interface: PointToSurfaceDistanceVisitor
      Returns the closest mesh facets and their closest points. As there can be more point in the same (smallest) distance, the method returns a list instead of a single point. Similarly, as the closest point(s) can belong to multiple facets, a map of facet is returned instead of a single facet.
      Specified by:
      getNearestPoints in interface PointToSurfaceDistanceVisitor
      Returns:
      closest mesh facets and their closest points.
    • getDistance

      public double getDistance()
      Description copied from interface: PointToSurfaceDistanceVisitor
      Returns the minimal found distance between a 3D point (set in a constructor) and visited mesh facets.
      Specified by:
      getDistance in interface PointToSurfaceDistanceVisitor
      Returns:
      the minimal found distance, Double.POSITIVE_INFINITY if no distance has been computed so far
    • visitKdTree

      public void visitKdTree(KdTree kdTree)
      Description copied from interface: KdTreeVisitor
      The main inspection method to be implemented by specific visitors.
      Specified by:
      visitKdTree in interface KdTreeVisitor
      Parameters:
      kdTree - K-d tree to be visited