Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:17:10

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file orange/g4org/SolidConverter.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <unordered_map>
0012 
0013 #include "corecel/Types.hh"
0014 #include "corecel/cont/Array.hh"
0015 
0016 class G4VSolid;
0017 class G4BooleanSolid;
0018 
0019 namespace celeritas
0020 {
0021 namespace orangeinp
0022 {
0023 class ObjectInterface;
0024 }
0025 
0026 namespace g4org
0027 {
0028 //---------------------------------------------------------------------------//
0029 class Scaler;
0030 class Transformer;
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Convert a Geant4 solid to an ORANGE object.
0035  */
0036 class SolidConverter
0037 {
0038   public:
0039     //!@{
0040     //! \name Type aliases
0041     using arg_type = G4VSolid const&;
0042     using result_type = std::shared_ptr<orangeinp::ObjectInterface const>;
0043     //!@}
0044 
0045   public:
0046     // Construct with functors for applying scales and transformations
0047     inline SolidConverter(Scaler const& scaler, Transformer const& transformer);
0048 
0049     // Return a CSG object
0050     result_type operator()(arg_type);
0051 
0052     // Return a sphere with equivalent capacity
0053     result_type to_sphere(arg_type) const;
0054 
0055   private:
0056     //// DATA ////
0057 
0058     Scaler const& scale_;
0059     Transformer const& transform_;
0060     std::unordered_map<G4VSolid const*, result_type> cache_;
0061 
0062     //// HELPER FUNCTIONS ////
0063 
0064     // Convert a solid that's not in the cache
0065     result_type convert_impl(arg_type);
0066 
0067     // Conversion functions
0068     result_type box(arg_type);
0069     result_type cons(arg_type);
0070     result_type cuttubs(arg_type);
0071     result_type displaced(arg_type);
0072     result_type ellipsoid(arg_type);
0073     result_type ellipticalcone(arg_type);
0074     result_type ellipticaltube(arg_type);
0075     result_type extrudedsolid(arg_type);
0076     result_type genericpolycone(arg_type);
0077     result_type generictrap(arg_type);
0078     result_type hype(arg_type);
0079     result_type intersectionsolid(arg_type);
0080     result_type orb(arg_type);
0081     result_type para(arg_type);
0082     result_type paraboloid(arg_type);
0083     result_type polycone(arg_type);
0084     result_type polyhedra(arg_type);
0085     result_type reflectedsolid(arg_type);
0086     result_type sphere(arg_type);
0087     result_type subtractionsolid(arg_type);
0088     result_type tessellatedsolid(arg_type);
0089     result_type tet(arg_type);
0090     result_type torus(arg_type);
0091     result_type trap(arg_type);
0092     result_type trd(arg_type);
0093     result_type tubs(arg_type);
0094     result_type unionsolid(arg_type);
0095 
0096     // Construct bool daughters
0097     Array<result_type, 2> make_bool_solids(G4BooleanSolid const&);
0098     // Calculate solid capacity in native celeritas units
0099     double calc_capacity(G4VSolid const&) const;
0100 };
0101 
0102 //---------------------------------------------------------------------------//
0103 /*!
0104  * Construct with functors for applying scales and transformations.
0105  */
0106 SolidConverter::SolidConverter(Scaler const& convert_scale,
0107                                Transformer const& convert_transform)
0108     : scale_(convert_scale), transform_(convert_transform)
0109 {
0110 }
0111 
0112 //---------------------------------------------------------------------------//
0113 }  // namespace g4org
0114 }  // namespace celeritas