using System.Reflection;
public class MeshICPExample
{
public static void Run()
{
try
{
Mesh meshFloating = MeshLoad.FromAnySupportedFormat("meshA.stl");
MeshOrPointsXf meshXfFloating = new MeshOrPointsXf(meshFloating, new AffineXf3f());
MeshOrPointsXf meshXfFixed = new MeshOrPointsXf(MeshLoad.FromAnySupportedFormat("meshB.stl"), new AffineXf3f());
float diagonal = meshXfFixed.obj.BoundingBox.Diagonal();
float icpSamplingVoxelSize = diagonal * 0.01f;
ICPProperties icpParams = new ICPProperties();
icpParams.distThresholdSq = diagonal * diagonal * 0.01f;
icpParams.exitVal = diagonal * 0.003f;
ICP icp = new ICP(meshXfFloating, meshXfFixed, icpSamplingVoxelSize);
icp.SetParams( icpParams );
AffineXf3f xf = icp.CalculateTransformation();
meshFloating.Transform(xf);
Console.WriteLine("info {0}", icp.GetStatusInfo());
MeshSave.ToAnySupportedFormat( meshFloating, "meshA_icp.stl");
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e.Message);
}
}
}