/// <summary> /// Load spiral parameters from input textboxes and verify they are correct /// </summary> /// <returns>spiral parameters<</returns> public SpiralParameters GetSpiralParametres() { if (areParametersPhysical) { double wallWidth = Convert.ToDouble(textBoxWidthWall.Text, CultureInfo.InvariantCulture); double spaceWidth = Convert.ToDouble(textBoxWidthStructure.Text, CultureInfo.InvariantCulture); double depth = Convert.ToDouble(textBoxLength.Text, CultureInfo.InvariantCulture); double innerSize = Convert.ToDouble(textBoxInnerDiameter.Text, CultureInfo.InvariantCulture); double outerSize = Convert.ToDouble(textBoxOuterDiameter.Text, CultureInfo.InvariantCulture); if (!(Validator.ValidNumber(wallWidth) && Validator.ValidNumber(spaceWidth) && Validator.ValidNumber(depth) && Validator.ValidNumber(innerSize) && Validator.ValidNumber(outerSize))) { return(null); } double climb = ConvertorOfParametres.CountClimb(spaceWidth, wallWidth); double move = ConvertorOfParametres.CountMove(innerSize, wallWidth, climb); double turns = ConvertorOfParametres.CountTurns(climb, wallWidth, outerSize, move); double circ = ConvertorOfParametres.CountCircumference(move, climb, turns); return(new SpiralParameters(move, climb, depth, circ, wallWidth)); } double move1 = Convert.ToDouble(textBoxWidthWall.Text, CultureInfo.InvariantCulture); double climb1 = Convert.ToDouble(textBoxWidthStructure.Text, CultureInfo.InvariantCulture); double depth1 = Convert.ToDouble(textBoxLength.Text, CultureInfo.InvariantCulture); double circumference = Convert.ToDouble(textBoxInnerDiameter.Text, CultureInfo.InvariantCulture); double wallWidth1 = Convert.ToDouble(textBoxOuterDiameter.Text, CultureInfo.InvariantCulture); SpiralParameters sp = new SpiralParameters(move1, climb1, depth1, circumference, wallWidth1); if (!Validator.ValidSpiral(sp)) { return(null); } return(sp); }
/// <summary> /// create spiral /// </summary> /// <param name="crystParams">parameters of the crystal</param> /// <param name="inputFile">name of file with input crystal</param> /// <param name="axis">axis and direction of rotation</param> public void CreateSpiral(CrystalParameters crystParams, string inputFile, string axis) { SpiralParameters spiralParams = GetSpiralParametres(); if (Equals(spiralParams, null)) { ShowError("Invalid values of spiral parametres."); return; } try { //Program.CreateSpiral(crystParams, spiralParams, inputFile, axis); //TODO:nejak tam nesedi navazovani automu Program.CreateSpiralFromPlane(crystParams, spiralParams, inputFile, axis); ActionWasSuccessfull("Spiral was created."); } catch { ShowError("Mistake while creating spiral. Check your structure parameters or input file."); } }
static void SpiralTest(string path) { Console.WriteLine("======= SPIRAL TEST ======="); Progress <String> progress = new Progress <string>(pr => Console.WriteLine(pr)); //Mat mat = CvInvoke.Imread(path, ImreadModes.AnyColor); SpiralParameters p = new SpiralParameters(Path.GetFullPath("tests/Spiral.DObject"), path, 50, "colors.DColor", ColorDetectionMode.CieDe2000Comparison, new Dithering(), AverageMode.Corner, new NoColorRestriction()); p.ThetaMin = 0.3d * Math.PI; var watch = System.Diagnostics.Stopwatch.StartNew(); //DominoTransfer t = await Dispatcher.CurrentDispatcher.Invoke(async () => await Task.Run(() => p.Generate(wb, progress))); DominoTransfer t = p.Generate(); Console.WriteLine(t.length); watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); watch = System.Diagnostics.Stopwatch.StartNew(); Mat b2 = t.GenerateImage(Colors.Transparent); watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); b2.Save("tests/SpiralTest.png"); FileStream fs = new FileStream(@"SpiralPlanTest.html", FileMode.Create); StreamWriter sw = new StreamWriter(fs); /*sw.Write(p.GetHTMLProcotol(new ObjectProtocolParameters() * { * backColorMode = ColorMode.Normal, * foreColorMode = ColorMode.Intelligent, * orientation = Core.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(); watch = Stopwatch.StartNew(); int[] counts = Workspace.LoadColorList <SpiralParameters>(Path.GetFullPath("tests/Spiral.DObject")).Item2; watch.Stop(); Console.WriteLine("Preview Load Time: " + watch.ElapsedMilliseconds); Console.WriteLine(String.Join(", ", counts)); Workspace.Clear(); watch = Stopwatch.StartNew(); SpiralParameters loaded = Workspace.Load <SpiralParameters>(Path.GetFullPath("tests/Spiral.DObject")); loaded.Generate().GenerateImage().Save("tests/spiral_after_load.png"); }