/// <summary> /// Generates and solves the constraints. /// </summary> /// <param name="solver">The solver to generate into and solve. May be null, in which case one /// is created by the method.</param> /// <param name="parameters">Parameters to OverlapRemoval and ProjectionSolver.Solver.Solve().</param> /// <param name="doGenerate">Generate constraints before solving; if false, solver is assumed to /// have already been populated by this.Generate().</param> /// <returns>The set of OverlapRemoval.Constraints that were unsatisfiable, or NULL.</returns> public ProjectionSolver.Solution Solve(ProjectionSolver.Solver solver, OverlapRemovalParameters parameters, bool doGenerate) { if (null == solver) { solver = new ProjectionSolver.Solver(); } if (null == parameters) { parameters = new OverlapRemovalParameters(); } if (doGenerate) { Generate(solver, parameters); } ProjectionSolver.Solution solverSolution = solver.Solve(parameters.SolverParameters); foreach (OverlapRemovalCluster cluster in this.clusterHierarchies) { cluster.UpdateFromVariable(); // "recursively" processes all child clusters } return solverSolution; }
/// <summary> /// Generate the necessary constraints to ensure there is no overlap (unless we're doing /// a horizontal pass and deferring some movement, which would be smaller, to the vertical pass). /// </summary> /// <param name="solver">The solver to generate into.</param> /// <param name="parameters">Parameters to OverlapRemoval and ProjectionSolver.Solver.Solve().</param> public void Generate(ProjectionSolver.Solver solver, OverlapRemovalParameters parameters) { ValidateArg.IsNotNull(solver, "solver"); if (null == parameters) { parameters = new OverlapRemovalParameters(); } foreach (OverlapRemovalCluster cluster in this.clusterHierarchies) { cluster.Generate(solver, parameters, this.IsHorizontal); } // For Clusters we reposition their "fake border" variables between the constraint-generation // and solving phases, so we need to tell the solver to do this. solver.UpdateVariables(); // @@PERF: Not needed if no clusters were created. }