MeshLib C++ Docs
Loading...
Searching...
No Matches
MRFixUndercuts.h
Go to the documentation of this file.
1#pragma once
2#include "MRVoxelsFwd.h"
3
4#include "MRMesh/MRVector3.h"
5#include "MRMesh/MRVector2.h"
7#include "MRMesh/MRExpected.h"
8#include <functional>
9
10namespace MR
11{
12namespace FixUndercuts
13{
14// Changes mesh:
15// Fills all holes first, then:
16// fixes undercuts via prolonging widest points down
17// Requires to update RenderObject after using
18// upDirection is in mesh space
19// voxelSize - size of voxel in mesh rasterization, precision grows with lower voxelSize
20// bottomExtension - this parameter specifies how long should bottom prolongation be, if (bottomExtension <= 0) bottomExtension = 2*voxelSize
21// if mesh is not closed this is used to prolong hole and make bottom
22//
23// if voxelSize == 0.0f it will be counted automaticly
24[[deprecated( "Use fix( mesh, params )" )]]
25MRVOXELS_API void fixUndercuts( Mesh& mesh, const Vector3f& upDirection, float voxelSize = 0.0f, float bottomExtension = 0.0f );
26
27// Changes mesh:
28// Fills all holes first, then:
29// fixes undercuts (in selected area) via prolonging widest points down
30// Requires to update RenderObject after using
31// upDirection is in mesh space
32// voxelSize - size of voxel in mesh rasterization, precision grows with lower voxelSize
33// bottomExtension - this parameter specifies how long should bottom prolongation be, if (bottomExtension <= 0) bottomExtension = 2*voxelSize
34// if mesh is not closed this is used to prolong hole and make bottom
35//
36// if voxelSize == 0.0f it will be counted automaticly
37[[deprecated( "Use fix( mesh, params )" )]]
38MRVOXELS_API void fixUndercuts( Mesh& mesh, const FaceBitSet& selectedArea, const Vector3f& upDirection, float voxelSize = 0.0f, float bottomExtension = 0.0f );
39
42{
44 Vector3f upDirection;
45
50 float wallAngle = 0.0f;
51};
52
55{
58
60 float voxelSize = 0.0f;
61
63 float bottomExtension = 0.0f;
64
66 const FaceBitSet* region = nullptr;
67
69};
70
74
75// Input - undercut faces, insertion direction
76// Output - metric value
77using UndercutMetric = std::function<double( const FaceBitSet&, const FindParams& params )>;
78
81
84
86[[deprecated( "Use find( mesh, params)" )]]
87MRVOXELS_API void findUndercuts( const Mesh& mesh, const Vector3f& upDirection, FaceBitSet& outUndercuts );
89[[deprecated( "Use find( mesh, params )" )]]
90MRVOXELS_API void findUndercuts( const Mesh& mesh, const Vector3f& upDirection, VertBitSet& outUndercuts );
91
94[[deprecated( "Use find( mesh, params, metric )" )]]
95[[nodiscard]] MRVOXELS_API double findUndercuts( const Mesh& mesh, const Vector3f& upDirection, FaceBitSet& outUndercuts, const UndercutMetric& metric );
96
99MRVOXELS_API double find( const Mesh& mesh, const FindParams& params, FaceBitSet& outUndercuts, const UndercutMetric& metric = {} );
101MRVOXELS_API void find( const Mesh& mesh, const FindParams& params, VertBitSet& outUndercuts );
102
106[[nodiscard]] MRVOXELS_API double scoreUndercuts( const Mesh& mesh, const Vector3f& upDirection, const Vector2i& resolution );
107
109{
110 // Hint direction which will be improved
112 // Radial step given in radians look improveDirection comment
113 float baseAngleStep{5.0f*PI_F / 180.0f};
114 // Maximum radial line given in radians look improveDirection comment
115 float maxBaseAngle{30.0f*PI_F / 180.0f};
116 // Polar angle step
117 float polarAngleStep{20.0f*PI_F / 180.0f};
118};
119
121{
122 // Resolution of distance map, lower it is, faster score works
123 Vector2i distanceMapResolution{100,100};
124};
125
126// Parallel finds best of several directions defined by ImproveDirectionParameters struct
135[[nodiscard]] MRVOXELS_API Vector3f improveDirection( const Mesh& mesh, const ImproveDirectionParameters& params, const UndercutMetric& metric );
138[[nodiscard]] MRVOXELS_API Vector3f distMapImproveDirection( const Mesh& mesh, const DistMapImproveDirectionParameters& params );
139}
140}
#define MRVOXELS_API
Definition MRVoxels/MRVoxelsFwd.h:13
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:641
MRVOXELS_API double scoreUndercuts(const Mesh &mesh, const Vector3f &upDirection, const Vector2i &resolution)
MRVOXELS_API void fixUndercuts(Mesh &mesh, const Vector3f &upDirection, float voxelSize=0.0f, float bottomExtension=0.0f)
MRVOXELS_API Vector3f distMapImproveDirection(const Mesh &mesh, const DistMapImproveDirectionParameters &params)
MRVOXELS_API void findUndercuts(const Mesh &mesh, const Vector3f &upDirection, FaceBitSet &outUndercuts)
Adds to.
MRVOXELS_API UndercutMetric getUndercutAreaMetric(const Mesh &mesh)
returns the metric that computes total area of undercut faces
MRVOXELS_API Vector3f improveDirection(const Mesh &mesh, const ImproveDirectionParameters &params, const UndercutMetric &metric)
MRVOXELS_API Expected< void > fix(Mesh &mesh, const FixParams &params)
MRVOXELS_API double find(const Mesh &mesh, const FindParams &params, FaceBitSet &outUndercuts, const UndercutMetric &metric={})
MRVOXELS_API UndercutMetric getUndercutAreaProjectionMetric(const Mesh &mesh)
returns the metric that computes summed absolute projected area of undercut
std::function< double(const FaceBitSet &, const FindParams &params)> UndercutMetric
Definition MRFixUndercuts.h:77
tl::expected< T, E > Expected
Definition MRExpected.h:59
Vector2i distanceMapResolution
Definition MRFixUndercuts.h:123
Parameters that is used to find undercuts.
Definition MRFixUndercuts.h:42
float wallAngle
Definition MRFixUndercuts.h:50
Vector3f upDirection
Primitives that are not visible from up direction are considered as undercuts (fix undercuts is perfo...
Definition MRFixUndercuts.h:44
Fix undercuts function paramters.
Definition MRFixUndercuts.h:55
float bottomExtension
minimum extension of bottom part of the mesh
Definition MRFixUndercuts.h:63
ProgressCallback cb
Definition MRFixUndercuts.h:68
float voxelSize
voxel size for internal computations: lower size - better precision but more system resources require...
Definition MRFixUndercuts.h:60
FindParams findParameters
parameters of what is considered as undercut
Definition MRFixUndercuts.h:57
const FaceBitSet * region
if set - only this region will be fixed (but still all mesh will be rebuild)
Definition MRFixUndercuts.h:66
Definition MRFixUndercuts.h:109
float maxBaseAngle
Definition MRFixUndercuts.h:115
Vector3f hintDirection
Definition MRFixUndercuts.h:111
float polarAngleStep
Definition MRFixUndercuts.h:117
float baseAngleStep
Definition MRFixUndercuts.h:113
Definition MRMesh/MRMesh.h:22