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 MR_BIND_IGNORE Expected<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 MR_BIND_IGNORE Expected<void> fixUndercuts( Mesh& mesh, const FaceBitSet& selectedArea, const Vector3f& upDirection, float voxelSize = 0.0f, float bottomExtension = 0.0f );
39
41struct FindParams
42{
45
50 float wallAngle = 0.0f;
51};
52
54struct FixParams
55{
57 FindParams findParameters;
58
60 float voxelSize = 0.0f;
61
63 float bottomExtension = 0.0f;
64
66 const FaceBitSet* region = nullptr;
67
69 bool smooth = false;
70
71 ProgressCallback cb;
72};
73
76MRVOXELS_API Expected<void> fix( Mesh& mesh, const FixParams& params );
77
78// Input - undercut faces, insertion direction
79// Output - metric value
80using UndercutMetric = std::function<double( const FaceBitSet&, const FindParams& params )>;
81
83[[nodiscard]] MRVOXELS_API UndercutMetric getUndercutAreaMetric( const Mesh& mesh );
84
86[[nodiscard]] MRVOXELS_API UndercutMetric getUndercutAreaProjectionMetric( const Mesh& mesh );
87
89[[deprecated( "Use find( mesh, params)" )]]
90MRVOXELS_API MR_BIND_IGNORE void findUndercuts( const Mesh& mesh, const Vector3f& upDirection, FaceBitSet& outUndercuts );
92[[deprecated( "Use find( mesh, params )" )]]
93MRVOXELS_API MR_BIND_IGNORE void findUndercuts( const Mesh& mesh, const Vector3f& upDirection, VertBitSet& outUndercuts );
94
97[[deprecated( "Use find( mesh, params, metric )" )]]
98[[nodiscard]] MRVOXELS_API MR_BIND_IGNORE double findUndercuts( const Mesh& mesh, const Vector3f& upDirection, FaceBitSet& outUndercuts, const UndercutMetric& metric );
99
102MRVOXELS_API double find( const Mesh& mesh, const FindParams& params, FaceBitSet& outUndercuts, const UndercutMetric& metric = {} );
104MRVOXELS_API void find( const Mesh& mesh, const FindParams& params, VertBitSet& outUndercuts );
105
109[[nodiscard]] MRVOXELS_API double scoreUndercuts( const Mesh& mesh, const Vector3f& upDirection, const Vector2i& resolution );
110
112{
113 // Hint direction which will be improved
114 Vector3f hintDirection;
115 // Radial step given in radians look improveDirection comment
116 float baseAngleStep{5.0f*PI_F / 180.0f};
117 // Maximum radial line given in radians look improveDirection comment
118 float maxBaseAngle{30.0f*PI_F / 180.0f};
119 // Polar angle step
120 float polarAngleStep{20.0f*PI_F / 180.0f};
121};
122
123struct DistMapImproveDirectionParameters : ImproveDirectionParameters
124{
125 // Resolution of distance map, lower it is, faster score works
126 Vector2i distanceMapResolution{100,100};
127};
128
129// Parallel finds best of several directions defined by ImproveDirectionParameters struct
138[[nodiscard]] MRVOXELS_API Vector3f improveDirection( const Mesh& mesh, const ImproveDirectionParameters& params, const UndercutMetric& metric );
142}
143}
#define MRVOXELS_API
Definition MRVoxelsFwd.h:14
Definition MRFixUndercuts.h:42
new unsafe ref float wallAngle
new unsafe ref MR.Vector3f upDirection
Definition MRFixUndercuts.h:55
new unsafe MR.? Const_FaceBitSet region
new unsafe ref float voxelSize
new unsafe ref bool smooth
new unsafe ref float bottomExtension
new unsafe MR.FixUndercuts.FindParams findParameters
Definition MRFixUndercuts.h:112
Definition MRMesh/MRMesh.h:23
MRVOXELS_API double scoreUndercuts(const Mesh &mesh, const Vector3f &upDirection, const Vector2i &resolution)
MRVOXELS_API Vector3f distMapImproveDirection(const Mesh &mesh, const DistMapImproveDirectionParameters &params)
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
MRVOXELS_API MR_BIND_IGNORE void findUndercuts(const Mesh &mesh, const Vector3f &upDirection, FaceBitSet &outUndercuts)
Adds to.
MRVOXELS_API MR_BIND_IGNORE Expected< void > fixUndercuts(Mesh &mesh, const Vector3f &upDirection, float voxelSize=0.0f, float bottomExtension=0.0f)
Definition MRCameraOrientationPlugin.h:8