Ejemplo n.º 1
0
  // Writes polygons to the saveFile
  private static void savePolygons() {
    if (!saveFile.exists()) {
      try {
        saveFile.createNewFile();
      } catch (IOException ex) {
        // Can't create file
      }
    }

    try {
      PrintStream fileOut = new PrintStream(saveFile);
      for (Polygon p : polygons) {
        fileOut.println(p.getName());
        fileOut.println(p.getPoints().size());
        for (Point3Df q : p.getPoints()) {
          fileOut.print(q.x);
          fileOut.print(",");
          fileOut.print(q.y);
          fileOut.print(",");
          fileOut.println(q.z);
        }

        fileOut.println(p.getEdges().size());
        for (Edge q : p.getEdges()) {
          fileOut.print(q.p1);
          fileOut.print(",");
          fileOut.println(q.p2);
        }
      }
      fileOut.close();
    } catch (FileNotFoundException ex) {
      // Can't find file
    }
  }