77 std::vector<PointPair>
vec;
93 [[nodiscard]]
float rootMeanSqF()
const {
return ( num <= 0 ) ? FLT_MAX : (float)std::sqrt( sum / num ); }
115 ICPMode mode,
float angleLimit,
float scaleLimit,
const Vector3f & fixedRotationAxis );
124 float p2plAngleLimit = PI_F / 6.0f;
127 float p2plScaleLimit = 2;
130 float cosThreshold = 0.7f;
133 float distThresholdSq = 1.f;
137 float farDistFactor = 3.f;
149 int badIterStopCount = 3;
155 bool mutualClosest =
false;
164 float cosThreshold,
float distThresholdSq,
bool mutualClosest );
179 const VertBitSet& fltSamples = {},
const VertBitSet& refSamples = {} ) :
ICP( { flt, fltXf }, { ref, refXf }, fltSamples, refSamples ) {}
189 float samplingVoxelSize ) :
ICP( { flt, fltXf }, { ref, refXf }, samplingVoxelSize ) {}
208 void samplePoints(
float samplingVoxelSize ) { sampleFltPoints( samplingVoxelSize ); sampleRefPoints( samplingVoxelSize ); }
210 [[deprecated]]
void recomputeBitSet(
float fltSamplingVoxelSize ) { sampleFltPoints( fltSamplingVoxelSize ); }
261 ICPExitType resultType_{ ICPExitType::NotStarted };
264 void deactivatefarDistPairs_();
int VertId
Definition MRDotNet/MRMeshFwd.h:51
constexpr A operator+(A a)
Definition MRImGuiVectorOperators.h:97
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDotNet/MRBitSet.h:39
Definition MRDotNet/MRICP.h:97
container of bits
Definition MRMesh/MRBitSet.h:27
Definition MRMesh/MRICP.h:169
size_t getNumSamples() const
computes the number of samples able to form pairs
Definition MRMesh/MRICP.h:231
MRMESH_API void setCosineLimit(const float cos)
const ICPProperties & getParams() const
Definition MRMesh/MRICP.h:226
MRMESH_API AffineXf3f calculateTransformation()
void setParams(const ICPProperties &prop)
tune algorithm params before run calculateTransformation()
Definition MRMesh/MRICP.h:193
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:208
const PointPairs & getRef2FltPairs() const
returns current pairs formed from samples on reference object and projections on floating object
Definition MRMesh/MRICP.h:246
const PointPairs & getFlt2RefPairs() const
returns current pairs formed from samples on floating object and projections on reference object
Definition MRMesh/MRICP.h:243
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:234
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:178
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:188
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:210
Definition MRMesh/MRMeshOrPoints.h:17
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
Definition MRCameraOrientationPlugin.h:8
float getMeanSqDistToPlane(const IPointPairs &pairs)
computes root-mean-square deviation from points to target planes
Definition MRMesh/MRICP.h:108
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:81
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:105
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:119
Vector3f fixedRotationAxis
If this vector is not zero then rotation is allowed relative to this axis only.
Definition MRMesh/MRICP.h:143
Simple interface for pairs holder.
Definition MRMesh/MRICP.h:59
IPointPairs(const IPointPairs &)=default
IPointPairs(IPointPairs &&) noexcept=default
BitSet active
whether corresponding pair from vec must be considered during minimization
Definition MRMesh/MRICP.h:70
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:87
float rootMeanSqF() const
Definition MRMesh/MRICP.h:93
double sum
Definition MRMesh/MRICP.h:89
int num
Definition MRMesh/MRICP.h:88
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:74
std::vector< PointPair > vec
vector of all point pairs both active and not
Definition MRMesh/MRICP.h:77
virtual const ICPPairData & operator[](size_t idx) const override
Definition MRMesh/MRICP.h:75
virtual ICPPairData & operator[](size_t idx) override
Definition MRMesh/MRICP.h:76