private static void KeepPointAngle(GenericPosture posture, GenericPostureImpactKeepAngle impact) { // The point is moved so that the angle between its leg and the other leg is kept. if (impact == null) { return; } PointF origin = posture.PointList[impact.Origin]; PointF leg1 = posture.PointList[impact.Leg1]; if (origin == leg1) { return; } PointF result = GeometryHelper.GetPointAtAngleAndDistance(origin, leg1, impact.OldAngle, impact.OldDistance); posture.PointList[impact.Leg2] = result; }
private static void PrepareImpacts(GenericPosture posture, int handle) { foreach (GenericPostureAbstractImpact impact in posture.Handles[handle].Impacts) { // If there is a KeepAngle impact, we'll later need to know the current angle. if (impact.Type == ImpactType.KeepAngle) { GenericPostureImpactKeepAngle impactKeepAngle = impact as GenericPostureImpactKeepAngle; PointF origin = posture.PointList[impactKeepAngle.Origin]; PointF leg1 = posture.PointList[impactKeepAngle.Leg1]; PointF leg2 = posture.PointList[impactKeepAngle.Leg2]; if (origin == leg1 || origin == leg2) { continue; } impactKeepAngle.OldAngle = GeometryHelper.GetAngle(origin, leg1, leg2); impactKeepAngle.OldDistance = GeometryHelper.GetDistance(origin, leg2); } } }
private void ParseImpacts(XmlReader r) { r.ReadStartElement(); while (r.NodeType == XmlNodeType.Element) { if (r.Name == "Align") { GenericPostureImpactLineAlign impact = new GenericPostureImpactLineAlign(r); if (impact != null) { Impacts.Add(impact); } } else if (r.Name == "VerticalAlign") { GenericPostureImpactVerticalAlign impact = new GenericPostureImpactVerticalAlign(r); if (impact != null) { Impacts.Add(impact); } } else if (r.Name == "HorizontalAlign") { GenericPostureImpactHorizontalAlign impact = new GenericPostureImpactHorizontalAlign(r); if (impact != null) { Impacts.Add(impact); } } else if (r.Name == "Pivot") { GenericPostureImpactPivot impact = new GenericPostureImpactPivot(r); if (impact != null) { Impacts.Add(impact); } } else if (r.Name == "KeepAngle") { GenericPostureImpactKeepAngle impact = new GenericPostureImpactKeepAngle(r); if (impact != null) { Impacts.Add(impact); } } else if (r.Name == "HorizontalSymmetry") { GenericPostureImpactHorizontalSymmetry impact = new GenericPostureImpactHorizontalSymmetry(r); if (impact != null) { Impacts.Add(impact); } } else if (r.Name == "SegmentCenter") { GenericPostureImpactSegmentCenter impact = new GenericPostureImpactSegmentCenter(r); if (impact != null) { Impacts.Add(impact); } } else if (r.Name == "PerdpendicularAlign") { GenericPosturePerpendicularAlign impact = new GenericPosturePerpendicularAlign(r); if (impact != null) { Impacts.Add(impact); } } else if (r.Name == "ParallelAlign") { GenericPostureParallelAlign impact = new GenericPostureParallelAlign(r); if (impact != null) { Impacts.Add(impact); } } else { string outerXml = r.ReadOuterXml(); log.DebugFormat("Unparsed content in XML: {0}", outerXml); } } r.ReadEndElement(); }