Esempio n. 1
0
 public UnitsInspected()
 {
     InspectedUnits      = new List <InspectedUnit>();
     Inspector           = new Operator();
     InspectionMethod    = InspectionMethod.Human;
     SamplingInformation = new SamplingInformation();
 }
Esempio n. 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));
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 public UnitsTested()
 {
     TestedUnits         = new List <TestedUnit>();
     Tester              = new Operator();
     TestMethod          = TestMethod.Human;
     SamplingInformation = new SamplingInformation();
 }
        public void TestSample_Pyramid_45()
        {
            EditorSceneManager.OpenScene(sceneName);

            //The 'default' child of a mesh contains the stuff we are interested in
            GameObject gameObject = GameObject.Find("pyramid").transform.GetChild(0).gameObject;

            SamplingInformation samplingInformation = new SamplingInformation(gameObject);

            NDOSubsampling.Configuration ndosConfig = new NDOSubsampling.Configuration(
                referenceTransform: gameObject.transform.root,
                percentage: 45,
                binCount: 6
                );

            SamplingInformation             samplingInfo = new SamplingInformation(gameObject);
            Dictionary <int, List <Point> > bins         = new NormalBinner(ndosConfig).Bin(samplingInformation);

            List <Point> actual = new NDOSubsampling(ndosConfig).Sample(samplingInfo);

            Assert.That(CountPointsSampledFromBin(actual, bins[0]), Is.EqualTo(1));
            Assert.That(CountPointsSampledFromBin(actual, bins[1]), Is.EqualTo(1));
            Assert.That(CountPointsSampledFromBin(actual, bins[2]), Is.EqualTo(0));
            Assert.That(CountPointsSampledFromBin(actual, bins[3]), Is.EqualTo(1));
            Assert.That(CountPointsSampledFromBin(actual, bins[4]), Is.EqualTo(1));
            Assert.That(CountPointsSampledFromBin(actual, bins[5]), Is.EqualTo(2));
        }
        public void TestSample_Cube_50()
        {
            EditorSceneManager.OpenScene(sceneName);

            //The 'default' child of a mesh contains the stuff we are interested in
            GameObject gameObject = GameObject.Find("cube").transform.GetChild(0).gameObject;

            SamplingInformation samplingInformation = new SamplingInformation(gameObject);

            NDOSubsampling.Configuration ndosConfig = new NDOSubsampling.Configuration(
                referenceTransform: gameObject.transform.root,
                percentage: 50,
                binCount: 6
                );

            SamplingInformation samplingInfo = new SamplingInformation(gameObject);

            List <Point> actual = new NDOSubsampling(ndosConfig).Sample(samplingInfo);


            NormalBinner binner = new NormalBinner(ndosConfig.BinCount, ndosConfig.referenceTransform);
            Dictionary <int, List <Point> > bins = binner.Bin(samplingInformation);

            for (int i = 0; i < bins.Count; i++)
            {
                Assert.That(CountPointsSampledFromBin(actual, bins[i]), Is.EqualTo(2));
            }
        }
        public void TestSample_100(string gameObjectName)
        {
            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;

            SamplingInformation samplingInformation = new SamplingInformation(gameObject);

            NDOSubsampling.Configuration ndosConfig = new NDOSubsampling.Configuration(
                referenceTransform: gameObject.transform.root,
                percentage: 100,
                binCount: 6
                );

            AllPointsSampler.Configuration allPointsConfig = new AllPointsSampler.Configuration(
                referenceTransform: gameObject.transform.root,
                normalProcessing: AllPointsSampler.Configuration.NormalProcessing.VertexNormals
                );

            SamplingInformation samplingInfo = new SamplingInformation(gameObject);

            List <Point> expected = new AllPointsSampler(allPointsConfig).Sample(samplingInfo);
            List <Point> actual   = new NDOSubsampling(ndosConfig).Sample(samplingInfo);

            Assert.That(actual, Is.EquivalentTo(expected));
        }
        public void Test_Bin(string gameObjectName, Dictionary <int, List <Point> > expected)
        {
            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;
            Transform  referenceTransform = gameObject.transform.root;

            SamplingInformation samplingInformation = new SamplingInformation(gameObject);

            NormalBinner binner = new NormalBinner(6, referenceTransform);
            Dictionary <int, List <Point> > actual = binner.Bin(samplingInformation);

            Assert.That(actual.Keys, Is.EquivalentTo(expected.Keys));
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.That(actual[i], Is.EquivalentTo(expected[i]));
            }
        }