MeshLib
 
Loading...
Searching...
No Matches
MRRelaxParams.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVector3.h"
4#include "MRVectorTraits.h"
5#include "MRPch/MRBindingMacros.h"
6#include <cassert>
7
8namespace MR
9{
10
12{
14 int iterations = 1;
15
17 const VertBitSet *region = nullptr;
18
20 float force = 0.5f;
21
23 bool limitNearInitial = false;
24
26 float maxInitialDist = 0;
27
28 // Fixes ABI incompatibility. Without this GCC 12+ warns here with `-Wabi=16`.
29 // Read our `cmake/Modules/CompilerOptions.cmake` (the part about `-Wabi=16`) for details.
30 // This is enabled for GCC 11 and older because they're buggy, and for GCC 12 because for it we enable the warning to catch other similar cases.
31 // For other compilers it's disabled for clarity, but should have no effect on struct layout.
32 MR_BIND_IGNORE int _padding;
33};
34
36{
37 Planar,
38 Quadric,
39};
40
43template <typename V>
44[[nodiscard]] inline V getLimitedPos( const V & pos, const V & guidePos, typename VectorTraits<V>::BaseType maxGuideDistSq )
45{
46 assert( maxGuideDistSq > 0 );
47 const auto d = pos - guidePos;
48 float distSq = sqr( d );
49 if ( distSq <= maxGuideDistSq )
50 return pos;
51 return guidePos + std::sqrt( maxGuideDistSq / distSq ) * d;
52}
53
54} // namespace MR
Definition MRDotNet/MRBitSet.h:39
Definition MRCameraOrientationPlugin.h:8
constexpr T sqr(T x) noexcept
Definition MRMesh/MRMeshFwd.h:595
RelaxApproxType
Definition MRRelaxParams.h:36
V getLimitedPos(const V &pos, const V &guidePos, typename VectorTraits< V >::BaseType maxGuideDistSq)
Definition MRRelaxParams.h:44
Definition MRRelaxParams.h:12
MR_BIND_IGNORE int _padding
Definition MRRelaxParams.h:32
float force
speed of relaxing, typical values (0.0, 0.5]
Definition MRRelaxParams.h:20
const VertBitSet * region
region to relax
Definition MRRelaxParams.h:17
float maxInitialDist
maximum distance between a point and its position before relaxation, ignored if limitNearInitial = fa...
Definition MRRelaxParams.h:26
bool limitNearInitial
if true then maximal displacement of each point during denoising will be limited
Definition MRRelaxParams.h:23
int iterations
number of iterations
Definition MRRelaxParams.h:14
T BaseType
Definition MRMesh/MRVectorTraits.h:17