Ejemplo n.º 1
0
 public void RenderSnap(Graphics g, ScreenTrans zoom, RenderParameter RParas, List <SnapMode> SModes)
 {
     /////渲染捕捉到的几何体
     if (!(SModes.Contains(SnapMode.Geo2DRim)))
     {
         return;
     }
     try
     {
         if (data.objSnap.Geo2D_Rims == null || data.objSnap.Geo2D_Rims.Count == 0)
         {
             return;
         }
     }
     catch { }
     /////
     for (int i = 0; i < data.objSnap.Geo2D_Rims.Count; i++)
     {
         RimT = data.Rims[data.objSnap.Geo2D_Rims[i]];
         if (RimT.Count == 0)
         {
             continue;
         }
         Ps = new PointF[RimT.Shape.Count];
         for (int j = 0; j < RimT.Shape.Count; j++)
         {
             Ps[j] = zoom.WorldToScreen((float)(RimT.Shape[j].X), (float)(RimT.Shape[j].Y));
         }
         g.DrawPolygon(RParas.SnapGeo2DPen, Ps);
     }
 }
Ejemplo n.º 2
0
 public void Render(Graphics g, ScreenTrans zoom, RenderParameter RParas)
 {
     if (RParas.Show_WRim2D == false)
     {
         return;
     }
     try
     {
         if (data.Rims == null || data.Rims.Count == 0)
         {
             return;
         }
     }
     catch { }
     /////
     for (int i = 0; i < data.Rims.Count; i++)
     {
         RenderRim(g, zoom, RParas, data.Rims[i]);
     }
     if (RParas.SwitchSnap == false)
     {
         return;                              /////如果对象捕捉没有打开则直接返回
     }
     RenderSnap(g, zoom, RParas, RParas.SModes);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Renders the voronoi diagram.
        /// </summary>
        public void Render(Graphics g, ScreenTrans zoom, RenderParameter renderColors)
        {
            this.renderColors = renderColors;

            var points = data.VoronoiPoints;
            var edges  = data.VoronoiEdges;

            if (points != null && edges != null)
            {
                uint   k;
                PointF p0, p1;
                int    n = edges.Length / 2;

                for (int i = 0; i < n; i++)
                {
                    // First endpoint of voronoi edge
                    k  = edges[2 * i];
                    p0 = new PointF(points[2 * k], points[2 * k + 1]);

                    // Second endpoint of voronoi edge
                    k  = edges[2 * i + 1];
                    p1 = new PointF(points[2 * k], points[2 * k + 1]);

                    // Render the edge
                    if (zoom.ViewportContains(p0.X, p0.Y) ||
                        zoom.ViewportContains(p1.X, p1.Y))
                    {
                        p0 = zoom.WorldToScreen(p0.X, p0.Y);
                        p1 = zoom.WorldToScreen(p1.X, p1.Y);

                        g.DrawLine(renderColors.VoronoiLine, p0, p1);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        List <int>[] RenderSort = new List <int> [6];  /////显示顺序

        public WGeoRenderer(RenderData data, RenderParameter RParas)
        {
            this.data   = data;
            this.RParas = RParas;
            for (int i = 0; i < 6; i++)
            {
                RenderSort[i] = new List <int>();
            }
        }
Ejemplo n.º 5
0
 private void RenderRim(Graphics g, ScreenTrans zoom, RenderParameter RParas, WRim2D Rim)
 {
     tB   = new SolidBrush(Rim.Color);
     tPen = new Pen(Rim.Color_Shape, 2);
     Ps   = new PointF[Rim.Shape.Count];
     for (int i = 0; i < Rim.Shape.Count; i++)
     {
         Ps[i] = zoom.WorldToScreen((float)(Rim.Shape[i].X), (float)(Rim.Shape[i].Y));
     }
     g.FillPolygon(tB, Ps);
     g.DrawPolygon(tPen, Ps);
 }
Ejemplo n.º 6
0
 public void Render(Graphics g, ScreenTrans zoom, RenderParameter RParas)
 {
     if (RParas.Show_WMesh2D == false)
     {
         return;
     }
     try
     {
         if (data.Meshs == null || data.Meshs.Count == 0)
         {
             return;
         }
     }
     catch { }
     /////
     for (int i = 0; i < data.Meshs.Count; i++)
     {
         RenderSingleMesh(g, zoom, RParas, data.Meshs[i]);
     }
 }
Ejemplo n.º 7
0
 private void RenderHighLights(Graphics g, ScreenTrans zoom, RenderParameter RParas, ref List <WShapeRim2D> HighLights)
 {
     if (HighLights == null || HighLights.Count == 0)
     {
         return;
     }
     for (int i = 0; i < HighLights.Count; i++)
     {
         if (HighLights[i].Count == 0)
         {
             continue;
         }
         Ps = new PointF[HighLights[i].Count];
         for (int j = 0; j < HighLights[i].Count; j++)
         {
             Ps[j] = zoom.WorldToScreen((float)(HighLights[i][j].X), (float)(HighLights[i][j].Y));
         }
         g.DrawPolygon(RParas.SnapGeo2DPen, Ps);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MeshRenderer" /> class.
        /// </summary>
        public MeshRenderer(RenderData data, RenderParameter renderColors)
        {
            this.data         = data;
            this.renderColors = renderColors;

            int featureCount = data.Points.Length;

            if (data.MeshEdges != null)
            {
                featureCount += data.MeshEdges.Length;
            }
            else if (data.Triangles != null)
            {
                featureCount += 2 * data.Triangles.Length;
            }

            this.ignoreBounds = featureCount < 1000;

            if (data.Triangles != null && data.NumberOfRegions > 0)
            {
                renderColors.MakeRegionMap(data.TrianglePartition, data.NumberOfRegions);
            }
        }
Ejemplo n.º 9
0
        public void Render(Graphics G, RenderParameter RParas, int Width, int Height)
        {
            G.Clear(Color.White);
            Image I = Image.FromFile(RParas.Pic_FileNeme);
            float width, height;
            float x, y;

            if (I.Width / Width > I.Height / Height)
            {
                width  = Width;
                height = I.Height / (I.Width / Width);
                x      = 0;
                y      = (Height - height) / 2;
            }
            else
            {
                height = Height;
                width  = I.Width / (I.Height / Height);
                x      = (Width - width) / 2;
                y      = 0;
            }
            G.DrawImage(I, x, y, width, height);
        }
Ejemplo n.º 10
0
        public void Initialize()
        {
            if (RParas == null)
            {
                RParas = new RenderParameter(Theme.Default);
            }

            wresRenderer = new WResRenderer();

            this.BackColor = RParas.Background;
            this.Dock      = DockStyle.Fill;
            this.Location  = new System.Drawing.Point(0, 0);
            this.Name      = "renderControl1";
            this.TabIndex  = 0;
            this.Text      = "meshRenderer1";

            trans.Initialize(this.ClientRectangle);
            InitializeBuffer();
            G = buffer.Graphics;

            initialized = true;

            this.Invalidate();
        }
Ejemplo n.º 11
0
        public void RenderSingleMesh(Graphics g, ScreenTrans zoom, RenderParameter RParas, WMesh2D_Mesh Mesh)
        {
            PointF P;

            PointF[] Ps;

            Brush tB = new SolidBrush(Mesh.Color);

            int Num;
            int Kind;

            /////节点转换
            PointF[] Ns = new PointF[Mesh.QNs + 1];
            for (int i = 1; i <= Mesh.QNs; i++)
            {
                Ns[i] = new PointF((float)Mesh.Nodes[i].X, (float)Mesh.Nodes[i].Y);
                Ns[i] = zoom.WorldToScreen(Ns[i].X, Ns[i].Y);
            }
            /////使用Shape输出
            bool Check_Fill = false;
            //if (Mesh.Shapes != null && Mesh.Shapes.Count != 0)
            //{
            //    for (int i = 0; i < Mesh.Shapes.Count; i++)
            //    {
            //        Ps = new PointF[Mesh.Shapes[i].Count];
            //        for (int j = 0; j < Mesh.Shapes[i].Count; j++)
            //        {
            //            Ps[j] = new PointF((float)Mesh.Shapes[i][j].X, (float)Mesh.Shapes[i][j].Y);
            //            Ps[j] = zoom.WorldToScreen(Ps[j].X, Ps[j].Y);
            //        }
            //        g.FillPolygon(tB, Ps);
            //    }
            //    Check_Fill = true;
            //}
            /////
            bool Check_Frame = false;

            if (Mesh.NsPairs != null && Mesh.NsPairs.Length > 0)
            {
                Ps = new PointF[2];
                for (int i = 0; i < Mesh.NsPairs.Length; i++)
                {
                    g.DrawLine(RParas.PenES, Ns[Mesh.NsPairs[i].N1], Ns[Mesh.NsPairs[i].N2]);
                }
                Check_Frame = true;
            }
            /////单元输出
            if (Check_Fill == false || Check_Frame == false)
            {
                for (int i = 0; i < Mesh.QEs; i++)
                {
                    Kind = Mesh.Elements[i].Kind;
                    if (Kind < 3)
                    {
                        continue;
                    }
                    /////
                    Ps = new PointF[Kind + 1];

                    Num = Mesh.Elements[i].N1;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[0] = Ns[Num];
                    Num   = Mesh.Elements[i].N2;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[1] = Ns[Num];
                    Num   = Mesh.Elements[i].N3;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[2] = Ns[Num];
                    if (Kind == 4)
                    {
                        Num = Mesh.Elements[i].N4;
                        if (Num < 0)
                        {
                            continue;
                        }
                        Ps[3] = Ns[Num];
                    }
                    Ps[Kind] = Ps[0];
                    /////
                    if (Check_Fill == false)
                    {
                        g.FillPolygon(tB, Ps);
                    }
                    if (Check_Frame == false)
                    {
                        g.DrawPolygon(RParas.PenES, Ps);
                    }
                }
            }
            /////
            for (int i = 0; i < Mesh.Elements.Count; i++)
            {
                Kind = Mesh.Elements[i].Kind;
                if (Kind == 2)
                {
                    Ps    = new PointF[2];
                    Num   = Mesh.Elements[i].N1;
                    Ps[0] = Ns[Num];
                    Num   = Mesh.Elements[i].N2;
                    Ps[1] = Ns[Num];
                    g.DrawLine(RParas.PenEB, Ps[0], Ps[1]);
                    continue;
                }
            }

            if (RParas.SwitchN == false)
            {
                return;
            }
            for (int i = 1; i < Mesh.Nodes.Count; i++)
            {
                P = new PointF((float)Mesh.Nodes[i].X, (float)Mesh.Nodes[i].Y);
                P = zoom.WorldToScreen(P.X, P.Y);
                g.FillEllipse(RParas.BrushN, P.X - RParas.Rn / 2, P.Y - RParas.Rn / 2, RParas.Rn, RParas.Rn);
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Initialize the graphics buffer (should be called in the forms load event).
 /// </summary>
 public void Initialize(ref RenderParameter RParas)
 {
     this.RParas = RParas;
     Initialize();
 }
Ejemplo n.º 13
0
 public void Initialize(ref RenderParameter RParas)
 {
     renderer.Initialize(ref RParas);
 }