Class MeshDistanceNN

java.lang.Object
cz.fidentis.analyst.engines.distance.impl.MeshDistanceVisitorImpl
cz.fidentis.analyst.engines.distance.impl.MeshDistanceNN
All Implemented Interfaces:
MeshVisitor, MeshDistanceVisitor, Serializable

public class MeshDistanceNN extends MeshDistanceVisitorImpl
This visitor searches for the closest points of the primary mesh (provided to the constructor) and inspected meshes using nearest neighbor (NN) search , then provides these closest points, their distances, etc. This class can be used for Hausdorff distance computation, for instance:
 MeshDistanceNN dA = new MeshDistanceNN(faceA);
 MeshDistanceNN dB = new MeshDistanceNN(faceB);
 dA.visitMeshFacet(faceB);
 dB.visitMeshFacet(faceA);
 double hausdorffDist = Math.max(dA.getStats.getMax(), dB.getStats.getMax());
 

This visitor is instantiated with a single k-d tree (either given as the input parameter, or automatically created from the triangular mesh). When applied to other mesh facets, it finds points from the k-d tree that are the closest to each point of the inspected mesh.

This visitor is thread-safe, i.e., a single instance of the visitor can be used to inspect multiple meshes simultaneously.

The distance is computed either as absolute or relative. Absolute represents Euclidean distance (all numbers are positive). On the contrary, relative distance considers orientation of the visited mesh (determined by its normal vectors) and produces positive or negative distances depending on whether the primary mesh is "in front of" or "behind" the given vertex.

See Also:
  • Constructor Details

    • MeshDistanceNN

      public MeshDistanceNN(KdTree mainKdTree, boolean pointToPoint, boolean relativeDistance, boolean parallel, boolean crop)
      Constructor.
      Parameters:
      mainKdTree - The KD tree to which distance from the visited facets is to be computed. Must not be null
      pointToPoint - If true, then point-to-point distance measurement is used. Otherwise, point-to-triangle is used
      relativeDistance - If true, then the visitor calculates the relative distances with respect to the normal vectors of source facets (normal vectors have to present), i.e., we can get negative distances.
      parallel - If true, then the algorithm runs concurrently utilizing all CPU cores
      crop - If true, then only parts of the visited secondary faces that overlay the primary face are taken into account. Parts (vertices) that are out of the surface of the primary face are ignored (their distance is set to NaN). This feature makes the distance computation more symmetric.
      Throws:
      IllegalArgumentException - if some parameter is wrong
  • Method Details

    • setCrop

      public void setCrop(boolean crop)
      Enables to change auto-cropping feature at runtime
      Parameters:
      crop - If true, then only parts of the visited secondary faces that overlay the primary face are taken into account. Parts (vertices) that are out of the surface of the primary face are ignored (their distance is set to NaN). This feature makes the distance computation more symmetric.
    • getMainKdTree

      public KdTree getMainKdTree()
      Return the KD tree to which distances are computed.
      Returns:
      KD tree to which distances are computed
    • visitMeshFacet

      public void visitMeshFacet(MeshFacet comparedFacet)
      Description copied from interface: MeshVisitor
      The inspection method to be implemented by specific visitors.
      Parameters:
      comparedFacet - Mesh facet to be visited.
    • instantiateVisitor

      protected KdTreeVisitor instantiateVisitor(javax.vecmath.Point3d inspectedPoint)
    • updateResults

      protected void updateResults(PointToSurfaceDistanceVisitor vis, MeshPoint point, List<Double> distList, List<MeshPoint> nearestPointsList)
    • getClosestMeshPoint

      protected MeshPoint getClosestMeshPoint(PointToSurfaceDistanceVisitor vis)
      Parameters:
      vis - visitor
      Returns:
      the only one existing closest vertex or null