DDLPolyGenerator processes DDL XML Polycone and DDL XML Polyhedra elements. More...
#include <DDLPolyGenerator.h>
Public Member Functions | |
DDLPolyGenerator (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. | |
~DDLPolyGenerator (void) | |
Destructor. |
DDLPolyGenerator processes DDL XML Polycone and DDL XML Polyhedra elements.
DDLPolyGenerator.h - description ------------------- begin: Mon Aug 5 2002 email: case@ucdhep.ucdavis.edu
The PolyGenerator element uses RZPoint elements. The DDLRZPoint can return the r and z std::vectors with the points needed to form the polycone. The RZPoint "accumulator" is also used by the Polyhedra and Polycone elements, and could be used anywhere a pair of std::vectors of r and z values are needed.
Definition at line 25 of file DDLPolyGenerator.h.
DDLPolyGenerator::DDLPolyGenerator | ( | DDLElementRegistry * | myreg | ) |
DDLPolyGenerator::~DDLPolyGenerator | ( | void | ) |
void DDLPolyGenerator::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 30 of file DDLPolyGenerator.cc.
References DDXMLElement::clear(), DDLElementRegistry::getElement(), and DDXMLElement::myRegistry_.
{ myRegistry_->getElement("RZPoint")->clear(); myRegistry_->getElement("ZSection")->clear(); }
void DDLPolyGenerator::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 40 of file DDLPolyGenerator.cc.
References DDXMLElement::clear(), DCOUT_V, ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), i, DDI::Singleton< I >::instance(), MatrixRunner::msg, DDXMLElement::myRegistry_, mergeVDriftHistosByStation::name, DDSolidFactory::polycone(), DDSolidFactory::polyhedra(), csvReporter::r, DDLSolid::setReference(), DDXMLElement::size(), DDXMLElement::throwError(), and z.
{ DCOUT_V('P', "DDLPolyGenerator::processElement started"); DDXMLElement* myRZPoints = myRegistry_->getElement("RZPoint"); DDXMLElement* myZSection = myRegistry_->getElement("ZSection"); ExprEvalInterface & ev = ExprEvalSingleton::instance(); DDXMLAttribute atts; // get z and r std::vector<double> z, r; for (size_t i = 0; i < myRZPoints->size(); ++i) { atts = myRZPoints->getAttributeSet(i); z.push_back(ev.eval(nmspace, atts.find("z")->second)); r.push_back(ev.eval(nmspace, atts.find("r")->second)); } // if z is empty, then it better not have been a polycone defined // by RZPoints, instead, it must be a ZSection defined polycone. if (z.size() == 0 ) { // get zSection information, note, we already have a z declared above // and we will use r for rmin. In this case, no use "trying" because // it better be there! std::vector<double> rMax; for (size_t i = 0; i < myZSection->size(); ++i) { atts = myZSection->getAttributeSet(i); z.push_back(ev.eval(nmspace, atts.find("z")->second)); r.push_back(ev.eval(nmspace, atts.find("rMin")->second)); rMax.push_back(ev.eval(nmspace, atts.find("rMax")->second)); } atts = getAttributeSet(); if (name == "Polycone") // defined with ZSections { DDSolid ddpolycone = DDSolidFactory::polycone(getDDName(nmspace) , ev.eval(nmspace, atts.find("startPhi")->second) , ev.eval(nmspace, atts.find("deltaPhi")->second) , z , r , rMax); } else if (name == "Polyhedra") // defined with ZSections { DDSolid ddpolyhedra = DDSolidFactory::polyhedra(getDDName(nmspace) , int (ev.eval(nmspace, atts.find("numSide")->second)) , ev.eval(nmspace, atts.find("startPhi")->second) , ev.eval(nmspace, atts.find("deltaPhi")->second) , z , r , rMax); } } else if (name == "Polycone") // defined with RZPoints { atts = getAttributeSet(); DDSolid ddpolycone = DDSolidFactory::polycone(getDDName(nmspace) , ev.eval(nmspace, atts.find("startPhi")->second) , ev.eval(nmspace, atts.find("deltaPhi")->second) , z , r); } else if (name == "Polyhedra") // defined with RZPoints { atts = getAttributeSet(); DDSolid ddpolyhedra = DDSolidFactory::polyhedra(getDDName(nmspace) , int (ev.eval(nmspace, atts.find("numSide")->second)) , ev.eval(nmspace, atts.find("startPhi")->second) , ev.eval(nmspace, atts.find("deltaPhi")->second) , z , r); } else { std::string msg = "\nDDLPolyGenerator::processElement was called with incorrect name of solid: " + name; throwError(msg); } DDLSolid::setReference(nmspace, cpv); // clear out RZPoint element accumulator and ZSections myRZPoints->clear(); myZSection->clear(); clear(); DCOUT_V('P', "DDLPolyGenerator::processElement completed"); }