Example #1
0
        public static BitMap3d CreateSampleForLobsterX2()
        {
            BitMap3d image = new BitMap3d(602, 648, 112, BitMap3d.BLACK);

            image.ReadRaw("D://VTKproj//lobsterx2.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 37 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            for (int k = 0; k < image.depth; k++)
            {
                for (int j = 0; j < image.height; j++)
                {
                    for (int i = 0; i < image.width; i++)
                    {
                        int index = k * image.width * image.height + j * image.width + i;
                        if (i == 0 || i == image.width - 1 || j == 0 || j == image.height - 1 || k == 0 || k == image.depth - 1)
                        {
                            data[index] = BitMap3d.BLACK;
                        }
                    }
                }
            }
            return(image);
        }
Example #2
0
        static void Main(string[] args)
        {
            string path = @"D:\VTKproj\FillMeshTest.ply";
            Mesh   mesh = new Mesh();

            PlyManager.ReadMeshFile(mesh, path);
            MeshVoxelizer      mf   = new MeshVoxelizer(mesh);
            List <Int16Triple> list = mf.GetVoxels();
            BitMap3d           bmp  = BitMap3d.CreateFromPointSet(list);
            CuberilleProcessor cb   = new CuberilleProcessor(bmp);
            Mesh ret = cb.GeneratorSurface();

            PlyManager.Output(ret, "test.ply");
        }
Example #3
0
        public static BitMap3d CreateFromPointSet(List <Int16Triple> list)
        {
            Box3Int box = new Box3Int();

            for (int i = 0; i < list.Count; i++)
            {
                box.UpdataRange(list[i].X, list[i].Y, list[i].Z);
            }
            BitMap3d bmp = new BitMap3d(box.Max3[0] + 1, box.Max3[1] + 1, box.Max3[2] + 1, 0);

            for (int i = 0; i < list.Count; i++)
            {
                bmp.SetPixel(list[i].X, list[i].Y, list[i].Z, 255);
            }
            return(bmp);
        }
Example #4
0
        public static BitMap3d CreateSampleTedVolume(int is400_300_200_100)
        {
            BitMap3d image = new BitMap3d(is400_300_200_100, is400_300_200_100, is400_300_200_100, BitMap3d.BLACK);

            image.ReadRaw(string.Format("D://VTKproj//Ted_{0}.raw", is400_300_200_100));
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] > 128)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            return(image);
        }
Example #5
0
        private ByteMatrix FillMesh()
        {
            int        stx    = (int)(range.Min3[0] - 2);
            int        sty    = (int)(range.Min3[1] - 2);
            int        stz    = (int)(range.Min3[2] - 2);
            int        width  = (int)(range.GetXLength() + 4);
            int        height = (int)(range.GetYLength() + 4);
            int        depth  = (int)(range.GetZLength() + 4);
            ByteMatrix bmp    = new ByteMatrix(stx, sty, stz, width, height, depth, 0);

            FillTriangles(bmp, 255);
            BitMap3d cmp = new BitMap3d(bmp.data, bmp.width, bmp.height, bmp.depth);
            //cmp.SaveRaw("ret1T " + bmp.width + "_" + bmp.height + "_" + bmp.depth + ".raw");
            SpanFill3d rg = new SpanFill3d();

            rg.ExcuteSpanFill(bmp, new Int16Triple(0, 0, 0), 0, 128);
            ReverseValue(bmp);
            return(bmp);
        }
Example #6
0
        public static BitMap3d CreateSampleEngineVolume(string x2)
        {
            BitMap3d image;

            if (x2 == "")
            {
                image = new BitMap3d(256, 256, 128, BitMap3d.BLACK);
                image.ReadRaw("D://VTKproj//engine.raw");
            }
            else
            {
                image = new BitMap3d(512, 512, 256, BitMap3d.BLACK);
                image.ReadRaw("D://VTKproj//enginex2.raw");
            }
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 64 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            for (int k = 0; k < image.depth; k++)
            {
                for (int j = 0; j < image.height; j++)
                {
                    for (int i = 0; i < image.width; i++)
                    {
                        int index = k * image.width * image.height + j * image.width + i;
                        if (i == 0 || i == image.width - 1 || j == 0 || j == image.height - 1 || k == 0 || k == image.depth - 1)
                        {
                            data[index] = BitMap3d.BLACK;
                        }
                    }
                }
            }
            return(image);
        }
Example #7
0
 public CuberilleProcessor(BitMap3d bitmap)
 {
     bmp = bitmap;
 }