/// <summary>
        /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.HitTest (BoundingCube, out GeoPoint2D)"/>
        /// </summary>
        /// <param name="bc"></param>
        /// <param name="uv"></param>
        /// <returns></returns>
        public override bool HitTest(BoundingCube bc, out GeoPoint2D uv)
        {
            Plane        p  = new Plane(GeoPoint.Origin, direction);
            PlaneSurface ps = new PlaneSurface(p);
            ICurve2D     c  = basisCurve.GetProjectedCurve(p);

            GeoPoint[]   points   = bc.Points;
            GeoPoint2D[] points2D = new GeoPoint2D[8];
            for (int i = 0; i < 8; ++i)
            {
                points2D[i] = ps.PositionOf(points[i]);
            }
            // does c hit the polygon?
            int[,] l = bc.LineNumbers;
            for (int k = 0; k < 12; ++k)
            {
                int      i  = l[k, 0];
                int      j  = l[k, 1];
                ICurve2D c2 = new Line2D(points2D[i], points2D[j]);
                if (c2.Length > 0)
                {
                    GeoPoint2DWithParameter[] list = c.Intersect(c2);
                    for (int m = 0; m < list.Length; ++m)
                    {
                        GeoPoint2D d0 = list[m].p;
                        double     d1 = (points2D[i] - d0).Length;
                        double     d2 = (points2D[j] - d0).Length;
                        double     d3 = (points2D[i] - points2D[j]).Length;
                        if (Math.Abs(d1 + d2 - d3) < Precision.eps)
                        {
                            if (d3 < Precision.eps)
                            {
                                throw new Exception();
                            }
                            GeoPoint gp = points[i] + (d1 / d3) * (points[j] - points[i]);
                            uv = PositionOf(gp);
                            return(true);
                        }
                    }
                }
            }
            // is c in the polygon?
            GeoPoint e   = ps.PointAt(c.EndPoint);
            bool     res = (bc.Interferes(e, direction, bc.Size * 1e-8, false));

            if (res)
            {   // nur berechnen, wenn auch gültig
                uv = PositionOf(e);
            }
            else
            {
                uv = GeoPoint2D.Origin;
            }
            return(res);
        }
示例#2
0
        private ICurve[] Intersect(IGeoObject go, PlaneSurface pls)
        {
            Plane plane = pls.Plane;

            if (go is Solid)
            {
                BoundingCube bc = go.GetBoundingCube();
                if (bc.Interferes(plane))
                {
                    return((go as Solid).GetPlaneIntersection(pls));
                }
            }
            if (go is Shell)
            {
                BoundingCube bc = go.GetBoundingCube();
                if (bc.Interferes(plane))
                {
                    return((go as Shell).GetPlaneIntersection(pls));
                }
            }
            if (go is Face)
            {
                BoundingCube bc = go.GetBoundingCube();
                if (bc.Interferes(plane))
                {
                    return((go as Face).GetPlaneIntersection(pls));
                }
            }
            List <ICurve> res = new List <ICurve>();

            if (go is Block)
            {
                for (int i = 0; i < go.NumChildren; i++)
                {
                    res.AddRange(Intersect(go.Child(i), pls));
                }
            }
            return(res.ToArray());
        }
示例#3
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.HitTest (ref BoundingCube, double)"/>
 /// </summary>
 /// <param name="cube"></param>
 /// <param name="precision"></param>
 /// <returns></returns>
 public override bool HitTest(ref BoundingCube cube, double precision)
 {
     return(cube.Interferes(new GeoPoint[] { location, location + directionWidth, location + directionWidth + directionHeight, location + directionHeight }, new int[] { 0, 1, 2, 0, 2, 3 }));
 }
示例#4
0
文件: Line.cs 项目: SOFAgh/CADability
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.HitTest (ref BoundingCube, double)"/>
 /// </summary>
 /// <param name="cube"></param>
 /// <param name="precision"></param>
 /// <returns></returns>
 public override bool HitTest(ref BoundingCube cube, double precision)
 {
     return(cube.Interferes(ref startPoint, ref endPoint));
 }
示例#5
0
文件: Line.cs 项目: SOFAgh/CADability
 bool IOctTreeInsertable.HitTest(ref BoundingCube cube, double precision)
 {
     return(cube.Interferes(p1, p2, p3, p4));
 }
示例#6
0
文件: Line.cs 项目: SOFAgh/CADability
 bool IOctTreeInsertable.HitTest(ref BoundingCube cube, double precision)
 {
     return(cube.Interferes(ref startPoint, ref endPoint));
 }
示例#7
0
文件: Line.cs 项目: SOFAgh/CADability
 bool IOctTreeInsertable.HitTest(ref BoundingCube cube, double precision)
 {
     return(cube.Interferes(start, dir, precision, true));
 }