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();
}
Aggregations