CMS 3D CMS Logo

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

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

#include <DDLBooleanSolid.h>

Inheritance diagram for DDLBooleanSolid:
DDLSolid DDXMLElement

Public Member Functions

 DDLBooleanSolid (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 dumpBooleanSolid (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 BooleanSolid type elements.

Author
Michael Case

DDLBooleanSolid.h - description

begin: Wed Dec 12, 2001 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

This is the Intersection, Subtraction and Union processor. A BooleanSolid handles all of these because as far as the DDL is concerned, they have the same basic form, including two solid references, and potentially one translation and one rotation.

Definition at line 27 of file DDLBooleanSolid.h.

Constructor & Destructor Documentation

◆ DDLBooleanSolid()

DDLBooleanSolid::DDLBooleanSolid ( DDLElementRegistry myreg)

Definition at line 14 of file DDLBooleanSolid.cc.

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

Member Function Documentation

◆ dumpBooleanSolid()

std::string DDLBooleanSolid::dumpBooleanSolid ( const std::string &  name,
const std::string &  nmspace 
)
private

Definition at line 99 of file DDLBooleanSolid.cc.

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

Referenced by processElement().

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

◆ preProcessElement()

void DDLBooleanSolid::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 17 of file DDLBooleanSolid.cc.

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

17  {
18  myRegistry_->getElement("rSolid")->clear();
19 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.

◆ processElement()

void DDLBooleanSolid::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 24 of file DDLBooleanSolid.cc.

References DDXMLElement::clear(), dumpBooleanSolid(), makeMEIFBenchmarkPlots::ev, DDLElementRegistry::evaluator(), Exception, DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), DDSolidFactory::intersection(), DDXMLElement::myRegistry_, Skims_PA_cff::name, alignCSCRings::s, DDLSolid::setReference(), AlCaHLTBitMon_QueryRunRegistry::string, DDSolidFactory::subtraction(), DDXMLElement::throwError(), DDSolidFactory::unionSolid(), x, y, and z.

24  {
25  // new DDLBoolean will handle:
26  // <UnionSolid name="bs" firstSolid="blah" secondSolid="argh"> <Translation...> <rRotation .../> </UnionSolid
27  // AND <UnionSolid> <rSolid...> <rSolid...> <Translation...> <rRotation...> </UnionSolid>
28 
29  auto myrSolid = myRegistry_->getElement("rSolid"); // get rSolid children
30  auto myTranslation = myRegistry_->getElement("Translation"); // get Translation child
31  auto myrRotation = myRegistry_->getElement("rRotation"); // get rRotation child
32 
35 
36  DDName ddn1, ddn2;
37  double x = 0.0, y = 0.0, z = 0.0;
38  DDRotation ddrot;
39 
40  // Basically check if there are rSolids or Translation or rRotation then we have
41  // should NOT have any of the attributes shown above.
42  if (myrSolid->size() == 0) {
43  // do the solids using the attributes only.
44  if (atts.find("firstSolid") != atts.end() && atts.find("secondSolid") != atts.end()) {
45  ddn1 = getDDName(nmspace, "firstSolid");
46  ddn2 = getDDName(nmspace, "secondSolid");
47  } else {
48  std::string s("DDLBooleanSolid did not find any solids with which to form a boolean solid.");
49  s += dumpBooleanSolid(name, nmspace);
50  throwError(s);
51  }
52  } else if (myrSolid->size() == 2) {
53  ddn1 = myrSolid->getDDName(nmspace, "name", 0);
54  ddn2 = myrSolid->getDDName(nmspace, "name", 1);
55  } else {
56  std::string s("DDLBooleanSolid did not find any solids with which to form a boolean solid.");
57  s += dumpBooleanSolid(name, nmspace);
58  throwError(s);
59  }
60 
61  if (myTranslation->size() > 0) {
62  atts.clear();
63  atts = myTranslation->getAttributeSet();
64  x = ev.eval(nmspace, atts.find("x")->second);
65  y = ev.eval(nmspace, atts.find("y")->second);
66  z = ev.eval(nmspace, atts.find("z")->second);
67  }
68 
69  if (myrRotation->size() > 0) {
70  ddrot = DDRotation(myrRotation->getDDName(nmspace));
71  }
72 
73  DDSolid theSolid;
74 
75  if (name == "UnionSolid") {
76  theSolid =
77  DDSolidFactory::unionSolid(getDDName(nmspace), DDSolid(ddn1), DDSolid(ddn2), DDTranslation(x, y, z), ddrot);
78  } else if (name == "SubtractionSolid") {
79  theSolid =
80  DDSolidFactory::subtraction(getDDName(nmspace), DDSolid(ddn1), DDSolid(ddn2), DDTranslation(x, y, z), ddrot);
81  } else if (name == "IntersectionSolid") {
82  theSolid =
83  DDSolidFactory::intersection(getDDName(nmspace), DDSolid(ddn1), DDSolid(ddn2), DDTranslation(x, y, z), ddrot);
84  } else {
85  throw cms::Exception("DDException")
86  << "DDLBooleanSolid was asked to do something other than Union-, Subtraction- or IntersectionSolid?";
87  }
88 
89  DDLSolid::setReference(nmspace, cpv);
90 
91  // clear all "children" and attributes
92  myTranslation->clear();
93  myrRotation->clear();
94  myrSolid->clear();
95  clear();
96 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
ClhepEvaluator & evaluator()
static DDSolid intersection(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:604
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
std::string dumpBooleanSolid(const std::string &name, const std::string &nmspace)
static DDSolid subtraction(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:599
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:40
static DDSolid unionSolid(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:594
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLSolid.cc:13