Search in sources :

Example 6 with Vect3D

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

the class MovingBoundaryMeshMapping method fromReader.

public VisMesh fromReader(MovingBoundaryReader reader, DomainType domainType, int timeIndex) {
    MeshInfo meshInfo = reader.getMeshInfo();
    ISize size = new ISize(meshInfo.xinfo.number(), meshInfo.yinfo.number(), 1);
    Plane plane = reader.getPlane(timeIndex);
    int numX = size.getX();
    int numY = size.getY();
    int dimension = 2;
    Vect3D origin = new Vect3D(meshInfo.xinfo.start, meshInfo.yinfo.start, 0.0);
    Vect3D extent = new Vect3D(meshInfo.xinfo.end - meshInfo.xinfo.start, meshInfo.yinfo.end - meshInfo.yinfo.start, 1.0);
    // invoke VisMesh() constructor
    VisMesh visMesh = new VisMesh(dimension, origin, extent);
    int currPointIndex = 0;
    HashMap<String, Integer> pointDict = new HashMap<String, Integer>();
    PointIndex pointIndex = reader.getPointIndex();
    if (domainType == DomainType.INSIDE || domainType == DomainType.OUTSIDE) {
        int volumeIndex = 0;
        for (int j = 0; j < numY; j++) {
            for (int i = 0; i < numX; i++) {
                Element mbElement = plane.get(i, j);
                if ((domainType == DomainType.INSIDE && (mbElement.position == Position.INSIDE || mbElement.position == Position.BOUNDARY)) || (domainType == DomainType.OUTSIDE && mbElement.position == Position.OUTSIDE)) {
                    ArrayList<Integer> elementVisIndices = new ArrayList<Integer>();
                    int[] elementPointIndices = mbElement.boundary();
                    // first and last index is same
                    int numUniqueElementIndices = elementPointIndices.length - 1;
                    for (int p = 0; p < numUniqueElementIndices; p++) {
                        Vect3Didx point = pointIndex.lookup(elementPointIndices[p]);
                        VisPoint visPoint = new VisPoint(point.x, point.y, point.z);
                        String visPointKey = toStringKey(visPoint);
                        Integer visPointIndex = pointDict.get(visPointKey);
                        if (visPointIndex == null) {
                            visPointIndex = currPointIndex++;
                            pointDict.put(visPointKey, visPointIndex);
                            visMesh.addToPoints(visPoint);
                        }
                        elementVisIndices.add(visPointIndex);
                    }
                    VisPolygon polygon = new VisPolygon(elementVisIndices);
                    polygon.setMovingBoundaryVolumeIndex(new MovingBoundaryVolumeIndex(volumeIndex));
                    visMesh.addToPolygons(polygon);
                    volumeIndex++;
                }
            // end if
            }
        // end i
        }
    // end j
    } else if (domainType == DomainType.MEMBRANE) {
        throw new RuntimeException("DomainType MEMBRANE not yet implemented for moving boundary vtk processing");
    }
    return visMesh;
}
Also used : Plane(cbit.vcell.solvers.mb.MovingBoundaryTypes.Plane) HashMap(java.util.HashMap) ISize(org.vcell.util.ISize) Element(cbit.vcell.solvers.mb.MovingBoundaryTypes.Element) ArrayList(java.util.ArrayList) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint) Vect3D(org.vcell.vis.vismesh.thrift.Vect3D) VisMesh(org.vcell.vis.vismesh.thrift.VisMesh) PointIndex(cbit.vcell.solvers.mb.PointIndex) VisPolygon(org.vcell.vis.vismesh.thrift.VisPolygon) MeshInfo(cbit.vcell.solvers.mb.MovingBoundaryTypes.MeshInfo) Vect3Didx(cbit.vcell.solvers.mb.Vect3Didx) MovingBoundaryVolumeIndex(org.vcell.vis.vismesh.thrift.MovingBoundaryVolumeIndex) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint)

Example 7 with Vect3D

use of org.vcell.vis.vismesh.thrift.Vect3D 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

Vect3D (org.vcell.vis.vismesh.thrift.Vect3D)7 VisPoint (org.vcell.vis.vismesh.thrift.VisPoint)7 VisMesh (org.vcell.vis.vismesh.thrift.VisMesh)6 HashMap (java.util.HashMap)5 ISize (org.vcell.util.ISize)5 Box3D (org.vcell.vis.core.Box3D)3 FiniteVolumeIndex (org.vcell.vis.vismesh.thrift.FiniteVolumeIndex)3 VisPolygon (org.vcell.vis.vismesh.thrift.VisPolygon)3 ArrayList (java.util.ArrayList)2 ChomboVolumeIndex (org.vcell.vis.vismesh.thrift.ChomboVolumeIndex)2 VisVoxel (org.vcell.vis.vismesh.thrift.VisVoxel)2 Element (cbit.vcell.solvers.mb.MovingBoundaryTypes.Element)1 MeshInfo (cbit.vcell.solvers.mb.MovingBoundaryTypes.MeshInfo)1 Plane (cbit.vcell.solvers.mb.MovingBoundaryTypes.Plane)1 PointIndex (cbit.vcell.solvers.mb.PointIndex)1 Vect3Didx (cbit.vcell.solvers.mb.Vect3Didx)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 HashSet (java.util.HashSet)1