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

Member Function Documentation

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

Definition at line 125 of file DDLBooleanSolid.cc.

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

Referenced by processElement().

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

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 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 29 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.

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