Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:11

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 /// \brief Wrapper class for mesh representation of VecGeom solids.
0006 /// \file volumes/SolidMesh.h
0007 /// \author First version created by Murat Topak (CERN summer student 2019)
0008 
0009 
0010 #ifndef VECGEOM_VOLUMES_SOLIDMESH_H_
0011 #define VECGEOM_VOLUMES_SOLIDMESH_H_
0012 
0013 #include "VecGeom/base/Utils3D.h"
0014 
0015 namespace vecgeom {
0016 inline namespace VECGEOM_IMPL_NAMESPACE {
0017 
0018 class SolidMesh {
0019 private:
0020   Utils3D::Polyhedron fMesh; ///< Structure storing the mesh data
0021 
0022 public:
0023   /// Gets the mesh object
0024   Utils3D::Polyhedron const &GetMesh() { return fMesh; }
0025 
0026   /// Gets the vertices
0027   Utils3D::vector_t<Utils3D::Vec_t> const &GetVertices() { return fMesh.fVert; }
0028 
0029   /// Gets the polygons
0030   Utils3D::vector_t<Utils3D::Polygon> const &GetPolygons() { return fMesh.fPolys; }
0031 
0032   /// Sets the polygons to the given polygons
0033   void SetPolygons(const Utils3D::Polygon polys[], size_t n) { fMesh.fPolys.assign(polys, polys + n); }
0034 
0035   /// Sets the vertices to the given vertices
0036   void SetVertices(const Utils3D::Vec_t vertices[], size_t n) { fMesh.fVert.assign(vertices, vertices + n); }
0037 
0038   /// Clears the mesh and allocates sufficient space to hold given amount of vertices and polygons
0039   void ResetMesh(size_t nvert, size_t nPoly) { fMesh.Reset(nvert, nPoly); }
0040 
0041   /// Transforms the vertices and polygons
0042   void ApplyTransformation(const Transformation3D &trans);
0043 
0044   /// Transforms only the vertices
0045   void TransformVertices(const Transformation3D &trans);
0046 
0047   /// Adds polygon given by its indices only if it is not a line or a point
0048   bool AddPolygon(size_t n, Utils3D::vector_t<size_t> const &indices, bool convex)
0049   {
0050     Utils3D::Polygon poly{n, fMesh.fVert, indices, convex};
0051     if (!poly.fValid) return false;
0052 
0053     fMesh.AddPolygon(poly, false);
0054     return true;
0055   }
0056 };
0057 } // namespace VECGEOM_IMPL_NAMESPACE
0058 } // namespace vecgeom
0059 
0060 #endif