maspack.geometry
Class NURBSObject

java.lang.Object
  extended by maspack.geometry.NURBSObject
All Implemented Interfaces:
GLRenderable, GLSelectable, HasRenderProps, Renderable
Direct Known Subclasses:
NURBSCurveBase, NURBSSurface

public abstract class NURBSObject
extends java.lang.Object
implements Renderable

Base class for a NURBS curve or surface.


Field Summary
 
Fields inherited from interface maspack.render.GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
 
Method Summary
 boolean controlPointIsSelected(int i)
           
 Vector4d getControlPoint(int i)
           
 Vector4d[] getControlPoints()
          Returns the control points used by this curve.
 boolean getDrawControlShape()
           
 int getLineWidth()
           
 RigidTransform3d getObjToWorld()
          Returns the 3D transform from the coordinate frame of this NURBS object to the world.
 void getObjToWorld(RigidTransform3d TOW)
          Gets the 3D transform from the coordinate frame of this NURBS object to the world.
 int getPointSize()
           
 int getRenderHints()
          Returns a bit code giving rendering hints about this renderable.
 RenderProps getRenderProps()
          Returns the render properities for this object.
 void getSelection(java.util.LinkedList<java.lang.Object> list, int qid)
          Append to list the component (or components) associated with the qid-th selection query issued by this component's render method.
 boolean isSelectable()
          Returns true if this object is in fact selectable.
 int numControlPoints()
          Returns the number of control points used by this curve.
 int numSelectionQueriesNeeded()
          If this selectable manages its own selection (by issuing selection queries within its render method), then this method should return the maximum number of selection queries that will be required.
 void prerender(RenderList list)
          Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.
 void render(GLRenderer renderer, int flags)
          Render this object using Open GL via the JOGL.
abstract  void render(GLRenderer renderer, RenderProps props, int flags)
           
 void selectControlPoint(int i, boolean selected)
           
 void setDrawControlShape(boolean enable)
           
 void setLineWidth(int w)
           
 void setObjToWorld(RigidTransform3d TOW)
          Sets the 3D transform from the coordinate frame of this NURBS object to the world.
 void setPointSize(int w)
           
 void setRenderProps(RenderProps props)
          Assigns a new set of render properties to this object.
 void transform(AffineTransform3dBase X)
          Applies an affine transformation to the control points this NURBS object.
 void updateBounds(Point3d pmin, Point3d pmax)
          Update the minimum and maximum points for this object.
 void write(java.io.PrintWriter pw)
          Writes a text description of this NURBS object to a PrintWriter, using a subset of the Wavefront OBJ format described in the documentation for the read method for this object.
 void write(java.io.PrintWriter pw, java.lang.String fmtStr)
          Writes a text description of this NURBS object to a PrintWriter, using a subset of the Wavefront OBJ format described in the documentation for the read method for this object.
abstract  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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface maspack.render.HasRenderProps
createRenderProps
 

Method Detail

getObjToWorld

public RigidTransform3d getObjToWorld()
Returns the 3D transform from the coordinate frame of this NURBS object to the world.


getObjToWorld

public void getObjToWorld(RigidTransform3d TOW)
Gets the 3D transform from the coordinate frame of this NURBS object to the world.


setObjToWorld

public void setObjToWorld(RigidTransform3d TOW)
Sets the 3D transform from the coordinate frame of this NURBS object to the world.


setLineWidth

public void setLineWidth(int w)

getLineWidth

public int getLineWidth()

setPointSize

public void setPointSize(int w)

getPointSize

public int getPointSize()

getDrawControlShape

public boolean getDrawControlShape()

setDrawControlShape

public void setDrawControlShape(boolean enable)

numControlPoints

public int numControlPoints()
Returns the number of control points used by this curve.

Returns:
number of control points

getControlPoint

public Vector4d getControlPoint(int i)

getControlPoints

public Vector4d[] getControlPoints()
Returns the control points used by this curve.

Returns:
control points

selectControlPoint

public void selectControlPoint(int i,
                               boolean selected)

controlPointIsSelected

public boolean controlPointIsSelected(int i)

getSelection

public void getSelection(java.util.LinkedList<java.lang.Object> list,
                         int qid)
Description copied from interface: GLSelectable
Append to list the component (or components) associated with the qid-th selection query issued by this component's render method. This will only be called if this component manages its own selection (i.e., the number nums returned by GLSelectable.numSelectionQueriesNeeded() is positive), and qid will in turn be a number between 0 and nums-1.

Specified by:
getSelection in interface GLSelectable
Parameters:
list - selected objects are appended to the end of this list
qid - index of the selection query

updateBounds

public void updateBounds(Point3d pmin,
                         Point3d pmax)
Description copied from interface: GLRenderable
Update the minimum and maximum points for this object. In an x-y-z coordinate system with x directed to the right and y directed upwards, the minimum and maximum points can be thought of as defining the left-lower-far and right-upper-near corners of a bounding cube. This method should only reduce the elements of the minimum point and increase the elements of the maximum point, since it may be used as part of an iteration to determine the bounding cube for several different objects.

Specified by:
updateBounds in interface GLRenderable
Parameters:
pmin - minimum point
pmax - maximum point

isSelectable

public boolean isSelectable()
Returns true if this object is in fact selectable.

Specified by:
isSelectable in interface GLSelectable
Returns:
true if this object is selectable

numSelectionQueriesNeeded

public int numSelectionQueriesNeeded()
Description copied from interface: GLSelectable
If this selectable manages its own selection (by issuing selection queries within its render method), then this method should return the maximum number of selection queries that will be required. Otherwise, this method should return -1.

Specified by:
numSelectionQueriesNeeded in interface GLSelectable
Returns:
maximum number of selection queries needed by this component, or -1 if this component does not manage its own selection.

prerender

public void prerender(RenderList list)
Description copied from interface: GLRenderable
Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.

Specified by:
prerender in interface GLRenderable

getRenderHints

public int getRenderHints()
Description copied from interface: GLRenderable
Returns a bit code giving rendering hints about this renderable. Current bit codes include TRANSLUCENT.

Specified by:
getRenderHints in interface GLRenderable
Returns:
bit code of rendering hints.

write

public void write(java.io.PrintWriter pw)
           throws java.io.IOException
Writes a text description of this NURBS object to a PrintWriter, using a subset of the Wavefront OBJ format described in the documentation for the read method for this object.

Parameters:
pw - PrintWriter for outputing the text description
Throws:
java.io.IOException - if an I/O error occurs

write

public void write(java.io.PrintWriter pw,
                  java.lang.String fmtStr)
           throws java.io.IOException
Writes a text description of this NURBS object to a PrintWriter, using a subset of the Wavefront OBJ format described in the documentation for the read method for this object.

Parameters:
pw - PrintWriter for outputing the text description
fmtStr - printf-style format string for formatting the floating point values (e.g., "%g", "%10.3f").
Throws:
java.io.IOException - if an I/O error occurs

write

public abstract void write(java.io.PrintWriter pw,
                           java.lang.String fmtStr,
                           boolean relative)
                    throws java.io.IOException
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.

Parameters:
pw - PrintWriter for outputing the text description
fmtStr - 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.
Throws:
java.io.IOException - if an I/O error occurs

setRenderProps

public void setRenderProps(RenderProps props)
Assigns a new set of render properties to this object. An argument of null will remove render properties from this object.

Specified by:
setRenderProps in interface HasRenderProps
Parameters:
props - new render properties for this object

getRenderProps

public RenderProps getRenderProps()
Returns the render properities for this object. If no render properties are assigned, this routines returns null.

Specified by:
getRenderProps in interface HasRenderProps
Returns:
current render properties for this object

render

public void render(GLRenderer renderer,
                   int flags)
Description copied from interface: GLRenderable
Render this object using Open GL via the JOGL.

Specified by:
render in interface GLRenderable
Parameters:
renderer - renderer object which is used to perform the rendering. Provides pointers to GL and GLU, along with helper functions.
flags - supplies flags that may be used to control different aspects of the rendering. Flags are defined in GLRenderer and currently include GLRenderer.SELECTED, GLRenderer.VERTEX_COLORING, GLRenderer.HSV_COLOR_INTERPOLATION, GLRenderer.SORT_FACES, and GLRenderer.CLEAR_MESH_DISPLAY_LISTS.

render

public abstract void render(GLRenderer renderer,
                            RenderProps props,
                            int flags)

transform

public void transform(AffineTransform3dBase X)
Applies an affine transformation to the control points this NURBS object.

Parameters:
X - affine transformation