CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DetectorDescription/Core/interface/DDSolid.h

Go to the documentation of this file.
00001 #ifndef DDSolid_h
00002 #define DDSolid_h
00003 
00004 #include <iosfwd>
00005 #include <vector>
00006 
00007 #include "DetectorDescription/Core/interface/DDName.h"
00008 #include "DetectorDescription/Core/interface/DDBase.h"
00009 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
00010 #include "DetectorDescription/Core/interface/DDTransform.h"
00011 #include "DetectorDescription/Base/interface/DDTranslation.h"
00012 
00013 namespace DDI { class Solid; }
00014 namespace DDI { class Reflection; }
00015 namespace DDI { class BooleanSolid; }
00016 
00017 class DDSolid;
00018 struct DDSolidFactory;
00019 class DDStreamer;
00020 
00021 std::ostream & operator<<( std::ostream &, const DDSolid & );
00022 
00024 
00035 class DDSolid : public DDBase<DDName, DDI::Solid*>
00036 {
00037   friend std::ostream & operator<<( std::ostream &, const DDSolid & );
00038   friend struct DDSolidFactory;
00039   friend class DDDToPersFactory;
00040   friend class DDPersToDDDFactory;
00041   friend class DDStreamer;
00042     
00043 public: 
00045   DDSolid( void );
00046   
00048 
00056   DDSolid( const DDName & name ); 
00057   
00059   const std::vector<double> & parameters( void ) const;
00060   
00062   double volume( void ) const;
00063   
00065   DDSolidShape shape( void ) const;
00066   
00067 private:
00068   DDSolid( const DDName &, DDI::Solid * );    
00069   DDSolid( const DDName &, DDSolidShape, const std::vector<double> & );
00070 };
00071 
00073 
00077 class DDTrap : public DDSolid
00078 {
00079 public:
00080   DDTrap( const DDSolid & s );
00082   double halfZ( void ) const;
00084   double theta( void ) const;
00086   double phi( void ) const;
00088   double y1( void ) const;
00090   double x1( void ) const;
00092   double x2( void ) const;
00094   double alpha1( void ) const;
00096   double y2( void ) const;
00098   double x3( void ) const;
00100   double x4( void ) const;
00102   double alpha2( void ) const;
00103   
00104 private:
00105   DDTrap( void );
00106 };
00107 
00108 class DDPseudoTrap : public DDSolid
00109 {
00110 public:
00111   DDPseudoTrap( const DDSolid & s );
00113   double halfZ( void ) const;
00115   double x1( void ) const;
00117   double x2( void ) const;
00119   double y1( void ) const;
00121   double y2( void ) const;   
00123   double radius( void ) const;
00125   bool atMinusZ( void ) const;
00126 
00127 private:
00128   DDPseudoTrap( void );
00129 };
00130   
00132 class DDTruncTubs : public DDSolid
00133 {
00134 public:
00135   DDTruncTubs( const DDSolid & s );
00137   double zHalf( void ) const;
00139   double rIn( void ) const;
00141   double rOut( void ) const;
00143   double startPhi( void ) const;
00145   double deltaPhi( void ) const;
00147   double cutAtStart( void ) const;
00149   double cutAtDelta( void ) const;
00151   bool cutInside( void ) const;
00152 
00153 private:
00154   DDTruncTubs( void );
00155 };
00156 
00158 
00162 class DDBox : public DDSolid
00163 {
00164 public:
00165   DDBox( const DDSolid & s );
00166   double halfX( void ) const; 
00167   double halfY( void ) const; 
00168   double halfZ( void ) const; 
00169 
00170 private:
00171   DDBox( void );
00172 };
00173 
00175 class DDShapelessSolid : public DDSolid
00176 {
00177 public:
00178   DDShapelessSolid( const DDSolid & s );
00179 
00180 private:
00181   DDShapelessSolid( void );
00182 };
00183 
00184 class DDReflectionSolid : public DDSolid
00185 {
00186 public:
00187   DDReflectionSolid( const DDSolid & s );
00188   DDSolid unreflected( void ) const;
00189 
00190 private:
00191   DDReflectionSolid( void ); 
00192   DDI::Reflection * reflected_; 
00193 }; 
00194 
00195 class DDBooleanSolid : public DDSolid
00196 {
00197 public:
00198   DDBooleanSolid( const DDSolid & s );
00199   DDSolid solidA( void ) const;
00200   DDSolid solidB( void ) const;
00201   DDTranslation translation( void ) const;
00202   DDRotation rotation( void ) const;
00203 
00204 private:
00205   DDBooleanSolid( void );
00206   DDI::BooleanSolid * boolean_;  
00207 };
00208 
00210 class DDPolySolid : public DDSolid
00211 {
00212 public:
00213   DDPolySolid( const DDSolid & s );
00214 
00215 protected:
00217   virtual std::vector<double> getVec( const size_t& which, const size_t& offset = 0, const size_t& nVecs = 1 ) const;
00218   DDPolySolid( void );
00219 };
00220   
00221 class DDPolycone : public DDPolySolid
00222 {
00223 public:
00224   DDPolycone( const DDSolid & s );
00225   double startPhi( void ) const;
00226   double deltaPhi( void ) const;
00227   std::vector<double> zVec( void ) const;
00228   std::vector<double> rVec( void ) const;
00229   std::vector<double> rMinVec( void ) const;
00230   std::vector<double> rMaxVec( void ) const;
00231 
00232 private:
00233   DDPolycone( void );
00234 };
00235 
00236 class DDPolyhedra : public DDPolySolid
00237 {
00238 public:
00239   DDPolyhedra( const DDSolid & s );
00240   int sides( void ) const;
00241   double startPhi( void ) const;
00242   double deltaPhi( void ) const;
00243   std::vector<double> zVec( void ) const;
00244   std::vector<double> rVec( void ) const;
00245   std::vector<double> rMinVec( void ) const;
00246   std::vector<double> rMaxVec( void ) const;
00247 
00248 private:
00249   DDPolyhedra( void );
00250 };
00251 
00252 class DDTubs : public DDSolid
00253 {
00254 public:
00255   DDTubs( const DDSolid & s );
00256   double zhalf( void ) const;
00257   double rIn( void ) const;
00258   double rOut( void ) const;
00259   double startPhi( void ) const;
00260   double deltaPhi( void ) const;
00261 
00262 private:
00263   DDTubs( void );
00264 };
00265 
00266 class DDCons : public DDSolid
00267 {
00268 public:
00269   DDCons( const DDSolid & s );
00270   double zhalf( void ) const;
00271   double rInMinusZ( void ) const;
00272   double rOutMinusZ( void ) const;
00273   double rInPlusZ( void ) const;
00274   double rOutPlusZ( void ) const;
00275   double phiFrom( void ) const;
00276   double deltaPhi( void ) const;
00277 
00278 private:
00279   DDCons( void );
00280 };
00281 
00282 class DDTorus : public DDSolid
00283 {
00284 public:
00285   DDTorus( const DDSolid & s );
00286   double rMin( void ) const;
00287   double rMax( void ) const;
00288   double rTorus( void ) const;
00289   double startPhi( void ) const;
00290   double deltaPhi( void ) const;
00291 
00292 private:
00293   DDTorus( void );
00294 };
00295 
00296 class DDUnion : public DDBooleanSolid
00297 {
00298 public:
00299   DDUnion( const DDSolid & s );
00300   
00301 private:
00302   DDUnion( void );
00303 };
00304 
00305 class DDIntersection : public DDBooleanSolid
00306 {
00307 public:
00308   DDIntersection( const DDSolid & s );
00309 
00310 private:
00311   DDIntersection( void );
00312 };
00313 
00314 class DDSubtraction : public DDBooleanSolid
00315 {
00316 public:
00317   DDSubtraction( const DDSolid & s );
00318 
00319 private:
00320   DDSubtraction( void );
00321 };
00322 
00323 class DDSphere : public DDSolid
00324 {
00325 public:
00326   DDSphere( const DDSolid & s );
00327   double innerRadius( void ) const;
00328   double outerRadius( void ) const;
00329   double startPhi( void ) const;
00330   double deltaPhi( void ) const;
00331   double startTheta( void ) const;
00332   double deltaTheta( void ) const;
00333 
00334 private:
00335   DDSphere( void );
00336 };
00337 
00338 class DDOrb : public DDSolid
00339 {
00340 public:
00341   DDOrb( const DDSolid & s );
00342   double radius( void ) const;
00343 
00344 private:
00345   DDOrb( void );
00346 };
00347 
00348 class DDEllipticalTube : public DDSolid
00349 {
00350 public:
00351   DDEllipticalTube( const DDSolid & s );
00352   double xSemiAxis( void ) const;
00353   double ySemiAxis( void ) const;
00354   double zHeight( void ) const;
00355   
00356 private:
00357   DDEllipticalTube( void );
00358 };
00359 
00360 class DDEllipsoid : public DDSolid
00361 {
00362 public:
00363   DDEllipsoid( const DDSolid & s );
00364   double xSemiAxis( void ) const;
00365   double ySemiAxis( void ) const;
00366   double zSemiAxis( void ) const;
00367   double zBottomCut( void ) const;
00368   double zTopCut( void ) const;
00369 
00370 private:
00371   DDEllipsoid( void );
00372 };
00373 
00374 class DDParallelepiped : public DDSolid
00375 {
00376 public:
00377   DDParallelepiped( const DDSolid & s );
00378   double xHalf( void ) const;
00379   double yHalf( void ) const;
00380   double zHalf( void ) const;
00381   double alpha( void ) const;
00382   double theta( void ) const;
00383   double phi( void ) const;
00384 
00385 private:
00386   DDParallelepiped( void );
00387 };
00388 
00389 // Solid generation functions
00390 //
00391 struct DDSolidFactory
00392 {
00394 
00400   static DDSolid box( const DDName & name,
00401                       double xHalf, 
00402                       double yHalf,
00403                       double zHalf );
00404 
00406 
00409   static DDSolid polycone( const DDName & name, double startPhi, double deltaPhi,
00410                            const std::vector<double> & z,
00411                            const std::vector<double> & rmin,
00412                            const std::vector<double> & rmax );
00413 
00415 
00418   static DDSolid polycone( const DDName & name, double startPhi, double deltaPhi,
00419                            const std::vector<double> & z,
00420                            const std::vector<double> & r );
00421 
00423 
00426   static DDSolid polyhedra( const DDName & name,
00427                             int sides,
00428                             double startPhi, double deltaPhi,
00429                             const std::vector<double> & z,
00430                             const std::vector<double> & rmin,
00431                             const std::vector<double> & rmax );
00432                      
00434 
00437   static DDSolid polyhedra( const DDName & name,
00438                             int sides,
00439                             double startPhi, double deltaPhi,
00440                             const std::vector<double> & z,
00441                             const std::vector<double> & r );
00442 
00443   static DDSolid unionSolid( const DDName & name,
00444                              const DDSolid & a,
00445                              const DDSolid & b,
00446                              const DDTranslation & t,
00447                              const DDRotation & r );
00448 
00449   static DDSolid intersection( const DDName & name,
00450                                const DDSolid & a,
00451                                const DDSolid & b,
00452                                const DDTranslation & t,
00453                                const DDRotation & r );
00454 
00455   static DDSolid subtraction( const DDName & name,
00456                               const DDSolid & a,
00457                               const DDSolid & b,
00458                               const DDTranslation & t,
00459                               const DDRotation & r );
00460 
00461   static DDSolid trap( const DDName & name,
00462                        double pDz,
00463                        double pTheta, double pPhi,
00464                        double pDy1, double pDx1, double pDx2,
00465                        double pAlp1,
00466                        double pDy2, double pDx3, double pDx4,
00467                        double pAlp2 );                               
00468 
00469   static DDSolid pseudoTrap( const DDName & name,
00470                              double pDx1,       
00471                              double pDx2,       
00472                              double pDy1,       
00473                              double pDy2,       
00474                              double pDz,        
00475                              double radius,     
00476                              bool atMinusZ );   
00478   static DDSolid truncTubs( const DDName & name,
00479                             double zHalf,       
00480                             double rIn,         
00481                             double rOut,        
00482                             double startPhi,    
00483                             double deltaPhi,    
00484                             double cutAtStart,  
00485                             double cutAtDelta,  
00486                             bool cutInside );
00487 
00488   static DDSolid tubs( const DDName & name,
00489                        double zhalf,
00490                        double rIn, double rOut,               
00491                        double startPhi, 
00492                        double deltaPhi );
00493 
00494   static DDSolid cons( const DDName & name,
00495                        double zhalf,
00496                        double rInMinusZ,                      
00497                        double rOutMinusZ,
00498                        double rInPlusZ,
00499                        double rOutPlusZ,
00500                        double phiFrom,
00501                        double deltaPhi );
00502 
00503   static DDSolid torus( const DDName & name,
00504                         double rMin,
00505                         double rMax,
00506                         double rTorus,
00507                         double startPhi,
00508                         double deltaPhi );
00509   
00510   static DDSolid sphere( const DDName & name,
00511                          double innerRadius,
00512                          double outerRadius,                  
00513                          double startPhi,
00514                          double deltaPhi,
00515                          double startTheta,
00516                          double deltaTheta );
00517 
00518   static DDSolid orb( const DDName & name,
00519                       double radius );
00520   
00521   static DDSolid ellipticalTube( const DDName & name,
00522                                  double xSemiAxis,
00523                                  double ySemiAxis,
00524                                  double zHeight );
00525 
00526   static DDSolid ellipsoid( const DDName & name,
00527                             double  xSemiAxis,
00528                             double  ySemiAxis,
00529                             double  zSemiAxis,
00530                             double  zBottomCut = 0.,
00531                             double  zTopCut = 0. );
00532 
00533   static DDSolid parallelepiped( const DDName & name,
00534                                  double xHalf, double yHalf, double zHalf,
00535                                  double alpha, double theta, double phi );
00536 
00537 
00538   static DDSolid shapeless( const DDName & name );
00539 
00540   static DDSolid reflection( const DDName & name,
00541                              const DDSolid & s );
00542 };                                                                                                  
00543                                       
00544 #endif