Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef VECGEOM_VOLUMES_UNPLACED_SEXTRUVOLUME_H_
0002 #define VECGEOM_VOLUMES_UNPLACED_SEXTRUVOLUME_H_
0003 
0004 #include "VecGeom/base/AlignedBase.h"
0005 #include "VecGeom/base/Cuda.h"
0006 #include "VecGeom/base/Global.h"
0007 #include "VecGeom/base/Vector3D.h"
0008 #include "VecGeom/volumes/PolygonalShell.h"
0009 #include "VecGeom/volumes/UnplacedVolume.h"
0010 #include "VecGeom/volumes/kernel/SExtruImplementation.h"
0011 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0012 
0013 namespace vecgeom {
0014 
0015 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedSExtruVolume;);
0016 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedSExtruVolume);
0017 
0018 inline namespace VECGEOM_IMPL_NAMESPACE {
0019 
0020 class UnplacedSExtruVolume : public LoopUnplacedVolumeImplHelper<SExtruImplementation>, public AlignedBase {
0021 
0022 private:
0023   PolygonalShell fPolyShell;
0024 
0025 public:
0026   using Kernel = SExtruImplementation;
0027 
0028   VECCORE_ATT_HOST_DEVICE
0029   UnplacedSExtruVolume(int nvertices, Precision *x, Precision *y, Precision lowerz, Precision upperz)
0030       : fPolyShell(nvertices, x, y, lowerz, upperz)
0031   {
0032     ComputeBBox();
0033   }
0034 
0035   VECCORE_ATT_HOST_DEVICE
0036   UnplacedSExtruVolume(UnplacedSExtruVolume const &other) : fPolyShell(other.fPolyShell)
0037   {
0038     ComputeBBox();
0039   }
0040 
0041   VECCORE_ATT_HOST_DEVICE
0042   PolygonalShell const &GetStruct() const { return fPolyShell; }
0043 
0044   Precision Capacity() const override { return fPolyShell.fPolygon.Area() * (fPolyShell.fUpperZ - fPolyShell.fLowerZ); }
0045 
0046   // VECCORE_ATT_HOST_DEVICE
0047   Precision SurfaceArea() const override { return fPolyShell.SurfaceArea() + 2. * fPolyShell.fPolygon.Area(); }
0048 
0049   VECCORE_ATT_HOST_DEVICE
0050   void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override { fPolyShell.Extent(aMin, aMax); }
0051 
0052   VECCORE_ATT_HOST_DEVICE
0053   virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0054   {
0055     bool valid(false);
0056     normal = SExtruImplementation::NormalKernel(fPolyShell, p, valid);
0057     return valid;
0058   }
0059 
0060   VECCORE_ATT_HOST_DEVICE
0061   virtual void Print() const override;
0062 
0063   virtual void Print(std::ostream &os) const override;
0064 
0065 #ifndef VECCORE_CUDA
0066   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0067 #endif
0068 
0069 #ifdef VECGEOM_CUDA_INTERFACE
0070   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedSExtruVolume>::SizeOf(); }
0071   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0072   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0073 #endif
0074 
0075 #ifndef VECCORE_CUDA
0076   // this is the function called from the VolumeFactory
0077   // this may be specific to the shape
0078   template <TranslationCode trans_code, RotationCode rot_code>
0079   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0080                                VPlacedVolume *const placement = NULL);
0081 
0082   VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0083                                    const TranslationCode trans_code, const RotationCode rot_code,
0084                                    VPlacedVolume *const placement) const override;
0085 #else
0086   template <TranslationCode trans_code, RotationCode rot_code>
0087   VECCORE_ATT_DEVICE
0088   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0089                                const int id, const int copy_no, const int child_id,
0090                                VPlacedVolume *const placement = NULL);
0091   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0092                                                       Transformation3D const *const transformation,
0093                                                       const TranslationCode trans_code, const RotationCode rot_code,
0094                                                       const int id, const int copy_no, const int child_id,
0095                                                       VPlacedVolume *const placement) const override;
0096 
0097 #endif
0098 };
0099 } // namespace VECGEOM_IMPL_NAMESPACE
0100 } // namespace vecgeom
0101 
0102 #endif