use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class PDEDataContextPanel method findChomboSinglePointSelectionInfoForPoint.
public CurveSelectionInfo findChomboSinglePointSelectionInfoForPoint(Coordinate wc) {
if (getPdeDataContext().getCartesianMesh().isChomboMesh()) {
CartesianMeshChombo chomboMesh = (CartesianMeshChombo) getPdeDataContext().getCartesianMesh();
int memIndex = chomboMesh.findMembraneIndexFromVolumeCoordinate(wc);
if (memIndex >= 0) {
Coordinate coord = chomboMesh.getMembraneElements()[memIndex].getCentroid();
return new CurveSelectionInfo(new SinglePoint(coord));
}
}
return null;
}
use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class PDEDataContextPanel method fetchSpatialSelections0.
/**
* Insert the method's description here.
* Creation date: (6/28/2003 4:57:18 PM)
* @return cbit.vcell.simdata.gui.SpatialSelection[]
*/
private SpatialSelection[] fetchSpatialSelections0(Curve curveOfInterest, boolean bFetchOnlyVisible, VariableType vt) {
//
java.util.Vector<SpatialSelection> spatialSelection = new java.util.Vector<SpatialSelection>();
//
if (getPdeDataContext() != null && getPdeDataContext().getCartesianMesh() != null && getImagePlaneManagerPanel() != null && getImagePlaneManagerPanel().getCurveRenderer() != null) {
//
CartesianMesh cm = getPdeDataContext().getCartesianMesh();
Curve[] curves = getImagePlaneManagerPanel().getCurveRenderer().getAllCurves();
//
if (curves != null && curves.length > 0) {
for (int i = 0; i < curves.length; i += 1) {
boolean bIsVisible = getImagePlaneManagerPanel().getCurveRenderer().getRenderPropertyVisible(curves[i]);
if ((bFetchOnlyVisible && !bIsVisible) || (curveOfInterest != null && curves[i] != curveOfInterest)) {
continue;
}
//
if ((vt.equals(VariableType.POSTPROCESSING) || vt.equals(VariableType.VOLUME) || vt.equals(VariableType.VOLUME_REGION)) && curves[i] instanceof ControlPointCurve && !(curves[i] instanceof CurveSelectionCurve) && (curves[i].getDescription() == null || curves[i].getDescription().startsWith(CurveValueProvider.DESCRIPTION_VOLUME)) && (membranesAndIndexes == null || !membranesAndIndexes.containsKey(curves[i]))) {
// Volume
//
Curve samplerCurve = null;
// if(isSpatial2D){
samplerCurve = projectCurveOntoSlice(curves[i].getSampledCurve());
// }
if (samplerCurve != null) {
samplerCurve.setDescription(curves[i].getDescription());
spatialSelection.add(new SpatialSelectionVolume(new CurveSelectionInfo(samplerCurve), vt, cm));
}
} else if ((vt.equals(VariableType.MEMBRANE) || vt.equals(VariableType.MEMBRANE_REGION)) && membranesAndIndexes != null) {
//
if (curves[i] instanceof CurveSelectionCurve) {
CurveSelectionCurve csCurve = (CurveSelectionCurve) curves[i];
if (csCurve.getSourceCurveSelectionInfo().getCurve() instanceof ControlPointCurve) {
int[] csisegsel = csCurve.getSourceCurveSelectionInfo().getSegmentsInSelectionOrder();
if (csisegsel != null) {
ControlPointCurve cscpcCurve = (ControlPointCurve) (csCurve.getSourceCurveSelectionInfo().getCurve());
Curve[] membraneCurves = (Curve[]) (membranesAndIndexes.keySet().toArray(new Curve[membranesAndIndexes.size()]));
// See if CurveSelectionCurve matches controlpoints in space of a membrane we have
for (int j = 0; j < membraneCurves.length; j += 1) {
if (membraneCurves[j] instanceof ControlPointCurve) {
// They should all be
ControlPointCurve cpc = (ControlPointCurve) membraneCurves[j];
boolean bSame = true;
for (int k = 0; k < csisegsel.length; k += 1) {
if (csisegsel[k] >= cpc.getControlPointCount() || csisegsel[k] >= cscpcCurve.getControlPointCount() || !Coordinate.get2DProjection(cpc.getControlPoint(csisegsel[k]), getNormalAxis()).equals(Coordinate.get2DProjection(cscpcCurve.getControlPoint(csisegsel[k]), getNormalAxis()))) {
//
bSame = false;
break;
}
}
if (bSame) {
int[] mi = (int[]) membranesAndIndexes.get(membraneCurves[j]);
spatialSelection.add(new SpatialSelectionMembrane(new CurveSelectionInfo(membraneCurves[j], csisegsel[0], csisegsel[csisegsel.length - 1], csCurve.getSourceCurveSelectionInfo().getDirectionNegative()), vt, cm, mi, csCurve));
}
}
}
}
}
} else if (curves[i] instanceof SinglePoint && (curves[i].getDescription() == null || curves[i].getDescription().startsWith(CurveValueProvider.DESCRIPTION_MEMBRANE))) {
CurveSelectionInfo[] csiArr = getImagePlaneManagerPanel().getCurveRenderer().getCloseCurveSelectionInfos(curves[i].getBeginningCoordinate());
if (csiArr != null && csiArr.length > 0) {
for (int j = 0; j < csiArr.length; j += 1) {
if (membranesAndIndexes.containsKey(csiArr[j].getCurve())) {
CurveSelectionInfo closestCSI = getImagePlaneManagerPanel().getCurveRenderer().getClosestSegmentSelectionInfo(curves[i].getBeginningCoordinate(), csiArr[j].getCurve());
int[] mi = (int[]) membranesAndIndexes.get(csiArr[j].getCurve());
spatialSelection.add(new SpatialSelectionMembrane(closestCSI, vt, cm, mi, (SinglePoint) curves[i]));
break;
}
}
}
}
}
}
}
}
//
if (spatialSelection.size() > 0) {
SpatialSelection[] ss = new SpatialSelection[spatialSelection.size()];
spatialSelection.copyInto(ss);
return ss;
}
return null;
}
use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class PDEDataContextPanel method getInitalCurveSelection.
/**
* Insert the method's description here.
* Creation date: (7/4/2003 6:10:48 PM)
*/
public CurveSelectionInfo getInitalCurveSelection(int tool, Coordinate wc) {
//
CurveSelectionInfo newCurveSelection = null;
VariableType variableType = getPdeDataContext().getDataIdentifier().getVariableType();
if (variableType.equals(VariableType.MEMBRANE) || variableType.equals(VariableType.MEMBRANE_REGION)) {
if (getPdeDataContext().getCartesianMesh().isChomboMesh() && tool == CurveEditorTool.TOOL_POINT) {
newCurveSelection = findChomboSinglePointSelectionInfoForPoint(wc);
} else {
CurveSelectionInfo[] closeCSI = getImagePlaneManagerPanel().getCurveRenderer().getCloseCurveSelectionInfos(wc);
if (closeCSI != null) {
for (int i = 0; i < closeCSI.length; i += 1) {
if (membranesAndIndexes != null && membranesAndIndexes.containsKey(closeCSI[i].getCurve())) {
if (tool == CurveEditorTool.TOOL_LINE) {
newCurveSelection = new CurveSelectionInfo(new CurveSelectionCurve((SampledCurve) (closeCSI[i].getCurve())));
} else if (tool == CurveEditorTool.TOOL_POINT) {
newCurveSelection = new CurveSelectionInfo(new CurveSelectionCurve((SampledCurve) (closeCSI[i].getCurve())));
double dist = closeCSI[i].getCurve().getDistanceTo(wc);
int segmentIndex = closeCSI[i].getCurve().pickSegment(wc, dist * 1.1);
Coordinate[] coordArr = closeCSI[i].getCurve().getSampledCurve().getControlPointsForSegment(segmentIndex);
Coordinate middleCoord = new Coordinate((coordArr[0].getX() + coordArr[1].getX()) / 2, (coordArr[0].getY() + coordArr[1].getY()) / 2, (coordArr[0].getZ() + coordArr[1].getZ()) / 2);
newCurveSelection = new CurveSelectionInfo(new SinglePoint(middleCoord));
}
break;
}
}
}
}
}
if (newCurveSelection != null) {
if (membraneSamplerCurves == null) {
membraneSamplerCurves = new java.util.Vector<Curve>();
}
membraneSamplerCurves.add(newCurveSelection.getCurve());
}
return newCurveSelection;
}
use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class ASCIIExporter method getallSampleIndexes.
private int[] getallSampleIndexes(GeometrySpecs geometrySpecs, CartesianMesh mesh) throws DataAccessException {
ArrayList<Integer> sampleIndexes = new ArrayList<>();
SpatialSelection[] spatialSelections = geometrySpecs.getSelections();
for (int i = 0; i < spatialSelections.length; i++) {
spatialSelections[i].setMesh(mesh);
}
// Add points
if (geometrySpecs.getPointIndexes().length > 0) {
for (int i = 0; i < geometrySpecs.getPointIndexes().length; i++) {
sampleIndexes.add(geometrySpecs.getPointIndexes()[i]);
}
}
// Add curves
if (geometrySpecs.getCurves().length != 0) {
for (int i = 0; i < geometrySpecs.getCurves().length; i++) {
SpatialSelection curve = geometrySpecs.getCurves()[i];
curve.setMesh(mesh);
if (curve instanceof SpatialSelectionVolume) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionVolume) curve).getIndexSamples(0.0, 1.0);
for (int j = 0; j < ssh.getSampledIndexes().length; j++) {
sampleIndexes.add(ssh.getSampledIndexes()[j]);
}
// numSamplePoints+= ssh.getSampledIndexes().length;
// pointIndexes = ssh.getSampledIndexes();
// distances = ssh.getWorldCoordinateLengths();
// crossingMembraneIndexes = ssh.getMembraneIndexesInOut();
} else if (curve instanceof SpatialSelectionMembrane) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionMembrane) curve).getIndexSamples();
if (((SpatialSelectionMembrane) curve).getSelectionSource() instanceof SinglePoint) {
sampleIndexes.add(ssh.getSampledIndexes()[0]);
// numSamplePoints++;
// pointIndexes = new int[] {ssh.getSampledIndexes()[0]};
// distances = new double[] {0};
} else {
for (int j = 0; j < ssh.getSampledIndexes().length; j++) {
sampleIndexes.add(ssh.getSampledIndexes()[j]);
}
// numSamplePoints+= ssh.getSampledIndexes().length;
// pointIndexes = ssh.getSampledIndexes();
// distances = ssh.getWorldCoordinateLengths();
}
}
}
}
if (sampleIndexes.size() > 0) {
int[] allSampleIndexes = new int[sampleIndexes.size()];
for (int i = 0; i < allSampleIndexes.length; i++) {
allSampleIndexes[i] = sampleIndexes.get(i);
}
return allSampleIndexes;
}
return null;
}
use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class ASCIIExporter method getCurveTimeSeries.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @throws IOException
*/
private FileDataContainerID getCurveTimeSeries(int hdf5GroupVarID, PointsCurvesSlices pointsCurvesSlices, OutputContext outputContext, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, String variableName, SpatialSelection curve, double[] allTimes, int beginIndex, int endIndex, boolean switchRowsColumns, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
int[] pointIndexes = null;
double[] distances = null;
int[] crossingMembraneIndexes = null;
if (curve instanceof SpatialSelectionVolume) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionVolume) curve).getIndexSamples(0.0, 1.0);
pointIndexes = ssh.getSampledIndexes();
distances = ssh.getWorldCoordinateLengths();
crossingMembraneIndexes = ssh.getMembraneIndexesInOut();
} else if (curve instanceof SpatialSelectionMembrane) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionMembrane) curve).getIndexSamples();
if (((SpatialSelectionMembrane) curve).getSelectionSource() instanceof SinglePoint) {
pointIndexes = new int[] { ssh.getSampledIndexes()[0] };
distances = new double[] { 0 };
} else {
pointIndexes = ssh.getSampledIndexes();
distances = ssh.getWorldCoordinateLengths();
}
}
pointsCurvesSlices.data.put(PCS.TIMES, new ArrayList<Double>());
pointsCurvesSlices.data.put(PCS.TIMEBOUNDS, new int[] { beginIndex, endIndex });
final TreeMap<PCS, Object> treePCS = new TreeMap<PCS, Object>();
((TreeMap<String, TreeMap<PCS, Object>>) pointsCurvesSlices.data.get(PCS.CURVES)).put(getSpatialSelectionDescription(curve), treePCS);
treePCS.put(PCS.CURVEINDEXES, pointIndexes);
treePCS.put(PCS.CURVEDISTANCES, distances);
if (crossingMembraneIndexes != null) {
treePCS.put(PCS.CURVECROSSMEMBRINDEX, crossingMembraneIndexes);
}
treePCS.put(PCS.CURVEVALS, new ArrayList<Double>());
org.vcell.util.document.TimeSeriesJobSpec timeSeriesJobSpec = new org.vcell.util.document.TimeSeriesJobSpec(new String[] { variableName }, new int[][] { pointIndexes }, new int[][] { crossingMembraneIndexes }, allTimes[beginIndex], 1, allTimes[endIndex], VCDataJobID.createVCDataJobID(user, false));
org.vcell.util.document.TSJobResultsNoStats timeSeriesJobResults = (org.vcell.util.document.TSJobResultsNoStats) dataServerImpl.getTimeSeriesValues(outputContext, user, vcdID, timeSeriesJobSpec);
// variableValues[0] is time array
// variableValues[1] is values for 1st spatial point.
// variableValues[2] is values for 2nd spatial point.
// variableValues[n] (n>=1) is values for nth spatial point.
// the length of variableValues should always be 1 + pointIndexes.length
// the length of variableValues[n] is allTimes.length
final double[][] variableValues = timeSeriesJobResults.getTimesAndValuesForVariable(variableName);
//
// put data in csv format
//
FileDataContainerID fileDataContainerID = fileDataContainerManager.getNewFileDataContainerID();
fileDataContainerManager.append(fileDataContainerID, "\"variable ('" + variableName + "') times (" + allTimes[beginIndex] + " " + allTimes[endIndex] + ") " + getSpatialSelectionDescription(curve) + "\"\n");
if (switchRowsColumns) {
fileDataContainerManager.append(fileDataContainerID, ",Distances\n");
fileDataContainerManager.append(fileDataContainerID, "Times,");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
((ArrayList<Double>) pointsCurvesSlices.data.get(PCS.TIMES)).add(allTimes[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int j = 0; j < distances.length; j++) {
fileDataContainerManager.append(fileDataContainerID, "," + distances[j]);
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[j + 1][i - beginIndex]);
((ArrayList<Double>) treePCS.get(PCS.CURVEVALS)).add(variableValues[j + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
} else {
fileDataContainerManager.append(fileDataContainerID, ",Times\n");
fileDataContainerManager.append(fileDataContainerID, "Distances,");
for (int i = 0; i < distances.length; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + distances[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
((ArrayList<Double>) pointsCurvesSlices.data.get(PCS.TIMES)).add(allTimes[i]);
for (int j = 0; j < distances.length; j++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[j + 1][i - beginIndex]);
((ArrayList<Double>) treePCS.get(PCS.CURVEVALS)).add(variableValues[j + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
}
if (curve instanceof SpatialSelectionMembrane) {
fileDataContainerManager.append(fileDataContainerID, "\n");
fileDataContainerManager.append(fileDataContainerID, "\"Centroid(XYZ):Times:Values[Times,Centroid]\",X,Y,Z,distance");
for (int i = 0; i < variableValues[0].length; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[0][i]);
((ArrayList<Double>) pointsCurvesSlices.data.get(PCS.TIMES)).add(variableValues[0][i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
double distance = 0;
for (int i = 0; i < pointIndexes.length; i++) {
if (pointIndexes.length > 1 && (i == (pointIndexes.length - 1)) && pointIndexes[i] == pointIndexes[i - 1]) {
continue;
}
Coordinate coord = curve.getMesh().getCoordinateFromMembraneIndex(pointIndexes[i]);
// double value = variableValues[i+1][0];
fileDataContainerManager.append(fileDataContainerID, "," + coord.getX() + "," + coord.getY() + "," + coord.getZ());
if (i > 0) {
Coordinate prevCoord = curve.getMesh().getCoordinateFromMembraneIndex(pointIndexes[i - 1]);
distance += coord.distanceTo(prevCoord);
}
fileDataContainerManager.append(fileDataContainerID, "," + distance);
for (int t = 0; t < variableValues[t].length; t++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[i + 1][t]);
((ArrayList<Double>) treePCS.get(PCS.CURVEVALS)).add(variableValues[i + 1][t]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
}
if (hdf5GroupVarID != -1) {
try {
int hdf5GroupCurveID = H5.H5Gcreate(hdf5GroupVarID, getSpatialSelectionDescription(curve), HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVEINDEXES.name(), new long[] {((int[])treePCS.get(PCS.CURVEINDEXES)).length}, (int[])treePCS.get(PCS.CURVEINDEXES),false);
Hdf5Utils.insertInts(hdf5GroupCurveID, PCS.CURVEINDEXES.name(), new long[] { ((int[]) treePCS.get(PCS.CURVEINDEXES)).length }, (int[]) treePCS.get(PCS.CURVEINDEXES));
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVEDISTANCES.name(), new long[] {((double[])treePCS.get(PCS.CURVEDISTANCES)).length}, (double[])treePCS.get(PCS.CURVEDISTANCES),false);
Hdf5Utils.insertDoubles(hdf5GroupCurveID, PCS.CURVEDISTANCES.name(), new long[] { ((double[]) treePCS.get(PCS.CURVEDISTANCES)).length }, (double[]) treePCS.get(PCS.CURVEDISTANCES));
if (treePCS.get(PCS.CURVECROSSMEMBRINDEX) != null) {
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVECROSSMEMBRINDEX.name(), new long[] {((int[])treePCS.get(PCS.CURVECROSSMEMBRINDEX)).length}, (int[])treePCS.get(PCS.CURVECROSSMEMBRINDEX),false);
Hdf5Utils.insertInts(hdf5GroupCurveID, PCS.CURVECROSSMEMBRINDEX.name(), new long[] { ((int[]) treePCS.get(PCS.CURVECROSSMEMBRINDEX)).length }, (int[]) treePCS.get(PCS.CURVECROSSMEMBRINDEX));
ArrayList<Integer> crossPoints = new ArrayList<Integer>();
for (int i = 0; i < crossingMembraneIndexes.length; i++) {
if (crossingMembraneIndexes[i] != -1) {
crossPoints.add(i);
}
}
String attrText = PCS.CURVEVALS.name() + " columns " + crossPoints.get(0) + " and " + crossPoints.get(1) + " are added points of interpolation near membrane";
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVECROSSMEMBRINDEX.name()+" Info", null, attrText,true);
Hdf5Utils.insertAttribute(hdf5GroupCurveID, PCS.CURVECROSSMEMBRINDEX.name() + " Info", attrText);
}
// Hdf5Utils.writeHDF5Dataset(hdf5GroupCurveID, PCS.CURVEVALS.name(), new long[] {endIndex-beginIndex+1,((int[])treePCS.get(PCS.CURVEINDEXES)).length}, (ArrayList<Double>)treePCS.get(PCS.CURVEVALS),false);
Hdf5Utils.insertDoubles(hdf5GroupCurveID, PCS.CURVEVALS.name(), new long[] { endIndex - beginIndex + 1, ((int[]) treePCS.get(PCS.CURVEINDEXES)).length }, (ArrayList<Double>) treePCS.get(PCS.CURVEVALS));
H5.H5Gclose(hdf5GroupCurveID);
} catch (Exception e) {
e.printStackTrace();
throw new DataAccessException(e.getMessage(), e);
}
}
return fileDataContainerID;
}
Aggregations