static void WallTest(String path) { Progress <String> progress = new Progress <string>(pr => Console.WriteLine(pr)); StreamReader sr = new StreamReader(new FileStream("Structures.xml", FileMode.Open)); XElement xml = XElement.Parse(sr.ReadToEnd()); StructureParameters p = new StructureParameters(Path.GetFullPath("tests/WallTest.DObject"), path, xml.Elements().ElementAt(1), 30000, "colors.DColor", ColorDetectionMode.Cie1976Comparison, new Dithering(), AverageMode.Corner, new NoColorRestriction(), true); var watch = System.Diagnostics.Stopwatch.StartNew(); //DominoTransfer t = await Dispatcher.CurrentDispatcher.Invoke(async () => await Task.Run(() => p.Generate(wb, progress))); sr.Close(); //DominoTransfer t = p.Generate(); //Console.WriteLine("Size: " + t.shapes.Count()); watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); watch = System.Diagnostics.Stopwatch.StartNew(); //Mat b2 = t.GenerateImage(borders: false); watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); //b2.Save("tests/WallTest.png"); p.Save(); ((NonEmptyCalculation)p.PrimaryCalculation).Dithering = new JarvisJudiceNinkeDithering(); p.Generate().GenerateImage().Save("tests/Wall_dithered.png"); sr.Close(); //FileStream fs = new FileStream(@"WallPlanTest.html", FileMode.Create); //StreamWriter sw = new StreamWriter(fs); //sw.Write(p.GetHTMLProcotol(new ObjectProtocolParameters() //{ // backColorMode = ColorMode.Normal, // foreColorMode = ColorMode.Intelligent, // orientation = Orientation.Horizontal, // reverse = false, // summaryMode = SummaryMode.Large, // textFormat = "<font face=\"Verdana\">", // templateLength = 20, // textRegex = "%count% %color%", // title = "Field" //})); //p.SaveXLSFieldPlan("ExcelFieldPlanTest.xlsx", new ObjectProtocolParameters() //{ // backColorMode = ColorMode.Normal, // foreColorMode = ColorMode.Intelligent, // orientation = Orientation.Horizontal, // reverse = false, // summaryMode = SummaryMode.Large, // textFormat = "<font face=\"Verdana\">", // templateLength = 20, // textRegex = "%count%", // title = "Field", // path = Directory.GetCurrentDirectory() //}); //sw.Close(); p.Save(); Workspace.Clear(); StructureParameters p2 = Workspace.Load <StructureParameters>(Path.GetFullPath("tests/WallTest.DObject")); p2.Generate().GenerateImage().Save("tests/wall_after_load.png"); }
public static AssemblyNode CreateProject() { string rootpath = Path.GetFullPath("tests/"); DominoAssembly main = new DominoAssembly(); main.Save(Path.Combine(rootpath, "main.DProject")); main.colorPath = "colors.DColor"; var mainnode = new AssemblyNode(Path.Combine(rootpath, "main.DProject")); FieldParameters field1 = new FieldParameters(Path.GetFullPath("tests/field1.DObject"), "mountain.jpg", main.colorPath, 8, 8, 24, 8, 10000, Emgu.CV.CvEnum.Inter.Lanczos4, new CieDe2000Comparison(), new Dithering(), new NoColorRestriction()); field1.Save(); new FieldNode("field1.DObject", main); StreamReader sr = new StreamReader(new FileStream("Structures.xml", FileMode.Open)); XElement xml = XElement.Parse(sr.ReadToEnd()); StructureParameters structure = new StructureParameters(Path.GetFullPath("tests/structure.DObject"), "transparent.png", xml.Elements().ElementAt(1), 30000, main.colorPath, ColorDetectionMode.Cie1976Comparison, new Dithering(), AverageMode.Corner, new NoColorRestriction(), true); structure.Save(); new StructureNode("structure.DObject", main); DominoAssembly sub = new DominoAssembly(); string subpath = "sub.DProject"; sub.Save(Workspace.AbsolutePathFromReference(ref subpath, main)); sub.colorPath = "colors.DColor"; new AssemblyNode("sub.DProject", main); FieldParameters sub1 = new FieldParameters(Path.GetFullPath("tests/field2.DObject"), "transparent.png", main.colorPath, 8, 8, 24, 8, 10000, Emgu.CV.CvEnum.Inter.Lanczos4, new CieDe2000Comparison(), new Dithering(), new NoColorRestriction()); field1.Save(); new FieldNode("field2.DObject", sub); new FieldNode("field1.DObject", sub); sub.Save(); foreach (AssemblyNode node in main.children.Where(child => child is AssemblyNode)) { node.obj.Save(); } if (field1 == ((FieldNode)sub.children[1]).obj) { Console.WriteLine("references to field1 identical"); } main.Save(mainnode.Path); PrintProjectStructure(mainnode, ""); return(mainnode); }