예제 #1
0
        unsafe private void DrawElectrodes(float radius, float scale, Graphics g)
        {
            NodeStruct *node_ptr = this.mesher.GetFirstPlainNode();

            SmoothingMode old_mode = g.SmoothingMode;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            using (Pen p = new Pen(Color.Red, 3.0f))
                for (int i = 0; i < this.mesher.GetNumberOfPlainElectrodes(); i++)
                {
                    PlainElectrodeEdge *edges = this.mesher.GetFirstPlainElectrodeElement(i);
                    int count = this.mesher.GetNumberOfPlainElectrodeElements(i);

                    for (int j = 0; j < count; j++)
                    {
                        NodeStruct *n1 = &node_ptr[edges[j].node1];
                        NodeStruct *n2 = &node_ptr[edges[j].node2];

                        float x1 = (float)(n1->x * scale + 5);
                        float y1 = (float)((2 * radius - n1->y) * scale + 5);
                        float x2 = (float)(n2->x * scale + 5);
                        float y2 = (float)((2 * radius - n2->y) * scale + 5);
                        g.DrawLine(p, x1, y1, x2, y2);
                    }
                }
            g.SmoothingMode = old_mode;
        }
예제 #2
0
        unsafe private void DrawNodes(float radius, float scale, Bitmap bmp)
        {
            int         node_count = this.mesher.GetNumberOfPlainNodes();
            NodeStruct *node_ptr   = this.mesher.GetFirstPlainNode();
            Color       c          = this.cNodes.SelectedColor;

            for (int i = 0; i < node_count; i++, node_ptr++)
            {
                float nx = (float)(node_ptr->x * scale + 5);
                float ny = (float)((2 * radius - node_ptr->y) * scale + 5);
                // g.FillRectangle(Brushes.DarkGreen, nx - 1, ny - 1, 3, 3);
                bmp.SetPixel((int)Math.Round(nx), (int)Math.Round(ny), c);
            }
        }
예제 #3
0
        unsafe private void DrawTriangles(float radius, float scale, Graphics g, bool draw_lines)
        {
            int            node_count    = this.mesher.GetNumberOfPlainNodes();
            NodeStruct *   node_ptr      = this.mesher.GetFirstPlainNode();
            int            element_count = this.mesher.GetNumberOfPlainElements();
            ElementStruct *element_ptr   = this.mesher.GetFirstPlainElement();

            using (Pen line_pen = new Pen(this.cLines.SelectedColor))
                for (int i = 0; i < element_count; i++, element_ptr++)
                {
                    NodeStruct *n1 = &node_ptr[element_ptr->node1];
                    NodeStruct *n2 = &node_ptr[element_ptr->node2];
                    NodeStruct *n3 = &node_ptr[element_ptr->node3];

                    float x1 = (float)(n1->x * scale + 5);
                    float y1 = (float)((2 * radius - n1->y) * scale + 5);
                    float x2 = (float)(n2->x * scale + 5);
                    float y2 = (float)((2 * radius - n2->y) * scale + 5);
                    float x3 = (float)(n3->x * scale + 5);
                    float y3 = (float)((2 * radius - n3->y) * scale + 5);

                    PointF[] points = new PointF[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3) };

                    if (draw_lines)
                    {
                        g.DrawLines(line_pen, points);
                    }
                    else
                    {
                        //Brush b = this.gray_brushes[(byte)(255 * this.mesher.NormalizeMaterial(element_ptr->material))];
                        double m = element_ptr->material / 80.0;
                        m = Math.Max(Math.Min(m, 1), 0); // normalizacja: 0=0, 80=1
                        Brush b = this.gray_brushes[(byte)(255 * m)];

                        g.FillPolygon(b, points);
                    }
                }
        }