CMS 3D CMS Logo

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