artisynth.core.femmodels
Class PointSkinAttachment

java.lang.Object
  extended by artisynth.core.modelbase.ModelComponentBase
      extended by artisynth.core.mechmodels.DynamicAttachment
          extended by artisynth.core.mechmodels.PointAttachment
              extended by artisynth.core.femmodels.PointSkinAttachment
All Implemented Interfaces:
CopyableComponent, ModelComponent, ScalableUnits, java.lang.Cloneable, HasProperties, HierarchyNode, Scannable

public class PointSkinAttachment
extends PointAttachment
implements ScalableUnits

A special attachment class that is used to update a point's position based on the state of the controlling bodies (such as Frames and FemModels) in a SkinMesh. Instances of this class (without an actual slave Point) are used to control the positions of each vertex in a SkinMesh.

The class maintains a list of Connection objects for each underlying dynamic component (such as a Frame or FemNode3d) that has a weighted influence on the point's final value.


Nested Class Summary
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.ModelComponent
ModelComponent.NavpanelVisibility
 
Field Summary
 
Fields inherited from class artisynth.core.modelbase.ModelComponentBase
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, myProps, NULL_OBJ, useCompactPathNames
 
Fields inherited from interface artisynth.core.modelbase.CopyableComponent
COPY_REFERENCES
 
Constructor Summary
PointSkinAttachment()
          Creates an empty PointSkinAttachment.
PointSkinAttachment(SkinMesh skinMesh)
          Creates an empty PointSkinAttachment to associated with a specific skinMesh.
 
Method Summary
 void addBaseConnection(double weight)
          Adds a base point connection to this attachment.
 void addFemDisplacementConnection(FemNode3d node, double weight)
          Adds a displacment-based FemNode connection to this attachment.
 void addFrameConnection(SkinMesh.FrameInfo frameInfo, double weight)
          Adds a Frame connection to this attachment.
 void addMassToMaster(MatrixBlock mblk, MatrixBlock sblk, int idx)
           
 void addParticleConnection(Particle particle, double weight)
          Adds an arbitrary particle connection to this attachment.
 void addScaledExternalForce(Point3d pnt, double s, Vector3d f)
          Distributes an external force applied at a particular point to all masters
 void applyForces()
           
 void clearConnections()
          Clear the connections used by this attachment.
 void computePosState(Vector3d pos)
           
 void connectToHierarchy()
          Update the attachment position state whenever we connect to the parent (i.e., plug in to the hierarchy).
 PointSkinAttachment copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
          Create a copy of this component.
 void disconnectFromHierarchy()
          Called by the system after this component is removed from the component hierarchy (i.e., when it is removed as a child of its parent).
 void finalizeConnections()
          Should be called after all connections have been added.
 Point3d getBasePosition()
          Gets the base position for this attachment.
 artisynth.core.femmodels.PointSkinAttachment.Connection getConnection(int idx)
          Gets a specific connection used by this attachent.
 boolean getDerivative(double[] buf, int idx)
           
 DynamicMechComponent getMaster(int idx)
          Returns the underlying master component for a connection used by this attachment.
 DynamicMechComponent[] getMasters()
          
 SkinMesh getSkinMesh()
          Returns the SkinMesh associated with this attachment.
 void getSoftReferences(java.util.List<ModelComponent> refs)
          Appends all soft references for this component to a list.
 double getWeight(int idx)
          Returns the weight for a connection used by this attachment.
 void mulSubG(MatrixBlock D, MatrixBlock B, int idx)
          Computes
 void mulSubGT(double[] ybuf, int yoff, double[] xbuf, int xoff, int idx)
          Computes
 void mulSubGT(MatrixBlock D, MatrixBlock B, int idx)
          Computes
 int numConnections()
          Returns the number of connections (to master components) used by this attachment.
 int numMasters()
          
 void postscan(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor)
          Performs any required post-scanning for this component.
 void scaleBaseWeights(double s, artisynth.core.femmodels.PointSkinAttachment.Connection[] connections)
           
 void scaleDistance(double s)
          Scales all distance coordinates.
 void scaleMass(double s)
          Scales all mass units.
 void setBasePosition(Vector3d pos)
          Sets the base position for this attachment.
 void setSkinMesh(SkinMesh skinMesh)
          Sets the SkinMesh associated with this attachment.
 void setWeight(int idx, double w)
          Sets the weight for a connection used by this attachment.
 void transformSlaveGeometry(AffineTransform3dBase X, TransformableGeometry topObject, int flags)
           
 void trimToSize()
          Minimizes the connection storage space.
 void updateAttachment()
          Update attachment to reflect changes in the slave state.
 void updatePosStates()
           
 void updateReferences(boolean undo, java.util.Deque<java.lang.Object> undoInfo)
          May be called by the system if any of the soft references for this component are removed from the the component hierarchy.
 void updateVelStates()
           
 void writeItems(java.io.PrintWriter pw, NumberFormat fmt, CompositeComponent ancestor)
           
 
Methods inherited from class artisynth.core.mechmodels.PointAttachment
getCopyReferences, getPoint, getSlave, getSlaveSolveIndex, isDuplicatable
 
Methods inherited from class artisynth.core.mechmodels.DynamicAttachment
addAttachmentJacobian, addSolveBlocks, clone, containsLoop, containsLoops, containsMaster, createOrderedList, reduceConstraints, reduceMass, reduceRowMatrix
 
Methods inherited from class artisynth.core.modelbase.ModelComponentBase
checkFlag, checkName, checkNameUniqueness, clearFlag, createTempFlag, getAllPropertyInfo, getChildren, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, hasChildren, hasState, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, scan, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface artisynth.core.modelbase.ModelComponent
getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected
 
Methods inherited from interface maspack.properties.HasProperties
getAllPropertyInfo, getProperty
 
Methods inherited from interface maspack.properties.HierarchyNode
getChildren, hasChildren
 
Methods inherited from interface maspack.util.Scannable
isWritable, write
 

Constructor Detail

PointSkinAttachment

public PointSkinAttachment()
Creates an empty PointSkinAttachment. The associated skin mesh will have to be set later.


PointSkinAttachment

public PointSkinAttachment(SkinMesh skinMesh)
Creates an empty PointSkinAttachment to associated with a specific skinMesh.

Method Detail

getSkinMesh

public SkinMesh getSkinMesh()
Returns the SkinMesh associated with this attachment.


setSkinMesh

public void setSkinMesh(SkinMesh skinMesh)
Sets the SkinMesh associated with this attachment. Will be called by objects utilizing this attachment.


getBasePosition

public Point3d getBasePosition()
Gets the base position for this attachment. Base positions are used for displacement-based position computations.


setBasePosition

public void setBasePosition(Vector3d pos)
Sets the base position for this attachment.


numConnections

public int numConnections()
Returns the number of connections (to master components) used by this attachment.


clearConnections

public void clearConnections()
Clear the connections used by this attachment.


getConnection

public artisynth.core.femmodels.PointSkinAttachment.Connection getConnection(int idx)
Gets a specific connection used by this attachent.

Parameters:
idx - index of the connection. Must be in the range 0 to numConnections().

getWeight

public double getWeight(int idx)
Returns the weight for a connection used by this attachment.

Parameters:
idx - index of the connection. Must be in the range 0 to numConnections().

setWeight

public void setWeight(int idx,
                      double w)
Sets the weight for a connection used by this attachment.

Parameters:
idx - index of the connection. Must be in the range 0 to numConnections().

getMaster

public DynamicMechComponent getMaster(int idx)
Returns the underlying master component for a connection used by this attachment.

Parameters:
idx - index of the connection. Must be in the range 0 to numConnections().

addFrameConnection

public void addFrameConnection(SkinMesh.FrameInfo frameInfo,
                               double weight)
Adds a Frame connection to this attachment. The Frame's displacement from it's rest pose will be used to compute a weighted contribution to the point value, using a mechanism determined by the blend type associated with the SkinMesh (as returned by SkinMesh.getFrameBlending()).

Parameters:
frameInfo - FrameInfo structure within the associated SkinMesh.
weight - connection weight.

addFemDisplacementConnection

public void addFemDisplacementConnection(FemNode3d node,
                                         double weight)
Adds a displacment-based FemNode connection to this attachment. The node's displacement from it's rest position will be used to compute a weighted contribution to the point value.

Parameters:
node - FemNode
weight - connection weight.

addBaseConnection

public void addBaseConnection(double weight)
Adds a base point connection to this attachment. The point's base position (as returned by getBasePosition() will be used to compute a weighted contribution to the point value.

Parameters:
weight - connection weight.

addParticleConnection

public void addParticleConnection(Particle particle,
                                  double weight)
Adds an arbitrary particle connection to this attachment. The particle's current position will be used to compute a weighted contribution to the point value.

Parameters:
particle - particle associated with the attachment.
weight - connection weight.

addScaledExternalForce

public void addScaledExternalForce(Point3d pnt,
                                   double s,
                                   Vector3d f)
Description copied from class: PointAttachment
Distributes an external force applied at a particular point to all masters

Specified by:
addScaledExternalForce in class PointAttachment
Parameters:
pnt - point at which to apply the force (to be used to compute a wrench)
s - force scale factor
f - force vector to apply

trimToSize

public void trimToSize()
Minimizes the connection storage space. Should be called after all connections have been added.


finalizeConnections

public void finalizeConnections()
Should be called after all connections have been added. At the moment, all this does is trim the connection storage space.


getMasters

public DynamicMechComponent[] getMasters()

Specified by:
getMasters in class DynamicAttachment

numMasters

public int numMasters()

Overrides:
numMasters in class DynamicAttachment

computePosState

public void computePosState(Vector3d pos)
Specified by:
computePosState in class PointAttachment

updatePosStates

public void updatePosStates()
Specified by:
updatePosStates in class DynamicAttachment

updateVelStates

public void updateVelStates()
Specified by:
updateVelStates in class DynamicAttachment

applyForces

public void applyForces()
Specified by:
applyForces in class DynamicAttachment

mulSubGT

public void mulSubGT(MatrixBlock D,
                     MatrixBlock B,
                     int idx)
Description copied from class: DynamicAttachment
Computes
       T
 D -= G  B
 
where D and B are matrices associated with master and slave components, respectively, and G is the constraint matrix for the attachment.

Parameters:
D - dependent matrix associated with a master component
B - matrix associated with a slave component

mulSubG

public void mulSubG(MatrixBlock D,
                    MatrixBlock B,
                    int idx)
Description copied from class: DynamicAttachment
Computes
 D -= B G
 
where D and B are matrices associated with master and slave components, respectively, and G is the constraint matrix for the attachment.

Parameters:
D - dependent matrix associated with a master component
B - matrix associated with a slave component

mulSubGT

public void mulSubGT(double[] ybuf,
                     int yoff,
                     double[] xbuf,
                     int xoff,
                     int idx)
Description copied from class: DynamicAttachment
Computes
       T
 y -= G  x
 
where y and x are vectors associated with master and slave components, respectively, and G is the constraint matrix for the attachment.

Parameters:
ybuf - buffer into which to store result
yoff - offset into ybuf
xbuf - buffer containing right hand side vector
xoff - offset into xbuf
idx - master component index

updateAttachment

public void updateAttachment()
Description copied from class: DynamicAttachment
Update attachment to reflect changes in the slave state.

Specified by:
updateAttachment in class DynamicAttachment

transformSlaveGeometry

public void transformSlaveGeometry(AffineTransform3dBase X,
                                   TransformableGeometry topObject,
                                   int flags)
Specified by:
transformSlaveGeometry in class DynamicAttachment

addMassToMaster

public void addMassToMaster(MatrixBlock mblk,
                            MatrixBlock sblk,
                            int idx)
Specified by:
addMassToMaster in class DynamicAttachment

postscan

public void postscan(java.util.Deque<ScanToken> tokens,
                     CompositeComponent ancestor)
              throws java.io.IOException
Description copied from interface: ModelComponent
Performs any required post-scanning for this component. This involves handling any information whose processing was deferred during the scan() method and stored in the token queue. The most common use of this method is to resolve the paths of component references, which may not have been created at the time of the initial scan() call.

Specified by:
postscan in interface ModelComponent
Overrides:
postscan in class ModelComponentBase
Parameters:
tokens - token information that was stored during scan().
ancestor - ancestor component with respect to which reference component paths are defined.
Throws:
java.io.IOException

writeItems

public void writeItems(java.io.PrintWriter pw,
                       NumberFormat fmt,
                       CompositeComponent ancestor)
                throws java.io.IOException
Overrides:
writeItems in class PointAttachment
Throws:
java.io.IOException

getDerivative

public boolean getDerivative(double[] buf,
                             int idx)
Specified by:
getDerivative in class DynamicAttachment

connectToHierarchy

public void connectToHierarchy()
Description copied from class: DynamicAttachment
Update the attachment position state whenever we connect to the parent (i.e., plug in to the hierarchy).

Specified by:
connectToHierarchy in interface ModelComponent
Overrides:
connectToHierarchy in class DynamicAttachment

disconnectFromHierarchy

public void disconnectFromHierarchy()
Description copied from class: ModelComponentBase
Called by the system after this component is removed from the component hierarchy (i.e., when it is removed as a child of its parent). This method is responsible for any required hierarchy-dependent deinitialization.

When this method is called, ModelComponent.getParent() will still return this original parent component; the system will set this to null after.

Specified by:
disconnectFromHierarchy in interface ModelComponent
Overrides:
disconnectFromHierarchy in class ModelComponentBase

getSoftReferences

public void getSoftReferences(java.util.List<ModelComponent> refs)
Description copied from class: ModelComponentBase
Appends all soft references for this component to a list. References are other components, outside of this component's immediate ancestry, on which this component depends. For example, an ExcitationComponent may refer to one or more other ExcitationComponents to act as excitation sources. A soft reference is one which can be removed from the referring component. In particular, if any soft references for a component are deleted, then that component's updateReferences() method will be called to update its internal reference information.

Specified by:
getSoftReferences in interface ModelComponent
Overrides:
getSoftReferences in class ModelComponentBase
Parameters:
refs - list to which soft references are appended

scaleDistance

public void scaleDistance(double s)
Description copied from interface: ScalableUnits
Scales all distance coordinates.

Specified by:
scaleDistance in interface ScalableUnits
Parameters:
s - scaling factor

scaleMass

public void scaleMass(double s)
Description copied from interface: ScalableUnits
Scales all mass units.

Specified by:
scaleMass in interface ScalableUnits
Parameters:
s - scaling factor

copy

public PointSkinAttachment copy(int flags,
                                java.util.Map<ModelComponent,ModelComponent> copyMap)
Description copied from interface: CopyableComponent
Create a copy of this component. If COPY_REFERENCES is set in flags, then any component referenced by this component should itself be set to a copy. This should be done first checking copyMap for an existing copy of the referenced component. If there is no existing copy, then a copy should be created by calling copy recursively and adding the new copy to copyMap.

Specified by:
copy in interface CopyableComponent
Overrides:
copy in class PointAttachment

scaleBaseWeights

public void scaleBaseWeights(double s,
                             artisynth.core.femmodels.PointSkinAttachment.Connection[] connections)

updateReferences

public void updateReferences(boolean undo,
                             java.util.Deque<java.lang.Object> undoInfo)
May be called by the system if any of the soft references for this component are removed from the the component hierarchy. If called with undo equal to false, this component should then examine its soft references and use ComponentUtils.isConnected() to determine which of them have been disconnected from the hierarchy. Disconnected references should be removed, and sufficient information should be appended to undoInfo to allow this update to be undone if this method is called later with undo equal to true. When undoing an update, the undo information should be removed from the front of undoInfo.

Specified by:
updateReferences in interface ModelComponent
Overrides:
updateReferences in class ModelComponentBase
Parameters:
undo - if true, indicates that the most recent reference update should be undone, using the supplied undo information.
undoInfo - if undo is false, should be used to store information allowing the reference update to be undone. Otherwise, if undo is true, then this supplied information to undo the most recent update.