Search in sources :

Example 1 with OperatorType

use of cbit.vcell.geometry.CSGSetOperator.OperatorType 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) GeometryContext(cbit.vcell.mapping.GeometryContext) 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)

Example 2 with OperatorType

use of cbit.vcell.geometry.CSGSetOperator.OperatorType in project vcell by virtualcell.

the class CSGObjectPropertiesPanel method menuItemClicked.

private void menuItemClicked(Object source) {
    boolean bGeometryChanged = false;
    boolean bFoundClickedMenuItem = false;
    Object objectToBeSelected = null;
    if (!bFoundClickedMenuItem) {
        PrimitiveType[] values = CSGPrimitive.PrimitiveType.values();
        int numTypes = values.length;
        for (int i = 0; i < numTypes; i++) {
            if (source == addPrimitiveMenuItems[i]) {
                bFoundClickedMenuItem = true;
                CSGPrimitive csgPrimitive = new CSGPrimitive(csgObject.getFreeName(values[i]), values[i]);
                objectToBeSelected = csgPrimitive;
                bGeometryChanged = addNode(csgPrimitive);
                break;
            }
        }
    }
    if (!bFoundClickedMenuItem) {
        OperatorType[] values = CSGSetOperator.OperatorType.values();
        int numTypes = values.length;
        for (int i = 0; i < numTypes; i++) {
            if (source == addSetOperatorMenuItems[i]) {
                bFoundClickedMenuItem = true;
                CSGSetOperator csgSetOperator = new CSGSetOperator(csgObject.getFreeName(values[i]), values[i]);
                objectToBeSelected = csgSetOperator;
                bGeometryChanged = addNode(csgSetOperator);
                break;
            }
        }
    }
    if (!bFoundClickedMenuItem) {
        TransformationType[] values = CSGTransformation.TransformationType.values();
        int numTypes = values.length;
        for (int i = 0; i < numTypes; i++) {
            if (source == addTranformationMenuItems[i]) {
                bFoundClickedMenuItem = true;
                CSGTransformation csgTransformation = createNewCSGTransformation(values[i]);
                objectToBeSelected = csgTransformation;
                bGeometryChanged = addNode(csgTransformation);
                break;
            }
        }
    }
    if (!bFoundClickedMenuItem) {
        TransformationType[] values = CSGTransformation.TransformationType.values();
        int numTypes = values.length;
        for (int i = 0; i < numTypes; i++) {
            if (source == tranformMenuItems[i]) {
                bFoundClickedMenuItem = true;
                CSGTransformation csgTransformation = createNewCSGTransformation(values[i]);
                objectToBeSelected = csgTransformation;
                bGeometryChanged = transformOrApplySetOperator(csgTransformation);
                break;
            }
        }
    }
    if (!bFoundClickedMenuItem) {
        OperatorType[] values = CSGSetOperator.OperatorType.values();
        int numTypes = values.length;
        for (int i = 0; i < numTypes; i++) {
            if (source == applySetOperatorMenuItems[i]) {
                bFoundClickedMenuItem = true;
                CSGSetOperator csgSetOperator = new CSGSetOperator(csgObject.getFreeName(values[i]), values[i]);
                objectToBeSelected = csgSetOperator;
                bGeometryChanged = transformOrApplySetOperator(csgSetOperator);
                break;
            }
        }
    }
    if (!bGeometryChanged) {
        return;
    }
    updateCSGObject(objectToBeSelected);
}
Also used : CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGPrimitive(cbit.vcell.geometry.CSGPrimitive) CSGObject(cbit.vcell.geometry.CSGObject) PrimitiveType(cbit.vcell.geometry.CSGPrimitive.PrimitiveType) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator) TransformationType(cbit.vcell.geometry.CSGTransformation.TransformationType) Point(java.awt.Point) OperatorType(cbit.vcell.geometry.CSGSetOperator.OperatorType)

Example 3 with OperatorType

use of cbit.vcell.geometry.CSGSetOperator.OperatorType in project vcell by virtualcell.

the class CSGObjectPropertiesPanel method getAddSetOperatorMenu.

private JMenu getAddSetOperatorMenu() {
    if (addSetOperatorMenu == null) {
        addSetOperatorMenu = new JMenu("Set Operator");
        OperatorType[] values = CSGSetOperator.OperatorType.values();
        int numTypes = values.length;
        addSetOperatorMenuItems = new JMenuItem[numTypes];
        for (int i = 0; i < numTypes; i++) {
            addSetOperatorMenuItems[i] = new JMenuItem(values[i].name().toLowerCase());
            addSetOperatorMenuItems[i].addActionListener(eventHandler);
            addSetOperatorMenu.add(addSetOperatorMenuItems[i]);
        }
    }
    return addSetOperatorMenu;
}
Also used : JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) OperatorType(cbit.vcell.geometry.CSGSetOperator.OperatorType) Point(java.awt.Point)

Example 4 with OperatorType

use of cbit.vcell.geometry.CSGSetOperator.OperatorType in project vcell by virtualcell.

the class XmlReader method getCSGSetOperator.

private CSGSetOperator getCSGSetOperator(Element param) throws XmlParseException {
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    String operatorTypeStr = unMangle(param.getAttributeValue(XMLTags.CSGSetOperatorTypeTag));
    // ---Create the new CSGSetOperator object ---
    OperatorType type = CSGSetOperator.OperatorType.valueOf(operatorTypeStr);
    CSGSetOperator csgSetOperator = new CSGSetOperator(name, type);
    List<Element> children = param.getChildren();
    Iterator<Element> iterator = children.iterator();
    int count = 0;
    while (iterator.hasNext()) {
        Element tempElement = iterator.next();
        CSGNode csgNode = getCSGNode(tempElement);
        csgSetOperator.addChild(csgNode);
    }
    return csgSetOperator;
}
Also used : Element(org.jdom.Element) CSGNode(cbit.vcell.geometry.CSGNode) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator) OperatorType(cbit.vcell.geometry.CSGSetOperator.OperatorType)

Aggregations

OperatorType (cbit.vcell.geometry.CSGSetOperator.OperatorType)4 PrimitiveType (cbit.vcell.geometry.CSGPrimitive.PrimitiveType)2 CSGSetOperator (cbit.vcell.geometry.CSGSetOperator)2 Point (java.awt.Point)2 CSGNode (cbit.vcell.geometry.CSGNode)1 CSGObject (cbit.vcell.geometry.CSGObject)1 CSGPrimitive (cbit.vcell.geometry.CSGPrimitive)1 CSGTransformation (cbit.vcell.geometry.CSGTransformation)1 TransformationType (cbit.vcell.geometry.CSGTransformation.TransformationType)1 GeometryContext (cbit.vcell.mapping.GeometryContext)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 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 Element (org.jdom.Element)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