Beispiel #1
0
        public void WeldPointsWithLineSegment()
        {
            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
            sb.Line(6.0, 0.0, 5.0, 5.0);  // 4, 5, s2

            Assert.IsTrue(SketchUtils.WeldPointsWithSegments(sketch, new[] { sketch.Segments[0] }, new[] { 2, 4 }));

            Assert.AreEqual(6, sketch.Points.Count);
            Assert.AreEqual(5, sketch.Segments.Count);
            Assert.AreEqual(6, sketch.Segments[1].StartPoint);
            Assert.AreEqual(3, sketch.Segments[1].EndPoint);
            Assert.AreEqual(7, sketch.Segments[2].StartPoint);
            Assert.AreEqual(5, sketch.Segments[2].EndPoint);
            Assert.AreEqual(0, sketch.Segments[3].StartPoint);
            Assert.AreEqual(6, sketch.Segments[3].EndPoint);
            Assert.AreEqual(6, sketch.Segments[5].StartPoint);
            Assert.AreEqual(7, sketch.Segments[5].EndPoint);
            Assert.AreEqual(7, sketch.Segments[6].StartPoint);
            Assert.AreEqual(1, sketch.Segments[6].EndPoint);
            Assert.IsTrue(sketch.Points[6].IsEqual(new Pnt2d(5.0, 0.0), 0.01));
            Assert.IsTrue(sketch.Points[7].IsEqual(new Pnt2d(6.0, 0.0), 0.01));
        }
Beispiel #2
0
        public void WeldPointWithLineSegments()
        {
            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
            sb.Line(0.0, 0.1, 10.0, 0.1); // 4, 5, s2 - Parallel line segment

            Assert.IsTrue(SketchUtils.WeldPointsWithSegments(sketch, new[] { sketch.Segments[0], sketch.Segments[2] }, new[] { 2 }));

            Assert.AreEqual(6, sketch.Points.Count);
            Assert.AreEqual(4, sketch.Segments.Count);
            Assert.IsFalse(sketch.Segments.ContainsKey(0));
            Assert.IsTrue(sketch.Segments.ContainsKey(1));

            Assert.IsTrue(sketch.Points[6].IsEqual(new Pnt2d(5.0, 0.0), 0.01));
        }
Beispiel #3
0
        public void WeldPointWithSegment_IncorrectParameters()
        {
            var sketch = Sketch.Create();
            var sb     = new SketchBuilder(sketch);

            sb.Line(0.0, 0.0, 10.0, 0.0); // 0, 1, s0

            Assert.IsFalse(SketchUtils.WeldPointsWithSegments(sketch, new[] { sketch.Segments[0] }, new[] { 0 }));
            Assert.AreEqual(2, sketch.Points.Count);
            Assert.AreEqual(1, sketch.Segments.Count);

            Assert.IsFalse(SketchUtils.WeldPointsWithSegments(sketch, new SketchSegment[] { }, new[] { 0 }));
            Assert.AreEqual(2, sketch.Points.Count);
            Assert.AreEqual(1, sketch.Segments.Count);

            Assert.IsFalse(SketchUtils.WeldPointsWithSegments(sketch, new[] { sketch.Segments[0] }, new int[] { }));
            Assert.AreEqual(2, sketch.Points.Count);
            Assert.AreEqual(1, sketch.Segments.Count);
        }