File indexing completed on 2025-01-18 10:14:14
0001
0002
0003
0004 #ifndef VECGEOM_VOLUMES_UNPLACEDEXTRUDED_H_
0005 #define VECGEOM_VOLUMES_UNPLACEDEXTRUDED_H_
0006
0007 #include "VecGeom/base/Cuda.h"
0008 #include "VecGeom/base/Global.h"
0009 #include "VecGeom/base/AlignedBase.h"
0010 #include "VecGeom/volumes/UnplacedVolume.h"
0011 #include "ExtrudedStruct.h"
0012 #include "VecGeom/volumes/kernel/ExtrudedImplementation.h"
0013 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0014
0015 namespace vecgeom {
0016
0017 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedExtruded;);
0018 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedExtruded);
0019
0020 inline namespace VECGEOM_IMPL_NAMESPACE {
0021
0022 class UnplacedExtruded : public LoopUnplacedVolumeImplHelper<ExtrudedImplementation>, public AlignedBase {
0023
0024
0025
0026 template <typename U>
0027 using vector_t = std::vector<U>;
0028
0029 private:
0030 ExtrudedStruct fXtru;
0031
0032 public:
0033
0034 VECCORE_ATT_HOST_DEVICE
0035 UnplacedExtruded() : fXtru()
0036 {
0037 ComputeBBox();
0038 }
0039
0040
0041 VECCORE_ATT_HOST_DEVICE
0042 UnplacedExtruded(int nvertices, XtruVertex2 const *vertices, int nsections, XtruSection const *sections)
0043 : fXtru(nvertices, vertices, nsections, sections)
0044 {
0045 fGlobalConvexity = (nsections == 2) && fXtru.IsConvexPolygon();
0046 ComputeBBox();
0047 }
0048
0049 VECCORE_ATT_HOST_DEVICE
0050 UnplacedExtruded(int nvertices, const Precision *x, const Precision *y, Precision zmin, Precision zmax)
0051 : fXtru(nvertices, x, y, zmin, zmax)
0052 {
0053 fGlobalConvexity = fXtru.IsConvexPolygon();
0054 ComputeBBox();
0055 }
0056
0057 VECCORE_ATT_HOST_DEVICE
0058 ExtrudedStruct const &GetStruct() const { return fXtru; }
0059
0060
0061 VECCORE_ATT_HOST_DEVICE
0062 void Initialize(int nvertices, XtruVertex2 const *vertices, int nsections, XtruSection const *sections)
0063 {
0064 fXtru.Initialize(nvertices, vertices, nsections, sections);
0065 fGlobalConvexity = (nsections == 2) && fXtru.IsConvexPolygon();
0066 }
0067
0068
0069 VECCORE_ATT_HOST_DEVICE
0070 VECGEOM_FORCE_INLINE
0071 size_t GetNSections() const { return fXtru.GetNSections(); }
0072
0073
0074 VECCORE_ATT_HOST_DEVICE
0075 VECGEOM_FORCE_INLINE
0076 XtruSection GetSection(int i) const { return fXtru.GetSection(i); }
0077
0078
0079 VECCORE_ATT_HOST_DEVICE
0080 VECGEOM_FORCE_INLINE
0081 size_t GetNVertices() const { return fXtru.GetNVertices(); }
0082
0083
0084 VECCORE_ATT_HOST_DEVICE
0085 VECGEOM_FORCE_INLINE
0086 void GetVertex(int i, Precision &x, Precision &y) const { fXtru.GetVertex(i, x, y); }
0087
0088 VECCORE_ATT_HOST_DEVICE
0089 void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override;
0090
0091
0092 VECCORE_ATT_HOST_DEVICE
0093 Precision Capacity() const override;
0094
0095
0096 Precision SurfaceArea() const override;
0097
0098 VECCORE_ATT_HOST_DEVICE
0099 int ChooseSurface() const;
0100
0101 Vector3D<Precision> SamplePointOnSurface() const override;
0102
0103 VECCORE_ATT_HOST_DEVICE
0104 bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override;
0105
0106 VECCORE_ATT_HOST_DEVICE
0107 virtual void Print() const final;
0108
0109 virtual void Print(std::ostream &os) const final;
0110
0111 virtual int memory_size() const final { return sizeof(*this); }
0112 std::string GetEntityType() const { return "Extruded"; }
0113
0114 #ifndef VECCORE_CUDA
0115 virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0116 #endif
0117
0118 template <TranslationCode transCodeT, RotationCode rotCodeT>
0119 VECCORE_ATT_DEVICE
0120 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0121 #ifdef VECCORE_CUDA
0122 const int id,
0123 #endif
0124 VPlacedVolume *const placement = NULL);
0125 #ifdef VECGEOM_CUDA_INTERFACE
0126 #ifdef HYBRID_NAVIGATOR_PORTED_TO_CUDA
0127 virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedExtruded>::SizeOf(); }
0128 #else
0129 virtual size_t DeviceSizeOf() const override { return 0; }
0130 #endif
0131 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0132 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0133 #endif
0134
0135 std::ostream &StreamInfo(std::ostream &os) const;
0136
0137 #ifndef VECCORE_CUDA
0138 #ifdef VECGEOM_ROOT
0139 TGeoShape const *ConvertToRoot(char const *label) const;
0140 #endif
0141
0142 #ifdef VECGEOM_GEANT4
0143 G4VSolid const *ConvertToGeant4(char const *label) const;
0144 #endif
0145 #endif
0146
0147 private:
0148 VECCORE_ATT_DEVICE
0149 virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0150 Transformation3D const *const transformation,
0151 const TranslationCode trans_code, const RotationCode rot_code,
0152 #ifdef VECCORE_CUDA
0153 const int id,
0154 #endif
0155 VPlacedVolume *const placement = NULL) const override;
0156 };
0157
0158 template <>
0159 struct Maker<UnplacedExtruded> {
0160 template <typename... ArgTypes>
0161 static UnplacedExtruded *MakeInstance(const size_t nvertices, XtruVertex2 const *vertices, const int nsections,
0162 XtruSection const *sections);
0163 };
0164
0165 using GenericUnplacedExtruded = UnplacedExtruded;
0166
0167 }
0168 }
0169
0170 #endif