public void SubdividingACSGShapeSubdividesItsChildren() { var s1 = new Sphere { Transform = Transform.Translation(-1.5, 0, 0) }; var s2 = new Sphere { Transform = Transform.Translation(1.5, 0, 0) }; var left = Group.Of(s1, s2); var s3 = new Sphere { Transform = Transform.Translation(0, 0, -1.5) }; var s4 = new Sphere { Transform = Transform.Translation(0, 0, 1.5) }; var right = Group.Of(s3, s4); var shape = new CSG(Operation.DIFFERENCE, left, right); shape.Divide(1); Assert.AreEqual(Group.Of(s1), left[0]); Assert.AreEqual(Group.Of(s2), left[1]); Assert.AreEqual(Group.Of(s3), right[0]); Assert.AreEqual(Group.Of(s4), right[1]); }
public void TestCsgSubdividingChildren() { var left = new Group(); var s1 = new Sphere(); s1.Transform = Matrix.Translation(-1.5, 0, 0); left.Add(s1); var s2 = new Sphere(); s2.Transform = Matrix.Translation(1.5, 0, 0); left.Add(s2); var right = new Group(); var s3 = new Sphere(); s3.Transform = Matrix.Translation(0, 0, -1.5); right.Add(s3); var s4 = new Sphere(); s4.Transform = Matrix.Translation(0, 0, 1.5); right.Add(s4); var shape = new CSG(CsgOperation.Difference, left, right); shape.Divide(1); Group group; group = left[0] as Group; Assert.IsNotNull(group); Assert.AreEqual(group[0], s1); group = left[1] as Group; Assert.IsNotNull(group); Assert.AreEqual(group[0], s2); group = right[0] as Group; Assert.IsNotNull(group); Assert.AreEqual(group[0], s3); group = right[1] as Group; Assert.IsNotNull(group); Assert.AreEqual(group[0], s4); }