edu.stanford.rsl.konrad.geometry.splines
Class SurfaceBSpline

java.lang.Object
  extended by edu.stanford.rsl.konrad.geometry.AbstractShape
      extended by edu.stanford.rsl.konrad.geometry.AbstractSurface
          extended by edu.stanford.rsl.konrad.geometry.splines.SurfaceBSpline
All Implemented Interfaces:
Transformable, java.io.Serializable

public class SurfaceBSpline
extends AbstractSurface

Class to model a surface made of BSplines.

Author:
akmaier
See Also:
Serialized Form

Field Summary
static int TESSELATE_COMPOUND_OF_COMPOUND_SHAPES
           
static int TESSELATE_COMPOUND_OF_OCTREES
           
static int TESSELATE_COMPOUND_SHAPE
           
static int TESSELATE_LINEAR_OCTREE
           
static int TESSELATE_NESTED_OCTREE
           
 
Constructor Summary
SurfaceBSpline(java.util.ArrayList<PointND> list, double[] uKnots, double[] vKnots)
          Constructor for a surface BSpline.
SurfaceBSpline(java.util.ArrayList<PointND> controlPoints, SimpleVector uKnots, SimpleVector vKnots)
          Constructor for a surface BSpline.
SurfaceBSpline(java.lang.String title, java.util.ArrayList<PointND> list, double[] uKnots, double[] vKnots)
          Constructor for a surface BSpline.
 
Method Summary
 void applyTransform(Transform t)
          Applies the Transform t to the object.
 double[] computeInitialUV(PointND point)
          Computes approximate u, v coordinates to of the closest control point to the given point.
 PointND evaluate(double u, double v)
          Returns a point on the surface at position (u, v).
 java.util.ArrayList<PointND> getControlPoints()
           
 int getDimension()
          Returns the external dimension of the shape.
 PointND[] getRasterPoints(int number)
          Rasters the shape with a given number of points or less.
 java.lang.String getTitle()
           
 SimpleVector getUKnots()
           
 SimpleVector getVKnots()
           
 java.util.ArrayList<PointND> intersect(AbstractCurve other)
          Returns the intersection points between the curve and the shape.
 PointND[] intersectDeCasteljau(StraightLine line)
           
 boolean isBounded()
          Returns true if the shape is of limited space
static SurfaceBSpline readBSpline(java.io.BufferedReader reader)
          Reads a BSpline from a BufferedReader and returns it.
static java.util.ArrayList<SurfaceBSpline> readSplinesFromFile(java.lang.String filename)
           
 void setTitle(java.lang.String title)
           
 AbstractShape tesselateMesh(double samplingU, double samplingV, int mode)
          Tesselates the BSplineSurface into a mesh of Triangles.
 AbstractShape tessellateMesh(double samplingU, double samplingV)
          Tesselates the BSplineSurface into a mesh of Triangles.
 
Methods inherited from class edu.stanford.rsl.konrad.geometry.AbstractSurface
evaluate, getInternalDimension
 
Methods inherited from class edu.stanford.rsl.konrad.geometry.AbstractShape
getHitsOnBoundingBox_slow, getHitsOnBoundingBox, getMax, getMin
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TESSELATE_COMPOUND_SHAPE

public static final int TESSELATE_COMPOUND_SHAPE
See Also:
Constant Field Values

TESSELATE_COMPOUND_OF_COMPOUND_SHAPES

public static final int TESSELATE_COMPOUND_OF_COMPOUND_SHAPES
See Also:
Constant Field Values

TESSELATE_COMPOUND_OF_OCTREES

public static final int TESSELATE_COMPOUND_OF_OCTREES
See Also:
Constant Field Values

TESSELATE_LINEAR_OCTREE

public static final int TESSELATE_LINEAR_OCTREE
See Also:
Constant Field Values

TESSELATE_NESTED_OCTREE

public static final int TESSELATE_NESTED_OCTREE
See Also:
Constant Field Values
Constructor Detail

SurfaceBSpline

public SurfaceBSpline(java.util.ArrayList<PointND> controlPoints,
                      SimpleVector uKnots,
                      SimpleVector vKnots)
Constructor for a surface BSpline.

Parameters:
controlPoints - the control points
uKnots - the knot vector in u direction
vKnots - the knot vector in v direction

SurfaceBSpline

public SurfaceBSpline(java.util.ArrayList<PointND> list,
                      double[] uKnots,
                      double[] vKnots)
Constructor for a surface BSpline.

Parameters:
list - the control points
uKnots - the knot vector in u direction
vKnots - the knot vector in v direction

SurfaceBSpline

public SurfaceBSpline(java.lang.String title,
                      java.util.ArrayList<PointND> list,
                      double[] uKnots,
                      double[] vKnots)
Constructor for a surface BSpline.

Parameters:
title - the title of the BSpline
list - the control points
uKnots - the knot vector in u direction
vKnots - the knot vector in v direction
Method Detail

getControlPoints

public java.util.ArrayList<PointND> getControlPoints()

getUKnots

public SimpleVector getUKnots()

getVKnots

public SimpleVector getVKnots()

getTitle

public java.lang.String getTitle()
Returns:
the title

setTitle

public void setTitle(java.lang.String title)
Parameters:
title - the title to set

evaluate

public PointND evaluate(double u,
                        double v)
Description copied from class: AbstractSurface
Returns a point on the surface at position (u, v). u, v in [0, 1];

Specified by:
evaluate in class AbstractSurface
Parameters:
u - the internal position in u dimension
v - the internal position in v dimension
Returns:
the surface point

getDimension

public int getDimension()
Description copied from class: AbstractShape
Returns the external dimension of the shape.

Specified by:
getDimension in class AbstractShape
Returns:
the dimension

readBSpline

public static SurfaceBSpline readBSpline(java.io.BufferedReader reader)
                                  throws java.io.IOException
Reads a BSpline from a BufferedReader and returns it.

Parameters:
reader - the reader
Returns:
the surface BSpline
Throws:
java.io.IOException

readSplinesFromFile

public static java.util.ArrayList<SurfaceBSpline> readSplinesFromFile(java.lang.String filename)
                                                               throws java.io.IOException
Throws:
java.io.IOException

computeInitialUV

public double[] computeInitialUV(PointND point)
Computes approximate u, v coordinates to of the closest control point to the given point.

Parameters:
point - the point
Returns:
the approximate (u, v) coordinates of the control point.

intersect

public java.util.ArrayList<PointND> intersect(AbstractCurve other)
Description copied from class: AbstractShape
Returns the intersection points between the curve and the shape. Returns null, if the intersection is empty.

Specified by:
intersect in class AbstractShape
Returns:
the intersection points.

intersectDeCasteljau

public PointND[] intersectDeCasteljau(StraightLine line)

tessellateMesh

public AbstractShape tessellateMesh(double samplingU,
                                    double samplingV)
Tesselates the BSplineSurface into a mesh of Triangles. The parameters samplingU and samplingV define the number of points in each of the internal dimensions. Based on these points a triangle surface mesh is build. The resulting triangles are stored in a CompoundShape for each neighboring point pair in u direction. The u-triangle rings are then put into another CompoundShape. This configuration was optimal when ray tracing in x direction using XCAT BSplines.

Parameters:
samplingU - number of points in u direction
samplingV - number of points in v direction
Returns:
the tesselated mesh

tesselateMesh

public AbstractShape tesselateMesh(double samplingU,
                                   double samplingV,
                                   int mode)
Tesselates the BSplineSurface into a mesh of Triangles. The parameters samplingU and samplingV define the number of points in each of the internal dimensions. Based on these points a triangle surface mesh is build. The resulting triangles are stored in a CompoundShape for each neighboring point pair in u direction. The mode determines the internal structure of the tesselated mesh.

Parameters:
samplingU - number of points in u direction
samplingV - number of points in v direction
mode - the internal representation of the mesh. Possible modes are
  • TESSELATE_COMPOUND_SHAPE
  • TESSELATE_COMPOUND_OF_COMPOUND_SHAPES (default)
  • TESSELATE_COMPOUND_OF_OCTREES
  • TESSELATE_LINEAR_OCTREE
  • TESSELATE_NESTED_OCTREE
  • Returns:
    the tesselated mesh

    applyTransform

    public void applyTransform(Transform t)
    Description copied from interface: Transformable
    Applies the Transform t to the object.

    Specified by:
    applyTransform in interface Transformable
    Specified by:
    applyTransform in class AbstractShape
    Parameters:
    t - the transform to apply to the object.

    isBounded

    public boolean isBounded()
    Description copied from class: AbstractShape
    Returns true if the shape is of limited space

    Specified by:
    isBounded in class AbstractShape
    Returns:
    Boundedness of this shape.

    getRasterPoints

    public PointND[] getRasterPoints(int number)
    Description copied from class: AbstractShape
    Rasters the shape with a given number of points or less. If the shape is not bounded null is returned.

    Specified by:
    getRasterPoints in class AbstractShape
    Parameters:
    number - the number of points
    Returns:
    the raster points