Celeritas 0.6.0-129+develop.846910afa
Loading...
Searching...
No Matches
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.
 
Optional< SimpleQuadric, GeneralQuadricoperator() (GeneralQuadric const &) const
 Quadric can be regularized or simplified.
 
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.
 
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.
 

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? (Or use local length scale with SoftClose.) Also, 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, as changes to the scaling affect the distance to intercept and can result in terms being discarded as "nearly zero". Normalization should be done in the shape creation (IntersectRegion) so that the quadric equations directly simplify to simpler quadrics by dropping terms.

◆ 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. Normalization of the values should be performed during the IntersectRegion construction: see, e.g., Ellipsoid, Paraboloid, etc.

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