use of org.sbml.jsbml.ext.spatial.CSGScale in project vcell by virtualcell.
the class SBMLImporter method getVCellCSGNode.
public static cbit.vcell.geometry.CSGNode getVCellCSGNode(org.sbml.jsbml.ext.spatial.CSGNode sbmlCSGNode) {
String csgNodeName = sbmlCSGNode.getId();
if (sbmlCSGNode instanceof org.sbml.jsbml.ext.spatial.CSGPrimitive) {
PrimitiveKind primitiveKind = ((org.sbml.jsbml.ext.spatial.CSGPrimitive) sbmlCSGNode).getPrimitiveType();
cbit.vcell.geometry.CSGPrimitive.PrimitiveType vcellCSGPrimitiveType = getVCellPrimitiveType(primitiveKind);
cbit.vcell.geometry.CSGPrimitive vcellPrimitive = new cbit.vcell.geometry.CSGPrimitive(csgNodeName, vcellCSGPrimitiveType);
return vcellPrimitive;
} else if (sbmlCSGNode instanceof CSGPseudoPrimitive) {
throw new RuntimeException("Pseudo primitives not yet supported in CSGeometry.");
} else if (sbmlCSGNode instanceof CSGSetOperator) {
org.sbml.jsbml.ext.spatial.CSGSetOperator sbmlSetOperator = (org.sbml.jsbml.ext.spatial.CSGSetOperator) sbmlCSGNode;
OperatorType opType = null;
switch(sbmlSetOperator.getOperationType()) {
case difference:
{
opType = OperatorType.DIFFERENCE;
break;
}
case intersection:
{
opType = OperatorType.INTERSECTION;
break;
}
case union:
{
opType = OperatorType.UNION;
break;
}
default:
{
throw new RuntimeException("sbml CSG geometry set operator " + sbmlSetOperator.getOperationType().name() + " not supported");
}
}
cbit.vcell.geometry.CSGSetOperator vcellSetOperator = new cbit.vcell.geometry.CSGSetOperator(csgNodeName, opType);
for (int c = 0; c < sbmlSetOperator.getListOfCSGNodes().size(); c++) {
vcellSetOperator.addChild(getVCellCSGNode(sbmlSetOperator.getListOfCSGNodes().get(c)));
}
return vcellSetOperator;
} else if (sbmlCSGNode instanceof CSGTransformation) {
org.sbml.jsbml.ext.spatial.CSGTransformation sbmlTransformation = (org.sbml.jsbml.ext.spatial.CSGTransformation) sbmlCSGNode;
cbit.vcell.geometry.CSGNode vcellCSGChild = getVCellCSGNode(sbmlTransformation.getCSGNode());
if (sbmlTransformation instanceof org.sbml.jsbml.ext.spatial.CSGTranslation) {
org.sbml.jsbml.ext.spatial.CSGTranslation sbmlTranslation = (org.sbml.jsbml.ext.spatial.CSGTranslation) sbmlTransformation;
Vect3d translation = new Vect3d(sbmlTranslation.getTranslateX(), sbmlTranslation.getTranslateY(), sbmlTranslation.getTranslateZ());
cbit.vcell.geometry.CSGTranslation vcellTranslation = new cbit.vcell.geometry.CSGTranslation(csgNodeName, translation);
vcellTranslation.setChild(vcellCSGChild);
return vcellTranslation;
} else if (sbmlTransformation instanceof CSGRotation) {
CSGRotation sbmlRotation = (CSGRotation) sbmlTransformation;
Vect3d axis = new Vect3d(sbmlRotation.getRotateAxisX(), sbmlRotation.getRotateAxisY(), sbmlRotation.getRotateAxisZ());
double rotationAngleRadians = sbmlRotation.getRotateAngleInRadians();
cbit.vcell.geometry.CSGRotation vcellRotation = new cbit.vcell.geometry.CSGRotation(csgNodeName, axis, rotationAngleRadians);
vcellRotation.setChild(vcellCSGChild);
return vcellRotation;
} else if (sbmlTransformation instanceof CSGScale) {
CSGScale sbmlScale = (CSGScale) sbmlTransformation;
Vect3d scale = new Vect3d(sbmlScale.getScaleX(), sbmlScale.getScaleY(), sbmlScale.getScaleZ());
cbit.vcell.geometry.CSGScale vcellScale = new cbit.vcell.geometry.CSGScale(csgNodeName, scale);
vcellScale.setChild(vcellCSGChild);
return vcellScale;
} else if (sbmlTransformation instanceof CSGHomogeneousTransformation) {
throw new SBMLImportException("homogeneous transformations not supported yet.");
} else {
throw new SBMLImportException("unsupported type of CSGTransformation");
}
} else {
throw new SBMLImportException("unsupported type of CSGNode");
}
}
Aggregations