CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
DDLMultiUnionSolid Class Referencefinal

This class takes care of processing all MultiUnionSolid type elements. More...

#include <DDLMultiUnionSolid.h>

Inheritance diagram for DDLMultiUnionSolid:
DDLSolid DDXMLElement

Public Member Functions

 DDLMultiUnionSolid (DDLElementRegistry *myreg)
 
void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
 Called by loadAttributes AFTER attributes are loaded. More...
 
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
 Processing the element. More...
 
- Public Member Functions inherited from DDLSolid
 DDLSolid (DDLElementRegistry *myreg)
 Constructor. More...
 
void setReference (const std::string &nmspace, DDCompactView &cpv)
 
- Public Member Functions inherited from DDXMLElement
void appendText (const std::string &inText)
 append to the current (i.e. most recently added) More...
 
virtual std::vector< DDXMLAttribute >::const_iterator begin (void)
 
virtual void clear (void)
 clear this element's contents. More...
 
 DDXMLElement (DDLElementRegistry *myreg)
 Constructor. More...
 
 DDXMLElement (DDLElementRegistry *myreg, const bool &clearme)
 Constructor for autoClear element. More...
 
virtual std::vector< DDXMLAttribute >::const_iterator end (void)
 
virtual const std::string & get (const std::string &name, size_t aIndex=0) const
 Returns a specific value from the aIndex set of attributes. More...
 
virtual const std::string & getAttribute (const std::string &name) const
 Access to attributes by name. More...
 
virtual const DDXMLAttributegetAttributeSet (size_t aIndex=0) const
 Get a "row" of attributes, i.e. one attribute set. More...
 
virtual const DDName getDDName (const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
 
const std::string getText (size_t tindex=0) const
 retrieve the text blob. More...
 
virtual std::vector< std::string > getVectorAttribute (const std::string &name)
 Returns a set of values as a std::vector of strings, given the attribute name. More...
 
virtual bool gotText (void) const
 gotText()? kind of like gotMilk? Yes = text has already been encountered. More...
 
virtual bool isEmpty (void) const
 Have any elements of this type been encountered but not processed? More...
 
void loadAttributes (const std::string &elemName, const std::vector< std::string > &names, const std::vector< std::string > &values, const std::string &nmspace, DDCompactView &cpv)
 Load the element attributes. More...
 
void loadText (const std::string &inText)
 Used to load both text and XML comments into this object. More...
 
std::vector< DDXMLAttribute >::const_iterator & operator++ (int inc)
 Allow the elements of this type to be iterated over using ++ operator. More...
 
const std::string & parent (void) const
 access to parent element name More...
 
void setParent (const std::string &pename)
 Set parent element name to central list of names. More...
 
void setSelf (const std::string &sename)
 Set self element name to central list of names. More...
 
virtual size_t size (void) const
 Number of elements accumulated. More...
 
virtual void stream (std::ostream &os) const
 Allow for the elements to have their own streaming method, but also provide a default. More...
 
void throwError (const std::string &keyMessage) const
 format std::string for throw an error. More...
 
virtual ~DDXMLElement (void)=default
 Destructor. More...
 

Private Member Functions

std::string dumpMultiUnionSolid (const std::string &name, const std::string &nmspace)
 

Additional Inherited Members

- Protected Attributes inherited from DDXMLElement
DDLElementRegistrymyRegistry_
 

Detailed Description

This class takes care of processing all MultiUnionSolid type elements.

This is the MultiUnion processor.

Definition at line 18 of file DDLMultiUnionSolid.h.

Constructor & Destructor Documentation

DDLMultiUnionSolid::DDLMultiUnionSolid ( DDLElementRegistry myreg)

Definition at line 14 of file DDLMultiUnionSolid.cc.

15  : DDLSolid( myreg )
16 {}
DDLSolid(DDLElementRegistry *myreg)
Constructor.
Definition: DDLSolid.cc:11

Member Function Documentation

std::string DDLMultiUnionSolid::dumpMultiUnionSolid ( const std::string &  name,
const std::string &  nmspace 
)
private

Definition at line 97 of file DDLMultiUnionSolid.cc.

References DDXMLElement::getAttributeSet(), DDLElementRegistry::getElement(), mps_fire::i, DDXMLElement::myRegistry_, alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by processElement().

98 {
99  std::string s;
101 
102  s = std::string ("\n<") + name + " name=\"" + atts.find("name")->second + "\"";
103  s += ">\n";
104 
105  auto myrSolids = myRegistry_->getElement("rSolid"); // get rSolid children
106  auto myTranslations = myRegistry_->getElement("Translation"); // get Translation child
107  auto myrRotations = myRegistry_->getElement("rRotation"); // get rRotation child
108  if( myrSolids->size() > 0 )
109  {
110  for( size_t i = 0; i < myrSolids->size(); ++i )
111  {
112  atts = myrSolids->getAttributeSet(i);
113  s+="<rSolid name=\"" + atts.find("name")->second + "\"/>\n";
114  }
115  }
116 
117  for( size_t i = 0; i < myTranslations->size(); ++i )
118  {
119  atts = myTranslations->getAttributeSet(i);
120  s+= "<Translation";
121  if (atts.find("x") != atts.end())
122  s+=" x=\"" + atts.find("x")->second + "\"";
123  if (atts.find("y") != atts.end())
124  s+= " y=\"" + atts.find("y")->second + "\"";
125  if (atts.find("z") != atts.end())
126  s+= " z=\"" + atts.find("z")->second + "\"";
127  s+="/>\n";
128  }
129 
130  for( size_t i = 0; i < myrRotations->size(); ++i )
131  {
132  atts = myrRotations->getAttributeSet(i);
133  if (atts.find("name") != atts.end())
134  {
135  s+= "<rRotation name=\"" + atts.find("name")->second + "\"/>\n";
136  }
137  s+= "</" + name + ">\n\n";
138  }
139 
140  return s;
141 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:172
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:72
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
void DDLMultiUnionSolid::preProcessElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
overridevirtual

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 20 of file DDLMultiUnionSolid.cc.

References DDLElementRegistry::getElement(), and DDXMLElement::myRegistry_.

22 {
23  myRegistry_->getElement( "rSolid" )->clear();
24 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:172
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
void DDLMultiUnionSolid::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
overridevirtual

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 30 of file DDLMultiUnionSolid.cc.

References DDXMLElement::clear(), dumpMultiUnionSolid(), ev, ClhepEvaluator::eval(), DDLElementRegistry::evaluator(), Exception, DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), mps_fire::i, DDSolidFactory::multiUnionSolid(), DDXMLElement::myRegistry_, alignCSCRings::s, DDLSolid::setReference(), AlCaHLTBitMon_QueryRunRegistry::string, DDXMLElement::throwError(), x, y, and z.

32 {
33  // new DDLMultiUnion will handle:
34  // <MultiUnionSolid> <rSolid...> <Translation...> <rRotation...> <rSolid...> <Translation...> <rRotation...> ... </MultiUnionSolid>
35 
36  auto myrSolids = myRegistry_->getElement( "rSolid" ); // get rSolid children
37  auto myTranslations = myRegistry_->getElement( "Translation" ); // get Translation child
38  auto myrRotations = myRegistry_->getElement( "rRotation" ); // get rRotation child
39 
42 
43  std::vector<DDSolid> solids;
44  std::vector<DDTranslation> translations;
45  std::vector<DDRotation> rotations;
46  for( unsigned int i = 0; i < myrSolids->size(); ++i )
47  {
48  DDName ddname = myrSolids->getDDName( nmspace, "name", i );
49  solids.emplace_back( DDSolid( ddname ));
50  }
51  for( unsigned int i = 0; i < myTranslations->size(); ++i )
52  {
53  double x = 0.0, y = 0.0, z = 0.0;
54  atts = myTranslations->getAttributeSet(i);
55  x = ev.eval(nmspace, atts.find("x")->second);
56  y = ev.eval(nmspace, atts.find("y")->second);
57  z = ev.eval(nmspace, atts.find("z")->second);
58  translations.emplace_back( DDTranslation( x, y, z ));
59  }
60  for( unsigned int i = 0; i < myrRotations->size(); ++i )
61  {
62  DDRotation ddrot = myrRotations->getDDName( nmspace, "name", i );
63  rotations.emplace_back( ddrot );
64  }
65 
66  // Basically check if there are rSolids or Translation or rRotation then we have
67  // should NOT have any of the attributes shown above.
68  if( myrSolids->size() == 0 )
69  {
70  std::string s( "DDLMultiUnionSolid did not find any solids with which to form a multi union solid." );
71  s += dumpMultiUnionSolid(name, nmspace);
72  throwError( s );
73  }
74 
75  DDSolid theSolid;
76 
77  if (name == "MultiUnionSolid") {
78  theSolid = DDSolidFactory::multiUnionSolid( getDDName( nmspace ),
79  solids,
80  translations,
81  rotations );
82  }
83  else {
84  throw cms::Exception("DDException") << "DDLMultiUnionSolid was asked to do something other than MultiUnion-?";
85  }
86 
87  DDLSolid::setReference( nmspace, cpv );
88 
89  // clear all "children" and attributes
90  myTranslations->clear();
91  myrRotations->clear();
92  myrSolids->clear();
93  clear();
94 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:172
static DDSolid multiUnionSolid(const DDName &name, const std::vector< DDSolid > &a, const std::vector< DDTranslation > &t, const std::vector< DDRotation > &r)
Definition: DDSolid.cc:890
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:72
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
bool ev
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
ClhepEvaluator & evaluator()
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
double eval(const std::string &ns, const std::string &expr)
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:54
std::string dumpMultiUnionSolid(const std::string &name, const std::string &nmspace)
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:79
void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLSolid.cc:16