Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/orange/g4org/SolidConverter.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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