Beispiel #1
0
        public void ConvertBezier3ToBezier()
        {
            var sketch = Sketch.Create();
            int p1     = sketch.AddPoint(new Pnt2d(-2, 0));
            int p2     = sketch.AddPoint(new Pnt2d(0.5, 5));
            int p3     = sketch.AddPoint(new Pnt2d(2, 3));
            int p4     = sketch.AddPoint(new Pnt2d(3, 2));
            var s1     = new SketchSegmentBezier(p1, p2, p3, p4);

            sketch.AddSegment(s1);

            Assert.IsFalse(SketchUtils.CanConvertSegment(sketch, s1, typeof(SketchSegmentBezier)));
        }
Beispiel #2
0
        public void ConvertToLine()
        {
            var sketch = Sketch.Create();
            int p1     = sketch.AddPoint(new Pnt2d(0, 0));
            int p2     = sketch.AddPoint(new Pnt2d(5, 3));
            int pr     = sketch.AddPoint(new Pnt2d(2, 3));
            var s1     = new SketchSegmentArc(p1, p2, pr);

            sketch.AddSegment(s1);

            Assert.IsTrue(SketchUtils.CanConvertSegment(sketch, s1, typeof(SketchSegmentLine)));
            var s2 = SketchUtils.ConvertSegment(sketch, s1, typeof(SketchSegmentLine));

            Assert.AreNotEqual(SketchUtils.ConvertSegmentFailed, s2);

            Assert.AreEqual(1, sketch.Segments.Count);
            Assert.IsInstanceOf <SketchSegmentLine>(sketch.Segments[1]);
            Assert.AreEqual(p1, sketch.Segments[s2].StartPoint);
            Assert.AreEqual(p2, sketch.Segments[s2].EndPoint);
        }
Beispiel #3
0
        public void ConvertLineToBezier()
        {
            var sketch = Sketch.Create();
            int p1     = sketch.AddPoint(new Pnt2d(0, 0));
            int p2     = sketch.AddPoint(new Pnt2d(10, 0));
            var s1     = new SketchSegmentLine(p1, p2);

            sketch.AddSegment(s1);

            Assert.IsTrue(SketchUtils.CanConvertSegment(sketch, s1, typeof(SketchSegmentBezier)));
            var s2 = SketchUtils.ConvertSegment(sketch, s1, typeof(SketchSegmentBezier));

            Assert.AreNotEqual(SketchUtils.ConvertSegmentFailed, s2);

            Assert.AreEqual(1, sketch.Segments.Count);
            Assert.IsInstanceOf <SketchSegmentBezier>(sketch.Segments[1]);
            Assert.AreEqual(p1, sketch.Segments[s2].StartPoint);
            Assert.AreEqual(p2, sketch.Segments[s2].EndPoint);
            Assert.AreEqual(p2 + 1, sketch.Segments[s2].Points[1]);
            Assert.AreEqual(p2 + 2, sketch.Segments[s2].Points[2]);
        }
Beispiel #4
0
        public void ConvertBezierToArc()
        {
            var sketch = Sketch.Create();
            int p1     = sketch.AddPoint(new Pnt2d(-2, 0));
            int p2     = sketch.AddPoint(new Pnt2d(0.5, 5));
            int p3     = sketch.AddPoint(new Pnt2d(3, 2));
            var s1     = new SketchSegmentBezier(p1, p2, p3);

            sketch.AddSegment(s1);

            Assert.IsTrue(SketchUtils.CanConvertSegment(sketch, s1, typeof(SketchSegmentArc)));
            var s2 = SketchUtils.ConvertSegment(sketch, s1, typeof(SketchSegmentArc));

            Assert.AreNotEqual(SketchUtils.ConvertSegmentFailed, s2);

            Assert.AreEqual(1, sketch.Segments.Count);
            Assert.IsInstanceOf <SketchSegmentArc>(sketch.Segments[1]);
            Assert.AreEqual(p1, sketch.Segments[s2].StartPoint);
            Assert.AreEqual(p3, sketch.Segments[s2].EndPoint);
            Assert.AreEqual(p3 + 1, sketch.Segments[s2].Points[2]);
        }
Beispiel #5
0
        public void ConvertEllipticalArcToArc()
        {
            var sketch = Sketch.Create();
            int p1     = sketch.AddPoint(new Pnt2d(2, 1));
            int p2     = sketch.AddPoint(new Pnt2d(-2, 5));
            int pc     = sketch.AddPoint(new Pnt2d(0, 0));
            var s1     = new SketchSegmentEllipticalArc(p1, p2, pc);

            sketch.AddSegment(s1);

            Assert.IsTrue(SketchUtils.CanConvertSegment(sketch, s1, typeof(SketchSegmentArc)));
            var s2 = SketchUtils.ConvertSegment(sketch, s1, typeof(SketchSegmentArc));

            Assert.AreNotEqual(SketchUtils.ConvertSegmentFailed, s2);

            Assert.AreEqual(1, sketch.Segments.Count);
            Assert.IsInstanceOf <SketchSegmentArc>(sketch.Segments[1]);
            Assert.AreEqual(p1, sketch.Segments[s2].StartPoint);
            Assert.AreEqual(p2, sketch.Segments[s2].EndPoint);
            Assert.AreEqual(pc + 1, sketch.Segments[s2].Points[2]);
        }