public class TransformGeometryContext
extends java.lang.Object
TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
methods have been
called. The transform operation is carried out by the context's
apply(maspack.geometry.GeometryTransformer, int)
method.Modifier and Type | Field and Description |
---|---|
static int |
IS_TRANSFORMED |
Constructor and Description |
---|
TransformGeometryContext()
Creates a new TransformGeometryContext.
|
TransformGeometryContext(java.lang.Iterable<? extends TransformableGeometry> tgens)
Creates a new TransformGeometryContext and adds a set of
transformable components to it.
|
TransformGeometryContext(TransformableGeometry tg)
Creates a new TransformGeometryContext and adds a single
transformable component to it.
|
TransformGeometryContext(TransformableGeometry[] tgens)
Creates a new TransformGeometryContext and adds a set of
transformable components to it.
|
Modifier and Type | Method and Description |
---|---|
void |
add(TransformableGeometry tg)
Adds a transformable component to this context.
|
void |
add(TransformableGeometry tg,
int flags)
Adds a transformable component to this context, with the specified
flags settings.
|
void |
addAction(TransformGeometryAction action)
Adds an action to be called within the
apply(maspack.geometry.GeometryTransformer, int) method
after the TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
methods have been called for all the transformables. |
void |
addAll(java.util.Collection<? extends TransformableGeometry> tgens)
Adds a set of transformable components to this context.
|
void |
addParentToNotify(CompositeComponent comp)
Adds a parent component to be notified of the change in geometry
using a
GeometryChangeEvent . |
void |
addTransformableDescendants(CompositeComponent comp,
int flags)
Adds transformable descendants of a composite component to this context.
|
boolean |
allTransformed(java.util.Collection<? extends TransformableGeometry> tgens)
Returns
true if all members of a specified set of
transformable components are marked as having been transformed. |
boolean |
allTransformed(TransformableGeometry[] tgens)
Returns
true if all members of a specified set of
transformable components are marked as having been transformed. |
void |
apply(GeometryTransformer gtr,
int flags)
Applies a geometry transformation to all the transformable
components currently stored in this context.
|
boolean |
contains(TransformableGeometry tg)
Returns
true if a specified transformable component
is contained in this context. |
boolean |
containsAction(TransformGeometryAction action)
Returns
true if this context contains the specified
action. |
boolean |
containsAll(java.lang.Iterable<? extends TransformableGeometry> tgens)
Returns
true if all members of a set of transformable
components are contained in this context. |
boolean |
containsAll(TransformableGeometry[] tgens)
Returns
true if all members of a set of transformable
components are contained in this context. |
boolean |
containsAny(java.lang.Iterable<? extends TransformableGeometry> tgens)
Returns
true if any member of a set of transformable
components is contained in this context. |
boolean |
containsAny(TransformableGeometry[] tgens)
Returns
true if any member of a set of transformable
components is contained in this context. |
boolean |
containsParentToNotify(CompositeComponent comp)
Returns
true if this context contains the
specified parent component to notified of the change in geometry. |
java.util.Set<TransformableGeometry> |
getTransformables()
Returns a set view of all the transformable components contained in this
context.
|
boolean |
isTransformed(TransformableGeometry tg)
Returns
true if a specified transformable component
is marked as having been transformed. |
void |
markTransformed(TransformableGeometry tg)
Mark a specified transformable component as having been transformed.
|
int |
numTransformables()
Returns the number of transformable components in this context.
|
static void |
transform(java.lang.Iterable<TransformableGeometry> tgens,
AffineTransform3dBase X,
int flags)
Applies a rigid or affine transform to a specified set of transformable
components.
|
static void |
transform(java.lang.Iterable<TransformableGeometry> tgens,
GeometryTransformer gtr,
int flags)
Applies a geometry transform to a specified set of transformable
components.
|
static void |
transform(TransformableGeometry[] tgens,
AffineTransform3dBase X,
int flags)
Applies a rigid or affine transform to a specified set of transformable
components.
|
static void |
transform(TransformableGeometry[] tgens,
GeometryTransformer gtr,
int flags)
Applies a geometry transform to a specified set of transformable
components.
|
static void |
transform(TransformableGeometry tg,
AffineTransform3dBase X,
int flags)
Applies a rigid or affine transform to a specified transformable
component.
|
static void |
transform(TransformableGeometry tg,
GeometryTransformer gtr,
int flags)
Applies a geometry transform to a specified transformable component.
|
public static final int IS_TRANSFORMED
public TransformGeometryContext()
public TransformGeometryContext(TransformableGeometry tg)
tg
- transformable component to addpublic TransformGeometryContext(java.lang.Iterable<? extends TransformableGeometry> tgens)
tgens
- transformable components to addpublic TransformGeometryContext(TransformableGeometry[] tgens)
tgens
- transformable components to addpublic void add(TransformableGeometry tg)
tg
- transformable component to addpublic void add(TransformableGeometry tg, int flags)
tg
- transformable component to addflags
- flag settings for the componentadd(TransformableGeometry)
public void addAll(java.util.Collection<? extends TransformableGeometry> tgens)
tgens
- transformable components to addadd(TransformableGeometry)
public boolean contains(TransformableGeometry tg)
true
if a specified transformable component
is contained in this context.tg
- transformable component to checktrue
if tg
is
contained in this context.public boolean containsAll(java.lang.Iterable<? extends TransformableGeometry> tgens)
true
if all members of a set of transformable
components are contained in this context.tgens
- transformable components to checktrue
if all components are
contained in this context.public boolean containsAll(TransformableGeometry[] tgens)
true
if all members of a set of transformable
components are contained in this context.tgens
- transformable components to checktrue
if all components are
contained in this context.public java.util.Set<TransformableGeometry> getTransformables()
public boolean containsAny(java.lang.Iterable<? extends TransformableGeometry> tgens)
true
if any member of a set of transformable
components is contained in this context.tgens
- transformable components to checktrue
if any of the components are
contained in this context.public boolean containsAny(TransformableGeometry[] tgens)
true
if any member of a set of transformable
components is contained in this context.tgens
- transformable components to checktrue
if any of the components are
contained in this context.public int numTransformables()
public boolean isTransformed(TransformableGeometry tg)
true
if a specified transformable component
is marked as having been transformed. Components are automatically
marked as having been transformed after their
TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
method
is called within this context's apply(maspack.geometry.GeometryTransformer, int)
method. Components
can also be marked as being transformed using
markTransformed(artisynth.core.modelbase.TransformableGeometry)
. The apply(maspack.geometry.GeometryTransformer, int)
method will not
call the TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
method
for any component which is already marked as transformed.tg
- component to checktrue
if tg
is marked as transformedpublic void markTransformed(TransformableGeometry tg)
tg
- component to mark as transformedpublic boolean allTransformed(java.util.Collection<? extends TransformableGeometry> tgens)
true
if all members of a specified set of
transformable components are marked as having been transformed.
For more information on what this means, see isTransformed(artisynth.core.modelbase.TransformableGeometry)
.tgens
- components to checktrue
if all components are marked as transformedpublic boolean allTransformed(TransformableGeometry[] tgens)
true
if all members of a specified set of
transformable components are marked as having been transformed.
For more information on what this means, see isTransformed(artisynth.core.modelbase.TransformableGeometry)
.tgens
- components to checktrue
if all components are marked as transformedpublic void addAction(TransformGeometryAction action)
apply(maspack.geometry.GeometryTransformer, int)
method
after the TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
methods have been called for all the transformables. Actions
are stored as a set, so the same action can only be
added once.action
- action to be called after all
transformGeometry
methods.public boolean containsAction(TransformGeometryAction action)
true
if this context contains the specified
action.action
- action to be checkedtrue
if this context contains action
public void addParentToNotify(CompositeComponent comp)
GeometryChangeEvent
. More information about when
the notification occurs is contained in the documentation for
the apply(maspack.geometry.GeometryTransformer, int)
method. Parents to be notified are stored as a set,
and so cannot be added twice.comp
- parent component to be notifiedpublic boolean containsParentToNotify(CompositeComponent comp)
true
if this context contains the
specified parent component to notified of the change in geometry.comp
- component to be testedtrue
if comp
is contained
in this contextpublic void apply(GeometryTransformer gtr, int flags)
TransformableGeometry.addTransformableDependencies(artisynth.core.modelbase.TransformGeometryContext, int)
for
each transformable to add additional components that need
to be transformed, such as descendants or certain connected components.
TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
for
each transformable, and then use markTransformed(artisynth.core.modelbase.TransformableGeometry)
to
mark that component as being transformed. The call is skipped
for components that have already been marked as being transformed.
This gives the components some ability to control the transform
process: within the transformGeometry
method for
component A, it may be desirable to call the
transformGeometry
method for another component B
directly. Component A may do so, and then mark B as being transformed.
GeometryChangeEvent
to any parent components
for which notification was requested (using addParentToNotify(artisynth.core.modelbase.CompositeComponent)
)
during step 2.
TransformGeometryAction.transformGeometry(maspack.geometry.GeometryTransformer, artisynth.core.modelbase.TransformGeometryContext, int)
method of any actions that were requested (
using addAction(artisynth.core.modelbase.TransformGeometryAction)
)
by the transformGeometry
methods called during step 2.
The actions themselves may request additional actions; the process
will continue until all actions have been called.
GeometryChangeEvent
to all the parents of
the transformable components, along with any additional parent
components for which notification was requested during step 4.
gtr
- transformation to applyflags
- specifies conditions associated with the transformationpublic void addTransformableDescendants(CompositeComponent comp, int flags)
comp
. When a transformable is
found, it is added to this context, and its
TransformableGeometry.addTransformableDependencies(artisynth.core.modelbase.TransformGeometryContext, int)
method
is called to add any dependencies of that component to this context.comp
- component for which transformable descendants should be addedflags
- specifies conditions associated with the transformationpublic static void transform(TransformableGeometry tg, GeometryTransformer gtr, int flags)
apply(maspack.geometry.GeometryTransformer, int)
method
is called.tg
- component to transformgtr
- transformer to effect the transformationflags
- specifies conditions associated with the transformationpublic static void transform(java.lang.Iterable<TransformableGeometry> tgens, GeometryTransformer gtr, int flags)
apply(maspack.geometry.GeometryTransformer, int)
method is called.tgens
- components to transformgtr
- transformer to effect the transformationflags
- specifies conditions associated with the transformationpublic static void transform(TransformableGeometry[] tgens, GeometryTransformer gtr, int flags)
apply(maspack.geometry.GeometryTransformer, int)
method is called.tgens
- components to transformgtr
- transformer to effect the transformationflags
- specifies conditions associated with the transformationpublic static void transform(TransformableGeometry tg, AffineTransform3dBase X, int flags)
apply(maspack.geometry.GeometryTransformer, int)
method is called using a transformer created for X
.tg
- component to transformX
- rigid or affine transform (used to create the transformer)flags
- specifies conditions associated with the transformationpublic static void transform(java.lang.Iterable<TransformableGeometry> tgens, AffineTransform3dBase X, int flags)
apply(maspack.geometry.GeometryTransformer, int)
method is called using a transformer created for
X
.tgens
- components to transformX
- rigid or affine transform (used to create the transformer)flags
- specifies conditions associated with the transformationpublic static void transform(TransformableGeometry[] tgens, AffineTransform3dBase X, int flags)
apply(maspack.geometry.GeometryTransformer, int)
method is called using a transformer created for
X
.tgens
- components to transformX
- rigid or affine transform (used to create the transformer)flags
- specifies conditions associated with the transformation