예제 #1
0
 private void SetStartAngleValue(object data)
 {
     if (Builder.Node.Children.Count == 0)
         return;
     BeginUpdate();
     var angle = (double)data;
     Builder[1].RefTransformedPoint3D = NodeBuilderUtils.PositionForAngle(Builder, Builder[0].RefTransformedPoint3D,
                                                         Builder[1].RefTransformedPoint3D, angle);
     Builder.ExecuteFunction();
     NodeBuilderUtils.UpdateSketchesOnFaces(new NodeBuilder(Parent));
     EndVisualUpdate("");
     
 }
        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);
        }