File indexing completed on 2026-06-27 08:49:44
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDPARALLELEPIPED_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDPARALLELEPIPED_H_
0011
0012 #include "VecGeom/base/Cuda.h"
0013 #include "VecGeom/base/AlignedBase.h"
0014 #include "VecGeom/base/Vector3D.h"
0015 #include "VecGeom/volumes/UnplacedVolume.h"
0016 #include "ParallelepipedStruct.h"
0017 #include "VecGeom/volumes/kernel/ParallelepipedImplementation.h"
0018 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0019
0020 namespace vecgeom {
0021
0022 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedParallelepiped;);
0023 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedParallelepiped);
0024
0025 inline namespace VECGEOM_IMPL_NAMESPACE {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class UnplacedParallelepiped : public UnplacedVolumeImplHelper<ParallelepipedImplementation>, public AlignedBase {
0036
0037 private:
0038 ParallelepipedStruct<Precision> fPara;
0039
0040 public:
0041 using Kernel = ParallelepipedImplementation;
0042
0043
0044
0045
0046
0047
0048 VECCORE_ATT_HOST_DEVICE
0049 UnplacedParallelepiped(Vector3D<Precision> const &dimensions, const Precision alpha, const Precision theta,
0050 const Precision phi)
0051 : fPara(dimensions, alpha, theta, phi)
0052 {
0053 fGlobalConvexity = true;
0054 ComputeBBox();
0055 }
0056
0057
0058
0059
0060
0061
0062
0063
0064 VECCORE_ATT_HOST_DEVICE
0065 UnplacedParallelepiped(const Precision dx, const Precision dy, const Precision dz, const Precision alpha,
0066 const Precision theta, const Precision phi)
0067 : fPara(dx, dy, dz, alpha, theta, phi)
0068 {
0069 fGlobalConvexity = true;
0070 ComputeBBox();
0071 }
0072
0073
0074 VECCORE_ATT_HOST_DEVICE
0075 UnplacedParallelepiped() : fPara(0., 0., 0., 0., 0., 0.) { fGlobalConvexity = true; }
0076
0077 VECCORE_ATT_HOST_DEVICE
0078 VECGEOM_FORCE_INLINE
0079 virtual ESolidType GetType() const override { return ESolidType::parallelepiped; }
0080
0081
0082 VECCORE_ATT_HOST_DEVICE
0083 ParallelepipedStruct<Precision> const &GetStruct() const { return fPara; }
0084
0085
0086 VECCORE_ATT_HOST_DEVICE
0087 Vector3D<Precision> const &GetDimensions() const { return fPara.fDimensions; }
0088
0089
0090 VECCORE_ATT_HOST_DEVICE
0091 Vector3D<Precision> const &GetNormal(int i) const { return fPara.fNormals[i]; }
0092
0093
0094 VECCORE_ATT_HOST_DEVICE
0095 Precision GetX() const { return fPara.fDimensions[0]; }
0096
0097
0098 VECCORE_ATT_HOST_DEVICE
0099 Precision GetY() const { return fPara.fDimensions[1]; }
0100
0101
0102 VECCORE_ATT_HOST_DEVICE
0103 Precision GetZ() const { return fPara.fDimensions[2]; }
0104
0105
0106 VECCORE_ATT_HOST_DEVICE
0107 Precision GetAlpha() const { return fPara.fAlpha; }
0108
0109
0110 VECCORE_ATT_HOST_DEVICE
0111 Precision GetTheta() const { return fPara.fTheta; }
0112
0113
0114 VECCORE_ATT_HOST_DEVICE
0115 Precision GetPhi() const { return fPara.fPhi; }
0116
0117
0118 VECCORE_ATT_HOST_DEVICE
0119 Precision GetTanAlpha() const { return fPara.fTanAlpha; }
0120
0121
0122 VECCORE_ATT_HOST_DEVICE
0123 Precision GetTanThetaSinPhi() const { return fPara.fTanThetaSinPhi; }
0124
0125
0126 VECCORE_ATT_HOST_DEVICE
0127 Precision GetTanThetaCosPhi() const { return fPara.fTanThetaCosPhi; }
0128
0129
0130 VECCORE_ATT_HOST_DEVICE
0131 Precision GetCtx() const { return fPara.fCtx; }
0132
0133
0134 VECCORE_ATT_HOST_DEVICE
0135 Precision GetCty() const { return fPara.fCty; }
0136
0137
0138
0139 VECCORE_ATT_HOST_DEVICE
0140 void SetDimensions(Vector3D<Precision> const &dimensions) { fPara.fDimensions = dimensions; }
0141
0142
0143
0144
0145
0146 VECCORE_ATT_HOST_DEVICE
0147 void SetDimensions(const Precision dx, const Precision dy, const Precision dz) { fPara.fDimensions.Set(dx, dy, dz); }
0148
0149
0150
0151 VECCORE_ATT_HOST_DEVICE
0152 void SetAlpha(const Precision alpha) { fPara.SetAlpha(alpha); }
0153
0154
0155
0156 VECCORE_ATT_HOST_DEVICE
0157 void SetTheta(const Precision theta) { fPara.SetTheta(theta); }
0158
0159
0160
0161 VECCORE_ATT_HOST_DEVICE
0162 void SetPhi(const Precision phi) { fPara.SetPhi(phi); }
0163
0164
0165
0166
0167 VECCORE_ATT_HOST_DEVICE
0168 void SetThetaAndPhi(const Precision theta, const Precision phi) { fPara.SetThetaAndPhi(theta, phi); }
0169
0170 virtual int MemorySize() const final { return sizeof(*this); }
0171
0172 VECCORE_ATT_HOST_DEVICE
0173 virtual void Print() const final;
0174
0175 virtual void Print(std::ostream &os) const final;
0176
0177 #ifndef VECCORE_CUDA
0178 virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0179 #endif
0180 VECCORE_ATT_HOST_DEVICE
0181 void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0182
0183
0184 Precision volume() const { return 8.0 * fPara.fDimensions[0] * fPara.fDimensions[1] * fPara.fDimensions[2]; }
0185
0186 Precision Capacity() const override { return volume(); }
0187
0188 Vector3D<Precision> SamplePointOnSurface() const override;
0189
0190 Precision SurfaceArea() const override { return 2. * (fPara.fAreas[0] + fPara.fAreas[1] + fPara.fAreas[2]); }
0191
0192 VECCORE_ATT_HOST_DEVICE
0193 virtual bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override
0194 {
0195 bool valid;
0196 normal = ParallelepipedImplementation::NormalKernel(fPara, point, valid);
0197 return valid;
0198 }
0199
0200
0201
0202 std::string GetEntityType() const { return "parallelepiped"; }
0203
0204
0205 #ifdef VECCORE_CUDA
0206 VECCORE_ATT_DEVICE
0207 #endif
0208 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0209 #ifdef VECCORE_CUDA
0210 const int id, const int copy_no, const int child_id,
0211 #endif
0212 VPlacedVolume *const placement = NULL);
0213
0214 #ifdef VECGEOM_CUDA_INTERFACE
0215 virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedParallelepiped>::SizeOf(); }
0216 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0217 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0218 #endif
0219
0220 #ifdef VECCORE_CUDA
0221 VECCORE_ATT_DEVICE
0222 #endif
0223 virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0224 Transformation3D const *const transformation,
0225 #ifdef VECCORE_CUDA
0226 const int id, const int copy_no, const int child_id,
0227 #endif
0228 VPlacedVolume *const placement = NULL) const final;
0229 };
0230 }
0231 }
0232
0233 #endif