예제 #1
0
        public MeshICP ICP(DMesh3Builder mesh)
        {
            DMeshAABBTree3 tree = new DMeshAABBTree3(mesh.Meshes[1], autoBuild: true);

            MeshICP calc = new MeshICP(mesh.Meshes[0], tree);

            calc.Solve();
            calc.Solve(bUpdate: true);

            return(calc);
        }
예제 #2
0
        static void RunCalc()
        {
            // Target = Element you transform around.
            // Source = Element you want to transform.
            DMesh3Builder      builder = new DMesh3Builder();
            StandardMeshReader reader  = new StandardMeshReader();

            reader.MeshBuilder = builder;
            var Target = reader.Read(@"D:\Eksamen 4th semester\Pointclouds\triangle4.obj", new ReadOptions());
            var Source = reader.Read(@"D:\Eksamen 4th semester\Pointclouds\triangle3.obj", new ReadOptions());



            DMeshAABBTree3 tree = new DMeshAABBTree3(builder.Meshes[0], autoBuild: true);

            MeshICP calc = new MeshICP(builder.Meshes[1], tree);

            calc.Solve();
            calc.Solve(bUpdate: true);
            Console.WriteLine(calc.Rotation);
            Console.WriteLine(calc.Translation);
            Console.WriteLine();
            DMesh3 source = builder.Meshes[1];
            DMesh3 target = builder.Meshes[0];
            //foreach (var item in source.Vertices())
            //{
            //    Console.WriteLine(item);
            //}
            //Console.WriteLine("--------------------");

            Func <Vector3d, Vector3d> TransformF = (v1) =>
            {
                return(v1 += calc.Translation);
            };

            MeshTransforms.PerVertexTransform(source, TransformF);

            var             tarver  = target.Vertices();
            List <Vector3d> tarlist = tarver.ToList();

            trees = new KdTree <double, string>(3, new DoubleMath());

            foreach (var item in tarlist)
            {
                trees.Add(new double[] { item.x, item.y, item.z }, item.xy.ToString());
            }

            for (var findLimit = 0; findLimit <= tarlist.Count; findLimit++)
            {
            }


            double[][] tar = new double[tarlist.Count][];

            int i = 0;

            foreach (var item in tarlist)
            {
                tar[i] = new double[] { item.x, item.y, 1 };
                i++;
            }

            int k          = 3;
            int numClasses = 300;

            Console.WriteLine("With k = 3");
            List <int> res = new List <int>();

            foreach (var item in target.Vertices())
            {
                double[] src       = new double[] { item.x, item.y, item.z };
                int      predicted = Classify(src, tar, numClasses, k);
            }
        }