Mantid
|
#include <HKLFilter.h>
Public Member Functions | |
std::function< bool(const Kernel::V3D &)> | fn () const noexcept |
Returns a function object that wraps HKLFilter::isAllowed. More... | |
virtual std::string | getDescription () const =0 |
virtual bool | isAllowed (const Kernel::V3D &hkl) const =0 |
virtual | ~HKLFilter ()=default |
There are many ways to filter lists of Miller indices HKL. In order to be able to use HKLGenerator with arbitrary filters, HKLFilter provides a general interface for such filters.
The abstract base class HKLFilter defines a pure virtual method HKLFilter::isAllowed(), which takes a V3D as argument and returns a boolean. Implementing classes can then implement this method, wrapping very different concepts of checking HKLs for certain characteristics.
There are two general ways of using HKLFilters. When used "standalone", the isAllowed()-function can be used directly:
if(filter->isAllowed(hkl)) { do something }
For interoperability with STL-algorithms, HKLFilter provides a method that returns a function-object with the filter:
std::copy_if(generator.begin(), generator.end(), hkls.begin(), filter->fn());
Often, it's not enough to filter a list by one criterion. To this end, there are two implementations of HKLFilter that provide binary logic operations "and" (HKLFilterAnd) and "or" (HKLFilterOr). They can be constructed from two HKLFilter_const_sptrs, or, more conveniently, by using the operators & and | directly with those types. This makes it possible to combine filters in many ways:
HKLFilter_const_sptr filter = (filter1 | filter2) & filter3;
Lastly, the unary logic operation "not" (HKLFilterNot) is implemented. This is important for usability with the pre-C++11 algorithm std::remove_copy_if that works logically reversed compared to std::copy_if:
std::remove_copy_if(generator.begin(), generator.end(), hkls.begin(), (~filter)->fn());
For actual implementations of HKLFilter, check out BasicHKLFilters, where some important filters are defined.
@author Michael Wedel, ESS @date 06/09/2015
Definition at line 65 of file HKLFilter.h.
|
virtualdefault |
|
noexcept |
Returns a function object that wraps HKLFilter::isAllowed.
This method uses std::bind to create a function object that represents the HKLFilter::isAllowed() method. This way it's possible to pass the function to STL-algorithms easily (see class documentation).
Definition at line 24 of file HKLFilter.cpp.
References isAllowed().
|
pure virtual |
Implemented in Mantid::Geometry::HKLFilterNone, Mantid::Geometry::HKLFilterDRange, Mantid::Geometry::HKLFilterSpaceGroup, Mantid::Geometry::HKLFilterStructureFactor, Mantid::Geometry::HKLFilterCentering, Mantid::Geometry::HKLFilterNot, Mantid::Geometry::HKLFilterAnd, Mantid::Geometry::HKLFilterOr, and Mantid::Geometry::HKLFilterWavelength.
|
pure virtual |
Implemented in Mantid::Geometry::HKLFilterNone, Mantid::Geometry::HKLFilterDRange, Mantid::Geometry::HKLFilterSpaceGroup, Mantid::Geometry::HKLFilterStructureFactor, Mantid::Geometry::HKLFilterCentering, Mantid::Geometry::HKLFilterNot, Mantid::Geometry::HKLFilterAnd, Mantid::Geometry::HKLFilterOr, and Mantid::Geometry::HKLFilterWavelength.
Referenced by fn().