Exemple #1
0
        bool intersectPlaneWithLine(SnapItem Plane, SnapItem Line, xyzArray LineArray, ref double Lam, ref xyz Result)
        {
            TriangleF T = Plane.GetTriangle();

            if (T == null)
            {
                return(false);
            }
            xyz N1 = ((T.B - T.A) & (T.C - T.A)).Toxyz();

            if (LineArray == null)
            {
            }
            xyz N2 = LineArray.cross();

            if ((N1 & N2).length() < 0.00001)   // Parallel
            {
                xyzArray A = Plane.getxyzArray();
                if (A != null)
                {
                    xyzArray         B = LineArray;
                    List <CrossTag1> L = CrossTag1.GetCrossList(A, B);

                    for (int i = 0; i < L.Count; i++)
                    {
                        if (A.Value(L[i].Lam1).dist(Plane.Point) <= SnapItem.Snapdist)
                        {
                            Lam = L[i].Lam1;

                            Result = A.Value(L[i].Lam1);
                            return(true);
                        }
                    }
                }
            }

            int Object = StoredSnapItems.IndexOf(Plane);
            int siz    = SnapDistance * 2 + 1;

            //  int siz = SnapDistance;
            Drawing3d.PrimIdObj[,] P = SubArray(Device.MousePos.X - siz / 2, (int)Device.ViewPort.Height - Device.MousePos.Y - siz / 2, siz, siz);
            List <TriangleF> LT = GetTriangles(P, Object);

            Lam = -1;



            bool R = Cross(LT, LineArray, ref Lam, ref Result);

            return(R);
        }
Exemple #2
0
        public override Base GetBase()
        {
            Base B = ModelMatrix.toBase();;

            B.BaseO = Point;
            int id = -1;

            for (int i = 0; i < PolyPoly.Count; i++)
            {
                xyArray  A        = PolyPoly[i];
                LineType ViewLine = Device.FromScr(Device.MousePos);
                double   Dummy    = -1;
                double   di       = A.Distance(ViewLine, 2 * Snapdist, out Lam, out Dummy);
                if (di <= 2 * Snapdist)
                {
                    id = i;
                    break;
                }
            }
            if (id >= 0)
            {
                xyzArray A = ModelMatrix * PolyPoly[id].ToxyzArray();
                if (Lam >= 0)
                {
                    xyz D = ModelMatrix * PolyPoly[id].Direction(Lam).toXYZ() - ModelMatrix * new xyz(0, 0, 0);
                    B = Base.DoComplete(Point, D, new xyz(0, 0, 1) & D);
                }
            }
            else
            {
                xyzArray A = ModelMatrix * PolyPoly[0].ToxyzArray();
                xyz      D = A.cross();
                B = Base.DoComplete(Point, D, new xyz(0, 0, 1) & D);
            }
            return(B);
        }