Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:35:48

0001 // This file is part of VecGeom and is distributed under the
0002 // conditions in the file LICENSE.txt in the top directory.
0003 // For the full list of authors see CONTRIBUTORS.txt and `git log`.
0004 
0005 /// Declaration of the unplaced tetrahedron shape
0006 /// @file volumes/UnplaceTet.h
0007 /// @author Raman Sehgal, Evgueni Tcherniaev
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 /// Class for tetrahedron shape primitive
0029 ///
0030 /// Tetrahedron, also known as a triangular pyramid, is a polyhedron composed
0031 /// by four triangular faces. It is completely defined by its four vertices.
0032 class UnplacedTet : public UnplacedVolumeImplHelper<TetImplementation>, public AlignedBase {
0033 
0034 private:
0035   TetStruct<Precision> fTet; ///< The structure with the tetrahedron data members
0036 
0037 public:
0038   /// Default constructor
0039   VECCORE_ATT_HOST_DEVICE
0040   UnplacedTet();
0041 
0042   /// Constructor from four points
0043   /// @param [in] p0 Point given as 3D vector
0044   /// @param [in] p1 Point given as 3D vector
0045   /// @param [in] p2 Point given as 3D vector
0046   /// @param [in] p3 Point given as 3D vector
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   /// Constructor from four points
0052   /// @param [in] p0 Point given as array
0053   /// @param [in] p1 Point given as array
0054   /// @param [in] p2 Point given as array
0055   /// @param [in] p3 Point given as array
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   /// Getter for the structure storing the tetrahedron data
0068   VECCORE_ATT_HOST_DEVICE
0069   TetStruct<Precision> const &GetStruct() const { return fTet; }
0070 
0071   /// Getter for the tetrahedron vertices
0072   /// @param [out] p0 Point given as 3D vector
0073   /// @param [out] p1 Point given as 3D vector
0074   /// @param [out] p2 Point given as 3D vector
0075   /// @param [out] p3 Point given as 3D vector
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   /// Get the solid type as string
0105   /// @return Name of the solid type
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   /// Templated factory for creating a placed volume
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 } // namespace VECGEOM_IMPL_NAMESPACE
0151 } // namespace vecgeom
0152 
0153 #endif