00001 #ifndef DDSolid_h
00002 #define DDSolid_h
00003
00004 #include <stdexcept>
00005 #include <iosfwd>
00006 #include <vector>
00007 #include <utility>
00008
00009 #include "DetectorDescription/Core/interface/DDName.h"
00010 #include "DetectorDescription/Core/interface/DDBase.h"
00011 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
00012 #include "DetectorDescription/Core/interface/DDTransform.h"
00013 #include "DetectorDescription/Base/interface/DDTranslation.h"
00014
00015 namespace DDI { class Solid; }
00016 namespace DDI { class Reflection; }
00017 namespace DDI { class BooleanSolid; }
00018
00019
00020
00021 class DDSolid;
00022
00023 class DDSolidFactory;
00024 class DDStreamer;
00025
00026
00027 std::ostream & operator<<( std::ostream &, const DDSolid &);
00028
00029
00031
00042 class DDSolid : public DDBase<DDName,DDI::Solid*>
00043 {
00044 friend std::ostream & operator<<(std::ostream &, const DDSolid &);
00045 friend class DDSolidFactory;
00046 friend class DDDToPersFactory;
00047 friend class DDPersToDDDFactory;
00048 friend class DDStreamer;
00049
00050 public:
00052 DDSolid();
00053
00055
00063 DDSolid(const DDName & name);
00064
00066
00072
00073 const std::vector<double> & parameters() const;
00074
00076 double volume() const;
00077
00079 DDSolidShape shape() const;
00080
00082
00083
00085
00092
00093
00094
00095
00096 private:
00097 DDSolid(const DDName &, DDI::Solid *);
00098 DDSolid(const DDName &, DDSolidShape, const std::vector<double> &);
00099 };
00100
00101 struct Composites {
00102 Composites (const DDSolid & A, const DDSolid & B,
00103 const DDTranslation & T, const DDRotation & R)
00104 : a_(A), b_(B), t_(T), r_(R) { }
00105 const DDSolid a_, b_;
00106 const DDTranslation t_;
00107 const DDRotation r_;
00108 };
00109
00111
00115 class DDTrap : public DDSolid
00116 {
00117 public:
00118 DDTrap(const DDSolid & s);
00120 double halfZ() const;
00122 double theta() const;
00124 double phi() const;
00126 double y1() const;
00128 double x1() const;
00130 double x2() const;
00132 double alpha1() const;
00134 double y2() const;
00136 double x3() const;
00138 double x4() const;
00140 double alpha2() const;
00141 };
00142
00143 class DDPseudoTrap : public DDSolid
00144 {
00145 public:
00146 DDPseudoTrap(const DDSolid & s);
00148 double halfZ() const;
00150 double x1() const;
00152 double x2() const;
00154 double y1() const;
00156 double y2() const;
00158 double radius() const;
00160 bool atMinusZ() const;
00161 };
00162
00164 class DDTruncTubs : public DDSolid
00165 {
00166 public:
00167 DDTruncTubs(const DDSolid & s);
00169 double zHalf() const;
00171 double rIn() const;
00173 double rOut() const;
00175 double startPhi() const;
00177 double deltaPhi() const;
00179 double cutAtStart() const;
00181 double cutAtDelta() const;
00183 bool cutInside() const;
00184 };
00185 class DDBox : public DDSolid
00186 {
00187 public:
00188 DDBox(const DDSolid & s);
00189 double halfX() const;
00190 double halfY() const;
00191 double halfZ() const;
00192 private:
00193 DDBox();
00194 };
00195
00197 class DDShapelessSolid : public DDSolid
00198
00199 {
00200 public:
00201 DDShapelessSolid(const DDSolid & s);
00202
00203 private:
00204 DDShapelessSolid();
00205 };
00206
00207 class DDReflectionSolid : public DDSolid
00208 {
00209 public:
00210 DDReflectionSolid(const DDSolid & s);
00211 DDSolid unreflected() const;
00212 private:
00213 DDReflectionSolid();
00214 DDI::Reflection * reflected_;
00215 };
00216
00217
00218 class DDBooleanSolid : public DDSolid
00219 {
00220 public:
00221 DDBooleanSolid(const DDSolid & s);
00222 DDSolid solidA() const;
00223 DDSolid solidB() const;
00224 DDTranslation translation() const;
00225 DDRotation rotation() const;
00226 private:
00227 DDBooleanSolid();
00228 DDI::BooleanSolid * boolean_;
00229 };
00230
00232 class DDPolySolid : public DDSolid
00233 {
00234 public:
00235 DDPolySolid(const DDSolid & s);
00236
00237 protected:
00239 virtual std::vector<double> getVec(const size_t& which, const size_t& offset = 0, const size_t& nVecs = 1) const;
00240 DDPolySolid();
00241
00242 };
00243
00244 class DDPolycone : public DDPolySolid
00245 {
00246 public:
00247 DDPolycone(const DDSolid & s);
00248 double startPhi() const;
00249 double deltaPhi() const;
00250 std::vector<double> zVec() const;
00251 std::vector<double> rVec() const;
00252 std::vector<double> rMinVec() const;
00253 std::vector<double> rMaxVec() const;
00254
00255 private:
00256 DDPolycone();
00257 };
00258
00259 class DDPolyhedra : public DDPolySolid
00260 {
00261 public:
00262 DDPolyhedra(const DDSolid & s);
00263 int sides() const;
00264 double startPhi() const;
00265 double deltaPhi() const;
00266 std::vector<double> zVec() const;
00267 std::vector<double> rVec() const;
00268 std::vector<double> rMinVec() const;
00269 std::vector<double> rMaxVec() const;
00270
00271 private:
00272 DDPolyhedra();
00273 };
00274
00275 class DDTubs : public DDSolid
00276 {
00277 public:
00278 DDTubs(const DDSolid & s);
00279 double zhalf() const;
00280 double rIn() const;
00281 double rOut() const;
00282 double startPhi() const;
00283 double deltaPhi() const;
00284
00285 private:
00286 DDTubs();
00287 };
00288
00289 class DDCons : public DDSolid
00290 {
00291 public:
00292 DDCons(const DDSolid & s);
00293 double zhalf() const;
00294 double rInMinusZ() const;
00295 double rOutMinusZ() const;
00296 double rInPlusZ() const;
00297 double rOutPlusZ() const;
00298 double phiFrom() const;
00299 double deltaPhi() const;
00300
00301 private:
00302 DDCons();
00303 };
00304
00305 class DDTorus : public DDSolid
00306 {
00307 public:
00308 DDTorus (const DDSolid & s);
00309 double rMin() const;
00310 double rMax() const;
00311 double rTorus() const;
00312 double startPhi() const;
00313 double deltaPhi() const;
00314
00315 private:
00316 DDTorus
00317 ();
00318 };
00319
00320 class DDUnion : public DDBooleanSolid
00321 {
00322 public:
00323 DDUnion(const DDSolid & s);
00324
00325 private:
00326 DDUnion();
00327 };
00328
00329 class DDIntersection : public DDBooleanSolid
00330 {
00331 public:
00332 DDIntersection(const DDSolid & s);
00333
00334 private:
00335 DDIntersection();
00336 };
00337
00338 class DDSubtraction : public DDBooleanSolid
00339 {
00340 public:
00341 DDSubtraction(const DDSolid & s);
00342
00343 private:
00344 DDSubtraction();
00345 };
00346
00347
00348 class DDSphere : public DDSolid
00349 {
00350 public:
00351 DDSphere(const DDSolid & s);
00352 double innerRadius() const;
00353 double outerRadius() const;
00354 double startPhi() const;
00355 double deltaPhi() const;
00356 double startTheta() const;
00357 double deltaTheta() const;
00358
00359 private:
00360 DDSphere();
00361 };
00362
00363 class DDOrb : public DDSolid
00364 {
00365 public:
00366 DDOrb(const DDSolid & s);
00367 double radius() const;
00368
00369 private:
00370 DDOrb();
00371 };
00372
00373 class DDEllipticalTube : public DDSolid
00374 {
00375 public:
00376 DDEllipticalTube(const DDSolid & s);
00377 double xSemiAxis() const;
00378 double ySemiAxis() const;
00379 double zHeight() const;
00380
00381 private:
00382 DDEllipticalTube();
00383 };
00384
00385 class DDEllipsoid : public DDSolid
00386 {
00387 public:
00388 DDEllipsoid(const DDSolid & s);
00389 double xSemiAxis() const;
00390 double ySemiAxis() const;
00391 double zSemiAxis() const;
00392 double zBottomCut() const;
00393 double zTopCut() const;
00394
00395 private:
00396 DDEllipsoid();
00397 };
00398
00399 class DDParallelepiped : public DDSolid
00400 {
00401 public:
00402 DDParallelepiped(const DDSolid & s);
00403 double xHalf() const;
00404 double yHalf() const;
00405 double zHalf() const;
00406 double alpha() const;
00407 double theta() const;
00408 double phi() const;
00409
00410 private:
00411 DDParallelepiped();
00412 };
00413
00414
00416
00422 struct DDSolidFactory {
00423
00424
00425 static DDSolid box(const DDName & name,
00426 double xHalf,
00427 double yHalf,
00428 double zHalf);
00429
00431
00434 static DDSolid polycone(const DDName & name, double startPhi, double deltaPhi,
00435 const std::vector<double> & z,
00436 const std::vector<double> & rmin,
00437 const std::vector<double> & rmax);
00438
00440
00443 static DDSolid polycone(const DDName & name, double startPhi, double deltaPhi,
00444 const std::vector<double> & z,
00445 const std::vector<double> & r);
00446
00448
00451 static DDSolid polyhedra(const DDName & name,
00452 int sides,
00453 double startPhi, double deltaPhi,
00454 const std::vector<double> & z,
00455 const std::vector<double> & rmin,
00456 const std::vector<double> & rmax);
00457
00459
00462 static DDSolid polyhedra(const DDName & name,
00463 int sides,
00464 double startPhi, double deltaPhi,
00465 const std::vector<double> & z,
00466 const std::vector<double> & r);
00467
00468 static DDSolid unionSolid(const DDName & name,
00469 const DDSolid & a,
00470 const DDSolid & b,
00471 const DDTranslation & t,
00472 const DDRotation & r);
00473
00474 static DDSolid intersection(const DDName & name,
00475 const DDSolid & a,
00476 const DDSolid & b,
00477 const DDTranslation & t,
00478 const DDRotation & r);
00479
00480 static DDSolid subtraction(const DDName & name,
00481 const DDSolid & a,
00482 const DDSolid & b,
00483 const DDTranslation & t,
00484 const DDRotation & r);
00485
00486 static DDSolid trap(const DDName & name,
00487 double pDz,
00488 double pTheta, double pPhi,
00489 double pDy1, double pDx1, double pDx2,
00490 double pAlp1,
00491 double pDy2, double pDx3, double pDx4,
00492 double pAlp2);
00493
00494 static DDSolid pseudoTrap(const DDName & name,
00495 double pDx1,
00496 double pDx2,
00497 double pDy1,
00498 double pDy2,
00499 double pDz,
00500 double radius,
00501 bool atMinusZ
00502 );
00503
00504 static DDSolid truncTubs(const DDName & name,
00505 double zHalf,
00506 double rIn,
00507 double rOut,
00508 double startPhi,
00509 double deltaPhi,
00510 double cutAtStart,
00511 double cutAtDelta,
00512 bool cutInside);
00513
00514 static DDSolid tubs(const DDName & name,
00515 double zhalf,
00516 double rIn, double rOut,
00517 double startPhi,
00518 double deltaPhi);
00519
00520 static DDSolid cons(const DDName & name,
00521 double zhalf,
00522 double rInMinusZ,
00523 double rOutMinusZ,
00524 double rInPlusZ,
00525 double rOutPlusZ,
00526 double phiFrom,
00527 double deltaPhi);
00528
00529 static DDSolid torus(const DDName & name,
00530 double rMin,
00531 double rMax,
00532 double rTorus,
00533 double startPhi,
00534 double deltaPhi);
00535
00536 static DDSolid sphere(const DDName & name,
00537 double innerRadius,
00538 double outerRadius,
00539 double startPhi,
00540 double deltaPhi,
00541 double startTheta,
00542 double deltaTheta);
00543
00544 static DDSolid orb(const DDName & name,
00545 double radius);
00546
00547 static DDSolid ellipticalTube(const DDName & name,
00548 double xSemiAxis,
00549 double ySemiAxis,
00550 double zHeight);
00551
00552 static DDSolid ellipsoid(const DDName & name,
00553 double xSemiAxis,
00554 double ySemiAxis,
00555 double zSemiAxis,
00556 double zBottomCut=0,
00557 double zTopCut=0
00558 );
00559
00560 static DDSolid parallelepiped(const DDName & name,
00561 double xHalf, double yHalf, double zHalf,
00562 double alpha, double theta, double phi);
00563
00564
00565 static DDSolid shapeless(const DDName & name);
00566
00567 static DDSolid reflection(const DDName & name,
00568 const DDSolid & s);
00569
00570 };
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686 #endif