public abstract class InterpolatingGridBase extends java.lang.Object implements Renderable, Scannable
The grid is implemented as a regular 3D grid composed of
nx X ny X nz vertices along the x, y
and z directions, giving it a resolution of rx,
ry, rz, cells along each of these directions,
where rx = nx-1, ry = ny-1, and rz =
nz-1. The grid has widths w = (wx, wy, wz) along each of
these directions, and cell widths given by wx/rx,
wy/ry, and wz/rz.
Several coordinate frames are associated with the grid:
TRANSPARENT, TWO_DIMENSIONAL| Constructor and Description |
|---|
InterpolatingGridBase(InterpolatingGridBase grid)
Creates a new grid base that is a copy of an existing one.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearColors()
Clears the color map used to specify vertex colors.
|
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object.
|
boolean |
epsilonEquals(InterpolatingGridBase grid,
double tol)
Returns
true if this grid base equals another within a
prescribed tolerance. |
Vector3i |
getCellVertex(Vector3i xyzi,
Point3d point)
Returns the x, y, z indices of the minimum vertex of the cell containing
a given point in local coordinates.
|
Vector3d |
getCellWidths()
Returns the grid cell widths along each axis.
|
void |
getCenter(Vector3d center)
Returns the center of this grid with respect to its local coordinates.
|
RigidTransform3d |
getCenterAndOrientation()
Returns the transform TCL that describes the center and orientation of
this grid with respect to local coordinates.
|
int |
getClosestVertex(Point3d point)
Returns the vertex index of the nearest vertex to a point in local
coordinates.
|
int |
getDebug() |
java.awt.Color |
getDefaultVertexColor()
Returns the default color used for rendering vertices when a color map is
specified.
|
VectorTransformer3d |
getGridToLocalTransformer()
Returns the transformer that maps from grid to local coordinates.
|
RigidTransform3d |
getLocalToWorld()
Returns the transform that maps from local to world coordinates.
|
VectorTransformer3d |
getLocalToWorldTransformer()
Returns the transformer that maps from local to world coordinates.
|
Vector3d |
getLocalVertexCoords(Vector3d coords,
int vi)
Find the local coordinates of a vertex, as specified by its vertex index.
|
Vector3d |
getLocalVertexCoords(Vector3d coords,
Vector3i vxyz)
Find the local coordinates of a vertex, as specified by its x, y, z
indices.
|
void |
getOrientation(RotationMatrix3d R)
Returns the orientation of this grid with respect to its local
coordinates.
|
abstract java.lang.Class<?> |
getParameterType()
For subclasses with parameterized typing, returns the type parameter.
|
double |
getRadius()
Returns the radius of this grid, defined as half the distance across its
maximal diagonal.
|
int |
getRenderHints()
Returns a bit code giving rendering hints about this renderable.
|
RenderProps |
getRenderProps()
Returns the render properities for this object.
|
java.lang.String |
getRenderRanges()
Returns a string describing the render ranges for this grid, as described
for
setRenderRanges(java.lang.String). |
boolean |
getRenderVector(Vector3d vec3,
int xi,
int yj,
int zk)
For grid subclasses wishing to render 3D vector information, this method
should be overridden to optionally returns a vector quantity associated
with the vertex at indices
xi, yj, and zk. |
double |
getRenderVectorScale()
For grid subclasses wishing to render 3D vector information, this method
should be overridden to return a scaling factor to be applied to vectors
returned by
getRenderVector(maspack.matrix.Vector3d, int, int, int) to determine the length of the
actual rendered vector. |
Vector3i |
getResolution()
Returns the resolution of this grid along each axis.
|
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. |
java.awt.Color |
getVertexColor(int idx)
Returns the color used for rendering a specific vertex when using a color
map.
|
Vector3d |
getWidths()
Returns the widths of this grid along the x, y, and z axes.
|
void |
getWidths(Vector3d widths)
Returns the widths of this grid along the x, y, and z axes.
|
void |
getWorldCenter(Point3d center)
Returns the center of this grid with respect to world coordinates.
|
void |
getWorldOrientation(RotationMatrix3d R)
Returns the orientation of this grid with respect to world coordinates.
|
Vector3d |
getWorldVertexCoords(Vector3d coords,
int vi)
Find the world coordinates of a vertex, as specified by its
vertex index.
|
Vector3d |
getWorldVertexCoords(Vector3d coords,
Vector3i vxyz)
Find the world coordinates of a vertex, as specified by its x, y, z
indices.
|
boolean |
hasLocalToWorld()
Queries whether this grid has a local-to-world transform that is
not the identity.
|
boolean |
isSelectable()
Returns true if this object is in fact selectable.
|
boolean |
isVertexRenderingEnabled()
Queries whether rendering of vertices is enabled.
|
boolean |
isWritable()
Returns
true if this component should in fact be written to
secondary storage. |
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. |
int |
numVertices()
Returns the total number of vertices in this grid.
|
static int[] |
parseRenderRanges(java.lang.String str,
StringHolder errorMsg)
Parses a render range specification for this grid.
|
void |
prerender(RenderList list)
Called prior to rendering to allow this object to update the internal
state required for rendering (such as by caching rendering coordinates).
|
void |
prerender(RenderProps props) |
void |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer. |
void |
render(Renderer renderer,
RenderProps props,
int flags) |
void |
scaleDistance(double s)
Scales the distance units of the grid, which entails
scaling the widths and coordinate transform information.
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
void |
set(InterpolatingGridBase grid)
Sets this grid base to be a copy of an existing one.
|
void |
setCenter(Vector3d center)
Sets the center of this grid with respect to its local coordinates.
|
void |
setCenterAndOrientation(RigidTransform3d TCL)
Sets the center and orientation of this grid with respect to local
coordinates, by means of the transform
TCL whose rotation
matrix R gives the orientation and offset vector
p gives the center. |
void |
setDebug(int level) |
void |
setDefaultVertexColor(java.awt.Color color)
Sets the default color used for rendering vertices.
|
void |
setLocalToWorld(RigidTransform3d TLW)
Sets a transform that maps from local to world coordinates.
|
void |
setOrientation(RotationMatrix3d R)
Sets the orientation of this grid with respect to its local coordinates.
|
void |
setRenderProps(RenderProps props)
Assigns a new set of render properties to this object.
|
void |
setRenderRanges(java.lang.String str)
Sets the render ranges for this grid.
|
void |
setResolution(Vector3i resolution)
Sets the resolution for this grid along the x, y, and z axes.
|
void |
setVertexColor(int idx,
java.awt.Color color)
Sets the color used to render a specific vertex.
|
void |
setVertexRenderingEnabled(boolean enable)
Enable or disable rendering of vertices.
|
void |
updateBounds(Vector3d pmin,
Vector3d pmax)
Update the minimum and maximum points for this object.
|
Vector3i |
vertexToXyzIndices(Vector3i vxyz,
int vi)
Given a vertex index
vi, compute the corresponding
x, y, z indices. |
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this element to a PrintWriter.
|
int |
xyzIndicesToVertex(Vector3i vxyz)
Given the x, y, z indices for a vertex, compute the corresponding
vertex index.
|
public InterpolatingGridBase(InterpolatingGridBase grid)
grid - grid base to copypublic abstract java.lang.Class<?> getParameterType()
null.nullpublic void setLocalToWorld(RigidTransform3d TLW)
hasLocalToWorld
will subsequently return false.TLW - transform from local to world coordinatespublic RigidTransform3d getLocalToWorld()
hasLocalToWorld returns false, this will be
the identity.public boolean hasLocalToWorld()
true if the local-to-world transform is not the
identity.public VectorTransformer3d getLocalToWorldTransformer()
public VectorTransformer3d getGridToLocalTransformer()
public void setResolution(Vector3i resolution)
resolution - cell resolution along the x, y and z axes. Must be at
least 1 along each axis.public void set(InterpolatingGridBase grid)
grid - grid base to copypublic void clearColors()
public void setVertexColor(int idx,
java.awt.Color color)
idx - vertex indexcolor - rendering color for the vertexpublic java.awt.Color getVertexColor(int idx)
null is returned.idx - vertex indexpublic void setDefaultVertexColor(java.awt.Color color)
color - default vertex color when using a color map.public java.awt.Color getDefaultVertexColor()
null
is returned.public void setCenterAndOrientation(RigidTransform3d TCL)
TCL whose rotation
matrix R gives the orientation and offset vector
p gives the center. All other aspects of the grid remain
unchanged.TCL - transform giving the center and orientation of the
grid with respect to local coordinates.public RigidTransform3d getCenterAndOrientation()
public void getCenter(Vector3d center)
center - returns the grid centerpublic void setCenter(Vector3d center)
center - new grid centerpublic void getOrientation(RotationMatrix3d R)
R - grid orientation in local coordinatespublic void setOrientation(RotationMatrix3d R)
R - new grid orientation in local coordinatespublic void getWorldOrientation(RotationMatrix3d R)
R - grid orientation in world coordinatespublic void getWorldCenter(Point3d center)
center - returns the grid centerpublic Vector3i getCellVertex(Vector3i xyzi, Point3d point)
point is outside the
grid, null is returned.xyzi - returns the x, y, z indices. If specified as
null, then the containing vector is allocated internally.point - point for which the cell vertex is desired (local coordinates)null if point is outside the grid.public Vector3i vertexToXyzIndices(Vector3i vxyz, int vi)
vi, compute the corresponding
x, y, z indices.vxyz - returns the x, y, z indices.vi - vertex indexvxyzpublic int xyzIndicesToVertex(Vector3i vxyz)
vxyz - x, y, z indicespublic Vector3i getResolution()
public Vector3d getCellWidths()
i, this equals w_i/res_i, where w_i
and res_i are the overall width and resolution associated
with that axis.public Vector3d getWidths()
public void getWidths(Vector3d widths)
widths - returns the grid widthspublic int numVertices()
public boolean getRenderVector(Vector3d vec3, int xi, int yj, int zk)
xi, yj, and zk. Should
returns null if no vector information should be rendered at that
vertex.vec3 - three vector valuexi - x vertex indexyj - y vertex indexzk - z vertex indextrue if the vector quantity maps to a 3-vector valuepublic double getRenderVectorScale()
getRenderVector(maspack.matrix.Vector3d, int, int, int) to determine the length of the
actual rendered vector. Returning 0 disables vector rendering.public RenderProps getRenderProps()
getRenderProps in interface HasRenderPropspublic RenderProps createRenderProps()
createRenderProps in interface HasRenderPropspublic void setRenderProps(RenderProps props)
null will remove render properties from this object.setRenderProps in interface HasRenderPropsprops - new render properties for this objectpublic void setVertexRenderingEnabled(boolean enable)
true.enable - if true, enables vertex renderingpublic boolean isVertexRenderingEnabled()
true if vertex rendering is enabledpublic void getSelection(java.util.LinkedList<java.lang.Object> list,
int qid)
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 IsSelectable.numSelectionQueriesNeeded() is positive), and qid will in
turn be a number between 0 and nums-1.getSelection in interface IsSelectablelist - selected objects are appended to the end of this listqid - index of the selection querypublic boolean isSelectable()
isSelectable in interface IsSelectablepublic int numSelectionQueriesNeeded()
render method), then this method should
return the maximum number of selection queries that will be
required. Otherwise, this method should return -1.numSelectionQueriesNeeded in interface IsSelectablepublic void prerender(RenderList list)
list.addIfVisible (obj);
for each of the objects in question.prerender in interface IsRenderablelist - list of objects to be renderedpublic void prerender(RenderProps props)
public void render(Renderer renderer, int flags)
Renderer.render in interface IsRenderablerenderer - provides the functionality used to perform the rendering.flags - flags that may be used to control different
aspects of the rendering. Flags are defined in Renderer
and currently include
Renderer.HIGHLIGHT and
Renderer.SORT_FACES.public void render(Renderer renderer, RenderProps props, int flags)
public void updateBounds(Vector3d pmin, Vector3d pmax)
updateBounds in interface IsRenderablepmin - minimum pointpmax - maximum pointpublic int getRenderHints()
TRANSPARENT and
TWO_DIMENSIONAL.getRenderHints in interface IsRenderablepublic int getClosestVertex(Point3d point)
point - point for which to calculate nearest vertex (local
coordinates)pointpublic Vector3d getLocalVertexCoords(Vector3d coords, int vi)
coords - if not null, supplies a vector for returning
the coordinatesvi - vertex indexpublic Vector3d getLocalVertexCoords(Vector3d coords, Vector3i vxyz)
coords - if not null, supplies a vector for returning
the coordinatesvxyz - x, y, z vertex indicespublic Vector3d getWorldVertexCoords(Vector3d coords, int vi)
coords - if not null, supplies a vector for returning
the coordinatesvi - vertex indexpublic Vector3d getWorldVertexCoords(Vector3d coords, Vector3i vxyz)
coords - if not null, supplies a vector for returning
the coordinatesvxyz - x, y, z vertex indicespublic java.lang.String getRenderRanges()
setRenderRanges(java.lang.String).public void setRenderRanges(java.lang.String str)
The format consists of three separate range descriptors, one for each axis. A range descriptor may be '*' (all vertices), 'n:m' (vertices in the index range n to m, inclusive), or 'n' (vertices only at index n). For example:
"* * *" - all vertices "* 7 *" - all vertices along x and z, and those at index 7 along y "0 2 3" - a single vertex at indices (0, 2, 3) "0:3 4:5 *" - all vertices between indices 0-3 along x, and 4-5 along yIn addition, the single charater "*" also indicates all vertices.
str - render range specificationjava.lang.IllegalArgumentException - if the range specification is not valid.public static int[] parseRenderRanges(java.lang.String str,
StringHolder errorMsg)
setRenderRanges(java.lang.String). This method does
not set anything; it simply parses the ranges and converts then into an
integer array of length 6, giving the upper and lower bounds along each
of the x, y, and z axes. For the ``all'' specifier ('*'), the
values 0 and Integer.MAX_VALUE are used. Applications can
use this method to test if a range specification is valid prior to
calling setRenderRanges(java.lang.String). If the specification is invalid, then
an error message is placed in errorMsg and the method
returns null.str - range specificationerrorMsg - returns an error message in case of an errornull if there
is an errorpublic double getRadius()
public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
write.public void write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
throws java.io.IOException
scan and complete
enough to allow full reconstruction of the element.public boolean isWritable()
Scannabletrue if this component should in fact be written to
secondary storage. This gives subclasses control over whether or
not they are actually written out.isWritable in interface Scannabletrue if this component should be written to
secondary storage.public boolean epsilonEquals(InterpolatingGridBase grid, double tol)
true if this grid base equals another within a
prescribed tolerance. The grid bases are equal if the resolution, widths,
center, and orientation are equal. Specifying tol = 0 requires
exact equality.grid - grid base to compare againsttol - floating point tolerance (absolute)public int getDebug()
public void setDebug(int level)
public void scaleDistance(double s)
s - scaling factor