Search in sources :

Example 11 with ControlPointCurve

use of cbit.vcell.geometry.ControlPointCurve in project vcell by virtualcell.

the class CurveTable method encodeCurve.

/**
 * Insert the method's description here.
 * Creation date: (7/28/00 6:01:29 PM)
 * @param shape java.awt.Shape
 */
public static String encodeCurve(cbit.vcell.geometry.Curve curve) {
    StringBuffer encodedVals = new StringBuffer();
    // CurveType
    encodedVals.append(curve.getClass().getName() + " ");
    // Curve open or closed
    encodedVals.append(curve.isClosed() + " ");
    if (curve instanceof ControlPointCurve) {
        ControlPointCurve cpc = (ControlPointCurve) curve;
        // ControlPointCount
        encodedVals.append(cpc.getControlPointCount() + " ");
        for (int c = 0; c < cpc.getControlPointCount(); c += 1) {
            Coordinate cpcCoord = cpc.getControlPoint(c);
            encodedVals.append(cpcCoord.getX() + " " + cpcCoord.getY() + " " + cpcCoord.getZ() + " ");
        }
    } else {
        throw new RuntimeException("Can't encode curvetype " + curve.getClass().getName());
    }
    /*else {
		double[] segments = new double[6];
		java.awt.geom.PathIterator pi = shape.getPathIterator(null);
		encodedVals.append(pi.getWindingRule() + " ");
		while (!pi.isDone()) {
			int segType = pi.currentSegment(segments);
			encodedVals.append(segType + " ");
			switch (segType) {
				case java.awt.geom.PathIterator.SEG_MOVETO :
					encodedVals.append(segments[0] + " " + segments[1] + " ");
					break;
				case java.awt.geom.PathIterator.SEG_LINETO :
					encodedVals.append(segments[0] + " " + segments[1] + " ");
					break;
				case java.awt.geom.PathIterator.SEG_QUADTO :
					encodedVals.append(segments[0] + " " + segments[1] + segments[2] + " " + segments[3] + " ");
					break;
				case java.awt.geom.PathIterator.SEG_CUBICTO :
					encodedVals.append(segments[0] + " " + segments[1] + segments[2] + " " + segments[3] + segments[4] + " " + segments[5] + " ");
					break;
				case java.awt.geom.PathIterator.SEG_CLOSE :
					//No points
					break;
			}
			pi.next();
		}
	}*/
    return encodedVals.toString();
}
Also used : Coordinate(org.vcell.util.Coordinate) ControlPointCurve(cbit.vcell.geometry.ControlPointCurve)

Aggregations

ControlPointCurve (cbit.vcell.geometry.ControlPointCurve)11 Coordinate (org.vcell.util.Coordinate)8 SinglePoint (cbit.vcell.geometry.SinglePoint)5 SampledCurve (cbit.vcell.geometry.SampledCurve)4 CurveSelectionInfo (cbit.vcell.geometry.CurveSelectionInfo)3 Element (org.jdom.Element)3 Curve (cbit.vcell.geometry.Curve)2 CurveSelectionCurve (cbit.vcell.geometry.CurveSelectionCurve)2 PolyLine (cbit.vcell.geometry.PolyLine)2 Spline (cbit.vcell.geometry.Spline)2 Vector (java.util.Vector)2 ImageException (cbit.image.ImageException)1 VCImage (cbit.image.VCImage)1 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)1 CompartmentSubVolume (cbit.vcell.geometry.CompartmentSubVolume)1 Geometry (cbit.vcell.geometry.Geometry)1 GeometryException (cbit.vcell.geometry.GeometryException)1 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)1 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)1 Line (cbit.vcell.geometry.Line)1