Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
Mantid::Geometry::MDImplicitFunction Class Reference

An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions. More...

#include <MDImplicitFunction.h>

Inheritance diagram for Mantid::Geometry::MDImplicitFunction:
Mantid::Geometry::CompositeImplicitFunction Mantid::Geometry::MDAlgorithms::MDBoxMaskFunction Mantid::Geometry::MDBoxImplicitFunction Mantid::Geometry::MDPlaneImplicitFunction Mantid::Geometry::NullImplicitFunction

Public Types

enum  eContact { NOT_TOUCHING = 0 , TOUCHING = 1 , CONTAINED = 2 }
 Enum for describing the contact between a box and an implicit function. More...
 

Public Member Functions

void addPlane (const MDPlane &plane)
 Add a bounded plane to this implicit function. More...
 
eContact boxContact (const coord_t *vertexes, const size_t numPoints) const
 Determine how a box (consisting of a number of vertexes) is in contact with the implicit function. More...
 
virtual std::string getName () const
 
size_t getNumDims () const
 
size_t getNumPlanes () const
 
const MDPlanegetPlane (size_t index) const
 
bool isBoxTouching (const coord_t *vertexes, const size_t numPoints)
 Same as isBoxTouching(vector), except that it takes a bare array of coordinates. More...
 
bool isBoxTouching (const std::vector< std::vector< coord_t > > &vertexes)
 Is there a chance that the box defined by these vertexes touches the implicit function volume? More...
 
virtual bool isPointContained (const coord_t *coords)
 Is a point in MDimensions contained by this ImplicitFunction? If the point is bounded by ALL planes contained, then this returns true. More...
 
virtual bool isPointContained (const Mantid::Kernel::VMD &coords)
 Is a point in MDimensions contained by this ImplicitFunction? If the point is bounded by ALL planes contained, then this returns true. More...
 
virtual bool isPointContained (const std::vector< coord_t > &coords)
 Is a point in MDimensions contained by this ImplicitFunction? If the point is bounded by ALL planes contained, then this returns true. More...
 
 MDImplicitFunction ()
 Constructor. More...
 
virtual std::string toXMLString () const
 
virtual ~MDImplicitFunction ()=default
 

Protected Attributes

size_t m_nd
 number of dimensions for which this object can be applied More...
 
size_t m_numPlanes
 Cached number of planes (for a sligh speed-up) More...
 
std::vector< MDPlanem_planes
 Vector of all the planes applying for this implict function. More...
 

Detailed Description

An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.

This is to be used in various MD rebinning algorithms to determine e.g, which boxes should be considered to be within the integration volume.

This general case would cover boxes that are not aligned with the axes.

Various shapes can be built by intersecting 1 or more planes. The Plane, and whether a point is bounded by it, will be the basis of determining whether a point is in a volume.

For example, in a 3D space:

1 plane = a half-infinite volume 2 parallel planes = a plane with a thickness 4 aligned planes = an infinite line, rectangular in cross-section 6 planes = a cuboid

For most efficiency, each MDImplicitFunction should be built with a given set of dimensions in mind; that is, if it is to be applied on a MDEventWorkspace with say 6 dimensions: X, Y, Z, time, temperature, field; then a mask that only looks at the relevant 3 dimensions is used.

Author
Janik Zikovsky
Date
2011-07-15

Definition at line 44 of file MDImplicitFunction.h.

Member Enumeration Documentation

◆ eContact

Enum for describing the contact between a box and an implicit function.

Enumerator
NOT_TOUCHING 

No part of the box touches the implicit function.

TOUCHING 

Box is partly touching the implicit function region.

CONTAINED 

Box is fully contained by the implicit function.

Definition at line 75 of file MDImplicitFunction.h.

Constructor & Destructor Documentation

◆ MDImplicitFunction()

Mantid::Geometry::MDImplicitFunction::MDImplicitFunction ( )

Constructor.

Definition at line 15 of file MDImplicitFunction.cpp.

◆ ~MDImplicitFunction()

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

Member Function Documentation

◆ addPlane()

void Mantid::Geometry::MDImplicitFunction::addPlane ( const MDPlane plane)

Add a bounded plane to this implicit function.

Parameters
plane:: MDPlane to add.

Definition at line 22 of file MDImplicitFunction.cpp.

References Mantid::Geometry::MDPlane::getNumDims(), m_nd, m_numPlanes, and m_planes.

Referenced by Mantid::Geometry::MDPlaneImplicitFunction::addPlane(), and Mantid::Geometry::MDBoxImplicitFunction::construct().

◆ boxContact()

eContact Mantid::Geometry::MDImplicitFunction::boxContact ( const coord_t vertexes,
const size_t  numPoints 
) const
inline

Determine how a box (consisting of a number of vertexes) is in contact with the implicit function.

Returns: NOT_TOUCHING : if any of the planes has no vertex in it. CONTAINED : if all of the vertexes are in all of the planes. TOUCHING : if there is a chance of the box touching the volume. (there can sometimes be false positives)

Parameters
vertexes:: bare array of length numPoints * m_nd
numPoints:: number of vertexes in the array.
Returns
eContact enum value

Definition at line 229 of file MDImplicitFunction.h.

◆ getName()

virtual std::string Mantid::Geometry::MDImplicitFunction::getName ( ) const
inlinevirtual

◆ getNumDims()

size_t Mantid::Geometry::MDImplicitFunction::getNumDims ( ) const
inline
Returns
the number of dimensions for which this object can be applied

Definition at line 56 of file MDImplicitFunction.h.

Referenced by Mantid::Geometry::MDPlaneImplicitFunction::checkOrigin(), and Mantid::Geometry::MDPlaneImplicitFunction::coordValue().

◆ getNumPlanes()

size_t Mantid::Geometry::MDImplicitFunction::getNumPlanes ( ) const
inline
Returns
the number of dimensions for which this object can be applied

Definition at line 59 of file MDImplicitFunction.h.

Referenced by Mantid::Geometry::MDPlaneImplicitFunction::addPlane().

◆ getPlane()

const MDPlane & Mantid::Geometry::MDImplicitFunction::getPlane ( size_t  index) const
inline
Returns
the MDPlane contained
Parameters
index:: which plane to return

Definition at line 53 of file MDImplicitFunction.h.

References index.

Referenced by Mantid::Geometry::MDPlaneImplicitFunction::toXMLString().

◆ isBoxTouching() [1/2]

bool Mantid::Geometry::MDImplicitFunction::isBoxTouching ( const coord_t vertexes,
const size_t  numPoints 
)
inline

Same as isBoxTouching(vector), except that it takes a bare array of coordinates.

This is for max. performance.

The array is to be filled with numPoints sets of coordinates, each of m_nd in length.

Parameters
vertexes:: bare array of length numPoints * m_nd
numPoints:: number of vertexes in the array.
Returns
true if there is a chance of the box touching.

Definition at line 195 of file MDImplicitFunction.h.

◆ isBoxTouching() [2/2]

bool Mantid::Geometry::MDImplicitFunction::isBoxTouching ( const std::vector< std::vector< coord_t > > &  vertexes)
inline

Is there a chance that the box defined by these vertexes touches the implicit function volume?

The algorithm operates by the idea that if any point in a volume is contained in the volume, then that means that at least one of the vertexes is within EACH one of the planes that define the volume.

That means that if you find a plane for which NO vertex is contained, then the box defined by these vertexes CANNOT touch any part of the volume so it is safe to ignore. (I don't have a rigorous proof for this but it looks right :)

There are situations where the condition can be satisfied but the box does not actually touch the volume (false positives) but these should be pretty rare.

Parameters
vertexes:: vector of n-dimensional coordinate vertexes. NOTE: no size check is done! Each vertex must be length m_nd!
Returns
true if there is a chance of the box touching. Note that the algorithm does not guarantee that it touches, but it should never return false if the box does touch.

Definition at line 161 of file MDImplicitFunction.h.

◆ isPointContained() [1/3]

virtual bool Mantid::Geometry::MDImplicitFunction::isPointContained ( const coord_t coords)
inlinevirtual

Is a point in MDimensions contained by this ImplicitFunction? If the point is bounded by ALL planes contained, then this returns true.

Parameters
coords:: nd-sized array of coordinates
Returns
true if it is contained in the implicit function.

Reimplemented in Mantid::Geometry::NullImplicitFunction, Mantid::Geometry::CompositeImplicitFunction, Mantid::Geometry::NullImplicitFunction, Mantid::Geometry::MDAlgorithms::MDBoxMaskFunction, Mantid::Geometry::CompositeImplicitFunction, and Mantid::Geometry::MDAlgorithms::MDBoxMaskFunction.

Definition at line 94 of file MDImplicitFunction.h.

Referenced by Mantid::DataObjects::MDHistoWorkspace::applyImplicitFunction(), and Mantid::API::MatrixWorkspaceMDIterator::next().

◆ isPointContained() [2/3]

virtual bool Mantid::Geometry::MDImplicitFunction::isPointContained ( const Mantid::Kernel::VMD coords)
inlinevirtual

Is a point in MDimensions contained by this ImplicitFunction? If the point is bounded by ALL planes contained, then this returns true.

Parameters
coords:: nd-sized array of coordinates
Returns
true if it is contained in the implicit function.

Reimplemented in Mantid::Geometry::CompositeImplicitFunction, Mantid::Geometry::NullImplicitFunction, and Mantid::Geometry::MDAlgorithms::MDBoxMaskFunction.

Definition at line 110 of file MDImplicitFunction.h.

◆ isPointContained() [3/3]

virtual bool Mantid::Geometry::MDImplicitFunction::isPointContained ( const std::vector< coord_t > &  coords)
inlinevirtual

Is a point in MDimensions contained by this ImplicitFunction? If the point is bounded by ALL planes contained, then this returns true.

Parameters
coords:: nd-sized vector of coordinates. No size-check is made!
Returns
true if it is contained in the implicit function.

Reimplemented in Mantid::Geometry::NullImplicitFunction, Mantid::Geometry::CompositeImplicitFunction, Mantid::Geometry::NullImplicitFunction, Mantid::Geometry::MDAlgorithms::MDBoxMaskFunction, and Mantid::Geometry::CompositeImplicitFunction.

Definition at line 126 of file MDImplicitFunction.h.

◆ toXMLString()

virtual std::string Mantid::Geometry::MDImplicitFunction::toXMLString ( ) const
inlinevirtual

Member Data Documentation

◆ m_nd

size_t Mantid::Geometry::MDImplicitFunction::m_nd
protected

number of dimensions for which this object can be applied

Definition at line 269 of file MDImplicitFunction.h.

Referenced by addPlane().

◆ m_numPlanes

size_t Mantid::Geometry::MDImplicitFunction::m_numPlanes
protected

Cached number of planes (for a sligh speed-up)

Definition at line 275 of file MDImplicitFunction.h.

Referenced by addPlane().

◆ m_planes

std::vector<MDPlane> Mantid::Geometry::MDImplicitFunction::m_planes
protected

Vector of all the planes applying for this implict function.

Definition at line 272 of file MDImplicitFunction.h.

Referenced by addPlane().


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