File indexing completed on 2025-01-18 10:14:15
0001
0002
0003
0004
0005 #ifndef VECGEOM_VOLUMES_UNPLACEDGENTRAP_H_
0006 #define VECGEOM_VOLUMES_UNPLACEDGENTRAP_H_
0007
0008 #include "VecGeom/base/Cuda.h"
0009 #include "VecGeom/base/Global.h"
0010 #include "VecGeom/base/AlignedBase.h"
0011 #include "VecGeom/volumes/GenTrapStruct.h"
0012 #include "VecGeom/volumes/UnplacedVolume.h"
0013 #include "VecGeom/volumes/SecondOrderSurfaceShell.h"
0014 #include "VecGeom/volumes/kernel/GenTrapImplementation.h"
0015 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0016
0017 namespace vecgeom {
0018
0019 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedGenTrap;);
0020 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedGenTrap);
0021
0022 inline namespace VECGEOM_IMPL_NAMESPACE {
0023
0024
0025
0026
0027
0028 class UnplacedGenTrap : public SIMDUnplacedVolumeImplHelper<GenTrapImplementation>, public AlignedBase {
0029
0030 public:
0031 using Vertex_t = Vector3D<Precision>;
0032
0033 GenTrapStruct<Precision> fGenTrap;
0034
0035 public:
0036
0037 VECCORE_ATT_HOST_DEVICE
0038 UnplacedGenTrap() : fGenTrap() {}
0039
0040
0041
0042
0043
0044
0045 VECCORE_ATT_HOST_DEVICE
0046 UnplacedGenTrap(const Precision verticesx[], const Precision verticesy[], Precision halfzheight)
0047 : fGenTrap(verticesx, verticesy, halfzheight)
0048 {
0049 fGlobalConvexity = !fGenTrap.fIsTwisted;
0050 ComputeBBox();
0051 }
0052
0053
0054 VECCORE_ATT_HOST_DEVICE
0055 virtual ~UnplacedGenTrap() {}
0056
0057 VECCORE_ATT_HOST_DEVICE
0058 bool Initialize(const Precision verticesx[], const Precision verticesy[], Precision halfzheight)
0059 {
0060 return fGenTrap.Initialize(verticesx, verticesy, halfzheight);
0061 }
0062
0063
0064 VECCORE_ATT_HOST_DEVICE
0065 GenTrapStruct<Precision> const &GetStruct() const { return fGenTrap; }
0066
0067
0068 VECCORE_ATT_HOST_DEVICE
0069 VECGEOM_FORCE_INLINE
0070 SecondOrderSurfaceShell<4> const &GetShell() const { return (fGenTrap.fSurfaceShell); }
0071
0072
0073 VECCORE_ATT_HOST_DEVICE
0074 VECGEOM_FORCE_INLINE
0075 Precision GetDZ() const { return (fGenTrap.fDz); }
0076
0077
0078 VECCORE_ATT_HOST_DEVICE
0079 VECGEOM_FORCE_INLINE
0080 void SetDZ(Precision dz) { fGenTrap.fDz = dz; }
0081
0082
0083 VECCORE_ATT_HOST_DEVICE
0084 VECGEOM_FORCE_INLINE
0085 Precision GetTwist(int i) const { return (fGenTrap.fTwist[i]); }
0086
0087
0088 VECCORE_ATT_HOST_DEVICE
0089 VECGEOM_FORCE_INLINE
0090 Vertex_t const &GetVertex(int i) const { return fGenTrap.fVertices[i]; }
0091
0092
0093 VECCORE_ATT_HOST_DEVICE
0094 VECGEOM_FORCE_INLINE
0095 const Precision *GetVerticesX() const { return fGenTrap.fVerticesX; }
0096
0097
0098 VECCORE_ATT_HOST_DEVICE
0099 VECGEOM_FORCE_INLINE
0100 const Precision *GetVerticesY() const { return fGenTrap.fVerticesY; }
0101
0102
0103 VECCORE_ATT_HOST_DEVICE
0104 VECGEOM_FORCE_INLINE
0105 const Vertex_t *GetVertices() const { return fGenTrap.fVertices; }
0106
0107
0108 VECCORE_ATT_HOST_DEVICE
0109 bool ComputeIsTwisted() { return fGenTrap.ComputeIsTwisted(); }
0110
0111
0112 VECCORE_ATT_HOST_DEVICE
0113 bool ComputeIsConvexQuadrilaterals() { return fGenTrap.ComputeIsConvexQuadrilaterals(); }
0114
0115
0116 VECCORE_ATT_HOST_DEVICE
0117 VECGEOM_FORCE_INLINE
0118 bool IsPlanar() const { return (!fGenTrap.fIsTwisted); }
0119
0120
0121 VECCORE_ATT_HOST_DEVICE
0122 VECGEOM_FORCE_INLINE
0123 bool IsDegenerated(int i) const { return (fGenTrap.fDegenerated[i]); }
0124
0125
0126
0127 VECCORE_ATT_HOST_DEVICE
0128 bool SegmentsCrossing(Vertex_t pa, Vertex_t pb, Vertex_t pc, Vertex_t pd) const
0129 {
0130 return fGenTrap.SegmentsCrossing(pa, pb, pc, pd);
0131 }
0132
0133
0134 VECCORE_ATT_HOST_DEVICE
0135 void ComputeBoundingBox() { fGenTrap.ComputeBoundingBox(); }
0136
0137
0138 virtual int MemorySize() const final { return sizeof(*this); }
0139
0140
0141 VECCORE_ATT_HOST_DEVICE
0142 virtual void Print() const final { fGenTrap.Print(); }
0143
0144
0145 virtual void Print(std::ostream &os) const final;
0146
0147 #ifndef VECCORE_CUDA
0148 virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0149 #endif
0150
0151 #ifdef VECGEOM_CUDA_INTERFACE
0152
0153 size_t DeviceSizeOf() const final { return DevicePtr<cuda::UnplacedGenTrap>::SizeOf(); }
0154
0155 DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const final;
0156
0157 DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const final;
0158 #endif
0159
0160
0161 Precision Capacity() const override { return volume(); }
0162
0163
0164 Precision volume() const;
0165
0166
0167 Precision SurfaceArea() const override;
0168
0169
0170 VECCORE_ATT_HOST_DEVICE
0171 bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override;
0172
0173
0174 VECCORE_ATT_HOST_DEVICE
0175 void Extent(Vertex_t &amin, Vertex_t &amax) const override { return fGenTrap.Extent(amin, amax); }
0176
0177
0178 Vertex_t SamplePointOnSurface() const override;
0179
0180
0181 std::string GetEntityType() const { return "GenTrap"; }
0182
0183
0184 template <TranslationCode transCodeT, RotationCode rotCodeT>
0185 VECCORE_ATT_DEVICE
0186 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0187 #ifdef VECCORE_CUDA
0188 const int id, const int copy_no, const int child_id,
0189 #endif
0190 VPlacedVolume *const placement = NULL);
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 std::ostream &StreamInfo(std::ostream &os) const;
0205
0206 private:
0207
0208 VECCORE_ATT_DEVICE
0209 virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0210 Transformation3D const *const transformation,
0211 const TranslationCode trans_code, const RotationCode rot_code,
0212 #ifdef VECCORE_CUDA
0213 const int id, const int copy_no, const int child_id,
0214 #endif
0215 VPlacedVolume *const placement = NULL) const final;
0216
0217 };
0218 }
0219 }
0220
0221 #endif