|
| 1 | +#include <MRMesh/MRMultiwayICP.h> |
| 2 | +#include <MRMesh/MRTorus.h> |
| 3 | +#include <MRMesh/MRMesh.h> |
| 4 | +#include <MRMesh/MRAffineXf3.h> |
| 5 | +#include <MRMesh/MRGTest.h> |
| 6 | +#include <iostream> |
| 7 | + |
| 8 | +namespace MR |
| 9 | +{ |
| 10 | + |
| 11 | +TEST( MRMesh, MultiwayICPTorus ) |
| 12 | +{ |
| 13 | + auto torusRef = makeTorus( 2.5f, 0.7f, 48, 48 ); |
| 14 | + auto torusMove = torusRef; |
| 15 | + |
| 16 | + auto axis = Vector3f( 1, 0, 0 ); |
| 17 | + auto trans = Vector3f( 0, 0.2f, 0.105f ); |
| 18 | + |
| 19 | + auto xf = AffineXf3f( Matrix3f::rotation( axis, 0.2f ), trans ); |
| 20 | + |
| 21 | + ICPObjects objs; |
| 22 | + objs.push_back( { torusMove, xf } ); |
| 23 | + objs.push_back( { torusRef, AffineXf3f{} } ); |
| 24 | + MultiwayICP icp( objs, MultiwayICPSamplingParameters{} ); |
| 25 | + |
| 26 | + ICPProperties props |
| 27 | + { |
| 28 | + .iterLimit = 20 |
| 29 | + }; |
| 30 | + icp.setParams( props ); |
| 31 | + auto newXfs = icp.calculateTransformations(); |
| 32 | + EXPECT_EQ( newXfs[ObjId( 1 )], AffineXf3f{} ); |
| 33 | + std::cout << icp.getStatusInfo() << '\n'; |
| 34 | + |
| 35 | + auto newXf = newXfs[ObjId( 0 )]; |
| 36 | + constexpr float eps = 1e-6f; |
| 37 | + EXPECT_NEAR( ( newXf.A - Matrix3f::identity() ).norm(), 0., eps ); |
| 38 | + EXPECT_NEAR( newXf.b.length(), 0., eps ); |
| 39 | +} |
| 40 | + |
| 41 | +} //namespace MR |
0 commit comments