Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
 public SerializablePointSampler(
     Transform referenceTransform,
     AllPointsSampler.Configuration.NormalProcessing normalProcessing,
     float percentage, int numberOfBins
     ) : this(new Utils.SerializableTransform(referenceTransform),
              NormalProcessingEnumToString(normalProcessing),
              percentage, numberOfBins)
 {
 }
Exemplo n.º 3
0
        private static string NormalProcessingEnumToString(AllPointsSampler.Configuration.NormalProcessing normalProcessing)
        {
            switch (normalProcessing)
            {
            case AllPointsSampler.Configuration.NormalProcessing.AreaWeightedSmoothNormals:
                return("AreaWeightedSmoothNormals");

            case AllPointsSampler.Configuration.NormalProcessing.VertexNormals:
                return("VertexNormals");

            case AllPointsSampler.Configuration.NormalProcessing.NoNormals:
                return("NoNormals");
            }
            return("");
        }
Exemplo n.º 4
0
 public Configuration(Transform referenceTransform, AllPointsSampler.Configuration.NormalProcessing normalProcessing, float percentage)
     : base(referenceTransform, normalProcessing)
 {
     this.Percentage = percentage;
 }
Exemplo n.º 5
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);
        }