//int _iso; // Use this for initialization void Start() { Slice.initDicom(); string dicomfilepath = Application.dataPath + @"\..\dicomdata\"; // Application.dataPath is in the assets folder, but these files are "managed", so we go one level up _slices = processSlices(dicomfilepath); // loads slices from the folder above setTexture(_slices[0], 0); // shows the first slice // gets the mesh object and uses it to create a diagonal line meshScript mscript = GameObject.Find("GameObjectMesh").GetComponent <meshScript>(); List <Vector3> vertices = new List <Vector3>(); List <int> indices = new List <int>(); vertices.Add(new Vector3(-0.5f, -0.5f, 0)); vertices.Add(new Vector3(0.5f, 0.5f, 0)); indices.Add(0); indices.Add(1); mscript.createMeshGeometry(vertices, indices); //TODO: pseudokode fra forelesning for (int i = 0; i < _numSlices; i++) { foreach (Slice x in _slices) { break; } } }
void update() { var texture = new Texture2D(xdim, ydim, TextureFormat.RGB24, false); // garbage collector will tackle that it is new'ed for (int y = 0; y < ydim; y++) { for (int x = 0; x < xdim; x++) { float v = pixelValue(new Vector3(x, y, this.slice)); texture.SetPixel(x, y, new UnityEngine.Color(v, v, v)); } } texture.filterMode = FilterMode.Point; // nearest neigbor interpolation is used. (alternative is FilterMode.Bilinear) texture.Apply(); // Apply all SetPixel calls GetComponent <Renderer>().material.mainTexture = texture; var circle = marchingSquares(texture, true); mScript = GameObject.Find("GameObjectMesh").GetComponent <meshScript>(); mScript.createMeshGeometry(circle.Item1, circle.Item2); }