Пример #1
0
        public UVDirection GetDirection(DrawablePoint p1, DrawablePoint p2)
        {
            var i1 = _points.IndexOf(p1);
            var i2 = _points.IndexOf(p2);

            switch (i1)
            {
            case 0 when i2 == 3:
                return(UVDirection.U0V01);

            case 3 when i2 == 0:
                return(UVDirection.U0V10);

            case 0 when i2 == 12:
                return(UVDirection.V0U01);

            case 12 when i2 == 0:
                return(UVDirection.V0U10);

            case 3 when i2 == 15:
                return(UVDirection.V1U01);

            case 15 when i2 == 3:
                return(UVDirection.V1U10);

            case 12 when i2 == 15:
                return(UVDirection.U1V01);

            case 15 when i2 == 12:
                return(UVDirection.U1V10);

            default:
                return(UVDirection.U0V01);
            }
        }
Пример #2
0
        public bool AreLine(DrawablePoint p1, DrawablePoint p2)
        {
            if (!p1.IsCorner || !p2.IsCorner)
            {
                return(false);
            }

            var i1 = _points.IndexOf(p1);
            var i2 = _points.IndexOf(p2);

            if (i1 < 0 || i2 < 0)
            {
                return(false);
            }

            if (i1 == i2)
            {
                return(false);
            }

            var sm = i1 < i2 ? i1 : i2;
            var bi = i1 > i2 ? i1 : i2;

            if (sm == 0 && bi == 15)
            {
                return(false);
            }

            if (sm == 3 && bi == 12)
            {
                return(false);
            }

            return(true);
        }
Пример #3
0
 public void AddPoint(DrawablePoint point)
 {
     if (point != null && !_points.Contains(point))
     {
         _points.Add(point);
     }
 }
Пример #4
0
        private void AddPoint()
        {
            var point = new DrawablePoint(_cursor.Position.X, _cursor.Position.Y, _cursor.Position.Z);

            _listBox.Items.Add(point);
            _listBox.Refresh();

            _listBox.Items.OfType <ICurve>().Where(x => x.Selected).ToList().ForEach(x => x.AddPoint(point));
        }
Пример #5
0
 public void AddPoint(DrawablePoint point)
 {
     if (IsBernstein)
     {
         MessageBox.Show("Can't add points in Bernstein mode.");
         return;
     }
     if (point != null && !_points.Contains(point))
     {
         _points.Add(point);
     }
 }
Пример #6
0
        public void ReplacePoint(DrawablePoint old, DrawablePoint newPoint)
        {
            var index = _points.IndexOf(old);

            if (index < 0 || index >= _points.Count)
            {
                return;
            }

            if (!old.IsCorner)
            {
                return;
            }

            _points[index] = newPoint;
        }
Пример #7
0
        private void AddInterpolatingCurveFromIntersectingCurve()
        {
            var intersectingCurves = _listBox.Items.OfType <IntersectionCurve>().Where(x => x.Selected).ToList();

            if (intersectingCurves.Count != 1)
            {
                return;
            }

            var curve         = intersectingCurves[0];
            var interpolating = new InterpolatingBSpline();
            var points        = curve.GetPoints(out var parameters);

            foreach (var point in points)
            {
                var drawable = new DrawablePoint(point.X, point.Y, point.Z);
                interpolating.AddPoint(drawable);
            }

            _listBox.Items.Remove(curve);
            _listBox.Items.Add(interpolating);
        }
Пример #8
0
 public void AddPoint(DrawablePoint point)
 {
     _points.Add(point);
 }
Пример #9
0
        private void DrawPoint(MyColor color, Matrix4x4 matrixViewProj, Matrix4x4 viewportMatrix, Vector4 point, Graphics g = null, Pen pen = null, Pen secondPen = null, Pen thirdPen = null, DrawablePoint pointData = null, bool circle = false)
        {
            var transformed = Vector4.Transform(point, matrixViewProj);
            var p           = transformed / transformed.W;

            if (pointData != null)
            {
                pointData.ScreenPosition = new Point(-100, -100);
            }

            if (p.X > -1 && p.X < 1 && p.Y > -1 && p.Y < 1 && p.Z > -1 && p.Z < 1)
            {
                var screenPoint = Vector4.Transform(p, viewportMatrix);
                if (screenPoint.X < 2 || screenPoint.X > _bitmap.Width - 2 || screenPoint.Y < 2 ||
                    screenPoint.Y > _bitmap.Height - 2)
                {
                    return;
                }

                var x = (int)screenPoint.X;
                var y = (int)screenPoint.Y;
                _bitmap.SetPixel(x - 1, y, color);
                _bitmap.SetPixel(x, y + 1, color);
                _bitmap.SetPixel(x + 1, y, color);
                _bitmap.SetPixel(x, y - 1, color);
                _bitmap.SetPixel(x, y, color);

                if (pointData != null && thirdPen != null)
                {
                    pointData.ScreenPosition = new Point(x, y);
                    if (pointData.IsCorner)
                    {
                        g.DrawEllipse(thirdPen, screenPoint.X - 6, screenPoint.Y - 6, 12, 12);
                    }
                }

                if (circle && g != null && pen != null)
                {
                    g.DrawEllipse(pen, screenPoint.X - 5, screenPoint.Y - 5, 10, 10);
                }
                if (!circle && g != null && secondPen != null)
                {
                    g.DrawEllipse(secondPen, screenPoint.X - 5, screenPoint.Y - 5, 10, 10);
                }
            }
        }
Пример #10
0
 public void AddPoint(DrawablePoint point)
 {
 }