41 [[nodiscard]]
bool isInBounds(
size_t x,
size_t y )
const {
return x < size_t( dims_.x ) && y < size_t( dims_.y ); }
43 [[nodiscard]]
bool isInBounds(
size_t i )
const {
return i < size_; }
46 [[nodiscard]]
MRMESH_API std::optional<float>
get(
size_t x,
size_t y )
const;
51 [[nodiscard]]
float&
getValue(
size_t x,
size_t y )
53 return data_[toIndex( { int( x ), int( y ) } )];
55 [[nodiscard]]
float getValue(
size_t x,
size_t y )
const
57 return data_[toIndex( { int( x ), int( y ) } )];
68 float*
data() {
return data_.data(); }
69 const float*
data()
const {
return data_.data(); }
85 [[nodiscard]]
MRMESH_API std::optional<Vector3f>
unproject(
size_t x,
size_t y,
const AffineXf3f& toWorld )
const;
139 [[nodiscard]]
size_t resX()
const
144 [[nodiscard]]
size_t resY()
const
172 std::vector<float> data_;
181 ProgressCallback cb = {}, std::vector<MeshTriPoint> * outSamples = nullptr );
186 ProgressCallback cb = {}, std::vector<MeshTriPoint> * outSamples = nullptr );
197 } type{ OffsetType::Shell };
212 } signMethod{ ContourOrientation };
216 const PixelBitSet* region{
nullptr };
218 std::vector<UndirectedEdgeId>* outClosestEdges{
nullptr };
222 float maxDist{ FLT_MAX };
257 const AffineXf3f& xf,
float isoValue,
bool useDepth =
false );
constexpr A operator-(A a)
Definition MRImGuiVectorOperators.h:98
constexpr A & operator-=(A &a, B b)
Definition MRImGuiVectorOperators.h:113
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDistanceMap.h:24
MRMESH_API void set(size_t i, float val)
sets value in index element (the coord must be valid, UB otherwise)
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 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...
float getValue(size_t i) const
Definition MRDistanceMap.h:63
float & getValue(size_t i)
Definition MRDistanceMap.h:59
float * data()
Definition MRDistanceMap.h:68
MRMESH_API void negate()
replaces every valid element in the map with its negative value
const float * data() const
Definition MRDistanceMap.h:69
float getValue(size_t x, size_t y) const
Definition MRDistanceMap.h:55
MRMESH_API std::pair< size_t, size_t > getMaxIndex() const
MRMESH_API DistanceMap min(const DistanceMap &rhs) const
returns new Distance Map with cell-wise minimum values. Invalid values remain only if both correspond...
MRMESH_API const DistanceMap & mergeMax(const DistanceMap &rhs)
replaces values with cell-wise maximum values. Invalid values remain only if both corresponding cells...
MRMESH_API void set(std::vector< float > data)
sets all values at one time
MRMESH_API DistanceMap(size_t resX, size_t resY)
MRMESH_API DistanceMap getDerivativeMap() const
returns new derivatives map without directions
MRMESH_API DistanceMap max(const DistanceMap &rhs) const
MRMESH_API std::pair< float, float > getMinMaxValues() const
size_t resX() const
returns X resolution
Definition MRDistanceMap.h:139
MRMESH_API std::optional< Vector3f > unproject(size_t x, size_t y, const AffineXf3f &toWorld) const
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.
MRMESH_API std::vector< std::pair< size_t, size_t > > getLocalMaximums() const
computes single derivative map from XY spaces combined. Returns local maximums then
MRMESH_API const DistanceMap & mergeMin(const DistanceMap &rhs)
replaces values with cell-wise minimum values. Invalid values remain only if both corresponding cells...
MRMESH_API std::optional< float > getInterpolated(float x, float y) const
finds interpolated value.
size_t heapBytes() const
returns the amount of memory this object occupies on heap
Definition MRDistanceMap.h:166
MRMESH_API DistanceMap(const MR::Matrix< float > &m)
make from 2d array
float & getValue(size_t x, size_t y)
Definition MRDistanceMap.h:51
MRMESH_API std::pair< DistanceMap, DistanceMap > getXYDerivativeMaps() const
returns new derivative maps with X and Y axes direction
MRMESH_API std::pair< size_t, size_t > getMinIndex() const
size_t resY() const
returns Y resolution
Definition MRDistanceMap.h:144
bool isInBounds(size_t x, size_t y) const
Returns true if (X,Y) coordinates are in bounds.
Definition MRDistanceMap.h:41
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 invalidateAll()
invalidates all elements
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 unset(size_t i)
invalidates value in index element (the coord must be valid, UB otherwise)
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
size_t numPoints() const
returns the number of pixels
Definition MRDistanceMap.h:150
MRMESH_API void clear()
clears data, sets resolutions to zero
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 c...
bool isInBounds(size_t i) const
Returns true if a flattened coordinate is in bounds.
Definition MRDistanceMap.h:43
a class for converting 2D integer coordinates into 1D linear coordinates and backward
Definition MRRectIndexer.h:38
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:20
size_t heapBytes(const std::vector< T > &vec)
returns the amount of memory given vector occupies on heap
Definition MRHeapBytes.h:15
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:576
MRMESH_API std::vector< Vector3f > edgePointsFromContours(const Polyline2 &polyline, float pixelSize, float threshold)
MRMESH_API Expected< Mesh > distanceMapToMesh(const DistanceMap &distMap, const AffineXf3f &toWorld, ProgressCallback cb={})
converts distance map into mesh and applies a transformation to all points
MRMESH_API DistanceMap combineXYderivativeMaps(std::pair< DistanceMap, DistanceMap > XYderivativeMaps)
fill another distance map pair with gradients across X and Y axes of the argument map
MRMESH_API Polyline2 contourUnion(const Polyline2 &contoursA, const Polyline2 &contoursB, const ContourToDistanceMapParams ¶ms, float offsetInside=0)
computes the union of the shapes bounded by input 2d contours
MRMESH_API DistanceMap distanceMapFromContours(const Polyline2 &contours, const ContourToDistanceMapParams ¶ms, const ContoursDistanceMapOptions &options={})
Computes distance of 2d contours according ContourToDistanceMapParams.
MRMESH_API Polyline2 contourIntersection(const Polyline2 &contoursA, const Polyline2 &contoursB, const ContourToDistanceMapParams ¶ms, float offsetInside=0.f)
computes the intersection of the shapes bounded by input 2d contours
MRMESH_API DistanceMap computeDistanceMapD(const MeshPart &mp, const MeshToDistanceMapParams ¶ms, ProgressCallback cb={}, std::vector< MeshTriPoint > *outSamples=nullptr)
MRMESH_API Polyline2 distanceMapTo2DIsoPolyline(const DistanceMap &distMap, float isoValue)
MRMESH_API Polyline2 contourSubtract(const Polyline2 &contoursA, const Polyline2 &contoursB, const ContourToDistanceMapParams ¶ms, float offsetInside=0.f)
computes the difference between the shapes bounded by contoursA and the shapes bounded by contoursB
MRMESH_API Expected< DistanceMap > convertImageToDistanceMap(const Image &image, float threshold=1.f/255)
MRMESH_API Image convertDistanceMapToImage(const DistanceMap &distMap, float threshold=1.f/255)
MRMESH_API Polyline2 polylineOffset(const Polyline2 &polyline, float pixelSize, float offset)
constructs an offset contour for given polyline
MRMESH_API DistanceMap computeDistanceMap(const MeshPart &mp, const MeshToDistanceMapParams ¶ms, ProgressCallback cb={}, std::vector< MeshTriPoint > *outSamples=nullptr)
Definition MRCameraOrientationPlugin.h:8
@ WindingRule
ray intersection counter, significantly slower than ProjectionNormal and does not support holes in me...
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
tl::expected< T, E > Expected
Definition MRExpected.h:58
Structure with parameters to generate DistanceMap by Contours.
Definition MRDistanceMapParams.h:94
Structure with parameters for optional offset in distanceMapFromContours function.
Definition MRDistanceMap.h:190
const Vector< float, UndirectedEdgeId > & perEdgeOffset
offset values for each undirected edge of given polyline
Definition MRDistanceMap.h:192
OffsetType
Definition MRDistanceMap.h:194
Definition MRDistanceMap.h:201
SignedDetectionMethod
method to calculate sign
Definition MRDistanceMap.h:204
@ ContourOrientation
Definition MRDistanceMap.h:208
Definition MRDistanceMapParams.h:17