#include <MRDistanceMap.h>
Public Member Functions | |
DistanceMap ()=default | |
MRMESH_API | DistanceMap (size_t resX, size_t resY) |
MRMESH_API | DistanceMap (const MR::Matrix< float > &m) |
make from 2d array | |
MRMESH_API bool | isValid (size_t x, size_t y) const |
checks if X,Y element is valid (i.e. not std::numeric_limits<float>::lowest() ; passing invalid coords to this is UB) | |
MRMESH_API bool | isValid (size_t i) const |
checks if index element is valid (i.e. not std::numeric_limits<float>::lowest() ; 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. | |
MRMESH_API 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. | |
MRMESH_API 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 |
MRMESH_API std::optional< float > | getInterpolated (float x, float y) const |
finds interpolated value. | |
MRMESH_API std::optional< Vector3f > | unproject (size_t x, size_t y, const AffineXf3f &toWorld) const |
MRMESH_API 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 | |
MRMESH_API void | negate () |
replaces every valid element in the map with its negative value | |
MRMESH_API DistanceMap | max (const DistanceMap &rhs) const |
MRMESH_API const DistanceMap & | mergeMax (const DistanceMap &rhs) |
replaces values with cell-wise maximum values. Invalid values remain only if both corresponding cells are invalid | |
MRMESH_API 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 | |
MRMESH_API const DistanceMap & | mergeMin (const DistanceMap &rhs) |
replaces values with cell-wise minimum values. Invalid values remain only if both corresponding cells are invalid | |
MRMESH_API 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 | |
MRMESH_API const DistanceMap & | operator-= (const DistanceMap &rhs) |
replaces values with cell-wise subtracted values. Invalid values remain only if both corresponding cells are invalid | |
MRMESH_API void | set (size_t x, size_t y, float val) |
sets value in (X,Y) element (the coords must be valid, UB otherwise) | |
MRMESH_API void | set (size_t i, float val) |
sets value in index element (the coord must be valid, UB otherwise) | |
MRMESH_API void | set (std::vector< float > data) |
sets all values at one time | |
MRMESH_API void | unset (size_t x, size_t y) |
invalidates value in (X,Y) element (the coords must be valid, UB otherwise) | |
MRMESH_API void | unset (size_t i) |
invalidates value in index element (the coord must be valid, UB otherwise) | |
MRMESH_API void | invalidateAll () |
invalidates all elements | |
MRMESH_API void | clear () |
clears data, sets resolutions to zero | |
MRMESH_API DistanceMap | getDerivativeMap () const |
returns new derivatives map without directions | |
MRMESH_API std::pair< DistanceMap, DistanceMap > | getXYDerivativeMaps () const |
returns new derivative maps with X and Y axes direction | |
MRMESH_API 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 | |
MRMESH_API std::pair< float, float > | getMinMaxValues () const |
MRMESH_API std::pair< size_t, size_t > | getMinIndex () const |
MRMESH_API 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 | |
MRMESH_API PixelId | getNeighbor (PixelId v, const Vector2i &pos, OutEdge2 toNei) const |
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
MRMESH_API 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
MRMESH_API 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 std::numeric_limits<float>::lowest()
; passing an invalid coord to this is UB)
|
nodiscard |
checks if X,Y element is valid (i.e. not std::numeric_limits<float>::lowest()
; 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
MRMESH_API 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
MRMESH_API 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
MRMESH_API 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
MRMESH_API 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
MRMESH_API void MR::DistanceMap::set | ( | size_t | i, |
float | val ) |
sets value in index element (the coord must be valid, UB otherwise)
MRMESH_API 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)
MRMESH_API 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.
MRMESH_API void MR::DistanceMap::unset | ( | size_t | i | ) |
invalidates value in index element (the coord must be valid, UB otherwise)
MRMESH_API void MR::DistanceMap::unset | ( | size_t | x, |
size_t | y ) |
invalidates value in (X,Y) element (the coords must be valid, UB otherwise)