3#include "MRPch/MRBindingMacros.h"
71 virtual
size_t size() const = 0;
79 virtual size_t size()
const override {
return vec.size(); }
80 std::vector<PointPair>
vec;
96 [[nodiscard]]
float rootMeanSqF()
const {
return ( num <= 0 ) ? FLT_MAX : (float)std::sqrt( sum / num ); }
118 ICPMode mode,
float angleLimit,
float scaleLimit,
const Vector3f & fixedRotationAxis );
127 float p2plAngleLimit = PI_F / 6.0f;
130 float p2plScaleLimit = 2;
133 float cosThreshold = 0.7f;
136 float distThresholdSq = 1.f;
140 float farDistFactor = 3.f;
152 int badIterStopCount = 3;
158 bool mutualClosest =
false;
167 float cosThreshold,
float distThresholdSq,
bool mutualClosest );
183 const VertBitSet& fltSamples = {},
const VertBitSet& refSamples = {} ) : ICP( { flt, fltXf }, { ref, refXf }, fltSamples, refSamples ) {}
193 float samplingVoxelSize ) :
ICP( { flt, fltXf }, { ref, refXf }, samplingVoxelSize ) {}
212 void samplePoints(
float samplingVoxelSize ) { sampleFltPoints( samplingVoxelSize ); sampleRefPoints( samplingVoxelSize ); }
265 ICPExitType resultType_{ ICPExitType::NotStarted };
268 void deactivatefarDistPairs_();
constexpr A operator+(A a)
Definition MRImGuiVectorOperators.h:97
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
Definition MRMesh/MRBitSet.h:28
Definition MRMesh/MRICP.h:173
size_t getNumSamples() const
computes the number of samples able to form pairs
Definition MRMesh/MRICP.h:235
MRMESH_API void setCosineLimit(const float cos)
const ICPProperties & getParams() const
Definition MRMesh/MRICP.h:230
MRMESH_API AffineXf3f calculateTransformation()
void setParams(const ICPProperties &prop)
tune algorithm params before run calculateTransformation()
Definition MRMesh/MRICP.h:197
MRMESH_API void sampleRefPoints(float samplingVoxelSize)
MRMESH_API void setFltSamples(const VertBitSet &fltSamples)
select pairs with origin samples on floating object
void samplePoints(float samplingVoxelSize)
select pairs with origin samples on both objects
Definition MRMesh/MRICP.h:212
const PointPairs & getRef2FltPairs() const
returns current pairs formed from samples on reference object and projections on floating object
Definition MRMesh/MRICP.h:250
const PointPairs & getFlt2RefPairs() const
returns current pairs formed from samples on floating object and projections on reference object
Definition MRMesh/MRICP.h:247
MRMESH_API void setFloatXf(const AffineXf3f &fltXf)
sets to-world transformation for the floating object
size_t getNumActivePairs() const
computes the number of active point pairs
Definition MRMesh/MRICP.h:238
MRMESH_API void setRefSamples(const VertBitSet &refSamples)
select pairs with origin samples on reference object
MRMESH_API void sampleFltPoints(float samplingVoxelSize)
MRMESH_API void setBadIterCount(const int iter)
MRMESH_API void updatePointPairs()
recompute point pairs after manual change of transformations or parameters
MRMESH_API void setXfs(const AffineXf3f &fltXf, const AffineXf3f &refXf)
sets to-world transformations both for floating and reference objects
MR_BIND_IGNORE void recomputeBitSet(float fltSamplingVoxelSize)
Definition MRMesh/MRICP.h:214
ICP(const MeshOrPoints &flt, const MeshOrPoints &ref, const AffineXf3f &fltXf, const AffineXf3f &refXf, const VertBitSet &fltSamples={}, const VertBitSet &refSamples={})
Definition MRMesh/MRICP.h:182
MRMESH_API ICP(const MeshOrPointsXf &flt, const MeshOrPointsXf &ref, const VertBitSet &fltSamples={}, const VertBitSet &refSamples={})
MRMESH_API float getMeanSqDistToPlane() const
computes root-mean-square deviation from points to target planes
MRMESH_API float getMeanSqDistToPoint() const
computes root-mean-square deviation between points
MRMESH_API ICP(const MeshOrPointsXf &flt, const MeshOrPointsXf &ref, float samplingVoxelSize)
MRMESH_API std::string getStatusInfo() const
MRMESH_API ICP(const MeshOrPoints &flt, const MeshOrPoints &ref, const AffineXf3f &fltXf, const AffineXf3f &refXf, float samplingVoxelSize)
Definition MRMesh/MRICP.h:192
MRMESH_API AffineXf3f autoSelectFloatXf()
MRMESH_API void setDistanceLimit(const float dist)
MRMESH_API void setFarDistFactor(const float factor)
Definition MRMesh/MRMeshOrPoints.h:18
Definition MRCameraOrientationPlugin.h:8
MRMESH_API NumSum getSumSqDistToPoint(const IPointPairs &pairs, std::optional< double > inaccuracy={})
float getMeanSqDistToPlane(const IPointPairs &pairs)
computes root-mean-square deviation from points to target planes
Definition MRMesh/MRICP.h:111
ICPMode
The group of transformations, each with its own degrees of freedom.
Definition MRICPEnums.h:20
MRMESH_API NumSum getSumSqDistToPlane(const IPointPairs &pairs, std::optional< double > inaccuracy={})
MRMESH_API size_t getNumActivePairs(const IPointPairs &pairs)
computes the number of active pairs
size_t getNumSamples(const IPointPairs &pairs)
returns the number of samples able to form pairs
Definition MRMesh/MRICP.h:84
MRMESH_API std::string getICPStatusInfo(int iterations, ICPExitType exitType)
returns status info string
float getMeanSqDistToPoint(const IPointPairs &pairs)
computes root-mean-square deviation between points
Definition MRMesh/MRICP.h:108
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
ICPExitType
Definition MRICPEnums.h:29
MRMESH_API AffineXf3f getAligningXf(const PointToPlaneAligningTransform &p2pl, ICPMode mode, float angleLimit, float scaleLimit, const Vector3f &fixedRotationAxis)
given prepared (p2pl) object, finds the best transformation from it of given type with given limitati...
ICPMethod
The method how to update transformation from point pairs.
Definition MRICPEnums.h:6
MRMESH_API void updatePointPairs(PointPairs &pairs, const MeshOrPointsXf &src, const MeshOrPointsXf &tgt, float cosThreshold, float distThresholdSq, bool mutualClosest)
in each pair updates the target data and performs basic filtering (activation)
MRMESH_API size_t deactivateFarPairs(IPointPairs &pairs, float maxDistSq)
reset active bit if pair distance is further than maxDistSq
Definition MRMesh/MRICP.h:17
friend bool operator==(const ICPPairData &, const ICPPairData &)=default
Vector3f srcNorm
normal in source point after transforming in world space
Definition MRMesh/MRICP.h:22
Vector3f tgtPoint
coordinates of the closest point on target after transforming in world space
Definition MRMesh/MRICP.h:25
Vector3f tgtNorm
normal in the target point after transforming in world space
Definition MRMesh/MRICP.h:28
float weight
weight of the pair (to prioritize over other pairs)
Definition MRMesh/MRICP.h:34
Vector3f srcPoint
coordinates of the source point after transforming in world space
Definition MRMesh/MRICP.h:19
float distSq
squared distance between source and target points
Definition MRMesh/MRICP.h:31
Definition MRMesh/MRICP.h:122
Vector3f fixedRotationAxis
If this vector is not zero then rotation is allowed relative to this axis only.
Definition MRMesh/MRICP.h:146
Simple interface for pairs holder.
Definition MRMesh/MRICP.h:60
virtual size_t size() const =0
IPointPairs(const IPointPairs &)=default
IPointPairs(IPointPairs &&) noexcept=default
BitSet active
whether corresponding pair from vec must be considered during minimization
Definition MRMesh/MRICP.h:72
IPointPairs & operator=(const IPointPairs &)=default
an object and its transformation to global space with other objects
Definition MRMesh/MRMeshOrPoints.h:101
Definition MRMesh/MRICP.h:90
float rootMeanSqF() const
Definition MRMesh/MRICP.h:96
double sum
Definition MRMesh/MRICP.h:92
int num
Definition MRMesh/MRICP.h:91
Stores a pair of points: one samples on the source and the closest to it on the target.
Definition MRMesh/MRICP.h:41
float normalsAngleCos
cosine between normals in source and target points
Definition MRMesh/MRICP.h:50
VertId srcVertId
id of the source point
Definition MRMesh/MRICP.h:43
friend bool operator==(const PointPair &, const PointPair &)=default
VertId tgtCloseVert
Definition MRMesh/MRICP.h:47
bool tgtOnBd
true if if the closest point on target is located on the boundary (only for meshes)
Definition MRMesh/MRICP.h:53
Definition MRMesh/MRICP.h:76
virtual size_t size() const override
Definition MRMesh/MRICP.h:79
std::vector< PointPair > vec
vector of all point pairs both active and not
Definition MRMesh/MRICP.h:80
virtual const ICPPairData & operator[](size_t idx) const override
Definition MRMesh/MRICP.h:77
virtual ICPPairData & operator[](size_t idx) override
Definition MRMesh/MRICP.h:78