Search in sources :

Example 1 with PolyhedronFace

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

the class ChomboMeshMapping method createClippedPolyhedron.

private VisIrregularPolyhedron createClippedPolyhedron(ClippedVoxel clippedVoxel, VisMesh visMesh, VisVoxel oldVoxel) {
    VisIrregularPolyhedron visIrregularPolyhedron = new VisIrregularPolyhedron();
    visIrregularPolyhedron.setChomboVolumeIndex(new ChomboVolumeIndex(oldVoxel.getChomboVolumeIndex()));
    // 
    for (VisSurfaceTriangle triangle : clippedVoxel.surfaceTriangles) {
        List<Integer> triangleIndices = triangle.getPointIndices();
        PolyhedronFace polyhedronFace = new PolyhedronFace(triangleIndices);
        visIrregularPolyhedron.addToPolyhedronFaces(polyhedronFace);
    }
    VoxelFace[] voxelFaces = new VoxelFace[] { clippedVoxel.f0, clippedVoxel.f1, clippedVoxel.f2, clippedVoxel.f3, clippedVoxel.f4, clippedVoxel.f5 };
    for (VoxelFace voxelFace : voxelFaces) {
        VisSurfaceTriangle triangleForThisFace = clippedVoxel.getSurfaceTriangle(voxelFace.face);
        List<Integer> triangleIndices = null;
        VisPoint[] trianglePoints = null;
        if (triangleForThisFace != null) {
            triangleIndices = triangleForThisFace.getPointIndices();
            trianglePoints = new VisPoint[] { visMesh.getPoints().get(triangleIndices.get(0)), visMesh.getPoints().get(triangleIndices.get(1)), visMesh.getPoints().get(triangleIndices.get(2)) };
        }
        ArrayList<Integer> indices = new ArrayList<Integer>();
        if (voxelFace.p0.bIncluded) {
            indices.add(voxelFace.p0.p);
        }
        if (triangleIndices != null) {
            for (int i = 0; i < 3; i++) {
                if (isColinear(voxelFace.p0.vp, trianglePoints[i], voxelFace.p1.vp)) {
                    indices.add(triangleIndices.get(i));
                }
            }
        }
        if (voxelFace.p1.bIncluded) {
            indices.add(voxelFace.p1.p);
        }
        if (triangleIndices != null) {
            for (int i = 0; i < 3; i++) {
                if (isColinear(voxelFace.p1.vp, trianglePoints[i], voxelFace.p2.vp)) {
                    indices.add(triangleIndices.get(i));
                }
            }
        }
        if (voxelFace.p2.bIncluded) {
            indices.add(voxelFace.p2.p);
        }
        if (triangleIndices != null) {
            for (int i = 0; i < 3; i++) {
                if (isColinear(voxelFace.p2.vp, trianglePoints[i], voxelFace.p3.vp)) {
                    indices.add(triangleIndices.get(i));
                }
            }
        }
        if (voxelFace.p3.bIncluded) {
            indices.add(voxelFace.p3.p);
        }
        if (triangleIndices != null) {
            for (int i = 0; i < 3; i++) {
                if (isColinear(voxelFace.p3.vp, trianglePoints[i], voxelFace.p0.vp)) {
                    indices.add(triangleIndices.get(i));
                }
            }
        }
        // indices.add(voxelFace.p3.p);
        if (indices.size() >= 3) {
            ArrayList<Integer> indexArray = new ArrayList<Integer>(indices);
            PolyhedronFace polyFace = new PolyhedronFace(indexArray);
            visIrregularPolyhedron.addToPolyhedronFaces(polyFace);
        }
    }
    return visIrregularPolyhedron;
}
Also used : PolyhedronFace(org.vcell.vis.vismesh.thrift.PolyhedronFace) ArrayList(java.util.ArrayList) ChomboVolumeIndex(org.vcell.vis.vismesh.thrift.ChomboVolumeIndex) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint) VisSurfaceTriangle(org.vcell.vis.vismesh.thrift.VisSurfaceTriangle) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint) VisIrregularPolyhedron(org.vcell.vis.vismesh.thrift.VisIrregularPolyhedron)

Example 2 with PolyhedronFace

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

the class DebugWriteProblem method main.

/**
 * @param args
 */
public static void main(String[] args) {
    try {
        VisMesh visMesh = new VisMesh(3, new Vect3D(0, 0, 0), new Vect3D(3, 1, 1));
        VisPoint[] points0 = new VisPoint[] { new VisPoint(0, 0, 0), new VisPoint(1, 0, 0), new VisPoint(0, 1, 0), new VisPoint(0, 0, 1) };
        visMesh.addToPoints(points0[0]);
        visMesh.addToPoints(points0[1]);
        visMesh.addToPoints(points0[2]);
        visMesh.addToPoints(points0[3]);
        List<PolyhedronFace> faces0 = Arrays.asList(new PolyhedronFace(Arrays.asList(0, 1, 3)), new PolyhedronFace(Arrays.asList(0, 3, 2)), new PolyhedronFace(Arrays.asList(0, 2, 1)), new PolyhedronFace(Arrays.asList(1, 3, 2)));
        int level = 0;
        int boxNumber = 0;
        int boxIndex = 0;
        int fraction = 0;
        VisIrregularPolyhedron genPolyhedra0 = new VisIrregularPolyhedron(faces0);
        genPolyhedra0.setChomboVolumeIndex(new ChomboVolumeIndex(level, boxNumber, boxIndex, fraction));
        visMesh.addToIrregularPolyhedra(genPolyhedra0);
    // VisPoint[] points1 = new VisPoint[] {
    // new VisPoint(2+0, 0, 0),
    // new VisPoint(2+1, 0, 0),
    // new VisPoint(2+0, 1, 0),
    // new VisPoint(2+0, 0, 1)
    // };
    // 
    // visMesh.addPoint(points1[0]);
    // visMesh.addPoint(points1[1]);
    // visMesh.addPoint(points1[2]);
    // visMesh.addPoint(points1[3]);
    // 
    // vtkUnstructuredGrid vtkgrid = VtkGridUtils.getVolumeVtkGrid(visMesh);
    // String filenameASCII = "testASCII.vtk";
    // String filenameBinary = "testBinary.vtk";
    // VtkGridUtils.writeXML(vtkgrid, filenameASCII, true);
    // VtkGridUtils.writeXML(vtkgrid, filenameBinary, false);
    // vtkgrid = VtkGridUtils.read(filenameBinary);
    // vtkgrid.BuildLinks();
    // SimpleVTKViewer simpleViewer = new SimpleVTKViewer();
    // String[] varNames = visDomain.getVisMeshData().getVarNames();
    // simpleViewer.showGrid(vtkgrid, varNames[0], varNames[1]);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : VisMesh(org.vcell.vis.vismesh.thrift.VisMesh) PolyhedronFace(org.vcell.vis.vismesh.thrift.PolyhedronFace) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint) VisIrregularPolyhedron(org.vcell.vis.vismesh.thrift.VisIrregularPolyhedron) ChomboVolumeIndex(org.vcell.vis.vismesh.thrift.ChomboVolumeIndex) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint) Vect3D(org.vcell.vis.vismesh.thrift.Vect3D)

Aggregations

ChomboVolumeIndex (org.vcell.vis.vismesh.thrift.ChomboVolumeIndex)2 PolyhedronFace (org.vcell.vis.vismesh.thrift.PolyhedronFace)2 VisIrregularPolyhedron (org.vcell.vis.vismesh.thrift.VisIrregularPolyhedron)2 VisPoint (org.vcell.vis.vismesh.thrift.VisPoint)2 ArrayList (java.util.ArrayList)1 Vect3D (org.vcell.vis.vismesh.thrift.Vect3D)1 VisMesh (org.vcell.vis.vismesh.thrift.VisMesh)1 VisSurfaceTriangle (org.vcell.vis.vismesh.thrift.VisSurfaceTriangle)1