Exemplo n.º 1
0
        public void SplitOnceSecondSegment()
        {
            // Act
            var result = FillFactory.CreateTriangleCCW().SplitAtDistances(new double[] { 5 });

            // Assert
            Assert.AreEqual(2, result.Count);

            var curve0 = result[0];

            Assert.AreEqual(2, curve0.Elements.Count);
            Assert.AreEqual(0, curve0.Elements[0].NodeStart.x, delta);
            Assert.AreEqual(0, curve0.Elements[0].NodeStart.y, delta);
            Assert.AreEqual(4, curve0.Elements[1].NodeStart.x, delta);
            Assert.AreEqual(0, curve0.Elements[1].NodeStart.y, delta);
            Assert.AreEqual(4, curve0.Elements[1].NodeEnd.x, delta);
            Assert.AreEqual(1, curve0.Elements[1].NodeEnd.y, delta);

            var curve1 = result[1];

            Assert.AreEqual(2, curve1.Elements.Count);
            Assert.AreEqual(4, curve1.Elements[0].NodeStart.x, delta);
            Assert.AreEqual(1, curve1.Elements[0].NodeStart.y, delta);
            Assert.AreEqual(4, curve1.Elements[1].NodeStart.x, delta);
            Assert.AreEqual(3, curve1.Elements[1].NodeStart.y, delta);
            Assert.AreEqual(0, curve1.Elements[1].NodeEnd.x, delta);
            Assert.AreEqual(0, curve1.Elements[1].NodeEnd.y, delta);
        }
Exemplo n.º 2
0
        public void SplitTwiceFirstSegmentConnect()
        {
            // Act
            var result = FillFactory.CreateTriangleCCW().SplitAtDistances(new double[] { 1, 3 }, true);

            // Assert
            Assert.AreEqual(2, result.Count);

            var curve0 = result[0];

            Assert.AreEqual(1, curve0.Elements.Count);
            Assert.AreEqual(1, curve0.Elements[0].NodeStart.x, delta);
            Assert.AreEqual(0, curve0.Elements[0].NodeStart.y, delta);
            Assert.AreEqual(3, curve0.Elements[0].NodeEnd.x, delta);
            Assert.AreEqual(0, curve0.Elements[0].NodeEnd.y, delta);

            var curve1 = result[1];

            Assert.AreEqual(4, curve1.Elements.Count);
            Assert.AreEqual(3, curve1.Elements[0].NodeStart.x, delta);
            Assert.AreEqual(0, curve1.Elements[0].NodeStart.y, delta);
            Assert.AreEqual(4, curve1.Elements[1].NodeStart.x, delta);
            Assert.AreEqual(0, curve1.Elements[1].NodeStart.y, delta);
            Assert.AreEqual(4, curve1.Elements[2].NodeStart.x, delta);
            Assert.AreEqual(3, curve1.Elements[2].NodeStart.y, delta);
            Assert.AreEqual(0, curve1.Elements[3].NodeStart.x, delta);
            Assert.AreEqual(0, curve1.Elements[3].NodeStart.y, delta);
            Assert.AreEqual(1, curve1.Elements[3].NodeEnd.x, delta);
            Assert.AreEqual(0, curve1.Elements[3].NodeEnd.y, delta);
        }
Exemplo n.º 3
0
        public void TotalLength()
        {
            // Act
            var length = FillFactory.CreateTriangleCCW().TotalLength();

            // Assert
            Assert.AreEqual(4 + 3 + (Math.Sqrt(4 * 4 + 3 * 3)), length, delta);
        }
Exemplo n.º 4
0
        public void IsClockwise_False()
        {
            // Arrange
            var loop = FillFactory.CreateTriangleCCW();

            // Act
            bool isClockwise = loop.IsClockwise();

            // Assert
            Assert.IsFalse(isClockwise);
        }
Exemplo n.º 5
0
        public void Reversed()
        {
            // Arrange
            var loop = FillFactory.CreateTriangleCCW();

            // Act
            var reversed = (FillLoop <FillSegment>)loop.Reversed();

            // Assert
            Assert.AreEqual(loop.Elements.Count, reversed.Elements.Count);
            Assert.AreEqual(loop.Elements[0].NodeStart, reversed.Elements[0].NodeStart);
            Assert.AreEqual(loop.Elements[^ 1].NodeEnd, reversed.Elements[^ 1].NodeEnd);
Exemplo n.º 6
0
        public void RollToVertex()
        {
            // Arrange
            var loop = FillFactory.CreateTriangleCCW();

            // Act
            var rolled = (FillLoop <FillSegment>)loop.RollToVertex(1);

            // Assert
            Assert.AreEqual(loop.Elements.Count, rolled.Elements.Count);
            Assert.AreEqual(loop.Elements[0].NodeEnd, rolled.Elements[0].NodeStart);
        }
Exemplo n.º 7
0
        public void FindClosestElementToPoint_Case2()
        {
            // Arrange
            var loop  = FillFactory.CreateTriangleCCW();
            var point = new Vector2d(5, -1);

            // Act
            var distance = loop.FindClosestElementToPoint(point, out var location);

            // Assert
            Assert.AreEqual(Math.Sqrt(2), distance, delta);
            Assert.AreEqual(1, location.Index);
            Assert.AreEqual(0, location.ParameterizedDistance, delta);
        }
Exemplo n.º 8
0
        public void Vertices_RepeatFirstFalse()
        {
            // Act
            var vertices = FillFactory.CreateTriangleCCW().Vertices(false).ToList();

            // Assert
            Assert.AreEqual(3, vertices.Count);

            Assert.AreEqual(0, vertices[0].x, delta);
            Assert.AreEqual(0, vertices[0].y, delta);

            Assert.AreEqual(4, vertices[1].x, delta);
            Assert.AreEqual(0, vertices[1].y, delta);

            Assert.AreEqual(4, vertices[2].x, delta);
            Assert.AreEqual(3, vertices[2].y, delta);
        }
Exemplo n.º 9
0
        public void CloneBareAsCurve()
        {
            // Arrange
            var settings = new SingleMaterialFFFSettings();
            var loop     = FillFactory.CreateTriangleCCW();

            loop.FillType       = settings.FillTypeFactory.OuterPerimeter();
            loop.PerimeterOrder = 100;
            loop.IsHoleShell    = true;
            loop.FillThickness  = 3;

            // Act
            var clone = loop.CloneBareAsCurve();

            // Assert
            Assert.AreEqual(100, clone.PerimeterOrder);
            Assert.AreEqual(3, clone.FillThickness);
            Assert.IsTrue(clone.IsHoleShell);
            Assert.IsInstanceOfType(clone.FillType, typeof(OuterPerimeterFillType));
        }
Exemplo n.º 10
0
        public void ConvertToCurve()
        {
            // Act
            var result = FillFactory.CreateTriangleCCW().ConvertToCurve();

            // Assert
            Assert.AreEqual(3, result.Elements.Count);

            Assert.AreEqual(0, result.Elements[0].NodeStart.x, delta);
            Assert.AreEqual(0, result.Elements[0].NodeStart.y, delta);

            Assert.AreEqual(4, result.Elements[1].NodeStart.x, delta);
            Assert.AreEqual(0, result.Elements[1].NodeStart.y, delta);

            Assert.AreEqual(4, result.Elements[2].NodeStart.x, delta);
            Assert.AreEqual(3, result.Elements[2].NodeStart.y, delta);

            Assert.AreEqual(0, result.Elements[2].NodeEnd.x, delta);
            Assert.AreEqual(0, result.Elements[2].NodeEnd.y, delta);
        }
Exemplo n.º 11
0
        public void RollFirstSegmentWithinToleranceHighSideCCW()
        {
            // Arrange
            var triangle = FillFactory.CreateTriangleCCW();

            // Act
            var result = (FillLoop <FillSegment>)triangle.RollBetweenVertices(new ElementLocation(0, 1 - (0.004 / 4)), 0.005);

            // Assert
            Assert.AreEqual(3, result.Elements.Count);

            Assert.AreEqual(4, result.Elements[0].NodeStart.x, delta);
            Assert.AreEqual(0, result.Elements[0].NodeStart.y, delta);

            Assert.AreEqual(4, result.Elements[1].NodeStart.x, delta);
            Assert.AreEqual(3, result.Elements[1].NodeStart.y, delta);

            Assert.AreEqual(0, result.Elements[2].NodeStart.x, delta);
            Assert.AreEqual(0, result.Elements[2].NodeStart.y, delta);
        }
Exemplo n.º 12
0
        public void RollLastSegmentAtEnd()
        {
            // Arrange
            var triangle = FillFactory.CreateTriangleCCW();

            // Act
            var result = (FillLoop <FillSegment>)triangle.RollBetweenVertices(new ElementLocation(2, 1));

            // Assert
            Assert.AreEqual(3, result.Elements.Count);

            Assert.AreEqual(0, result.Elements[0].NodeStart.x, delta);
            Assert.AreEqual(0, result.Elements[0].NodeStart.y, delta);

            Assert.AreEqual(4, result.Elements[1].NodeStart.x, delta);
            Assert.AreEqual(0, result.Elements[1].NodeStart.y, delta);

            Assert.AreEqual(4, result.Elements[2].NodeStart.x, delta);
            Assert.AreEqual(3, result.Elements[2].NodeStart.y, delta);
        }