Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:03:18

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