use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.
the class MeshDisplayAdapter method getCurvesFromContours.
/**
* Insert the method's description here.
* Creation date: (11/9/2000 4:36:26 PM)
* @return java.util.Hashtable
* @param normalAxis int
* @param slice int
* @param countourValues double[]
*/
public Hashtable<SampledCurve, Vector<Double>> getCurvesFromContours(double[] countourValues) {
ContourElement[] contourElements = mesh.getContourElements();
if (contourElements == null) {
return null;
}
if (countourValues != null && countourValues.length != contourElements.length) {
throw new RuntimeException("countourValues.length != contourElements.length");
}
Hashtable<SampledCurve, Vector<Double>> curvesAndValues = new Hashtable<SampledCurve, Vector<Double>>();
SampledCurve newCurve = null;
Vector<Double> resolvedContourValues = null;
for (int c = 0; c < contourElements.length; c += 1) {
if (contourElements[c].isBegin()) {
newCurve = new SampledCurve();
resolvedContourValues = new Vector<Double>();
}
newCurve.appendControlPoint(contourElements[c].getBeginCoordinate());
if (countourValues != null) {
resolvedContourValues.addElement(new Double(countourValues[c]));
}
if (contourElements[c].isEnd()) {
newCurve.appendControlPoint(contourElements[c].getEndCoordinate());
curvesAndValues.put(newCurve, resolvedContourValues);
}
}
return curvesAndValues;
}
use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.
the class PDEDataContextPanel method getCurveValue.
/**
* Insert the method's description here.
* Creation date: (3/13/2001 12:53:10 PM)
* @return java.lang.String
* @param csi cbit.vcell.geometry.CurveSelectionInfo
*/
public String getCurveValue(CurveSelectionInfo csi) {
String infoS = null;
if (csi.getType() == CurveSelectionInfo.TYPE_SEGMENT) {
if (membranesAndIndexes != null) {
java.util.Enumeration<SampledCurve> keysEnum = membranesAndIndexes.keys();
while (keysEnum.hasMoreElements()) {
Curve curve = (Curve) keysEnum.nextElement();
if (csi.getCurve() == curve) {
int[] membraneIndexes = (int[]) membranesAndIndexes.get(curve);
if (meshDisplayAdapter != null) {
double[] membraneValues = meshDisplayAdapter.getDataValuesForMembraneIndexes(membraneIndexes, getPdeDataContext().getDataValues(), getPdeDataContext().getDataIdentifier().getVariableType());
if (membraneValues != null) {
Coordinate segmentWC = getPdeDataContext().getCartesianMesh().getCoordinateFromMembraneIndex(membraneIndexes[csi.getSegment()]);
String xCoordString = NumberUtils.formatNumber(segmentWC.getX());
String yCoordString = NumberUtils.formatNumber(segmentWC.getY());
String zCoordString = NumberUtils.formatNumber(segmentWC.getZ());
boolean bDefined = getDataInfoProvider() == null || getDataInfoProvider().isDefined(membraneIndexes[csi.getSegment()]);
infoS = "(" + xCoordString + "," + yCoordString + "," + zCoordString + ") [" + membraneIndexes[csi.getSegment()] + "] Value = " + (bDefined ? membraneValues[csi.getSegment()] : "Undefined");
if (getPdeDataContext().getCartesianMesh() != null && getPdeDataContext().getCartesianMesh().isChomboMesh()) {
if (bDefined && getDataInfoProvider() != null) {
StructureMetricsEntry structure = ((CartesianMeshChombo) getDataInfoProvider().getPDEDataContext().getCartesianMesh()).getStructureInfo(getDataInfoProvider().getPDEDataContext().getDataIdentifier());
if (structure != null) {
infoS += " || " + structure.getDisplayLabel();
}
}
} else {
if (getDataInfoProvider() != null) {
MembraneDataInfo membraneDataInfo = getDataInfoProvider().getMembraneDataInfo(membraneIndexes[csi.getSegment()]);
infoS += " ";
infoS += " \"" + membraneDataInfo.membraneName + "\"";
infoS += " mrID=" + membraneDataInfo.membraneRegionID;
}
String curveDescr = CurveRenderer.getROIDescriptions(segmentWC, getImagePlaneManagerPanel().getCurveRenderer());
if (curveDescr != null) {
infoS += " " + curveDescr;
}
}
break;
}
}
}
}
}
}
return infoS;
}
use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.
the class PDEDataContextPanel method findChomboCurveSelectionInfoForPoint.
@Override
public CurveSelectionInfo findChomboCurveSelectionInfoForPoint(CoordinateIndex ci) {
if (getPdeDataContext().getCartesianMesh().isChomboMesh()) {
CartesianMeshChombo chomboMesh = (CartesianMeshChombo) getPdeDataContext().getCartesianMesh();
int memIndex = chomboMesh.findMembraneIndexFromVolumeIndex(ci);
if (memIndex >= 0) {
for (Entry<SampledCurve, int[]> entry : membranesAndIndexes.entrySet()) {
SampledCurve sc = entry.getKey();
int[] memIndexes = entry.getValue();
for (int idx = 0; idx < memIndexes.length; ++idx) {
if (memIndexes[idx] == memIndex) {
return new CurveSelectionInfo(sc, CurveSelectionInfo.TYPE_SEGMENT, idx);
}
}
}
}
}
return null;
}
use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.
the class ImageJHelper method sendMembraneOutline.
private static void sendMembraneOutline(ImageJConnection imageJConnection, Hashtable<SampledCurve, int[]>[] membraneTables) throws Exception {
if (membraneTables != null) {
// num slices
imageJConnection.dos.writeInt(membraneTables.length);
for (Hashtable<SampledCurve, int[]> membraneTable : membraneTables) {
// System.out.println();
if (membraneTable != null) {
// some slices have no membrane outline
// num polygons on slice
imageJConnection.dos.writeInt(membraneTable.size());
Enumeration<SampledCurve> sliceMembranes = membraneTable.keys();
while (sliceMembranes.hasMoreElements()) {
SampledCurve sampledCurve = sliceMembranes.nextElement();
Vector<Coordinate> polygonPoints = sampledCurve.getControlPointsVector();
// System.out.println(polygonPoints.size());
// num points for polygon
imageJConnection.dos.writeInt(polygonPoints.size());
// isClosed
imageJConnection.dos.writeInt((sampledCurve.isClosed() ? 1 : 0));
for (Coordinate coord : polygonPoints) {
imageJConnection.dos.writeDouble(coord.getX());
imageJConnection.dos.writeDouble(coord.getY());
imageJConnection.dos.writeDouble(coord.getZ());
}
}
} else {
imageJConnection.dos.writeInt(0);
}
}
} else {
imageJConnection.dos.writeInt(0);
}
}
use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.
the class PDEOffscreenRenderer method getPixelsRGB.
/**
* Insert the method's description here.
* Creation date: (3/1/2001 11:54:44 PM)
* @return int[]
*/
public int[] getPixelsRGB(int imageScale, int membrScale, int meshMode, int volVarMembrOutlineThickness) {
if (getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.VOLUME) || getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.POSTPROCESSING)) {
CartesianMesh mesh = getServerPDEDataContext().getCartesianMesh();
MeshDisplayAdapter meshDisplayAdapter = new MeshDisplayAdapter(mesh);
BufferedImage bufferedImage = getScaledRGBVolume(mesh, meshMode, imageScale, false);
//
if (!getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.POSTPROCESSING) && volVarMembrOutlineThickness > 0) {
cbit.vcell.geometry.CurveRenderer curveRenderer = new cbit.vcell.geometry.CurveRenderer(getDisplayAdapterService());
curveRenderer.setNormalAxis(getNormalAxis());
org.vcell.util.Origin origin = mesh.getOrigin();
org.vcell.util.Extent extent = mesh.getExtent();
curveRenderer.setWorldOrigin(new org.vcell.util.Coordinate(origin.getX(), origin.getY(), origin.getZ()));
Coordinate pixeldelta = getPixelDelta(extent, mesh, meshMode, imageScale);
curveRenderer.setWorldDelta(new org.vcell.util.Coordinate(pixeldelta.getX(), pixeldelta.getY(), pixeldelta.getZ()));
Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(getNormalAxis(), getSlice());
if (curvesAndMembraneIndexes != null) {
Curve[] curves = (Curve[]) org.vcell.util.BeanUtils.getArray(curvesAndMembraneIndexes.keys(), Curve.class);
for (int i = 0; curves != null && i < curves.length; i++) {
curveRenderer.addCurve(curves[i]);
curveRenderer.renderPropertySegmentColors(curves[i], null);
curveRenderer.renderPropertyLineWidthMultiplier(curves[i], volVarMembrOutlineThickness);
}
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
// must be false or could get more than 256 colors
curveRenderer.setAntialias(false);
curveRenderer.draw(g);
}
}
return ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
} else if (getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.MEMBRANE)) {
CartesianMesh mesh = getServerPDEDataContext().getCartesianMesh();
MeshDisplayAdapter meshDisplayAdapter = new MeshDisplayAdapter(mesh);
BufferedImage bufferedImage = getScaledRGBVolume(mesh, meshMode, imageScale, true);
//
// apply curve renderer
//
cbit.vcell.geometry.CurveRenderer curveRenderer = new cbit.vcell.geometry.CurveRenderer(getDisplayAdapterService());
curveRenderer.setNormalAxis(getNormalAxis());
org.vcell.util.Origin origin = mesh.getOrigin();
org.vcell.util.Extent extent = mesh.getExtent();
curveRenderer.setWorldOrigin(new org.vcell.util.Coordinate(origin.getX(), origin.getY(), origin.getZ()));
Coordinate pixeldelta = getPixelDelta(extent, mesh, meshMode, imageScale);
curveRenderer.setWorldDelta(new org.vcell.util.Coordinate(pixeldelta.getX(), pixeldelta.getY(), pixeldelta.getZ()));
Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(getNormalAxis(), getSlice());
if (curvesAndMembraneIndexes != null) {
Curve[] curves = (Curve[]) org.vcell.util.BeanUtils.getArray(curvesAndMembraneIndexes.keys(), Curve.class);
for (int i = 0; curves != null && i < curves.length; i++) {
curveRenderer.addCurve(curves[i]);
curveRenderer.renderPropertySegmentColors(curves[i], getCurveColors(curvesAndMembraneIndexes, curves[i], meshDisplayAdapter));
curveRenderer.renderPropertyLineWidthMultiplier(curves[i], membrScale);
}
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
curveRenderer.setAntialias(false);
curveRenderer.draw(g);
}
return ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
} else {
throw new RuntimeException("unsupported VariableType " + getServerPDEDataContext().getDataIdentifier().getVariableType());
}
}
Aggregations