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:12

Member Function Documentation

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

Definition at line 95 of file DDLMultiUnionSolid.cc.

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

Referenced by processElement().

96 {
97  std::string s;
99 
100  s = std::string ("\n<") + name + " name=\"" + atts.find("name")->second + "\"";
101  s += ">\n";
102 
103  auto myrSolids = myRegistry_->getElement("rSolid"); // get rSolid children
104  auto myTranslations = myRegistry_->getElement("Translation"); // get Translation child
105  auto myrRotations = myRegistry_->getElement("rRotation"); // get rRotation child
106  if( myrSolids->size() > 0 )
107  {
108  for( size_t i = 0; i < myrSolids->size(); ++i )
109  {
110  atts = myrSolids->getAttributeSet(i);
111  s+="<rSolid name=\"" + atts.find("name")->second + "\"/>\n";
112  }
113  }
114 
115  for( size_t i = 0; i < myTranslations->size(); ++i )
116  {
117  atts = myTranslations->getAttributeSet(i);
118  s+= "<Translation";
119  if (atts.find("x") != atts.end())
120  s+=" x=\"" + atts.find("x")->second + "\"";
121  if (atts.find("y") != atts.end())
122  s+= " y=\"" + atts.find("y")->second + "\"";
123  if (atts.find("z") != atts.end())
124  s+= " z=\"" + atts.find("z")->second + "\"";
125  s+="/>\n";
126  }
127 
128  for( size_t i = 0; i < myrRotations->size(); ++i )
129  {
130  atts = myrRotations->getAttributeSet(i);
131  if (atts.find("name") != atts.end())
132  {
133  s+= "<rRotation name=\"" + atts.find("name")->second + "\"/>\n";
134  }
135  s+= "</" + name + ">\n\n";
136  }
137 
138  return s;
139 }
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:73
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_.

21 {
22  myRegistry_->getElement( "rSolid" )->clear();
23 }
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 29 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.

30 {
31  // new DDLMultiUnion will handle:
32  // <MultiUnionSolid> <rSolid...> <Translation...> <rRotation...> <rSolid...> <Translation...> <rRotation...> ... </MultiUnionSolid>
33 
34  auto myrSolids = myRegistry_->getElement( "rSolid" ); // get rSolid children
35  auto myTranslations = myRegistry_->getElement( "Translation" ); // get Translation child
36  auto myrRotations = myRegistry_->getElement( "rRotation" ); // get rRotation child
37 
40 
41  std::vector<DDSolid> solids;
42  std::vector<DDTranslation> translations;
43  std::vector<DDRotation> rotations;
44  for( unsigned int i = 0; i < myrSolids->size(); ++i )
45  {
46  DDName ddname = myrSolids->getDDName( nmspace, "name", i );
47  solids.emplace_back( DDSolid( ddname ));
48  }
49  for( unsigned int i = 0; i < myTranslations->size(); ++i )
50  {
51  double x = 0.0, y = 0.0, z = 0.0;
52  atts = myTranslations->getAttributeSet(i);
53  x = ev.eval(nmspace, atts.find("x")->second);
54  y = ev.eval(nmspace, atts.find("y")->second);
55  z = ev.eval(nmspace, atts.find("z")->second);
56  translations.emplace_back( DDTranslation( x, y, z ));
57  }
58  for( unsigned int i = 0; i < myrRotations->size(); ++i )
59  {
60  DDRotation ddrot = myrRotations->getDDName( nmspace, "name", i );
61  rotations.emplace_back( ddrot );
62  }
63 
64  // Basically check if there are rSolids or Translation or rRotation then we have
65  // should NOT have any of the attributes shown above.
66  if( myrSolids->size() == 0 )
67  {
68  std::string s( "DDLMultiUnionSolid did not find any solids with which to form a multi union solid." );
69  s += dumpMultiUnionSolid(name, nmspace);
70  throwError( s );
71  }
72 
73  DDSolid theSolid;
74 
75  if (name == "MultiUnionSolid") {
76  theSolid = DDSolidFactory::multiUnionSolid( getDDName( nmspace ),
77  solids,
78  translations,
79  rotations );
80  }
81  else {
82  throw cms::Exception("DDException") << "DDLMultiUnionSolid was asked to do something other than MultiUnion-?";
83  }
84 
85  DDLSolid::setReference( nmspace, cpv );
86 
87  // clear all "children" and attributes
88  myTranslations->clear();
89  myrRotations->clear();
90  myrSolids->clear();
91  clear();
92 }
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:887
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:73
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:64
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:55
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:80
void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLSolid.cc:17