Mantid
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Mantid::Geometry::HKLFilter Class Referenceabstract

HKLFilter. More...

#include <HKLFilter.h>

Inheritance diagram for Mantid::Geometry::HKLFilter:
Mantid::Geometry::HKLFilterBinaryLogicOperation Mantid::Geometry::HKLFilterCentering Mantid::Geometry::HKLFilterDRange Mantid::Geometry::HKLFilterNone Mantid::Geometry::HKLFilterSpaceGroup Mantid::Geometry::HKLFilterStructureFactor Mantid::Geometry::HKLFilterUnaryLogicOperation Mantid::Geometry::HKLFilterWavelength

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
 

Detailed Description

HKLFilter.

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.

Constructor & Destructor Documentation

◆ ~HKLFilter()

virtual Mantid::Geometry::HKLFilter::~HKLFilter ( )
virtualdefault

Member Function Documentation

◆ fn()

std::function< bool(const Kernel::V3D &)> Mantid::Geometry::HKLFilter::fn ( ) const
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).

Returns
Function object with filter function for V3D.s

Definition at line 24 of file HKLFilter.cpp.

References isAllowed().

◆ getDescription()

virtual std::string Mantid::Geometry::HKLFilter::getDescription ( ) const
pure virtual

◆ isAllowed()

virtual bool Mantid::Geometry::HKLFilter::isAllowed ( const Kernel::V3D hkl) const
pure virtual

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