Module vecmath

Class IntersectionList

java.lang.Object
de.grogra.vecmath.geom.Variables
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 Details

    • size

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

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

    • IntersectionList

      public IntersectionList()
  • Method Details

    • 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
    • clear

      public void clear()
      Clears this list so that the size is 0.
    • 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
    • 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)
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object