void SatisfyConstraints() { for (int i = 0; i < settings.ProjectionIterations; ++i) { foreach (var level in constraints.Keys) { if (level > CurrentConstraintLevel) { break; } foreach (var c in constraints[level]) { c.Project(); // c.Project operates only on MSAGL nodes, so need to update the local FiNode.Centers foreach (var v in c.Nodes) { ((FiNode)v.AlgorithmData).Center = v.Center; } } } foreach (LockPosition l in settings.locks) { l.Project(); // again, project operates only on MSAGL nodes, we'll also update FiNode.PreviousPosition since we don't want any inertia in this case foreach (var v in l.Nodes) { FiNode fiNode = v.AlgorithmData as FiNode; // the locks should have had their AlgorithmData updated, but if (for some reason) // the locks list is out of date we don't want to null ref here. if (fiNode != null && v.AlgorithmData != null) { fiNode.ResetBounds(); } } } } }