CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DetectorDescription/Core/src/DDSolid.cc

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