Exemple #1
0
        private unsafe HexahedronPositionBuffer GeneratePositionBuffer(ref Vertex max, ref Vertex min)
        {
            HexahedronGridderSource  src            = this;
            HexahedronPositionBuffer positionBuffer = new HexahedronPositionBuffer();
            int dimSize = src.DimenSize;
            int I, J, K;

            positionBuffer.AllocMem(dimSize);

            HexahedronPosition *cell = (HexahedronPosition *)positionBuffer.Data;

            for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
            {
                src.InvertIJK(gridIndex, out I, out J, out K);
                cell[gridIndex].FLT = src.PointFLT(I, J, K);
                cell[gridIndex].FRT = src.PointFRT(I, J, K);
                cell[gridIndex].BRT = src.PointBRT(I, J, K);
                cell[gridIndex].BLT = src.PointBLT(I, J, K);
                cell[gridIndex].FLB = src.PointFLB(I, J, K);
                cell[gridIndex].FRB = src.PointFRB(I, J, K);
                cell[gridIndex].BRB = src.PointBRB(I, J, K);
                cell[gridIndex].BLB = src.PointBLB(I, J, K);

                if (!isSet && src.IsActiveBlock(gridIndex))
                {
                    min   = cell[gridIndex].FLT;
                    max   = min;
                    isSet = true;
                }

                if (isSet && src.IsActiveBlock(gridIndex))
                {
                    min = SimLab.SimGrid.helper.VertexHelper.MinVertex(min, cell[gridIndex].FLT);
                    max = SimLab.SimGrid.helper.VertexHelper.MaxVertex(max, cell[gridIndex].FLT);

                    min = SimLab.SimGrid.helper.VertexHelper.MinVertex(min, cell[gridIndex].FRT);
                    max = SimLab.SimGrid.helper.VertexHelper.MaxVertex(max, cell[gridIndex].FRT);

                    min = SimLab.SimGrid.helper.VertexHelper.MinVertex(min, cell[gridIndex].BRT);
                    max = SimLab.SimGrid.helper.VertexHelper.MaxVertex(max, cell[gridIndex].BRT);

                    min = SimLab.SimGrid.helper.VertexHelper.MinVertex(min, cell[gridIndex].BLT);
                    max = SimLab.SimGrid.helper.VertexHelper.MaxVertex(max, cell[gridIndex].BLT);

                    min = SimLab.SimGrid.helper.VertexHelper.MinVertex(min, cell[gridIndex].FLB);
                    max = SimLab.SimGrid.helper.VertexHelper.MaxVertex(max, cell[gridIndex].FLB);

                    min = SimLab.SimGrid.helper.VertexHelper.MinVertex(min, cell[gridIndex].FRB);
                    max = SimLab.SimGrid.helper.VertexHelper.MaxVertex(max, cell[gridIndex].FRB);

                    min = SimLab.SimGrid.helper.VertexHelper.MinVertex(min, cell[gridIndex].BRB);
                    max = SimLab.SimGrid.helper.VertexHelper.MaxVertex(max, cell[gridIndex].BRB);

                    min = SimLab.SimGrid.helper.VertexHelper.MinVertex(min, cell[gridIndex].BLB);
                    max = SimLab.SimGrid.helper.VertexHelper.MaxVertex(max, cell[gridIndex].BLB);
                }
            }

            return(positionBuffer);
        }
Exemple #2
0
        public override HexahedronGrid GenerateGrid(OpenGL gl, IScientificCamera camera, int[] gridIndexes, float[] values, float minValue, float maxValue)
        {
            HexahedronPositionBuffer  positionBuffer = GeneratePositionBuffer(ref this.max, ref this.min);
            HexahedronTexCoordBuffer  texCoordBuffer = GenerateTexCoordBuffer(gridIndexes, values, minValue, maxValue);
            HalfHexahedronIndexBuffer indexBuffer    = GenerateIndexBuffer();

            HexahedronGrid grid = new HexahedronGrid(gl, camera);

            grid.
        }
Exemple #3
0
        public override MeshBase CreateMesh(GridderSource source)
        {
            HexahedronGridderSource src = (HexahedronGridderSource)source;

            PositionBuffer            positions             = new HexahedronPositionBuffer();
            HalfHexahedronIndexBuffer halfHexahedronIndices = new HalfHexahedronIndexBuffer();
            int dimSize = src.DimenSize;
            int I, J, K;

            unsafe
            {
                positions.AllocMem(dimSize);

                HexahedronPosition *cell = (HexahedronPosition *)positions.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    src.InvertIJK(gridIndex, out I, out J, out K);
                    cell[gridIndex].FLT = src.Transform * src.PointFLT(I, J, K);
                    cell[gridIndex].FRT = src.Transform * src.PointFRT(I, J, K);
                    cell[gridIndex].BRT = src.Transform * src.PointBRT(I, J, K);
                    cell[gridIndex].BLT = src.Transform * src.PointBLT(I, J, K);
                    cell[gridIndex].FLB = src.Transform * src.PointFLB(I, J, K);
                    cell[gridIndex].FRB = src.Transform * src.PointFRB(I, J, K);
                    cell[gridIndex].BRB = src.Transform * src.PointBRB(I, J, K);
                    cell[gridIndex].BLB = src.Transform * src.PointBLB(I, J, K);
                }

                //网格个数*每个六面体的面数*描述每个六面体的三角形个数
                int halfHexahedronIndexCount = dimSize * 2;
                //int memorySizeInBytes = halfHexahedronIndexCount * sizeof(HalfHexahedronIndex);
                //halfHexahedronIndices.AllocMem(memorySizeInBytes);
                halfHexahedronIndices.AllocMem(halfHexahedronIndexCount);

                HalfHexahedronIndex *array = (HalfHexahedronIndex *)halfHexahedronIndices.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    array[gridIndex * 2].dot0         = (uint)(8 * gridIndex + 6);
                    array[gridIndex * 2].dot1         = (uint)(8 * gridIndex + 2);
                    array[gridIndex * 2].dot2         = (uint)(8 * gridIndex + 7);
                    array[gridIndex * 2].dot3         = (uint)(8 * gridIndex + 3);
                    array[gridIndex * 2].dot4         = (uint)(8 * gridIndex + 4);
                    array[gridIndex * 2].dot5         = (uint)(8 * gridIndex + 0);
                    array[gridIndex * 2].dot6         = (uint)(8 * gridIndex + 5);
                    array[gridIndex * 2].dot7         = (uint)(8 * gridIndex + 1);
                    array[gridIndex * 2].restartIndex = uint.MaxValue;

                    array[gridIndex * 2 + 1].dot0         = (uint)(8 * gridIndex + 3);
                    array[gridIndex * 2 + 1].dot1         = (uint)(8 * gridIndex + 0);
                    array[gridIndex * 2 + 1].dot2         = (uint)(8 * gridIndex + 2);
                    array[gridIndex * 2 + 1].dot3         = (uint)(8 * gridIndex + 1);
                    array[gridIndex * 2 + 1].dot4         = (uint)(8 * gridIndex + 6);
                    array[gridIndex * 2 + 1].dot5         = (uint)(8 * gridIndex + 5);
                    array[gridIndex * 2 + 1].dot6         = (uint)(8 * gridIndex + 7);
                    array[gridIndex * 2 + 1].dot7         = (uint)(8 * gridIndex + 4);
                    array[gridIndex * 2 + 1].restartIndex = uint.MaxValue;
                }

                HexahedronMeshGeometry3D mesh = new HexahedronMeshGeometry3D(positions, halfHexahedronIndices);
                mesh.Max = source.TransformedActiveBounds.Min;
                mesh.Min = source.TransformedActiveBounds.Max;
                return(mesh);
            }
        }
Exemple #4
0
        public override MeshBase CreateMesh(GridderSource source)
        {
            HexahedronGridderSource src                     = (HexahedronGridderSource)source;
            Vertex                    minVertex             = new Vertex();
            Vertex                    maxVertex             = new Vertex();
            bool                      isSet                 = false;
            PositionBuffer            positions             = new HexahedronPositionBuffer();
            HalfHexahedronIndexBuffer halfHexahedronIndices = new HalfHexahedronIndexBuffer();
            int dimSize = src.DimenSize;
            int I, J, K;

            unsafe
            {
                positions.AllocMem(dimSize);

                HexahedronPosition *cell = (HexahedronPosition *)positions.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    src.InvertIJK(gridIndex, out I, out J, out K);
                    cell[gridIndex].FLT = src.PointFLT(I, J, K);
                    cell[gridIndex].FRT = src.PointFRT(I, J, K);
                    cell[gridIndex].BRT = src.PointBRT(I, J, K);
                    cell[gridIndex].BLT = src.PointBLT(I, J, K);
                    cell[gridIndex].FLB = src.PointFLB(I, J, K);
                    cell[gridIndex].FRB = src.PointFRB(I, J, K);
                    cell[gridIndex].BRB = src.PointBRB(I, J, K);
                    cell[gridIndex].BLB = src.PointBLB(I, J, K);

                    if (!isSet && src.IsActiveBlock(gridIndex))
                    {
                        minVertex = cell[gridIndex].FLT;
                        maxVertex = minVertex;
                        isSet     = true;
                    }

                    if (isSet && src.IsActiveBlock(gridIndex))
                    {
                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, cell[gridIndex].FLT);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, cell[gridIndex].FLT);

                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, cell[gridIndex].FRT);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, cell[gridIndex].FRT);

                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, cell[gridIndex].BRT);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, cell[gridIndex].BRT);

                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, cell[gridIndex].BLT);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, cell[gridIndex].BLT);

                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, cell[gridIndex].FLB);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, cell[gridIndex].FLB);

                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, cell[gridIndex].FRB);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, cell[gridIndex].FRB);

                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, cell[gridIndex].BRB);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, cell[gridIndex].BRB);

                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, cell[gridIndex].BLB);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, cell[gridIndex].BLB);
                    }
                }

                //网格个数*每个六面体的面数*描述每个六面体的三角形个数
                int halfHexahedronIndexCount = dimSize * 2;
                //int memorySizeInBytes = halfHexahedronIndexCount * sizeof(HalfHexahedronIndex);
                //halfHexahedronIndices.AllocMem(memorySizeInBytes);
                halfHexahedronIndices.AllocMem(halfHexahedronIndexCount);

                HalfHexahedronIndex *array = (HalfHexahedronIndex *)halfHexahedronIndices.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    array[gridIndex * 2].dot0         = (uint)(8 * gridIndex + 6);
                    array[gridIndex * 2].dot1         = (uint)(8 * gridIndex + 2);
                    array[gridIndex * 2].dot2         = (uint)(8 * gridIndex + 7);
                    array[gridIndex * 2].dot3         = (uint)(8 * gridIndex + 3);
                    array[gridIndex * 2].dot4         = (uint)(8 * gridIndex + 4);
                    array[gridIndex * 2].dot5         = (uint)(8 * gridIndex + 0);
                    array[gridIndex * 2].dot6         = (uint)(8 * gridIndex + 5);
                    array[gridIndex * 2].dot7         = (uint)(8 * gridIndex + 1);
                    array[gridIndex * 2].restartIndex = uint.MaxValue;

                    array[gridIndex * 2 + 1].dot0         = (uint)(8 * gridIndex + 3);
                    array[gridIndex * 2 + 1].dot1         = (uint)(8 * gridIndex + 0);
                    array[gridIndex * 2 + 1].dot2         = (uint)(8 * gridIndex + 2);
                    array[gridIndex * 2 + 1].dot3         = (uint)(8 * gridIndex + 1);
                    array[gridIndex * 2 + 1].dot4         = (uint)(8 * gridIndex + 6);
                    array[gridIndex * 2 + 1].dot5         = (uint)(8 * gridIndex + 5);
                    array[gridIndex * 2 + 1].dot6         = (uint)(8 * gridIndex + 7);
                    array[gridIndex * 2 + 1].dot7         = (uint)(8 * gridIndex + 4);
                    array[gridIndex * 2 + 1].restartIndex = uint.MaxValue;
                }

                HexahedronMesh mesh = new HexahedronMesh(positions, halfHexahedronIndices);
                mesh.Max = maxVertex;
                mesh.Min = minVertex;
                return(mesh);
            }
        }
        public override MeshBase CreateMesh(GridderSource source)
        {
            HexahedronGridderSource src = (HexahedronGridderSource)source;

            PositionBuffer positions = new HexahedronPositionBuffer();
            HalfHexahedronIndexBuffer halfHexahedronIndices = new HalfHexahedronIndexBuffer();
            int dimSize = src.DimenSize;
            int I, J, K;
            unsafe
            {
                positions.AllocMem(dimSize);

                var cell = (HexahedronPosition*)positions.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    src.InvertIJK(gridIndex, out I, out J, out K);
                    cell[gridIndex].FLT = src.TranslateMatrix * src.PointFLT(I, J, K);
                    cell[gridIndex].FRT = src.TranslateMatrix * src.PointFRT(I, J, K);
                    cell[gridIndex].BRT = src.TranslateMatrix * src.PointBRT(I, J, K);
                    cell[gridIndex].BLT = src.TranslateMatrix * src.PointBLT(I, J, K);
                    cell[gridIndex].FLB = src.TranslateMatrix * src.PointFLB(I, J, K);
                    cell[gridIndex].FRB = src.TranslateMatrix * src.PointFRB(I, J, K);
                    cell[gridIndex].BRB = src.TranslateMatrix * src.PointBRB(I, J, K);
                    cell[gridIndex].BLB = src.TranslateMatrix * src.PointBLB(I, J, K);
                }

                //网格个数*每个六面体的面数*描述每个六面体的三角形个数
                int halfHexahedronIndexCount = dimSize * 2;
                //int memorySizeInBytes = halfHexahedronIndexCount * sizeof(HalfHexahedronIndex);
                //halfHexahedronIndices.AllocMem(memorySizeInBytes);
                halfHexahedronIndices.AllocMem(halfHexahedronIndexCount);

                HalfHexahedronIndex* array = (HalfHexahedronIndex*)halfHexahedronIndices.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    array[gridIndex * 2].dot0 = (uint)(8 * gridIndex + 6);
                    array[gridIndex * 2].dot1 = (uint)(8 * gridIndex + 2);
                    array[gridIndex * 2].dot2 = (uint)(8 * gridIndex + 7);
                    array[gridIndex * 2].dot3 = (uint)(8 * gridIndex + 3);
                    array[gridIndex * 2].dot4 = (uint)(8 * gridIndex + 4);
                    array[gridIndex * 2].dot5 = (uint)(8 * gridIndex + 0);
                    array[gridIndex * 2].dot6 = (uint)(8 * gridIndex + 5);
                    array[gridIndex * 2].dot7 = (uint)(8 * gridIndex + 1);
                    array[gridIndex * 2].restartIndex = uint.MaxValue;

                    array[gridIndex * 2 + 1].dot0 = (uint)(8 * gridIndex + 3);
                    array[gridIndex * 2 + 1].dot1 = (uint)(8 * gridIndex + 0);
                    array[gridIndex * 2 + 1].dot2 = (uint)(8 * gridIndex + 2);
                    array[gridIndex * 2 + 1].dot3 = (uint)(8 * gridIndex + 1);
                    array[gridIndex * 2 + 1].dot4 = (uint)(8 * gridIndex + 6);
                    array[gridIndex * 2 + 1].dot5 = (uint)(8 * gridIndex + 5);
                    array[gridIndex * 2 + 1].dot6 = (uint)(8 * gridIndex + 7);
                    array[gridIndex * 2 + 1].dot7 = (uint)(8 * gridIndex + 4);
                    array[gridIndex * 2 + 1].restartIndex = uint.MaxValue;
                }

                HexahedronMeshGeometry3D mesh = new HexahedronMeshGeometry3D(positions, halfHexahedronIndices);
                mesh.Max = source.TransformedActiveBounds.Min;
                mesh.Min = source.TransformedActiveBounds.Max;
                return mesh;
            }
        }