MeshLib Documentation
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 <functional>
8
9namespace MR
10{
11namespace FixUndercuts
12{
13// Changes mesh:
14// Fills all holes first, then:
15// fixes undercuts via prolonging widest points down
16// Requires to update RenderObject after using
17// upDirection is in mesh space
18// voxelSize - size of voxel in mesh rasterization, precision grows with lower voxelSize
19// bottomExtension - this parameter specifies how long should bottom prolongation be, if (bottomExtension <= 0) bottomExtension = 2*voxelSize
20// if mesh is not closed this is used to prolong hole and make bottom
21//
22// if voxelSize == 0.0f it will be counted automaticly
23MRVOXELS_API void fixUndercuts( Mesh& mesh, const Vector3f& upDirection, float voxelSize = 0.0f, float bottomExtension = 0.0f );
24
25// Changes mesh:
26// Fills all holes first, then:
27// fixes undercuts (in selected area) via prolonging widest points down
28// Requires to update RenderObject after using
29// upDirection is in mesh space
30// voxelSize - size of voxel in mesh rasterization, precision grows with lower voxelSize
31// bottomExtension - this parameter specifies how long should bottom prolongation be, if (bottomExtension <= 0) bottomExtension = 2*voxelSize
32// if mesh is not closed this is used to prolong hole and make bottom
33//
34// if voxelSize == 0.0f it will be counted automaticly
35MRVOXELS_API void fixUndercuts( Mesh& mesh, const FaceBitSet& selectedArea, const Vector3f& upDirection, float voxelSize = 0.0f, float bottomExtension = 0.0f );
36
37// Input - undercut faces, insertion direction
38// Output - metric value
39using UndercutMetric = std::function<double( const FaceBitSet&, const Vector3f& upDir )>;
40
43
46
48MRVOXELS_API void findUndercuts( const Mesh& mesh, const Vector3f& upDirection, FaceBitSet& outUndercuts );
50MRVOXELS_API void findUndercuts( const Mesh& mesh, const Vector3f& upDirection, VertBitSet& outUndercuts );
51
54[[nodiscard]] MRVOXELS_API double findUndercuts( const Mesh& mesh, const Vector3f& upDirection, FaceBitSet& outUndercuts, const UndercutMetric& metric );
55
56// Fast score undercuts projected area via distance map with given resolution
57// lower resolution means lower precision, but faster work
58[[nodiscard]] MRVOXELS_API double scoreUndercuts( const Mesh& mesh, const Vector3f& upDirection, const Vector2i& resolution );
59
61{
62 // Hint direction which will be improved
63 Vector3f hintDirection;
64 // Radial step given in radians look improveDirection comment
65 float baseAngleStep{5.0f*PI_F / 180.0f};
66 // Maximum radial line given in radians look improveDirection comment
67 float maxBaseAngle{30.0f*PI_F / 180.0f};
68 // Polar angle step
69 float polarAngleStep{20.0f*PI_F / 180.0f};
70};
71
73{
74 // Resolution of distance map, lower it is, faster score works
75 Vector2i distanceMapResolution{100,100};
76};
77
78// Parallel finds best of several directions defined by ImproveDirectionParameters struct
79// ________
80// Top view: / \__/ \-----> maximum radial line Side view: | / _/
81// / / \/ \ \ | / _/ - maxBaseAngle
82// |--|------|--| | / _/ difference between two angles is baseAngleStep
83// \ \_/\_/ / | / _/
84// \__/__\__/ |/_/
85// This picture shows polarAngle = 60 deg
86[[nodiscard]] MRVOXELS_API Vector3f improveDirection( const Mesh& mesh, const ImproveDirectionParameters& params, const UndercutMetric& metric );
87// Score candidates with distance maps, lower resolution -> faster score
88[[nodiscard]] MRVOXELS_API Vector3f distMapImproveDirection( const Mesh& mesh, const DistMapImproveDirectionParameters& params );
89}
90}
#define MRVOXELS_API
Definition MRVoxelsFwd.h:13
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)
std::function< double(const FaceBitSet &, const Vector3f &upDir)> UndercutMetric
Definition MRFixUndercuts.h:39
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 UndercutMetric getUndercutAreaProjectionMetric(const Mesh &mesh)
returns the metric that computes summed absolute area of undercut faces as visible if look from upDir
Definition MRCameraOrientationPlugin.h:8
Vector2i distanceMapResolution
Definition MRFixUndercuts.h:75
Definition MRFixUndercuts.h:61
float maxBaseAngle
Definition MRFixUndercuts.h:67
Vector3f hintDirection
Definition MRFixUndercuts.h:63
float polarAngleStep
Definition MRFixUndercuts.h:69
float baseAngleStep
Definition MRFixUndercuts.h:65
Definition MRMesh/MRMesh.h:23