MeshLib
 
Loading...
Searching...
No Matches
Distance Map group

Classes

class  MR::DistanceMap
 
struct  MR::ContoursDistanceMapOffset
 Structure with parameters for optional offset in distanceMapFromContours function. More...
 
struct  MR::ContoursDistanceMapOptions
 
struct  MR::MeshToDistanceMapParams
 
struct  MR::ContourToDistanceMapParams
 Structure with parameters to generate DistanceMap by Contours. More...
 
struct  MR::DistanceMapToWorld
 This structure store data to transform distance map to world coordinates. More...
 
class  MR::RectIndexer
 a class for converting 2D integer coordinates into 1D linear coordinates and backward More...
 

Enumerations

enum class  MR::OutEdge2 : signed char {
  MR::OutEdge2::Invalid = -1 , MR::OutEdge2::PlusY , MR::OutEdge2::MinusY , MR::OutEdge2::PlusX ,
  MR::OutEdge2::MinusX , MR::OutEdge2::Count
}
 

Functions

MRMESH_API DistanceMap MR::combineXYderivativeMaps (std::pair< DistanceMap, DistanceMap > XYderivativeMaps)
 fill another distance map pair with gradients across X and Y axes of the argument map
 
MRMESH_API DistanceMap MR::computeDistanceMap (const MeshPart &mp, const MeshToDistanceMapParams &params, ProgressCallback cb={}, std::vector< MeshTriPoint > *outSamples=nullptr)
 
MRMESH_API DistanceMap MR::computeDistanceMapD (const MeshPart &mp, const MeshToDistanceMapParams &params, ProgressCallback cb={}, std::vector< MeshTriPoint > *outSamples=nullptr)
 
MRMESH_API DistanceMap MR::distanceMapFromContours (const Polyline2 &contours, const ContourToDistanceMapParams &params, const ContoursDistanceMapOptions &options={})
 Computes distance of 2d contours according ContourToDistanceMapParams.
 
MRMESH_API void MR::distanceMapFromContours (DistanceMap &distMap, const Polyline2 &polyline, const ContourToDistanceMapParams &params, const ContoursDistanceMapOptions &options={})
 Computes distance of 2d contours according ContourToDistanceMapParams.
 
MRMESH_API std::vector< Vector3fMR::edgePointsFromContours (const Polyline2 &polyline, float pixelSize, float threshold)
 
MRMESH_API Polyline2 MR::distanceMapTo2DIsoPolyline (const DistanceMap &distMap, float isoValue)
 
MRMESH_API Polyline2 MR::distanceMapTo2DIsoPolyline (const DistanceMap &distMap, const ContourToDistanceMapParams &params, float isoValue)
 iso-lines are created in real space ( plane OXY with parameters according ContourToDistanceMapParams )
 
MRMESH_API std::pair< Polyline2, AffineXf3fMR::distanceMapTo2DIsoPolyline (const DistanceMap &distMap, const AffineXf3f &xf, float isoValue, bool useDepth=false)
 
MRMESH_API Polyline2 MR::distanceMapTo2DIsoPolyline (const DistanceMap &distMap, float pixelSize, float isoValue)
 
MRMESH_API Polyline2 MR::polylineOffset (const Polyline2 &polyline, float pixelSize, float offset)
 constructs an offset contour for given polyline
 
MRMESH_API Polyline2 MR::contourUnion (const Polyline2 &contoursA, const Polyline2 &contoursB, const ContourToDistanceMapParams &params, float offsetInside=0)
 computes the union of the shapes bounded by input 2d contours
 
MRMESH_API Polyline2 MR::contourIntersection (const Polyline2 &contoursA, const Polyline2 &contoursB, const ContourToDistanceMapParams &params, float offsetInside=0.f)
 computes the intersection of the shapes bounded by input 2d contours
 
MRMESH_API Polyline2 MR::contourSubtract (const Polyline2 &contoursA, const Polyline2 &contoursB, const ContourToDistanceMapParams &params, float offsetInside=0.f)
 computes the difference between the shapes bounded by contoursA and the shapes bounded by contoursB
 
MRMESH_API Expected< MeshMR::distanceMapToMesh (const DistanceMap &distMap, const AffineXf3f &toWorld, ProgressCallback cb={})
 converts distance map into mesh and applies a transformation to all points
 
MRMESH_API Image MR::convertDistanceMapToImage (const DistanceMap &distMap, float threshold=1.f/255)
 
MRMESH_API VoidOrErrStr MR::saveDistanceMapToImage (const DistanceMap &distMap, const std::filesystem::path &filename, float threshold=1.f/255)
 
MRMESH_API Expected< DistanceMapMR::convertImageToDistanceMap (const Image &image, float threshold=1.f/255)
 
MRMESH_API Expected< DistanceMapMR::loadDistanceMapFromImage (const std::filesystem::path &filename, float threshold=1.f/255)
 
OutEdge2 MR::opposite (OutEdge2 e)
 
MRMESH_API void MR::expandPixelMask (PixelBitSet &mask, const RectIndexer &indexer, int expansion=1)
 expands PixelBitSet with given number of steps
 
MRMESH_API void MR::shrinkPixelMask (PixelBitSet &mask, const RectIndexer &indexer, int shrinkage=1)
 shrinks PixelBitSet with given number of steps
 
 MR::RectIndexer::RectIndexer (const Vector2i &dims)
 
void MR::RectIndexer::resize (const Vector2i &dims)
 
Vector2i MR::RectIndexer::toPos (size_t id) const
 
size_t MR::RectIndexer::toIndex (const Vector2i &pos) const
 

Detailed Description

Enumeration Type Documentation

◆ OutEdge2

enum class MR::OutEdge2 : signed char
strong
Enumerator
Invalid 
PlusY 
MinusY 
PlusX 
MinusX 
Count 

Function Documentation

◆ combineXYderivativeMaps()

MRMESH_API DistanceMap MR::combineXYderivativeMaps ( std::pair< DistanceMap, DistanceMap > XYderivativeMaps)

fill another distance map pair with gradients across X and Y axes of the argument map

◆ computeDistanceMap()

MRMESH_API DistanceMap MR::computeDistanceMap ( const MeshPart & mp,
const MeshToDistanceMapParams & params,
ProgressCallback cb = {},
std::vector< MeshTriPoint > * outSamples = nullptr )

computes distance (height) map for given projection parameters using float-precision for finding ray-mesh intersections, which is faster but less reliable

◆ computeDistanceMapD()

MRMESH_API DistanceMap MR::computeDistanceMapD ( const MeshPart & mp,
const MeshToDistanceMapParams & params,
ProgressCallback cb = {},
std::vector< MeshTriPoint > * outSamples = nullptr )

computes distance (height) map for given projection parameters using double-precision for finding ray-mesh intersections, which is slower but more reliable

◆ contourIntersection()

MRMESH_API Polyline2 MR::contourIntersection ( const Polyline2 & contoursA,
const Polyline2 & contoursB,
const ContourToDistanceMapParams & params,
float offsetInside = 0.f )
nodiscard

computes the intersection of the shapes bounded by input 2d contours

Returns
the boundary of the intersection

input contours must be closed within the area of distance map and be consistently oriented (clockwise, that is leaving the bounded shapes from the left). the value of params.withSign must be true (checked with assert() inside the function)

Note
that polyline topology should be consistently oriented

◆ contourSubtract()

MRMESH_API Polyline2 MR::contourSubtract ( const Polyline2 & contoursA,
const Polyline2 & contoursB,
const ContourToDistanceMapParams & params,
float offsetInside = 0.f )
nodiscard

computes the difference between the shapes bounded by contoursA and the shapes bounded by contoursB

Returns
the boundary of the difference

input contours must be closed within the area of distance map and be consistently oriented (clockwise, that is leaving the bounded shapes from the left). the value of params.withSign must be true (checked with assert() inside the function)

Note
that polyline topology should be consistently oriented

◆ contourUnion()

MRMESH_API Polyline2 MR::contourUnion ( const Polyline2 & contoursA,
const Polyline2 & contoursB,
const ContourToDistanceMapParams & params,
float offsetInside = 0 )
nodiscard

computes the union of the shapes bounded by input 2d contours

Returns
the boundary of the union

input contours must be closed within the area of distance map and be consistently oriented (clockwise, that is leaving the bounded shapes from the left). the value of params.withSign must be true (checked with assert() inside the function)

Note
that polyline topology should be consistently oriented

◆ convertDistanceMapToImage()

MRMESH_API Image MR::convertDistanceMapToImage ( const DistanceMap & distMap,
float threshold = 1.f/255 )
nodiscard

export distance map to a grayscale image

Parameters
threshold- threshold of valid values [0.; 1.]. pixel with color less then threshold set invalid

◆ convertImageToDistanceMap()

MRMESH_API Expected< DistanceMap > MR::convertImageToDistanceMap ( const Image & image,
float threshold = 1.f/255 )
nodiscard

load distance map from a grayscale image:

Parameters
threshold- threshold of valid values [0.; 1.]. pixel with color less then threshold set invalid

◆ distanceMapFromContours() [1/2]

MRMESH_API DistanceMap MR::distanceMapFromContours ( const Polyline2 & contours,
const ContourToDistanceMapParams & params,
const ContoursDistanceMapOptions & options = {} )
nodiscard

Computes distance of 2d contours according ContourToDistanceMapParams.

Parameters
options- optional input and output options for distance map calculation, find more ContoursDistanceMapOptions

◆ distanceMapFromContours() [2/2]

MRMESH_API void MR::distanceMapFromContours ( DistanceMap & distMap,
const Polyline2 & polyline,
const ContourToDistanceMapParams & params,
const ContoursDistanceMapOptions & options = {} )

Computes distance of 2d contours according ContourToDistanceMapParams.

Parameters
distMap- preallocated distance map
options- optional input and output options for distance map calculation, find more ContoursDistanceMapOptions

◆ distanceMapTo2DIsoPolyline() [1/4]

MRMESH_API std::pair< Polyline2, AffineXf3f > MR::distanceMapTo2DIsoPolyline ( const DistanceMap & distMap,
const AffineXf3f & xf,
float isoValue,
bool useDepth = false )
nodiscard

computes iso-lines of distance map corresponding to given iso-value; in second returns the transformation from 0XY plane to world;

Parameters
useDepthtrue - the isolines will be located on distance map surface, false - isolines for any iso-value will be located on the common plane xf(0XY)

◆ distanceMapTo2DIsoPolyline() [2/4]

MRMESH_API Polyline2 MR::distanceMapTo2DIsoPolyline ( const DistanceMap & distMap,
const ContourToDistanceMapParams & params,
float isoValue )
nodiscard

iso-lines are created in real space ( plane OXY with parameters according ContourToDistanceMapParams )

◆ distanceMapTo2DIsoPolyline() [3/4]

MRMESH_API Polyline2 MR::distanceMapTo2DIsoPolyline ( const DistanceMap & distMap,
float isoValue )
nodiscard

converts distance map to 2d iso-lines: iso-lines are created in space DistanceMap ( plane OXY with pixelSize = (1, 1) )

◆ distanceMapTo2DIsoPolyline() [4/4]

MRMESH_API Polyline2 MR::distanceMapTo2DIsoPolyline ( const DistanceMap & distMap,
float pixelSize,
float isoValue )
nodiscard

◆ distanceMapToMesh()

MRMESH_API Expected< Mesh > MR::distanceMapToMesh ( const DistanceMap & distMap,
const AffineXf3f & toWorld,
ProgressCallback cb = {} )
nodiscard

converts distance map into mesh and applies a transformation to all points

◆ edgePointsFromContours()

MRMESH_API std::vector< Vector3f > MR::edgePointsFromContours ( const Polyline2 & polyline,
float pixelSize,
float threshold )
nodiscard

Makes distance map and filter out pixels with large (>threshold) distance between closest points on contour in neighbor pixels Converts such points back in 3d space and return

Note
that polyline topology should be consistently oriented

◆ expandPixelMask()

MRMESH_API void MR::expandPixelMask ( PixelBitSet & mask,
const RectIndexer & indexer,
int expansion = 1 )

expands PixelBitSet with given number of steps

◆ loadDistanceMapFromImage()

MRMESH_API Expected< DistanceMap > MR::loadDistanceMapFromImage ( const std::filesystem::path & filename,
float threshold = 1.f/255 )
nodiscard

load distance map from a grayscale image file

Parameters
threshold- threshold of valid values [0.; 1.]. pixel with color less then threshold set invalid

◆ opposite()

OutEdge2 MR::opposite ( OutEdge2 e)
inline

◆ polylineOffset()

MRMESH_API Polyline2 MR::polylineOffset ( const Polyline2 & polyline,
float pixelSize,
float offset )
nodiscard

constructs an offset contour for given polyline

◆ RectIndexer()

MR::RectIndexer::RectIndexer ( const Vector2i & dims)
inline

◆ resize()

void MR::RectIndexer::resize ( const Vector2i & dims)
inline

◆ saveDistanceMapToImage()

MRMESH_API VoidOrErrStr MR::saveDistanceMapToImage ( const DistanceMap & distMap,
const std::filesystem::path & filename,
float threshold = 1.f/255 )

saves distance map to a grayscale image file

Parameters
threshold- threshold of maximum values [0.; 1.]. invalid pixel set as 0. (black) minimum (close): 1.0 (white) maximum (far): threshold invalid (infinity): 0.0 (black)

◆ shrinkPixelMask()

MRMESH_API void MR::shrinkPixelMask ( PixelBitSet & mask,
const RectIndexer & indexer,
int shrinkage = 1 )

shrinks PixelBitSet with given number of steps

◆ toIndex()

size_t MR::RectIndexer::toIndex ( const Vector2i & pos) const
inline

◆ toPos()

Vector2i MR::RectIndexer::toPos ( size_t id) const
inline