Пример #1
0
        /// <summary>
        /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.Intersect (ICurve, BoundingRect, out GeoPoint[], out GeoPoint2D[], out double[])"/>
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="uvExtent"></param>
        /// <param name="ips"></param>
        /// <param name="uvOnFaces"></param>
        /// <param name="uOnCurve3Ds"></param>
        public override void Intersect(ICurve curve, BoundingRect uvExtent, out GeoPoint[] ips, out GeoPoint2D[] uvOnFaces, out double[] uOnCurve3Ds)
        {
            if (curve is Line)
            {
                GeoPoint ip;
                if (Plane.Intersect(curve.StartPoint, curve.StartDirection, out ip))
                {
                    ips         = new GeoPoint[] { ip };
                    uvOnFaces   = new GeoPoint2D[] { PositionOf(ip) };
                    uOnCurve3Ds = new double[] { curve.PositionOf(ip) };
                }
                else
                {
                    ips         = new GeoPoint[0];
                    uvOnFaces   = new GeoPoint2D[0];
                    uOnCurve3Ds = new double[0];
                }
#if DEBUG
                //GeoPoint[] ipsdbg;
                //GeoPoint2D[] uvOnFacesdbg;
                //double[] uOnCurve3Dsdbg;
                //base.Intersect(curve, out ipsdbg, out uvOnFacesdbg, out uOnCurve3Dsdbg);
#endif
                return;
            }
            //else if (curve is IExplicitPCurve3D)
            //{
            //    ExplicitPCurve3D epc3d = (curve as IExplicitPCurve3D).GetExplicitPCurve3D();
            //    double [] res = epc3d.GetPlaneIntersection(Location, DirectionX, DirectionY);
            //    for (int i = 0; i < res.Length; i++)
            //    {
            //        double d = Plane.Distance(epc3d.PointAt(res[i]));
            //        if (i>0) d = Plane.Distance(epc3d.PointAt((res[i]+res[i-1])/2.0));
            //    }
            //    double dd = Plane.Distance(epc3d.PointAt(epc3d.knots[epc3d.knots.Length - 1]));
            //    for (int i = 0; i < res.Length; i++)
            //    {
            //        res[i] = (res[i] - epc3d.knots[0]) / (epc3d.knots[epc3d.knots.Length - 1] - epc3d.knots[0]);
            //    }
            //}
            else
            {
                if (curve.GetPlanarState() == PlanarState.Planar)
                {
                    GeoPoint  loc;
                    GeoVector dir;
                    Plane     pln = curve.GetPlane();
                    if (Plane.Intersect(curve.GetPlane(), out loc, out dir))
                    {
                        ICurve2D     c2d = curve.GetProjectedCurve(pln);
                        BoundingRect ext = c2d.GetExtent();
                        ext.Inflate(ext.Height + ext.Width); // sonst entstehen null-Linien
                        ICurve2D ll = new Line2D(pln.Project(loc), pln.Project(dir), ext);
#if DEBUG
                        DebuggerContainer dc = new DebuggerContainer();
                        dc.Add(c2d);
                        dc.Add(ll);
#endif
                        GeoPoint2DWithParameter[] gpp = ll.Intersect(c2d);
                        ips         = new GeoPoint[gpp.Length];
                        uvOnFaces   = new GeoPoint2D[gpp.Length];
                        uOnCurve3Ds = new double[gpp.Length];
                        for (int i = 0; i < gpp.Length; ++i)
                        {
                            ips[i]         = pln.ToGlobal(gpp[i].p);
                            uvOnFaces[i]   = PositionOf(ips[i]);
                            uOnCurve3Ds[i] = curve.PositionOf(ips[i]);
                        }
                    }
                    else
                    {
                        ips         = new GeoPoint[0];
                        uvOnFaces   = new GeoPoint2D[0];
                        uOnCurve3Ds = new double[0];
                    }
#if DEBUG
                    //GeoPoint[] ipsdbg;
                    //GeoPoint2D[] uvOnFacesdbg;
                    //double[] uOnCurve3Dsdbg;
                    //base.Intersect(curve, out ipsdbg, out uvOnFacesdbg, out uOnCurve3Dsdbg);
#endif
                    return;
                }
            }
            TetraederHull th = new TetraederHull(curve);
            // alle Kurven müssten eine gemeinsame basis habe, auf die man sich hier beziehen kann
            // damit die TetraederHull nicht mehrfach berechnet werden muss
            th.PlaneIntersection(this, out ips, out uvOnFaces, out uOnCurve3Ds);
            // base.Intersect(curve, out ips, out uvOnFaces, out uOnCurve3Ds);
        }