Search in sources :

Example 1 with VisTetrahedron

use of org.vcell.vis.vismesh.thrift.VisTetrahedron in project vcell by virtualcell.

the class ComsolMeshReader method readElements.

private static void readElements(BufferedReader br, VisMesh visMesh, int numElements) throws IOException {
    String line = br.readLine();
    String tetrahedraTag = "% Elements (tetrahedra)";
    String trianglesTag = "% Elements (triangles)";
    if (line.trim().equals(trianglesTag)) {
        for (int i = 0; i < numElements; i++) {
            line = br.readLine();
            String[] tokens = line.split("\\ +");
            ArrayList<Integer> points = new ArrayList<Integer>();
            points.add(Integer.parseInt(tokens[0]) - 1);
            points.add(Integer.parseInt(tokens[1]) - 1);
            points.add(Integer.parseInt(tokens[2]) - 1);
            visMesh.addToPolygons(new VisPolygon(points));
        }
    } else if (line.trim().equals(tetrahedraTag)) {
        for (int i = 0; i < numElements; i++) {
            line = br.readLine();
            String[] tokens = line.split("\\ +");
            ArrayList<Integer> points = new ArrayList<Integer>();
            points.add(Integer.parseInt(tokens[0]) - 1);
            points.add(Integer.parseInt(tokens[1]) - 1);
            points.add(Integer.parseInt(tokens[2]) - 1);
            points.add(Integer.parseInt(tokens[3]) - 1);
            visMesh.addToTetrahedra(new VisTetrahedron(points));
        }
    } else {
        throw new RuntimeException("read " + line + "\nexpected " + tetrahedraTag + " or " + trianglesTag);
    }
}
Also used : VisTetrahedron(org.vcell.vis.vismesh.thrift.VisTetrahedron) VisPolygon(org.vcell.vis.vismesh.thrift.VisPolygon) ArrayList(java.util.ArrayList) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint)

Aggregations

ArrayList (java.util.ArrayList)1 VisPoint (org.vcell.vis.vismesh.thrift.VisPoint)1 VisPolygon (org.vcell.vis.vismesh.thrift.VisPolygon)1 VisTetrahedron (org.vcell.vis.vismesh.thrift.VisTetrahedron)1