MeshLib C++ Docs
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{
12
13
15{
17 int iterations = 1;
18
20 const VertBitSet *region = nullptr;
21
23 float force = 0.5f;
24
27 bool updateCaches = false;
28
30 bool limitNearInitial = false;
31
33 float maxInitialDist = 0;
34
39 MR_BIND_IGNORE int _padding;
40};
41
43{
46};
47
50template <typename V>
51[[nodiscard]] inline V getLimitedPos( const V & pos, const V & guidePos, typename VectorTraits<V>::BaseType maxGuideDistSq )
52{
53 assert( maxGuideDistSq > 0 );
54 const auto d = pos - guidePos;
55 float distSq = sqr( d );
56 if ( distSq <= maxGuideDistSq )
57 return pos;
58 return guidePos + std::sqrt( maxGuideDistSq / distSq ) * d;
59}
60
61}
constexpr auto sqr(T x) noexcept -> decltype(x *x)
squared value; the result type is the type of x*x, which is int for small integer types (char,...
Definition MRMeshFwd.h:800
RelaxApproxType
Definition MRRelaxParams.h:43
float force
speed of relaxing, typical values (0.0, 0.5]
Definition MRRelaxParams.h:23
V getLimitedPos(const V &pos, const V &guidePos, typename VectorTraits< V >::BaseType maxGuideDistSq)
Definition MRRelaxParams.h:51
const VertBitSet * region
region to relax
Definition MRRelaxParams.h:20
T BaseType
The base template handles scalars (or just non-vectors).
Definition MRVectorTraits.h:21
float maxInitialDist
maximum distance between a point and its position before relaxation, ignored if limitNearInitial = fa...
Definition MRRelaxParams.h:33
bool limitNearInitial
if true then maximal displacement of each point during denoising will be limited
Definition MRRelaxParams.h:30
int _padding
Definition MRRelaxParams.h:39
bool updateCaches
Definition MRRelaxParams.h:27
int iterations
number of iterations
Definition MRRelaxParams.h:17
@ Planar
Definition MRRelaxParams.h:44
@ Quadric
Definition MRRelaxParams.h:45
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRRelaxParams.h:15