EBGeometry  1.0
Classes | Functions | Variables
EBGeometry_CSG.hpp File Reference

Declaration of a CSG operations for implicit functions. More...

#include <vector>
#include <type_traits>
#include "EBGeometry_ImplicitFunction.hpp"
#include "EBGeometry_NamespaceHeader.hpp"
#include "EBGeometry_NamespaceFooter.hpp"
#include "EBGeometry_CSGImplem.hpp"
Include dependency graph for EBGeometry_CSG.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  UnionIF< T >
 CSG union. Computes the minimum value of all input primitives. More...
 
class  SmoothUnionIF< T >
 Smooth CSG union. Computes the minimum value of all input primitives. More...
 
class  FastUnionIF< T, P, BV, K >
 Implicit function union using BVHs. More...
 
class  FastSmoothUnionIF< T, P, BV, K >
 Implicit function smoothed union using BVHs. More...
 
class  IntersectionIF< T >
 CSG intersection. Computes the maximum value of all input primitives. More...
 
class  SmoothIntersectionIF< T >
 Smooth intersection. More...
 
class  DifferenceIF< T >
 CSG difference between two implicit functions. More...
 
class  SmoothDifferenceIF< T >
 CSG difference between two implicit functions. More...
 
class  FiniteRepetitionIF< T >
 Class which creates a periodic repetition of an implicit function. More...
 

Functions

template<class T , class P = ImplicitFunction<T>>
std::shared_ptr< ImplicitFunction< T > > Union (const std::vector< std::shared_ptr< P >> &a_implicitFunctions) noexcept
 Convenience function for taking the union of a bunch of a implicit functions. More...
 
template<class T , class P1 , class P2 >
std::shared_ptr< ImplicitFunction< T > > Union (const std::shared_ptr< P1 > &a_implicitFunctionA, const std::shared_ptr< P2 > &a_implicitFunctionB) noexcept
 Convenience function for taking the union of two implicit functions. More...
 
template<class T , class P = ImplicitFunction<T>>
std::shared_ptr< ImplicitFunction< T > > SmoothUnion (const std::vector< std::shared_ptr< P >> &a_implicitFunctions, const T a_smooth) noexcept
 Convenience function for taking the union of a bunch of a implicit functions. More...
 
template<class T , class P1 , class P2 >
std::shared_ptr< ImplicitFunction< T > > SmoothUnion (const std::shared_ptr< P1 > &a_implicitFunctionA, const std::shared_ptr< P2 > &a_implicitFunctionB, const T a_smooth) noexcept
 Convenience function for taking the union of two implicit functions. More...
 
template<class T , class P , class BV , size_t K>
std::shared_ptr< ImplicitFunction< T > > FastUnion (const std::vector< std::shared_ptr< P >> &a_implicitFunctions, const std::vector< BV > &a_boundingVolumes) noexcept
 Convenience function for taking the BVH-accelerated union of a bunch of a implicit functions. More...
 
template<class T , class P , class BV , size_t K>
std::shared_ptr< ImplicitFunction< T > > FastSmoothUnion (const std::vector< std::shared_ptr< P >> &a_implicitFunctions, const std::vector< BV > &a_boundingVolumes, const T a_smoothLen) noexcept
 Convenience function for taking the BVH-accelerated union of a bunch of a implicit functions. More...
 
template<class T , class P >
std::shared_ptr< ImplicitFunction< T > > Intersection (const std::vector< std::shared_ptr< P >> &a_implicitFunctions) noexcept
 Convenience function for taking the intersection of a bunch of a implicit functions. More...
 
template<class T , class P1 , class P2 >
std::shared_ptr< ImplicitFunction< T > > Intersection (const std::shared_ptr< std::shared_ptr< P1 >> &a_implicitFunctionA, const std::shared_ptr< std::shared_ptr< P2 >> &a_implicitFunctionB) noexcept
 Convenience function for taking the intersection of two implicit functions. More...
 
template<class T , class P >
std::shared_ptr< ImplicitFunction< T > > SmoothIntersection (const std::vector< std::shared_ptr< P >> &a_implicitFunctions, const T a_smooth) noexcept
 Convenience function for taking the smooth intersection of a bunch of a implicit functions. More...
 
template<class T , class P1 , class P2 >
std::shared_ptr< ImplicitFunction< T > > SmoothIntersection (const std::shared_ptr< P1 > &a_implicitFunctionA, const std::shared_ptr< P2 > &a_implicitFunctionB, const T a_smooth) noexcept
 Convenience function for taking the smooth intersection of two implicit functions. More...
 
template<class T , class P1 = ImplicitFunction<T>, class P2 = ImplicitFunction<T>>
std::shared_ptr< ImplicitFunction< T > > Difference (const std::shared_ptr< P1 > &a_implicitFunctionA, const std::shared_ptr< P2 > &a_implicitFunctionB) noexcept
 Convenience function for taking the CSG difference. More...
 
template<class T , class P1 = ImplicitFunction<T>, class P2 = ImplicitFunction<T>>
std::shared_ptr< ImplicitFunction< T > > SmoothDifference (const std::shared_ptr< P1 > &a_implicitFunctionA, const std::shared_ptr< P2 > &a_implicitFunctionB, const T a_smoothLen) noexcept
 Convenience function for taking the smooth CSG difference. More...
 
template<class T , class P = ImplicitFunction<T>>
std::shared_ptr< ImplicitFunction< T > > FiniteRepetition (const std::shared_ptr< P > &a_implicitFunction, const Vec3T< T > &a_period, const Vec3T< T > &a_repeatLo, const Vec3T< T > &a_repeatHi) noexcept
 Convenience function for creating a periodically repeated implicit function (FiniteRepetitionIF). More...
 

Variables

template<class T >
std::function< T(const T &a, const T &b, const T &s)> expMin
 Exponential minimum function for CSG. More...
 
template<class T >
std::function< T(const T &a, const T &b, const T &s)> smoothMin
 Smooth minimum function for CSG. More...
 
template<class T >
std::function< T(const T &a, const T &b, const T &s)> smoothMax
 Smooth maximum function for CSG. More...
 

Detailed Description

Declaration of a CSG operations for implicit functions.

Author
Robert Marskar

Function Documentation

◆ Difference()

template<class T , class P1 = ImplicitFunction<T>, class P2 = ImplicitFunction<T>>
std::shared_ptr<ImplicitFunction<T> > Difference ( const std::shared_ptr< P1 > &  a_implicitFunctionA,
const std::shared_ptr< P2 > &  a_implicitFunctionB 
)
noexcept

Convenience function for taking the CSG difference.

Parameters
[in]a_implicitFunctionAImplicit function.
[in]a_implicitFunctionBImplicit function to subtract.
Note
P1 and P2 must derive from ImplicitFunction<T>

◆ FastSmoothUnion()

template<class T , class P , class BV , size_t K>
std::shared_ptr<ImplicitFunction<T> > FastSmoothUnion ( const std::vector< std::shared_ptr< P >> &  a_implicitFunctions,
const std::vector< BV > &  a_boundingVolumes,
const T  a_smoothLen 
)
noexcept

Convenience function for taking the BVH-accelerated union of a bunch of a implicit functions.

Parameters
[in]a_implicitFunctionsImplicit functions
[in]a_boundingVolumesBounding volumes for the implicit functions.
[in]a_smoothLenSmoothing length
Note
P must derive from ImplicitFunction<T>

◆ FastUnion()

template<class T , class P , class BV , size_t K>
std::shared_ptr<ImplicitFunction<T> > FastUnion ( const std::vector< std::shared_ptr< P >> &  a_implicitFunctions,
const std::vector< BV > &  a_boundingVolumes 
)
noexcept

Convenience function for taking the BVH-accelerated union of a bunch of a implicit functions.

Parameters
[in]a_implicitFunctionsImplicit functions
[in]a_boundingVolumesBounding volumes for implicit functions.
Note
P must derive from ImplicitFunction<T>

◆ FiniteRepetition()

template<class T , class P = ImplicitFunction<T>>
std::shared_ptr<ImplicitFunction<T> > FiniteRepetition ( const std::shared_ptr< P > &  a_implicitFunction,
const Vec3T< T > &  a_period,
const Vec3T< T > &  a_repeatLo,
const Vec3T< T > &  a_repeatHi 
)
noexcept

Convenience function for creating a periodically repeated implicit function (FiniteRepetitionIF).

User inputs the implicit function and the repetition parameters.

Parameters
[in]a_implicitFunctionImplicit function to be replicated
[in]a_periodRepetition period (in each coordinate direction)
[in]a_repeatLoNumber of repetitions for decreasing coordinates (should contain integers)
[in]a_repeatHiNumber of repetitions for increasing coordinates (should contain integers)

◆ Intersection() [1/2]

template<class T , class P1 , class P2 >
std::shared_ptr<ImplicitFunction<T> > Intersection ( const std::shared_ptr< std::shared_ptr< P1 >> &  a_implicitFunctionA,
const std::shared_ptr< std::shared_ptr< P2 >> &  a_implicitFunctionB 
)
noexcept

Convenience function for taking the intersection of two implicit functions.

Parameters
[in]a_implicitFunctionAFirst implicit function.
[in]a_implicitFunctionBSecond implicit function.
Note
P1 and P2 must derive from ImplicitFunction<T>

◆ Intersection() [2/2]

template<class T , class P >
std::shared_ptr<ImplicitFunction<T> > Intersection ( const std::vector< std::shared_ptr< P >> &  a_implicitFunctions)
noexcept

Convenience function for taking the intersection of a bunch of a implicit functions.

Parameters
[in]a_implicitFunctionsImplicit functions
Note
P must derive from ImplicitFunction<T>

◆ SmoothDifference()

template<class T , class P1 = ImplicitFunction<T>, class P2 = ImplicitFunction<T>>
std::shared_ptr<ImplicitFunction<T> > SmoothDifference ( const std::shared_ptr< P1 > &  a_implicitFunctionA,
const std::shared_ptr< P2 > &  a_implicitFunctionB,
const T  a_smoothLen 
)
noexcept

Convenience function for taking the smooth CSG difference.

Parameters
[in]a_implicitFunctionAImplicit function.
[in]a_implicitFunctionBImplicit function to subtract.
[in]a_smoothLenSmoothing length.
Note
P1 and P2 must derive from ImplicitFunction<T>. This uses the default smoothMax function.

◆ SmoothIntersection() [1/2]

template<class T , class P1 , class P2 >
std::shared_ptr<ImplicitFunction<T> > SmoothIntersection ( const std::shared_ptr< P1 > &  a_implicitFunctionA,
const std::shared_ptr< P2 > &  a_implicitFunctionB,
const T  a_smooth 
)
noexcept

Convenience function for taking the smooth intersection of two implicit functions.

Parameters
[in]a_implicitFunctionAFirst implicit function.
[in]a_implicitFunctionBSecond implicit function.
[in]a_smoothSmoothing distance.
Note
P1 and P2 must derive from ImplicitFunction<T>

◆ SmoothIntersection() [2/2]

template<class T , class P >
std::shared_ptr<ImplicitFunction<T> > SmoothIntersection ( const std::vector< std::shared_ptr< P >> &  a_implicitFunctions,
const T  a_smooth 
)
noexcept

Convenience function for taking the smooth intersection of a bunch of a implicit functions.

Parameters
[in]a_implicitFunctionsImplicit functions
[in]a_smoothSmoothing distance.
Note
P must derive from ImplicitFunction<T>

◆ SmoothUnion() [1/2]

template<class T , class P1 , class P2 >
std::shared_ptr<ImplicitFunction<T> > SmoothUnion ( const std::shared_ptr< P1 > &  a_implicitFunctionA,
const std::shared_ptr< P2 > &  a_implicitFunctionB,
const T  a_smooth 
)
noexcept

Convenience function for taking the union of two implicit functions.

Parameters
[in]a_implicitFunctionAFirst implicit function.
[in]a_implicitFunctionBSecond implicit function.
[in]a_smoothSmoothing distance.
Note
P1 and P2 must derive from ImplicitFunction<T>

◆ SmoothUnion() [2/2]

template<class T , class P = ImplicitFunction<T>>
std::shared_ptr<ImplicitFunction<T> > SmoothUnion ( const std::vector< std::shared_ptr< P >> &  a_implicitFunctions,
const T  a_smooth 
)
noexcept

Convenience function for taking the union of a bunch of a implicit functions.

Parameters
[in]a_implicitFunctionsImplicit functions
[in]a_smoothSmoothing distance.
Note
P must derive from ImplicitFunction<T>

◆ Union() [1/2]

template<class T , class P1 , class P2 >
std::shared_ptr<ImplicitFunction<T> > Union ( const std::shared_ptr< P1 > &  a_implicitFunctionA,
const std::shared_ptr< P2 > &  a_implicitFunctionB 
)
noexcept

Convenience function for taking the union of two implicit functions.

Parameters
[in]a_implicitFunctionAFirst implicit function.
[in]a_implicitFunctionBSecond implicit function.
Note
P1 and P2 must derive from ImplicitFunction<T>

◆ Union() [2/2]

template<class T , class P = ImplicitFunction<T>>
std::shared_ptr<ImplicitFunction<T> > Union ( const std::vector< std::shared_ptr< P >> &  a_implicitFunctions)
noexcept

Convenience function for taking the union of a bunch of a implicit functions.

Parameters
[in]a_implicitFunctionsImplicit functions
Note
P must derive from ImplicitFunction<T>

Variable Documentation

◆ expMin

template<class T >
std::function<T(const T& a, const T& b, const T& s)> expMin
Initial value:
= [](const T& a, const T& b, const T& s) -> T {
T ret = exp(-a / s) + exp(-b / s);
return -log(ret) * s;
}

Exponential minimum function for CSG.

Parameters
[in]aSmallest value
[in]bSecond smallest value
[in]sSmoothing distance.

◆ smoothMax

template<class T >
std::function<T(const T& a, const T& b, const T& s)> smoothMax
Initial value:
= [](const T& a, const T& b, const T& s) -> T {
const T h = std::max(s - std::abs(a - b), 0.0) / s;
return std::max(a, b) + 0.25 * h * h * s;
}
Vec2T< T > max(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Maximum function. Returns new vector with component-wise minimums.

Smooth maximum function for CSG.

Parameters
[in]aLargest value
[in]bSecond largest value
[in]sSmoothing distance.

◆ smoothMin

template<class T >
std::function<T(const T& a, const T& b, const T& s)> smoothMin
Initial value:
= [](const T& a, const T& b, const T& s) -> T {
const T h = std::max(s - std::abs(a - b), 0.0) / s;
return std::min(a, b) - 0.25 * h * h * s;
}
Vec2T< T > min(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Minimum function. Returns new vector with component-wise minimums.

Smooth minimum function for CSG.

Parameters
[in]aSmallest value
[in]bSecond smallest value
[in]sSmoothing distance.