Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:06:13

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/orangeinp/detail/SurfaceHashPoint.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <cmath>
0010 
0011 #include "orange/surf/VariantSurface.hh"
0012 
0013 namespace celeritas
0014 {
0015 namespace orangeinp
0016 {
0017 namespace detail
0018 {
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Construct a point to hash for deduplicating surfaces.
0022  *
0023  * Surfaces that *can* be soft equal *must* result in a point that is less than
0024  * or equal to epsilon.
0025  *
0026  * \todo We could potentially reduce the number of collisions by turning this
0027  * into a two- or three-dimensional point that's then hashed in an infinite
0028  * grid.
0029  */
0030 struct SurfaceHashPoint
0031 {
0032     template<Axis T>
0033     real_type operator()(PlaneAligned<T> const& s) const
0034     {
0035         return s.position();
0036     }
0037 
0038     template<Axis T>
0039     real_type operator()(CylCentered<T> const& s) const
0040     {
0041         return std::sqrt(s.radius_sq());
0042     }
0043 
0044     real_type operator()(SphereCentered const& s) const
0045     {
0046         return std::sqrt(s.radius_sq());
0047     }
0048 
0049     template<Axis T>
0050     real_type operator()(CylAligned<T> const& s) const
0051     {
0052         return std::sqrt(s.radius_sq());
0053     }
0054 
0055     real_type operator()(Plane const& p) const { return p.displacement(); }
0056 
0057     real_type operator()(Sphere const& s) const
0058     {
0059         return std::sqrt(s.radius_sq());
0060     }
0061 
0062     template<Axis T>
0063     real_type operator()(ConeAligned<T> const& s) const
0064     {
0065         return norm(s.origin());
0066     }
0067 
0068     real_type operator()(Involute const& s) const
0069     {
0070         return s.displacement_angle();
0071     }
0072 
0073     real_type operator()(SimpleQuadric const& s) const
0074     {
0075         return std::sqrt(s.zeroth());
0076     }
0077 
0078     real_type operator()(GeneralQuadric const& s) const
0079     {
0080         return std::sqrt(s.zeroth());
0081     }
0082 };
0083 
0084 //---------------------------------------------------------------------------//
0085 }  // namespace detail
0086 }  // namespace orangeinp
0087 }  // namespace celeritas