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 ( DDLElementRegistry myreg)

Definition at line 14 of file DDLBooleanSolid.cc.

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

Member Function Documentation

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

Definition at line 126 of file DDLBooleanSolid.cc.

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

Referenced by processElement().

127 {
128  std::string s;
130 
131  s = std::string ("\n<") + name + " name=\"" + atts.find("name")->second + "\"";
132 
133  if (atts.find("firstSolid") != atts.end()) s+= " firstSolid=\"" + atts.find("firstSolid")->second + "\"";
134  if (atts.find("secondSolid") != atts.end()) s+= " secondSolid=\"" + atts.find("secondSolid")->second + "\"";
135  s += ">\n";
136 
137  auto myrSolid = myRegistry_->getElement("rSolid"); // get rSolid children
138  auto myTranslation = myRegistry_->getElement("Translation"); // get Translation child
139  auto myrRotation = myRegistry_->getElement("rRotation"); // get rRotation child
140  if (myrSolid->size() > 0)
141  {
142  for (size_t i = 0; i < myrSolid->size(); ++i)
143  {
144  atts = myrSolid->getAttributeSet(i);
145  s+="<rSolid name=\"" + atts.find("name")->second + "\"/>\n";
146  }
147  }
148 
149  atts = myTranslation->getAttributeSet();
150  s+= "<Translation";
151  if (atts.find("x") != atts.end())
152  s+=" x=\"" + atts.find("x")->second + "\"";
153  if (atts.find("y") != atts.end())
154  s+= " y=\"" + atts.find("y")->second + "\"";
155  if (atts.find("z") != atts.end())
156  s+= " z=\"" + atts.find("z")->second + "\"";
157  s+="/>\n";
158 
159  atts = myrRotation->getAttributeSet();
160  if (atts.find("name") != atts.end())
161  {
162  s+= "<rRotation name=\"" + atts.find("name")->second + "\"/>\n";
163  }
164  s+= "</" + name + ">\n\n";
165  return s;
166 }
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 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 20 of file DDLBooleanSolid.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 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 30 of file DDLBooleanSolid.cc.

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

31 {
32  // new DDLBoolean will handle:
33  // <UnionSolid name="bs" firstSolid="blah" secondSolid="argh"> <Translation...> <rRotation .../> </UnionSolid
34  // AND <UnionSolid> <rSolid...> <rSolid...> <Translation...> <rRotation...> </UnionSolid>
35 
36  auto myrSolid = myRegistry_->getElement( "rSolid" ); // get rSolid children
37  auto myTranslation = myRegistry_->getElement( "Translation" ); // get Translation child
38  auto myrRotation = myRegistry_->getElement( "rRotation" ); // get rRotation child
39 
42 
43  DDName ddn1, ddn2;
44  double x=0.0, y=0.0, z=0.0;
45  DDRotation ddrot;
46 
47  // Basically check if there are rSolids or Translation or rRotation then we have
48  // should NOT have any of the attributes shown above.
49  if( myrSolid->size() == 0 )
50  {
51  // do the solids using the attributes only.
52  if ( atts.find("firstSolid") != atts.end() && atts.find("secondSolid") != atts.end() ) {
53  ddn1 = getDDName(nmspace, "firstSolid");
54  ddn2 = getDDName(nmspace, "secondSolid");
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  else if (myrSolid->size() == 2)
62  {
63  ddn1 = myrSolid->getDDName(nmspace, "name", 0);
64  ddn2 = myrSolid->getDDName(nmspace, "name", 1);
65  } else {
66  std::string s("DDLBooleanSolid did not find any solids with which to form a boolean solid.");
67  s += dumpBooleanSolid(name, nmspace);
68  throwError( s );
69  }
70 
71  if (myTranslation->size() > 0)
72  {
73  atts.clear();
74  atts = myTranslation->getAttributeSet();
75  x = ev.eval(nmspace, atts.find("x")->second);
76  y = ev.eval(nmspace, atts.find("y")->second);
77  z = ev.eval(nmspace, atts.find("z")->second);
78  }
79 
80  if (myrRotation->size() > 0)
81  {
82  ddrot = DDRotation( myrRotation->getDDName (nmspace) );
83  }
84 
85  DDSolid theSolid;
86 
87  if (name == "UnionSolid") {
88  theSolid = DDSolidFactory::unionSolid (getDDName(nmspace)
89  , DDSolid(ddn1)
90  , DDSolid(ddn2)
91  , DDTranslation(x, y, z)
92  , ddrot
93  );
94  }
95  else if (name == "SubtractionSolid") {
96  theSolid = DDSolidFactory::subtraction (getDDName(nmspace)
97  , DDSolid(ddn1)
98  , DDSolid(ddn2)
99  , DDTranslation(x, y, z)
100  , ddrot
101  );
102  }
103  else if (name == "IntersectionSolid") {
104  theSolid = DDSolidFactory::intersection (getDDName(nmspace)
105  , DDSolid(ddn1)
106  , DDSolid(ddn2)
107  , DDTranslation(x, y, z)
108  , ddrot
109  );
110  }
111  else {
112  throw cms::Exception("DDException") << "DDLBooleanSolid was asked to do something other than Union-, Subtraction- or IntersectionSolid?";
113  }
114 
115  DDLSolid::setReference(nmspace, cpv);
116 
117  // clear all "children" and attributes
118  myTranslation->clear();
119  myrRotation->clear();
120  myrSolid->clear();
121  clear();
122 }
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
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()
static DDSolid intersection(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:785
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:776
double eval(const std::string &ns, const std::string &expr)
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:54
static DDSolid unionSolid(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:767
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