protected virtual Structure ParseStructure(Type type) { Method[] methods = ReflectionUtility.GetMethodsOnType(type).Select(ParseMethod).ToArray(); Indexer[] indexers = ReflectionUtility.GetIndexersOnType(type).Select(ParseIndexer).ToArray(); Property[] properties = ReflectionUtility.GetPropertiesOnType(type).Select(ParseProperty).ToArray(); AccessModifier accessModifier = ReflectionUtility.GetAccessModifier(type); string name = ReflectionUtility.GetGeneralizedTypeName(type); var parameters = new StructureParameters { Indexers = indexers, Methods = methods, Name = name, Properties = properties, RawType = type, AccessModifier = accessModifier, FullName = type.FullName }; var structure = new Structure(parameters); return(structure); }
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 Neat() { Neural = new NeuralParameters(); Mutation = new MutationParameters(); Speciation = new SpeciationParameters(); Reproduction = new ReproductionParameters(); Structure = new StructureParameters(); }
public static void DeleteColumnStructureTest(StructureParameters s) { DeleteColumns deleteColumn = new DeleteColumns(s, new int[] { 40, 200, 500 }); deleteColumn.Apply(); s.Generate().GenerateImage().Save("tests/StructureFilterTests/nachColumnLöschen.png"); SaveFieldPlan(s, "tests/StructureFilterTests/FeldplanNachColumnLöschen.html"); deleteColumn.Undo(); s.Generate().GenerateImage().Save("tests/StructureFilterTests/nachColumnLoeschenUndo.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); }
public static void InsertColumnStructureTest(StructureParameters s) { AddColumns addColumns = new AddColumns(s, 40, 2, 1, true); addColumns.Apply(); AddColumns addColumns2 = new AddColumns(s, 1500, 2, 5, false); addColumns2.Apply(); s.Generate().GenerateImage().Save("tests/StructureFilterTests/nachColumnEinfügen.png"); SaveFieldPlan(s, "tests/StructureFilterTests/FeldplanNachColumnEinfuegen.html"); addColumns2.Undo(); addColumns.Undo(); s.Generate().GenerateImage().Save("tests/StructureFilterTests/nachColumnEinfügenUndo.png"); }
public static void PostFilterStructureTest(string path) { StreamReader sr = new StreamReader(new FileStream("Structures.xml", FileMode.Open)); XElement xml = XElement.Parse(sr.ReadToEnd()); StructureParameters s = new StructureParameters(Path.GetFullPath("tests/PostFilterTest.DObject"), path, xml.Elements().ElementAt(6), 3000, "colors.DColor", ColorDetectionMode.Cie1976Comparison, new Dithering(), AverageMode.Corner, new NoColorRestriction(), true); sr.Close(); s.Generate().GenerateImage().Save("tests/StructureFilterTests/vorFilter.png"); InsertRowStructureTest(s); DeleteRowStructureTest(s); InsertColumnStructureTest(s); DeleteColumnStructureTest(s); }
public static void CopyPasteFieldTest(StructureParameters s) { int[] source_area = new int[100]; int start = 33; int end = 459 + 126 * 10; for (int j = 0; j < 100; j++) { source_area[j] = start + j; } PasteFilter paste = new PasteFilter(s, start, source_area, end); paste.Apply(); s.Generate().GenerateImage().Save("tests/StructureFilterTests/nachPaste.png"); paste.Undo(); s.Generate().GenerateImage().Save("tests/StructureFilterTests/nachPasteUndo.png"); }
public CreateRectangularStructureVM(StructureParameters d, bool?AllowRegenerate) : base(d, AllowRegenerate) { var result = StuctureTypes(); list = result.Item2; structures = result.Item1; for (int i = 0; i < structures.Count; i++) { if (XNode.DeepEquals(structures[i], XElement.Parse(currentStructure._structureDefinitionXML))) { structure_index = i; } } if (structure_index == -1) { structure_index = 0; } UnsavedChanges = false; TargetSizeAffectedProperties = new string[] { nameof(sLength), nameof(sHeight) }; }
public Structure(StructureParameters parameters) : base(parameters) { Methods = parameters.Methods; Properties = parameters.Properties; Indexers = parameters.Indexers; }