CMS 3D CMS Logo

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