![]() |
![]() |
#include <DetectorDescription/Parser/src/DDLPolyGenerator.h>
Public Member Functions | |
DDLPolyGenerator () | |
Constructor. | |
void | preProcessElement (const std::string &name, const std::string &nmspace) |
Called by loadAttributes AFTER attributes are loaded. | |
void | processElement (const std::string &name, const std::string &nmspace) |
Processing the element. | |
~DDLPolyGenerator () | |
Destructor. |
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 | ( | ) |
DDLPolyGenerator::~DDLPolyGenerator | ( | ) |
void DDLPolyGenerator::preProcessElement | ( | const std::string & | name, | |
const std::string & | nmspace | |||
) | [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 40 of file DDLPolyGenerator.cc.
References DDXMLElement::clear(), and DDLElementRegistry::getElement().
00041 { 00042 DDLElementRegistry::getElement("RZPoint")->clear(); 00043 DDLElementRegistry::getElement("ZSection")->clear(); 00044 }
void DDLPolyGenerator::processElement | ( | const std::string & | name, | |
const std::string & | nmspace | |||
) | [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 49 of file DDLPolyGenerator.cc.
References DDXMLElement::clear(), DCOUT_V, ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), i, DDI::Singleton< I >::instance(), alivecheck_mergeAndRegister::msg, DDSolidFactory::polycone(), DDSolidFactory::polyhedra(), r, DDLSolid::setReference(), DDXMLElement::size(), DDXMLElement::throwError(), and z.
00050 { 00051 DCOUT_V('P', "DDLPolyGenerator::processElement started"); 00052 00053 DDXMLElement* myRZPoints = DDLElementRegistry::getElement("RZPoint"); 00054 DDXMLElement* myZSection = DDLElementRegistry::getElement("ZSection"); 00055 00056 ExprEvalInterface & ev = ExprEvalSingleton::instance(); 00057 DDXMLAttribute atts; 00058 00059 // get z and r 00060 std::vector<double> z, r; 00061 for (size_t i = 0; i < myRZPoints->size(); ++i) 00062 { 00063 atts = myRZPoints->getAttributeSet(i); 00064 z.push_back(ev.eval(nmspace, atts.find("z")->second)); 00065 r.push_back(ev.eval(nmspace, atts.find("r")->second)); 00066 } 00067 00068 // if z is empty, then it better not have been a polycone defined 00069 // by RZPoints, instead, it must be a ZSection defined polycone. 00070 if (z.size() == 0 ) 00071 { 00072 // get zSection information, note, we already have a z declared above 00073 // and we will use r for rmin. In this case, no use "trying" because 00074 // it better be there! 00075 std::vector<double> rMax; 00076 00077 for (size_t i = 0; i < myZSection->size(); ++i) 00078 { 00079 atts = myZSection->getAttributeSet(i); 00080 z.push_back(ev.eval(nmspace, atts.find("z")->second)); 00081 r.push_back(ev.eval(nmspace, atts.find("rMin")->second)); 00082 rMax.push_back(ev.eval(nmspace, atts.find("rMax")->second)); 00083 } 00084 atts = getAttributeSet(); 00085 if (name == "Polycone") // defined with ZSections 00086 { 00087 DDSolid ddpolycone = 00088 DDSolidFactory::polycone(getDDName(nmspace) 00089 , ev.eval(nmspace, atts.find("startPhi")->second) 00090 , ev.eval(nmspace, atts.find("deltaPhi")->second) 00091 , z 00092 , r 00093 , rMax); 00094 } 00095 else if (name == "Polyhedra") // defined with ZSections 00096 { 00097 DDSolid ddpolyhedra = 00098 DDSolidFactory::polyhedra(getDDName(nmspace) 00099 , int (ev.eval(nmspace, atts.find("numSide")->second)) 00100 , ev.eval(nmspace, atts.find("startPhi")->second) 00101 , ev.eval(nmspace, atts.find("deltaPhi")->second) 00102 , z 00103 , r 00104 , rMax); 00105 } 00106 00107 } 00108 else if (name == "Polycone") // defined with RZPoints 00109 { 00110 atts = getAttributeSet(); 00111 DDSolid ddpolycone = 00112 DDSolidFactory::polycone(getDDName(nmspace) 00113 , ev.eval(nmspace, atts.find("startPhi")->second) 00114 , ev.eval(nmspace, atts.find("deltaPhi")->second) 00115 , z 00116 , r); 00117 } 00118 else if (name == "Polyhedra") // defined with RZPoints 00119 { 00120 atts = getAttributeSet(); 00121 DDSolid ddpolyhedra = 00122 DDSolidFactory::polyhedra(getDDName(nmspace) 00123 , int (ev.eval(nmspace, atts.find("numSide")->second)) 00124 , ev.eval(nmspace, atts.find("startPhi")->second) 00125 , ev.eval(nmspace, atts.find("deltaPhi")->second) 00126 , z 00127 , r); 00128 } 00129 else 00130 { 00131 std::string msg = "\nDDLPolyGenerator::processElement was called with incorrect name of solid: " + name; 00132 throwError(msg); 00133 } 00134 DDLSolid::setReference(nmspace); 00135 00136 // clear out RZPoint element accumulator and ZSections 00137 myRZPoints->clear(); 00138 myZSection->clear(); 00139 clear(); 00140 00141 DCOUT_V('P', "DDLPolyGenerator::processElement completed"); 00142 }