Search in sources :

Example 16 with Probe

use of artisynth.core.probes.Probe in project artisynth_core by artisynth.

the class Workspace method oldScanProbes.

private static void oldScanProbes(ReaderTokenizer rtok, RootModel rootModel) throws IOException {
    // myInputProbes.clear();
    // myOutputProbes.clear()
    rootModel.removeAllInputProbes();
    rootModel.removeAllOutputProbes();
    rootModel.removeAllWayPoints();
    // myOutputProbes.add(myWayPoints); will be read from file
    // boolean isInvalid = false;
    rtok.scanToken('[');
    while (rtok.nextToken() != ']') {
        if (!rtok.tokenIsWord()) {
            throw new IOException("Expecting type identifier for probe, got " + rtok);
        }
        Class probeClass = null;
        if ((probeClass = ClassAliases.resolveClass(rtok.sval)) == null) {
            throw new IOException("Unknown resolve probe class: " + rtok.sval);
        }
        Object probeObj = null;
        if (probeClass == WayPointProbe.class) {
            probeObj = rootModel.getWayPoints();
        } else {
            try {
                probeObj = probeClass.newInstance();
            } catch (Exception e) {
                throw new IOException("Can't instantiate probe class " + probeClass.getName() + ", line " + rtok.lineno());
            }
        }
        if (probeObj instanceof Probe) {
            if (((Probe) probeObj).isInput()) {
                Probe iprobe = (Probe) probeObj;
                try {
                    ScanWriteUtils.scanfull(rtok, iprobe, rootModel);
                    rootModel.addInputProbe(iprobe);
                } catch (IOException e) {
                    String errMsg = "scan probe failed, ";
                    if (rtok.getResourceName() != null) {
                        errMsg += "file=" + rtok.getResourceName() + ", ";
                    }
                    System.err.println(errMsg + e.getMessage());
                }
            } else {
                Probe oprobe = (Probe) probeObj;
                try {
                    ScanWriteUtils.scanfull(rtok, oprobe, rootModel);
                    if (!(oprobe instanceof WayPointProbe)) {
                        // waypoint probe is
                        // already added
                        rootModel.addOutputProbe(oprobe);
                    }
                } catch (IOException e) {
                    String errMsg = "scan probe failed, ";
                    if (rtok.getResourceName() != null) {
                        errMsg += "file=" + rtok.getResourceName() + ", ";
                    }
                    System.err.println(errMsg + e.getMessage());
                }
            }
        } else {
        // throw new IOException("Probe object " + probeClass.getName()
        // + " is not a probe, line " + rtok.lineno());
        // isInvalid = true;
        }
    }
}
Also used : WayPointProbe(artisynth.core.probes.WayPointProbe) WayPointProbe(artisynth.core.probes.WayPointProbe) Probe(artisynth.core.probes.Probe)

Aggregations

Probe (artisynth.core.probes.Probe)16 WayPointProbe (artisynth.core.probes.WayPointProbe)11 NumericInputProbe (artisynth.core.probes.NumericInputProbe)5 TracingProbe (artisynth.core.probes.TracingProbe)5 NumericOutputProbe (artisynth.core.probes.NumericOutputProbe)4 WayPoint (artisynth.core.probes.WayPoint)4 RootModel (artisynth.core.workspace.RootModel)3 SelectionManager (artisynth.core.gui.selectionManager.SelectionManager)2 Controller (artisynth.core.modelbase.Controller)2 Model (artisynth.core.modelbase.Model)2 Monitor (artisynth.core.modelbase.Monitor)2 Point (java.awt.Point)2 InternalErrorException (maspack.util.InternalErrorException)2 FemModel3d (artisynth.core.femmodels.FemModel3d)1 NumericProbeDisplayLarge (artisynth.core.gui.NumericProbeDisplayLarge)1 AddComponentsCommand (artisynth.core.gui.editorManager.AddComponentsCommand)1 NumericProbeEditor (artisynth.core.gui.probeEditor.NumericProbeEditor)1 MechModel (artisynth.core.mechmodels.MechModel)1 RigidBody (artisynth.core.mechmodels.RigidBody)1 CopyableComponent (artisynth.core.modelbase.CopyableComponent)1