MeshLib
 
Loading...
Searching...
No Matches
MRFixUndercuts.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#ifndef MRMESH_NO_OPENVDB
4#include "MRVector3.h"
5#include "MRVector2.h"
6#include "MRConstants.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
23MRMESH_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
35MRMESH_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
48MRMESH_API void findUndercuts( const Mesh& mesh, const Vector3f& upDirection, FaceBitSet& outUndercuts );
50MRMESH_API void findUndercuts( const Mesh& mesh, const Vector3f& upDirection, VertBitSet& outUndercuts );
51
54[[nodiscard]] MRMESH_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]] MRMESH_API double scoreUndercuts( const Mesh& mesh, const Vector3f& upDirection, const Vector2i& resolution );
59
61{
62 // Hint direction which will be improved
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]] MRMESH_API Vector3f improveDirection( const Mesh& mesh, const ImproveDirectionParameters& params, const UndercutMetric& metric );
87// Score candidates with distance maps, lower resolution -> faster score
89}
90}
91#endif
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDotNet/MRBitSet.h:39
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
MRMESH_API void findUndercuts(const Mesh &mesh, const Vector3f &upDirection, FaceBitSet &outUndercuts)
Adds to.
std::function< double(const FaceBitSet &, const Vector3f &upDir)> UndercutMetric
Definition MRFixUndercuts.h:39
MRMESH_API UndercutMetric getUndercutAreaMetric(const Mesh &mesh)
returns the metric that computes total area of undercut faces
MRMESH_API Vector3f distMapImproveDirection(const Mesh &mesh, const DistMapImproveDirectionParameters &params)
MRMESH_API Vector3f improveDirection(const Mesh &mesh, const ImproveDirectionParameters &params, const UndercutMetric &metric)
MRMESH_API double scoreUndercuts(const Mesh &mesh, const Vector3f &upDirection, const Vector2i &resolution)
MRMESH_API UndercutMetric getUndercutAreaProjectionMetric(const Mesh &mesh)
returns the metric that computes summed absolute area of undercut faces as visible if look from upDir
MRMESH_API void fixUndercuts(Mesh &mesh, const Vector3f &upDirection, float voxelSize=0.0f, float bottomExtension=0.0f)
Definition MRCameraOrientationPlugin.h:7
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