Class RayIntersectionVisitorImpl
java.lang.Object
cz.fidentis.analyst.engines.raycasting.impl.RayIntersectionVisitorImpl
- All Implemented Interfaces:
OctreeVisitor
,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 Summary
ConstructorsConstructorDescriptionRayIntersectionVisitorImpl
(Ray ray, MeshTriangle.Smoothing smoothing) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetClosestIntersection
(boolean filter) Returns a closets intersection point, either positive or negative, ornull
.protected int
getFistSubNode
(javax.vecmath.Point3d t0, javax.vecmath.Point3d tm) Thefirst_node
method from [1] implementing Tables 1 and 2.protected javax.vecmath.Point3d
getNextCellPoint
(javax.vecmath.Point3d t0, javax.vecmath.Point3d t1, OctNode node) Computest_m
from [1].protected List
<javax.vecmath.Point3d> Computes initial values oft0
andt1
from [1].getSortedIntersections
(boolean filter) Returns found ray intersections sorted by distances.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.getUnsortedIntersections
(boolean filter) Returns ray intersections in random order and without distances.protected int
nextSubNode
(double tx1, int yzExitPlane, double ty1, int xzExitPlane, double tz1, int xyExitPlane) Thenew_node
method from [1] implementing Table 3.protected void
processSubTree
(OctNode node, javax.vecmath.Point3d t0, javax.vecmath.Point3d t1, int subNodeMask) The main traversal algorithms from [1].protected double
sumCoord
(double t0, double t1, double o0, double o1, double p) Equation 12 from [1].protected void
traverseOctree
(Octree octree, Ray ray) Traverse an octree and finds candidate triangles that might be intersected by the ray.void
visitOctree
(Octree octree) The main inspection method to be implemented by specific visitors.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cz.fidentis.analyst.data.octree.OctreeVisitor
isThreadSafe
-
Constructor Details
-
RayIntersectionVisitorImpl
Constructor.- Parameters:
ray
- Ray, must not benull
smoothing
- Smoothing strategy- Throws:
IllegalArgumentException
- if theray
isnull
-
-
Method Details
-
visitOctree
Description copied from interface:OctreeVisitor
The main inspection method to be implemented by specific visitors.- Specified by:
visitOctree
in interfaceOctreeVisitor
- Parameters:
octree
- octree to be visited
-
getUnsortedIntersections
Description copied from interface:RayIntersectionVisitor
Returns ray intersections in random order and without distances.- Specified by:
getUnsortedIntersections
in interfaceRayIntersectionVisitor
- Parameters:
filter
- Iftrue
, then only triangles with the same orientation are taken into account- Returns:
- ray intersections without distances.
-
getSortedIntersections
Description copied from interface:RayIntersectionVisitor
Returns found ray intersections sorted by distances.- Specified by:
getSortedIntersections
in interfaceRayIntersectionVisitor
- Parameters:
filter
- Iftrue
, then only triangles with the same orientation are taken into account- Returns:
- found ray intersections ordered by distances.
-
getClosestIntersection
Description copied from interface:RayIntersectionVisitor
Returns a closets intersection point, either positive or negative, ornull
.- Specified by:
getClosestIntersection
in interfaceRayIntersectionVisitor
- Parameters:
filter
- Iftrue
, then only triangles with the same orientation are taken into account- Returns:
- a closets intersection point, either positive or negative, or
null
.
-
traverseOctree
Traverse an octree and finds candidate triangles that might be intersected by the ray.- Parameters:
octree
- An octreeray
- A ray. It must start outside the root node of the octree!
-
getSubNodeMask
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
Computes initial values oft0
andt1
from [1].- Parameters:
root
- Root node of the octreeray
- ray- Returns:
t0
andt1
-
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) Computest_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) Thefirst_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) Thenew_node
method from [1] implementing Table 3. It returns the index of the next sub-node intersected by a ray.
-