use of cbit.vcell.geometry.CSGNode in project vcell by virtualcell.
the class XmlReader method getCSGRotation.
private CSGRotation getCSGRotation(Element param) throws XmlParseException {
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String rotateXStr = unMangle(param.getAttributeValue(XMLTags.CSGRotationXTag));
String rotateYStr = unMangle(param.getAttributeValue(XMLTags.CSGRotationYTag));
String rotateZStr = unMangle(param.getAttributeValue(XMLTags.CSGRotationZTag));
String rotationAngleStr = unMangle(param.getAttributeValue(XMLTags.CSGRotationAngleInRadiansTag));
Vect3d rotationAxis = new Vect3d(Double.parseDouble(rotateXStr), Double.parseDouble(rotateYStr), Double.parseDouble(rotateZStr));
CSGRotation csgRotation = new CSGRotation(name, rotationAxis, Double.parseDouble(rotationAngleStr));
// Retrieve CSGNode - CSGRotation element should have one child
Object[] elements = param.getChildren().toArray();
if (elements.length > 1) {
throw new XmlParseException("CSGRotation element cannot have more than one child element");
}
CSGNode csgChildNode = getCSGNode((Element) elements[0]);
csgRotation.setChild(csgChildNode);
return csgRotation;
}
use of cbit.vcell.geometry.CSGNode 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;
}
use of cbit.vcell.geometry.CSGNode in project vcell by virtualcell.
the class XmlReader method getCSGNode.
private CSGNode getCSGNode(Element param) throws XmlParseException {
String nodeNameString = param.getName();
CSGNode csgNode = null;
if (nodeNameString != null) {
if (nodeNameString.equalsIgnoreCase(XMLTags.CSGPrimitiveTag)) {
// Process CSGPrimitive
csgNode = getCSGPrimitive(param);
} else if (nodeNameString.equalsIgnoreCase(XMLTags.CSGPseudoPrimitiveTag)) {
// Process CSGPseudoPrimitive
csgNode = getCSGPseudoPrimitive(param);
} else if (nodeNameString.equalsIgnoreCase(XMLTags.CSGSetOperatorTag)) {
// Process CSGSetOperator
csgNode = getCSGSetOperator(param);
} else if (nodeNameString.equalsIgnoreCase(XMLTags.CSGHomogeneousTransformationTag)) {
// Process CSGHomogeneousTransformation
csgNode = getCSGHomogeneousTransformation(param);
} else if (nodeNameString.equalsIgnoreCase(XMLTags.CSGRotationTag)) {
// Process CSGRotation
csgNode = getCSGRotation(param);
} else if (nodeNameString.equalsIgnoreCase(XMLTags.CSGScaleTag)) {
// Process CSGScale
csgNode = getCSGScale(param);
} else if (nodeNameString.equalsIgnoreCase(XMLTags.CSGTranslationTag)) {
// Process CSGTranslation
csgNode = getCSGTranslation(param);
} else {
// Throw an exception
throw new XmlParseException("Parse Error! Unknown CSGNode type : " + nodeNameString);
}
} else {
throw new XmlParseException("CSGNode : cannot be null");
}
return csgNode;
}
use of cbit.vcell.geometry.CSGNode in project vcell by virtualcell.
the class XmlReader method getCSGScale.
private CSGScale getCSGScale(Element param) throws XmlParseException {
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String scaleXStr = unMangle(param.getAttributeValue(XMLTags.CSGScaleXTag));
String scaleYStr = unMangle(param.getAttributeValue(XMLTags.CSGScaleYTag));
String scaleZStr = unMangle(param.getAttributeValue(XMLTags.CSGScaleZTag));
Vect3d scaleAxis = new Vect3d(Double.parseDouble(scaleXStr), Double.parseDouble(scaleYStr), Double.parseDouble(scaleZStr));
CSGScale csgScale = new CSGScale(name, scaleAxis);
// Retrieve CSGNode - CSGScale element should have one child
Object[] elements = param.getChildren().toArray();
if (elements.length > 1) {
throw new XmlParseException("CSGScale element cannot have more than one child element");
}
CSGNode csgChildNode = getCSGNode((Element) elements[0]);
csgScale.setChild(csgChildNode);
return csgScale;
}
use of cbit.vcell.geometry.CSGNode in project vcell by virtualcell.
the class Xmlproducer method getXML.
private Element getXML(CSGSetOperator param) {
Element csgSetOperatorElement = new Element(XMLTags.CSGSetOperatorTag);
csgSetOperatorElement.setAttribute(XMLTags.NameAttrTag, mangle(param.getName()));
csgSetOperatorElement.setAttribute(XMLTags.CSGSetOperatorTypeTag, mangle(param.getOpType().name()));
ArrayList<CSGNode> setOpChildren = param.getChildren();
Element csgNodeElement = null;
for (CSGNode setOpNode : setOpChildren) {
csgNodeElement = getXML(setOpNode);
csgSetOperatorElement.addContent(csgNodeElement);
}
return csgSetOperatorElement;
}
Aggregations