CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DetectorDescription/Core/src/DDSolid.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "DetectorDescription/Base/interface/DDException.h"
00004 #include "DetectorDescription/Core/interface/DDSolid.h"
00005 #include "DetectorDescription/Core/src/Solid.h"
00006 
00007 #include "DetectorDescription/Core/src/Box.h"
00008 #include "DetectorDescription/Core/src/Polycone.h"
00009 #include "DetectorDescription/Core/src/Polyhedra.h"
00010 #include "DetectorDescription/Core/src/Boolean.h"
00011 #include "DetectorDescription/Core/src/Reflection.h"
00012 #include "DetectorDescription/Core/src/Shapeless.h"
00013 #include "DetectorDescription/Core/src/Torus.h"
00014 #include "DetectorDescription/Core/src/Trap.h"
00015 #include "DetectorDescription/Core/src/Tubs.h"
00016 #include "DetectorDescription/Core/src/Cons.h"
00017 #include "DetectorDescription/Core/src/PseudoTrap.h"
00018 #include "DetectorDescription/Core/src/TruncTubs.h"
00019 #include "DetectorDescription/Core/src/Sphere.h"
00020 #include "DetectorDescription/Core/src/Orb.h"
00021 #include "DetectorDescription/Core/src/EllipticalTube.h"
00022 #include "DetectorDescription/Core/src/Ellipsoid.h"
00023 #include "DetectorDescription/Core/src/Parallelepiped.h"
00024 #include <algorithm>
00025 
00026 // Message logger.
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028 
00029 using DDI::Solid;
00030 
00031 //DDBase<DDName,Solid*>::StoreT::pointer_type 
00032 //  DDBase<DDName,Solid*>::StoreT::instance_ = 0;
00033 
00034 
00035 std::ostream & 
00036 operator<<(std::ostream & os, const DDSolid & solid)
00037 { 
00038   DDBase<DDName,DDI::Solid*>::def_type defined(solid.isDefined());
00039   if (defined.first) {
00040     os << *(defined.first) << " ";
00041     if (defined.second) {
00042       os << "  " << DDSolidShapesName::name(solid.shape()) << ": ";
00043       solid.rep().stream(os); 
00044     }
00045     else {
00046       os << "* solid not defined * ";  
00047     }
00048   }  
00049   else {
00050     os << "* solid not declared * ";  
00051   }  
00052   return os;
00053 }
00054 
00055 
00056 // =================================================================================
00057 
00058 DDSolid::DDSolid() : DDBase<DDName,Solid*>() { }
00059 
00060 
00061 DDSolid::DDSolid(const DDName & n) : DDBase<DDName,Solid*>()
00062 {
00063   prep_ = StoreT::instance().create(n);
00064 }
00065 
00066 DDSolid::DDSolid(const DDName & n, Solid * s) : DDBase<DDName,Solid*>()
00067 {
00068   prep_ = StoreT::instance().create(n,s);
00069 }
00070 
00071 
00072 DDSolid::DDSolid(const DDName & n, DDSolidShape s, const std::vector<double> & p)
00073 {
00074   DDI::Solid * solid(0);
00075   std::vector<double> dummy;
00076   switch(s) {
00077        case ddbox:
00078         solid = new DDI::Box(0,0,0);
00079         break;
00080        case ddtubs:
00081         solid = new DDI::Tubs(0,0,0,0,0);
00082         break;
00083        case ddcons:
00084         solid = new DDI::Cons(0,0,0,0,0,0,0);
00085         break;
00086        case ddpseudotrap:
00087         solid = new DDI::PseudoTrap(0,0,0,0,0,0,0);
00088         break;
00089        case ddshapeless:
00090         solid = new DDI::Shapeless();
00091         break;
00092        case ddtrap:
00093         solid = new DDI::Trap(0,0,0,0,0,0,0,0,0,0,0);
00094         break;
00095        case ddpolyhedra_rz:
00096         solid = new DDI::Polyhedra(0,0,0,dummy,dummy);
00097         break;
00098        case ddpolyhedra_rrz:
00099         solid = new DDI::Polyhedra(0,0,0,dummy,dummy,dummy);
00100         break;
00101        case ddpolycone_rz:
00102         solid = new DDI::Polycone(0,0,dummy,dummy);
00103         break;
00104        case ddpolycone_rrz:
00105         solid = new DDI::Polycone(0,0,dummy,dummy,dummy);
00106         break;                  
00107        case ddtrunctubs:
00108          solid = new DDI::TruncTubs(0,0,0,0,0,0,0,0);
00109          break;
00110        case ddtorus:
00111          solid = new DDI::Torus(0,0,0,0,0);
00112          break;
00113        case ddsphere:
00114          solid = new DDI::Sphere(0,0,0,0,0,0);
00115          break;
00116        case ddorb:
00117          solid = new DDI::Orb(0);
00118          break;
00119        case ddellipticaltube:
00120          solid = new DDI::EllipticalTube(0,0,0);
00121          break;
00122        case ddellipsoid:
00123          solid = new DDI::Ellipsoid(0,0,0,0,0);
00124          break;
00125        case ddparallelepiped:
00126          solid = new DDI::Parallelepiped(0,0,0,0,0,0);
00127          break;
00128        default:
00129         throw DDException("DDSolid::DDSolid(DDName,DDSolidShape,std::vector<double>: wrong shape");   
00130   }
00131   solid->setParameters(p);
00132   prep_ = StoreT::instance().create(n,solid);
00133 }
00134 
00135 
00136 double DDSolid::volume() const
00137 {
00138   return rep().volume();
00139 }
00140 
00141 // void DDSolid::clear()
00142 // {
00143 //  StoreT::instance().clear();
00144 // }
00145 
00146 
00147 DDSolidShape DDSolid::shape() const
00148 {
00149   return rep().shape();
00150 }
00151 
00152 
00153 const std::vector<double> & DDSolid::parameters() const
00154 { 
00155   return rep().parameters(); 
00156 }
00157 
00158 
00159 // =================================================================================
00160 
00161 DDTrap::DDTrap(const DDSolid & s) : DDSolid(s)
00162 {
00163   if (s.shape() != ddtrap) {
00164     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is no DDTrap.\n";
00165     ex = ex + "Use a different solid interface!";
00166     throw DDException(ex);
00167   }
00168 }
00169 
00170 double DDTrap::halfZ() const { return rep().parameters()[0]; }
00171 
00172 double DDTrap::theta() const { return rep().parameters()[1]; }
00173 
00174 double DDTrap::phi() const { return rep().parameters()[2]; }
00175 
00176 double DDTrap::y1() const { return rep().parameters()[3]; }
00177 
00178 double DDTrap::x1() const { return rep().parameters()[4]; }
00179 
00180 double DDTrap::x2() const { return rep().parameters()[5]; }
00181 
00182 double DDTrap::alpha1() const { return rep().parameters()[6]; }
00183 
00184 double DDTrap::y2() const { return rep().parameters()[7]; }
00185 
00186 double DDTrap::x3() const { return rep().parameters()[8]; }
00187 
00188 double DDTrap::x4() const { return rep().parameters()[9]; }
00189 
00190 double DDTrap::alpha2() const { return rep().parameters()[10]; }
00191 
00192 // =================================================================================
00193 
00194 DDTruncTubs::DDTruncTubs(const DDSolid & s) : DDSolid(s)
00195 {
00196   if (s.shape() != ddtrunctubs) {
00197     edm::LogError ("DDSolid") << "s.shape()=" << s.shape() << "  " << s << std::endl;
00198     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is no DDTruncTubs\n";
00199     ex = ex + "Use a different solid interface!";
00200     throw DDException(ex);
00201   }
00202 }
00203 
00204 double DDTruncTubs::zHalf() const { return rep().parameters()[0];}
00205 
00206 double DDTruncTubs::rIn() const { return rep().parameters()[1];}
00207 
00208 double DDTruncTubs::rOut() const { return rep().parameters()[2];}
00209 
00210 double DDTruncTubs::startPhi() const { return rep().parameters()[3];}
00211 
00212 double DDTruncTubs::deltaPhi() const { return rep().parameters()[4];}
00213 
00214 double DDTruncTubs::cutAtStart() const { return rep().parameters()[5];}
00215 
00216 double DDTruncTubs::cutAtDelta() const { return rep().parameters()[6];}
00217 
00218 bool DDTruncTubs::cutInside() const { return bool(rep().parameters()[7]);}
00219 
00220 // =================================================================================
00221 
00222 DDPseudoTrap::DDPseudoTrap(const DDSolid & s) : DDSolid(s)
00223 {
00224   if (s.shape() != ddpseudotrap) {
00225     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is no DDPseudoTrap\n";
00226     ex = ex + "Use a different solid interface!";
00227     throw DDException(ex);
00228   }
00229 }
00230 
00231 double DDPseudoTrap::halfZ() const { return rep().parameters()[4]; }
00232 
00233 double DDPseudoTrap::x1() const { return rep().parameters()[0]; }
00234 
00235 double DDPseudoTrap::x2() const { return rep().parameters()[1]; }
00236 
00237 double DDPseudoTrap::y1() const { return rep().parameters()[2]; }
00238 
00239 double DDPseudoTrap::y2() const { return rep().parameters()[3]; }
00240 
00241 double DDPseudoTrap::radius() const { return rep().parameters()[5]; }
00242 
00243 bool DDPseudoTrap::atMinusZ() const { return rep().parameters()[6]; }
00244 
00245 // =================================================================================
00246 
00247 DDBox::DDBox(const DDSolid & s) 
00248  : DDSolid(s) 
00249 { 
00250  if (s.shape() != ddbox) {
00251     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDBox.\n";
00252     ex = ex + "Use a different solid interface!";
00253     throw DDException(ex);
00254  }
00255 }
00256 
00257 double DDBox::halfX() const
00258 { return rep().parameters()[0]; }
00259 double DDBox::halfY() const
00260 { return rep().parameters()[1]; }
00261 double DDBox::halfZ() const
00262 { return rep().parameters()[2]; }
00263 
00264 
00265 // =================================================================================
00266 
00267 DDReflectionSolid::DDReflectionSolid(const DDSolid & s)
00268  : DDSolid(s), reflected_(0)
00269 { 
00270   //FIXME: exception handling!
00271   reflected_ = dynamic_cast<DDI::Reflection*>(&s.rep());
00272 }
00273 
00274 
00275 DDSolid DDReflectionSolid::unreflected() const
00276 { return reflected_->solid();}
00277 
00278 
00279 // =================================================================================
00280 
00281 DDShapelessSolid::DDShapelessSolid (const DDSolid & s) : DDSolid(s)
00282 {
00283   if (s.shape() != ddshapeless) {
00284     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDShapelessSolid.\n";
00285     ex = ex + "Use a different solid interface!";
00286     throw DDException(ex);
00287   }
00288 }
00289 
00290 
00291 // =================================================================================
00292 
00293 DDUnion::DDUnion(const DDSolid & s) 
00294   : DDBooleanSolid(s)
00295 {
00296   if (s.shape() != ddunion) {
00297     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDUnion.\n";
00298     ex = ex + "Use a different solid interface!";
00299     throw DDException(ex);
00300   }
00301 }
00302 
00303 
00304 // =================================================================================
00305 
00306 DDIntersection::DDIntersection(const DDSolid & s) 
00307   : DDBooleanSolid(s)
00308 {
00309   if (s.shape() != ddunion) {
00310     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDIntersection.\n";
00311     ex = ex + "Use a different solid interface!";
00312     throw DDException(ex);
00313   }
00314 }
00315 
00316 
00317 // =================================================================================
00318 
00319 DDSubtraction::DDSubtraction(const DDSolid & s) 
00320   : DDBooleanSolid(s)
00321 {
00322   if (s.shape() != ddsubtraction) {
00323     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is no DDSubtraction.\n";
00324     ex = ex + "Use a different solid interface!";
00325     throw DDException(ex);
00326   }
00327 }
00328 
00329 
00330 // =================================================================================
00331 
00332 DDPolySolid::DDPolySolid(const DDSolid & s)
00333   : DDSolid(s)
00334 { }
00335 
00336 std::vector<double> DDPolySolid::getVec (const size_t& which, 
00337                                          const size_t& offset,
00338                                          const size_t& numVecs) const {
00339 
00340   // which:  first second or third std::vector 
00341   // offset: number of non-std::vector components before std::vectors start
00342   std::string locErr;
00343   size_t szVec = 0;
00344   std::vector<double> tvec; // = new std::vector<double>;
00345   if ( (rep().parameters().size() - offset) % numVecs != 0 ) { // / 2 != (rep().parameters().size() - 2) \ 2) {
00346     locErr = std::string("Could not find equal sized components of std::vectors in a PolySolid description.");
00347     edm::LogError ("DDSolid") << "rep().parameters().size()=" << rep().parameters().size() << "  numVecs=" << numVecs
00348          << "  offset=" << offset << std::endl;
00349   }
00350   else {
00351     szVec = (rep().parameters().size() - offset)/ numVecs;
00352   }
00353   for (size_t i = offset + which; i < rep().parameters().size(); i = i + numVecs) {
00354     tvec.push_back(rep().parameters()[i]);
00355   }                
00356   return tvec;
00357 }
00358 
00359 // =================================================================================
00360 
00361 DDPolycone::DDPolycone(const DDSolid & s)
00362   : DDPolySolid(s)
00363 {
00364   if (s.shape() != ddpolycone_rz && s.shape() != ddpolycone_rrz) {
00365     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDPolycone.\n";
00366     ex = ex + "Use a different solid interface!";
00367     throw DDException(ex);
00368   }
00369 }
00370 
00371 double DDPolycone::startPhi() const { return rep().parameters()[0]; }
00372 
00373 double DDPolycone::deltaPhi() const { return rep().parameters()[1]; }
00374 
00375 std::vector<double> DDPolycone::rVec() const {
00376   std::vector<double> tvec;
00377   if (shape() == ddpolycone_rz)
00378     tvec = getVec(1, 2, 2);
00379   return tvec; 
00380 }
00381 
00382 std::vector<double> DDPolycone::zVec() const {
00383   if (shape() == ddpolycone_rz)
00384     return getVec(0, 2, 2);
00385   else // (shape() == ddpolycone_rrz)
00386     return getVec(0, 2, 3);
00387 }
00388 
00389 std::vector<double> DDPolycone::rMinVec() const {
00390   std::vector<double> tvec;
00391   if (shape() == ddpolycone_rrz)
00392     tvec = getVec(1, 2, 3);
00393   return tvec; 
00394 }
00395 
00396 std::vector<double> DDPolycone::rMaxVec() const {
00397   std::vector<double> tvec;
00398   if (shape() == ddpolycone_rrz)
00399     tvec = getVec(2, 2, 3);
00400   return tvec; 
00401 }
00402 
00403 
00404 // =================================================================================
00405 
00406 DDPolyhedra::DDPolyhedra(const DDSolid & s)
00407   : DDPolySolid(s)
00408 {
00409   if (s.shape() != ddpolyhedra_rz && s.shape() != ddpolyhedra_rrz) {
00410     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDPolyhedra.\n";
00411     ex = ex + "Use a different solid interface!";
00412     throw DDException(ex);
00413   }
00414 }
00415 
00416 int DDPolyhedra::sides() const { return int(rep().parameters()[0]); }
00417 
00418 double DDPolyhedra::startPhi() const { return rep().parameters()[1]; }
00419 
00420 double DDPolyhedra::deltaPhi() const { return rep().parameters()[2]; }
00421 
00422 std::vector<double> DDPolyhedra::rVec() const {
00423   std::vector<double> tvec;
00424   if (shape() == ddpolyhedra_rz)
00425     tvec = getVec(1, 3, 2);
00426   return tvec;
00427 }
00428 
00429 std::vector<double> DDPolyhedra::zVec() const {
00430   if (shape() == ddpolyhedra_rz)
00431     return getVec(0, 3, 2);
00432   else // (shape() == ddpolycone_rrz)
00433     return getVec(0, 3, 3);
00434 }
00435 
00436 std::vector<double> DDPolyhedra::rMinVec() const {
00437   std::vector<double> tvec;
00438   if (shape() == ddpolyhedra_rrz)
00439     tvec = getVec(1, 3, 3);
00440   return tvec;
00441 }
00442 
00443 std::vector<double> DDPolyhedra::rMaxVec() const {
00444   std::vector<double> tvec;
00445   if (shape() == ddpolyhedra_rrz)
00446     tvec = getVec(2, 3, 3);
00447   return tvec;
00448 }
00449 
00450 // =================================================================================
00451 
00452 DDCons::DDCons(const DDSolid& s) 
00453   : DDSolid(s) {
00454   if (s.shape() != ddcons) {
00455     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDCons.\n";
00456     ex = ex + "Use a different solid interface!";
00457     throw DDException(ex);
00458   }
00459 }
00460 
00461 double DDCons::zhalf() const { return rep().parameters()[0]; }
00462 
00463 double DDCons::rInMinusZ() const { return rep().parameters()[1]; }
00464 
00465 double DDCons::rOutMinusZ () const { return rep().parameters()[2]; }
00466 
00467 double DDCons::rInPlusZ() const { return rep().parameters()[3]; }
00468 
00469 double DDCons::rOutPlusZ() const { return rep().parameters()[4]; }
00470 
00471 double DDCons::phiFrom() const { return rep().parameters()[5]; }
00472 
00473 double DDCons::deltaPhi() const { return rep().parameters()[6]; }
00474 
00475 // =================================================================================
00476 
00477 DDTorus::DDTorus(const DDSolid& s) 
00478   : DDSolid(s) {
00479   if (s.shape() != ddtorus) {
00480     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDTorus.\n";
00481     ex = ex + "Use a different solid interface!";
00482     throw DDException(ex);
00483   }
00484 }
00485 
00486 double DDTorus::rMin() const { return rep().parameters()[0]; }
00487 
00488 double DDTorus::rMax() const { return rep().parameters()[1]; }
00489 
00490 double DDTorus::rTorus () const { return rep().parameters()[2]; }
00491 
00492 double DDTorus::startPhi() const { return rep().parameters()[3]; }
00493 
00494 double DDTorus::deltaPhi() const { return rep().parameters()[4]; }
00495 
00496 
00497 // =================================================================================
00498 
00499 DDTubs::DDTubs(const DDSolid& s) 
00500   : DDSolid(s) {
00501   if (s.shape() != ddtubs) {
00502     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDTubs.\n";
00503     ex = ex + "Use a different solid interface!";
00504     throw DDException(ex);
00505   }
00506 }
00507 
00508 double DDTubs::zhalf() const { return rep().parameters()[0]; }
00509 
00510 double DDTubs::rIn() const { return rep().parameters()[1]; }
00511 
00512 double DDTubs::rOut() const { return rep().parameters()[2]; }
00513 
00514 double DDTubs::startPhi() const { return rep().parameters()[3]; }
00515 
00516 double DDTubs::deltaPhi() const { return rep().parameters()[4]; }
00517 
00518 
00519 // =================================================================================
00520 
00521 
00522 DDSolid DDSolidFactory::box(const DDName & name, 
00523                               double xHalf, 
00524                               double yHalf, 
00525                               double zHalf)
00526 {
00527   return DDSolid(name, new DDI::Box(xHalf, yHalf, zHalf ));
00528 }
00529 
00530 
00531 DDBooleanSolid::DDBooleanSolid(const DDSolid &s)
00532  : DDSolid(s), boolean_(0)
00533 {
00534   boolean_ = dynamic_cast<DDI::BooleanSolid*>(&s.rep());
00535 }
00536 
00537 
00538 DDRotation DDBooleanSolid::rotation() const
00539 {
00540   return boolean_->r();
00541 }
00542 
00543 DDTranslation DDBooleanSolid::translation() const
00544 {
00545   return boolean_->t();
00546 }
00547 
00548 DDSolid DDBooleanSolid::solidA() const
00549 {
00550   return boolean_->a();
00551 }
00552 
00553 DDSolid DDBooleanSolid::solidB() const
00554 {
00555   return boolean_->b();
00556 }
00557 
00558 // =================================================================================
00559 
00560 DDSphere::DDSphere(const DDSolid& s) 
00561   : DDSolid(s) {
00562   if (s.shape() != ddsphere) {
00563     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDSphere (or sphere section).\n";
00564     ex = ex + "Use a different solid interface!";
00565     throw DDException(ex);
00566   }
00567 }
00568 
00569 double DDSphere::innerRadius() const { return rep().parameters()[0]; }
00570 
00571 double DDSphere::outerRadius() const { return rep().parameters()[1]; }
00572 
00573 double DDSphere::startPhi () const { return rep().parameters()[2]; }
00574 
00575 double DDSphere::deltaPhi() const { return rep().parameters()[3]; }
00576 
00577 double DDSphere::startTheta() const { return rep().parameters()[4]; }
00578 
00579 double DDSphere::deltaTheta() const { return rep().parameters()[5]; }
00580 
00581 // =================================================================================
00582 
00583 DDOrb::DDOrb(const DDSolid& s) 
00584   : DDSolid(s) {
00585   if (s.shape() != ddorb) {
00586     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDOrb.\n";
00587     ex = ex + "Use a different solid interface!";
00588     throw DDException(ex);
00589   }
00590 }
00591 
00592 double DDOrb::radius() const { return rep().parameters()[0]; }
00593 
00594 // =================================================================================
00595 
00596 DDEllipticalTube::DDEllipticalTube(const DDSolid& s) 
00597   : DDSolid(s) {
00598   if (s.shape() != ddellipticaltube) {
00599     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDEllipticalTube.\n";
00600     ex = ex + "Use a different solid interface!";
00601     throw DDException(ex);
00602   }
00603 }
00604 
00605 double DDEllipticalTube::xSemiAxis() const { return rep().parameters()[0]; }
00606 
00607 double DDEllipticalTube::ySemiAxis() const { return rep().parameters()[1]; }
00608 
00609 double DDEllipticalTube::zHeight() const { return rep().parameters()[2]; }
00610 
00611 // =================================================================================
00612 
00613 DDEllipsoid::DDEllipsoid(const DDSolid& s) 
00614   : DDSolid(s) {
00615   if (s.shape() != ddellipsoid) {
00616     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDEllipsoid (or truncated ellipsoid).\n";
00617     ex = ex + "Use a different solid interface!";
00618     throw DDException(ex);
00619   }
00620 }
00621 
00622 double DDEllipsoid::xSemiAxis() const { return rep().parameters()[0]; }
00623 
00624 double DDEllipsoid::ySemiAxis() const { return rep().parameters()[1]; }
00625 
00626 double DDEllipsoid::zSemiAxis() const { return rep().parameters()[2]; }
00627 
00628 double DDEllipsoid::zBottomCut() const { return rep().parameters()[3]; }
00629 
00630 double DDEllipsoid::zTopCut() const { return rep().parameters()[4]; }
00631 
00632 // =================================================================================
00633 
00634 DDParallelepiped::DDParallelepiped(const DDSolid& s) 
00635   : DDSolid(s) {
00636   if (s.shape() != ddparallelepiped) {
00637     std::string ex  = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDParallelepiped.\n";
00638     ex = ex + "Use a different solid interface!";
00639     throw DDException(ex);
00640   }
00641 }
00642 
00643 double DDParallelepiped::xHalf() const { return rep().parameters()[0]; }
00644 
00645 double DDParallelepiped::yHalf() const { return rep().parameters()[1]; }
00646 
00647 double DDParallelepiped::zHalf () const { return rep().parameters()[2]; }
00648 
00649 double DDParallelepiped::alpha() const { return rep().parameters()[3]; }
00650 
00651 double DDParallelepiped::theta() const { return rep().parameters()[4]; }
00652 
00653 double DDParallelepiped::phi() const { return rep().parameters()[5]; }
00654 
00655 
00656 // =================================================================================
00657 // =========================SolidFactory============================================
00658 
00659 DDSolid DDSolidFactory::polycone(const DDName & name, double startPhi, double deltaPhi,
00660                   const std::vector<double> & z,
00661                   const std::vector<double> & rmin,
00662                   const std::vector<double> & rmax) 
00663 {
00664   return DDSolid(name, new DDI::Polycone(startPhi, deltaPhi, z, rmin, rmax));
00665 }
00666 
00667 
00668 DDSolid DDSolidFactory::polycone(const DDName & name, double startPhi, double deltaPhi,
00669                   const std::vector<double> & z,
00670                   const std::vector<double> & r)
00671 {
00672   return DDSolid(name, new DDI::Polycone(startPhi, deltaPhi, z, r));
00673 }                                 
00674 
00675 
00676 DDSolid DDSolidFactory::polyhedra(const DDName & name,
00677                      int sides,
00678                      double startPhi,
00679                      double deltaPhi,
00680                      const std::vector<double> & z,
00681                      const std::vector<double> & rmin,
00682                      const std::vector<double> & rmax)
00683 {               
00684   return DDSolid(name, new DDI::Polyhedra(sides,  startPhi, deltaPhi, z, rmin,rmax));     
00685 }
00686 
00687 
00688 DDSolid  DDSolidFactory::polyhedra(const DDName & name,
00689                      int sides,
00690                      double startPhi,
00691                      double deltaPhi,
00692                      const std::vector<double> & z,
00693                      const std::vector<double> & r)
00694 {
00695   return DDSolid(name, new DDI::Polyhedra(sides,  startPhi, deltaPhi, z, r));
00696 }
00697 
00698 
00699 DDSolid DDSolidFactory::unionSolid(const DDName & name,
00700                     const DDSolid & a, const DDSolid & b,
00701                     const DDTranslation & t,
00702                     const DDRotation & r)
00703 {
00704   return DDSolid(name, new DDI::Union(a,b,t,r));
00705 }
00706 
00707 
00708 DDSolid DDSolidFactory::subtraction(const DDName & name,
00709                     const DDSolid & a, const DDSolid & b,
00710                     const DDTranslation & t,
00711                     const DDRotation & r)
00712 {
00713   return DDSolid(name, new DDI::Subtraction(a,b,t,r));
00714 }
00715 
00716 
00717 DDSolid DDSolidFactory::intersection(const DDName & name,
00718                     const DDSolid & a, const DDSolid & b,
00719                     const DDTranslation & t,
00720                     const DDRotation & r)
00721 {
00722   return DDSolid(name, new DDI::Intersection(a,b,t,r));
00723 }
00724 
00725 
00726 DDSolid DDSolidFactory::trap(const DDName & name,
00727                      double pDz,
00728                      double pTheta, double pPhi,
00729                      double pDy1, double pDx1, double pDx2,
00730                      double pAlp1,
00731                      double pDy2, double pDx3, double pDx4,
00732                      double pAlp2)
00733 {
00734   return DDSolid(name, new DDI::Trap(pDz, pTheta, pPhi,
00735                                      pDy1, pDx1, pDx2, pAlp1,
00736                                      pDy2, pDx3, pDx4, pAlp2));
00737 }                            
00738 
00739 
00740 DDSolid DDSolidFactory::pseudoTrap(const DDName & name,
00741                           double pDx1, 
00742                              double pDx2, 
00743                              double pDy1, 
00744                              double pDy2, 
00745                              double pDz, 
00746                              double radius, 
00747                              bool atMinusZ 
00748                              )
00749 {
00750    return DDSolid(name, new DDI::PseudoTrap(pDx1, pDx2, pDy1, pDy2, pDz, radius, atMinusZ));
00751 }
00752 
00753 DDSolid DDSolidFactory::truncTubs(const DDName & name,
00754                                   double zHalf, 
00755                                   double rIn, 
00756                                   double rOut, 
00757                                   double startPhi, 
00758                                   double deltaPhi, 
00759                                   double cutAtStart, 
00760                                   double cutAtDelta, 
00761                                   bool cutInside )
00762 {
00763   return DDSolid(name, new DDI::TruncTubs(zHalf,rIn,rOut,startPhi,deltaPhi,cutAtStart,cutAtDelta,cutInside));
00764 }                                 
00765 
00766 DDSolid DDSolidFactory::cons(const DDName & name,
00767                      double zhalf,
00768                      double rInMinusZ,                
00769                      double rOutMinusZ,
00770                      double rInPlusZ,
00771                      double rOutPlusZ,
00772                      double phiFrom,
00773                      double deltaPhi)
00774 {
00775   return DDSolid(name, new DDI::Cons(zhalf,
00776                                      rInMinusZ, rOutMinusZ,
00777                                      rInPlusZ, rOutPlusZ,
00778                                      phiFrom, deltaPhi));
00779 }                    
00780 
00781 DDSolid DDSolidFactory::torus(const DDName & name,
00782                               double rMin,
00783                               double rMax,
00784                               double rTorus,
00785                               double startPhi,
00786                               double deltaPhi)
00787 {
00788   return DDSolid(name, new DDI::Torus(rMin, rMax, rTorus, startPhi, deltaPhi));
00789 }                    
00790 
00791 DDSolid DDSolidFactory::tubs(const DDName & name,
00792                              double zhalf,
00793                              double rIn, double rOut,                 
00794                              double phiFrom, double deltaPhi)
00795 {                    
00796   return DDSolid(name, new DDI::Tubs(zhalf,rIn,rOut,phiFrom,deltaPhi));
00797 }
00798 
00799 
00800 DDSolid DDSolidFactory::sphere(const DDName & name,
00801                      double innerRadius,
00802                      double outerRadius,                      
00803                      double startPhi,
00804                      double deltaPhi,
00805                      double startTheta,
00806                      double deltaTheta)
00807 {
00808   return DDSolid(name, new DDI::Sphere(innerRadius, outerRadius, 
00809                                        startPhi, deltaPhi,
00810                                        startTheta, deltaTheta));
00811 }                    
00812 
00813 DDSolid DDSolidFactory::orb(const DDName & name, double radius)
00814 {
00815   return DDSolid(name, new DDI::Orb(radius));
00816 }                    
00817 
00818 DDSolid DDSolidFactory::ellipticalTube(const DDName & name,
00819                                        double xSemiAxis, double ySemiAxis, double zHeight)
00820 {
00821   return DDSolid(name, new DDI::EllipticalTube(xSemiAxis, ySemiAxis, zHeight));
00822 }                    
00823 
00824 DDSolid DDSolidFactory::ellipsoid(const DDName & name,
00825                                   double  xSemiAxis,
00826                                   double  ySemiAxis,
00827                                   double  zSemiAxis,
00828                                   double  zBottomCut,
00829                                   double  zTopCut
00830                                   )
00831   
00832 {
00833   return DDSolid(name, new DDI::Ellipsoid( xSemiAxis,
00834                                            ySemiAxis,
00835                                            zSemiAxis,
00836                                            zBottomCut,
00837                                            zTopCut
00838                                           ));
00839 }                    
00840 
00841 DDSolid DDSolidFactory::parallelepiped(const DDName & name,
00842                                        double xHalf, double yHalf, double zHalf,
00843                                        double alpha, double theta, double phi)
00844 {
00845   return DDSolid(name, new DDI::Parallelepiped(xHalf, yHalf, zHalf,
00846                                                alpha, theta, phi));
00847 }                    
00848 
00849 DDSolid DDSolidFactory::shapeless(const DDName & name)
00850 {
00851   return DDSolid(name, new DDI::Shapeless());
00852 }  
00853 
00854 
00855 DDSolid DDSolidFactory::reflection(const DDName & name,
00856                                    const DDSolid & s)
00857 {
00858   return DDSolid(name, new DDI::Reflection(s));
00859 }                                  
00860 
00861 /*
00862 DDSolid       DDcons(const DDName & name,
00863                      double zhalf,
00864                      double rInMinusZ,                
00865                      double rOutMinusZ,
00866                      double rInPlusZ,
00867                      double rOutPlusZ,
00868                      double phiFrom,
00869                      double deltaPhi)
00870 {                    
00871   return new DDConsImpl(name, zhalf, rInMinusZ, rOutMinusZ, rInPlusZ, rOutPlusZ,phiFrom, deltaPhi);
00872 }
00873 
00874                                      
00875 
00876 DDSolid       DDtubs(const DDName & name,
00877                      double zhalf,
00878                      double rIn, double rOut,                 
00879                      double phiFrom, double deltaPhi)
00880 {                    
00881   return new DDTubsImpl(name, zhalf,rIn,rOut,phiFrom,deltaPhi);
00882 }
00883                      
00884 
00885 DDSolid       DDtrap(const DDName & name,
00886                      double pDz,
00887                      double pTheta, double pPhi,
00888                      double pDy1, double pDx1, double pDx2,
00889                      double pAlp1,
00890                      double pDy2, double pDx3, double pDx4,
00891                      double pAlp2)
00892 {                    
00893  return new DDTrapImpl(name, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); 
00894 }
00895                      
00896                      
00897 DDSolid  DDshapeless(const DDName & name)
00898 {                    
00899   return new DDShapelessImpl(name);
00900 }
00901 
00902 
00903 DDSolid      DDunion(const DDName & name,
00904                      const DDSolid & a, 
00905                      const DDSolid & b, 
00906                      const DDRotation & r,
00907                      const DDTranslation & t)
00908 
00909 {                    
00910   return new DDUnionImpl( name, a, b,r,t);
00911 }
00912                      
00913                      
00914 DDSolid      DDsubtraction(const DDName & name,
00915                            const DDSolid & a, 
00916                            const DDSolid & b, 
00917                            const DDRotation & r,
00918                            const DDTranslation & t)
00919 
00920 {                    
00921   return new DDSubtractionImpl( name, a, b,r,t); 
00922 }
00923 
00924 
00925 DDSolid      DDintersection(const DDName & name,
00926                             const DDSolid & a, 
00927                             const DDSolid & b, 
00928                             const DDRotation & r,
00929                             const DDTranslation & t)
00930 
00931 {                    
00932   return new DDIntersectionImpl( name, a, b,r,t); 
00933 }
00934 
00935 
00936 DDSolid   DDreflectionSolid(const DDName & name,
00937                             const DDSolid & unreflected)
00938 {                                                                       
00939   return new DDReflectionSolidImpl( name, unreflected );
00940 }
00941 
00942 */