Search in sources :

Example 1 with CSGHomogeneousTransformation

use of org.sbml.jsbml.ext.spatial.CSGHomogeneousTransformation 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");
    }
}
Also used : CSGTransformation(org.sbml.jsbml.ext.spatial.CSGTransformation) PrimitiveKind(org.sbml.jsbml.ext.spatial.PrimitiveKind) OperatorType(cbit.vcell.geometry.CSGSetOperator.OperatorType) CSGScale(org.sbml.jsbml.ext.spatial.CSGScale) SimulationContext(cbit.vcell.mapping.SimulationContext) SpeciesContext(cbit.vcell.model.SpeciesContext) IssueContext(org.vcell.util.IssueContext) ReactionContext(cbit.vcell.mapping.ReactionContext) CSGSetOperator(org.sbml.jsbml.ext.spatial.CSGSetOperator) PrimitiveType(cbit.vcell.geometry.CSGPrimitive.PrimitiveType) CSGRotation(org.sbml.jsbml.ext.spatial.CSGRotation) InteriorPoint(org.sbml.jsbml.ext.spatial.InteriorPoint) Vect3d(cbit.vcell.render.Vect3d) CSGHomogeneousTransformation(org.sbml.jsbml.ext.spatial.CSGHomogeneousTransformation) CSGSetOperator(org.sbml.jsbml.ext.spatial.CSGSetOperator) CSGPseudoPrimitive(org.sbml.jsbml.ext.spatial.CSGPseudoPrimitive)

Aggregations

PrimitiveType (cbit.vcell.geometry.CSGPrimitive.PrimitiveType)1 OperatorType (cbit.vcell.geometry.CSGSetOperator.OperatorType)1 ReactionContext (cbit.vcell.mapping.ReactionContext)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 SpeciesContext (cbit.vcell.model.SpeciesContext)1 Vect3d (cbit.vcell.render.Vect3d)1 CSGHomogeneousTransformation (org.sbml.jsbml.ext.spatial.CSGHomogeneousTransformation)1 CSGPseudoPrimitive (org.sbml.jsbml.ext.spatial.CSGPseudoPrimitive)1 CSGRotation (org.sbml.jsbml.ext.spatial.CSGRotation)1 CSGScale (org.sbml.jsbml.ext.spatial.CSGScale)1 CSGSetOperator (org.sbml.jsbml.ext.spatial.CSGSetOperator)1 CSGTransformation (org.sbml.jsbml.ext.spatial.CSGTransformation)1 InteriorPoint (org.sbml.jsbml.ext.spatial.InteriorPoint)1 PrimitiveKind (org.sbml.jsbml.ext.spatial.PrimitiveKind)1 IssueContext (org.vcell.util.IssueContext)1