CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DetectorDescription/Core/src/DDCompactView.cc

Go to the documentation of this file.
00001 #include "DetectorDescription/Core/interface/DDCompactView.h"
00002 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00003 #include "DetectorDescription/Core/interface/DDMaterial.h"
00004 #include "DetectorDescription/Core/interface/DDSolid.h"
00005 #include "DetectorDescription/Core/interface/DDName.h"
00006 #include "DetectorDescription/ExprAlgo/interface/AlgoPos.h"
00007 
00008 #include "DetectorDescription/Core/interface/DDSpecifics.h"
00009 #include "DetectorDescription/Base/interface/DDRotationMatrix.h"
00010 
00011 #include "DetectorDescription/Core/src/Material.h"
00012 #include "DetectorDescription/Core/src/Solid.h"
00013 #include "DetectorDescription/Core/src/LogicalPart.h"
00014 #include "DetectorDescription/Core/src/Specific.h"
00015 
00016 #include <iostream>
00017 
00018 //DDCompactViewmpl * DDCompactView::global_ = 0;
00019 
00036 // 
00037 DDCompactView::DDCompactView(const DDLogicalPart & rootnodedata)
00038   : rep_(new DDCompactViewImpl(rootnodedata))
00039 {
00040   // 2010-01-27 I am leaving this here so that we are sure the global stores
00041   // are open when a new DDCompactView is being made.  Eventually I want to
00042   // get rid of the need for this somehow? think about it...
00043   DDMaterial::StoreT::instance().setReadOnly(false);
00044   DDSolid::StoreT::instance().setReadOnly(false);
00045   DDLogicalPart::StoreT::instance().setReadOnly(false);
00046   DDSpecifics::StoreT::instance().setReadOnly(false);
00047   DDRotation::StoreT::instance().setReadOnly(false);
00048 }
00049 
00050 DDCompactView::~DDCompactView() 
00051 {  
00052   if (rep_ != 0) {
00053     delete rep_;
00054   }
00055 }
00056 
00062 const DDCompactView::graph_type & DDCompactView::graph() const 
00063 { 
00064   return rep_->graph(); 
00065 }
00066 
00067 DDCompactView::graph_type & DDCompactView::writeableGraph() 
00068 {
00069   return const_cast<graph_type&>(rep_->graph());
00070 }
00071 
00072 const DDLogicalPart & DDCompactView::root() const
00073 { 
00074   return rep_->root(); 
00075 } 
00076 
00077 
00078 DDCompactView::walker_type DDCompactView::walker() const
00079 {
00080   return rep_->walker();
00081 }
00082 
00083     
00102 double DDCompactView::weight(const DDLogicalPart & p) const
00103 {
00104   return rep_->weight(p);
00105 }  
00106 
00107 void DDCompactView::algoPosPart(const DDLogicalPart & self,
00108                                 const DDLogicalPart & parent,
00109                                 DDAlgo & algo
00110                                 ) {
00111   static int cnt_=0;
00112   ++cnt_;
00113   if (algo.rep().numRegistered() == 0) {
00114     std::string e;
00115     e = "DDalgoPosPart: algorithmic positioning\n";
00116     e += "\t[" + algo.name().ns() 
00117                + ":" 
00118                + algo.name().name() 
00119                + "] is not defined!\n";
00120     throw cms::Exception("DDException") << e;
00121   }
00122   
00123   LogDebug ("AlgoPos")  << "DDCompactView, algo=" << std::endl << algo << std::endl;
00124   int inner=0;
00125   do { 
00126     ++inner;
00127     DDRotationMatrix * rmp = new DDRotationMatrix(algo.rotation());
00128     DDRotation anonymRot = DDanonymousRot(rmp);
00129     DDTranslation tr(algo.translation());
00130     position(self, parent, algo.label(), tr, anonymRot); 
00131     algo.next();
00132   } 
00133   while(algo.go());
00134 
00135 }
00136 
00137 void DDCompactView::position (const DDLogicalPart & self, 
00138                               const DDLogicalPart & parent,
00139                               std::string copyno,
00140                               const DDTranslation & trans,
00141                               const DDRotation & rot,
00142                               const DDDivision * div)
00143 {
00144   int cpno = atoi(copyno.c_str());
00145   position(self,parent,cpno,trans,rot, div);
00146 }
00147 
00148 void DDCompactView::position (const DDLogicalPart & self,
00149                               const DDLogicalPart & parent,
00150                               int copyno,
00151                               const DDTranslation & trans,
00152                               const DDRotation & rot,
00153                               const DDDivision * div)
00154 {
00155   rep_->position( self, parent, copyno, trans, rot, div );
00156 }
00157 
00158 
00159 // >>---==========================<()>==========================---<<
00160 
00161 // UNSTABLE STUFF below ...
00162 void DDCompactView::setRoot(const DDLogicalPart & root)
00163 {
00164   rep_->setRoot(root);
00165 }  
00166 
00167 void DDCompactView::swap( DDCompactView& repToSwap ) {
00168   rep_->swap ( *(repToSwap.rep_) );
00169 }
00170 
00171 DDCompactView::DDCompactView() : rep_(new DDCompactViewImpl) { }
00172 
00173 void DDCompactView::lockdown() {
00174   // at this point we should have a valid store of DDObjects and we will move these
00175   // to the local storage area using swaps with the existing Singleton<Store...>'s
00176   // 2010-01-27 memory patch
00177   DDMaterial::StoreT::instance().swap(matStore_);
00178   DDSolid::StoreT::instance().swap(solidStore_);
00179   DDLogicalPart::StoreT::instance().swap(lpStore_);
00180   DDSpecifics::StoreT::instance().swap(specStore_);
00181   DDRotation::StoreT::instance().swap(rotStore_);
00182 
00183   // 2010-01-27 memory patch
00184   // not sure this will stay, but for now we want to explicitely lock the global stores.
00185   // lock the global stores.
00186   DDMaterial::StoreT::instance().setReadOnly(false);
00187   DDSolid::StoreT::instance().setReadOnly(false);
00188   DDLogicalPart::StoreT::instance().setReadOnly(false);
00189   DDSpecifics::StoreT::instance().setReadOnly(false);
00190   DDRotation::StoreT::instance().setReadOnly(false);
00191 
00192 }
00193