public abstract class NURBSCurveBase extends NURBSObject
Modifier and Type | Field and Description |
---|---|
static int |
CLOSED
Specifies a closed curve.
|
static boolean |
init |
static int |
OPEN
Specifies an open curve.
|
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
NURBSCurveBase() |
Modifier and Type | Method and Description |
---|---|
void |
addControlPoint(Vector4d pnt,
double h)
Add an additional control point and knot to the end of this curve.
|
double |
computeControlPolygonLength() |
void |
convertToBezier() |
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object.
|
static double[] |
createUniformKnots(int numi,
int d,
boolean open)
Creates an array of evenly spaced knots.
|
abstract void |
eval(Point3d pnt,
double u)
Evaluates the point on this curve for parameter u.
|
int |
getDegree()
Returns the degree of this curve.
|
double |
getKnot(int i)
Returns the i-th knot used by this curve.
|
int |
getKnotIndex(double u)
Gets the lower knot point index for the knot interval which contains the
parameter value u.
|
double[] |
getKnots()
Returns the knots used by this curve.
|
void |
getRange(double[] uStartEnd)
Gets the range of the curve parameter u.
|
int |
getResolution()
Returns the resolution used for rendering this curve.
|
int |
getType() |
void |
insertKnot(int k,
double uval) |
boolean |
isBezier()
Returns true if this curve represents a piecewise bezier
curve.
|
boolean |
isBSpline()
Returns true if this curve represents a B-spline (i.e.,
if all control points have unity weights).
|
boolean |
isClosed()
Returns true if this curve is closed.
|
int |
numKnots()
Returns the number of knots used by this curve.
|
void |
read(java.io.Reader reader)
Reads this curve from a text description supplied by a reader.
|
void |
read(ReaderTokenizer rtok)
Reads this curve in from a ReaderTokenizer, using the same format as
read(Reader) . |
void |
removeControlPoint()
Remove the control point at the end of this curve.
|
void |
render(Renderer renderer,
RenderProps props,
int flags) |
void |
reset(int d,
int type,
double[] knots)
Resets the degrees, type, and knots of this curve.
|
void |
set(int d,
int type,
Vector4d[] ctrlPnts,
double[] knots)
Sets this NURBS curve to either an open or closed curve with a specified
degree, knots, and control points.
|
void |
set(int d,
Vector4d[] ctrlPnts,
double[] knots)
Sets this NURBS curve to an open curve with a specified degree, knot
points, and control points.
|
void |
set(WavefrontReader.Curve curve,
Vector4d[] allPnts) |
void |
setBezier(int d,
Vector4d[] ctrlPnts)
Sets this curve to a piecewise Bezier curve with a prescribed degree and
set of control points.
|
void |
setCircle(double x,
double y,
double radius)
Sets this curve to an eight-point circle formed using rational cubics.
|
void |
setRange(double ustart,
double uend)
Sets the range of the curve parameter u.
|
void |
setResolution(int res)
Sets the resolution used for rendering this curve.
|
void |
setUniformCubic(int type,
Vector4d[] ctrlPnts)
Sets this NURBS curve to a curve of third degree with uniform
unity knot spacing and a specified number of control points.
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
boolean relative) |
void |
write(java.io.PrintWriter pw,
java.lang.String fmtStr,
boolean relative)
Writes a text description of this NURBS object to a PrintWriter, using a
subset of the Wavefront OBJ format as described in the documentation
for the
read method for this object. |
controlPointIsSelected, getControlPoint, getControlPoints, getDrawControlShape, getLineWidth, getObjToWorld, getObjToWorld, getPointSize, getRenderHints, getRenderProps, getSelection, isSelectable, numControlPoints, numSelectionQueriesNeeded, prerender, render, selectControlPoint, setDrawControlShape, setLineWidth, setObjToWorld, setPointSize, setRenderProps, transform, updateBounds, write, write
public static final int OPEN
public static final int CLOSED
public static boolean init
public boolean isClosed()
public int getType()
public void setResolution(int res)
res
- rendering resolutiongetResolution()
public abstract void eval(Point3d pnt, double u)
pnt
- returns the curve point valueu
- curve parameter valuepublic int getResolution()
setResolution(int)
public void setRange(double ustart, double uend)
ustart
- minimum curve parameteruend
- maximum curve parametergetRange(double[])
public void getRange(double[] uStartEnd)
uStartEnd
- returns the ustart and uend values, in elements 0 and 1, respectively.setRange(double, double)
public static double[] createUniformKnots(int numi, int d, boolean open)
numi
- number of active intervalsd
- degree of the curveopen
- true if the curve is open and false if it is closedjava.lang.IllegalArgumentException
- if constraints on the arguments are violatedpublic void set(int d, Vector4d[] ctrlPnts, double[] knots)
set
.d
- degree of the curvectrlPnts
- control pointsknots
- knot values * @throws IllegalArgumentException
if constraints on the arguments are violatedset(int,int,Vector4d[],double[])
public void setUniformCubic(int type, Vector4d[] ctrlPnts)
public boolean isBSpline()
public boolean isBezier()
public void convertToBezier()
public void insertKnot(int k, double uval)
public void addControlPoint(Vector4d pnt, double h)
h
. If this is specified as -1,
then the default uniform knot spacing (typically 1) is used.public void removeControlPoint()
public void set(int d, int type, Vector4d[] ctrlPnts, double[] knots)
Let d, numk, and numc be the degree of the curve, the number of knots, and the number of control points. The degree must be 1 or greater. For open curves,
numc = numk - d + 1and for closed curves,
numc = numk - 2*d + 1
The knots argument may be set to null, in which case an appropriate number of uniformly spaced knots will be created, in the range [0, 1]. Otherwise, if knots is specified, the ctrlPnts argument must contain at least numc elements.
This method automatically sets ustart and uend (see
setRange
) to knots[d-1] and knots[numk-d].
The control points are specified as 4-vectors, where their spatial location is given by x, y, and z and their weight is given by w. The points should not be in homogeneous form; i.e., x, y, and z should not be premultipled by w.
public void reset(int d, int type, double[] knots)
knots
is null, then appropriate uniform knots are
computed for the curve type.public void setBezier(int d, Vector4d[] ctrlPnts)
d
- degree for the curvectrlPnts
- control pointsjava.lang.IllegalArgumentException
- if constraints on the arguments are violatedpublic void setCircle(double x, double y, double radius)
x
- center x coordinatey
- center y coordinateradius
- circle radiusjava.lang.IllegalArgumentException
- if radius is non-positivepublic int getKnotIndex(double u)
u
- curve parameter valuepublic double computeControlPolygonLength()
public void render(Renderer renderer, RenderProps props, int flags)
render
in class NURBSObject
public int getDegree()
public int numKnots()
public double getKnot(int i)
public double[] getKnots()
public void read(java.io.Reader reader) throws java.io.IOException
\
).
The allowed statements are:
v x y z [w]each giving the x, y, and z values for a control point (with an optional weighting value w which defaults to 1 if omitted).
deg dwhere d is the degree of the curve. A degree statement must precede a curve statement (described below).
curv ustart uend i0 i1 ...where ustart and uend give the minimum and maximum values for the curve parameter u, and i0, i1, etc. give the indices of the control points defined by the vertex statements. Control points are indexed, starting at 1, by their order of occurance. If the index value is negative, then it gives the relative location of a control point relative to the curve statement, where -1 is the closest preceding, -2 is the next closest preceding, etc.
parm u [closed] k0 k1 ...where
closed
is an optional
keyword indicating that the curve is closed, and k0, k1, etc. are the knot
values for the curve. The parameter statement must follow the curve
statement and precede the end statement (described below). If a curve has
degree d and numc control points, then it number of knots numk must be
given by numk = numc + 2*d - 1if the curve is closed and by
numk = numc + d - 1if the curve is open. If no knots are specified, then an appropriate number of uniformly-spaced knots is created with ustart and uend corresponding to 0 and 1.
endThis must be placed after the curve and parameter statements.
As an example, here are the statements that define an eight point NURBS circle:
v 1 0 0 1 v 1 1 0 0.35355339059327 v 0 1 0 1 v -1 1 0 0.35355339059327 v -1 0 0 1 v -1 -1 0 0.35355339059327 v 0 -1 0 1 v 1 -1 0 0.35355339059327 deg 3 curv 0 1 1 2 3 4 5 6 7 8 parm u closed end
reader
- providing the text inputjava.io.IOException
- if an I/O or format error occurspublic void read(ReaderTokenizer rtok) throws java.io.IOException
read(Reader)
.rtok
- tokenizer which provides the inputjava.io.IOException
- if an I/O or format error occurspublic void set(WavefrontReader.Curve curve, Vector4d[] allPnts)
public void write(java.io.PrintWriter pw, NumberFormat fmt, boolean relative) throws java.io.IOException
java.io.IOException
public void write(java.io.PrintWriter pw, java.lang.String fmtStr, boolean relative) throws java.io.IOException
read
method for this object.write
in class NURBSObject
pw
- PrintWriter for outputing the text descriptionfmtStr
- printf-style format string for formatting the floating point values (e.g.,
"%g", "%10.3f").relative
- if true, then control point indices are written as negative values giving
their location relative to the curv
statement.java.io.IOException
- if an I/O error occurspublic RenderProps createRenderProps()