public class MFreeMeshComp extends FemMeshComp implements CollidableBody, PointAttachable
Collidable.Collidability, Collidable.Group
ModelComponent.NavpanelVisibility
CompositeComponent.NavpanelDisplay
Modifier and Type | Field and Description |
---|---|
static PropertyList |
myProps |
DEFAULT_COLOR_INTERPOLATION, DEFAULT_SELECTABLE, DEFAULT_VERTEX_COLOR_MIXING
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
All, AllBodies, Deformable, Rigid, Self
TRANSPARENT, TWO_DIMENSIONAL
TG_ARTICULATED, TG_DRAGGER, TG_PRESERVE_ORIENTATION, TG_SIMULATING
Constructor and Description |
---|
MFreeMeshComp() |
MFreeMeshComp(MFreeModel3d mfree) |
MFreeMeshComp(MFreeModel3d fem,
java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
addVertexAttachment(PointAttachment attachment) |
boolean |
allowCollision(ContactPoint cpnt,
Collidable other,
java.util.Set<Vertex3d> attachedVertices)
Returns
true if a collision between this Collidable
and other should be allowed for the contact point
cpnt . |
void |
collectVertexMasters(java.util.List<ContactMaster> mlist,
Vertex3d vtx)
Collects the contact masters for a particular mesh vertex.
|
void |
connectToHierarchy(CompositeComponent hcomp)
Called by the system after this component, or an ancestor of this
component, is added to the component hierarchy (i.e., added as
a child of another CompositeComponent).
|
boolean |
containsContactMaster(CollidableDynamicComponent comp)
Returns true if this Collidable contains a specified contact master
component.
|
MFreeMeshComp |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap) |
static MFreeMeshComp |
createEmbedded(MFreeMeshComp surf,
MeshBase mesh) |
static MFreeMeshComp |
createEmbedded(MFreeMeshComp surf,
MeshBase mesh,
MFreeModel3d mfree)
Assumes the mesh is in "rest" coordinates, not current coordinates
|
static MFreeMeshComp |
createEmbedded(MFreeModel3d fem,
MeshBase mesh) |
PointFem3dAttachment |
createPointAttachment(Point pnt)
Returns a PointAttachment that attaches
pnt
to this component. |
void |
disconnectFromHierarchy(CompositeComponent hcomp)
Called by the system after this component, or an ancestor of this
component, is removed from the component hierarchy (i.e., removed as a
child of its parent).
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
Collidable.Collidability |
getCollidable()
Returns the
Collidable.Collidability of this Collidable. |
Collidable |
getCollidableAncestor()
Returns the most immediate Collidable ancestor of this Collidable,
if any.
|
int |
getCollidableIndex() |
PolygonalMesh |
getCollisionMesh()
Returns the mesh that should be used for computing collisions, or
null if there is no such mesh. |
DistanceGridComp |
getDistanceGridComp()
Returns a
DistanceGridComp object that in turn contains
a signed distance grid that can be used with a SignedDistanceCollider,
or null if this Collidable
does not support a signed distance grid (i.e., if
CollidableBody.hasDistanceGrid() returns false ). |
MFreeElement3d |
getFaceElement(Face face) |
MFreeModel3d |
getFem() |
double |
getMass()
Returns the mass of the body.
|
FemModel3d |
getModel() |
MFreeNode3d |
getNodeForVertex(Vertex3d vtx)
Returns the node to which a specified vertex is directly attached,
or
null if no such node exists. |
PointAttachment |
getVertexAttachment(int idx)
Retrieves (or creates) a vertex attachment component associated with
vertex vidx, describing how its motion is driven by the underlying
physical system.
|
PointAttachment |
getVertexAttachment(Vertex3d vtx)
Retrieves (or creates) a vertex attachment component associated with
vertex vtx, describing how its motion is driver by the underlying
physical system.
|
Vertex3d |
getVertexForNode(MFreeNode3d node)
Returns a vertex which is directly attached to the specified
node, or
null if no such vertex exists. |
boolean |
hasDistanceGrid()
Returns
true if this Collidable supports a signed
distance grid that can be used with a SignedDistanceCollider. |
boolean |
hasNodeDependency(MFreeNode3d node)
Check if this mesh depends on a particular node
|
boolean |
isCompound()
Queries whether or not this collidable has sub-collidables.
|
boolean |
isDeformable()
Returns
true if this collidable is deformable. |
boolean |
isSingleNodeMapped()
Returns
true if every vertex in this mesh is
directly attached to a single FEM node. |
boolean |
isSurfaceMesh() |
int |
numVertexAttachments() |
void |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer . |
MeshBase |
scanMesh(ReaderTokenizer rtok)
Scans this mesh from a file, using the format described for
writeMesh(java.lang.String) . |
void |
setCollidable(Collidable.Collidability c) |
void |
setCollidableIndex(int idx) |
void |
setSurfaceRendering(FemModel.SurfaceRender mode) |
void |
setVertexAttachment(int vidx,
double[] weights,
MFreeNode3d[] nodes) |
void |
setVertexAttachment(int vidx,
PointAttachment attachment) |
boolean |
writeMesh(java.io.PrintWriter pw)
Writes the mesh for this FemMeshComp out to a PrintWriter, using a format
of the form
|
boolean |
writeMesh(java.io.PrintWriter pw,
boolean nodeFormat) |
boolean |
writeMesh(java.lang.String fileName)
Writes the mesh for this FemMeshComp out to a named file,
using the format described for
writeMesh(PrintWriter) . |
createEmbedded, createEmbedded, createEmbedded, createEmbeddingAttachments, createNodalEmbedded, createNodalEmbedded, createShellSurface, createShellSurface, createShellSurface, createShellSurface, createSurface, createSurface, createSurface, createVolumetricShellSurface, createVolumetricSurface, createVolumetricSurface, createVolumetricSurface, createVolumetricSurface, getHalfEdgeForNodes, getNodes, getVertexEnergyDensity, getVertexForNode, getVertexStrain, getVertexStress, hasInvariantMasters, hasNodeDependency, isGeneratedSurface, isSurfaceEdge, postscan, setVertexAttachment, transformGeometry
getColorMap, getColorMapMode, getSelection, getStressPlotRange, getStressPlotRangeMode, getStressPlotRanging, getStressPlotRangingMode, getSurfaceRendering, getSurfaceRenderingMode, numSelectionQueriesNeeded, prerender, render, resetAutoStressPlotRange, setColorMap, setColorMapMode, setMeshFromInfo, setStressPlotRange, setStressPlotRangeMode, setStressPlotRanging, setStressPlotRangingMode, setSurfaceRenderingMode
componentChanged, findComponent, get, get, getByNumber, getChildren, getNavpanelDisplay, getNavpanelVisibility, getNumberLimit, getSurfaceMesh, getSurfaceMeshes, hasChildren, hierarchyContainsReferences, indexOf, numComponents, numSurfaceMeshes, scaleDistance, scan, setDisplayMode, setNavpanelDisplay, updateNameMap, updateSlavePos, updateSlaveVel
addTransformableDependencies, createSurfaceMeshArray, getColorInterpolation, getFileName, getFileTransform, getMesh, getMeshToWorld, getSurfaceMeshes, getVertex, getVertexColorMixing, isFileTransformRigid, isMeshModified, isMeshPolygonal, isMeshTriangular, isSelectable, numSurfaceMeshes, numVertices, prerenderMesh, scaleMass, setColorInterpolation, setFileName, setFileTransform, setMesh, setMesh, setMesh, setMeshToWorld, setSelectable, setVertexColorMixing, transformGeometry, updateBounds, updatePosition
createRenderProps, defaultRenderPropsAreNull, getRenderHints, getRenderProps, isVisible, setRenderProps, setVisible, updateRenderProps
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, createTempFlag, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasState, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, updateReferences, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hasInvariantMasters
getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable, updateReferences
getProperty
getChildren, hasChildren
postscan
isWritable, write
getMesh, isMeshPolygonal
getSelection, isSelectable, numSelectionQueriesNeeded
getRenderHints, prerender, updateBounds
createRenderProps, getRenderProps, setRenderProps
transformPriority
public static PropertyList myProps
public MFreeMeshComp()
public MFreeMeshComp(MFreeModel3d mfree)
public MFreeMeshComp(MFreeModel3d fem, java.lang.String name)
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class FemMeshComp
public void setSurfaceRendering(FemModel.SurfaceRender mode)
setSurfaceRendering
in class FemMeshBase
public void render(Renderer renderer, int flags)
IsRenderable
Renderer
.render
in interface IsRenderable
render
in class FemMeshComp
renderer
- 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 int numVertexAttachments()
numVertexAttachments
in class FemMeshComp
public PointAttachment getVertexAttachment(Vertex3d vtx)
DynamicMeshComponent
getVertexAttachment
in class FemMeshComp
vtx
- vertexpublic PointAttachment getVertexAttachment(int idx)
DynamicMeshComponent
getVertexAttachment
in class FemMeshComp
idx
- vertex indexpublic boolean isSingleNodeMapped()
true
if every vertex in this mesh is
directly attached to a single FEM node. If this is the case, then
getNodeForVertex(maspack.geometry.Vertex3d)
and getVertexForNode(artisynth.core.mfreemodels.MFreeNode3d)
will never return
null
.isSingleNodeMapped
in class FemMeshComp
true
if every vertex is attached
a single nodepublic MFreeNode3d getNodeForVertex(Vertex3d vtx)
null
if no such node exists. In particular,
if the specified vertex is controlled by multiple nodes,
then this method will return null
.getNodeForVertex
in class FemMeshComp
vtx
- vertex being queriedvtx
is directly attached, or
null
.public Vertex3d getVertexForNode(MFreeNode3d node)
null
if no such vertex exists.node
- node whose vertex is being queriednull
.public MFreeElement3d getFaceElement(Face face)
getFaceElement
in class FemMeshComp
public static MFreeMeshComp createEmbedded(MFreeMeshComp surf, MeshBase mesh)
public MFreeModel3d getFem()
getFem
in interface FemMesh
getFem
in class FemMeshComp
public void addVertexAttachment(PointAttachment attachment)
addVertexAttachment
in class FemMeshComp
public void setVertexAttachment(int vidx, PointAttachment attachment)
setVertexAttachment
in class FemMeshComp
public void setVertexAttachment(int vidx, double[] weights, MFreeNode3d[] nodes)
public static MFreeMeshComp createEmbedded(MFreeMeshComp surf, MeshBase mesh, MFreeModel3d mfree)
surf
- mfree surface to populate (or null to create one)mesh
- mesh to embedmfree
- model to embed mesh inpublic static MFreeMeshComp createEmbedded(MFreeModel3d fem, MeshBase mesh)
public boolean writeMesh(java.lang.String fileName)
writeMesh(PrintWriter)
.writeMesh
in class FemMeshComp
fileName
- Name of file to write the mesh totrue
if the mesh is a polygonal mesh and was written,
and false
otherwise.public boolean writeMesh(java.io.PrintWriter pw)
[ v 3 1.0 v 3 0.5 1 0.5 v 1 0.25 2 0.35 3 0.25 4 0.25 v 2 0.5 4 0.5 v 4 1.0 f 1 3 2 f 1 5 3 f 3 5 4 ]Here each line beginning with
v
describes a mesh
vertex in terms of the FEM nodes to which it is attached.
This takes the form of a list of number/weight pairs:
v n_0 w_0 n_1 w_1 n_2 w_2 ...where
n_i
and w_i
indicate, respectively,
a FEM node (using its number as returned by
getNumber()
),
and its corresponding weight. In the case where a vertex
is not associated with any nodes, then it is described by
a line of the form
v -1 pz py pzwhere
px
, py
, and pz
give the vertex's (fixed) position in space.
Each line beginning with f
describes a mesh face,
using the vertex numbers in counter-clockwise order about the
outward facing normal. To be consistent with Wavefront .obj
format, the vertex numbers are 1-based and so are equal to the
vertex indices plus one.
If the mesh is not an instance of
PolygonalMesh
, then the method does
nothing and returns null
.
writeMesh
in class FemMeshComp
pw
- writer to whichmesh is writtentrue
if the mesh is a polygonal mesh and was written,
and false
otherwise.public boolean writeMesh(java.io.PrintWriter pw, boolean nodeFormat)
writeMesh
in class FemMeshComp
public MeshBase scanMesh(ReaderTokenizer rtok) throws java.io.IOException
writeMesh(java.lang.String)
. For backward compatibility, a format
of the form
[ f 0 1 2 f 2 3 4 f 4 5 6 ]Where no vertex information is given, and each face is instead described using the numbers of the FEM nodes that underlie each vertex. This makes the assumption that the mesh is single node mapped (i.e.,
isSingleNodeMapped()
returns
true
), so that each vertex is associated with
a single FEM node.scanMesh
in class FemMeshComp
rtok
- tokenizer from which mesh is readjava.io.IOException
public void connectToHierarchy(CompositeComponent hcomp)
ModelComponentBase
When this method is called, ModelComponent.getParent()
will return the new
parent component; the system will have set this beforehand.
connectToHierarchy
in interface ModelComponent
connectToHierarchy
in class FemMeshComp
hcomp
- hierarchy component to which this component,
or its ancestor, was attachedpublic void disconnectFromHierarchy(CompositeComponent hcomp)
ModelComponentBase
When this method is called, ModelComponent.getParent()
will still return this
original parent component; the system will set this to null
after.
disconnectFromHierarchy
in interface ModelComponent
disconnectFromHierarchy
in class FemMeshComp
hcomp
- hierarchy component from which this component,
or its ancestor, was detachedpublic MFreeMeshComp copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
copy
in class FemMeshComp
public boolean isSurfaceMesh()
isSurfaceMesh
in class FemMeshComp
public boolean hasNodeDependency(MFreeNode3d node)
public PolygonalMesh getCollisionMesh()
CollidableBody
null
if there is no such mesh. If this method
returns null
, then no collisions will
be performed for this collidable, regardless any default or explicit
collision behaviors that have been arranged by the system.getCollisionMesh
in interface CollidableBody
getCollisionMesh
in class FemMeshComp
public boolean hasDistanceGrid()
CollidableBody
true
if this Collidable supports a signed
distance grid that can be used with a SignedDistanceCollider. At
present, this will only be true for non-deformable bodies.hasDistanceGrid
in interface CollidableBody
hasDistanceGrid
in class FemMeshComp
true
if this Collidable supports a signed
distance gridpublic DistanceGridComp getDistanceGridComp()
CollidableBody
DistanceGridComp
object that in turn contains
a signed distance grid that can be used with a SignedDistanceCollider,
or null
if this Collidable
does not support a signed distance grid (i.e., if
CollidableBody.hasDistanceGrid()
returns false
).getDistanceGridComp
in interface CollidableBody
getDistanceGridComp
in class FemMeshComp
public Collidable.Collidability getCollidable()
Collidable
Collidable.Collidability
of this Collidable. This provides
control over whether external and/or internal collisions are enabled for
this Collidable. This setting takes precedence over default and
explicitly requested collision behaviors.
Note that for collisions to actually occur, they still need to be enabled through either a default or explicit collision behavior in the MechModel.
getCollidable
in interface Collidable
getCollidable
in class FemMeshComp
public void setCollidable(Collidable.Collidability c)
setCollidable
in class FemMeshComp
public Collidable getCollidableAncestor()
Collidable
null
.getCollidableAncestor
in interface Collidable
getCollidableAncestor
in class FemMeshComp
null
.public boolean isCompound()
Collidable
isCompound
in interface Collidable
isCompound
in class FemMeshComp
true
if this collidable has sub-collidablespublic boolean isDeformable()
Collidable
true
if this collidable is deformable. Whether or
not a collidable is deformable determines how it responds to default
collision behaviors involving deformable and rigid collidables. Also,
self-collisions among sub-collidables of a collidable A are permitted
only if A is deformable.isDeformable
in interface Collidable
isDeformable
in class FemMeshComp
true
if this collidable is deformablepublic double getMass()
CollidableBody
getMass
in interface CollidableBody
getMass
in class FemMeshComp
public void collectVertexMasters(java.util.List<ContactMaster> mlist, Vertex3d vtx)
FemMeshComp
mlist
. The vertex
should be a vertex of the mesh returned by CollidableBody.getCollisionMesh()
.
If CollidableBody.hasInvariantMasters()
returns true
, then the
contact masters will not depend on vtx
.
collectVertexMasters
in interface CollidableBody
collectVertexMasters
in class FemMeshComp
mlist
- collected master componentsvtx
- vertex for which the master components are requestedpublic boolean containsContactMaster(CollidableDynamicComponent comp)
CollidableBody
containsContactMaster
in interface CollidableBody
containsContactMaster
in class FemMeshComp
comp
- component to test fortrue
if comp
is contained in
this Collidablepublic boolean allowCollision(ContactPoint cpnt, Collidable other, java.util.Set<Vertex3d> attachedVertices)
CollidableBody
true
if a collision between this Collidable
and other
should be allowed for the contact point
cpnt
. In making this decision, this method may
refer to attachedVertices
, which supplies a list
of vertices on this Collidable which are attached in some way
to the other Collidable.allowCollision
in interface CollidableBody
allowCollision
in class FemMeshComp
cpnt
- contact point being testedother
- opposing collidableattachedVertices
- list of vertices attached to other
.true
if the collision should be allowedpublic int getCollidableIndex()
getCollidableIndex
in interface CollidableBody
getCollidableIndex
in class FemMeshComp
public void setCollidableIndex(int idx)
setCollidableIndex
in interface CollidableBody
setCollidableIndex
in class FemMeshComp
public PointFem3dAttachment createPointAttachment(Point pnt)
PointAttachable
pnt
to this component. It should not be assumed that pnt
is currently connected to the component hierarchy, and no attempt
should be made to connect the returned attachment to the hierarchy;
the latter, if desired, is the responsibility of the caller.
In some cases, it may not be possible to attach the point at its present location. In that case, the method will create an attachment to the nearest feasible location.
createPointAttachment
in interface PointAttachable
createPointAttachment
in class FemMeshComp
pnt
- point for which an attachment should be createdpnt
to this componentpublic FemModel3d getModel()
getModel
in class FemMeshComp