Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:20:01

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/surf/SurfaceClipper.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Assert.hh"
0011 #include "geocel/BoundingBox.hh"
0012 #include "orange/OrangeTypes.hh"
0013 
0014 #include "SurfaceFwd.hh"
0015 #include "VariantSurface.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Truncate a bounding zone using a convex quadric surface.
0022  *
0023  * Convex surfaces are planes, spheroids, cylinders, parabolic cylinders, and
0024  * paraboloids. All but the spheroids are infinite in at least one direction.
0025  *
0026  * This \em reduces the size of inner and outer bounding boxes to fit a
0027  * surface. The \c interior bounding box is modified to be entirely \em inside
0028  * the surface, and the \c exterior is modified to be entirely \em outside.
0029  * Axes that cannot be determined inside or out are left unchanged.
0030  *
0031  * Even though most quadric surfaces are infinite, their intersection with a
0032  * bounding box may be a smaller bounding box. Accounting for the current
0033  * bounding box's size when considering further truncation is *not yet
0034  * implemented*.
0035  *
0036  * Shrinking bounding boxes will accelerate "distance to in" and "distance
0037  * to out" calculations.
0038  *
0039  * TODO: move to orangeinp/detail, use BZone, combine with
0040  * NegatedSurfaceClipper.
0041  */
0042 class SurfaceClipper
0043 {
0044   public:
0045     // Construct with interior and exterior bounding boxes
0046     explicit SurfaceClipper(BBox* interior, BBox* exterior);
0047 
0048     //// OPERATION ////
0049 
0050     // Apply to a surface with a known type
0051     template<Axis T>
0052     void operator()(PlaneAligned<T> const&) const;
0053 
0054     template<Axis T>
0055     void operator()(CylCentered<T> const&) const;
0056 
0057     void operator()(SphereCentered const&) const;
0058 
0059     template<Axis T>
0060     void operator()(CylAligned<T> const&) const;
0061 
0062     void operator()(Plane const&) const;
0063 
0064     void operator()(Sphere const&) const;
0065 
0066     template<Axis T>
0067     void operator()(ConeAligned<T> const&) const;
0068 
0069     void operator()(SimpleQuadric const&) const;
0070 
0071     void operator()(GeneralQuadric const&) const;
0072 
0073     void operator()(Involute const&) const;
0074 
0075     // Apply to a surface with unknown type
0076     void operator()(VariantSurface const& surf) const;
0077 
0078   private:
0079     BBox* int_{nullptr};
0080     BBox* ext_{nullptr};
0081 };
0082 
0083 //---------------------------------------------------------------------------//
0084 }  // namespace celeritas