Пример #1
0
        private HexahedronTexCoordBuffer GenerateTexCoordBuffer(int[] gridIndexes, float[] values, float minValue, float maxValue)
        {
            HexahedronGridderSource src = this;

            int[] resultsVisibles = src.ExpandVisibles(gridIndexes);
            int[] bindVisibles    = src.BindCellActive(src.BindVisibles, resultsVisibles);

            int dimenSize = src.DimenSize;

            float[] textures = src.GetInvisibleTextureCoords();
            float   distance = Math.Abs(maxValue - minValue);

            for (int i = 0; i < gridIndexes.Length; i++)
            {
                int   gridIndex = gridIndexes[i];
                float value     = values[i];
                if (value < minValue)
                {
                    value = minValue;
                }
                if (value > maxValue)
                {
                    value = maxValue;
                }

                if (bindVisibles[gridIndex] > 0)
                {
                    if (!(distance <= 0.0f))
                    {
                        textures[gridIndex] = (value - minValue) / distance;
                    }
                    else
                    {
                        //最小值最大值相等时,显示最小值的颜色
                        textures[gridIndex] = 0.0f;
                    }
                }
            }

            HexahedronTexCoordBuffer coordBuffer = new HexahedronTexCoordBuffer();

            unsafe
            {
                int gridCellCount = src.DimenSize;
                coordBuffer.AllocMem(gridCellCount);
                HexahedronTexCoord *coords = (HexahedronTexCoord *)coordBuffer.Data;
                for (int gridIndex = 0; gridIndex < dimenSize; gridIndex++)
                {
                    coords[gridIndex].SetCoord(textures[gridIndex]);
                }
            }

            return(coordBuffer);
        }
Пример #2
0
        public override TexCoordBuffer CreateTextureCoordinates(GridderSource source, int[] gridIndexes, float[] values, float minValue, float maxValue)
        {
            HexahedronGridderSource src = (HexahedronGridderSource)source;

            int[] resultsVisibles = src.ExpandVisibles(gridIndexes);
            int[] bindVisibles    = src.BindVisibles(src.BindVisibles, resultsVisibles);

            int dimenSize = src.DimenSize;

            float[] textures = src.GetInvisibleTextureCoords();
            float   distance = Math.Abs(maxValue - minValue);

            for (int i = 0; i < gridIndexes.Length; i++)
            {
                int   gridIndex = gridIndexes[i];
                float value     = values[i];
                if (value < minValue)
                {
                    value = minValue;
                    bindVisibles[gridIndex] = 0;
                }
                if (value > maxValue)
                {
                    value = maxValue;
                    bindVisibles[gridIndex] = 0;
                }


                if (bindVisibles[gridIndex] > 0)
                {
                    if (!(distance <= 0.0f))
                    {
                        textures[gridIndex] = (value - minValue) / distance;
                        if (textures[gridIndex] < 0.5f)
                        {
                            textures[gridIndex] = 0.5f - (0.5f - textures[gridIndex]) * 0.99f;
                        }
                        else
                        {
                            textures[gridIndex] = (textures[gridIndex] - 0.5f) * 0.99f + 0.5f;
                        }
                    }
                    else
                    {
                        //最小值最大值相等时,显示最小值的颜色
                        //textures[gridIndex] = 0.01f;
                        textures[gridIndex] = 0.01f;
                    }
                }
            }

            HexahedronTexCoordBuffer coordBuffer = new HexahedronTexCoordBuffer();

            unsafe
            {
                int gridCellCount = src.DimenSize;
                coordBuffer.AllocMem(gridCellCount);
                HexahedronTexCoord *coords = (HexahedronTexCoord *)coordBuffer.Data;
                for (int gridIndex = 0; gridIndex < dimenSize; gridIndex++)
                {
                    coords[gridIndex].SetCoord(textures[gridIndex]);
                }
            }
            return(coordBuffer);
        }