Ejemplo n.º 1
0
        /// <summary>
        /// draws a 2d-polygon, which is stored in Array. See also <see cref="xyArray"/>.
        /// </summary>
        /// <param name="Array"><see cref="xyArray"/>.</param>
        public void drawPolyLine(xyArray Array)
        {
            Object Handle = null;

            if ((RenderKind == RenderKind.SnapBuffer))
            {
                Handle = Selector.RegisterSnapItem(new PolyLineSnappItem(Array));
            }
            if (PolygonMode == PolygonMode.Fill)
            {
                Loxy L = new Loxy();
                L.Add(Array);

                drawFilledArray2d(this, L);
                if ((RenderKind == RenderKind.SnapBuffer))
                {
                    Selector.UnRegisterSnapItem(Handle);
                }
                if (PolygonMode == PolygonMode.Fill)
                {
                    return;
                }
            }
            Primitives2d.drawArrayLined(this, Array);
            if ((RenderKind == RenderKind.SnapBuffer))
            {
                Selector.UnRegisterSnapItem(Handle);
            }
        }
Ejemplo n.º 2
0
        void _drawPolyPolyCurve(Loxy L, Loca Loca, int id)
        {
            Object Handle = null;

            if (PolygonMode == PolygonMode.Fill)
            {
                if ((RenderKind == RenderKind.SnapBuffer))
                {
                    Handle = Selector.RegisterSnapItem(getSI(id, Loca, L, -1));
                }
                drawFilledArray2d(this, L);

                if ((RenderKind == RenderKind.SnapBuffer))
                {
                    MeshCreator.Renew();
                    Selector.UnRegisterSnapItem(Handle);
                }
                return;
            }

            if ((RenderKind == RenderKind.SnapBuffer))
            {
                SnappItem S = (getSI(id, Loca, L, -1));

                Handle = Selector.RegisterSnapItem(S);
            }
            {
                for (int i = 0; i < L.Count; i++)
                {
                    //IndexType[] Indices = new IndexType[L[i].Count];
                    //for (int k = 0;k < L[i].Count; k++)
                    //{
                    //    Indices[k] = k;
                    //}
                    //xyzf[] Points = new xyzf[L[i].Count];
                    //for (int k = 0; k < L[i].Count; k++)
                    //{
                    //    Points[k] = new xyzf((float)L[i][k].X, (float)L[i][k].y, 0f);
                    //}
                    //Primitives3d.drawTriangles(this,Indices, Points, null, null, null);
                    ////if ((RenderKind == RenderKind.SnapBuffer))
                    ////  Selector.ToSnapBuffer((uint)i);
                    Primitives2d.drawArrayLined(this, L[i]);
                }
            }
            if ((RenderKind == RenderKind.SnapBuffer))
            {
                Selector.UnRegisterSnapItem(Handle);
            }
        }
Ejemplo n.º 3
0
        private void drawFilledArray2d(OpenGlDevice Device, Loxy L)
        {
            if (L.Count == 0)
            {
                return;
            }
            double xMax = -10000000;
            double yMax = -10000000;
            double xMin = 10000000;
            double yMin = 10000000;

            if ((Device.texture != null) && (Device.texture.SoBigAsPossible != Drawing3d.Texture.BigAsPosible.None))

            {
                for (int i = 0; i < L[0].Count; i++)
                {
                    if (L[0][i].X > xMax)
                    {
                        xMax = L[0][i].X;
                    }
                    if (L[0][i].X < xMin)
                    {
                        xMin = L[0][i].X;
                    }
                    if (L[0][i].Y > yMax)
                    {
                        yMax = L[0][i].Y;
                    }
                    if (L[0][i].Y < yMin)
                    {
                        yMin = L[0][i].Y;
                    }
                }
            }
            double xDiff = xMax - xMin;
            double yDiff = yMax - yMin;


            List <IndexType> Indices = new List <IndexType>();

            xyf[] Points = null;
            L.TriAngulation(Indices, ref Points);
            xyf[] Texture = new xyf[Points.Length];
            float Aspectx = 1;
            float Aspecty = 1;

            if ((Device.texture != null) && (Device.texture.SoBigAsPossible != Drawing3d.Texture.BigAsPosible.None))

            {
                if (Device.texture.Bitmap != null)
                {
                    double w = (float)Device.texture.Bitmap.Width / Device.PixelsPerUnit;
                    double h = (float)Device.texture.Bitmap.Height / Device.PixelsPerUnit;
                    if (Device.texture.KeepAspect)
                    {
                        if (Device.texture.SoBigAsPossible == Drawing3d.Texture.BigAsPosible.Height)
                        {
                            Aspectx = (float)(h / w);
                        }
                        else
                        {
                            Aspecty = (float)(w / h);
                        }
                    }
                }
                for (int i = 0; i < Points.Length; i++)
                {
                    if (Device.texture.KeepAspect)
                    {
                        if (Aspecty != 1)
                        {
                            Texture[i] = new xyf((Points[i].x - (float)xMin) / (float)(xDiff), (Points[i].y - (float)yMin) / (float)(xDiff / Aspecty));
                        }
                        if (Aspectx != 1)
                        {
                            Texture[i] = new xyf((Points[i].x - (float)xMin) / (float)(yDiff / Aspectx), (Points[i].y - (float)yMin) / (float)(yDiff));
                        }
                    }
                    else
                    {
                        Texture[i] = new xyf((Points[i].x - (float)xMin) / (float)(xDiff), (Points[i].y - (float)yMin) / (float)(yDiff));
                    }
                }
            }
            else
            {
                for (int i = 0; i < Points.Length; i++)
                {
                    Texture[i] = Points[i] + Points[0] * (-1);
                }
            }

            Primitives2d.drawTriangles2d(Device, Indices, Points, Texture);
        }