Class RayIntersectionVisitorImpl

java.lang.Object
cz.fidentis.analyst.engines.raycasting.impl.RayIntersectionVisitorImpl
All Implemented Interfaces:
OctreeVisitor, RayIntersectionVisitor

public class RayIntersectionVisitorImpl extends Object implements RayIntersectionVisitor
This visitor throws a ray from origin point and finds all intersections of the ray with facets.

The implementation is based on
[1] Revelles, Jorge, Carlos Urena, and Miguel Lastra. "An efficient parametric algorithm for octree traversal." (2000)..

  • Constructor Details

    • RayIntersectionVisitorImpl

      public RayIntersectionVisitorImpl(Ray ray, MeshTriangle.Smoothing smoothing)
      Constructor.
      Parameters:
      ray - Ray, must not be null
      smoothing - Smoothing strategy
      Throws:
      IllegalArgumentException - if the ray is null
  • Method Details

    • visitOctree

      public void visitOctree(Octree octree)
      Description copied from interface: OctreeVisitor
      The main inspection method to be implemented by specific visitors.
      Specified by:
      visitOctree in interface OctreeVisitor
      Parameters:
      octree - octree to be visited
    • getUnsortedIntersections

      public List<RayIntersection> getUnsortedIntersections(boolean filter)
      Description copied from interface: RayIntersectionVisitor
      Returns ray intersections in random order and without distances.
      Specified by:
      getUnsortedIntersections in interface RayIntersectionVisitor
      Parameters:
      filter - If true, then only triangles with the same orientation are taken into account
      Returns:
      ray intersections without distances.
    • getSortedIntersections

      public SortedSet<RayIntersection> getSortedIntersections(boolean filter)
      Description copied from interface: RayIntersectionVisitor
      Returns found ray intersections sorted by distances.
      Specified by:
      getSortedIntersections in interface RayIntersectionVisitor
      Parameters:
      filter - If true, then only triangles with the same orientation are taken into account
      Returns:
      found ray intersections ordered by distances.
    • getClosestIntersection

      public RayIntersection getClosestIntersection(boolean filter)
      Description copied from interface: RayIntersectionVisitor
      Returns a closets intersection point, either positive or negative, or null.
      Specified by:
      getClosestIntersection in interface RayIntersectionVisitor
      Parameters:
      filter - If true, then only triangles with the same orientation are taken into account
      Returns:
      a closets intersection point, either positive or negative, or null.
    • traverseOctree

      protected void traverseOctree(Octree octree, Ray ray)
      Traverse an octree and finds candidate triangles that might be intersected by the ray.
      Parameters:
      octree - An octree
      ray - A ray. It must start outside the root node of the octree!
    • getSubNodeMask

      protected int getSubNodeMask(OctNode root, Ray ray)
      Flips the ray so that its coordinates are positive and sets the transformation mask of sub-node indexes accordingly. In contrast to the paper [1], this implementation is modified so that the octree can be placed anywhere in the space.
      Parameters:
      root - Root node of the octree.
      ray - Ray. It can be modified!
      Returns:
      transformation mask of sub-node indexes
    • getParams

      protected List<javax.vecmath.Point3d> getParams(OctNode root, Ray ray)
      Computes initial values of t0 and t1 from [1].
      Parameters:
      root - Root node of the octree
      ray - ray
      Returns:
      t0 and t1
    • processSubTree

      protected void processSubTree(OctNode node, javax.vecmath.Point3d t0, javax.vecmath.Point3d t1, int subNodeMask)
      The main traversal algorithms from [1].
    • getNextCellPoint

      protected javax.vecmath.Point3d getNextCellPoint(javax.vecmath.Point3d t0, javax.vecmath.Point3d t1, OctNode node)
      Computes t_m from [1].
    • sumCoord

      protected double sumCoord(double t0, double t1, double o0, double o1, double p)
      Equation 12 from [1].
    • getFistSubNode

      protected int getFistSubNode(javax.vecmath.Point3d t0, javax.vecmath.Point3d tm)
      The first_node method from [1] implementing Tables 1 and 2. It returns the first sub-node of the node intersected by a ray. In the contract to the original paper, indexes 1 and 4 have to be switched (error in the paper?)
    • nextSubNode

      protected int nextSubNode(double tx1, int yzExitPlane, double ty1, int xzExitPlane, double tz1, int xyExitPlane)
      The new_node method from [1] implementing Table 3. It returns the index of the next sub-node intersected by a ray.