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