Exemple #1
0
        public ArrayList GetMeshes()
        {
            ArrayList   meshs       = new ArrayList();
            ColorMesh3D surfaceMesh = new ColorMesh3D();

            surfaceMesh.SetSize(gridANo * gridBNo, 2 * (gridANo - 1) * (gridBNo - 1));

            for (int i = 0; i < gridANo; i++)
            {
                for (int j = 0; j < gridBNo; j++)
                {
                    int      k    = j * gridANo + i;
                    Vertex3D vert = vertices[k];
                    vertices[k].minI = k;
                    surfaceMesh.SetPoint(k, new Point3D(vert.x, vert.y, vert.z));
                    surfaceMesh.SetColor(k, vert.color);
                }
            }
            // set triangle
            int nT = 0;

            for (int i = 0; i < gridANo - 1; i++)
            {
                for (int j = 0; j < gridBNo - 1; j++)
                {
                    int n00 = j * gridANo + i;
                    int n10 = j * gridANo + i + 1;
                    int n01 = (j + 1) * gridANo + i;
                    int n11 = (j + 1) * gridANo + i + 1;

                    surfaceMesh.SetTriangle(nT, n00, n10, n01);
                    nT++;
                    surfaceMesh.SetTriangle(nT, n01, n10, n11);
                    nT++;
                }
            }
            meshs.Add(surfaceMesh);
            AddAxesMeshes(meshs);

            return(meshs);
        }
Exemple #2
0
        public void ShowChart3D(int ind)
        {
            if (chart3DList.Count == 0)
            {
                return;
            }
            // 4. Get the Mesh3D array from surface chart
            chart3DInd = ind;
            Chart3D chart3D = ((Chart3D)chart3DList[ind]);

            this.Title = chart3D.caption;
            int         vertNum     = chart3D.GetDataNo();
            int         trigNum     = (int)(vertNum / 3);
            ArrayList   meshs       = new ArrayList();
            ColorMesh3D surfaceMesh = new ColorMesh3D();

            surfaceMesh.SetSize(vertNum, (int)(vertNum / 3));

            double x, y, z, r;
            double rMinLog = 0.0;
            double rMaxLog = 1.0;
            double rMin    = Math.Pow(10.0, chartPrm.logMin / 10.0);
            double rMax    = 1.0;
            double logR;

            for (int i = 0; i < vertNum; i++)
            {
                x = chart3D.vertices[i].x;
                y = chart3D.vertices[i].y;
                z = chart3D.vertices[i].z;
                if (chartPrm.coordinateScale == CoordinateScale.Log)
                {
                    r = Math.Sqrt(x * x + y * y + z * z);
                    if (r > rMin)
                    {
                        logR = rMinLog + (rMaxLog - rMinLog) * (Math.Log10(r / rMin) / Math.Log10(rMax / rMin));
                        x    = x * logR / r;
                        y    = y * logR / r;
                        z    = z * logR / r;
                    }
                    else
                    {
                        z = y = x = 0.0;
                    }
                }
                surfaceMesh.SetPoint(i, new Point3D(x, y, z));
                surfaceMesh.SetColor(i, chart3D.vertices[i].color);
            }
            for (int i = 0; i < trigNum; i++)
            {
                surfaceMesh.SetTriangle(i, 3 * i, 3 * i + 1, 3 * i + 2);
            }
            meshs.Add(surfaceMesh);
            chart3D.AddAxesMeshes(meshs);

            // 5. display vertex no and triangle no of this surface chart
            UpdateModelSizeInfo(meshs);

            // 6. Set the model display of surface chart
            Model3D  model3d      = new Model3D();
            Material backMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));

            chartModelIndex = model3d.UpdateModel(meshs, backMaterial, chartModelIndex, this.mainViewport);

            // 7. set projection matrix, so the data is in the display region
            //float xMin = chart3D.XMin();
            //float xMax = chart3D.XMax();
            transformMatrix.CalculateProjectionMatrix(xMin, xMax, xMin, xMax, zMin, zMax, 0.5);
            TransformChart();
        }