8using ICPObjects = Vector<MeshOrPointsXf, ObjId>;
12using ICPElementId = Id<ICPElemtTag>;
13using ICPElementBitSet = TaggedBitSet<ICPElemtTag>;
14struct ICPGroupPair :
public ICPPairData
17 ObjVertId tgtClosestId;
19struct ICPGroupPairs :
public IPointPairs
21 virtual const ICPPairData& operator[](
size_t idx )
const override {
return vec[idx]; }
22 virtual ICPPairData& operator[](
size_t idx )
override {
return vec[idx]; }
23 virtual size_t size()
const override {
return vec.size(); }
24 std::vector<ICPGroupPair>
vec;
27using ICPGroupProjector = std::function<void(
const Vector3f& p, MeshOrPoints::ProjectionResult& res, ObjId& resId )>;
30 ICPGroupProjector srcProjector, ICPGroupProjector tgtProjector,
31 float cosThreshold,
float distThresholdSq,
bool mutualClosest );
42 virtual bool fromSameNode( ICPLayer l, ICPElementId eI, ICPElementId eJ )
const = 0;
45 virtual ObjBitSet getElementLeaves( ICPLayer l, ICPElementId eId )
const = 0;
48 virtual ICPElementBitSet getElementNodes( ICPLayer l, ICPElementId eId )
const = 0;
55 virtual size_t getNumElements( ICPLayer l )
const = 0;
56 virtual size_t getNumLayers()
const = 0;
60struct MultiwayICPSamplingParameters
71 enum class CascadeMode
75 } cascadeMode{ CascadeMode::AABBTreeBased };
88 MRMESH_API MultiwayICP(
const ICPObjects& objects,
const MultiwayICPSamplingParameters& samplingParams );
93 [[nodiscard]]
MRMESH_API Vector<AffineXf3f, ObjId> calculateTransformations(
const ProgressCallback& cb = {} );
98 [[nodiscard]]
MRMESH_API Vector<AffineXf3f, ObjId> calculateTransformationsFixFirst(
const ProgressCallback& cb = {} );
101 MRMESH_API bool resamplePoints(
const MultiwayICPSamplingParameters& samplingParams );
105 MRMESH_API bool updateAllPointPairs(
const ProgressCallback& cb = {} );
108 void setParams(
const ICPProperties& prop ) { prop_ = prop; }
109 [[nodiscard]]
const ICPProperties& getParams()
const {
return prop_; }
126 void setPerIterationCallback( std::function<
void(
int inter )> callback ) { perIterationCb_ = std::move( callback ); }
130 bool devIndependentEquationsModeEnabled()
const {
return maxGroupSize_ == 1; }
131 void devEnableIndependentEquationsMode(
bool on ) { maxGroupSize_ = on ? 1 : 0; }
134 [[nodiscard]]
MRMESH_API std::string getStatusInfo()
const;
136 using PairsPerLayer = Vector<ICPPairsGrid, ICPLayer>;
138 const PairsPerLayer& getPairsPerLayer()
const {
return pairsGridPerLayer_; }
142 const IICPTreeIndexer* getCascadeIndexer()
const {
return cascadeIndexer_.get(); }
145 PairsPerLayer pairsGridPerLayer_;
148 ICPExitType resultType_{ ICPExitType::NotStarted };
150 std::function<void(
int )> perIterationCb_;
152 std::unique_ptr<IICPTreeIndexer> cascadeIndexer_;
155 void setupLayers_( MultiwayICPSamplingParameters::CascadeMode mode );
159 bool reservePairsLayer0_( Vector<VertBitSet, ObjId>&& samples,
const ProgressCallback& cb );
161 using LayerSamples = Vector<Vector<MultiObjsSamples, ICPElementId>, ICPLayer>;
162 std::optional<LayerSamples> resampleUpperLayers_(
const ProgressCallback& cb );
163 bool reserveUpperLayerPairs_( LayerSamples&& samples,
const ProgressCallback& cb );
166 bool updateLayerPairs_( ICPLayer l,
const ProgressCallback& cb = {} );
168 void deactivateFarDistPairs_( ICPLayer l );
170 float samplingSize_{ 0.0f };
180 int maxGroupSize_{ 64 };
182 bool doIteration_(
bool p2pl );
185 bool multiwayIter_(
bool p2pl =
true );
186 bool cascadeIter_(
bool p2pl =
true );
188 void calcGen_(
bool p2pl,
const ProgressCallback& cb );
189 void calcP2Pt_(
const ProgressCallback& cb );
190 void calcP2Pl_(
const ProgressCallback& cb );
191 void calcCombined_(
const ProgressCallback& cb );
#define MRMESH_API
Definition MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMeshFwd.h:87
Definition MRMultiwayICP.h:20
new unsafe MR.Std.Vector_MRICPGroupPair vec
Definition MRMultiwayICP.h:38
new unsafe ref float samplingVoxelSize
new unsafe MR.Std.Function_BoolFuncFromFloat cb
new unsafe ref int maxGroupSize
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:19
Definition MRCameraOrientationPlugin.h:8
MRMESH_API void updateGroupPairs(ICPGroupPairs &pairs, const ICPObjects &objs, ICPGroupProjector srcProjector, ICPGroupProjector tgtProjector, float cosThreshold, float distThresholdSq, bool mutualClosest)
in each pair updates the target data and performs basic filtering (activation)
float getMeanSqDistToPlane(IPointPairs pairs)
float getMeanSqDistToPoint(IPointPairs pairs)
int getNumSamples(IPointPairs pairs)
int getNumActivePairs(IPointPairs pairs)