Search in sources :

Example 1 with ObjectToken

use of artisynth.core.util.ObjectToken in project artisynth_core by artisynth.

the class PointFem3dAttachment method scanNodes.

protected static void scanNodes(ReaderTokenizer rtok, Deque<ScanToken> tokens) throws IOException {
    ArrayList<Double> coordList = new ArrayList<Double>();
    rtok.scanToken('[');
    // begin token
    tokens.offer(ScanToken.BEGIN);
    while (ScanWriteUtils.scanAndStoreReference(rtok, tokens)) {
        coordList.add(rtok.scanNumber());
    }
    if (rtok.ttype != ']') {
        throw new IOException("Expected ']', got " + rtok);
    }
    // terminator token
    tokens.offer(ScanToken.END);
    tokens.offer(new ObjectToken(ArraySupport.toDoubleArray(coordList)));
}
Also used : ObjectToken(artisynth.core.util.ObjectToken) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 2 with ObjectToken

use of artisynth.core.util.ObjectToken in project artisynth_core by artisynth.

the class MFreeMeshComp method scanAttachment.

protected void scanAttachment(ReaderTokenizer rtok, Deque<ScanToken> tokens) throws IOException {
    ArrayList<Double> weights = new ArrayList<Double>();
    rtok.scanToken('[');
    tokens.offer(ScanToken.BEGIN);
    while (ScanWriteUtils.scanAndStoreReference(rtok, tokens)) {
        weights.add(rtok.scanNumber());
    }
    if (rtok.ttype != ']') {
        throw new IOException("Expected ']', got " + rtok);
    }
    // while (rtok.nextToken() != ']') {
    // rtok.pushBack();
    // ScanWriteUtils.scanReferenceToken (rtok, tokens);
    // weights.add (rtok.scanNumber());
    // }
    // add null terminator
    tokens.offer(ScanToken.END);
    if (weights.size() == 1) {
        PointParticleAttachment ppa = new PointParticleAttachment();
        myVertexAttachments.add(ppa);
    } else {
        PointFem3dAttachment pfa = new PointFem3dAttachment();
        tokens.offer(new ObjectToken(ArraySupport.toDoubleArray(weights)));
        myVertexAttachments.add(pfa);
    }
}
Also used : ObjectToken(artisynth.core.util.ObjectToken) ArrayList(java.util.ArrayList) PointFem3dAttachment(artisynth.core.femmodels.PointFem3dAttachment) IOException(java.io.IOException) PointParticleAttachment(artisynth.core.mechmodels.PointParticleAttachment)

Example 3 with ObjectToken

use of artisynth.core.util.ObjectToken in project artisynth_core by artisynth.

the class FemMeshComp method scanAttachment.

protected void scanAttachment(ReaderTokenizer rtok, Deque<ScanToken> tokens) throws IOException {
    ArrayList<Double> weights = new ArrayList<Double>();
    rtok.scanToken('[');
    tokens.offer(ScanToken.BEGIN);
    while (ScanWriteUtils.scanAndStoreReference(rtok, tokens)) {
        weights.add(rtok.scanNumber());
    }
    if (rtok.ttype != ']') {
        throw new IOException("Expected ']', got " + rtok);
    }
    // while (rtok.nextToken() != ']') {
    // rtok.pushBack();
    // ScanWriteUtils.scanReferenceToken (rtok, tokens);
    // weights.add (rtok.scanNumber());
    // }
    // add null terminator
    tokens.offer(ScanToken.END);
    if (weights.size() == 1) {
        PointParticleAttachment ppa = new PointParticleAttachment();
        myVertexAttachments.add(ppa);
    } else {
        PointFem3dAttachment pfa = new PointFem3dAttachment();
        tokens.offer(new ObjectToken(ArraySupport.toDoubleArray(weights)));
        myVertexAttachments.add(pfa);
    }
}
Also used : ObjectToken(artisynth.core.util.ObjectToken) ArrayList(java.util.ArrayList) IOException(java.io.IOException) PointParticleAttachment(artisynth.core.mechmodels.PointParticleAttachment)

Aggregations

ObjectToken (artisynth.core.util.ObjectToken)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 PointParticleAttachment (artisynth.core.mechmodels.PointParticleAttachment)2 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)1