CMS 3D CMS Logo

DDLBooleanSolid.cc
Go to the documentation of this file.
11 
12 class DDCompactView;
13 
15 
16 // Clear out rSolids.
18  myRegistry_->getElement("rSolid")->clear();
19 }
20 
21 // To process a BooleanSolid we should have in the meantime
22 // hit two rSolid calls and possibly one rRotation and one Translation.
23 // So, retrieve them and make the call to DDCore.
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 }
97 
98 // This only happens on error, so I don't care how "slow" it is :-)
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 }
DDLBooleanSolid::preProcessElement
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
Definition: DDLBooleanSolid.cc:17
DDXMLElement::clear
virtual void clear(void)
clear this element's contents.
Definition: DDXMLElement.cc:40
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
DDTransform.h
DDXMLElement::throwError
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
Definition: DDXMLElement.cc:209
DDLSolid::setReference
void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLSolid.cc:13
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDLSolid
DDLSolid processes Box elements.
Definition: DDLSolid.h:30
ClhepEvaluator.h
DDLElementRegistry
The main class for processing parsed elements.
Definition: DDLElementRegistry.h:23
ClhepEvaluator
Definition: ClhepEvaluator.h:8
DDAxes::x
DDLBooleanSolid.h
DDXMLElement::getAttributeSet
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
DDLElementRegistry::evaluator
ClhepEvaluator & evaluator()
Definition: DDLElementRegistry.h:42
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DDSolidFactory::subtraction
static DDSolid subtraction(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:585
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDAxes::z
DDSolid.h
DDXMLAttribute
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDSolidFactory::intersection
static DDSolid intersection(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:590
DDLBooleanSolid::dumpBooleanSolid
std::string dumpBooleanSolid(const std::string &name, const std::string &nmspace)
Definition: DDLBooleanSolid.cc:99
DDTranslation.h
DDLElementRegistry.h
DDSolidFactory::unionSolid
static DDSolid unionSolid(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:580
DDLSolid.h
DDXMLElement::getDDName
const virtual DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56
DDLElementRegistry::getElement
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
Definition: DDLElementRegistry.cc:42
DDXMLElement.h
DDName.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDLBooleanSolid::processElement
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
Definition: DDLBooleanSolid.cc:24
Exception.h
DDXMLElement::myRegistry_
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18
DDLBooleanSolid::DDLBooleanSolid
DDLBooleanSolid(DDLElementRegistry *myreg)
Definition: DDLBooleanSolid.cc:14