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> ExecuteSilently( 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 new Dictionary <string, object> { { "nodePositions", null }, { "goalOutputs", null }, { "geometries", null }, { "stats", null } } } ; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); DynaShape.Solver solver = new DynaShape.Solver(); solver.AddGoals(goals); if (geometryBinders != null) { solver.AddGeometryBinders(geometryBinders); } solver.EnableMomentum = enableMomentum; solver.Execute(iterations, threshold); TimeSpan computationTime = stopwatch.Elapsed; stopwatch.Restart(); return(new Dictionary <string, object> { { "nodePositions", solver.GetNodePositionsAsPoints() }, { "goalOutputs", solver.GetGoalOutputs() }, { "geometries", solver.GetGeometries() }, { "stats", String.Concat( "Computation Time: " + computationTime, "\nData Output Time: " + stopwatch.Elapsed, "\nIterations : " + solver.CurrentIteration, "\nMovement : " + solver.GetKineticEnergy()) } }); } }
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 }, }); }
internal void SetUp() { Goals.Add(ContainmentGoal); Goals.Add(OnPlaneGoal); Goals.Add(SphereCollisionGoal); //Goals.Add(GlobalDirectionGoal); //Goals.AddRange(DepartmentAnchorGoals); Goals.AddRange(DepartmentCohesionGoals); Goals.AddRange(SpaceAdjacencyGoals); Goals.AddRange(SpaceDepartmentAdjacencyGoals); foreach (var circleBinderList in CircleBinders) { GeometryBinders.AddRange(circleBinderList); } GeometryBinders.AddRange(SpaceAdjacencyLineBinders); GeometryBinders.AddRange(SpaceDepartmentAdjacencyLineBinders); GeometryBinders.AddRange(TextBinders); //GeometryBinders.Add(BubbleMeshesBinder); Solver = new DynaShape.Solver(); Solver.AddGoals(Goals); Solver.AddGeometryBinders(GeometryBinders); }