Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:26:26

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 UnplacedVolumeImplHelper<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) { ComputeBBox(); }
0037 
0038   VECCORE_ATT_HOST_DEVICE
0039   VECGEOM_FORCE_INLINE
0040   virtual ESolidType GetType() const override { return ESolidType::sextruded; }
0041 
0042   VECCORE_ATT_HOST_DEVICE
0043   PolygonalShell const &GetStruct() const { return fPolyShell; }
0044 
0045   Precision Capacity() const override { return fPolyShell.fPolygon.Area() * (fPolyShell.fUpperZ - fPolyShell.fLowerZ); }
0046 
0047   // VECCORE_ATT_HOST_DEVICE
0048   Precision SurfaceArea() const override { return fPolyShell.SurfaceArea() + 2. * fPolyShell.fPolygon.Area(); }
0049 
0050   VECCORE_ATT_HOST_DEVICE
0051   void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override { fPolyShell.Extent(aMin, aMax); }
0052 
0053   VECCORE_ATT_HOST_DEVICE
0054   virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0055   {
0056     bool valid(false);
0057     normal = SExtruImplementation::NormalKernel(fPolyShell, p, valid);
0058     return valid;
0059   }
0060 
0061   VECCORE_ATT_HOST_DEVICE
0062   virtual void Print() const override;
0063 
0064   virtual void Print(std::ostream &os) const override;
0065 
0066 #ifndef VECCORE_CUDA
0067   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0068 #endif
0069 
0070 #ifdef VECGEOM_CUDA_INTERFACE
0071   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedSExtruVolume>::SizeOf(); }
0072   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0073   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0074 #endif
0075 
0076 #ifndef VECCORE_CUDA
0077   // this is the function called from the VolumeFactory
0078   // this may be specific to the shape
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                                    VPlacedVolume *const placement) const override;
0084 #else
0085   VECCORE_ATT_DEVICE
0086   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0087                                const int id, const int copy_no, const int child_id,
0088                                VPlacedVolume *const placement = NULL);
0089   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0090                                                       Transformation3D const *const transformation, const int id,
0091                                                       const int copy_no, const int child_id,
0092                                                       VPlacedVolume *const placement) const override;
0093 
0094 #endif
0095 };
0096 } // namespace VECGEOM_IMPL_NAMESPACE
0097 } // namespace vecgeom
0098 
0099 #endif