CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDLLogicalPart.cc
Go to the documentation of this file.
1 /***************************************************************************
2  DDLLogicalPart.cc - description
3  -------------------
4  begin : Tue Oct 31 2001
5  email : case@ucdhep.ucdavis.edu
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * DDDParser sub-component of DDD *
11  * *
12  ***************************************************************************/
13 
15 
20 
22  : DDXMLElement( myreg )
23 {
24  // initialize category map
25  catMap_["sensitive"] = DDEnums::sensitive;
26  catMap_["cable"] = DDEnums::cable;
27  catMap_["cooling"] = DDEnums::cooling;
28  catMap_["support"] = DDEnums::support;
29  catMap_["envelope"] = DDEnums::envelope;
30  catMap_["unspecified"] = DDEnums::unspecified;
31 }
32 
34 {}
35 
36 // upon initialization, we want to clear rMaterial and rSolid.
37 void
39 {
40  myRegistry_->getElement( "rMaterial" )->clear();
41  myRegistry_->getElement( "rSolid" )->clear();
42 }
43 
44 // Upon encountering the end of the LogicalPart element, retrieve all
45 // relevant information from its sub-elements and put it all together to
46 // call the DDCore appropriately.
47 //
48 // History: Initially only rSolid and rMaterial elements worked. Now,
49 // a Material or a Solid element inside the LogicalPart also works but
50 // this is handled outside this class. Each Solid inherits from DDLSolid
51 // and in each Solid, the processElement method must call the setReference
52 // of the DDLSolid. The Material element also works similarly. Thus,
53 // by retrieving the rMaterial and the rSolid it actually will be handling
54 // Material and Solid subelements as well.
55 
56 void
58 {
59  DCOUT_V('P', "DDLLogicalPart::processElement started");
60 
61  // rMaterial and rSolid
62  DDXMLElement* myrMaterial = myRegistry_->getElement("rMaterial"); // get Material reference child
63  DDXMLElement* myrSolid = myRegistry_->getElement("rSolid"); // get Solid reference child
64 
66 
67  // this check really is overkill so I'm commenting it out for now.
68  // validation of the XML should PREVENT this.
69 // if (myrSolid->size() > 1)
70 // {
71 // std::string s = "DDLLogicalPart::processElement: When looking at rSolid, found more than one. ";
72 // s += " Logical part name was: ";
73 // s += atts.find("name")->second;
74 // throw DDException(s);
75 // }
76 
77  DDSolid mySolid = DDSolid(myrSolid->getDDName(nmspace));
78  DDMaterial myMaterial = DDMaterial(myrMaterial->getDDName(nmspace));
79 
81 
82  if (atts.find("category") != atts.end())
83  cat = catMap_[atts.find("category")->second];
84  else
85  cat = catMap_["unspecified"];
86 
87  DDLogicalPart lp( getDDName( nmspace ), myMaterial, mySolid, cat );
88 
89  // clear all "children" and attributes
90  myrMaterial->clear();
91  myrSolid->clear();
92 
93  // after each logical part is made, we can clear it
94  clear();
95 
96  DCOUT_V('P', "DDLLogicalPart::processElement completed");
97 }
~DDLLogicalPart(void)
Destructor.
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:186
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:79
type of data representation of DDCompactView
Definition: DDCompactView.h:77
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:55
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
DDXMLElement * getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
def cat
Definition: eostools.py:398
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv)
Called by loadAttributes AFTER attributes are loaded.
Category
Definition: DDEnums.h:7
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv)
Processing the element.
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
std::map< std::string, DDEnums::Category > catMap_
The main class for processing parsed elements.
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:86
DDLLogicalPart(DDLElementRegistry *myreg)
Constructor.