#include <MRMesh/MRDistanceMap.h>
Public Member Functions | |
| DistanceMap ()=default | |
| DistanceMap (size_t resX, size_t resY) | |
| DistanceMap (const MR::Matrix< float > &m) | |
| make from 2d array | |
| bool | isValid (size_t x, size_t y) const |
| checks if X,Y element is valid (i.e. not NOT_VALID_VALUE; passing invalid coords to this is UB) | |
| bool | isValid (size_t i) const |
| checks if index element is valid (i.e. not NOT_VALID_VALUE; passing an invalid coord to this is UB) | |
| bool | isInBounds (size_t x, size_t y) const |
| Returns true if (X,Y) coordinates are in bounds. | |
| bool | isInBounds (size_t i) const |
| Returns true if a flattened coordinate is in bounds. | |
| std::optional< float > | get (size_t x, size_t y) const |
| returns value in (X,Y) element, returns nullopt if not valid (see isValid()), UB if out of bounds. | |
| std::optional< float > | get (size_t i) const |
| returns value of index element, returns nullopt if not valid (see isValid()), UB if out of bounds. | |
| float & | getValue (size_t x, size_t y) |
| float | getValue (size_t x, size_t y) const |
| float & | getValue (size_t i) |
| float | getValue (size_t i) const |
| float * | data () |
| const float * | data () const |
| std::optional< float > | getInterpolated (float x, float y) const |
| finds interpolated value. | |
| std::optional< Vector3f > | unproject (size_t x, size_t y, const AffineXf3f &toWorld) const |
| std::optional< Vector3f > | unprojectInterpolated (float x, float y, const AffineXf3f &toWorld) const |
| finds 3d coordinates of the Point on the model surface for the (x,y) interpolated value | |
| void | negate () |
| replaces every valid element in the map with its negative value | |
| DistanceMap | max (const DistanceMap &rhs) const |
| const DistanceMap & | mergeMax (const DistanceMap &rhs) |
| replaces values with cell-wise maximum values. Invalid values remain only if both corresponding cells are invalid | |
| DistanceMap | min (const DistanceMap &rhs) const |
| returns new Distance Map with cell-wise minimum values. Invalid values remain only if both corresponding cells are invalid | |
| const DistanceMap & | mergeMin (const DistanceMap &rhs) |
| replaces values with cell-wise minimum values. Invalid values remain only if both corresponding cells are invalid | |
| DistanceMap | operator- (const DistanceMap &rhs) const |
| returns new Distance Map with cell-wise subtracted values. Invalid values remain only if both corresponding cells are invalid | |
| const DistanceMap & | operator-= (const DistanceMap &rhs) |
| replaces values with cell-wise subtracted values. Invalid values remain only if both corresponding cells are invalid | |
| void | set (size_t x, size_t y, float val) |
| sets value in (X,Y) element (the coords must be valid, UB otherwise) | |
| void | set (size_t i, float val) |
| sets value in index element (the coord must be valid, UB otherwise) | |
| void | set (std::vector< float > data) |
| sets all values at one time | |
| void | unset (size_t x, size_t y) |
| invalidates value in (X,Y) element (the coords must be valid, UB otherwise) | |
| void | unset (size_t i) |
| invalidates value in index element (the coord must be valid, UB otherwise) | |
| void | invalidateAll () |
| invalidates all elements | |
| void | clear () |
| clears data, sets resolutions to zero | |
| DistanceMap | getDerivativeMap () const |
| returns new derivatives map without directions | |
| std::pair< DistanceMap, DistanceMap > | getXYDerivativeMaps () const |
| returns new derivative maps with X and Y axes direction | |
| std::vector< std::pair< size_t, size_t > > | getLocalMaximums () const |
| computes single derivative map from XY spaces combined. Returns local maximums then | |
| size_t | resX () const |
| returns X resolution | |
| size_t | resY () const |
| returns Y resolution | |
| size_t | numPoints () const |
| returns the number of pixels | |
| std::pair< float, float > | getMinMaxValues () const |
| std::pair< size_t, size_t > | getMinIndex () const |
| std::pair< size_t, size_t > | getMaxIndex () const |
| size_t | heapBytes () const |
| returns the amount of memory this object occupies on heap | |
| Public Member Functions inherited from MR::RectIndexer | |
| constexpr | RectIndexer () noexcept=default |
| RectIndexer (const Vector2i &dims) | |
| void | resize (const Vector2i &dims) |
| const Vector2i & | dims () const |
| size_t | size () const |
| Vector2i | toPos (PixelId id) const |
| Vector2i | toPos (size_t id) const |
| PixelId | toPixelId (const Vector2i &pos) const |
| size_t | toIndex (const Vector2i &pos) const |
| bool | areNeigbors (PixelId v0, PixelId v1) const |
| returns true if v1 is within at most 4 neighbors of v0 | |
| bool | areNeigbors (const Vector2i &pos0, const Vector2i &pos1) const |
| PixelId | getNeighbor (PixelId v, OutEdge2 toNei) const |
| returns id of v's neighbor specified by the edge | |
| PixelId | getNeighbor (PixelId v, const Vector2i &pos, OutEdge2 toNei) const |
Static Public Attributes | |
| static constexpr float | NOT_VALID_VALUE = std::numeric_limits<float>::lowest() |
| a constant that is treated as 'no value' or 'invalid value' | |
Additional Inherited Members | |
| Protected Attributes inherited from MR::RectIndexer | |
| Vector2i | dims_ |
| size_t | size_ = 0 |
| = dims_.x * dims_.y | |
this class allows to store distances from the plane in particular pixels validVerts keeps only pixels with mesh-intersecting rays from them
|
default |
|
nodiscard |
Preferable constructor with resolution arguments Access by the index (i) is equal to (y*resX + x)
|
nodiscard |
make from 2d array
| void MR::DistanceMap::clear | ( | ) |
clears data, sets resolutions to zero
|
inline |
|
inline |
|
nodiscard |
returns value of index element, returns nullopt if not valid (see isValid()), UB if out of bounds.
|
nodiscard |
returns value in (X,Y) element, returns nullopt if not valid (see isValid()), UB if out of bounds.
|
nodiscard |
returns new derivatives map without directions
|
nodiscard |
finds interpolated value.
https:/// en.wikipedia.org/wiki/Bilinear_interpolation getInterpolated( 0.5f, 0.5f ) == get( 0, 0 ) see https:/// docs.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-coordinates for details all 4 elements around this point should be valid, returns nullopt if at least one is not valid
| x,y | should be in resolution range [0;resX][0;resY]. If x,y are out of bounds, returns nullopt. |
|
nodiscard |
computes single derivative map from XY spaces combined. Returns local maximums then
|
nodiscard |
finds maximum value X,Y returns [-1.-1] if all values are invalid
|
nodiscard |
finds minimum value X,Y returns [-1.-1] if all values are invalid
|
nodiscard |
finds minimum and maximum values returns min_float and max_float if all values are invalid
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
returns value in (X,Y) element without check on valid use this only if you sure that distance map has no invalid values or for serialization
|
inlinenodiscard |
|
nodiscard |
returns new derivative maps with X and Y axes direction
|
inlinenodiscard |
returns the amount of memory this object occupies on heap
| void MR::DistanceMap::invalidateAll | ( | ) |
invalidates all elements
|
inlinenodiscard |
Returns true if a flattened coordinate is in bounds.
|
inlinenodiscard |
Returns true if (X,Y) coordinates are in bounds.
|
nodiscard |
checks if index element is valid (i.e. not NOT_VALID_VALUE; passing an invalid coord to this is UB)
|
nodiscard |
checks if X,Y element is valid (i.e. not NOT_VALID_VALUE; passing invalid coords to this is UB)
|
nodiscard |
boolean operators returns new Distance Map with cell-wise maximum values. Invalid values remain only if both corresponding cells are invalid
| const DistanceMap & MR::DistanceMap::mergeMax | ( | const DistanceMap & | rhs | ) |
replaces values with cell-wise maximum values. Invalid values remain only if both corresponding cells are invalid
| const DistanceMap & MR::DistanceMap::mergeMin | ( | const DistanceMap & | rhs | ) |
replaces values with cell-wise minimum values. Invalid values remain only if both corresponding cells are invalid
|
nodiscard |
returns new Distance Map with cell-wise minimum values. Invalid values remain only if both corresponding cells are invalid
| void MR::DistanceMap::negate | ( | ) |
replaces every valid element in the map with its negative value
|
inlinenodiscard |
returns the number of pixels
|
nodiscard |
returns new Distance Map with cell-wise subtracted values. Invalid values remain only if both corresponding cells are invalid
| const DistanceMap & MR::DistanceMap::operator-= | ( | const DistanceMap & | rhs | ) |
replaces values with cell-wise subtracted values. Invalid values remain only if both corresponding cells are invalid
|
inlinenodiscard |
returns X resolution
|
inlinenodiscard |
returns Y resolution
| void MR::DistanceMap::set | ( | size_t | i, |
| float | val ) |
sets value in index element (the coord must be valid, UB otherwise)
| void MR::DistanceMap::set | ( | size_t | x, |
| size_t | y, | ||
| float | val ) |
sets value in (X,Y) element (the coords must be valid, UB otherwise)
| void MR::DistanceMap::set | ( | std::vector< float > | data | ) |
sets all values at one time
|
nodiscard |
finds 3d coordinates of the Point on the model surface for the (x,y) pixel Use the same params with distance map creation (x,y) must be in bounds, the behavior is undefined otherwise.
|
nodiscard |
finds 3d coordinates of the Point on the model surface for the (x,y) interpolated value
| x,y | should be in resolution range [0;resX][0;resY]. |
getInterpolated( 0.5f, 0.5f ) == get( 0, 0 ) see https:/// docs.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-coordinates for details all 4 elements around this point should be valid, returns nullopt if at least one is not valid If x,y are out of bounds, returns nullopt.
| void MR::DistanceMap::unset | ( | size_t | i | ) |
invalidates value in index element (the coord must be valid, UB otherwise)
| void MR::DistanceMap::unset | ( | size_t | x, |
| size_t | y ) |
invalidates value in (X,Y) element (the coords must be valid, UB otherwise)
|
staticconstexpr |
a constant that is treated as 'no value' or 'invalid value'