public void Export(TileModel model, TilePropagator tilePropagator, string filename, DeBroglieConfig config, ExportOptions exportOptions) { Vox vox; ITopoArray <byte> array; if (exportOptions is VoxExportOptions veo) { vox = veo.Template; array = tilePropagator.ToValueArray <byte>(); } else if (exportOptions is VoxSetExportOptions vseo) { vox = vseo.Template; var tileArray = tilePropagator.ToArray(); var subTiles = vseo.SubTiles.ToDictionary(x => x.Key, x => VoxUtils.ToTopoArray(x.Value)); array = MoreTopoArrayUtils.ExplodeTiles(tileArray, subTiles, vseo.TileWidth, vseo.TileHeight, vseo.TileDepth); } else { throw new System.Exception($"Cannot export from {exportOptions.TypeDescription} to .vox"); } VoxUtils.Save(vox, array); using (var stream = new FileStream(filename, FileMode.Create)) { var br = new BinaryWriter(stream); VoxSerializer.Write(br, vox); } }
protected RoundTripTest(Type[] testTypes = null) { testTypes = testTypes ?? new Type[0]; serializer = new VoxFactory().Create(); var typeIdCounter = 1; var typeContextsByTypeId = testTypes.ToDictionary( testType => typeIdCounter++, TypeContext.Create); serializer.ImportTypes(new InlineVoxTypes(0, typeContextsByTypeId)); }
public Runner(VoxSerializer serializer, Action <T, T> assertEqualsOverride) { this.serializer = serializer; this.assertEqualsOverride = assertEqualsOverride; }