Exemple #1
0
        /// <summary>
        /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.GetPlaneIntersection (PlaneSurface, double, double, double, double, double)"/>
        /// </summary>
        /// <param name="pl"></param>
        /// <param name="umin"></param>
        /// <param name="umax"></param>
        /// <param name="vmin"></param>
        /// <param name="vmax"></param>
        /// <param name="precision"></param>
        /// <returns></returns>
        public override IDualSurfaceCurve[] GetPlaneIntersection(PlaneSurface pl, double umin, double umax, double vmin, double vmax, double precision)
        {
            if (firstCurve is Line && secondCurve is Line)
            {
                if (Precision.IsPerpendicular(firstCurve.StartDirection, pl.Normal, false) &&
                    Precision.IsPerpendicular(secondCurve.StartDirection, pl.Normal, false))
                {   // eine Ebene, die zu beiden Linien parallel ist
                    GeoPoint sp1, ep1, sp2, ep2;
                    sp1 = firstCurve.PointAt(umin);
                    ep1 = secondCurve.PointAt(umin);
                    sp2 = firstCurve.PointAt(umax);
                    ep2 = secondCurve.PointAt(umax);
                    GeoPoint2D[] ip1 = pl.GetLineIntersection(sp1, ep1 - sp1);
                    GeoPoint2D[] ip2 = pl.GetLineIntersection(sp2, ep2 - sp2);
                    if (ip1.Length == 1 && ip2.Length == 1)
                    {
                        GeoPoint sp   = pl.PointAt(ip1[0]);
                        GeoPoint ep   = pl.PointAt(ip2[0]);
                        double   v    = Geometry.LinePar(sp1, ep1, sp);
                        Line     line = Line.Construct();
                        line.SetTwoPoints(sp, ep);
                        DualSurfaceCurve dsc = new DualSurfaceCurve(line, this, new Line2D(new GeoPoint2D(umin, v), new GeoPoint2D(umax, v)),
                                                                    pl, new Line2D(ip1[0], ip2[0]));
                        return(new IDualSurfaceCurve[] { dsc });
                    }
                }
            }
            if (firstCurve is Ellipse && secondCurve is Ellipse)
            {
                Ellipse e1 = firstCurve as Ellipse;
                Ellipse e2 = secondCurve as Ellipse;
                if (Precision.SameDirection(pl.Normal, e1.Plane.Normal, false) && Precision.SameDirection(pl.Normal, e2.Plane.Normal, false))
                {
                    if (e1.IsCircle && e2.IsCircle)
                    {
                        GeoPoint sp1, ep1, sp2, ep2, spm, epm;
                        sp1 = firstCurve.PointAt(umin);
                        ep1 = secondCurve.PointAt(umin);
                        sp2 = firstCurve.PointAt(umax);
                        ep2 = secondCurve.PointAt(umax);
                        spm = firstCurve.PointAt((umin + umax) / 2.0);
                        epm = secondCurve.PointAt((umin + umax) / 2.0);
                        GeoPoint2D[] ip1 = pl.GetLineIntersection(sp1, ep1 - sp1);
                        GeoPoint2D[] ip2 = pl.GetLineIntersection(sp2, ep2 - sp2);
                        GeoPoint2D[] ipm = pl.GetLineIntersection(spm, epm - spm);
                        if (ip1.Length == 1 && ip2.Length == 1 && ipm.Length == 1)
                        {
                            Ellipse e3 = Ellipse.Construct();
                            e3.SetArc3Points(pl.PointAt(ip1[0]), pl.PointAt(ipm[0]), pl.PointAt(ip2[0]), pl.Plane);
                            double           v   = Geometry.LinePar(sp1, ep1, pl.PointAt(ip1[0]));
                            DualSurfaceCurve dsc = new DualSurfaceCurve(e3, this, new Line2D(new GeoPoint2D(umin, v), new GeoPoint2D(umax, v)),
                                                                        pl, e3.GetProjectedCurve(pl.Plane));
                            return(new IDualSurfaceCurve[] { dsc });
                        }
                    }
                }
            }
            PlanarState ps1 = firstCurve.GetPlanarState();
            PlanarState ps2 = secondCurve.GetPlanarState();

            if ((ps1 == PlanarState.UnderDetermined || ps1 == PlanarState.Planar) && (ps2 == PlanarState.UnderDetermined || ps2 == PlanarState.Planar))
            {
                if (Precision.IsPerpendicular(firstCurve.StartDirection, pl.Normal, false) && Precision.IsPerpendicular(secondCurve.StartDirection, pl.Normal, false))
                {   // beide Kurven sind eben und parallel zur Schnittebene, wir haben also ein festes v und somit eine Zwischenkurve
                    GeoPoint         ip  = pl.Plane.Intersect(firstCurve.StartPoint, secondCurve.StartPoint - firstCurve.StartPoint);
                    double           v   = Geometry.LinePar(firstCurve.StartPoint, secondCurve.StartPoint, ip);
                    ICurve           cv  = FixedV(v, umin, umax);
                    DualSurfaceCurve dsc = new DualSurfaceCurve(cv, this, new Line2D(new GeoPoint2D(umin, v), new GeoPoint2D(umax, v)),
                                                                pl, cv.GetProjectedCurve(pl.Plane));
                    return(new IDualSurfaceCurve[] { dsc });
                }
            }
            return(base.GetPlaneIntersection(pl, umin, umax, vmin, vmax, precision));
        }