public class PointSkinAttachment extends PointAttachment implements TransformableGeometry, ScalableUnits, ContactMaster
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.
Modifier and Type | Class and Description |
---|---|
static class |
PointSkinAttachment.ElementConnection |
static class |
PointSkinAttachment.FemConnection |
class |
PointSkinAttachment.FemDispConnection |
class |
PointSkinAttachment.FrameConnection |
static class |
PointSkinAttachment.SkinConnection<C extends PointSkinAttachment.SkinConnection<C>>
Defines connections associated with this attachment.
|
ModelComponent.NavpanelVisibility
Modifier and Type | Field and Description |
---|---|
boolean |
debug |
boolean |
useFemMasterBlocksForContact |
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, myProps, NULL_OBJ, useCompactPathNames
TG_ARTICULATED, TG_DRAGGER, TG_PRESERVE_ORIENTATION, TG_SIMULATING
COPY_REFERENCES, REST_POSITION
Constructor and Description |
---|
PointSkinAttachment()
Creates an empty PointSkinAttachment.
|
PointSkinAttachment(Point slave) |
Modifier and Type | Method and Description |
---|---|
void |
add1DConstraintBlocks(SparseBlockMatrix GT,
int bj,
double scale,
ContactPoint cpnt,
Vector3d dir)
Adds blocks to the constraint matrix GT to implement a 1D constraint in a
specified direction.
|
void |
add2DConstraintBlocks(SparseBlockMatrix GT,
int bj,
double scale,
ContactPoint cpnt,
Vector3d dir0,
Vector3d dir1)
Adds blocks to the constraint matrix GT to implement a 2D constraint in
two specified directions.
|
void |
addBackRefsIfConnected()
Add backrefs if this attachment is connected *and* controlling a point
|
void |
addForce(Vector3d f) |
void |
addFrameConnection(SkinMeshBody.FrameInfo frameInfo,
double weight)
Adds a Frame connection to this attachment.
|
void |
addMassToMasters() |
void |
addRelativeVelocity(Vector3d vel,
double scale,
ContactPoint cpnt)
Accumulate the velocity at the contact due to the current
velocity of the underlying dynamic components.
|
void |
addTransformableDependencies(TransformGeometryContext context,
int flags)
Adds to
context any transformable components which should be
transformed as the same time as this component. |
void |
applyForces() |
void |
clearConnections()
Clear the connections used by this attachment.
|
int |
collectMasterComponents(java.util.HashSet<DynamicComponent> masters,
boolean activeOnly)
Collects all the underlying dynamic ``master'' components.
|
void |
computeForceOnMasters(VectorNd uvec,
Vector3d fc,
double scale,
ContactPoint cpnt,
SparseBlockMatrix S)
XXX Experimental XXX
Compute the forces on the masters resulting from a force
fc applied at the contact point, and accumulate them in uvec,
whose size should equal that of the system forces.
|
void |
connectToHierarchy(CompositeComponent hcomp)
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(CompositeComponent hcomp)
Update the attachment position state whenever we connect to the parent
(i.e., plug in to the hierarchy).
|
Point3d |
getBasePosition()
Gets the base position for this attachment.
|
float |
getBaseWeight()
Gets the base weight for this attachment.
|
PointSkinAttachment.SkinConnection |
getConnection(int idx) |
double |
getConnectionWeight(int idx) |
void |
getCurrentPos(Vector3d pos)
Returns the current position of the attached point, in world coordinates.
|
void |
getCurrentVel(Vector3d vel,
Vector3d dvel) |
boolean |
getDerivative(double[] buf,
int idx) |
PointSkinAttachment.FemConnection |
getFemConnection(int idx) |
PointSkinAttachment.FemConnection |
getFemConnections() |
PointSkinAttachment.FrameConnection |
getFrameConnection(int idx) |
PointSkinAttachment.FrameConnection |
getFrameConnections() |
MatrixBlock |
getGT(int idx)
Returns the transpose of the constraint matrix G associated
with the idx-th master component.
|
void |
getHardReferences(java.util.List<ModelComponent> refs)
Appends all hard references for this component to a list.
|
MatrixBlock[] |
getMasterBlocks()
Returns the most recently updated set of master blocks for this
attachments.
|
SkinMeshBody |
getSkinMesh()
Finds the SkinMeshBody, if any, associated with this attachment.
|
void |
getSoftReferences(java.util.List<ModelComponent> refs)
Appends all soft references for this component to a list.
|
void |
invalidateMasters() |
boolean |
isControllable()
Queries whether at least one of the underlying dynamic components is
controllable.
|
static void |
main(java.lang.String[] args) |
void |
mulSubGT(double[] ybuf,
int yoff,
double[] xbuf,
int xoff,
int idx)
Computes
|
void |
mulSubGTM(MatrixBlock D,
MatrixBlock M,
int idx)
Computes
|
void |
mulSubMG(MatrixBlock D,
MatrixBlock M,
int idx)
Computes
|
void |
notifyMastersOfPositionChange()
If necessary, notify this attachment's master components that the
position state of one or more of them has changed.
|
int |
numConnections()
Returns the number of connections (to master components) used by this
attachment.
|
int |
numFemConnections() |
int |
numFrameConnections() |
void |
postscan(java.util.Deque<ScanToken> tokens,
CompositeComponent ancestor)
Performs any required post-scanning for this component.
|
void |
removeBackRefsIfConnected()
Remove backrefs if this attachment is connected *and* controlling a point
|
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 |
setBaseWeight(double w,
boolean normalize)
Sets the base weight for this attachment.
|
void |
transformGeometry(AffineTransform3dBase X)
Applies an affine transformation to the geometry of this component.
|
void |
transformGeometry(GeometryTransformer gtr,
TransformGeometryContext context,
int flags)
Transforms the geometry of this component, using the geometry transformer
gtr to transform its individual attributes. |
void |
updateAttachment()
Update attachment to reflect changes in the slave state.
|
int |
updateFrameMasterBlocks(SkinMeshBody.FrameBlending blending) |
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) |
addTargetJacobian, checkMasterBlocks, getCopyReferences, getMasters, getPoint, getSlave, isDuplicatable, numMasters
addBackRefs, addBackRefs, addConnectedMasterRefs, clone, connectAttachment, getAttachment, oneMasterActive, oneMasterNotAttached, removeBackRefs, removeBackRefs, removeConnectedMasterRefs, setSlaveAffectsStiffness, slaveAffectsStiffness
checkFlag, checkName, checkNameUniqueness, clearFlag, createTempFlag, getAllPropertyInfo, getChildren, getGrandParent, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, hasChildren, hasState, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, scan, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
transformPriority
getName, getNavpanelVisibility, getNumber, getParent, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable
getAllPropertyInfo, getProperty
getChildren, hasChildren
isWritable, write
public boolean useFemMasterBlocksForContact
public boolean debug
public PointSkinAttachment()
public PointSkinAttachment(Point slave)
public SkinMeshBody getSkinMesh()
public Point3d getBasePosition()
public void setBasePosition(Vector3d pos)
public float getBaseWeight()
public void setBaseWeight(double w, boolean normalize)
w
- new base weightnormalize
- if true
and the connection weights sum to a
non-zero value, scales the connections weights so that the total weight
sum remains unchangedpublic int numConnections()
public PointSkinAttachment.SkinConnection getConnection(int idx)
public double getConnectionWeight(int idx)
public void clearConnections()
public void addBackRefsIfConnected()
public void removeBackRefsIfConnected()
public void addFrameConnection(SkinMeshBody.FrameInfo frameInfo, double weight)
SkinMeshBody.getFrameBlending()
).frameInfo
- FrameInfo structure within the associated SkinMeshBody.weight
- connection weight.addFemConnectionpublic PointSkinAttachment.FrameConnection getFrameConnections()
public PointSkinAttachment.FrameConnection getFrameConnection(int idx)
public int numFrameConnections()
public PointSkinAttachment.FemConnection getFemConnections()
public PointSkinAttachment.FemConnection getFemConnection(int idx)
public int numFemConnections()
public void invalidateMasters()
invalidateMasters
in interface DynamicAttachment
invalidateMasters
in class PointAttachment
public MatrixBlock[] getMasterBlocks()
public int updateFrameMasterBlocks(SkinMeshBody.FrameBlending blending)
public void getCurrentPos(Vector3d pos)
PointAttachment
getCurrentPos
in class PointAttachment
pos
- used to return current point positionpublic void notifyMastersOfPositionChange()
PointAttachment
PointAttachment.createNumericMasterBlocks()
. Attachments
only need to implement this method when setting the position state of one
or more masters, in isolation, incurs the need for other updates before a
subsequwent call to DynamicAttachmentBase.updatePosStates()
will perform correctly.notifyMastersOfPositionChange
in class PointAttachment
public void updatePosStates()
updatePosStates
in interface DynamicAttachment
updatePosStates
in class DynamicAttachmentBase
public void updateVelStates()
updateVelStates
in interface DynamicAttachment
updateVelStates
in class DynamicAttachmentBase
public void applyForces()
applyForces
in interface DynamicAttachment
applyForces
in class PointAttachment
public void addForce(Vector3d f)
public void mulSubGTM(MatrixBlock D, MatrixBlock M, int idx)
DynamicAttachmentBase
T D -= G Mwhere D and M are matrices associated with master and slave components, respectively, and G is the constraint matrix for the attachment.
mulSubGTM
in interface DynamicAttachment
mulSubGTM
in class DynamicAttachmentBase
D
- dependent matrix associated with a master componentM
- matrix associated with a slave componentpublic void mulSubMG(MatrixBlock D, MatrixBlock M, int idx)
DynamicAttachmentBase
D -= M Gwhere D and M are matrices associated with master and slave components, respectively, and G is the constraint matrix for the attachment.
mulSubMG
in interface DynamicAttachment
mulSubMG
in class DynamicAttachmentBase
D
- dependent matrix associated with a master componentM
- matrix associated with a slave componentpublic MatrixBlock getGT(int idx)
DynamicAttachmentBase
getGT
in interface DynamicAttachment
getGT
in class DynamicAttachmentBase
idx
- index of the master componentpublic void mulSubGT(double[] ybuf, int yoff, double[] xbuf, int xoff, int idx)
DynamicAttachmentBase
T y -= G xwhere y and x are vectors associated with master and slave components, respectively, and G is the constraint matrix for the attachment.
mulSubGT
in interface DynamicAttachment
mulSubGT
in class DynamicAttachmentBase
ybuf
- buffer into which to store resultyoff
- offset into ybufxbuf
- buffer containing right hand side vectorxoff
- offset into xbufidx
- master component indexpublic void updateAttachment()
DynamicAttachmentBase
updateAttachment
in interface DynamicAttachment
updateAttachment
in class DynamicAttachmentBase
public void addMassToMasters()
addMassToMasters
in interface DynamicAttachment
addMassToMasters
in class DynamicAttachmentBase
public void postscan(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
PostScannable
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.postscan
in interface PostScannable
postscan
in class ModelComponentBase
tokens
- token information that was stored during
scan()
.ancestor
- ancestor component with respect to which
reference component paths are defined.java.io.IOException
- if an error is encountered (such as a reference to a
non-existent component)public void writeItems(java.io.PrintWriter pw, NumberFormat fmt, CompositeComponent ancestor) throws java.io.IOException
writeItems
in class PointAttachment
java.io.IOException
public boolean getDerivative(double[] buf, int idx)
getDerivative
in interface DynamicAttachment
getDerivative
in class DynamicAttachmentBase
public void getHardReferences(java.util.List<ModelComponent> refs)
ModelComponentBase
getHardReferences
in interface ModelComponent
getHardReferences
in class DynamicAttachmentBase
refs
- list to which hard references are appendedpublic void getSoftReferences(java.util.List<ModelComponent> refs)
ModelComponentBase
updateReferences()
method will
be called to update its internal reference information.getSoftReferences
in interface ModelComponent
getSoftReferences
in class ModelComponentBase
refs
- list to which soft references are appendedpublic void scaleDistance(double s)
ScalableUnits
scaleDistance
in interface ScalableUnits
s
- scaling factorpublic void scaleMass(double s)
ScalableUnits
scaleMass
in interface ScalableUnits
s
- scaling factorpublic PointSkinAttachment copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
CopyableComponent
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
.copy
in interface DynamicAttachmentComp
copy
in interface CopyableComponent
copy
in class PointAttachment
flags
- flags to control the copyingcopyMap
- map to possible existing instances of referenced
componentspublic void updateReferences(boolean undo, java.util.Deque<java.lang.Object> undoInfo)
undo
equal to false
,
this component should then examine its soft references and
use ComponentUtils.areConnected()
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
.updateReferences
in interface ModelComponent
updateReferences
in class ModelComponentBase
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.public void connectToHierarchy(CompositeComponent hcomp)
DynamicAttachmentBase
connectToHierarchy
in interface ModelComponent
connectToHierarchy
in class DynamicAttachmentBase
hcomp
- hierarchy component to which this component,
or its ancestor, was attachedpublic void disconnectFromHierarchy(CompositeComponent hcomp)
DynamicAttachmentBase
disconnectFromHierarchy
in interface ModelComponent
disconnectFromHierarchy
in class DynamicAttachmentBase
hcomp
- hierarchy component from which this component,
or its ancestor, was detachedpublic void transformGeometry(AffineTransform3dBase X)
TransformGeometryContext.transform (this, X, 0);
transformGeometry
in interface TransformableGeometry
X
- affine transformation to apply to the componentpublic void transformGeometry(GeometryTransformer gtr, TransformGeometryContext context, int flags)
gtr
to transform its individual attributes. The
context
argument supplies information about what other
components are currently being transformed, and also allows the
requesting of update actions to be performed after all transform called
have completed. The context is also the usual entity that calls
this method, from within its TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
method. The argument flags
provides flags to specify
various conditions associated with the the transformation.
At present, the available flags are TransformableGeometry.TG_SIMULATING
and
TransformableGeometry.TG_ARTICULATED
.
This method is not usually called directly by applications.
Instead, it is typically called from within the
TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
method of the context,
which takes care of the various operations needed for a
complete transform operation, including calling
TransformableGeometry.addTransformableDependencies(artisynth.core.modelbase.TransformGeometryContext, int)
to collect other
components that should be transformed, calling
TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
for each component, notifying
component parents that the geometry has changed, and calling
any requested TransformGeometryAction
s. More details
are given in the documentation for
TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
.
TransformGeometryContext
provides a number of
static convenience transform
methods
which take care of building the context and calling
apply()
for a specified set of components.
This method should not
generally call transformGeometry()
for its descendant
components. Instead, descendants needing transformation should be
specified by adding them to the context in the method TransformableGeometry.addTransformableDependencies(artisynth.core.modelbase.TransformGeometryContext, int)
.
transformGeometry
in interface TransformableGeometry
gtr
- transformer implementing the transformcontext
- context information, including what other components
are being transformedflags
- specifies conditions associated with the transformationpublic void addTransformableDependencies(TransformGeometryContext context, int flags)
context
any transformable components which should be
transformed as the same time as this component. This will generally
include descendant components, and may also include other components to
which this component is connected in some way.
This method is generally called from with the
TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
method of a
TransformGeometryContext
.
addTransformableDependencies
in interface TransformableGeometry
context
- context information, to which the dependent components
are added.flags
- specifies conditions associated with the transformationpublic void add1DConstraintBlocks(SparseBlockMatrix GT, int bj, double scale, ContactPoint cpnt, Vector3d dir)
ContactMaster
bj
,
while the block row(s) are determined internally by the solve indices of
the underlying dynamic components.add1DConstraintBlocks
in interface ContactMaster
GT
- constraint matrixbj
- block column indexscale
- TODOcpnt
- contact pointdir
- friction directionpublic void add2DConstraintBlocks(SparseBlockMatrix GT, int bj, double scale, ContactPoint cpnt, Vector3d dir0, Vector3d dir1)
ContactMaster
bj
, while the block row(s) are determined internally
by the solve indices of the underlying dynamic components.add2DConstraintBlocks
in interface ContactMaster
GT
- constraint matrixbj
- block column indexscale
- TODOcpnt
- contact pointdir0
- first friction directiondir1
- second friction directionpublic void addRelativeVelocity(Vector3d vel, double scale, ContactPoint cpnt)
ContactMaster
addRelativeVelocity
in interface ContactMaster
vel
- accumulates velocityscale
- TODOcpnt
- contact pointpublic void computeForceOnMasters(VectorNd uvec, Vector3d fc, double scale, ContactPoint cpnt, SparseBlockMatrix S)
ContactMaster
computeForceOnMasters
in interface ContactMaster
public boolean isControllable()
ContactMaster
isControllable
in interface ContactMaster
true
if at least one dynamic component is
controllablepublic int collectMasterComponents(java.util.HashSet<DynamicComponent> masters, boolean activeOnly)
ContactMaster
masters
, i.e., the number of components that were not already present
there.collectMasterComponents
in interface ContactMaster
masters
- set to which the dynamic components should be addedactiveOnly
- restrict collected components to those which are activepublic static void main(java.lang.String[] args)