70 virtual
size_t size() const = 0;
78 virtual size_t size()
const override {
return vec.size(); }
79 std::vector<PointPair>
vec;
95 [[nodiscard]]
float rootMeanSqF()
const {
return ( num <= 0 ) ? FLT_MAX : (float)std::sqrt( sum / num ); }
117 ICPMode mode,
float angleLimit,
float scaleLimit,
const Vector3f & fixedRotationAxis );
126 float p2plAngleLimit = PI_F / 6.0f;
129 float p2plScaleLimit = 2;
132 float cosThreshold = 0.7f;
135 float distThresholdSq = 1.f;
139 float farDistFactor = 3.f;
151 int badIterStopCount = 3;
157 bool mutualClosest =
false;
166 float cosThreshold,
float distThresholdSq,
bool mutualClosest );
181 const VertBitSet& fltSamples = {},
const VertBitSet& refSamples = {} ) : ICP( { flt, fltXf }, { ref, refXf }, fltSamples, refSamples ) {}
191 float samplingVoxelSize ) :
ICP( { flt, fltXf }, { ref, refXf }, samplingVoxelSize ) {}
210 void samplePoints(
float samplingVoxelSize ) { sampleFltPoints( samplingVoxelSize ); sampleRefPoints( samplingVoxelSize ); }
212 [[deprecated]]
void recomputeBitSet(
float fltSamplingVoxelSize ) { sampleFltPoints( fltSamplingVoxelSize ); }
263 ICPExitType resultType_{ ICPExitType::NotStarted };
266 void deactivatefarDistPairs_();
constexpr A operator+(A a)
Definition MRImGuiVectorOperators.h:97
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
container of bits
Definition MRMesh/MRBitSet.h:27
Definition MRMesh/MRICP.h:171
size_t getNumSamples() const
computes the number of samples able to form pairs
Definition MRMesh/MRICP.h:233
MRMESH_API void setCosineLimit(const float cos)
const ICPProperties & getParams() const
Definition MRMesh/MRICP.h:228
MRMESH_API AffineXf3f calculateTransformation()
void setParams(const ICPProperties &prop)
tune algorithm params before run calculateTransformation()
Definition MRMesh/MRICP.h:195
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:210
const PointPairs & getRef2FltPairs() const
returns current pairs formed from samples on reference object and projections on floating object
Definition MRMesh/MRICP.h:248
const PointPairs & getFlt2RefPairs() const
returns current pairs formed from samples on floating object and projections on reference object
Definition MRMesh/MRICP.h:245
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:236
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
ICP(const MeshOrPoints &flt, const MeshOrPoints &ref, const AffineXf3f &fltXf, const AffineXf3f &refXf, const VertBitSet &fltSamples={}, const VertBitSet &refSamples={})
Definition MRMesh/MRICP.h:180
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:190
MRMESH_API AffineXf3f autoSelectFloatXf()
MRMESH_API void setDistanceLimit(const float dist)
MRMESH_API void setFarDistFactor(const float factor)
void recomputeBitSet(float fltSamplingVoxelSize)
Definition MRMesh/MRICP.h:212
Definition MRMesh/MRMeshOrPoints.h:17
Definition MRCameraOrientationPlugin.h:8
float getMeanSqDistToPlane(const IPointPairs &pairs)
computes root-mean-square deviation from points to target planes
Definition MRMesh/MRICP.h:110
ICPMode
The group of transformations, each with its own degrees of freedom.
Definition MRICPEnums.h:16
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:83
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:107
ICPExitType
Definition MRICPEnums.h:25
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...
MRMESH_API NumSum getSumSqDistToPlane(const IPointPairs &pairs, double *inaccuracy=nullptr)
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
MRMESH_API NumSum getSumSqDistToPoint(const IPointPairs &pairs, double *inaccuracy=nullptr)
Definition MRMesh/MRICP.h:16
friend bool operator==(const ICPPairData &, const ICPPairData &)=default
Vector3f srcNorm
normal in source point after transforming in world space
Definition MRMesh/MRICP.h:21
Vector3f tgtPoint
coordinates of the closest point on target after transforming in world space
Definition MRMesh/MRICP.h:24
Vector3f tgtNorm
normal in the target point after transforming in world space
Definition MRMesh/MRICP.h:27
float weight
weight of the pair (to prioritize over other pairs)
Definition MRMesh/MRICP.h:33
Vector3f srcPoint
coordinates of the source point after transforming in world space
Definition MRMesh/MRICP.h:18
float distSq
squared distance between source and target points
Definition MRMesh/MRICP.h:30
Definition MRMesh/MRICP.h:121
Vector3f fixedRotationAxis
If this vector is not zero then rotation is allowed relative to this axis only.
Definition MRMesh/MRICP.h:145
Simple interface for pairs holder.
Definition MRMesh/MRICP.h:59
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:71
IPointPairs & operator=(const IPointPairs &)=default
an object and its transformation to global space with other objects
Definition MRMesh/MRMeshOrPoints.h:97
Definition MRMesh/MRICP.h:89
float rootMeanSqF() const
Definition MRMesh/MRICP.h:95
double sum
Definition MRMesh/MRICP.h:91
int num
Definition MRMesh/MRICP.h:90
Stores a pair of points: one samples on the source and the closest to it on the target.
Definition MRMesh/MRICP.h:40
float normalsAngleCos
cosine between normals in source and target points
Definition MRMesh/MRICP.h:49
VertId srcVertId
id of the source point
Definition MRMesh/MRICP.h:42
friend bool operator==(const PointPair &, const PointPair &)=default
VertId tgtCloseVert
Definition MRMesh/MRICP.h:46
bool tgtOnBd
true if if the closest point on target is located on the boundary (only for meshes)
Definition MRMesh/MRICP.h:52
Definition MRMesh/MRICP.h:75
virtual size_t size() const override
Definition MRMesh/MRICP.h:78
std::vector< PointPair > vec
vector of all point pairs both active and not
Definition MRMesh/MRICP.h:79
virtual const ICPPairData & operator[](size_t idx) const override
Definition MRMesh/MRICP.h:76
virtual ICPPairData & operator[](size_t idx) override
Definition MRMesh/MRICP.h:77