Пример #1
0
        /// <summary>
        /// Updates an xy track section to a new 3d curve. For the method to work as intended the xy curve should lie directly above the origin of the track section plane
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        private static void UpdateXYTrackSection(TrackSection ts, Curve c, double tolerance)
        {
            var events = Rhino.Geometry.Intersect.Intersection.CurvePlane(c, ts.TrackSectionPlane, tolerance);

            if (events != null)
            {
                if (events.Count != 1)
                {
                    throw new Exception(
                              "Curve/plane intersection failed. Only one intersection point expected, number of intersection points found: " + events.Count);
                }
                else
                {
                    if (events[0].IsPoint)
                    {
                        ts.Translate(events[0].PointA - ts.TrackSectionPlane.Origin);
                    }
                    else if (events[0].IsOverlap)
                    {
                        ts.Translate(((events[0].PointA + events[0].PointB) / 2) - ts.TrackSectionPlane.Origin);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Updates the height curve sections to a new 3d curve
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="c1">The original height curve</param>
        /// <param name="c2">The new 3d curve</param>
        private static void UpdateHTrackSection(TrackSection ts, Curve c1, Curve c2, double tolerance)
        {
            double t1;

            c1.ClosestPoint(ts.TrackSectionPlane.Origin, out t1);
            Interval iv     = new Interval(c1.Domain.T0, t1);
            double   length = c1.GetLength(iv);

            // Make projection of xy curve for length to be correct
            Curve c3 = c2.DuplicateCurve();

            c3.Transform(Rhino.Geometry.Transform.PlanarProjection(Plane.WorldXY));

            ts.Translate(c3.PointAtLength(length) - ts.TrackSectionPlane.Origin);
            UpdateXYTrackSection(ts, c2, tolerance);
        }