public class PointMesh extends MeshBase
XMeshToWorld
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
PointMesh()
Creates an empty point mesh.
|
PointMesh(java.io.File file)
Creates a point mesh and initializes it from a file, with the file format
being inferred from the file name suffix
|
PointMesh(java.lang.String fileName)
Creates a point mesh and initializes it from a file, with the file format
being inferred from the file name suffix.
|
Modifier and Type | Method and Description |
---|---|
void |
addMesh(PointMesh mesh) |
void |
addMesh(PointMesh mesh,
boolean respectTransforms)
Adds copies of the vertices of another mesh to this mesh.
|
void |
addVertex(Vertex3d vtx)
Adds a vertex to the set of vertices associated with this mesh.
|
PointMesh |
clone()
Creates a clone of this mesh.
|
PointMesh |
copy()
Creates a copy of this mesh.
|
SpatialInertia |
createInertia(double mass)
Computes a spatial inertia for this mesh, given a mass which
is assumed to be distributed uniformly across its vertices.
|
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.
|
double |
getNormalRenderLen() |
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[]) . |
int |
numFeatures()
Returns the number of features in this mesh.
|
void |
prerender(RenderProps props) |
void |
read(ReaderTokenizer rtok,
boolean zeroIndexed)
Reads the contents of this mesh from a ReaderTokenizer.
|
void |
readBinary(java.io.File file) |
boolean |
removeVertex(Vertex3d vtx)
Removes a vertex from this mesh.
|
boolean |
removeVertexFast(Vertex3d vtx)
Removes a vertex from this mesh.
|
java.util.ArrayList<java.lang.Integer> |
removeVertices(java.util.Collection<Vertex3d> vertices)
Removes a set of vertices from this mesh, as indicated by a collection.
|
void |
render(Renderer renderer,
RenderProps props,
int flags) |
void |
set(Point3d[] pnts,
Vector3d[] nrms)
Sets the vertex points and normals associated with this mesh.
|
void |
setNormalRenderLen(double len) |
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, checksum, clear, 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, render, replaceVertices, saveRenderInfo, scale, scale, setColor, setColor, setColor, setColor, setColorInterpolation, setColors, setColorsFixed, setFeatureColoringEnabled, setFixed, setMeshToWorld, setName, setNormal, setNormals, setRenderBuffered, setRenderProps, setTextureCoords, setTextureCoords, setTextureCoordsFixed, setVertexColoringEnabled, setVertexColorMixing, size, supportsMassDistribution, transform, transform, transformToLocal, transformToLocal, transformToOBB, transformToOBB, transformToWorld, transformToWorld, translate, translateToCentroid, updateBounds, write, write, write
public PointMesh()
public PointMesh(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
format is not compatible with point meshespublic PointMesh(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
format is not compatible with point meshespublic RenderProps createRenderProps(HasProperties host)
createRenderProps
in class MeshBase
host
- if non-null, is used to initialize inherited valuespublic double getNormalRenderLen()
public void setNormalRenderLen(double len)
public void readBinary(java.io.File file) throws java.io.IOException
java.io.IOException
public void read(ReaderTokenizer rtok, boolean zeroIndexed) throws java.io.IOException
write(PrintWriter,NumberFormat,boolean)
.public void set(Point3d[] pnts, Vector3d[] nrms)
pnts
- points from which the vertices are formednrms
- (optional) if non-null, gives vectors from which the normals are formed.java.lang.IllegalArgumentException
- if nrms is non-null and does not have the
same size as pnts.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
The format used to print vertex coordinates is specified by a
NumberFormat
.
write
in class MeshBase
pw
- PrintWriter to write this mesh tofmt
- (optional) format for writing the vertex and normals 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 PointMesh clone()
MeshBase
public void addMesh(PointMesh mesh)
public void addMesh(PointMesh mesh, boolean respectTransforms)
mesh
- Mesh to be added to this meshpublic AABBTree getBVTree()
MeshBase
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 void addVertex(Vertex3d vtx)
MeshBase
pnt
field of the vertex should be
non-null. The index of the vertex will be set to reflect it's position in
the list of vertices.addVertex
in class MeshBase
vtx
- vertex to addMeshBase.addVertex(Point3d,boolean)
,
MeshBase.addVertex(Point3d)
public boolean removeVertex(Vertex3d vtx)
MeshBase
removeVertex
in class MeshBase
vtx
- vertex to removepublic boolean removeVertexFast(Vertex3d vtx)
MeshBase
removeVertexFast
in class MeshBase
vtx
- vertex to removepublic java.util.ArrayList<java.lang.Integer> removeVertices(java.util.Collection<Vertex3d> vertices)
MeshBase
removeVertices
in class MeshBase
vertices
- Collection of vertices to removepublic SpatialInertia createInertia(double mass)
mass
- overall masspublic SpatialInertia createInertia(double mass, MassDistribution dist)
MassDistribution.POINT
distribution is
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.