示例#1
0
        private static void AlignPointParallel(GenericPosture posture, CalibrationHelper calibrationHelper, GenericPostureParallelAlign impact)
        {
            // The point is moved so that it stays on a segment parallel to another segment.

            if (impact == null)
            {
                return;
            }

            PointF a           = posture.Points[impact.A];
            PointF b           = posture.Points[impact.B];
            PointF c           = posture.Points[impact.C];
            PointF pointToMove = posture.Points[impact.PointToMove];

            PointF aPlane     = calibrationHelper.GetPoint(a);
            PointF bPlane     = calibrationHelper.GetPoint(b);
            PointF cPlane     = calibrationHelper.GetPoint(c);
            PointF pointPlane = calibrationHelper.GetPoint(pointToMove);

            PointF resultPlane = GeometryHelper.GetPointOnParallel(aPlane, bPlane, cPlane, pointPlane);
            PointF result      = calibrationHelper.GetImagePoint(resultPlane);

            posture.Points[impact.PointToMove] = result;
        }
        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();
        }