public static Dictionary <string, object> Execute( DynaShape.Solver solver, List <Goal> goals, [DefaultArgument("null")] List <GeometryBinder> geometryBinders, [DefaultArgument("0")] int iterations, [DefaultArgument("true")] bool reset, [DefaultArgument("true")] bool execute, [DefaultArgument("true")] bool enableMomentum, [DefaultArgument("true")] bool enableFastDisplay, [DefaultArgument("false")] bool enableManipulation) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); if (reset) { solver.StopBackgroundExecution(); solver.Clear(); solver.AddGoals(goals); if (geometryBinders != null) { solver.AddGeometryBinders(geometryBinders); } solver.Display.Render(); } else { solver.EnableMouseInteraction = enableManipulation; solver.EnableMomentum = enableMomentum; solver.EnableFastDisplay = enableFastDisplay; solver.IterationCount = iterations; if (execute) { solver.StartBackgroundExecution(); } else { solver.StopBackgroundExecution(); if (!enableFastDisplay) { solver.Iterate(); } } } return(enableFastDisplay ? new Dictionary <string, object> { { "nodePositions", null }, { "goalOutputs", null }, { "geometries", null } } : new Dictionary <string, object> { { "nodePositions", solver.GetNodePositionsAsPoints() }, { "goalOutputs", solver.GetGoalOutputs() }, { "geometries", solver.GetGeometries() } }); }
public static Dictionary <string, object> Execute( DynaShape.Solver solver, List <Goal> goals, [DefaultArgument("null")] List <GeometryBinder> geometryBinders, [DefaultArgument("10")] int iterations, [DefaultArgument("true")] bool reset, [DefaultArgument("true")] bool momentum, [DefaultArgument("true")] bool fastDisplay, [DefaultArgument("false")] bool mouseInteract) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); if (reset) { solver.Clear(); solver.AddGoals(goals); if (geometryBinders != null) { solver.AddGeometryBinders(geometryBinders); } } else { solver.AllowMouseInteraction = mouseInteract; solver.Step(iterations, momentum); } double time = stopwatch.Elapsed.TotalMilliseconds; return(fastDisplay ? new Dictionary <string, object> { { "time", time }, { "display", new DynaShapeDisplay(solver) } } : new Dictionary <string, object> { { "nodePositions", solver.GetNodePositionsAsPoints() }, { "geometries", solver.GetGeometries() }, { "time", time }, }); }
public static Dictionary <string, object> ExecuteSilently( DynaShape.Solver solver, List <Goal> goals, [DefaultArgument("null")] List <GeometryBinder> geometryBinders, [DefaultArgument("10000")] int iterations, [DefaultArgument("0.001")] double threshold, [DefaultArgument("true")] bool execute, [DefaultArgument("true")] bool enableMomentum) { if (!execute) { return(null); } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); solver.Clear(); solver.AddGoals(goals); solver.AddGeometryBinders(geometryBinders); solver.Execute(iterations, threshold); TimeSpan computationTime = stopwatch.Elapsed; stopwatch.Restart(); return(new Dictionary <string, object> { { "nodePositions", solver.GetStructuredNodePositionsAsPoints() }, { "goalOutputs", solver.GetGoalOutputs() }, { "geometries", solver.GetGeometries() }, { "stats", String.Concat( "Computation Time: " + computationTime, "\nData Output Time: " + stopwatch.Elapsed, "\nIterations : " + solver.CurrentIteration, "\nMovement : " + solver.GetKineticEnergy()) } }); }