Ejemplo 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));
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        private SamplingInformation(Transform transform, MeshFilter meshFilter, Collider collider, DoubleConnectedEdgeListStorage dcelStorage)
        {
            if (meshFilter == null)
            {
                throw new System.ArgumentNullException("mesh filter");
            }
            if (collider == null)
            {
                throw new System.ArgumentNullException("collider");
            }
            if (dcelStorage == null)
            {
                throw new System.ArgumentNullException("dcel storage");
            }

            this.Transform = transform;
            this.Mesh      = Application.isEditor ? meshFilter.sharedMesh : meshFilter.mesh;
            this.Collider  = collider;
            this.DCEL      = dcelStorage.DCEL;
        }