Ejemplo n.º 1
0
        public void DrawPoints(Matrix4d transformacja)
        {
            if (ShowControlPoints)
            {
                for (int i = 0; i < PatchPoints.GetLength(0); i++)
                {
                    for (int j = 0; j < PatchPoints.GetLength(1); j++)
                    {
                        PatchPoints[i, j].Draw(transformacja, 5);
                    }
                }
            }


            //TODO: Przenieść do funkcji rysującej płatek
            //CalculateBezierPoints();



            //Rysowanie punktów
            if (ShowBernstein)
            {
                for (int i = 0; i < _additionalPoints.GetLength(0); i++)
                {
                    for (int j = 0; j < _additionalPoints.GetLength(1); j++)
                    {
                        _additionalPoints[i, j].Draw(transformacja, 4);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void DrawPolyline(Matrix4d transformacja)
        {
            if (PolylineEnabled)
            {
                GL.Begin(BeginMode.Lines);
                GL.Color3(1.0, 1.0, 1.0);

                for (int i = 0; i < PatchPoints.GetLength(0); i++)
                {
                    for (int j = 0; j < PatchPoints.GetLength(1) - 1; j++)
                    {
                        var _windowCoordinates = projection.Multiply(transformacja.Multiply(PatchPoints[i, j].Coordinates));
                        GL.Vertex2(_windowCoordinates.X, _windowCoordinates.Y);

                        _windowCoordinates = projection.Multiply(transformacja.Multiply(PatchPoints[i, j + 1].Coordinates));
                        GL.Vertex2(_windowCoordinates.X, _windowCoordinates.Y);
                    }
                }

                for (int i = 0; i < PatchPoints.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < PatchPoints.GetLength(1); j++)
                    {
                        var _windowCoordinates = projection.Multiply(transformacja.Multiply(PatchPoints[i, j].Coordinates));
                        GL.Vertex2(_windowCoordinates.X, _windowCoordinates.Y);

                        _windowCoordinates = projection.Multiply(transformacja.Multiply(PatchPoints[i + 1, j].Coordinates));
                        GL.Vertex2(_windowCoordinates.X, _windowCoordinates.Y);
                    }
                }

                if (PatchesAreCylinder)
                {
                    for (int i = 0; i < PatchPoints.GetLength(0); i++)
                    {
                        var _windowCoordinates = projection.Multiply(transformacja.Multiply(PatchPoints[i, 0].Coordinates));
                        GL.Vertex2(_windowCoordinates.X, _windowCoordinates.Y);

                        _windowCoordinates = projection.Multiply(transformacja.Multiply(PatchPoints[i, PatchPoints.GetLength(1) - 1].Coordinates));
                        GL.Vertex2(_windowCoordinates.X, _windowCoordinates.Y);
                    }
                }
                GL.End();
            }
        }
Ejemplo n.º 3
0
        public void CalculateBezierPoints()
        {
            //Fragment do wyznaczania punktów beziera
            //Wywoływany w konstruktorze klasy i przez metodę Scene.MoveSelectedPoints

            if (PatchesAreCylinder)
            {
                var PatchPoints2 = new Point[VerticalPatches + 3, HorizontalPatches + 3 + 3];
                _additionalPoints2 = new Point[VerticalPatches + 3, 1 + 9 + 3 * HorizontalPatches];
                _additionalPoints  = new Point[1 + 3 * VerticalPatches, 1 + 9 + 3 * HorizontalPatches];
                for (int i = 0; i < VerticalPatches + 3; i++)
                {
                    for (int j = 0; j < HorizontalPatches + 3; j++)
                    {
                        PatchPoints2[i, j] = PatchPoints[i, j];
                    }
                }

                for (int i = 0; i < VerticalPatches + 3; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        PatchPoints2[i, j + HorizontalPatches + 3] = PatchPoints[i, j];
                    }
                }


                for (int k = 0; k < PatchPoints2.GetLength(0); k++)
                {
                    var tempCollection = new ObservableCollection <Point>();
                    for (int i = 0; i < PatchPoints2.GetLength(1); i++)
                    {
                        tempCollection.Add(PatchPoints2[k, i]);
                    }
                    int d = 0;
                    CalculateAdditionalPoints(tempCollection);
                    foreach (var item in _additionalPointsCollection2)
                    {
                        _additionalPoints2[k, d] = item;
                        d++;
                    }
                }

                _additionalPointsCollection2.Clear();

                for (int k = 0; k < _additionalPoints2.GetLength(1); k++)
                {
                    var tempCollection = new ObservableCollection <Point>();

                    for (int i = 0; i < _additionalPoints2.GetLength(0); i++)
                    {
                        tempCollection.Add(_additionalPoints2[i, k]);
                    }
                    int d = 0;
                    CalculateAdditionalPoints(tempCollection);

                    foreach (var item in _additionalPointsCollection2)
                    {//Może warto zmienić kolejność indeksów na d,k teraz k,d?
                        _additionalPoints[d, k] = item;
                        d++;
                    }
                }
            }
            else
            {
                for (int k = 0; k < PatchPoints.GetLength(0); k++)
                {
                    var tempCollection = new ObservableCollection <Point>();
                    for (int i = 0; i < PatchPoints.GetLength(1); i++)
                    {
                        tempCollection.Add(PatchPoints[k, i]);
                    }

                    int d = 0;

                    CalculateAdditionalPoints(tempCollection);
                    foreach (var item in _additionalPointsCollection2)
                    {
                        _additionalPoints2[k, d] = item;
                        d++;
                    }
                }


                _additionalPointsCollection2.Clear();

                for (int k = 0; k < _additionalPoints2.GetLength(1); k++)
                {
                    var tempCollection = new ObservableCollection <Point>();

                    for (int i = 0; i < _additionalPoints2.GetLength(0); i++)
                    {
                        tempCollection.Add(_additionalPoints2[i, k]);
                    }
                    int d = 0;
                    CalculateAdditionalPoints(tempCollection);

                    foreach (var item in _additionalPointsCollection2)
                    {//Może warto zmienić kolejność indeksów na d,k teraz k,d?
                        _additionalPoints[d, k] = item;
                        d++;
                    }
                }
            }



            CalculateCurvesPatchPoints();
        }
Ejemplo n.º 4
0
        public AllCollections PrepareToSave()
        {
            result = new AllCollections();
            int PointsCounter = 0;


            foreach (var item in TorusCollection1)
            {
                TorusExchange temp = new TorusExchange(item.r, item.R, item._division_fi, item.Division_teta, item.Center, item.Center, item.Center);
                result.toruses.Add(temp);
            }

            foreach (var item in BezierPatchC2Collection1)
            {
                int[][] pointIndices = new int[item.VerticalPatches + 3][];
                for (int i = 0; i < item.PatchPoints.GetLength(0); i++)
                {
                    pointIndices[i] = new int[item.HorizontalPatches + 3];
                    for (int j = 0; j < item.PatchPoints.GetLength(1); j++)
                    {
                        result.points.Add(new PointExchange(item.PatchPoints[i, j].Name, item.PatchPoints[i, j].X, item.PatchPoints[i, j].Y, item.PatchPoints[i, j].Z));
                        pointIndices[i][j] = PointsCounter;
                        PointsCounter++;
                    }
                }

                Surface temp = new Surface(item.PatchesAreCylinder, item.HorizontalPatches, item.VerticalPatches, item.Name, pointIndices, item.u, item.v);
                result.surfacesC2.Add(temp);
            }

            List <Point> AllPoints = new List <Point>();

            foreach (var item in BezierPatchCollection1)
            {
                Point[,] PatchPoints;
                PatchPoints = item.GetAllPointsInOneArray();
                int[][] pointIndices = new int[PatchPoints.GetLength(0)][];



                for (int i = 0; i < PatchPoints.GetLength(0); i++)
                {
                    pointIndices[i] = new int[PatchPoints.GetLength(1)];

                    for (int j = 0; j < PatchPoints.GetLength(1); j++)
                    {
                        int a = AllPoints.IndexOf(PatchPoints[i, j]);

                        if (a == -1)
                        {
                            AllPoints.Add(PatchPoints[i, j]);
                            result.points.Add(new PointExchange(PatchPoints[i, j].Name, PatchPoints[i, j].X,
                                                                PatchPoints[i, j].Y, PatchPoints[i, j].Z));
                            pointIndices[i][j] = PointsCounter;
                            PointsCounter++;
                        }
                        else
                        {
                            pointIndices[i][j] = a;
                            //MessageBox.Show(a.ToString());
                        }
                    }
                }

                Surface temp = new Surface(item.PatchesAreCylinder, item.HorizontalPatches, item.VerticalPatches, item.Name, pointIndices, item._patchHorizontalDivision, item._patchVerticalDivision);
                result.surfacesC0.Add(temp);
            }

            foreach (var item in _bezierCurveCollection1)
            {
                int[] pointIndices = new int[item.PointsCollection.Count];

                for (int j = 0; j < item.PointsCollection.Count; j++)
                {
                    result.points.Add(new PointExchange(item.PointsCollection[j].Name, item.PointsCollection[j].X, item.PointsCollection[j].Y, item.PointsCollection[j].Z));
                    pointIndices[j] = PointsCounter;
                    PointsCounter++;
                }

                CurveExchange temp = new CurveExchange(item.Name, pointIndices);

                if (item.CurveType == "C0")
                {
                    result.curvesC0.Add(temp);
                }
                else if (item.CurveType == "C2")
                {
                    result.curvesC2.Add(temp);
                }
                else if (item.CurveType == "C2Interpolation")
                {
                    result.curvesC2I.Add(temp);
                }
                else
                {
                }
            }



            return(result);
        }