// Change the gaps associated with a leg.
public static void ChangeLegGaps(EventDB eventDB, Id<ControlPoint> controlId1, Id<ControlPoint> controlId2, LegGap[] newGaps)
{
// Get the leg object for this leg. Create one if needed.
Id<Leg> legId = QueryEvent.FindLeg(eventDB, controlId1, controlId2);
Leg leg;
if (legId.IsNone)
leg = new Leg(controlId1, controlId2);
else
leg = (Leg) eventDB.GetLeg(legId).Clone();
// Change the gaps.
leg.gaps = (newGaps == null) ? null : (LegGap[]) newGaps.Clone();
// Write the change leg object to the event DB. If the leg is vacuous, could involve removing the leg.
if (leg.IsVacuous()) {
if (legId.IsNotNone)
eventDB.RemoveLeg(legId);
}
else {
if (legId.IsNone)
eventDB.AddLeg(leg);
else
eventDB.ReplaceLeg(legId, leg);
}
}