Search in sources :

Example 1 with IndentingPrintWriter

use of maspack.util.IndentingPrintWriter in project artisynth_core by artisynth.

the class MeshThicken method saveRegions.

public void saveRegions(File file) {
    try {
        PrintWriter pw = new IndentingPrintWriter(new PrintWriter(new BufferedWriter(new FileWriter(file))));
        pw.println("[ ");
        IndentingPrintWriter.addIndentation(pw, 2);
        for (Region region : myRegions) {
            region.write(pw);
        }
        IndentingPrintWriter.addIndentation(pw, -2);
        pw.println("]");
        pw.close();
        myRegionFile = file;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : FileWriter(java.io.FileWriter) IndentingPrintWriter(maspack.util.IndentingPrintWriter) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter) IndentingPrintWriter(maspack.util.IndentingPrintWriter) BufferedWriter(java.io.BufferedWriter)

Example 2 with IndentingPrintWriter

use of maspack.util.IndentingPrintWriter in project artisynth_core by artisynth.

the class MatlabSolver method write.

public void write(String filename) {
    System.out.println("writing data to file...");
    try {
        String fullpath = filename;
        System.out.println("write data to " + fullpath);
        IndentingPrintWriter pw = new IndentingPrintWriter(new FileWriter(fullpath));
        writeArray(pw, "I", rowIdxs);
        writeArray(pw, "J", colIdxs);
        writeArray(pw, "S", vals);
        writeArray(pw, "x", myX);
        writeArray(pw, "b", myB);
        pw.close();
        System.out.println("... done writing " + filename);
    } catch (Exception e) {
        System.out.println("Unable to open datafile for writing.");
        e.printStackTrace();
    }
}
Also used : FileWriter(java.io.FileWriter) IndentingPrintWriter(maspack.util.IndentingPrintWriter) IOException(java.io.IOException)

Example 3 with IndentingPrintWriter

use of maspack.util.IndentingPrintWriter in project artisynth_core by artisynth.

the class Main method saveProbesFile.

/**
 * to save the probes file
 *
 * @param file probe information file
 * @throws IOException if an I/O error occurred
 */
public boolean saveProbesFile(File file) throws IOException {
    if (getWorkspace() == null) {
        return false;
    }
    IndentingPrintWriter pw = ArtisynthIO.newIndentingPrintWriter(file);
    getWorkspace().writeProbes(pw, null);
    myProbeFile = file;
    return true;
}
Also used : IndentingPrintWriter(maspack.util.IndentingPrintWriter)

Example 4 with IndentingPrintWriter

use of maspack.util.IndentingPrintWriter in project artisynth_core by artisynth.

the class Main method saveModelFile.

public void saveModelFile(File file, String fmtStr) throws IOException {
    RootModel root = getRootModel();
    if (root != null) {
        IndentingPrintWriter pw = ArtisynthIO.newIndentingPrintWriter(file);
        if (!root.getClass().isAssignableFrom(RootModel.class)) {
            pw.println(ClassAliases.getAliasOrName(root.getClass()));
        }
        root.write(pw, new NumberFormat(fmtStr), root);
        pw.close();
    }
}
Also used : RootModel(artisynth.core.workspace.RootModel) IndentingPrintWriter(maspack.util.IndentingPrintWriter) NumberFormat(maspack.util.NumberFormat)

Example 5 with IndentingPrintWriter

use of maspack.util.IndentingPrintWriter in project artisynth_core by artisynth.

the class FemModel3d method writeSurfaceMesh.

public void writeSurfaceMesh(String fileName) {
    IndentingPrintWriter pw = null;
    try {
        pw = ArtisynthIO.newIndentingPrintWriter(fileName);
        writeSurfaceMesh(pw);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (pw != null) {
            pw.close();
        }
    }
}
Also used : IOException(java.io.IOException) IndentingPrintWriter(maspack.util.IndentingPrintWriter)

Aggregations

IndentingPrintWriter (maspack.util.IndentingPrintWriter)8 IOException (java.io.IOException)5 FileWriter (java.io.FileWriter)3 BufferedWriter (java.io.BufferedWriter)2 PrintWriter (java.io.PrintWriter)2 RootModel (artisynth.core.workspace.RootModel)1 NumberFormat (maspack.util.NumberFormat)1