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); }
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)); }
public void ValidProbability_WithConstructor(float percentage, float expected) { RandomSubSampling.Configuration config = new RandomSubSampling.Configuration(validTransform, validNormalProcessing, percentage); float actual = config.Probability; Assert.AreEqual(expected, actual); }
public void SetValidPercentage(float percentage) { Assert.DoesNotThrow( delegate { object q = new RandomSubSampling.Configuration(validTransform, validNormalProcessing, percentage); } ); RandomSubSampling.Configuration x = new RandomSubSampling.Configuration(validTransform, validNormalProcessing, percentage); Assert.DoesNotThrow( delegate { x.Percentage = percentage; } ); }
public void SetInvalidPercentage(float percentage) { Assert.Throws( typeof(ArgumentException), delegate { object q = new RandomSubSampling.Configuration(validTransform, validNormalProcessing, percentage); } ); RandomSubSampling.Configuration x = new RandomSubSampling.Configuration(validTransform, validNormalProcessing, validPercentage); Assert.Throws( typeof(ArgumentException), delegate { x.Percentage = percentage; } ); }