use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CartesianMesh method getVolumeSliceIndices.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @param variable java.lang.String
* @param time double
*/
public int[] getVolumeSliceIndices(int normalAxis, int sliceNumber) {
Coordinate normalAxisDimension = Coordinate.convertAxisFromStandardXYZToNormal(getSizeX(), getSizeY(), getSizeZ(), normalAxis);
int[] indices = new int[(int) normalAxisDimension.getX() * (int) normalAxisDimension.getY()];
int counter = 0;
CoordinateIndex coordIndex = new CoordinateIndex();
for (int y = 0; y < normalAxisDimension.getY(); y += 1) {
for (int x = 0; x < normalAxisDimension.getX(); x += 1) {
//
// indexing through "normal" slice, converting each X,Y pair into equivalent
// (X,Y,Z) in mesh coordinates.
//
coordIndex.x = x;
coordIndex.y = y;
coordIndex.z = sliceNumber;
Coordinate.convertCoordinateIndexFromNormalToStandardXYZ(coordIndex, normalAxis);
//
// store mesh coordinates in "normal" slice sample array.
//
indices[counter] = getVolumeIndex(coordIndex.x, coordIndex.y, coordIndex.z);
counter += 1;
}
}
return indices;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CartesianMesh method getCoordinate.
/**
* This method was created in VisualAge.
* @return cbit.vcell.geometry.Coordinate
* @param coordIndex cbit.vcell.math.CoordinateIndex
*/
public Coordinate getCoordinate(CoordinateIndex coordIndex) {
//
//
// calculate coordinates based on element coordinates
//
// 1--------2--------3-------4--------N
//
// so spacing is divided into (N-1) regions.
//
//
// if N is 1, then take middle of that dimension
//
//
// extent.getX()/2.0 + origin.getX();
double x = Coordinate.coordComponentFromSinglePlanePolicy(origin, extent, Coordinate.X_AXIS);
if (getSizeX() > 1) {
x = (((double) coordIndex.x) / (getSizeX() - 1)) * extent.getX() + origin.getX();
}
// extent.getY()/2.0 + origin.getY();
double y = Coordinate.coordComponentFromSinglePlanePolicy(origin, extent, Coordinate.Y_AXIS);
if (getSizeY() > 1) {
y = (((double) coordIndex.y) / (getSizeY() - 1)) * extent.getY() + origin.getY();
}
// extent.getZ()/2.0 + origin.getZ();
double z = Coordinate.coordComponentFromSinglePlanePolicy(origin, extent, Coordinate.Z_AXIS);
if (getSizeZ() > 1) {
z = (((double) coordIndex.z) / (getSizeZ() - 1)) * extent.getZ() + origin.getZ();
}
return (new Coordinate(x, y, z));
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CartesianMeshChombo method collectVertices.
private static void collectVertices(CartesianMeshChombo chomboMesh, Vector vectValues) {
int c = -1;
double[] x = (double[]) vectValues.get(++c);
double[] y = (double[]) vectValues.get(++c);
double[] z = null;
if (chomboMesh.dimension == 3) {
z = (double[]) vectValues.get(++c);
}
chomboMesh.vertices = new Coordinate[x.length];
for (int i = 0; i < x.length; ++i) {
chomboMesh.vertices[i] = new Coordinate(x[i], y[i], z == null ? 0 : z[i]);
}
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CartesianMeshChombo method collect3dSurfaceTriangles.
private static void collect3dSurfaceTriangles(CartesianMeshChombo chomboMesh, Vector vectValues) {
int c = 0;
int[] index = (int[]) vectValues.get(c);
int[] faceIndex = (int[]) vectValues.get(++c);
int[] neighbor = (int[]) vectValues.get(++c);
double[] x0 = (double[]) vectValues.get(++c);
double[] y0 = (double[]) vectValues.get(++c);
double[] z0 = null;
if (chomboMesh.dimension == 3) {
z0 = (double[]) vectValues.get(++c);
}
double[] x1 = (double[]) vectValues.get(++c);
double[] y1 = (double[]) vectValues.get(++c);
double[] z1 = null;
if (chomboMesh.dimension == 3) {
z1 = (double[]) vectValues.get(++c);
}
double[] x2 = (double[]) vectValues.get(++c);
double[] y2 = (double[]) vectValues.get(++c);
double[] z2 = null;
if (chomboMesh.dimension == 3) {
z2 = (double[]) vectValues.get(++c);
}
for (int n = 0; n < index.length; ++n) {
int memIndex = index[n];
List<SurfaceTriangleEntry3D> edgeList = chomboMesh.surfaceTriangleMap.get(memIndex);
if (edgeList == null) {
edgeList = new ArrayList<SurfaceTriangleEntry3D>();
chomboMesh.surfaceTriangleMap.put(index[n], edgeList);
}
SurfaceTriangleEntry3D mp = new SurfaceTriangleEntry3D();
mp.memIndex = index[n];
mp.faceIndex = faceIndex[n];
mp.p0 = new Coordinate(x0[n], y0[n], z0 == null ? 0 : z0[n]);
mp.p1 = new Coordinate(x1[n], y1[n], z1 == null ? 0 : z1[n]);
mp.p2 = new Coordinate(x2[n], y2[n], z2 == null ? 0 : z2[n]);
edgeList.add(mp);
}
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class MeshDisplayAdapter method getProjectedSegment.
/**
* Insert the method's description here.
* Creation date: (8/30/00 6:25:14 PM)
* @return cbit.vcell.geometry.Line
*/
private Line getProjectedSegment(MembraneElement membraneElement, int normalAxis) {
// Find midpoint between the 2 volume elements for this MembraneElement
Coordinate c0 = getMesh().getCoordinateFromMembraneIndex(membraneElement.getMembraneIndex());
double x0 = c0.getX(), y0 = c0.getY(), z0 = c0.getZ();
double x1 = c0.getX(), y1 = c0.getY(), z1 = c0.getZ();
// Stretch endpoints for the line segment based on membranePlane and size of volumeElement
int membranePlane = getParalellAxis(membraneElement, normalAxis);
if (membranePlane == Coordinate.Z_AXIS) {
double elementZSize = (1.0 / (double) (mesh.getSizeZ() - 1)) * mesh.getExtent().getZ();
z0 -= (elementZSize / 2.0);
z1 += (elementZSize / 2.0);
} else if (membranePlane == Coordinate.Y_AXIS) {
double elementYSize = (1.0 / (double) (mesh.getSizeY() - 1)) * mesh.getExtent().getY();
y0 -= (elementYSize / 2.0);
y1 += (elementYSize / 2.0);
} else if (membranePlane == Coordinate.X_AXIS) {
double elementXSize = (1.0 / (double) (mesh.getSizeX() - 1)) * mesh.getExtent().getX();
x0 -= (elementXSize / 2.0);
x1 += (elementXSize / 2.0);
}
// Clip to edge of world
x0 = (x0 < mesh.getOrigin().getX() ? mesh.getOrigin().getX() : x0);
y0 = (y0 < mesh.getOrigin().getY() ? mesh.getOrigin().getY() : y0);
z0 = (z0 < mesh.getOrigin().getZ() ? mesh.getOrigin().getZ() : z0);
x1 = (x1 > (mesh.getOrigin().getX() + mesh.getExtent().getX()) ? mesh.getOrigin().getX() + mesh.getExtent().getX() : x1);
y1 = (y1 > (mesh.getOrigin().getY() + mesh.getExtent().getY()) ? mesh.getOrigin().getY() + mesh.getExtent().getY() : y1);
z1 = (z1 > (mesh.getOrigin().getZ() + mesh.getExtent().getZ()) ? mesh.getOrigin().getZ() + mesh.getExtent().getZ() : z1);
//
return new Line(new Coordinate(x0, y0, z0), new Coordinate(x1, y1, z1));
}
Aggregations