ImFusion SDK 4.3
ImFusion::Utils Namespace Reference

Collection of utility methods not associated with any class. More...

Detailed Description

Collection of utility methods not associated with any class.

Generic utility classes and helper functions.

See also
ImFusionCoreUtils

Namespaces

namespace  EigenVectorWrapperImpl
 Wrapper classes for using std::vector<Eigen::Matrix<T,N,1>> with arbitrary T and N as input of a non-template function.
 

Classes

class  bad_expected_access
 
struct  EigenVectorWrapper
 Simple case: non-optional input argument. More...
 
class  Expected
 An Expected<T, E> object is an object that contains the storage for another object and manages the lifetime of this contained object T. More...
 
class  LinearIterator
 Typed convenience iterator for quick integration into custom containers, especially if traversal requires on-the-fly evaluations. More...
 
class  NotCopyable
 Inherit from this class if your class should be neither copy-constructible nor assignable. More...
 
struct  OptionalEigenVectorWrapper
 Optional input argument. More...
 
struct  OptionalOutputEigenVectorWrapper
 Optional output argument. More...
 
struct  OutputEigenVectorWrapper
 Non-optional output argument. More...
 
struct  Overloaded
 Syntactic sugar for easier implementation of visitors of a std::variant or our Utils::Variant. More...
 
class  ScopeGuard
 Templated proxy class to implement generic scope guards. More...
 
class  Span
 Describes a non-owning view into contiguous sequence of elements. More...
 
class  Unexpected
 
struct  Variant
 Specialization of std::variant offering additional convenience member functions for functionality that the standard library only provides in the form of free functions. More...
 
struct  Version
 Utility class to work with version information following the SemVer format. More...
 

Functions

template<class E>
constexpr bool operator== (const Unexpected< E > &lhs, const Unexpected< E > &rhs)
 
template<class E>
constexpr bool operator!= (const Unexpected< E > &lhs, const Unexpected< E > &rhs)
 
template<class E>
constexpr bool operator< (const Unexpected< E > &lhs, const Unexpected< E > &rhs)
 
template<class E>
constexpr bool operator<= (const Unexpected< E > &lhs, const Unexpected< E > &rhs)
 
template<class E>
constexpr bool operator> (const Unexpected< E > &lhs, const Unexpected< E > &rhs)
 
template<class E>
constexpr bool operator>= (const Unexpected< E > &lhs, const Unexpected< E > &rhs)
 
template<class E>
Unexpected< typename std::decay< E >::type > make_unexpected (E &&e)
 
template<class T, class E, class U, class F>
constexpr bool operator== (const Expected< T, E > &lhs, const Expected< U, F > &rhs)
 
template<class T, class E, class U, class F>
constexpr bool operator!= (const Expected< T, E > &lhs, const Expected< U, F > &rhs)
 
template<class E, class F>
constexpr bool operator== (const Expected< void, E > &lhs, const Expected< void, F > &rhs)
 
template<class E, class F>
constexpr bool operator!= (const Expected< void, E > &lhs, const Expected< void, F > &rhs)
 
template<class T, class E, class U>
constexpr bool operator== (const Expected< T, E > &x, const U &v)
 
template<class T, class E, class U>
constexpr bool operator== (const U &v, const Expected< T, E > &x)
 
template<class T, class E, class U>
constexpr bool operator!= (const Expected< T, E > &x, const U &v)
 
template<class T, class E, class U>
constexpr bool operator!= (const U &v, const Expected< T, E > &x)
 
template<class T, class E>
constexpr bool operator== (const Expected< T, E > &x, const Unexpected< E > &e)
 
template<class T, class E>
constexpr bool operator== (const Unexpected< E > &e, const Expected< T, E > &x)
 
template<class T, class E>
constexpr bool operator!= (const Expected< T, E > &x, const Unexpected< E > &e)
 
template<class T, class E>
constexpr bool operator!= (const Unexpected< E > &e, const Expected< T, E > &x)
 
template<class T, class E, detail::enable_if_t<(std::is_void< T >::value||std::is_move_constructible< T >::value) &&detail::is_swappable< T >::value &&std::is_move_constructible< E >::value &&detail::is_swappable< E >::value > * = nullptr>
void swap (Expected< T, E > &lhs, Expected< T, E > &rhs) noexcept(noexcept(lhs.swap(rhs)))
 
template<class... Ts>
 Overloaded (Ts...) -> Overloaded< Ts... >
 
template<typename T>
detail::RangeProxy< T > range (T begin, T end)
 An iterable wrapper for the half-open interval of integer numbers [begin, end).
 
template<typename T>
detail::RangeProxy< T > range (T end)
 An iterable wrapper for the half-open interval of integer numbers [0, end).
 
template<typename T>
detail::StepRangeProxy< T > range (T begin, T end, T step_size)
 An iterable wrapper for the uniformly numbers in the half-open interval [begin, end).
 
template<typename T>
detail::ReverseWrapper< T > reverse (T &&iterable)
 Iterator wrapper to reverse the iteration order.
 
template<class ReleaseFunc>
ScopeGuard< std::remove_reference_t< ReleaseFunc > > makeScopeGuard (ReleaseFunc &&f)
 Generator function to instantiate a ScopeGuard without writing out the templates.
 
template<class AcquisitionFunc, class ReleaseFunc>
ScopeGuard< std::remove_reference_t< ReleaseFunc > > makeScopeGuard (AcquisitionFunc &&acquisitionFunc, ReleaseFunc &&releaseFunc)
 Generator function to first execute acquisitionFunc and then instantiate a ScopeGuard with releaseFunc.
 
template<class T, size_t N>
 Span (T(&)[N]) -> Span< T, N >
 
template<class T, size_t N>
 Span (std::array< T, N > &) -> Span< T, N >
 
template<class T, size_t N>
 Span (const std::array< T, N > &) -> Span< const T, N >
 
template<class Container>
 Span (Container &) -> Span< typename std::remove_reference< decltype(*std::data(std::declval< Container & >()))>::type >
 
template<class Container>
 Span (const Container &) -> Span< const typename Container::value_type >
 
void applyMask (const MemImage *inImg, const MemImage *mask, MemImage *outImg, double outsideValue, bool const thresholdValue, bool const aboveThreshold, bool const elevateInside)
 
template<int R, typename Iter>
std::vector< std::array< typename Iter::value_type, R > > combinations (Iter begin, Iter end)
 Return r length subsequences of elements from the input iterable.
 
template<typename T>
sampleFromSequence (const std::vector< double > &x, const std::vector< T > &y, double x0, std::function< T(T, T, double)> interpFunc=[](T a, T b, double w) { return static_cast< T >(w *b+(1.0 - w) *a);})
 Given a sequence of values y measured at sampling points x, returns the linearly interpolated value for a specific x0.
 
template<typename T>
std::vector< T > resampleSequence (const std::vector< T > &vals, const std::vector< double > &tHave, const std::vector< double > &tWant, std::function< T(T, T, double)> interpFunc=[](T a, T b, double w) { return w *b+(1.0 - w) *a;})
 Resamples a sequence of values val measured at timestamps tHave with the new timestamps tWant.
 
template<typename T, typename U>
bool sortByVector (std::vector< T > &toBeSorted, std::vector< U > &valuesToSortBy)
 Sorts a vector according to the values in another vector, for cases where you somehow cannot work with structs containing both values.
 
template<typename ContainerT>
std::vector< std::tuple< typename ContainerT::const_iterator, typename ContainerT::const_iterator, double > > kMeans (const ContainerT &c, int numCluster, int numIter, std::function< double(const typename ContainerT::value_type &)> mapTToDouble=[](const typename ContainerT::value_type &elem) -> double { return static_cast< double >(elem);})
 A container-based 1D k-means clustering that checks whether all elements in a container are equal to each other.
 
void autoWindow (const SharedImageSet &img, bool applyTo2dDisplayOptions=true, bool applyTo3dDisplayOptions=true, double lowerLimit=0.0, double upperLimit=0.0)
 Update window/level of img to show the entire intensity range of the image.
 
template<typename T>
Image::Type imageTypeId ()
 
template<typename T>
PixelType pixelTypeId ()
 
mat4 getRenderMatrixToWorld (const SharedImageSet &img, int which=-1)
 Obtains the matrix to render the given image in 2D, MPR, and 3D views.
 
mat4 getRenderMatrixFromWorld (const SharedImageSet &img, int which=-1)
 Obtains the matrix to render the given image in 2D, MPR, and 3D views.
 
template<typename T>
bool operator> (const LinearIterator< T > &c1, const LinearIterator< T > &c2)
 
template<typename T>
bool operator>= (const LinearIterator< T > &c1, const LinearIterator< T > &c2)
 
template<typename T>
bool operator< (const LinearIterator< T > &c1, const LinearIterator< T > &c2)
 
template<typename T>
bool operator<= (const LinearIterator< T > &c1, const LinearIterator< T > &c2)
 
std::string defaultModelsPath ()
 Returns the default path of the machine learning models.
 
std::string sdkDocDirectory ()
 Returns the absolute directory of the C++ SDK documentation.
 
std::string userDocDirectory ()
 Returns the absolute directory of the HTML user documentation.
 
std::string pythonDocDirectory ()
 Returns the absolute directory to the Python documentation.
 
std::string licenseAgreementDirectory ()
 Returns the absolute directory to the License and Acknowledgments files.
 
std::string uniqueIdFromUsbPath (const std::string &usbPath)
 Tries to get a unique identifier from a USB device path.
 
std::vector< std::stringenumerateUsbDevices ()
 
template<typename F, typename... Args>
auto typeSwitch (Image::Type itype, F &&func, Args &&... args)
 Function for internally type switching a given lambda function on the Image::Type cases.
 
template<typename F, typename... Args>
auto typeSwitch (const MemImage &img, F &&func, Args &&... args)
 Function for internally type switching a given lambda function on the Image::Type cases.
 
template<typename F, typename... Args>
auto typeSwitch (const PixelType &type, F &&func, Args &&... args)
 

Function Documentation

◆ combinations()

template<int R, typename Iter>
std::vector< std::array< typename Iter::value_type, R > > combinations ( Iter begin,
Iter end )

Return r length subsequences of elements from the input iterable.

Combinations are emitted in lexicographic sort order. So, if the input iterable is sorted, the combination tuples will be produced in sorted order. Elements are treated as unique based on their position, not on their value. So if the input elements are unique, there will be no repeat values in each combination.

std::vector<std::string>> l = {"A", "B", "C", "D"};
T begin(T... args)
T end(T... args)
std::vector< std::array< typename Iter::value_type, R > > combinations(Iter begin, Iter end)
Return r length subsequences of elements from the input iterable.
Definition Containers.h:28

Returns {{"A", "B"}, {"A", "C"}, {"A", "D"}, {"B", "C"}, {"B", "D"}, {"C", "D"}}

◆ sampleFromSequence()

template<typename T>
T sampleFromSequence ( const std::vector< double > & x,
const std::vector< T > & y,
double x0,
std::function< T(T, T, double)> interpFunc = [](T a, T b, double w) { return static_cast<T>(w * b + (1.0 - w) * a); } )

Given a sequence of values y measured at sampling points x, returns the linearly interpolated value for a specific x0.

If the target sampling point is outside the measurement range given by x, it will return the closest valid y. x needs to be monotonically increasing, but does not have to be equidistant.

◆ kMeans()

template<typename ContainerT>
std::vector< std::tuple< typename ContainerT::const_iterator, typename ContainerT::const_iterator, double > > kMeans ( const ContainerT & c,
int numCluster,
int numIter,
std::function< double(const typename ContainerT::value_type &)> mapTToDouble = [](const typename ContainerT::value_type& elem) -> double { return static_cast<double>(elem); } )

A container-based 1D k-means clustering that checks whether all elements in a container are equal to each other.

Parameters
cA container of elements. Needs to be sorted in ascending order with respect to mapTToDouble.
numClusterExpected number of clusters.
numIterNumber of iterations for the k-means.
mapTToDoubleMapping of the elements of c to a double value. The same mapping needs to be used for sorting.
Returns
A vector of tuples (first, end, mean) with numIter elements. The const iterators first and second give the range of each cluster [first,end) with mean providing the corresponding mean value of the cluster.

◆ autoWindow()

void autoWindow ( const SharedImageSet & img,
bool applyTo2dDisplayOptions = true,
bool applyTo3dDisplayOptions = true,
double lowerLimit = 0.0,
double upperLimit = 0.0 )

Update window/level of img to show the entire intensity range of the image.

Parameters
imgImage to change the windowing for.
applyTo2dDisplayOptionsFlag whether update the DisplayOptions2d attached to img.
applyTo3dDisplayOptionsFlag whether update the DisplayOptions3d attached to img.
lowerLimitRatio of lower values removed by the auto windowing.
upperLimitRatio of upper values removed by the auto windowing.

◆ getRenderMatrixToWorld()

mat4 getRenderMatrixToWorld ( const SharedImageSet & img,
int which = -1 )

Obtains the matrix to render the given image in 2D, MPR, and 3D views.

The function evaluates to img.matrixToWorld() for standard SharedImageSets, but correctly considers the internal matrix for derived types (CBCT data, TrackedSharedImageSets, etc.)

◆ getRenderMatrixFromWorld()

mat4 getRenderMatrixFromWorld ( const SharedImageSet & img,
int which = -1 )

Obtains the matrix to render the given image in 2D, MPR, and 3D views.

The function evaluates to img.matrixFromWorld() for standard SharedImageSets, but correctly considers the internal matrix for derived types (CBCT data, TrackedSharedImageSets, etc.)

◆ defaultModelsPath()

std::string defaultModelsPath ( )

Returns the default path of the machine learning models.

Use Settings::defaultFolderMLModels to get a path which can be changed by the user.

Search Tab / S to search, Esc to close