DDLPosPart handles PosPart elements. More...
#include <DDLPosPart.h>
Public Member Functions | |
DDLPosPart (DDLElementRegistry *myreg) | |
Constructor. | |
void | preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Called by loadAttributes AFTER attributes are loaded. | |
void | processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Processing the element. | |
~DDLPosPart (void) | |
Destructor. |
DDLPosPart handles PosPart elements.
DDLPosPart.h - description ------------------- begin: Tue Oct 30 2001 email: case@ucdhep.ucdavis.edu
A PosPart (or Positioning Part or Part Positioner :-)) is used to position a LogicalPart somewhere inside it's parent. So, A PosPart needs two rLogicalParts (self and parent) on which to operate, a Translation and a Rotation.
Definition at line 24 of file DDLPosPart.h.
DDLPosPart::DDLPosPart | ( | DDLElementRegistry * | myreg | ) |
DDLPosPart::~DDLPosPart | ( | void | ) |
void DDLPosPart::preProcessElement | ( | const std::string & | name, |
const std::string & | nmspace, | ||
DDCompactView & | cpv | ||
) | [virtual] |
Called by loadAttributes AFTER attributes are loaded.
The preProcessElement method can assume that the attributes are loaded and perform any code that is necessary at the start of an element.
This would allow users to call their own code to setup anything necessary for the continued processing of the child elements.
Reimplemented from DDXMLElement.
Definition at line 35 of file DDLPosPart.cc.
References DDXMLElement::clear(), DCOUT_V, DDLElementRegistry::getElement(), and DDXMLElement::myRegistry_.
{ DCOUT_V('P', "DDLPosPart::preProcessElement started"); // Clear out child elements. myRegistry_->getElement("Rotation")->clear(); myRegistry_->getElement("ReflectionRotation")->clear(); DCOUT_V('P', "DDLPosPart::preProcessElement completed"); }
void DDLPosPart::processElement | ( | const std::string & | name, |
const std::string & | nmspace, | ||
DDCompactView & | cpv | ||
) | [virtual] |
Processing the element.
The processElement method completes any necessary work to process the XML element.
For example, this can be used to call the DDCore to make the geometry in memory. There is a default for this so that if not declared in the inheriting class, no processing is done.
Reimplemented from DDXMLElement.
Definition at line 50 of file DDLPosPart.cc.
References DDXMLElement::clear(), DCOUT_V, DDrot(), ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), instance, DDBase< N, C >::isValid(), DDXMLElement::myRegistry_, DDName::name(), DDName::ns(), DDCompactView::position(), DDXMLElement::size(), groupFilesInBlocks::temp, x, detailsBasic3DVector::y, and z.
{ DCOUT_V('P', "DDLPosPart::processElement started"); // get all internal elements. DDXMLElement* myParent = myRegistry_->getElement("rParent"); DDXMLElement* myChild = myRegistry_->getElement("rChild"); DDXMLElement* myTranslation= myRegistry_->getElement("Translation"); DDXMLElement* myDDLRotation= myRegistry_->getElement("Rotation"); DDXMLElement* myrRotation = myRegistry_->getElement("rRotation"); DDXMLElement* myDDLRefl = myRegistry_->getElement("ReflectionRotation"); DDXMLElement* myrRefl = myRegistry_->getElement("rReflectionRotation"); // FIXME!!! add in the new RotationByAxis element... // At this time, PosPart is becoming the most complex of the elements. // For simply reflections/rotations we have 4 possible internal "components" // to the PosPart. We take them in the following order of priority // rRotation, Rotation, rReflectionRotation, ReflectionRotation. // // The idea in the following if-else-if is that no matter // what was used inside the PosPart element, the order in which we // will look for and use an internal element is: // rRotation, Rotation, ReflectionRotation, rReflectionRotation. // If it falls through here, a default call will result in a nameless // "identity" rotation being passed to DDCore. DDName rotn; if (myrRotation->size() > 0){ rotn = myrRotation->getDDName(nmspace); } else if (myDDLRotation->size() > 0) { // The assumption here is that the Rotation element created // a DDRotation already, and so we can use this as an rRotation // just provide DDCore with the name of the one just added... // How to handle name conflicts? OVERWRITTEN by DDCore for now. rotn = myDDLRotation->getDDName(nmspace); } else if (myDDLRefl->size() > 0) { // The assumption is that a ReflectionRotation has been created and therefore // we can refer to it as the rotation associated with this PosPart. // we can further assume that the namespace is the same as this PosPart. rotn = myDDLRefl->getDDName(nmspace); } else if (myrRefl->size() > 0) { rotn = myrRefl->getDDName(nmspace); } DCOUT_V('P', "DDLPosPart::processElement: Final Rotation info: " << rotn); ExprEvalInterface & ev = ExprEvalSingleton::instance(); double x = 0.0, y = 0.0, z = 0.0; if (myTranslation->size() > 0) { const DDXMLAttribute & atts = myTranslation->getAttributeSet(); x = ev.eval(nmspace, atts.find("x")->second); y = ev.eval(nmspace, atts.find("y")->second); z = ev.eval(nmspace, atts.find("z")->second); } DCOUT_V('P', "DDLPosPart::processElement: Final Translation info x=" << x << " y=" << y << " z=" << z); DDRotation* myDDRotation; // if rotation is named ... if ( rotn.name() != "" && rotn.ns() != "" ) { DDRotation temp(rotn); myDDRotation = &temp; } else { // rotn is not assigned a name anywhere therefore the DDPos assumes the identity matrix. DDRotation temp(DDName(std::string("identity"),std::string("generatedForDDD"))); myDDRotation = &temp; // if the identity is not yet defined, then... if ( !myDDRotation->isValid() ) { DDRotationMatrix* dmr = new DDRotationMatrix; temp = DDrot(DDName(std::string("identity"),std::string("generatedForDDD")), dmr ); myDDRotation = &temp; } } DDTranslation myDDTranslation(x, y, z); DCOUT_V('P', "about to make a PosPart ..."); DCOUT_V('p', " myDDRotation : " << *myDDRotation); DCOUT_V('p', " myDDTranslation : " << myDDTranslation); DCOUT_V('p', " parentDDName : " << myParent->getDDName(nmspace)); DCOUT_V('p', " selfDDName : " << myChild->getDDName(nmspace)); const DDXMLAttribute & atts = getAttributeSet(); std::string copyno = ""; if (atts.find("copyNumber") != atts.end()) copyno = atts.find("copyNumber")->second; cpv.position(DDLogicalPart(myChild->getDDName(nmspace)) , DDLogicalPart(myParent->getDDName(nmspace)) , copyno , myDDTranslation , *myDDRotation); // clear all "children" and attributes myParent->clear(); myChild->clear(); myTranslation->clear(); myDDLRotation->clear(); myrRotation->clear(); myDDLRefl->clear(); myrRefl->clear(); // after a pos part is done, we know we can clear it. clear(); DCOUT_V('P', "DDLPosPart::processElement completed"); }