Пример #1
0
        protected internal override xyz Cross(LineType ViewLine)
        {
            double vz = ViewLine.Direction.z;

            if (ViewLine.Direction.z == 0)
            {
                return(new xyz(0, 0, 0));
            }
            xyzArray A = Curve.ToxyzArray();

            double LineLam = -1;
            double di      = A.Distance(ViewLine, 2 * Snapdist, out Lam, out LineLam);

            if (di <= 2 * Snapdist)
            {
                Lam /= Curve.Resolution;
                return(Curve.Value(Lam));
            }
            else
            {
                Lam = -1;
            }
            xyz Result = new xyz(0, 0, 0);

            new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)).Cross(ViewLine, out LineLam, out Result);
            return(Result);
        }
Пример #2
0
        xyz Nearest(LineType L, xyzf A, xyzf B, xyzf C)
        {
            xyzArray M = new xyzArray(4);

            M[0] = A.Toxyz();
            M[1] = B.Toxyz();
            M[2] = C.Toxyz();
            M[3] = A.Toxyz();
            double Param   = -1;
            double LineLam = -1;
            double n       = M.Distance(L, 1e10, out Param, out LineLam);

            return(M.Value(Param));
        }
Пример #3
0
        protected internal override xyz Cross(LineType ViewLine)
        {
            double Dummy = -1;
            double di    = Poly.Distance(ViewLine, 2 * Snapdist, out Lam, out Dummy);

            if (di <= 2 * Snapdist)
            {
                return(Poly.Value(Lam));
            }
            else
            {
                Lam = -1;
            }
            xyz    Result  = new xyz(0, 0, 0);
            double LineLam = -1;

            new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)).Cross(ViewLine, out LineLam, out Result);
            return(Result);
        }
Пример #4
0
        public static bool Cross(TriangleF t1, TriangleF t2, out double Lam, out double Mue, out xyz P, out xyz Q)
        {
            xyzArray A = new xyzArray();
            xyzArray B = new xyzArray();

            A.data = new xyz[] { t1.A.Toxyz(), t1.B.Toxyz(), t1.C.Toxyz() };
            B.data = new xyz[] { t2.A.Toxyz(), t2.B.Toxyz(), t2.C.Toxyz() };
            Lam    = -1;
            Mue    = -1;
            P      = new Drawing3d.xyz(0, 0, 0);
            Q      = new Drawing3d.xyz(0, 0, 0);

            double d = (A.Distance(B, 1e10, out Lam, out Mue));

            if (d < 2)
            {
                P = A.Value(Lam);
                Q = B.Value(Mue);
                return(true);
            }
            return(false);
        }
Пример #5
0
        protected internal override xyz Cross(LineType ViewLine)
        {
            xyzArray A = Curve.ToXYArray().ToxyzArray();

            double LineLam = -1;
            double di      = A.Distance(ViewLine, 2 * Snapdist, out Lam, out LineLam);

            if (di <= 2 * Snapdist)
            {
                doExchange = true;
                Lam        = Lam / Curve.Resolution;
                return(Curve.Value(Lam).toXYZ());
            }
            else
            {
                Lam = -1;
            }
            xyz Result = new xyz(0, 0, 0);

            new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)).Cross(ViewLine, out LineLam, out Result);
            return(Result);
        }
Пример #6
0
        protected internal override xyz Cross(LineType ViewLine)
        {
            if (this.PolygonMode == PolygonMode.Line)
            {
                Polygon = Primitives3d.GetBoxPoints(Position, Size);
                double Param    = -1;
                double LineLam1 = -1;
                if (Polygon.Distance(ViewLine, 1e10, out Param, out LineLam1) < 1)
                {
                    return(Polygon.Value(Param));
                }
                return(new xyz(0, 0, 0));
            }
            xyz[] Result   = new xyz[5];
            Plane Triangle = new Plane(TriangleInfo.Points[TriangleInfo.Indices[PrimId * 3]], TriangleInfo.Points[TriangleInfo.Indices[PrimId * 3 + 1]], TriangleInfo.Points[TriangleInfo.Indices[PrimId * 3 + 2]]);

            //Test
            switch (PrimId)
            {// Oben
            case 0:
                //Polygon.data = new xyz[] {TriangleInfo.Points[0].Toxyz(),
                //                TriangleInfo.Points[2].Toxyz(),
                //                TriangleInfo.Points[1].Toxyz(),
                //                TriangleInfo.Points[3].Toxyz(),
                //                TriangleInfo.Points[0].Toxyz()};
                //Point = Position;
                //Result[0] = new xyz(Point.x, Point.y, Point.z + Size.z);
                //Result[1] = new xyz(Point.x, Point.y + Size.y, Point.z + Size.z);
                //Result[2] = new xyz(Point.x, Point.y + Size.y, Point.z);
                //Result[3] = new xyz(Point.x, Point.y, Point.z);
                //Result[4] = Result[0];
                Result[0] = new xyz(Position.x, Position.y, Position.z + Size.Z);
                Result[1] = new xyz(Position.x + Size.x, Position.y, Position.z + Size.Z);
                Result[2] = new xyz(Position.x + Size.x, Position.y + Size.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x, Position.y + Size.y, Position.z + Size.Z);
                Result[4] = Result[0];
                break;

            case 1:
                //Polygon.data = new xyz[] {TriangleInfo.Points[0].Toxyz(),
                //                TriangleInfo.Points[2].Toxyz(),
                //                TriangleInfo.Points[1].Toxyz(),
                //                TriangleInfo.Points[3].Toxyz(),
                //                 TriangleInfo.Points[0].Toxyz()
                //};
                Result[0] = new xyz(Position.x, Position.y, Position.z + Size.Z);
                Result[1] = new xyz(Position.x + Size.x, Position.y, Position.z + Size.Z);
                Result[2] = new xyz(Position.x + Size.x, Position.y + Size.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x, Position.y + Size.y, Position.z + Size.Z);
                Result[4] = Result[0];
                break;

            case 2:    // unten
                //Polygon.data = new xyz[] {TriangleInfo.Points[4].Toxyz(),
                //                TriangleInfo.Points[6].Toxyz(),
                //                TriangleInfo.Points[5].Toxyz(),
                //                TriangleInfo.Points[7].Toxyz(),
                //                TriangleInfo.Points[4].Toxyz()
                //};
                Result[0] = new xyz(Position.x, Position.y, Position.z);
                Result[2] = new xyz(Position.x + Size.x, Position.y, Position.z);
                Result[1] = new xyz(Position.x + Size.x, Position.y + Size.y, Position.z);
                Result[3] = new xyz(Position.x, Position.y + Size.y, Position.z);
                Result[4] = Result[0];
                break;

            case 3:
                //Polygon.data = new xyz[] {TriangleInfo.Points[4].Toxyz(),
                //                TriangleInfo.Points[6].Toxyz(),
                //                TriangleInfo.Points[5].Toxyz(),
                //                TriangleInfo.Points[7].Toxyz(),
                //                TriangleInfo.Points[4].Toxyz()
                //};
                Result[0] = new xyz(Position.x, Position.y, Position.z);
                Result[2] = new xyz(Position.x + Size.x, Position.y, Position.z);
                Result[1] = new xyz(Position.x + Size.x, Position.y + Size.y, Position.z);
                Result[3] = new xyz(Position.x, Position.y + Size.y, Position.z);
                Result[4] = Result[0];
                break;

            case 4:
                //Polygon.data = new xyz[] {TriangleInfo.Points[8].Toxyz(),
                //                TriangleInfo.Points[10].Toxyz(),
                //                TriangleInfo.Points[9].Toxyz(),
                //                TriangleInfo.Points[11].Toxyz(),
                //                TriangleInfo.Points[8].Toxyz()
                //};
                Result[0] = new xyz(Position.x, Position.y, Position.z);
                Result[1] = new xyz(Position.x + Size.x, Position.y, Position.z);
                Result[2] = new xyz(Position.x + Size.x, Position.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x, Position.y, Position.z + Size.Z);
                Result[4] = Result[0];
                break;

            case 5:
                //Polygon.data = new xyz[] {TriangleInfo.Points[8].Toxyz(),
                //                TriangleInfo.Points[10].Toxyz(),
                //                TriangleInfo.Points[9].Toxyz(),
                //                TriangleInfo.Points[11].Toxyz(),
                //                TriangleInfo.Points[8].Toxyz()
                //};
                Result[0] = new xyz(Position.x, Position.y, Position.z);
                Result[1] = new xyz(Position.x + Size.x, Position.y, Position.z);
                Result[2] = new xyz(Position.x + Size.x, Position.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x, Position.y, Position.z + Size.Z);
                Result[4] = Result[0];

                break;

            case 6:    // Hinten
                //Polygon.data = new xyz[] {TriangleInfo.Points[12].Toxyz(),
                //                TriangleInfo.Points[14].Toxyz(),
                //                TriangleInfo.Points[13].Toxyz(),
                //                TriangleInfo.Points[15].Toxyz(),
                //                TriangleInfo.Points[12].Toxyz()
                //};
                Result[0] = new xyz(Position.x + Size.x, Position.y + Size.Y, Position.z);
                Result[1] = new xyz(Position.x, Position.y + Size.Y, Position.z);
                Result[2] = new xyz(Position.x, Position.y + Size.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x + Size.x, Position.y + Size.y, Position.z + Size.Z);
                Result[4] = Result[0];
                break;

            case 7:    // Hinten
                //Polygon.data = new xyz[] {TriangleInfo.Points[12].Toxyz(),
                //                TriangleInfo.Points[14].Toxyz(),
                //                TriangleInfo.Points[13].Toxyz(),
                //                TriangleInfo.Points[15].Toxyz(),
                //                TriangleInfo.Points[12].Toxyz()
                //};
                Result[0] = new xyz(Position.x + Size.x, Position.y + Size.Y, Position.z);
                Result[1] = new xyz(Position.x, Position.y + Size.Y, Position.z);
                Result[2] = new xyz(Position.x, Position.y + Size.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x + Size.x, Position.y + Size.y, Position.z + Size.Z);
                Result[4] = Result[0];
                break;

            case 8:     // Links))
                //Polygon.data = new xyz[] {TriangleInfo.Points[16].Toxyz(),
                //                TriangleInfo.Points[18].Toxyz(),
                //                TriangleInfo.Points[17].Toxyz(),
                //                TriangleInfo.Points[19].Toxyz(),
                //                TriangleInfo.Points[16].Toxyz()
                //};
                Result[0] = new xyz(Position.x, Position.y + Size.Y, Position.z);
                Result[1] = new xyz(Position.x, Position.y, Position.z);
                Result[2] = new xyz(Position.x, Position.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x, Position.y + Size.Y, Position.z + Size.Z);
                Result[4] = Result[0];
                break;

            case 9:
                //Polygon.data = new xyz[] {TriangleInfo.Points[16].Toxyz(),
                //                TriangleInfo.Points[18].Toxyz(),
                //                TriangleInfo.Points[17].Toxyz(),
                //                TriangleInfo.Points[19].Toxyz(),
                //                TriangleInfo.Points[16].Toxyz()

                //                  };
                Result[0] = new xyz(Position.x, Position.y + Size.Y, Position.z);
                Result[1] = new xyz(Position.x, Position.y, Position.z);
                Result[2] = new xyz(Position.x, Position.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x, Position.y + Size.Y, Position.z + Size.Z);
                Result[4] = Result[0];
                break;

            case 10:    //Rechts
                //Polygon.data = new xyz[] {TriangleInfo.Points[20].Toxyz(),
                //                TriangleInfo.Points[22].Toxyz(),
                //                TriangleInfo.Points[21].Toxyz(),
                //                TriangleInfo.Points[23].Toxyz(),
                //                TriangleInfo.Points[20].Toxyz()
                //                   };
                Result[0] = new xyz(Position.x + Size.X, Position.y, Position.z);
                Result[1] = new xyz(Position.x + Size.x, Position.y + Size.Y, Position.z);
                Result[2] = new xyz(Position.x + Size.x, Position.y + Size.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x + Size.x, Position.y, Position.z + Size.z);
                Result[4] = Result[0];
                break;

            case 11:    //Rechts
                //Polygon.data = new xyz[] {TriangleInfo.Points[20].Toxyz(),
                //                TriangleInfo.Points[22].Toxyz(),
                //                TriangleInfo.Points[21].Toxyz(),
                //                TriangleInfo.Points[23].Toxyz(),
                //                TriangleInfo.Points[20].Toxyz()
                //                 };
                Result[0] = new xyz(Position.x + Size.X, Position.y, Position.z);
                Result[1] = new xyz(Position.x + Size.x, Position.y + Size.Y, Position.z);
                Result[2] = new xyz(Position.x + Size.x, Position.y + Size.y, Position.z + Size.Z);
                Result[3] = new xyz(Position.x + Size.x, Position.y, Position.z + Size.z);
                Result[4] = Result[0];
                break;

            default:
                break;
            }
            Polygon.data = Result;
            double Lam     = -1;
            double LineLam = -1;
            double di      = Polygon.Distance(ViewLine, Snapdist, out Lam, out LineLam);

            if (di <= Snapdist)
            {
                xyz P = Polygon.Value(Lam);
                doExchange = true;

                //xyz W = ViewLine.Value(LineLam);
                //double mm = P.dist(W);
                return(P);
            }
            return(base.Cross(ViewLine));
        }