public class TRCReader
extends java.lang.Object
Once read, marker data is exposed via a MarkerMotionData structure.
Constructor and Description |
---|
TRCReader(java.io.File file)
Creates a TRCReader for the indicated file.
|
TRCReader(java.io.InputStream is)
Creates a TRCReader for an specified input stream.
|
TRCReader(java.lang.String filePath)
Creates a TRCReader for the indicated file path.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
If the reader was created with an input stream instead of a file, closes
the input stream.
|
PositionInputProbe |
createInputProbe(java.lang.String name,
java.util.Collection<? extends Point> points,
boolean useTargetProps,
double startTime,
double stopTime)
Constructs a PositionInputProbe for the specified points based on the TRC
data.
|
static PositionInputProbe |
createInputProbe(java.lang.String name,
java.util.Collection<? extends Point> points,
java.io.File trcFile,
boolean useTargetProps)
Constructs a PositionInputProbe for the specified points based on data in
the supplied TRC file.
|
static PositionInputProbe |
createInputProbeFromLabels(java.lang.String name,
java.util.Collection<? extends Point> points,
java.util.List<java.lang.String> labels,
java.io.File trcFile,
boolean useTargetProps)
Constructs a PositionInputProbe for the specified points based on data in
the supplied TRC file.
|
PositionInputProbe |
createInputProbeUsingLabels(java.lang.String name,
java.util.Collection<? extends Point> points,
java.util.List<java.lang.String> labels,
boolean useTargetProps,
double startTime,
double stopTime)
Constructs a PositionInputProbe for the specified points based on the TRC
data.
|
double |
getFrameTime(int fidx)
Returns the time of the
fidx -th frame in the TRC data. |
int |
getMarkerIndex(java.lang.String label)
Returns the index of the indicated marker in the TRC data.
|
java.util.ArrayList<java.lang.String> |
getMarkerLabels()
Returns a list of the marker labels in the TRC data, or an empty list if
readData() has not yet been called. |
Point3d |
getMarkerPosition(int fidx,
int midx)
Returns the position of the
midx -th marker in the fidx -th
frame of the TRC data. |
Point3d |
getMarkerPosition(int fidx,
java.lang.String label)
Returns the position of the named marker in the
fidx -th frame of
the TRC data. |
java.util.ArrayList<Point3d> |
getMarkerPositions(int fidx)
Returns all the marker positions in the
fidx -th frame of
the TRC data. |
void |
getMarkerPositions(VectorNd mpos,
int fidx)
Returns all the marker positions in the
fidx -th frame of the TRC
data, loading the data into the composite vector mpos . |
MarkerMotionData |
getMotionData() |
int |
getNumFrames()
Deprecated.
Use
numFrames() instead. |
int |
getNumMarkers()
Deprecated.
Use
numMarkers() instead. |
static void |
main(java.lang.String[] args) |
int |
numFrames()
Returns the number of frames in the TRC data, or 0 if
readData()
has not yet been called. |
int |
numMarkers()
Returns the number of markers in the TRC data, or 0 if
readData()
has not yet been called. |
void |
readData()
Reads the TRC data from the file or input stream.
|
public TRCReader(java.io.InputStream is)
is
- inout stream for reading the TRC datapublic TRCReader(java.io.File file) throws java.io.IOException
file
- TRC file to be readjava.io.IOException
public TRCReader(java.lang.String filePath) throws java.io.IOException
filePath
- path name of the TRC file to be readjava.io.IOException
public MarkerMotionData getMotionData()
public int getNumFrames()
numFrames()
instead.public int numFrames()
readData()
has not yet been called.public int getNumMarkers()
numMarkers()
instead.public int numMarkers()
readData()
has not yet been called.public java.util.ArrayList<java.lang.String> getMarkerLabels()
readData()
has not yet been called.public double getFrameTime(int fidx)
fidx
-th frame in the TRC data. Note that
fidx
is 0-based, and so will be one less than the corresponding
frame number in the data. An exception will be thrown if if readData()
has not yet been called.fidx
public Point3d getMarkerPosition(int fidx, int midx)
midx
-th marker in the fidx
-th
frame of the TRC data. Note that midx
and fidx
are both
0-based, and so fidx
will be one less than the corresponding
frame number in the data. An exception will be thrown if readData()
has not yet been called.idx
in frame fidx
. Should not
be modified.public Point3d getMarkerPosition(int fidx, java.lang.String label)
fidx
-th frame of
the TRC data. Note that fidx
is 0-based, and so will be one less
than the corresponding frame number in the data. null
will be
returned if the marker is not found or readData()
has not yet been
called.idx
in frame fidx
. Should not
be modified.public java.util.ArrayList<Point3d> getMarkerPositions(int fidx)
fidx
-th frame of
the TRC data. Note that fidx
is 0-based, and so will be one less
than the corresponding frame number in the data. An exception will be
thrown if readData()
has not yet been called.fidx
. Should not
be modified.public void getMarkerPositions(VectorNd mpos, int fidx)
fidx
-th frame of the TRC
data, loading the data into the composite vector mpos
. If
necessary, mpos
will be resized to 3 m, where m is the number of
markers. Note that fidx
is 0-based, and so will be one less than
the corresponding frame number in the data. An exception will be thrown
if readData()
has not yet been called.mpos
- returns all marker positions for frame fidx
. Is
resized if necessary.public int getMarkerIndex(java.lang.String label)
readData()
has not yet been
called.label
- name of the desired markerpublic void readData() throws java.io.IOException
java.io.IOException
public void close()
readData
.public static void main(java.lang.String[] args)
public PositionInputProbe createInputProbeUsingLabels(java.lang.String name, java.util.Collection<? extends Point> points, java.util.List<java.lang.String> labels, boolean useTargetProps, double startTime, double stopTime)
labels
gives the labels of the TRC marker data
that should be used for each point; if labels
is null
,
then each point's name is used instead. If the specified label (or point
name) is not found in the TRC data, an exception is thrown.
If the first TRC frame does not have a time of 0, this initial time will be subtracted from the time for the probe data (so that the probe data will begin at time 0).
name
- if non-null, gives the name of the probepoints
- points to be controlled by the probelabels
- if non-null
, gives labels of the TRC marker data
that should be used for the points.useTargetProps
- if true
, causes the probe to
bind to the point's targetPosition
property instead of position
startTime
- start time of the probestopTime
- stop time of the probepublic PositionInputProbe createInputProbe(java.lang.String name, java.util.Collection<? extends Point> points, boolean useTargetProps, double startTime, double stopTime)
n
points is taken from the data
for the first n
markers, regardless of their labels. The number
of markers in the TRC data must therefore equal or exceed n
. If
the first TRC frame does not have a time of 0, this initial time will be
subtracted from the time for the probe data (so that the probe data will
begin at time 0).name
- if non-null, gives the name of the probepoints
- points to be controlled by the probeuseTargetProps
- if true
, causes the probe to
bind to the point's targetPosition
property instead of position
startTime
- start time of the probestopTime
- stop time of the probepublic static PositionInputProbe createInputProbeFromLabels(java.lang.String name, java.util.Collection<? extends Point> points, java.util.List<java.lang.String> labels, java.io.File trcFile, boolean useTargetProps) throws java.io.IOException
createInputProbeUsingLabels(String,Collection,List,boolean,double,double)
.name
- if non-null, gives the name of the probepoints
- points to be controlled by the probelabels
- if non-null
, gives labels of the TRC marker data
that should be used for the points.trcFile
- TRC file providing the probe data.useTargetProps
- if true
, causes the probe to
bind to the point's targetPosition
property instead of position
java.io.IOException
public static PositionInputProbe createInputProbe(java.lang.String name, java.util.Collection<? extends Point> points, java.io.File trcFile, boolean useTargetProps) throws java.io.IOException
createInputProbe(String,Collection,boolean,double,double)
.name
- if non-null, gives the name of the probepoints
- points to be controlled by the probetrcFile
- TRC file providing the probe data.useTargetProps
- if true
, causes the probe to
bind to the point's targetPosition
property instead of position
java.io.IOException