Esempio n. 1
0
        public static void test_AABBTree_basic()
        {
            List <int> cases = new List <int>()
            {
                0, 1, 2, 3, 4, 7, 8
            };

            foreach (int meshCase in cases)
            {
                DMesh3         mesh       = MakeSpatialTestMesh(meshCase);
                DMeshAABBTree3 treeMedian = new DMeshAABBTree3(mesh);
                treeMedian.Build(DMeshAABBTree3.BuildStrategy.TopDownMedian);
                treeMedian.TestCoverage();
                treeMedian.TotalVolume();

                DMeshAABBTree3 treeMidpoint = new DMeshAABBTree3(mesh);
                treeMidpoint.Build(DMeshAABBTree3.BuildStrategy.TopDownMidpoint);
                treeMidpoint.TestCoverage();
                treeMidpoint.TotalVolume();

                DMeshAABBTree3 treeUpFast = new DMeshAABBTree3(mesh);
                treeUpFast.Build(DMeshAABBTree3.BuildStrategy.BottomUpFromOneRings, DMeshAABBTree3.ClusterPolicy.Fastest);
                treeUpFast.TestCoverage();
                treeUpFast.TotalVolume();

                DMeshAABBTree3 treeUpN = new DMeshAABBTree3(mesh);
                treeUpN.Build(DMeshAABBTree3.BuildStrategy.BottomUpFromOneRings, DMeshAABBTree3.ClusterPolicy.FastVolumeMetric);
                treeUpN.TestCoverage();
                treeUpN.TotalVolume();
            }
        }
Esempio n. 2
0
        public static void test_AABBTree_profile()
        {
            System.Console.WriteLine("Building test meshes");
            DMesh3[] meshes = new DMesh3[NumTestCases];
            for (int i = 0; i < NumTestCases; ++i)
            {
                meshes[i] = MakeSpatialTestMesh(i);
            }
            System.Console.WriteLine("done!");


            int N = 10;

            // avoid garbage collection
            List <DMeshAABBTree3> trees = new List <DMeshAABBTree3>();
            DMeshAABBTree3        tree  = null;



            for (int i = 0; i < NumTestCases; ++i)
            {
                Stopwatch w = new Stopwatch();
                for (int j = 0; j < N; ++j)
                {
                    tree = new DMeshAABBTree3(meshes[i]);
                    w.Start();
                    tree.Build(DMeshAABBTree3.BuildStrategy.TopDownMidpoint);
                    //tree.Build(DMeshAABBTree3.BuildStrategy.TopDownMedian);
                    //tree.Build(DMeshAABBTree3.BuildStrategy.BottomUpFromOneRings, DMeshAABBTree3.ClusterPolicy.FastVolumeMetric);
                    w.Stop();
                    trees.Add(tree);
                }
                double avg_time = w.ElapsedTicks / (double)N;
                System.Console.WriteLine(string.Format("Case {0}: time {1}  tris {2} vol {3}  len {4}", i, avg_time, tree.Mesh.TriangleCount, tree.TotalVolume(), tree.TotalExtentSum()));
            }
        }