MeshLib C++ Docs
Loading...
Searching...
No Matches

#include <MRMesh/MRDistanceMap.h>

Inheritance diagram for MR::DistanceMap:

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 DistanceMapmergeMax (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 DistanceMapmergeMin (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 DistanceMapoperator-= (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, DistanceMapgetXYDerivativeMaps () 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

Detailed Description

this class allows to store distances from the plane in particular pixels validVerts keeps only pixels with mesh-intersecting rays from them

Constructor & Destructor Documentation

◆ DistanceMap() [1/3]

MR::DistanceMap::DistanceMap ( )
default

◆ DistanceMap() [2/3]

MR::DistanceMap::DistanceMap ( size_t resX,
size_t resY )
nodiscard

Preferable constructor with resolution arguments Access by the index (i) is equal to (y*resX + x)

◆ DistanceMap() [3/3]

MR::DistanceMap::DistanceMap ( const MR::Matrix< float > & m)
nodiscard

make from 2d array

Member Function Documentation

◆ clear()

void MR::DistanceMap::clear ( )

clears data, sets resolutions to zero

◆ data() [1/2]

float * MR::DistanceMap::data ( )
inline

◆ data() [2/2]

const float * MR::DistanceMap::data ( ) const
inline

◆ get() [1/2]

std::optional< float > MR::DistanceMap::get ( size_t i) const
nodiscard

returns value of index element, returns nullopt if not valid (see isValid()), UB if out of bounds.

◆ get() [2/2]

std::optional< float > MR::DistanceMap::get ( size_t x,
size_t y ) const
nodiscard

returns value in (X,Y) element, returns nullopt if not valid (see isValid()), UB if out of bounds.

◆ getDerivativeMap()

DistanceMap MR::DistanceMap::getDerivativeMap ( ) const
nodiscard

returns new derivatives map without directions

◆ getInterpolated()

std::optional< float > MR::DistanceMap::getInterpolated ( float x,
float y ) const
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

Parameters
x,yshould be in resolution range [0;resX][0;resY]. If x,y are out of bounds, returns nullopt.

◆ getLocalMaximums()

std::vector< std::pair< size_t, size_t > > MR::DistanceMap::getLocalMaximums ( ) const
nodiscard

computes single derivative map from XY spaces combined. Returns local maximums then

◆ getMaxIndex()

std::pair< size_t, size_t > MR::DistanceMap::getMaxIndex ( ) const
nodiscard

finds maximum value X,Y returns [-1.-1] if all values are invalid

◆ getMinIndex()

std::pair< size_t, size_t > MR::DistanceMap::getMinIndex ( ) const
nodiscard

finds minimum value X,Y returns [-1.-1] if all values are invalid

◆ getMinMaxValues()

std::pair< float, float > MR::DistanceMap::getMinMaxValues ( ) const
nodiscard

finds minimum and maximum values returns min_float and max_float if all values are invalid

◆ getValue() [1/4]

float & MR::DistanceMap::getValue ( size_t i)
inlinenodiscard

◆ getValue() [2/4]

float MR::DistanceMap::getValue ( size_t i) const
inlinenodiscard

◆ getValue() [3/4]

float & MR::DistanceMap::getValue ( size_t x,
size_t y )
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

◆ getValue() [4/4]

float MR::DistanceMap::getValue ( size_t x,
size_t y ) const
inlinenodiscard

◆ getXYDerivativeMaps()

std::pair< DistanceMap, DistanceMap > MR::DistanceMap::getXYDerivativeMaps ( ) const
nodiscard

returns new derivative maps with X and Y axes direction

◆ heapBytes()

size_t MR::DistanceMap::heapBytes ( ) const
inlinenodiscard

returns the amount of memory this object occupies on heap

◆ invalidateAll()

void MR::DistanceMap::invalidateAll ( )

invalidates all elements

◆ isInBounds() [1/2]

bool MR::DistanceMap::isInBounds ( size_t i) const
inlinenodiscard

Returns true if a flattened coordinate is in bounds.

◆ isInBounds() [2/2]

bool MR::DistanceMap::isInBounds ( size_t x,
size_t y ) const
inlinenodiscard

Returns true if (X,Y) coordinates are in bounds.

◆ isValid() [1/2]

bool MR::DistanceMap::isValid ( size_t i) const
nodiscard

checks if index element is valid (i.e. not NOT_VALID_VALUE; passing an invalid coord to this is UB)

◆ isValid() [2/2]

bool MR::DistanceMap::isValid ( size_t x,
size_t y ) const
nodiscard

checks if X,Y element is valid (i.e. not NOT_VALID_VALUE; passing invalid coords to this is UB)

◆ max()

DistanceMap MR::DistanceMap::max ( const DistanceMap & rhs) const
nodiscard

boolean operators returns new Distance Map with cell-wise maximum values. Invalid values remain only if both corresponding cells are invalid

◆ mergeMax()

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

◆ mergeMin()

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

◆ min()

DistanceMap MR::DistanceMap::min ( const DistanceMap & rhs) const
nodiscard

returns new Distance Map with cell-wise minimum values. Invalid values remain only if both corresponding cells are invalid

◆ negate()

void MR::DistanceMap::negate ( )

replaces every valid element in the map with its negative value

◆ numPoints()

size_t MR::DistanceMap::numPoints ( ) const
inlinenodiscard

returns the number of pixels

◆ operator-()

DistanceMap MR::DistanceMap::operator- ( const DistanceMap & rhs) const
nodiscard

returns new Distance Map with cell-wise subtracted values. Invalid values remain only if both corresponding cells are invalid

◆ operator-=()

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

◆ resX()

size_t MR::DistanceMap::resX ( ) const
inlinenodiscard

returns X resolution

◆ resY()

size_t MR::DistanceMap::resY ( ) const
inlinenodiscard

returns Y resolution

◆ set() [1/3]

void MR::DistanceMap::set ( size_t i,
float val )

sets value in index element (the coord must be valid, UB otherwise)

◆ set() [2/3]

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)

◆ set() [3/3]

void MR::DistanceMap::set ( std::vector< float > data)

sets all values at one time

◆ unproject()

std::optional< Vector3f > MR::DistanceMap::unproject ( size_t x,
size_t y,
const AffineXf3f & toWorld ) const
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.

◆ unprojectInterpolated()

std::optional< Vector3f > MR::DistanceMap::unprojectInterpolated ( float x,
float y,
const AffineXf3f & toWorld ) const
nodiscard

finds 3d coordinates of the Point on the model surface for the (x,y) interpolated value

Parameters
x,yshould 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.

◆ unset() [1/2]

void MR::DistanceMap::unset ( size_t i)

invalidates value in index element (the coord must be valid, UB otherwise)

◆ unset() [2/2]

void MR::DistanceMap::unset ( size_t x,
size_t y )

invalidates value in (X,Y) element (the coords must be valid, UB otherwise)

Member Data Documentation

◆ NOT_VALID_VALUE

float MR::DistanceMap::NOT_VALID_VALUE = std::numeric_limits<float>::lowest()
staticconstexpr

a constant that is treated as 'no value' or 'invalid value'


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