de.grogra.vecmath.geom
Class IntersectionList

java.lang.Object
  extended by de.grogra.vecmath.geom.Variables
      extended by de.grogra.vecmath.geom.IntersectionList

public final class IntersectionList
extends Variables

This class contains a list of intersection points of a line with the surface of a Volume. The list is piecewise sorted in ascending order of distance, i.e., of Intersection.parameter. The congiguous pieces are computed by Volume.computeIntersections(de.grogra.vecmath.geom.Line, int, de.grogra.vecmath.geom.IntersectionList, de.grogra.vecmath.geom.Intersection, de.grogra.vecmath.geom.Intersection).

Author:
Ole Kniemeyer

Field Summary
 Intersection[] elements
          Contains the list of intersections.
 int size
          Specifies the number of valid intersections in elements.
 
Fields inherited from class de.grogra.vecmath.geom.Variables
cache, istack, tmpLine, tmpMatrix3, tmpPoint0, tmpPoint1, tmpPoint2, tmpPoint3, tmpVector0, tmpVector1, tmpVector2, tmpVector3
 
Constructor Summary
IntersectionList()
           
 
Method Summary
 Intersection add(Volume v, Line l, double p, int type)
          Appends an intersection element to this list and returns the appended instance.
 Intersection add(Volume v, Line l, double p, int type, int face)
          Appends an intersection element to this list and returns the appended instance.
 void addSwap(int index)
          Appends a new intersection element to this list and swaps it with the existing element at index.
 void clear()
          Clears this list so that the size is 0.
 int findClosestIntersection(double p, double maxDiff, int start, int end)
          Returns the index of the intersection whose parameter is closest to p.
 void remove(int start, int end)
          Removes the elements with indices from start to end - 1.
 void setSize(int size)
          Sets the size of this list to the specified value.
 java.lang.String toString()
           
 
Methods inherited from class de.grogra.vecmath.geom.Variables
getISize, ienter, ipop, ipush, setISize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elements

public Intersection[] elements
Contains the list of intersections. Only the components having indices between 0 and size - 1 are valid.


size

public int size
Specifies the number of valid intersections in elements.

Constructor Detail

IntersectionList

public IntersectionList()
Method Detail

add

public Intersection add(Volume v,
                        Line l,
                        double p,
                        int type)
Appends an intersection element to this list and returns the appended instance. The parameters are used to initialize the intersection element.

Parameters:
v - volume of intersection
l - line of intersection
p - line parameter of intersection
type - type of intersection (see Intersection.type)
Returns:
newly appended intersection instance

add

public Intersection add(Volume v,
                        Line l,
                        double p,
                        int type,
                        int face)
Appends an intersection element to this list and returns the appended instance. The parameters are used to initialize the intersection element.

Parameters:
v - volume of intersection
l - line of intersection
p - line parameter of intersection
type - type of intersection (see Intersection.type)
face - face value of intersection
Returns:
newly appended intersection instance

addSwap

public void addSwap(int index)
Appends a new intersection element to this list and swaps it with the existing element at index.

Parameters:
index - index of the element to be swapped with the new element

clear

public void clear()
Clears this list so that the size is 0.


findClosestIntersection

public int findClosestIntersection(double p,
                                   double maxDiff,
                                   int start,
                                   int end)
Returns the index of the intersection whose parameter is closest to p. Only intersection elements with indices from start to end - 1 and with a parameter value whose difference to p is less than maxDistance are considered.

Parameters:
p - a line parameter
maxDiff - maximum difference between p and intersections
start - index to start (inclusive)
end - index to end (exclusive)
Returns:
index of closest intersection, or -1

remove

public void remove(int start,
                   int end)
Removes the elements with indices from start to end - 1.

Parameters:
start - index to start (inclusive)
end - index to end (exclusive)

setSize

public void setSize(int size)
Sets the size of this list to the specified value. The first size elements will contain valid instances when this method returns.

Parameters:
size - new size of this list

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object