CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions
DDLBooleanSolid Class Reference

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)
 Constructor. More...
 
void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Called by loadAttributes AFTER attributes are loaded. More...
 
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Processing the element. More...
 
 ~DDLBooleanSolid ()
 Destructor. More...
 
- Public Member Functions inherited from DDLSolid
 DDLSolid (DDLElementRegistry *myreg)
 Constructor. More...
 
void setReference (const std::string &nmspace, DDCompactView &cpv)
 
virtual ~DDLSolid (void)
 Destructor. More...
 
- 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)
 Destructor. More...
 

Private Member Functions

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

Additional Inherited Members

- Static Public Member Functions inherited from DDXMLElement
static std::string itostr (int i)
 WARNING: abused by other classes in this system: yet another conversion from int to std::string... More...
 
- 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 24 of file DDLBooleanSolid.h.

Constructor & Destructor Documentation

DDLBooleanSolid::DDLBooleanSolid ( DDLElementRegistry myreg)

Constructor.

Definition at line 23 of file DDLBooleanSolid.cc.

24  : DDLSolid( myreg )
25 {}
DDLSolid(DDLElementRegistry *myreg)
Constructor.
Definition: DDLSolid.cc:18
DDLBooleanSolid::~DDLBooleanSolid ( void  )

Destructor.

Definition at line 27 of file DDLBooleanSolid.cc.

28 {}

Member Function Documentation

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

Definition at line 143 of file DDLBooleanSolid.cc.

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

Referenced by processElement().

144 {
145  std::string s;
147 
148  s = std::string ("\n<") + name + " name=\"" + atts.find("name")->second + "\"";
149 
150  if (atts.find("firstSolid") != atts.end()) s+= " firstSolid=\"" + atts.find("firstSolid")->second + "\"";
151  if (atts.find("secondSolid") != atts.end()) s+= " secondSolid=\"" + atts.find("secondSolid")->second + "\"";
152  s += ">\n";
153 
154  DDXMLElement* myrSolid = myRegistry_->getElement("rSolid"); // get rSolid children
155  DDXMLElement* myTranslation = myRegistry_->getElement("Translation"); // get Translation child
156  DDXMLElement* myrRotation = myRegistry_->getElement("rRotation"); // get rRotation child
157  if (myrSolid->size() > 0)
158  {
159  for (size_t i = 0; i < myrSolid->size(); ++i)
160  {
161  atts = myrSolid->getAttributeSet(i);
162  s+="<rSolid name=\"" + atts.find("name")->second + "\"/>\n";
163  }
164  }
165 
166  atts = myTranslation->getAttributeSet();
167  s+= "<Translation";
168  if (atts.find("x") != atts.end())
169  s+=" x=\"" + atts.find("x")->second + "\"";
170  if (atts.find("y") != atts.end())
171  s+= " y=\"" + atts.find("y")->second + "\"";
172  if (atts.find("z") != atts.end())
173  s+= " z=\"" + atts.find("z")->second + "\"";
174  s+="/>\n";
175 
176  atts = myrRotation->getAttributeSet();
177  if (atts.find("name") != atts.end())
178  {
179  s+= "<rRotation name=\"" + atts.find("name")->second + "\"/>\n";
180  }
181  s+= "</" + name + ">\n\n";
182  return s;
183 }
int i
Definition: DBlmapReader.cc:9
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:186
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a &quot;row&quot; of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:79
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:55
DDXMLElement * getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
virtual size_t size(void) const
Number of elements accumulated.
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
void DDLBooleanSolid::preProcessElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
virtual

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 32 of file DDLBooleanSolid.cc.

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

33 {
34  myRegistry_->getElement( "rSolid" )->clear();
35 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:186
DDXMLElement * getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
void DDLBooleanSolid::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
virtual

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 41 of file DDLBooleanSolid.cc.

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

42 {
43  DCOUT_V( 'P', "DDLBooleanSolid::processElement started" );
44 
45  // new DDLBoolean will handle:
46  // <UnionSolid name="bs" firstSolid="blah" secondSolid="argh"> <Translation...> <rRotation .../> </UnionSolid
47  // AND <UnionSolid> <rSolid...> <rSolid...> <Translation...> <rRotation...> </UnionSolid>
48 
49  DDXMLElement* myrSolid = myRegistry_->getElement( "rSolid" ); // get rSolid children
50  DDXMLElement* myTranslation = myRegistry_->getElement( "Translation" ); // get Translation child
51  DDXMLElement* myrRotation = myRegistry_->getElement( "rRotation" ); // get rRotation child
52 
55 
56  DDName ddn1, ddn2;
57  double x=0.0, y=0.0, z=0.0;
58  DDRotation ddrot;
59 
60  // Basically check if there are rSolids or Translation or rRotation then we have
61  // should NOT have any of the attributes shown above.
62  if( myrSolid->size() == 0 )
63  {
64  // do the solids using the attributes only.
65  if ( atts.find("firstSolid") != atts.end() && atts.find("secondSolid") != atts.end() ) {
66  ddn1 = getDDName(nmspace, "firstSolid");
67  ddn2 = getDDName(nmspace, "secondSolid");
68  } else {
69  std::string s ("DDLBooleanSolid did not find any solids with which to form a boolean solid.");
70  s += dumpBooleanSolid(name, nmspace);
71  throwError( s );
72  }
73  }
74  else if (myrSolid->size() == 2)
75  {
76  ddn1 = myrSolid->getDDName(nmspace, "name", 0);
77  ddn2 = myrSolid->getDDName(nmspace, "name", 1);
78  } else {
79  std::string s("DDLBooleanSolid did not find any solids with which to form a boolean solid.");
80  s += dumpBooleanSolid(name, nmspace);
81  throwError( s );
82  }
83 
84  if (myTranslation->size() > 0)
85  {
86  atts.clear();
87  atts = myTranslation->getAttributeSet();
88  x = ev.eval(nmspace, atts.find("x")->second);
89  y = ev.eval(nmspace, atts.find("y")->second);
90  z = ev.eval(nmspace, atts.find("z")->second);
91  }
92 
93  if (myrRotation->size() > 0)
94  {
95  ddrot = DDRotation( myrRotation->getDDName (nmspace) );
96  }
97 
98  DDSolid theSolid;
99 
100  if (name == "UnionSolid") {
101  theSolid = DDSolidFactory::unionSolid (getDDName(nmspace)
102  , DDSolid(ddn1)
103  , DDSolid(ddn2)
104  , DDTranslation(x, y, z)
105  , ddrot
106  );
107  }
108  else if (name == "SubtractionSolid") {
109  theSolid = DDSolidFactory::subtraction (getDDName(nmspace)
110  , DDSolid(ddn1)
111  , DDSolid(ddn2)
112  , DDTranslation(x, y, z)
113  , ddrot
114  );
115  }
116  else if (name == "IntersectionSolid") {
117  theSolid = DDSolidFactory::intersection (getDDName(nmspace)
118  , DDSolid(ddn1)
119  , DDSolid(ddn2)
120  , DDTranslation(x, y, z)
121  , ddrot
122  );
123  }
124  else {
125  throw cms::Exception("DDException") << "DDLBooleanSolid was asked to do something other than Union-, Subtraction- or IntersectionSolid?";
126  }
127 
128  DDLSolid::setReference(nmspace, cpv);
129 
130  DCOUT_V('p', theSolid);
131 
132  // clear all "children" and attributes
133  myTranslation->clear();
134  myrRotation->clear();
135  myrSolid->clear();
136  clear();
137  DCOUT_V('P', "DDLBooleanSolid::processElement completed");
138 
139 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:186
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a &quot;row&quot; of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:79
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:14
bool ev
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:55
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
DDXMLElement * getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
ClhepEvaluator & evaluator()
static DDSolid intersection(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:714
virtual size_t size(void) const
Number of elements accumulated.
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
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:705
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
double eval(const std::string &ns, const std::string &expr)
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
static DDSolid unionSolid(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:696
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:86
void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLSolid.cc:26