public void WeldPoints_IncorrectParameters() { var sketch = Sketch.Create(); var sb = new SketchBuilder(sketch); sb.Line(1.0, 1.0, 2.0, 2.0); // 0, 1 sb.Line(1.0, 1.0, -2.0, -2.0); // 2, 3 sb.Line(1.2, 1.2, -2.0, 2.0); // 4, 5 Assert.IsFalse(SketchUtils.WeldPoints(sketch, new[] { 0 })); Assert.AreEqual(6, sketch.Points.Count); Assert.IsTrue(SketchUtils.WeldPoints(sketch, new[] { 0, 2, 0 })); Assert.AreEqual(5, sketch.Points.Count); }
public void WeldPointsRemoveSegments() { var sketch = Sketch.Create(); var sb = new SketchBuilder(sketch); sb.Line(0.0, 0.0, 0.0, 1.0); // 0, 1 sb.Line(1.0, 0.0, 1.0, 1.0); // 2, 3 sketch.AddSegment(new SketchSegmentLine(0, 2)); sketch.AddSegment(new SketchSegmentLine(3, 1)); Assert.IsTrue(SketchUtils.WeldPoints(sketch, new[] { 0, 1 })); Assert.AreEqual(3, sketch.Points.Count); Assert.AreEqual(3, sketch.Segments.Count); }
public void WeldPoints() { var sketch = Sketch.Create(); var sb = new SketchBuilder(sketch); sb.Line(1.0, 1.0, 2.0, 2.0); // 0, 1 sb.Line(1.0, 1.0, -2.0, -2.0); // 2, 3 sb.Line(1.2, 1.2, -2.0, 2.0); // 4, 5 Assert.IsTrue(SketchUtils.WeldPoints(sketch, new[] { 0, 2, 4 })); Assert.AreEqual(4, sketch.Points.Count); Assert.AreEqual(3, sketch.Segments.Count); Assert.AreEqual(6, sketch.Segments[0].StartPoint); Assert.AreEqual(1, sketch.Segments[0].EndPoint); Assert.AreEqual(6, sketch.Segments[1].StartPoint); Assert.AreEqual(3, sketch.Segments[1].EndPoint); Assert.AreEqual(6, sketch.Segments[2].StartPoint); Assert.AreEqual(5, sketch.Segments[2].EndPoint); Assert.That(new Pnt2d(3.2 / 3, 3.2 / 3).IsEqual(sketch.Points[6], 0.001)); }