CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DetectorDescription/Parser/src/DDLLogicalPart.cc

Go to the documentation of this file.
00001 /***************************************************************************
00002                           DDLLogicalPart.cc  -  description
00003                              -------------------
00004     begin                : Tue Oct 31 2001
00005     email                : case@ucdhep.ucdavis.edu
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *           DDDParser sub-component of DDD                                *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 #include "DetectorDescription/Parser/src/DDLLogicalPart.h"
00015 
00016 #include "DetectorDescription/Core/interface/DDName.h"
00017 #include "DetectorDescription/Core/interface/DDSolid.h"
00018 #include "DetectorDescription/Base/interface/DDdebug.h"
00019 #include "DetectorDescription/Core/interface/DDMaterial.h"
00020 
00021 DDLLogicalPart::DDLLogicalPart(  DDLElementRegistry* myreg )
00022   : DDXMLElement( myreg )
00023 {
00024   // initialize category map
00025   catMap_["sensitive"]   = DDEnums::sensitive;
00026   catMap_["cable"]       = DDEnums::cable;
00027   catMap_["cooling"]     = DDEnums::cooling;
00028   catMap_["support"]     = DDEnums::support;
00029   catMap_["envelope"]    = DDEnums::envelope;
00030   catMap_["unspecified"] = DDEnums::unspecified;
00031 }
00032 
00033 DDLLogicalPart::~DDLLogicalPart( void )
00034 {}
00035 
00036 // upon initialization, we want to clear rMaterial and rSolid.
00037 void
00038 DDLLogicalPart::preProcessElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00039 {
00040   myRegistry_->getElement( "rMaterial" )->clear();
00041   myRegistry_->getElement( "rSolid" )->clear();
00042 }
00043 
00044 // Upon encountering the end of the LogicalPart element, retrieve all 
00045 // relevant information from its sub-elements and put it all together to 
00046 // call the DDCore appropriately.
00047 // 
00048 // History:  Initially only rSolid and rMaterial elements worked.  Now,
00049 // a Material or a Solid element inside the LogicalPart also works but
00050 // this is handled outside this class.  Each Solid inherits from DDLSolid
00051 // and in each Solid, the processElement method must call the setReference
00052 // of the DDLSolid.  The Material element also works similarly.  Thus,
00053 // by retrieving the rMaterial and the rSolid it actually will be handling
00054 // Material and Solid subelements as well.
00055 
00056 void
00057 DDLLogicalPart::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00058 {
00059   DCOUT_V('P', "DDLLogicalPart::processElement started");
00060 
00061   // rMaterial and rSolid  
00062   DDXMLElement* myrMaterial = myRegistry_->getElement("rMaterial"); // get Material reference child
00063   DDXMLElement* myrSolid = myRegistry_->getElement("rSolid"); // get Solid reference child
00064 
00065   DDXMLAttribute atts = getAttributeSet();
00066 
00067   // this check really is overkill so I'm commenting it out for now.
00068   // validation of the XML should PREVENT this.
00069 //    if (myrSolid->size() > 1)
00070 //      {
00071 //        std::string s = "DDLLogicalPart::processElement:  When looking at rSolid, found more than one. ";
00072 //        s += " Logical part name was: ";
00073 //        s += atts.find("name")->second;
00074 //        throw DDException(s);
00075 //      }
00076 
00077   DDSolid mySolid = DDSolid(myrSolid->getDDName(nmspace));
00078   DDMaterial myMaterial = DDMaterial(myrMaterial->getDDName(nmspace));
00079 
00080   DDEnums::Category cat;
00081 
00082   if (atts.find("category") != atts.end())
00083     cat = catMap_[atts.find("category")->second];
00084   else
00085     cat = catMap_["unspecified"];
00086 
00087   DDLogicalPart lp( getDDName( nmspace ), myMaterial, mySolid, cat );
00088 
00089   // clear all "children" and attributes
00090   myrMaterial->clear();
00091   myrSolid->clear();
00092 
00093   // after each logical part is made, we can clear it
00094   clear();
00095 
00096   DCOUT_V('P', "DDLLogicalPart::processElement completed");
00097 }