protected static unsafe TexCoordBuffer DoCreateFractureTextureCoordinates(DynamicUnstructuredGridderSource src, int[] gridIndexes, float[] values, float minValue, float maxValue) { int fractureStartIndex = 0; int fractureEndIndex = src.FractureNum - 1; int[] invisibles = src.BindResultsAndActiveFractures(gridIndexes); float[] textures = new float[src.InvisibleFractureTextures.Length]; Array.Copy(src.InvisibleFractureTextures, textures, textures.Length); for (int mixedIndex = 0; mixedIndex < gridIndexes.Length; mixedIndex++) { int gridIndex = gridIndexes[mixedIndex]; if (gridIndex >= fractureStartIndex && gridIndex <= fractureEndIndex) { float value = values[mixedIndex]; if (value < minValue) value = minValue; if (value > maxValue) value = maxValue; int matrixIndex = gridIndex; if (invisibles[matrixIndex] > 0) { float distance = maxValue - minValue; if (!(distance <= 0.0f)) { textures[matrixIndex] = (value - minValue) / distance; if (textures[matrixIndex] < 0.5f) { textures[matrixIndex] = 0.5f - (0.5f - textures[matrixIndex]) * 0.99f; } else { textures[matrixIndex] = (textures[matrixIndex] - 0.5f) * 0.99f + 0.5f; } } else { //最小值最大值相等时,显示最小值的颜色 textures[matrixIndex] = 0.01f; //textures[matrixIndex] = 0.01f; } } } }//end for //TextureCoordinatesBuffer textureCoordinates = new TextureCoordinatesBufferData(); TexCoordBuffer textureCoordinates = null; int texturesCount = textures.Length; if (src.FractureFormat == DynamicUnstructuredGridderSource.FRACTURE_FORMAT3_TRIANGLE) { textureCoordinates = new TriangleFractureTexCoordBuffer(); textureCoordinates.AllocMem(texturesCount); TriangleTexCoord* pTextures = (TriangleTexCoord*)textureCoordinates.Data; for (int i = 0; i <texturesCount; i++) { pTextures[i].SetTextureCoord(textures[i]); } } if (src.FractureFormat == DynamicUnstructuredGridderSource.FRACTURE_FORMAT2_LINE) { textureCoordinates = new LineFractureTexCoordBufer(); textureCoordinates.AllocMem(texturesCount); LineTexCoord* pTextures = (LineTexCoord*)textureCoordinates.Data; for (int i = 0; i < textures.Length; i++) { pTextures[i].SetTextureCoord(textures[i]); } } if (src.FractureFormat == DynamicUnstructuredGridderSource.FRACTURE_FORMAT4_QUAD) { textureCoordinates = new QuadFractureTexCoordBuffer(); textureCoordinates.AllocMem(texturesCount); QuadTexCoord* pTextures = (QuadTexCoord*)textureCoordinates.Data; for (int i = 0; i < textures.Length; i++) { pTextures[i].SetTextureCoord(textures[i]); } } return textureCoordinates; }
protected unsafe TexCoordBuffer DoCreateFractureTextureCoordinates(DynamicUnstructuredGridderSource src, int[] gridIndexes, float[] values, float minValue, float maxValue) { int fractureStartIndex = 0; int fractureEndIndex = src.FractureNum - 1; int[] invisibles = src.BindResultsAndActiveFractures(gridIndexes); float[] textures = new float[src.InvisibleFractureTextures.Length]; Array.Copy(src.InvisibleFractureTextures, textures, textures.Length); for (int mixedIndex = 0; mixedIndex < gridIndexes.Length; mixedIndex++) { int gridIndex = gridIndexes[mixedIndex]; int[] mapBlockIndexes = src.MapBlockIndexes(gridIndex); for (int j = 0; j < mapBlockIndexes.Length; j++) { int blockIndex = mapBlockIndexes[j]; if (blockIndex >= fractureStartIndex && blockIndex <= fractureEndIndex) { float value = values[mixedIndex]; if (value < minValue) { value = minValue; } if (value > maxValue) { value = maxValue; } int fracIndex = blockIndex; if (invisibles[fracIndex] > 0) { float distance = maxValue - minValue; if (!(distance <= 0.0f)) { textures[fracIndex] = (value - minValue) / distance; if (textures[fracIndex] < 0.5f) { textures[fracIndex] = 0.5f - (0.5f - textures[fracIndex]) * 0.99f; } else { textures[fracIndex] = (textures[fracIndex] - 0.5f) * 0.99f + 0.5f; } } else { //最小值最大值相等时,显示最小值的颜色 textures[fracIndex] = 0.01f; //textures[matrixIndex] = 0.01f; } } } } }//end for //TextureCoordinatesBuffer textureCoordinates = new TextureCoordinatesBufferData(); TexCoordBuffer textureCoordinates = null; int texturesCount = textures.Length; if (src.FractureFormat == DynamicUnstructuredGridderSource.FRACTURE_FORMAT3_TRIANGLE) { textureCoordinates = new TriangleFractureTexCoordBuffer(); textureCoordinates.AllocMem(texturesCount); TriangleTexCoord *pTextures = (TriangleTexCoord *)textureCoordinates.Data; for (int i = 0; i < texturesCount; i++) { pTextures[i].SetTextureCoord(textures[i]); } } if (src.FractureFormat == DynamicUnstructuredGridderSource.FRACTURE_FORMAT2_LINE) { textureCoordinates = new LineFractureTexCoordBufer(); textureCoordinates.AllocMem(texturesCount); LineTexCoord *pTextures = (LineTexCoord *)textureCoordinates.Data; for (int i = 0; i < textures.Length; i++) { pTextures[i].SetTextureCoord(textures[i]); } } if (src.FractureFormat == DynamicUnstructuredGridderSource.FRACTURE_FORMAT4_QUAD) { textureCoordinates = new QuadFractureTexCoordBuffer(); textureCoordinates.AllocMem(texturesCount); QuadTexCoord *pTextures = (QuadTexCoord *)textureCoordinates.Data; for (int i = 0; i < textures.Length; i++) { pTextures[i].SetTextureCoord(textures[i]); } } return(textureCoordinates); }