NormColor CalculateFaceColor(Zone owner, Face face, FaceType faceType)
        {
            float averageValue = 0;

            switch (faceType)
            {
            case FaceType.Triangular:
                averageValue += (float)owner.Vertices[face.Vertices[0]].Data[Coding_DatatypeIndex];
                averageValue += (float)owner.Vertices[face.Vertices[1]].Data[Coding_DatatypeIndex];
                averageValue += (float)owner.Vertices[face.Vertices[2]].Data[Coding_DatatypeIndex];
                averageValue /= 3;
                break;

            case FaceType.Quadrilateral:
                averageValue += (float)owner.Vertices[face.Vertices[0]].Data[Coding_DatatypeIndex];
                averageValue += (float)owner.Vertices[face.Vertices[1]].Data[Coding_DatatypeIndex];
                averageValue += (float)owner.Vertices[face.Vertices[2]].Data[Coding_DatatypeIndex];
                averageValue += (float)owner.Vertices[face.Vertices[3]].Data[Coding_DatatypeIndex];
                averageValue /= 4;
                break;
            }

            double min = Mesh_Manager.dataTypeRange[Coding_DatatypeIndex].Key, max = Mesh_Manager.dataTypeRange[Coding_DatatypeIndex].Value;

            Color_Mapper.minValue = (float)min;
            Color_Mapper.maxValue = (float)max;
            Color     C     = Color_Mapper.ValueToColor(averageValue, mappingMode);
            NormColor color = NormalizeColor(C);

            return(color);
        }
예제 #2
0
        public static List <Point3[]> CalculateLineContours(Mesh _mesh, uint varIndex, int num_Contours)
        {
            List <Point3[]> contourLines = new List <Point3[]>();
            double          contourValue = 0, step = 0;
            double          min = Mesh_Manager.dataTypeRange[varIndex].Key, max = Mesh_Manager.dataTypeRange[varIndex].Value;

            step                  = (max - min) / (num_Contours + 1);
            contourValue          = (float)min + step;
            Color_Mapper.minValue = (float)min;
            Color_Mapper.maxValue = (float)max;
            while (contourValue <= max)
            {
                foreach (Zone z in _mesh.Zones)
                {
                    foreach (Face f in z.Faces)
                    {
                        Point3[] points = new Point3[f.Vertices.Length];
                        double[] data   = new double[f.Vertices.Length];
                        for (int i = 0; i < f.Vertices.Length; i++)
                        {
                            points[i] = z.Vertices[f.Vertices[i]].Position;
                            data[i]   = z.Vertices[f.Vertices[i]].Data[varIndex];
                        }
                        contourLines.AddRange(GetLineContour(points, data, contourValue));
                        while (contourLines.Count > Contour.contourColors.Count)
                        {
                            Contour.contourColors.Add(Color_Mapper.ValueToColor((float)contourValue, Mapping_Mode.Continuous));
                        }
                    }
                }
                contourValue += step;
            }
            return(contourLines);
        }
예제 #3
0
        ///////////////////////////////////////////////////////////
        public static List <Point3[]> CalculateIsoSurface(Mesh _mesh, uint varIndex, int num_Contours)
        {
            List <Point3[]> isoSurfaces = new List <Point3[]>();

            double contourValue = 0, step = 0;
            double min = Mesh_Manager.dataTypeRange[varIndex].Key, max = Mesh_Manager.dataTypeRange[varIndex].Value;

            step                  = (max - min) / (num_Contours + 1);
            contourValue          = (float)min + step;
            Color_Mapper.minValue = (float)min;
            Color_Mapper.maxValue = (float)max;
            while (contourValue <= max)
            {
                List <Point3> isoSurface = new List <Point3>();
                foreach (Zone z in _mesh.Zones)
                {
                    foreach (Element e in z.Elements)
                    {
                        Point3[] points = new Point3[e.vertInOrder.Length];
                        double[] data   = new double[e.vertInOrder.Length];
                        for (int i = 0; i < e.vertInOrder.Length; i++)
                        {
                            points[i] = z.Vertices[e.vertInOrder[i]].Position;
                            data[i]   = z.Vertices[e.vertInOrder[i]].Data[varIndex];
                        }
                        //get case
                        byte elementCase = ISOSurface.GetElementCase(data, contourValue);
                        //get active edges
                        int[] edgeindex = new int[16];
                        for (int i = 0; i < 16; i++)
                        {
                            edgeindex[i] = ISOSurface.triTable[elementCase, i];
                        }
                        ///
                        for (int i = 0; i < 16; i++)
                        {
                            if (edgeindex[i] != -1)
                            {
                                Edge   edge     = ISOSurface.GetEdgePoints[edgeindex[i]];
                                Vertex Vert0    = z.Vertices[e.vertInOrder[edge.Start]];
                                Vertex Vert1    = z.Vertices[e.vertInOrder[edge.End]];
                                double alpha    = (contourValue - Vert0.Data[varIndex]) / (Vert1.Data[varIndex] - Vert0.Data[varIndex]);
                                Point3 isoPoint = Vert0.Position + alpha * (Vert1.Position - Vert0.Position);
                                isoSurface.Add(isoPoint);
                            }
                        }
                    }
                }

                isoSurfaces.Add(isoSurface.ToArray());
                Contour.isoSurfacesColors.Add(Color_Mapper.ValueToColor((float)contourValue, Mapping_Mode.Continuous));
                contourValue += step;
            }
            return(isoSurfaces);
        }
        NormColor CalculateEdgeColor(Zone owner, Edge edge)
        {
            float Average_value = (float)(owner.Vertices[edge.Start].Data[Coding_DatatypeIndex]
                                          + owner.Vertices[edge.End].Data[Coding_DatatypeIndex]) / 2;
            double min = Mesh_Manager.dataTypeRange[Coding_DatatypeIndex].Key, max = Mesh_Manager.dataTypeRange[Coding_DatatypeIndex].Value;

            Color_Mapper.minValue = (float)min;
            Color_Mapper.maxValue = (float)max;
            Color     C     = Color_Mapper.ValueToColor(Average_value, mappingMode);
            NormColor color = NormalizeColor(C);

            return(color);
        }
예제 #5
0
        public static List <List <Point3[]> > CalculateFloodedContours(Mesh _mesh, uint varIndex, int num_Contours)
        {
            contourPolygons = new List <List <Point3[]> >();
            double contourValue = 0, step = 0;
            double min = Mesh_Manager.dataTypeRange[varIndex].Key, max = Mesh_Manager.dataTypeRange[varIndex].Value;

            //  _mesh.GetMinMaxValues(varIndex, out min, out max);
            step                  = (max - min) / (num_Contours + 1);
            contourValue          = (float)min;
            Color_Mapper.minValue = (float)min;
            Color_Mapper.maxValue = (float)max;

            while (contourValue <= max)
            {
                foreach (Zone z in _mesh.Zones)
                {
                    foreach (Face f in z.Faces)
                    {
                        List <Point3[]> currentContourPolygonLines = new List <Point3[]>();
                        Point3[]        points = new Point3[f.Vertices.Length];
                        double[]        data   = new double[f.Vertices.Length];
                        for (int i = 0; i < f.Vertices.Length; i++)
                        {
                            points[i] = z.Vertices[f.Vertices[i]].Position;
                            data[i]   = z.Vertices[f.Vertices[i]].Data[varIndex];
                        }
                        List <Point3[]> tmpList = GetLineContour(points, data, contourValue);
                        if (tmpList.Count != 0)
                        {
                            currentContourPolygonLines.AddRange(tmpList);
                            contourPolygons.Add(currentContourPolygonLines);
                        }

                        while (contourPolygons.Count > Contour.contourColors.Count)
                        {
                            Contour.contourColors.Add(Color_Mapper.ValueToColor((float)contourValue, Mapping_Mode.Continuous));
                        }
                    }
                }
                contourValue += step;
            }
            return(contourPolygons);
        }