Ejemplo n.º 1
0
        public void RedrawCurve()
        {
            this.Children.Clear();
            this.Children.Add(this.AxisControlPoint);
            this.Children.Add(this.Axis);

            foreach (var cp in this.ControlPoints)
            {
                this.Children.Add(cp);
            }

            if (this.ControlPoints.Count == 1)
            {
                return;
            }

            var curvePoints = NurbsLogic.GetCurvePoints(this.Degree, this.ControlPointsNurbsList, this.KnotVector);

            if (curvePoints == null)
            {
                return;
            }

            for (var i = 0; i < curvePoints.Count - 1; i++)
            {
                var firstPoint  = curvePoints[i];
                var secondPoint = curvePoints[i + 1];
                var line        = new Line {
                    Stroke = Brushes.Aqua, IsHitTestVisible = false, X1 = firstPoint.X, Y1 = firstPoint.Y, X2 = secondPoint.X, Y2 = secondPoint.Y
                };
                this.Children.Add(line);
            }
        }
Ejemplo n.º 2
0
        private void Render()
        {
            this.HelixView.Children.Clear();
            var controlNet       = new List <List <NurbsPoint> >();
            var circleKnotVector = new decimal[1];

            foreach (var cp in this.ControlPoints)
            {
                controlNet.Add(SpaceLogic.Arc(cp, this.Angle, out circleKnotVector));
            }

            if (this.MenuItemAxis.IsChecked)
            {
                var axis = new LinesVisual3D
                {
                    Color  = Colors.Red,
                    Points = new Point3DCollection(new List <Point3D>
                    {
                        new Point3D(0, -1000d, 0),
                        new Point3D(0, 1000d, 0)
                    }),
                    Thickness = 1
                };
                this.HelixView.Children.Add(axis);
            }

            if (this.MenuItemNet.IsChecked)
            {
                this.DrawControlNet(controlNet);
            }

            if (this.MenuItemCurve.IsChecked)
            {
                var points =
                    new Point3DCollection(NurbsLogic.GetCurvePoints(this.Degree, this.ControlPoints, CurveKnotVector));
                var curve = new LinesVisual3D {
                    Color = Colors.BlueViolet, Points = points, Thickness = 1
                };
                this.HelixView.Children.Add(curve);
            }

            if (this.MenuItemPar.IsChecked)
            {
                this.DrawParallels(controlNet, circleKnotVector);
            }

            if (this.MenuItemMer.IsChecked)
            {
                this.DrawMeridians(controlNet, circleKnotVector);
            }
        }