artisynth.core.femmodels
Class MuscleBundle

java.lang.Object
  extended by artisynth.core.modelbase.ModelComponentBase
      extended by artisynth.core.modelbase.CompositeComponentBase
          extended by artisynth.core.femmodels.MuscleBundle
All Implemented Interfaces:
ExcitationComponent, RequiresInitialize, ComponentChangeListener, CompositeComponent, IndexedComponentList, ModelComponent, RenderableComponent, TransformableGeometry, java.lang.Cloneable, HasProperties, HierarchyNode, GLRenderable, GLSelectable, HasRenderProps, Renderable, Scannable

public class MuscleBundle
extends CompositeComponentBase
implements ExcitationComponent, RenderableComponent, TransformableGeometry


Nested Class Summary
static class MuscleBundle.DirectionRenderType
           
 
Nested classes/interfaces inherited from interface artisynth.core.mechmodels.ExcitationComponent
ExcitationComponent.CombinationRule
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.ModelComponent
ModelComponent.NavpanelVisibility
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.CompositeComponent
CompositeComponent.NavpanelDisplay
 
Field Summary
static PropertyList myProps
           
 
Fields inherited from class artisynth.core.modelbase.ModelComponentBase
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
 
Fields inherited from interface maspack.render.GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
 
Fields inherited from interface artisynth.core.util.TransformableGeometry
ARTICULATED, SIMULATING
 
Constructor Summary
MuscleBundle()
           
MuscleBundle(java.lang.String name)
           
 
Method Summary
 void addElement(MuscleElementDesc desc)
           
 void addElementsNearFibres(double dist)
           
 void addExcitationSource(ExcitationComponent ex)
          Adds a new excitation source to this Excitable, with an assumed gain of 1.
 void addExcitationSource(ExcitationComponent ex, double gain)
          Adds a new excitation source to this Excitable with a specified gain.
 void addFascicle(java.util.LinkedList<Muscle> fascicle)
           
 void addFiberMeshElements(double rad, PolylineMesh mesh)
           
 void addFibre(Muscle fibre)
           
 void addPosJacobian(SparseNumberedBlockMatrix M, double h)
           
 void addSolveBlocks(SparseNumberedBlockMatrix S)
           
 void addVelJacobian(SparseNumberedBlockMatrix M, double h)
           
 void applyForce(double t)
           
 void clearElements()
           
 void clearFascicles()
           
 void clearFibres()
           
 void computeElementDirections()
          Computes the directions within individual elements based on the directions of the muscle fibres.
 void connectToHierarchy()
          Called by the system after this component is added to the component hierarchy (i.e., when it is added as a child of another CompositeComponent).
 MuscleMaterial createMuscleMaterial()
           
 RenderProps createRenderProps()
          Factory method to create render properties appropriate to this object.
 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).
 PropertyList getAllPropertyInfo()
          Returns a list giving static information about all properties exported by this object.
static FemModel3d getAncestorFem(ModelComponent comp)
           
 ExcitationComponent.CombinationRule getCombinationRule()
          Return the combination rule for excitations.
 double getDefaultActivationWeight()
          Returns the default weight that should be used when this excitation component is being used for inverse actuation control.
 double getDirectionRenderLen()
           
 PropertyMode getDirectionRenderLenMode()
           
 MuscleBundle.DirectionRenderType getDirectionRenderType()
           
 PropertyMode getDirectionRenderTypeMode()
           
 MuscleElementDescList getElements()
           
 double getElementWidgetSize()
           
 PropertyMode getElementWidgetSizeMode()
           
 double getExcitation()
          Returns the primary excitation for this component.
 java.awt.Color getExcitationColor()
           
 PropertyMode getExcitationColorMode()
           
 double getExcitationGain(ExcitationComponent ex)
          Gets the gain for an excitation source in this component.
 java.util.ArrayList<java.util.LinkedList<Muscle>> getFascicles()
           
 Vector3d[] getFibreRestDirections()
           
 DelaunayInterpolator getFibreRestDistanceInterpolator()
           
 AxialSpringList<Muscle> getFibres()
           
 boolean getFibresActive()
           
 double getMaxColoredExcitation()
           
 PropertyMode getMaxColoredExcitationMode()
           
 MuscleMaterial getMuscleMaterial()
           
 double getNetExcitation()
          Returns the net excitation for this Excitable.
 java.util.LinkedList<MuscleElementDesc> getNewElementsNearFibres(double dist)
          Returns a list of MuscleElementDesc identifying all elements that are (a) within a specified distance of the fibres, and (b) not already referenced by this bundle.
 int getRenderHints()
          Returns a bit code giving rendering hints about this renderable.
 RenderProps getRenderProps()
          Returns the render properities for this object.
 void getSelection(java.util.LinkedList<java.lang.Object> list, int qid)
          Append to list the component (or components) associated with the qid-th selection query issued by this component's render method.
 void getSoftReferences(java.util.List<ModelComponent> refs)
          Appends all soft references for this component to a list.
 void initialize(double t)
          Called from within the model's initialize() method.
 boolean isSelectable()
          Returns true if this object is in fact selectable.
 int numSelectionQueriesNeeded()
          If this selectable manages its own selection (by issuing selection queries within its render method), then this method should return the maximum number of selection queries that will be required.
 void prerender(RenderList list)
          Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.
 boolean removeElement(MuscleElementDesc desc)
           
 boolean removeExcitationSource(ExcitationComponent ex)
          Removes an excitation source from this Excitable.
 boolean removeFibre(Muscle fibre)
           
 void render(GLRenderer renderer, int flags)
          Render this object using Open GL via the JOGL.
 void scaleDistance(double s)
           
 void scaleMass(double s)
           
 void setCombinationRule(ExcitationComponent.CombinationRule rule)
          Sets the rule for combining excitations.
 void setDefaultValues()
          Sets the attributes of this component to their default values.
 void setDirectionRenderLen(double size)
           
 void setDirectionRenderLenMode(PropertyMode mode)
           
 void setDirectionRenderType(MuscleBundle.DirectionRenderType type)
           
 void setDirectionRenderTypeMode(PropertyMode mode)
           
 void setElementWidgetSize(double size)
           
 void setElementWidgetSizeMode(PropertyMode mode)
           
 void setExcitation(double a)
          Sets the primary excitation for this component.
 void setExcitationColor(java.awt.Color color)
           
 void setExcitationColorMode(PropertyMode mode)
           
 boolean setExcitationGain(ExcitationComponent ex, double gain)
          Sets the gain for an excitation source in this component.
 void setFibresActive(boolean active)
           
 void setMaxColoredExcitation(double excitation)
           
 void setMaxColoredExcitationMode(PropertyMode mode)
           
 void setMaxForce(double maxForce)
           
 void setMuscleMaterial(MuscleMaterial mat)
           
 void setRenderProps(RenderProps props)
          Assigns a new set of render properties to this object.
 void transformGeometry(AffineTransform3dBase X)
          Applies an affine transformation to the geometry of this object.
 void transformGeometry(AffineTransform3dBase X, TransformableGeometry topObject, int flags)
          Applies an affine transformation to the geometry of this object.
 void updateBounds(Point3d pmin, Point3d pmax)
          Update the minimum and maximum points for this object.
 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.
 
Methods inherited from class artisynth.core.modelbase.CompositeComponentBase
componentChanged, copy, findComponent, get, get, getByNumber, getChildren, getNavpanelDisplay, getNumberLimit, hasChildren, hasState, hierarchyContainsReferences, indexOf, iterator, numComponents, postscan, scan, setDisplayMode, updateNameMap
 
Methods inherited from class artisynth.core.modelbase.ModelComponentBase
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, createTempFlag, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, 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, postscan, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected
 
Methods inherited from interface maspack.properties.HasProperties
getProperty
 
Methods inherited from interface maspack.properties.HierarchyNode
getChildren, hasChildren
 
Methods inherited from interface maspack.util.Scannable
isWritable, write
 

Field Detail

myProps

public static PropertyList myProps
Constructor Detail

MuscleBundle

public MuscleBundle()

MuscleBundle

public MuscleBundle(java.lang.String name)
Method Detail

setDefaultValues

public void setDefaultValues()
Description copied from class: ModelComponentBase
Sets the attributes of this component to their default values.


getExcitationColor

public java.awt.Color getExcitationColor()

setExcitationColor

public void setExcitationColor(java.awt.Color color)

getExcitationColorMode

public PropertyMode getExcitationColorMode()

setExcitationColorMode

public void setExcitationColorMode(PropertyMode mode)

getMaxColoredExcitation

public double getMaxColoredExcitation()

setMaxColoredExcitation

public void setMaxColoredExcitation(double excitation)

getMaxColoredExcitationMode

public PropertyMode getMaxColoredExcitationMode()

setMaxColoredExcitationMode

public void setMaxColoredExcitationMode(PropertyMode mode)

getFibresActive

public boolean getFibresActive()

setFibresActive

public void setFibresActive(boolean active)

getAllPropertyInfo

public PropertyList getAllPropertyInfo()
Description copied from interface: HasProperties
Returns a list giving static information about all properties exported by this object.

Specified by:
getAllPropertyInfo in interface HasProperties
Overrides:
getAllPropertyInfo in class ModelComponentBase
Returns:
static information for all exported properties

setElementWidgetSize

public void setElementWidgetSize(double size)

getElementWidgetSize

public double getElementWidgetSize()

setElementWidgetSizeMode

public void setElementWidgetSizeMode(PropertyMode mode)

getElementWidgetSizeMode

public PropertyMode getElementWidgetSizeMode()

setDirectionRenderLen

public void setDirectionRenderLen(double size)

getDirectionRenderLen

public double getDirectionRenderLen()

setDirectionRenderLenMode

public void setDirectionRenderLenMode(PropertyMode mode)

getDirectionRenderLenMode

public PropertyMode getDirectionRenderLenMode()

setDirectionRenderType

public void setDirectionRenderType(MuscleBundle.DirectionRenderType type)

getDirectionRenderType

public MuscleBundle.DirectionRenderType getDirectionRenderType()

setDirectionRenderTypeMode

public void setDirectionRenderTypeMode(PropertyMode mode)

getDirectionRenderTypeMode

public PropertyMode getDirectionRenderTypeMode()

getExcitation

public double getExcitation()
Returns the primary excitation for this component.

Specified by:
getExcitation in interface ExcitationComponent
Returns:
primary excitation value

initialize

public void initialize(double t)
Called from within the model's initialize() method.

Specified by:
initialize in interface RequiresInitialize
Parameters:
t - initialization time (seconds)

setExcitation

public void setExcitation(double a)
Sets the primary excitation for this component.

Specified by:
setExcitation in interface ExcitationComponent
Parameters:
a - excitation value

setCombinationRule

public void setCombinationRule(ExcitationComponent.CombinationRule rule)
Sets the rule for combining excitations.

Specified by:
setCombinationRule in interface ExcitationComponent
Parameters:
rule - rule for combining excitations

getCombinationRule

public ExcitationComponent.CombinationRule getCombinationRule()
Return the combination rule for excitations.

Specified by:
getCombinationRule in interface ExcitationComponent
Returns:
combination rule for excitations

addExcitationSource

public void addExcitationSource(ExcitationComponent ex)
Adds a new excitation source to this Excitable, with an assumed gain of 1.

Specified by:
addExcitationSource in interface ExcitationComponent
Parameters:
ex - excitatation source to be added

addExcitationSource

public void addExcitationSource(ExcitationComponent ex,
                                double gain)
Adds a new excitation source to this Excitable with a specified gain.

Specified by:
addExcitationSource in interface ExcitationComponent
Parameters:
ex - excitatation source to be added
gain - gain for the source

removeExcitationSource

public boolean removeExcitationSource(ExcitationComponent ex)
Removes an excitation source from this Excitable. Returns false if the source was not present.

Specified by:
removeExcitationSource in interface ExcitationComponent
Parameters:
ex - excitatation source to be removed
Returns:
true if the source was present and removed

getExcitationGain

public double getExcitationGain(ExcitationComponent ex)
Gets the gain for an excitation source in this component.

Specified by:
getExcitationGain in interface ExcitationComponent
Parameters:
ex - excitatation source whose gain is to be queried
Returns:
source gain value, or -1 if the source is not present in this component.

setExcitationGain

public boolean setExcitationGain(ExcitationComponent ex,
                                 double gain)
Sets the gain for an excitation source in this component.

Specified by:
setExcitationGain in interface ExcitationComponent
Parameters:
ex - excitatation source whose gain is to be modified
gain - new gain for the source
Returns:
false if the source is not present in this component.

getNetExcitation

public double getNetExcitation()
Returns the net excitation for this Excitable. The net excitation is the combination of the primary excitation and the net excitations of all the excitation sources.

Specified by:
getNetExcitation in interface ExcitationComponent

getSoftReferences

public void getSoftReferences(java.util.List<ModelComponent> refs)
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

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.

getDefaultActivationWeight

public double getDefaultActivationWeight()
Returns the default weight that should be used when this excitation component is being used for inverse actuation control. For muscle tissue we are using the average max force (proportional to physiological cross-sectional area) for all fibers within the bundle. Note: we could also use spatial distribution of fibres to determine CSA instead.

Specified by:
getDefaultActivationWeight in interface ExcitationComponent

getMuscleMaterial

public MuscleMaterial getMuscleMaterial()

createMuscleMaterial

public MuscleMaterial createMuscleMaterial()

setMuscleMaterial

public void setMuscleMaterial(MuscleMaterial mat)

applyForce

public void applyForce(double t)

setMaxForce

public void setMaxForce(double maxForce)

addPosJacobian

public void addPosJacobian(SparseNumberedBlockMatrix M,
                           double h)

addVelJacobian

public void addVelJacobian(SparseNumberedBlockMatrix M,
                           double h)

addSolveBlocks

public void addSolveBlocks(SparseNumberedBlockMatrix S)

getFibres

public AxialSpringList<Muscle> getFibres()

addFibre

public void addFibre(Muscle fibre)

removeFibre

public boolean removeFibre(Muscle fibre)

clearFibres

public void clearFibres()

getElements

public MuscleElementDescList getElements()

addElement

public void addElement(MuscleElementDesc desc)

removeElement

public boolean removeElement(MuscleElementDesc desc)

clearElements

public void clearElements()

getAncestorFem

public static FemModel3d getAncestorFem(ModelComponent comp)

getNewElementsNearFibres

public java.util.LinkedList<MuscleElementDesc> getNewElementsNearFibres(double dist)
Returns a list of MuscleElementDesc identifying all elements that are (a) within a specified distance of the fibres, and (b) not already referenced by this bundle.


addElementsNearFibres

public void addElementsNearFibres(double dist)

addFiberMeshElements

public void addFiberMeshElements(double rad,
                                 PolylineMesh mesh)

getFibreRestDistanceInterpolator

public DelaunayInterpolator getFibreRestDistanceInterpolator()

getFibreRestDirections

public Vector3d[] getFibreRestDirections()

computeElementDirections

public void computeElementDirections()
Computes the directions within individual elements based on the directions of the muscle fibres.


createRenderProps

public RenderProps createRenderProps()
Description copied from interface: HasRenderProps
Factory method to create render properties appropriate to this object.

Specified by:
createRenderProps in interface HasRenderProps
Returns:
new render properties for this object

getRenderProps

public RenderProps getRenderProps()
Description copied from interface: HasRenderProps
Returns the render properities for this object. If no render properties are assigned, this routines returns null.

Specified by:
getRenderProps in interface HasRenderProps
Returns:
current render properties for this object

setRenderProps

public void setRenderProps(RenderProps props)
Description copied from interface: HasRenderProps
Assigns a new set of render properties to this object. An argument of null will remove render properties from this object.

Specified by:
setRenderProps in interface HasRenderProps
Parameters:
props - new render properties for this object

prerender

public void prerender(RenderList list)
Description copied from interface: GLRenderable
Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.

Specified by:
prerender in interface GLRenderable

render

public void render(GLRenderer renderer,
                   int flags)
Description copied from interface: GLRenderable
Render this object using Open GL via the JOGL.

Specified by:
render in interface GLRenderable
Parameters:
renderer - renderer object which is used to perform the rendering. Provides pointers to GL and GLU, along with helper functions.
flags - supplies flags that may be used to control different aspects of the rendering. Flags are defined in GLRenderer and currently include GLRenderer.SELECTED, GLRenderer.VERTEX_COLORING, GLRenderer.HSV_COLOR_INTERPOLATION, GLRenderer.SORT_FACES, and GLRenderer.CLEAR_MESH_DISPLAY_LISTS.

isSelectable

public boolean isSelectable()
Returns true if this object is in fact selectable.

Specified by:
isSelectable in interface GLSelectable
Returns:
true if this object is selectable

numSelectionQueriesNeeded

public int numSelectionQueriesNeeded()
Description copied from interface: GLSelectable
If this selectable manages its own selection (by issuing selection queries within its render method), then this method should return the maximum number of selection queries that will be required. Otherwise, this method should return -1.

Specified by:
numSelectionQueriesNeeded in interface GLSelectable
Returns:
maximum number of selection queries needed by this component, or -1 if this component does not manage its own selection.

updateBounds

public void updateBounds(Point3d pmin,
                         Point3d pmax)
Description copied from interface: GLRenderable
Update the minimum and maximum points for this object. In an x-y-z coordinate system with x directed to the right and y directed upwards, the minimum and maximum points can be thought of as defining the left-lower-far and right-upper-near corners of a bounding cube. This method should only reduce the elements of the minimum point and increase the elements of the maximum point, since it may be used as part of an iteration to determine the bounding cube for several different objects.

Specified by:
updateBounds in interface GLRenderable
Parameters:
pmin - minimum point
pmax - maximum point

getRenderHints

public int getRenderHints()
Description copied from interface: GLRenderable
Returns a bit code giving rendering hints about this renderable. Current bit codes include TRANSLUCENT.

Specified by:
getRenderHints in interface GLRenderable
Returns:
bit code of rendering hints.

getSelection

public void getSelection(java.util.LinkedList<java.lang.Object> list,
                         int qid)
Description copied from interface: GLSelectable
Append to list the component (or components) associated with the qid-th selection query issued by this component's render method. This will only be called if this component manages its own selection (i.e., the number nums returned by GLSelectable.numSelectionQueriesNeeded() is positive), and qid will in turn be a number between 0 and nums-1.

Specified by:
getSelection in interface GLSelectable
Parameters:
list - selected objects are appended to the end of this list
qid - index of the selection query

scaleDistance

public void scaleDistance(double s)

scaleMass

public void scaleMass(double s)

connectToHierarchy

public void connectToHierarchy()
Description copied from class: ModelComponentBase
Called by the system after this component is added to the component hierarchy (i.e., when it is added as a child of another CompositeComponent). This method is responsible for doing any required hierarchy-dependent initialization.

When this method is called, ModelComponent.getParent() will return the new parent component; the system will have set this beforehand.

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

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

addFascicle

public void addFascicle(java.util.LinkedList<Muscle> fascicle)

getFascicles

public java.util.ArrayList<java.util.LinkedList<Muscle>> getFascicles()

clearFascicles

public void clearFascicles()

transformGeometry

public void transformGeometry(AffineTransform3dBase X)
Description copied from interface: TransformableGeometry
Applies an affine transformation to the geometry of this object. This method should be equivalent to
 transformGeometry (X, this, 0);
 

Specified by:
transformGeometry in interface TransformableGeometry
Parameters:
X - affine transformation

transformGeometry

public void transformGeometry(AffineTransform3dBase X,
                              TransformableGeometry topObject,
                              int flags)
Description copied from interface: TransformableGeometry
Applies an affine transformation to the geometry of this object. If recursively invoked within a component hierarchy, then topComponent should be the component for which the method was initially invoked. The variable flags provides information about the context in which the transformation is being applied. At present, the available flags are TransformableGeometry.SIMULATING and TransformableGeometry.ARTICULATED.

Specified by:
transformGeometry in interface TransformableGeometry
Parameters:
X - affine transformation
topObject - component on which the method was initially invoked
flags - provides information about the context in which the transformation is being applied.