/** * Creates the meshes of one single phase and adds it to the ArrayList of 4D meshes. * * @param phase * @param parameters * @param info * @param splines */ private void createPhantom( int phase, double[] parameters, CONRADCardiacModelConfig info, ArrayList<Mesh4D> splines) { String pcaFile = heartBase + "\\CardiacModel\\phase_" + phase + ".ccm"; ActiveShapeModel asm = new ActiveShapeModel(pcaFile); Mesh allComp = asm.getModel(parameters); if (phase == 0) { for (int i = 0; i < info.numAnatComp; i++) { splines.add(new Mesh4D()); } } int count = 0; for (heartComponents hc : heartComponents.values()) { Mesh comp = new Mesh(); SimpleMatrix pts = allComp .getPoints() .getSubMatrix(info.vertexOffs[count], 0, hc.getNumVertices(), info.vertexDim); // rotate and translate points for (int i = 0; i < pts.getRows(); i++) { SimpleVector row = SimpleOperators.multiply(rot, pts.getRow(i)); row.add(trans); pts.setRowValue(i, row); } comp.setPoints(pts); comp.setConnectivity( allComp .getConnectivity() .getSubMatrix(info.triangleOffs[count], 0, hc.getNumTriangles(), 3)); splines.get(count).addMesh(comp); count++; } }
/** * Calculate the current state of the heart at time t using spline evaluation of all vertices in * all heart components. */ @Override public PrioritizableScene getScene(double time) { double t = (time * heartBeats) % 1; System.out.println("Evaluating time step: " + time); PrioritizableScene scene = new PrioritizableScene(); int componentCount = 0; for (heartComponents hc : heartComponents.values()) { String material; if (hc.getName().contains("myocardium")) { material = "Heart"; } else if (hc.getName().contains("aorta")) { material = "Aorta"; } else if (hc.getName().contains("leftVentricle")) { material = "CoronaryArtery"; } else { material = "Blood"; } Mesh m = splines.get(componentCount).evaluateLinearInterpolation(t); // Mesh m = splines.get(componentCount).evaluateSplines(t); if (DEBUG) { String inspectionFolder = heartBase + "meshReference/" + t + "/"; File inspect = new File(inspectionFolder); if (!inspect.exists()) inspect.mkdirs(); String inspectionFile = inspectionFolder + hc.getName() + ".vtk"; VTKMeshIO wr = new VTKMeshIO(inspectionFile); wr.setMesh(m); wr.write(); } PhysicalObject po = createPhysicalObject(hc.toString(), m, material); scene.add(po); componentCount++; } scene.setMax(max); scene.setMin(min); return scene; }