Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/VecGeom/volumes/UnplacedExtruded.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /// @file UnplacedExtruded.h
0002 /// @author Mihaela Gheata (mihaela.gheata@cern.ch)
0003 
0004 #ifndef VECGEOM_VOLUMES_UNPLACEDEXTRUDED_H_
0005 #define VECGEOM_VOLUMES_UNPLACEDEXTRUDED_H_
0006 
0007 #include "VecGeom/base/Cuda.h"
0008 #include "VecGeom/base/Global.h"
0009 #include "VecGeom/base/AlignedBase.h"
0010 #include "VecGeom/volumes/UnplacedVolume.h"
0011 #include "ExtrudedStruct.h"
0012 #include "VecGeom/volumes/kernel/ExtrudedImplementation.h"
0013 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0014 
0015 namespace vecgeom {
0016 
0017 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedExtruded;);
0018 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedExtruded);
0019 
0020 inline namespace VECGEOM_IMPL_NAMESPACE {
0021 
0022 class UnplacedExtruded : public UnplacedVolumeImplHelper<ExtrudedImplementation>, public AlignedBase {
0023 
0024   // template <typename U>
0025   // using vector_t = vecgeom::Vector<U>;
0026   template <typename U>
0027   using vector_t = std::vector<U>;
0028 
0029 private:
0030   ExtrudedStruct fXtru; ///< Structure storing the data for the tessellated solid
0031 
0032 public:
0033   /** @brief Dummy constructor */
0034   VECCORE_ATT_HOST_DEVICE
0035   UnplacedExtruded() : fXtru() { ComputeBBox(); }
0036 
0037   /** @brief Constructor providing polygone vertices and sections */
0038   VECCORE_ATT_HOST_DEVICE
0039   UnplacedExtruded(int nvertices, XtruVertex2 const *vertices, int nsections, XtruSection const *sections)
0040       : fXtru(nvertices, vertices, nsections, sections)
0041   {
0042     fGlobalConvexity = (nsections == 2) && fXtru.IsConvexPolygon();
0043     ComputeBBox();
0044   }
0045 
0046   VECCORE_ATT_HOST_DEVICE
0047   UnplacedExtruded(int nvertices, const Precision *x, const Precision *y, Precision zmin, Precision zmax)
0048       : fXtru(nvertices, x, y, zmin, zmax)
0049   {
0050     fGlobalConvexity = fXtru.IsConvexPolygon();
0051     ComputeBBox();
0052   }
0053 
0054   VECCORE_ATT_HOST_DEVICE
0055   VECGEOM_FORCE_INLINE
0056   virtual ESolidType GetType() const override { return ESolidType::extruded; }
0057 
0058   VECCORE_ATT_HOST_DEVICE
0059   ExtrudedStruct const &GetStruct() const { return fXtru; }
0060 
0061   /** @brief Initialize */
0062   VECCORE_ATT_HOST_DEVICE
0063   void Initialize(int nvertices, XtruVertex2 const *vertices, int nsections, XtruSection const *sections)
0064   {
0065     fXtru.Initialize(nvertices, vertices, nsections, sections);
0066     fGlobalConvexity = (nsections == 2) && fXtru.IsConvexPolygon();
0067   }
0068 
0069   /** @brief GetThe number of sections */
0070   VECCORE_ATT_HOST_DEVICE
0071   VECGEOM_FORCE_INLINE
0072   size_t GetNSections() const { return fXtru.GetNSections(); }
0073 
0074   /** @brief Get section i */
0075   VECCORE_ATT_HOST_DEVICE
0076   VECGEOM_FORCE_INLINE
0077   XtruSection GetSection(int i) const { return fXtru.GetSection(i); }
0078 
0079   /** @brief Get the number of vertices */
0080   VECCORE_ATT_HOST_DEVICE
0081   VECGEOM_FORCE_INLINE
0082   size_t GetNVertices() const { return fXtru.GetNVertices(); }
0083 
0084   /** @brief Get the polygone vertex i */
0085   VECCORE_ATT_HOST_DEVICE
0086   VECGEOM_FORCE_INLINE
0087   void GetVertex(int i, Precision &x, Precision &y) const { fXtru.GetVertex(i, x, y); }
0088 
0089   VECCORE_ATT_HOST_DEVICE
0090   void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override;
0091 
0092   // Computes capacity of the shape in [length^3]
0093   VECCORE_ATT_HOST_DEVICE
0094   Precision Capacity() const override;
0095 
0096   // VECCORE_ATT_HOST_DEVICE
0097   Precision SurfaceArea() const override;
0098 
0099   VECCORE_ATT_HOST_DEVICE
0100   int ChooseSurface() const;
0101 
0102   Vector3D<Precision> SamplePointOnSurface() const override;
0103 
0104   VECCORE_ATT_HOST_DEVICE
0105   bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override;
0106 
0107   VECCORE_ATT_HOST_DEVICE
0108   virtual void Print() const final;
0109 
0110   virtual void Print(std::ostream &os) const final;
0111 
0112   virtual int memory_size() const final { return sizeof(*this); }
0113   std::string GetEntityType() const { return "Extruded"; }
0114 
0115 #ifndef VECCORE_CUDA
0116   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0117 #endif
0118 
0119   VECCORE_ATT_DEVICE
0120   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0121 #ifdef VECCORE_CUDA
0122                                const int id,
0123 #endif
0124                                VPlacedVolume *const placement = NULL);
0125 #ifdef VECGEOM_CUDA_INTERFACE
0126 #ifdef HYBRID_NAVIGATOR_PORTED_TO_CUDA
0127   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedExtruded>::SizeOf(); }
0128 #else
0129   virtual size_t DeviceSizeOf() const override { return 0; }
0130 #endif
0131   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0132   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0133 #endif
0134 
0135   std::ostream &StreamInfo(std::ostream &os) const;
0136 
0137 #ifndef VECCORE_CUDA
0138 #ifdef VECGEOM_ROOT
0139   TGeoShape const *ConvertToRoot(char const *label) const;
0140 #endif
0141 
0142 #ifdef VECGEOM_GEANT4
0143   G4VSolid const *ConvertToGeant4(char const *label) const;
0144 #endif
0145 #endif
0146 
0147 private:
0148   VECCORE_ATT_DEVICE
0149   virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0150                                            Transformation3D const *const transformation,
0151 #ifdef VECCORE_CUDA
0152                                            const int id,
0153 #endif
0154                                            VPlacedVolume *const placement = NULL) const override; // final;
0155 };
0156 
0157 template <>
0158 struct Maker<UnplacedExtruded> {
0159   template <typename... ArgTypes>
0160   static UnplacedExtruded *MakeInstance(const size_t nvertices, XtruVertex2 const *vertices, const int nsections,
0161                                         XtruSection const *sections);
0162 };
0163 
0164 using GenericUnplacedExtruded = UnplacedExtruded;
0165 
0166 } // namespace VECGEOM_IMPL_NAMESPACE
0167 } // namespace vecgeom
0168 
0169 #endif // VECGEOM_VOLUMES_UNPLACEDEXTRUDED_H_