public class NURBSSurface extends NURBSObject
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
NURBSSurface()
Creates an empty NURBS surface.
|
NURBSSurface(int du,
int typeu,
double[] knotsu,
int dv,
int typev,
double[] knotsv,
Vector4d[] ctrlPnts)
Creates a NURBS surface using degree and knot values in the u and v
directions, along with control points.
|
Modifier and Type | Method and Description |
---|---|
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object.
|
void |
eval(Point3d pnt,
double u,
double v)
Evaluates the point on this surface corresponding to u and v.
|
int |
getDegreeU()
Returns the degree of this surface in the u direction.
|
int |
getDegreeV()
Returns the degree of this surface in the v direction.
|
double[] |
getKnotsU()
Returns the knots in the u direction.
|
double[] |
getKnotsV()
Returns the knots in the v direction.
|
void |
getRangeU(double[] uStartEnd)
Gets the range of the u parameter.
|
void |
getRangeV(double[] vStartEnd)
Gets the range of the v parameter.
|
int |
getResolutionU()
Returns the resolution used for rendering this surface along the u
parameter.
|
int |
getResolutionV()
Returns the resolution used for rendering this surface along the v
parameter.
|
NURBSCurve3d |
getVCurve()
Returns the NURBS curve controlling this surface in the v direction.
|
int |
numKnotsU()
Returns the number of knots in the u direction.
|
int |
numKnotsV()
Returns the number of knots in the v direction.
|
void |
read(java.io.Reader reader)
Reads this surface from a text description supplied by a reader.
|
void |
render(Renderer renderer,
RenderProps props,
int flags) |
void |
set(int du,
double[] knotsu,
int dv,
double[] knotsv,
Vector4d[] ctrlPnts)
Sets this NURBS surface using degree and knot values in the u and v
directions, along with control points.
|
void |
set(int du,
int typeu,
double[] knotsu,
int dv,
int typev,
double[] knotsv,
Vector4d[] ctrlPnts)
Sets this NURBS surface using degree and knot values in the u and v
directions, along with control points.
|
void |
set(WavefrontReader.Surface surface,
Vector4d[] allPnts) |
void |
setRangeU(double ustart,
double uend)
Sets the range of the u parameter.
|
void |
setRangeV(double vstart,
double vend)
Sets the range of the v parameter.
|
void |
setResolutionU(int res)
Sets the resolution used for rendering this surface along the u parameter.
|
void |
setResolutionV(int res)
Sets the resolution used for rendering this surface along the v parameter.
|
void |
setSphere(double x,
double y,
double z,
double radius)
Sets this surface to a 40-point sphere formed by sweeping a 5-point
rational quadratic semi-circle about the z axis.
|
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 NURBSSurface()
public NURBSSurface(int du, int typeu, double[] knotsu, int dv, int typev, double[] knotsv, Vector4d[] ctrlPnts)
set
.du
- degree in the u directiontypeu
- u direction type, which must be either OPEN
or
CLOSED
.knotsu
- knot values for the u directiondv
- degree in the v directiontypev
- v direction type, which must be either OPEN
or
CLOSED
.knotsv
- knot values for the v directionctrlPnts
- control pointsjava.lang.IllegalArgumentException
- if constraints on the arguments are violatedset(int,int,double[],int,int,double[],Vector4d[])
public void setResolutionU(int res)
res
- rendering resolution for ugetResolutionU()
public int getResolutionU()
setResolutionU(int)
public void setResolutionV(int res)
res
- rendering resolution for vgetResolutionV()
public int getResolutionV()
setResolutionV(int)
public void setRangeU(double ustart, double uend)
ustart
- minimum u parameteruend
- maximum u parametergetRangeU(double[])
public void getRangeU(double[] uStartEnd)
uStartEnd
- returns the ustart and uend values, in elements 0 and 1, respectively.setRangeU(double, double)
public void setRangeV(double vstart, double vend)
vstart
- minimum v parametervend
- maximum v parametergetRangeV(double[])
public void getRangeV(double[] vStartEnd)
vStartEnd
- returns the vstart and vend values, in elements 0 and 1, respectively.setRangeV(double, double)
public void set(int du, double[] knotsu, int dv, double[] knotsv, Vector4d[] ctrlPnts)
set
.du
- degree in the u directionknotsu
- knot values for the u directiondv
- degree in the v directionknotsv
- knot values for the v directionctrlPnts
- control pointsjava.lang.IllegalArgumentException
- if constraints on the arguments are violatedset(int,int,double[],int,int,double[],Vector4d[])
public void set(int du, int typeu, double[] knotsu, int dv, int typev, double[] knotsv, Vector4d[] ctrlPnts)
Let du, numku, and numcu be the degree, number of knots, and number of control points associated with the u direction. The degree must be 1 or greater. If the u direction is open, then
numcu = numku - du + 1and if it is closed,
numcu = numku - 2*du + 1Analogous results hold for the v direction. The total number of control points is numcu*numcv, and so the ctrlPnts argument must be at least this length. Control points should be arranged so that the first set of v control points comes first, followed by the second set, etc.
This method automatically sets ustart, uend, vstart, and vend (see
setRangeU
and setRangeV
) to to
knotsu[du-1], knotsu[numku-du], knotsv[dv-1], and knotsv[numkv-dv].
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.
du
- degree in the u directiontypeu
- u direction type, which must be either OPEN
or
CLOSED
.knotsu
- knot values for the u directiondv
- degree in the v directiontypev
- v direction type, which must be either OPEN
or
CLOSED
.knotsv
- knot values for the v directionctrlPnts
- control pointsjava.lang.IllegalArgumentException
- if constraints on the arguments are violatedpublic void setSphere(double x, double y, double z, double radius)
x
- center x coordinatey
- center y coordinatez
- center z coordinateradius
- circle radiusjava.lang.IllegalArgumentException
- if radius is non-positivepublic void eval(Point3d pnt, double u, double v)
pnt
- returns the surface point valueu
- u parameter valuev
- v parameter valuepublic void render(Renderer renderer, RenderProps props, int flags)
render
in class NURBSObject
public NURBSCurve3d getVCurve()
public int getDegreeU()
public int numKnotsU()
public double[] getKnotsU()
public int getDegreeV()
public int numKnotsV()
public double[] getKnotsV()
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 du dvwhere du and dv are degree of the surface in the u and v directions. A degree statement must precede a surface statement (described below).
surf ustart uend vstart vend i0 i1 ...where ustart, uend, vstart, and vend give the minimum and maximum values for the u and v surface parameters, 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 with respect to the surface statement, where -1 is the closest preceding, -2 is the next closest preceding, etc. There should be numcu*numcv control points in all, where numcu and numcv are described in
set
, and the
points should be ordered so that the first set of v points comes first,
followed by the second set, etc.
parm u [closed] k0 k1 ...where
closed
is an
optional keyword indicating that the surface is closed in u direction, and
k0, k1, etc. are the u direction knot values. The u parameter statement
must follow the surface statement and precede the end statement (described
below).
parm v [closed] k0 k1 ...which is analogous to the u parameter statement.
endThis must be placed after the curve and parameter statements.
set
. Explicit
knot values may be omitted for either u or v, in which case an appropriate
number of uniformly-spaced knots is created with start and end values
corresponding to 0 and 1.
As an example, here are the statements that define a simple bezier surface patch:
v -10.0 0.0 10.0 1.0 v -5.0 5.0 10.0 1.0 v 5.0 5.0 10.0 1.0 v 10.0 0.0 10.0 1.0 v -10.0 0.0 5.0 1.0 v -5.0 5.0 5.0 1.0 v 5.0 5.0 5.0 1.0 v 10.0 0.0 5.0 1.0 v -10.0 0.0 -5.0 1.0 v -5.0 5.0 -5.0 1.0 v 5.0 5.0 -5.0 1.0 v 10.0 0.0 -5.0 1.0 v -10.0 0.0 -10.0 1.0 v -5.0 5.0 -10.0 1.0 v 5.0 5.0 -10.0 1.0 v 10.0 0.0 -10.0 1.0 deg 3 3 surf 0.0 1.0 0.0 1.0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 parm u 0.0 0.0 0.0 1.0 1.0 1.0 parm v 0.0 0.0 0.0 1.0 1.0 1.0 end
reader
- providing the text inputjava.io.IOException
- if an I/O or format error occurspublic void set(WavefrontReader.Surface surface, Vector4d[] allPnts)
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()