コード例 #1
0
        /// <summary>
        /// Calucalates a <see cref="CrossList"/> for this CurveArray with an other <see cref="Loca"/>.
        /// The CrossItemparameter <see cref="CrossItem.Param1"/> is relative to this CurveArray.
        /// <br/>
        /// The parameter <see cref="CrossItem.Param2"/>  relative to the "value"-Loca.
        /// If (<see cref="CrossItem.Param2"/> greater Loca[0].Count the take id =<see cref="CrossItem.Param2"/> - Loca[0].count,
        /// If (<see cref="CrossItem.Param2"/> greater Loca[1].Count the take id =<see cref="CrossItem.Param2"/> - Loca[1].count,
        /// and so on.
        /// </summary>
        /// <param name="value">A Loca</param>
        /// <param name="TangentialPoints">Respect curves, who are tangential an intersection.</param>
        /// <returns>A CrossList</returns>
        public CrossList getCrossList(Loca value, bool TangentialPoints)
        {
            CrossList Result = new CrossList();
            int       ct     = 0;

            for (int i = 0; i < value.Count; i++)
            {
                CrossList CL = getCrossList(value[i], TangentialPoints);
                for (int j = 0; j < CL.Count; j++)
                {
                    CrossItem CI = CL[j];
                    CI.Param2 = CI.Param2 + ct;
                    Result.Add(CI);
                    CI.CrossList = CL;
                }
                ct += value[i].Count;
            }

            return(Result);
        }
コード例 #2
0
        /// <summary>
        /// It`s the same as the overloaded method, but you can set, whether Tangential points
        /// should be taken or not.
        /// </summary>
        /// <param name="value">An other CurveArray</param>
        /// <param name="TangentialPoints">True, if the tangential points are taken</param>
        /// <returns>A Crosslist</returns>
        public CrossList getCrossList(CurveArray value, bool TangentialPoints)
        {
            ArrayList L1 = GetConnections();
            ArrayList L2 = value.GetConnections();

            int       StartJ;
            CrossList CL;
            CrossList Result = new CrossList();

            Result.AllowMultiCross = TangentialPoints;// for instant
            int AIndex = 0;

            for (int i = 0; i < L1.Count; i++)
            {
                CurveArray CA     = (CurveArray)L1[i];
                xyArray    A      = CA.getxyArray();
                int        BIndex = 0;
                StartJ = 0;
                for (int j = StartJ; j < L2.Count; j++)
                {
                    CurveArray CB = (CurveArray)L2[j];
                    xyArray    B  = CB.getxyArray();
                    CL = A.getCrossList(B, TangentialPoints);
                    for (int k = 0; k < CL.Count; k++)
                    {
                        CrossItem CI  = CL[k];
                        double    aID = CA.xyArrayIndexToCurveArrayIndex(CI.Param1);
                        double    bID = CB.xyArrayIndexToCurveArrayIndex(CI.Param2);



                        CI.Param1 = (float)AIndex + CA.xyArrayIndexToCurveArrayIndex(CI.Param1);
                        CI.Param2 = (float)BIndex + CB.xyArrayIndexToCurveArrayIndex(CI.Param2);
                        Curve  C1  = CA[Utils.trunc(aID)];
                        Curve  C2  = CB[Utils.trunc(bID)];
                        double Lam = CI.Param1 - Utils.trunc(CI.Param1);
                        double Mue = CI.Param2 - Utils.trunc(CI.Param2);

                        CI.Param1 = IndexOf(C1) + Lam;
                        CI.Param2 = value.IndexOf(C2) + Mue;
                        Mue       = CI.Param2 - Utils.trunc(CI.Param2);

                        Lam = CI.Param1 - Utils.trunc(CI.Param1);

                        if (C1.Cross(C2, Lam, Mue, out Lam, out Mue))
                        {
                            if ((Lam < 0) && ((System.Math.Abs(Lam) < 0.000001)))
                            {
                                Lam = 0;
                            }
                            if (System.Math.Abs(Lam - 1) < 0.00001)
                            {
                                Lam = 0.999999;
                            }
                            CI.Param1 = Utils.trunc(CI.Param1) + Lam;

                            if ((Mue < 0) && ((System.Math.Abs(Mue) < 0.000001)))
                            {
                                Mue = 0;
                            }
                            if (System.Math.Abs(Mue - 1) < 0.00001)
                            {
                                Mue = 0.999999;
                            }
                            CI.Param2 = Utils.trunc(CI.Param2) + Mue;
                        }

                        else
                        {
                            Lam = 0;
                            if (C1.Equals(C2))
                            {
                                Lam = 1;
                            }
                        }


                        if ((Utils.trunc(CI.Param1) < 0) && (System.Math.Abs(CI.Param1) < 0.00001))
                        {
                            CI.Param1 = 0;
                        }
                        if ((Utils.trunc(CI.Param2) < 0) && (System.Math.Abs(CI.Param2) < 0.00001))
                        {
                            CI.Param2 = 0;
                        }



                        //if (((Utils.trunc(System.Math.Round(CI.Param1,3)) !=System.Math.Round(CI.Param1,3)))
                        //    ||
                        //    ((Utils.trunc(System.Math.Round(CI.Param1,3)) !=System.Math.Round(CI.Param1,3))))
                        Result.Add(CI);
                    }
                    BIndex += CB.Count;
                }
                AIndex += CA.Count;
            }
            return(Result);
        }
コード例 #3
0
        static CrossList CrossWithLine(xy A, xy B, xyArray Array, EdgeLoop E)
        {
            CrossList Result = new CrossList();
            double    Lam    = -1;
            double    Mue    = -1;

            _Array1 = Array;
            xy Last = Array[Array.Count - 1];

            for (int i = 0; i < Array.Count - 1; i++)
            {
                if (i < Array.Count - 1)
                {
                    if (Array[i].dist(Array[i + 1]) < LuckyEpsilon)
                    {
                        continue;
                    }
                }
                int Nexti = Succ(i);

                xy Next = Array[Nexti];
                if (!(TwoLines(A, B, Array[i], Next, ref Lam, ref Mue)))
                {
                    continue;
                }
                Lam = System.Math.Round(Lam, 8);
                Mue = System.Math.Round(Mue, 8);

                double D1  = Distance(Next, A, B);
                double D2  = Distance(Array[i], A, B);
                int    Prv = Prev(i);
                double D3  = Distance(Array[Prv], A, B);

                if ((System.Math.Abs(D1) < EdgeTolerance) &&
                    (System.Math.Abs(D2) < EdgeTolerance))
                {
                    Last = Array[i];
                    continue;
                }
                if ((System.Math.Abs(D1) >= EdgeTolerance) &&
                    (System.Math.Abs(D2) < EdgeTolerance))
                {
                    if ((System.Math.Abs(D3) < EdgeTolerance))
                    {
                        CrossItem CI = new CrossItem(i + LuckyEpsilon, Lam, -1);// FromBorder
                        if (D1 > 0)
                        {
                            CI.CrossKind = 1;
                        }
                        else
                        {
                            CI.CrossKind = -1;
                        }

                        CI.Border1 = BorderBehavior.BorderEnd;
                        Result.Add(CI);
                        continue;
                    }
                }
                if ((System.Math.Abs(D1) < EdgeTolerance) &&
                    (System.Math.Abs(D2) >= EdgeTolerance))
                {
                    int    succ         = Succ(Nexti);
                    double SuccDistance = System.Math.Abs(Distance(Array[succ], A, B));
                    if (SuccDistance <= EdgeTolerance)
                    {
                        // ToBorder
                        CrossItem CI = new CrossItem(i + (1 - LuckyEpsilon), Lam, -1);// ToBorder
                        CI.CrossKind = 1;
                        if (D2 < 0)
                        {
                            CI.CrossKind = 1;
                        }
                        else
                        {
                            CI.CrossKind = -1;
                        }
                        CI.Border1 = BorderBehavior.BorderBegin;
                        Result.Add(CI);
                        Last = Array[i];
                    }

                    continue;
                }


                if ((System.Math.Abs(D2) < EdgeTolerance) && (D1 * D3 < 0))
                {
                    // Mue ==0 Durchgehend
                    int kk = ToSide;
                    if (D1 < 0)
                    {
                        kk = -ToSide;
                    }


                    CrossItem CI = new CrossItem(i - Mue - 0.000000001, Lam, -1);
                    CI.CrossKind = 1;
                    if (D1 < 0)
                    {
                        CI.CrossKind = -1;
                    }

                    Result.Add(CI);
                    Last = Array[i];
                    continue;
                }
                else
                //else // neu------------------------------------------------------------
                if ((System.Math.Abs(D2) < EdgeTolerance) && (D1 * D3 > 0))
                {
                    if ((Mue >= -LuckyEpsilon) && ((Mue < 1 - LuckyEpsilon) &&
                                                   (Lam >= -LuckyEpsilon) && ((Lam <= 1 + LuckyEpsilon))))
                    {
                        xy     v1 = Array[i] - Array[Prv];
                        xy     v2 = Next - Array[i];
                        double kk = v1 & v2;
                        if (kk * D1 < 0)
                        {
                        }
                        //D1 = v1 & v2;
                        //D1 = -D1;


                        CrossItem CI = null;    // new CrossItem(i + Mue, Lam, -1);// ToBorder
                        if (D1 > 0)
                        {
                            CI = new CrossItem(i + Mue - LuckyEpsilon, Lam + LuckyEpsilon, -1);    // FromBorder
                        }
                        else
                        {
                            CI = new CrossItem(i + Mue - LuckyEpsilon, Lam - LuckyEpsilon, -1);    // FromBorder
                        }
                        if (D1 < 0)
                        {
                            CI.CrossKind = 1;
                        }
                        else
                        {
                            CI.CrossKind = -1;
                        }

                        CI.Border1 = BorderBehavior.BorderBegin;
                        Result.Add(CI);
                        if (D1 < 0)
                        {
                            CI = new CrossItem(i + Mue + LuckyEpsilon, Lam + LuckyEpsilon, -1);    // FromBorder
                        }
                        else
                        {
                            CI = new CrossItem(i + Mue + LuckyEpsilon, Lam - LuckyEpsilon, -1);    // FromBorder
                        }
                        if (D1 > 0)
                        {
                            CI.CrossKind = 1;
                        }
                        else
                        {
                            CI.CrossKind = -1;
                        }

                        CI.Border1 = BorderBehavior.BorderEnd;
                        Result.Add(CI);
                        continue;
                    }
                }
                if (D1 * D2 < 0)
                {
                    CrossItem CI = new CrossItem(i + Mue, Lam, -1);
                    CI.CrossKind = 1;
                    if (D1 < 0)
                    {
                        CI.CrossKind = -1;
                    }
                    Result.Add(CI);
                    Last = Array[i];
                    continue;
                }
            }

            return(Result);
        }