Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:29:33

0001 /*
0002  * TUnplacedBooleanMinusVolume.h
0003  *
0004  *  Created on: Aug 13, 2014
0005  *      Author: swenzel
0006  */
0007 
0008 #ifndef TUNPLACEDBOOLEANMINUSVOLUME_H_
0009 #define TUNPLACEDBOOLEANMINUSVOLUME_H_
0010 
0011 #include "VecGeom/base/Cuda.h"
0012 #include "VecGeom/base/Global.h"
0013 #include "VecGeom/base/AlignedBase.h"
0014 #include "VecGeom/base/Vector3D.h"
0015 #include "VecGeom/volumes/UnplacedVolume.h"
0016 //#include "VecGeom/volumes/TSpecializedBooleanMinusVolume.h"
0017 
0018 namespace VECGEOM_NAMESPACE {
0019 
0020 /**
0021  * A class representing a simple UNPLACED substraction boolean volume A-B
0022  * It takes two template arguments:
0023  * 1.: the mother (or left) volume A in unplaced form
0024  * 2.: the subtraction (or right) volume B in placed form; the placement is with respect to the left volume
0025  *
0026  *
0027  * Example:
0028  *
0029  * typedef TUnplacedBooleanMinusVolume<UnplacedBox,
0030  *           SpecializedBox<translation::kGeneric,rotation::kIdentity> > BoxMinusTranslatedBox_t
0031  *
0032  *
0033  * will be a boolean solid where two boxes are subtracted
0034  * and B is only translated (not rotated) with respect to A
0035  *
0036  */
0037 // template< typename LeftUnplacedVolume_t, typename RightPlacedVolume_t >
0038 typedef VPlacedVolume LeftUnplacedVolume_t;
0039 typedef VPlacedVolume RightPlacedVolume_t;
0040 class TUnplacedBooleanMinusVolume : public VUnplacedVolume, public AlignedBase {
0041 
0042 public:
0043   VPlacedVolume const *fLeftVolume;
0044   VPlacedVolume const *fRightVolume;
0045   // LeftUnplacedVolume_t const* fLeftVolume;
0046   // RightPlacedVolume_t  const* fRightVolume;
0047 
0048 public:
0049   // need a constructor
0050   TUnplacedBooleanMinusVolume(LeftUnplacedVolume_t const *left, RightPlacedVolume_t const *right)
0051       : fLeftVolume(left), fRightVolume(right)
0052   {
0053   }
0054 
0055   typedef LeftUnplacedVolume_t LeftType;
0056   typedef RightPlacedVolume_t RightType;
0057 
0058   virtual int MemorySize() const { return sizeof(*this); }
0059 
0060 #ifdef VECGEOM_CUDA_INTERFACE
0061   virtual VUnplacedVolume *CopyToGpu() const;
0062   virtual VUnplacedVolume *CopyToGpu(VUnplacedVolume *const gpu_ptr) const;
0063 #endif
0064 
0065   VECCORE_ATT_HOST_DEVICE
0066   VECGEOM_FORCE_INLINE
0067   Precision Capacity() const
0068   {
0069     // TBDONE -- need some sampling
0070     return 0.;
0071   }
0072 
0073   VECCORE_ATT_HOST_DEVICE
0074   VECGEOM_FORCE_INLINE
0075   Precision SurfaceArea() const
0076   {
0077     // TBDONE -- need some sampling
0078     return 0.;
0079   }
0080 
0081   VECCORE_ATT_HOST_DEVICE
0082   void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const {
0083       // TBDONE
0084   };
0085 
0086   VECCORE_ATT_HOST_DEVICE
0087   virtual void Print() const {};
0088 
0089   virtual void Print(std::ostream &os) const {};
0090 
0091 #ifndef VECCORE_CUDA
0092   template <typename LeftUnplacedVolume_t, typename RightPlacedVolume_t, TranslationCode trans_code,
0093             RotationCode rot_code>
0094   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0095                                VPlacedVolume *const placement = NULL)
0096   {
0097     //      if (placement) {
0098     //          new(placement) TSpecializedBooleanMinusVolume<LeftUnplacedVolume_t, RightPlacedVolume_t,
0099     //                  trans_code, rot_code>(logical_volume,
0100     //                                                              transformation);
0101     //          return placement;
0102     //        }
0103     //      return new TSpecializedBooleanMinusVolume<LeftUnplacedVolume_t, RightPlacedVolume_t, trans_code,
0104     //      rot_code>(logical_volume,
0105     //                                                     transformation);
0106   }
0107 
0108   static VPlacedVolume *CreateSpecializedVolume(LogicalVolume const *const volume,
0109                                                 Transformation3D const *const transformation,
0110                                                 const TranslationCode trans_code, const RotationCode rot_code,
0111                                                 VPlacedVolume *const placement = NULL)
0112   {
0113 
0114     // return VolumeFactory::CreateByTransformation<TUnplacedBooleanMinusVolume<LeftUnplacedVolume_t,
0115     // RightPlacedVolume_t> >(
0116     //           volume, transformation, trans_code, rot_code, placement
0117     //         );
0118   }
0119 
0120 #else // for CUDA
0121   template <TranslationCode trans_code, RotationCode rot_code>
0122   VECCORE_ATT_DEVICE
0123   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0124                                const int id, VPlacedVolume *const placement = NULL);
0125 
0126   VECCORE_ATT_DEVICE static VPlacedVolume *CreateSpecializedVolume(LogicalVolume const *const volume,
0127                                                                    Transformation3D const *const transformation,
0128                                                                    const TranslationCode trans_code,
0129                                                                    const RotationCode rot_code, const int id,
0130                                                                    VPlacedVolume *const placement = NULL);
0131 #endif
0132 
0133 private:
0134 #ifndef VECCORE_CUDA
0135   virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0136                                            Transformation3D const *const transformation,
0137                                            const TranslationCode trans_code, const RotationCode rot_code,
0138                                            VPlacedVolume *const placement = NULL) const
0139   {
0140     return CreateSpecializedVolume(volume, transformation, trans_code, rot_code, placement);
0141   }
0142 #else
0143   VECCORE_ATT_DEVICE virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0144                                                               Transformation3D const *const transformation,
0145                                                               const TranslationCode trans_code,
0146                                                               const RotationCode rot_code, const int id,
0147                                                               VPlacedVolume *const placement = NULL) const
0148   {
0149     return CreateSpecializedVolume(volume, transformation, trans_code, rot_code, id, placement);
0150   }
0151 #endif
0152 
0153 }; // End class
0154 
0155 } // namespace VECGEOM_NAMESPACE
0156 
0157 #endif /* TUNPLACEDBOOLEANMINUSVOLUME_H_ */