/** * * Spustí algoritmus VoxelGridFilter * **/ private static void VoxelGridFilter(float velkostVoxelu) { vystup = new List <ColorPoint3D> (pocetBodovVstupu); zistiRozsah(); rozdelBody(velkostVoxelu); for (int i = 0; i < mriezka.Count; i++) { for (int j = 0; j < mriezka[i].Count; j++) { for (int k = 0; k < mriezka[i][j].Count; k++) { if (mriezka [i] [j] [k].Count > 0) { if (mriezka [i] [j] [k].Count == 1) { vystup.Add(mriezka [i] [j] [k] [0]); } else { ColorPoint3D tazisko = zratajTazisko(mriezka [i] [j] [k]); vystup.Add(tazisko); } } } } } }
/** * * Načítanie vstupu zo súboru. Očakáva sa vstupný súbor typu COFF. * **/ private static void nacitajVstupZoSuboru(string nazovSuboru) { string[] riadky = System.IO.File.ReadAllLines(nazovSuboru); string riadok = riadky [1]; string[] tokeny = riadok.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); pocetBodovVstupu = Int32.Parse(tokeny [0]); vstup = new List <ColorPoint3D> (pocetBodovVstupu); CultureInfo ci = CultureInfo.InvariantCulture; for (int i = 0; i < pocetBodovVstupu; i++) { riadok = riadky [i + 2]; tokeny = riadok.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); float x = float.Parse(tokeny [0], ci); float y = float.Parse(tokeny [1], ci); float z = float.Parse(tokeny [2], ci); int r = (int)(float.Parse(tokeny [3], ci) * 255); int g = (int)(float.Parse(tokeny [4], ci) * 255); int b = (int)(float.Parse(tokeny [5], ci) * 255); ColorPoint3D bod = new ColorPoint3D(x, y, z, r, g, b); vstup.Add(bod); } }
/** * * Načítanie vstupu zo súboru. Očakáva sa vstupný súbor typu COFF. * **/ private static void nacitajVstupZoSuboru(string nazovSuboru) { string[] riadky = System.IO.File.ReadAllLines (nazovSuboru); string riadok = riadky [1]; string[] tokeny = riadok.Split (new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); pocetBodovVstupu = Int32.Parse (tokeny [0]); vstup = new List<ColorPoint3D> (pocetBodovVstupu); CultureInfo ci = CultureInfo.InvariantCulture; for (int i = 0; i < pocetBodovVstupu; i++) { riadok = riadky [i + 2]; tokeny = riadok.Split (new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); float x = float.Parse (tokeny [0], ci); float y = float.Parse (tokeny [1], ci); float z = float.Parse (tokeny [2], ci); int r = (int)(float.Parse (tokeny [3], ci) * 255); int g = (int)(float.Parse (tokeny [4], ci) * 255); int b = (int)(float.Parse (tokeny [5], ci) * 255); ColorPoint3D bod = new ColorPoint3D (x, y, z, r, g, b); vstup.Add (bod); } }