예제 #1
0
        public void TestSample(string gameObjectname, float percentage, int expectedSampleSize, AllPointsSampler.Configuration.NormalProcessing normalProcessing)
        {
            EditorSceneManager.OpenScene(sceneName);

            //The 'default' child of a mesh contains the stuff we are interested in
            GameObject gameObject = GameObject.Find(gameObjectname).transform.GetChild(0).gameObject;
            DoubleConnectedEdgeListStorage dcelStorage = gameObject.GetComponent <DoubleConnectedEdgeListStorage>();

            dcelStorage.DCEL = DCEL.FromMesh(gameObject.GetComponent <MeshFilter>().sharedMesh);

            SamplingInformation samplingInformation = new SamplingInformation(gameObject);

            RandomSubSampling.Configuration randomConfig = new RandomSubSampling.Configuration(
                referenceTransform: gameObject.transform.root,
                normalProcessing: normalProcessing,
                percentage: percentage
                );

            SamplingInformation samplingInfo = new SamplingInformation(gameObject);

            AllPointsSampler.Configuration allPointsConfig = new AllPointsSampler.Configuration(
                referenceTransform: gameObject.transform.root,
                normalProcessing: normalProcessing
                );
            List <Point> allPoints = new AllPointsSampler(allPointsConfig).Sample(samplingInfo);

            List <Point> actual = new RandomSubSampling(randomConfig).Sample(samplingInfo);

            Assert.AreEqual(expectedSampleSize, actual.Count);
            Assert.That(actual, Is.SubsetOf(allPoints));

            bool allUnique = actual.GroupBy(x => x).All(g => g.Count() == 1);

            Assert.IsTrue(allUnique);
        }
예제 #2
0
        public void TestSample_0(string gameObjectName, AllPointsSampler.Configuration.NormalProcessing normalProcessing)
        {
            EditorSceneManager.OpenScene(sceneName);

            //The 'default' child of a mesh contains the stuff we are interested in
            GameObject gameObject = GameObject.Find(gameObjectName).transform.GetChild(0).gameObject;
            DoubleConnectedEdgeListStorage dcelStorage = gameObject.GetComponent <DoubleConnectedEdgeListStorage>();

            dcelStorage.DCEL = DCEL.FromMesh(gameObject.GetComponent <MeshFilter>().sharedMesh);

            SamplingInformation samplingInformation = new SamplingInformation(gameObject);

            RandomSubSampling.Configuration config = new RandomSubSampling.Configuration(
                referenceTransform: gameObject.transform.root,
                normalProcessing: normalProcessing,
                percentage: 0
                );

            SamplingInformation samplingInfo = new SamplingInformation(gameObject);

            List <Point> expected = new List <Point>();
            List <Point> actual   = new RandomSubSampling(config).Sample(samplingInfo);

            Assert.That(actual, Is.EquivalentTo(expected));
        }