public class PolylineMesh extends MeshBase
XMeshToWorld
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
PolylineMesh()
Creates an empty polyline mesh.
|
PolylineMesh(java.io.File file)
Creates a polyline mesh and initializes it from a file, with the file
format being inferred from the file name extension.
|
PolylineMesh(PolylineMesh old) |
PolylineMesh(java.lang.String fileName)
Creates a polyline mesh and initializes it from a file, with the file
format being inferred from the file name extension.
|
Modifier and Type | Method and Description |
---|---|
Polyline |
addLine(int[] indices)
Adds a line to this mesh.
|
Polyline |
addLine(Polyline line)
Adds a line to this mesh.
|
Polyline |
addLine(Vertex3d[] vertices)
Adds a line to this mesh.
|
void |
addMesh(PolylineMesh mesh) |
void |
addMesh(PolylineMesh mesh,
boolean respectTransforms)
Adds copies of the vertices and lines of another mesh to this mesh.
|
void |
clear()
Clears this mesh (makes it empty).
|
void |
clearBoundingInfo()
Invalidates bounding box information.
|
PolylineMesh |
clone()
Creates a clone of this mesh.
|
PolylineMesh |
copy()
Creates a copy of this mesh.
|
SpatialInertia |
createInertia(double mass,
MassDistribution dist)
Computes a spatial inertia for this mesh, given a mass and a mass
distribution.
|
RenderProps |
createRenderProps(HasProperties host)
Creates an appropriate RenderProps for this Mesh.
|
int[] |
createVertexIndices()
Creates and returns the vertex indices associated with each geometric
feature in this mesh.
|
boolean |
epsilonEquals(MeshBase base,
double eps)
Tests to see if a mesh equals this one.
|
AABBTree |
getBVTree()
Returns a bounding volume tree to be used for proximity queries
involving this mesh.
|
Polyline |
getLine(int i) |
java.util.ArrayList<Polyline> |
getLines()
Returns this mesh's lines.
|
int |
getRenderSkip() |
boolean |
getWriteNormals()
Returns
true if this mesh's normals should be written
to a file. |
boolean |
hasAutoNormalCreation()
Returns
true if this mesh automatically creates a default
set of normals if MeshBase.getNormals() is called and no normals have been
explicitly set using MeshBase.setNormals(java.util.List<maspack.matrix.Vector3d>, int[]) . |
void |
invalidateBoundingInfo()
Invalidates bounding box information.
|
int |
numFeatures()
Returns the number of features in this mesh.
|
int |
numLines()
Returns the number of lines in this mesh.
|
void |
prerender(RenderProps props) |
void |
read(ReaderTokenizer rtok,
boolean zeroIndexed)
Reads the contents of this mesh from a ReaderTokenizer.
|
boolean |
removeLine(Polyline line)
Removes a line from this mesh.
|
void |
render(Renderer renderer,
RenderProps props,
int flags) |
void |
replaceVertices(java.util.List<? extends Vertex3d> vtxs) |
void |
set(Point3d[] pnts)
Sets this mesh to a single polyline indicated by the specified
vertex points.
|
void |
set(Point3d[] pnts,
int[][] lineIndices)
Sets the vertex points and lines associated with this mesh.
|
void |
setRenderSkip(int skip)
Number of lines to skip while rendering
|
boolean |
supportsMassDistribution(MassDistribution dist)
Queries whether or not a given mass distrubution is supported for this
mesh type.
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
boolean zeroIndexed)
Writes this mesh to a PrintWriter, using an Alias Wavefront "obj" file
format.
|
void |
write(java.io.PrintWriter pw,
java.lang.String fmtStr)
Writes this mesh to a PrintWriter, using an Alias Wavefront "obj" file as
described for
write(PrintWriter,NumberFormat,boolean) . |
addVertex, addVertex, addVertex, addVertex, checksum, clearColors, clearNormals, clearRenderProps, clearTextureCoords, computeAverageRadius, computeCentroid, computeLocalBounds, computeOBB, computeOBB, computeRadius, computeWorldBounds, containsVertex, createFeatureIndices, createRenderProps, getColor, getColorIndices, getColorInterpolation, getColors, getFeatureColor, getFeatureColoringEnabled, getFeatureIndexOffsets, getFeatureNormal, getFeatureTextureCoords, getLocalBounds, getMeshToWorld, getMeshToWorld, getName, getNormal, getNormalIndices, getNormals, getRadius, getRenderHints, getRenderNormal, getRenderProps, getSelection, getTextureCoords, getTextureCoords, getTextureIndices, getVersion, getVertex, getVertexColoringEnabled, getVertexColorMixing, getVertices, getWorldBounds, getXMeshToWorldRender, hasColors, hasExplicitColors, hasExplicitNormals, hasNormals, hasTextureCoords, inverseTransform, inverseTransform, isColorsFixed, isEmpty, isFeatureColored, isFixed, isRenderBuffered, isSelectable, isTextureCoordsFixed, isVertexColored, meshToWorldIsIdentity, notifyVertexPositionsModified, numColors, numNormals, numSelectionQueriesNeeded, numTextureCoords, numVertices, perturb, prerender, read, read, read, read, removeVertex, removeVertexFast, removeVertices, render, saveRenderInfo, scale, scale, setColor, setColor, setColor, setColor, setColorInterpolation, setColors, setColorsFixed, setFeatureColoringEnabled, setFixed, setMeshToWorld, setName, setNormal, setNormals, setRenderBuffered, setRenderProps, setTextureCoords, setTextureCoords, setTextureCoordsFixed, setVertexColoringEnabled, setVertexColorMixing, size, transform, transform, transformToLocal, transformToLocal, transformToOBB, transformToOBB, transformToWorld, transformToWorld, translate, translateToCentroid, updateBounds, write, write, write
public PolylineMesh()
public PolylineMesh(java.lang.String fileName) throws java.io.IOException
fileName
- name of the file containing the mesh descriptionjava.io.IOException
- if an I/O error occurred or if the file
type is not compatible with polyline meshespublic PolylineMesh(java.io.File file) throws java.io.IOException
file
- file containing the mesh descriptionjava.io.IOException
- if an I/O error occurred or if the file
type is not compatible with polyline meshespublic PolylineMesh(PolylineMesh old)
public void invalidateBoundingInfo()
MeshBase
public void clearBoundingInfo()
MeshBase
public RenderProps createRenderProps(HasProperties host)
createRenderProps
in class MeshBase
host
- if non-null, is used to initialize inherited valuespublic java.util.ArrayList<Polyline> getLines()
public int numLines()
public void read(ReaderTokenizer rtok, boolean zeroIndexed) throws java.io.IOException
write(PrintWriter,NumberFormat,boolean)
.public void set(Point3d[] pnts)
pnts
- points from which the vertices are formedpublic void set(Point3d[] pnts, int[][] lineIndices)
pnts
- points from which the vertices are formedlineIndices
- integer arrays giving the indices of each line. Each index should
correspond to a particular point in pnts.java.lang.IllegalArgumentException
- if a vertex index is out of boundspublic Polyline addLine(int[] indices)
indices
- integer array giving the vertex indices of the line. Each index should
correspond to a vertex presently associated with this mesh.java.lang.IllegalArgumentException
- if a vertex index is out of boundspublic Polyline addLine(Vertex3d[] vertices)
vertices
- vertices comprising this line. Each vertex should be presently contained
in this mesh.java.lang.IllegalArgumentException
- if any vertices are not contained within this meshpublic Polyline addLine(Polyline line)
line
- Polyline to add to the meshpublic boolean removeLine(Polyline line)
line
- line to removepublic Polyline getLine(int i)
public void write(java.io.PrintWriter pw, java.lang.String fmtStr) throws java.io.IOException
write(PrintWriter,NumberFormat,boolean)
. Index
numbering starts at one, and the format used to print vertex coordinates
is specified by a C printf
style format string contained in
the parameter fmtStr
. For a description of the format
string syntax, see NumberFormat
. Good
default choices for fmtStr
are either "%g"
(full
precision), or "%.Ng"
, where N is the number of
desired significant figures.public void write(java.io.PrintWriter pw, NumberFormat fmt, boolean zeroIndexed) throws java.io.IOException
v 1.0 0.0 0.0 v 0.0 1.0 0.0 v 0.0 0.0 1.0 l 0 1 2
The format used to print vertex coordinates is specified by a
NumberFormat
.
write
in class MeshBase
pw
- PrintWriter to write this mesh tofmt
- format for writing the vertex coordinates. If null
,
a format of "%.8g"
is assumed.zeroIndexed
- if true, index numbering for mesh vertices starts at 0. Otherwise,
numbering starts at 1.java.io.IOException
public void prerender(RenderProps props)
public void render(Renderer renderer, RenderProps props, int flags)
public PolylineMesh copy()
public PolylineMesh clone()
MeshBase
public void replaceVertices(java.util.List<? extends Vertex3d> vtxs)
replaceVertices
in class MeshBase
public void addMesh(PolylineMesh mesh)
public void addMesh(PolylineMesh mesh, boolean respectTransforms)
mesh
- Mesh to be added to this meshpublic AABBTree getBVTree()
MeshBase
public void setRenderSkip(int skip)
public int getRenderSkip()
public boolean epsilonEquals(MeshBase base, double eps)
eps
).epsilonEquals
in class MeshBase
public int[] createVertexIndices()
MeshBase
The indices are zero-based and specify the vertex indices for
each mesh feature. The number of indices and their structure hence
depends on the mesh subclass: for PolygonalMesh
meshes,
this gives the vertices for each face; for PolylineMesh
, the
vertices for each polyline, and for PointMesh
, the vertices
for each point. For example, assume that we have a
PolygonalMesh
with four vertices and
four triangles arranged to form a tetrahedron, so that the vertex
indices for each triangular face are given by (0, 2, 1)
,
(0, 3, 2)
, (0, 1, 3)
,
and (1, 2, 3)
. Then the returned vertex
indices will be
0 2 1 0 3 2 0 1 3 1 2 3
createVertexIndices
in class MeshBase
public int numFeatures()
MeshBase
numFeatures
in class MeshBase
public boolean hasAutoNormalCreation()
MeshBase
true
if this mesh automatically creates a default
set of normals if MeshBase.getNormals()
is called and no normals have been
explicitly set using MeshBase.setNormals(java.util.List<maspack.matrix.Vector3d>, int[])
.hasAutoNormalCreation
in class MeshBase
true
if this mesh automatically creates normals.public boolean getWriteNormals()
true
if this mesh's normals should be written
to a file. This will be the case if the normals were explicitly
set, or if they were automatically created using information
(such as hard edges) that cannot be easily reconstructed from the
information written to standard file formats.getWriteNormals
in class MeshBase
true
if the normals should be written to a filepublic SpatialInertia createInertia(double mass, MassDistribution dist)
MassDistribution.POINT
and MassDistribution.LENGTH
distributions are supported.createInertia
in class MeshBase
mass
- overall massdist
- how the mass is distributed across the featuresjava.lang.IllegalArgumentException
- if the distribution is not compatible
with the available mesh features.public boolean supportsMassDistribution(MassDistribution dist)
supportsMassDistribution
in class MeshBase
true
if the indicated mass distrubution is supported