public void WeldCurvedSegments() { var sketch = Sketch.Create(); var sb = new SketchBuilder(sketch); sb.Arc(0.0, 0.0, 10.0, 0.0, 5.0, 5.0); // 0, 1, 2 s0 sb.Arc(0.0, 5.0, 10.0, 5.0, 5.0, 0.0); // 2, 3, 4 s1 Assert.IsTrue(SketchUtils.WeldSegments(sketch, new[] { sketch.Segments[0], sketch.Segments[1] })); Assert.AreEqual(12, sketch.Points.Count); Assert.AreEqual(6, sketch.Segments.Count); }
public void WeldOverlapSegments(int segOrder) { var sketch = Sketch.Create(); var sb = new SketchBuilder(sketch); sb.Line(0.0, 0.0, 10.0, 0.0); // 0, 1, s0 sb.Line(2.5, 0.0, 7.5, 0.0); // 2, 3, s1 Assert.IsTrue(SketchUtils.WeldSegments(sketch, new[] { sketch.Segments[0 + segOrder], sketch.Segments[1 - segOrder] })); Assert.AreEqual(4, sketch.Points.Count); Assert.AreEqual(3, sketch.Segments.Count); Assert.AreEqual(0, sketch.Segments[2].StartPoint); Assert.AreEqual(4, sketch.Segments[2].EndPoint); Assert.AreEqual(4, sketch.Segments[4].StartPoint); Assert.AreEqual(5, sketch.Segments[4].EndPoint); Assert.AreEqual(5, sketch.Segments[5].StartPoint); Assert.AreEqual(1, sketch.Segments[5].EndPoint); }
public void WeldLineSegmentsInOnePoint(int segOrder) { var sketch = Sketch.Create(); var sb = new SketchBuilder(sketch); sb.Line(0.0, 0.0, 10.0, 0.0); // 0, 1, s0 sb.Line(5.0, 0.0, 5.0, 5.0); // 2, 3, s1 Assert.IsTrue(SketchUtils.WeldSegments(sketch, new[] { sketch.Segments[0 + segOrder], sketch.Segments[1 - segOrder] })); Assert.AreEqual(4, sketch.Points.Count); Assert.AreEqual(3, sketch.Segments.Count); Assert.AreEqual(0, sketch.Segments[2].StartPoint); Assert.AreEqual(4, sketch.Segments[2].EndPoint); Assert.AreEqual(4, sketch.Segments[3].StartPoint); Assert.AreEqual(1, sketch.Segments[3].EndPoint); Assert.AreEqual(4, sketch.Segments[1].StartPoint); Assert.AreEqual(3, sketch.Segments[1].EndPoint); Assert.IsTrue(sketch.Points[4].IsEqual(new Pnt2d(5.0, 0.0), 0.01)); }