コード例 #1
0
        public void GetArcAnglesTest()
        {
            var sketchCreator = new SketchCreator(_document, false);
            var sketchNode = sketchCreator.BuildSketchNode();
            _document.Transact();

            var arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 3, 0), new Point3D(8, 3, 0),
                                           new Point3D(4, 7, 0));

            Assert.AreEqual(NodeBuilderUtils.GetStartAngle(arcBuilder), 0);
            Assert.AreEqual(NodeBuilderUtils.GetEndAngle(arcBuilder), 90);
            Assert.AreEqual(NodeBuilderUtils.GetInternalAngle(arcBuilder), 90);

            // s >0, e > 0, s < e
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(7.464101, 2, 0),
                                           new Point3D(0.535898, 2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetStartAngle(arcBuilder) - 30) < 0.00001, "Incorrect start angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetEndAngle(arcBuilder) - 150) < 0.00001, "Incorrect end angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetInternalAngle(arcBuilder) - 120) < 0.00001, "Incorrect internal angle");

            // s >0, e > 0, s > e
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(0.535898, 2, 0), new Point3D(7.464101, 2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetStartAngle(arcBuilder) - 150) < 0.00001, "Incorrect start angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetEndAngle(arcBuilder) - 30) < 0.00001, "Incorrect end angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetInternalAngle(arcBuilder) - 240) < 0.00001, "Incorrect internal angle");

            // s < 0, e < 0, s > e
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(7.464101, -2, 0),
                                           new Point3D(0.535898, -2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetStartAngle(arcBuilder) + 30) < 0.00001, "Incorrect start angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetEndAngle(arcBuilder) + 150) < 0.00001, "Incorrect end angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetInternalAngle(arcBuilder) - 240) < 0.00001, "Incorrect internal angle");

            // s < 0, e < 0, s < e
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(0.535898, -2, 0), new Point3D(7.464101, -2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetStartAngle(arcBuilder) + 150) < 0.00001, "Incorrect start angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetEndAngle(arcBuilder) + 30) < 0.00001, "Incorrect end angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetInternalAngle(arcBuilder) - 120) < 0.00001, "Incorrect internal angle");

            // s > 0, e < 0 
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(7.464101, 2, 0),
                                           new Point3D(7.464101, -2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetStartAngle(arcBuilder) - 30) < 0.00001, "Incorrect start angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetEndAngle(arcBuilder) + 30) < 0.00001, "Incorrect end angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetInternalAngle(arcBuilder) - 300) < 0.00001, "Incorrect internal angle");

            // s < 0, e > 0
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(7.464101, -2, 0), new Point3D(7.464101, 2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetStartAngle(arcBuilder) + 30) < 0.00001, "Incorrect start angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetEndAngle(arcBuilder) - 30) < 0.00001, "Incorrect end angle");
            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetInternalAngle(arcBuilder) - 60) < 0.00001, "Incorrect internal angle");
        }
コード例 #2
0
        public void SetArcAnglesTest()
        {
            var sketchCreator = new SketchCreator(_document, false);
            var sketchNode = sketchCreator.BuildSketchNode();
            _document.Transact();

            // set start angle value, s > 0
            var arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(7.464101, 2, 0),
                                           new Point3D(0.535898, 2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetStartAngle(arcBuilder) - 30) < 0.00001, "Incorrect start angle");
            var newPoint = NodeBuilderUtils.PositionForAngle(arcBuilder, arcBuilder[0].RefTransformedPoint3D,
                                                             arcBuilder[1].RefTransformedPoint3D, 90);
            Assert.IsTrue(Math.Abs(newPoint.X - 4) < 0.00001);
            Assert.IsTrue(Math.Abs(newPoint.Y - 4) < 0.00001);

            // set end angle value, e > 0
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(7.464101, 2, 0),
                                           new Point3D(0.535898, 2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetEndAngle(arcBuilder) - 150) < 0.00001, "Incorrect start angle");
            newPoint = NodeBuilderUtils.PositionForAngle(arcBuilder, arcBuilder[0].RefTransformedPoint3D,
                                                             arcBuilder[2].RefTransformedPoint3D, 90);
            Assert.IsTrue(Math.Abs(newPoint.X - 4) < 0.00001);
            Assert.IsTrue(Math.Abs(newPoint.Y - 4) < 0.00001);

            // set start angle value, s < 0
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(7.464101, -2, 0),
                                           new Point3D(0.535898, 2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetStartAngle(arcBuilder) + 30) < 0.00001, "Incorrect start angle");
            newPoint = NodeBuilderUtils.PositionForAngle(arcBuilder, arcBuilder[0].RefTransformedPoint3D,
                                                             arcBuilder[1].RefTransformedPoint3D, -90);
            Assert.IsTrue(Math.Abs(newPoint.X - 4) < 0.00001);
            Assert.IsTrue(Math.Abs(newPoint.Y + 4) < 0.00001);

            // set end angle value, e < 0
            arcBuilder = TestUtils.Arc(_document, sketchNode, new Point3D(4, 0, 0), new Point3D(7.464101, 2, 0),
                                           new Point3D(0.535898, -2, 0));

            Assert.IsTrue(Math.Abs(NodeBuilderUtils.GetEndAngle(arcBuilder) + 150) < 0.00001, "Incorrect start angle");
            newPoint = NodeBuilderUtils.PositionForAngle(arcBuilder, arcBuilder[0].RefTransformedPoint3D,
                                                             arcBuilder[2].RefTransformedPoint3D, -90);
            Assert.IsTrue(Math.Abs(newPoint.X - 4) < 0.00001);
            Assert.IsTrue(Math.Abs(newPoint.Y + 4) < 0.00001);
        }
コード例 #3
0
 private void GetStartAngleValue(ref object resultvalue)
 {
     resultvalue = NodeBuilderUtils.GetStartAngle(Builder);
 }