File indexing completed on 2025-01-30 10:26:27
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDTESSELLATED_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDTESSELLATED_H_
0011
0012 #include "VecGeom/base/Cuda.h"
0013 #include "VecGeom/base/Global.h"
0014 #include "VecGeom/base/AlignedBase.h"
0015 #include "VecGeom/volumes/UnplacedVolume.h"
0016 #include "TessellatedStruct.h"
0017 #include "VecGeom/volumes/kernel/TessellatedImplementation.h"
0018 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0019
0020 namespace vecgeom {
0021
0022 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedTessellated;);
0023 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedTessellated);
0024
0025 inline namespace VECGEOM_IMPL_NAMESPACE {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 class UnplacedTessellated : public LoopUnplacedVolumeImplHelper<TessellatedImplementation>, public AlignedBase {
0039 protected:
0040 mutable TessellatedStruct<3, Precision> fTessellated;
0041
0042 public:
0043
0044 VECCORE_ATT_HOST_DEVICE
0045 UnplacedTessellated() : fTessellated()
0046 {
0047 fGlobalConvexity = false;
0048 ComputeBBox();
0049 }
0050
0051
0052
0053 VECCORE_ATT_HOST_DEVICE
0054 TessellatedStruct<3, Precision> const &GetStruct() const { return fTessellated; }
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 VECCORE_ATT_HOST_DEVICE
0065 bool AddTriangularFacet(Vector3D<Precision> const &vt0, Vector3D<Precision> const &vt1,
0066 Vector3D<Precision> const &vt2, bool absolute = true)
0067 {
0068 bool result = fTessellated.AddTriangularFacet(vt0, vt1, vt2, absolute);
0069 ComputeBBox();
0070 return result;
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 VECCORE_ATT_HOST_DEVICE
0084 bool AddQuadrilateralFacet(Vector3D<Precision> const &vt0, Vector3D<Precision> const &vt1,
0085 Vector3D<Precision> const &vt2, Vector3D<Precision> const &vt3, bool absolute = true)
0086 {
0087 bool result = fTessellated.AddQuadrilateralFacet(vt0, vt1, vt2, vt3, absolute);
0088 ComputeBBox();
0089 return result;
0090 }
0091
0092
0093 VECGEOM_FORCE_INLINE
0094 VECCORE_ATT_HOST_DEVICE
0095 size_t GetNFacets() const { return fTessellated.fFacets.size(); }
0096
0097
0098
0099
0100
0101 VECGEOM_FORCE_INLINE
0102 VECCORE_ATT_HOST_DEVICE
0103 TriangleFacet<Precision> *GetFacet(int ifacet) const { return fTessellated.fFacets[ifacet]; }
0104
0105
0106 VECCORE_ATT_HOST_DEVICE
0107 void Close() { fTessellated.Close(); }
0108
0109
0110 VECCORE_ATT_HOST_DEVICE
0111 bool IsClosed() const { return fTessellated.fSolidClosed; }
0112
0113 virtual int memory_size() const { return sizeof(*this); }
0114
0115 VECCORE_ATT_HOST_DEVICE
0116 void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override { fTessellated.Extent(aMin, aMax); }
0117
0118
0119
0120 Precision Capacity() const override;
0121
0122
0123 Precision SurfaceArea() const override;
0124
0125
0126
0127 VECCORE_ATT_HOST_DEVICE
0128 int ChooseSurface() const;
0129
0130 Vector3D<Precision> SamplePointOnSurface() const override;
0131
0132 VECCORE_ATT_HOST_DEVICE
0133 bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override;
0134
0135 VECCORE_ATT_HOST_DEVICE
0136 virtual void Print() const override;
0137
0138
0139
0140 std::string GetEntityType() const { return "Tessellated"; }
0141
0142 template <TranslationCode transCodeT, RotationCode rotCodeT>
0143 VECCORE_ATT_DEVICE
0144 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0145 #ifdef VECCORE_CUDA
0146 const int id,
0147 #endif
0148 VPlacedVolume *const placement = NULL);
0149
0150 #ifdef VECGEOM_CUDA_INTERFACE
0151 #ifdef HYBRID_NAVIGATOR_PORTED_TO_CUDA
0152 virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedTessellated>::SizeOf(); }
0153 #else
0154 virtual size_t DeviceSizeOf() const override { return 0; }
0155 #endif
0156 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0157 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0158 #endif
0159
0160
0161 std::ostream &StreamInfo(std::ostream &os) const;
0162
0163 virtual void Print(std::ostream &os) const override;
0164
0165 private:
0166 VECCORE_ATT_DEVICE
0167 virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0168 Transformation3D const *const transformation,
0169 const TranslationCode trans_code, const RotationCode rot_code,
0170 #ifdef VECCORE_CUDA
0171 const int id,
0172 #endif
0173 VPlacedVolume *const placement = NULL) const override;
0174 };
0175 }
0176 }
0177
0178 #endif