Celeritas  0.5.0-86+4a8eea4
Public Member Functions | List of all members
celeritas::SurfaceSimplifier Class Reference

Return a simplified, regularized version of a surface/sense pair. More...

#include <SurfaceSimplifier.hh>

Public Member Functions

 SurfaceSimplifier (Sense *s, real_type tol)
 Construct with snapping tolerance and reference to sense.
 
 SurfaceSimplifier (Sense *s)
 Construct with reference to sense that may be flipped.
 
template<Axis T>
Optional< PlaneAligned< T > > operator() (PlaneAligned< T > const &) const
 
template<Axis T>
Optional< CylCentered< T > > operator() (CylAligned< T > const &) const
 
template<Axis T>
Optional< ConeAligned< T > > operator() (ConeAligned< T > const &) const
 
Optional< PlaneAligned< Axis::x >, PlaneAligned< Axis::y >, PlaneAligned< Axis::z >, Planeoperator() (Plane const &) const
 Plane may be flipped, adjusted, or become axis-aligned.
 
Optional< SphereCenteredoperator() (Sphere const &) const
 Sphere near center can be snapped.
 
Optional< Plane, Sphere, CylAligned< Axis::x >, CylAligned< Axis::y >, CylAligned< Axis::z >, ConeAligned< Axis::x >, ConeAligned< Axis::y >, ConeAligned< Axis::z >, SimpleQuadricoperator() (SimpleQuadric const &) const
 Simple quadric with near-zero terms can be another second-order surface. More...
 
Optional< SimpleQuadric, GeneralQuadricoperator() (GeneralQuadric const &) const
 Quadric can be regularized or simplified. More...
 
template<class S >
std::variant< std::monostate > operator() (S const &) const
 Default: no simplification.
 
template<Axis T>
auto operator() (PlaneAligned< T > const &p) const -> Optional< PlaneAligned< T >>
 Plane may be snapped to origin.
 
template<Axis T>
auto operator() (CylAligned< T > const &c) const -> Optional< CylCentered< T >>
 Cylinder at origin will be simplified. More...
 
template<Axis T>
auto operator() (ConeAligned< T > const &c) const -> Optional< ConeAligned< T >>
 A cone whose origin is close to any axis will be snapped to it. More...
 

Detailed Description

Return a simplified, regularized version of a surface/sense pair.

This class takes a general surface with an associated sense and will simplify (e.g., turning a general plane into an axis-aligned one) and regularize (e.g., flipping normals so that the plane points in a positive direction) it, modifying the sense as needed.

It is meant to be used with VariantSurface to visit a surface type.

The result of each simplification type should be a std::variant of possible simplified class forms, or a std::monostate if no simplification was applied.

Todo:
Use a Tolerance object instead of a single tolerance, and compare implementations with SoftSurfaceEqual for consistency.

Member Function Documentation

◆ operator()() [1/4]

template<Axis T>
auto celeritas::SurfaceSimplifier::operator() ( ConeAligned< T > const &  c) const -> Optional<ConeAligned<T>>

A cone whose origin is close to any axis will be snapped to it.

This uses a 1-norm for simplicity.

◆ operator()() [2/4]

template<Axis T>
auto celeritas::SurfaceSimplifier::operator() ( CylAligned< T > const &  c) const -> Optional<CylCentered<T>>

Cylinder at origin will be simplified.

distance({0,0}, {u,v}) < tol
sqrt(u^2 + v^2) < tol
u^2 + v^2 < tol^2

◆ operator()() [3/4]

auto celeritas::SurfaceSimplifier::operator() ( GeneralQuadric const &  gq) const

Quadric can be regularized or simplified.

  • When no cross terms are present, it's "simple".
  • When the higher-order terms are negative, the signs will be flipped.
Note
Differently scaled GQs are not simplified at the moment due to small changes in the intercept distances that haven't yet been investigated. Normalization should be done inside the GQ at construction time. Geant4's GenericTrap twisted surfaces are normalized by the magnitude of their linear component.

◆ operator()() [4/4]

auto celeritas::SurfaceSimplifier::operator() ( SimpleQuadric const &  sq) const

Simple quadric with near-zero terms can be another second-order surface.

The sign can also be reversed as part of regularization.

Note
Differently scaled SQs are not simplified at the moment due to small changes in the intercept distances that haven't yet been investigated.

The documentation for this class was generated from the following files: