File indexing completed on 2026-04-17 08:35:48
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDTET_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDTET_H_
0011
0012 #include "VecGeom/base/Cuda.h"
0013 #include "VecGeom/base/Global.h"
0014 #include "VecGeom/base/AlignedBase.h"
0015 #include "VecGeom/base/Vector3D.h"
0016 #include "VecGeom/volumes/UnplacedVolume.h"
0017 #include "VecGeom/volumes/TetStruct.h" // the pure Tet struct
0018 #include "VecGeom/volumes/kernel/TetImplementation.h"
0019 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0020
0021 namespace vecgeom {
0022
0023 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedTet;);
0024 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedTet);
0025
0026 inline namespace VECGEOM_IMPL_NAMESPACE {
0027
0028
0029
0030
0031
0032 class UnplacedTet : public UnplacedVolumeImplHelper<TetImplementation>, public AlignedBase {
0033
0034 private:
0035 TetStruct<Precision> fTet;
0036
0037 public:
0038
0039 VECCORE_ATT_HOST_DEVICE
0040 UnplacedTet();
0041
0042
0043
0044
0045
0046
0047 VECCORE_ATT_HOST_DEVICE
0048 UnplacedTet(const Vector3D<Precision> &p0, const Vector3D<Precision> &p1, const Vector3D<Precision> &p2,
0049 const Vector3D<Precision> &p3);
0050
0051
0052
0053
0054
0055
0056 VECCORE_ATT_HOST_DEVICE
0057 UnplacedTet(const Precision p0[], const Precision p1[], const Precision p2[], const Precision p3[])
0058 : fTet(p0, p1, p2, p3)
0059 {
0060 fGlobalConvexity = true;
0061 }
0062
0063 VECCORE_ATT_HOST_DEVICE
0064 VECGEOM_FORCE_INLINE
0065 virtual ESolidType GetType() const override { return ESolidType::tetrahedron; }
0066
0067
0068 VECCORE_ATT_HOST_DEVICE
0069 TetStruct<Precision> const &GetStruct() const { return fTet; }
0070
0071
0072
0073
0074
0075
0076 VECCORE_ATT_HOST_DEVICE
0077 VECGEOM_FORCE_INLINE
0078 void GetVertices(Vector3D<Precision> &p0, Vector3D<Precision> &p1, Vector3D<Precision> &p2,
0079 Vector3D<Precision> &p3) const
0080 {
0081 p0 = fTet.fVertex[0];
0082 p1 = fTet.fVertex[1];
0083 p2 = fTet.fVertex[2];
0084 p3 = fTet.fVertex[3];
0085 }
0086
0087 VECCORE_ATT_HOST_DEVICE
0088 void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0089
0090 Precision Capacity() const override { return fTet.fCubicVolume; }
0091
0092 Precision SurfaceArea() const override { return fTet.fSurfaceArea; }
0093
0094 Vector3D<Precision> SamplePointOnSurface() const override;
0095
0096 VECCORE_ATT_HOST_DEVICE
0097 virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0098 {
0099 bool valid;
0100 normal = TetImplementation::NormalKernel(fTet, p, valid);
0101 return valid;
0102 }
0103
0104
0105
0106 std::string GetEntityType() const;
0107
0108 VECCORE_ATT_HOST_DEVICE
0109 void GetParametersList(int aNumber, Precision *aArray) const;
0110
0111 std::ostream &StreamInfo(std::ostream &os) const;
0112
0113 public:
0114 virtual int MemorySize() const final { return sizeof(*this); }
0115
0116 VECCORE_ATT_HOST_DEVICE
0117 virtual void Print() const override;
0118
0119 virtual void Print(std::ostream &os) const override;
0120
0121 #ifndef VECCORE_CUDA
0122 virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0123 #endif
0124
0125 #ifdef VECGEOM_CUDA_INTERFACE
0126 virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedTet>::SizeOf(); }
0127 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0128 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0129 #endif
0130
0131
0132 #ifndef VECCORE_CUDA
0133 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0134 VPlacedVolume *const placement = NULL);
0135
0136 VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0137 VPlacedVolume *const placement) const override;
0138 #else
0139 VECCORE_ATT_DEVICE
0140 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0141 const int id, const int copy_no, const int child_id,
0142 VPlacedVolume *const placement = NULL);
0143 VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0144 Transformation3D const *const transformation, const int id,
0145 const int copy_no, const int child_id,
0146 VPlacedVolume *const placement) const override;
0147
0148 #endif
0149 };
0150 }
0151 }
0152
0153 #endif