コード例 #1
0
ファイル: DMCN.cs プロジェクト: Lin20/isosurface
 private void GenerateCells(int x, int y, int z)
 {
     Cells[x, y, z] = new Cell();
     Cells[x, y, z].Edges[0] = GenerateEdge(x, y, z, 0);
     Cells[x, y, z].Edges[3] = GenerateEdge(x, y, z, 3);
     Cells[x, y, z].Edges[8] = GenerateEdge(x, y, z, 8);
 }
コード例 #2
0
ファイル: DMCN.cs プロジェクト: Lin20/isosurface
        public override long Contour(float threshold)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            Cells = new Cell[Resolution, Resolution, Resolution];
            for (int x = 0; x < Resolution; x++)
            {
                for (int y = 0; y < Resolution; y++)
                {
                    for (int z = 0; z < Resolution; z++)
                    {
                        GenerateCells(x, y, z);
                    }
                }
            }

            for (int x = 0; x < Resolution - 1; x++)
            {
                for (int y = 0; y < Resolution - 1; y++)
                {
                    for (int z = 0; z < Resolution - 1; z++)
                    {
                        GenerateEdges(x, y, z);
                    }
                }
            }

            //for (int x = Resolution - 2; x >= 0; x--)
            for (int x = 0; x < Resolution - 1; x++)
            {
                //for (int y = Resolution - 2; y >= 0; y-- )
                for (int y = 0; y < Resolution - 1; y++)
                {
                    //for (int z = Resolution - 2; z >= 0; z--)
                    for (int z = 0; z < Resolution - 1; z++)
                    {
                        Polygonize(x, y, z);
                    }
                }
            }

            for (int x = 0; x < Resolution; x++)
            {
                for (int y = 0; y < Resolution; y++)
                {
                    for (int z = 0; z < Resolution; z++)
                    {
                        GenerateIndexes(x, y, z);
                    }
                }
            }

            VertexCount = Vertices.Count;
            if (Indices != null)
                IndexCount = Indices.Count;

            if (Vertices.Count > 0)
                VertexBuffer.SetData<VertexPositionColorNormal>(0, Vertices.ToArray(), 0, VertexCount, VertexPositionColorNormal.VertexDeclaration.VertexStride);
            if (!UseFlatShading && Indices.Count > 0)
                IndexBuffer.SetData<int>(Indices.ToArray());

            watch.Stop();
            return watch.ElapsedMilliseconds;
        }