Example #1
0
        public static String3D XStrimextend(String3D XS, String3D XSTinta)
        {
            String3D XSrezultat = new String3D();

            if (XS.Count < 2 || XSTinta.Count < 2)
            {
                return(XS);
            }

            for (int i = 0; i < XS.Count; i++)
            {
                if (i == 0)
                {
                    for (int j = 0; j < XSTinta.Count - 1; j++)
                    {
                        Punct3D P = (Punct3D)XSint4P(XS[0], XS[1], XSTinta[j], XSTinta[j + 1]);
                        if (P.Offset <= XS[1].Offset && P.Offset >= XSTinta[j].Offset && P.Offset <= XSTinta[j + 1].Offset)
                        {
                            XSrezultat.Add(P);
                        }
                    }
                    if (XSrezultat.Count == 0)
                    {
                        XSrezultat.Add(XS[0]);
                    }
                }
                else if (i == XS.Count - 1)
                {
                    for (int j = 0; j < XSTinta.Count - 1; j++)
                    {
                        Punct3D P = (Punct3D)XSint4P(XS[XS.Count - 2], XS[XS.Count - 1], XSTinta[j], XSTinta[j + 1]);
                        if (P.Offset >= XS[XS.Count - 2].Offset && P.Offset >= XSTinta[j].Offset && P.Offset <= XSTinta[j + 1].Offset)
                        {
                            XSrezultat.Add(P);
                        }
                    }
                    if (XSrezultat.Count < XS.Count)
                    {
                        XSrezultat.Add(XS[XS.Count - 1]);
                    }
                }
                else
                {
                    XSrezultat.Add(XS[i]);
                }
            }

            return(XSrezultat);
        }
        public static String3D XSintersect(String3D S1, String3D S2)
        {
            String3D S = new String3D();

            for (int i = 0; i <= S1.Count - 2; i++)
            {
                for (int j = 0; j <= S2.Count - 2; j++)
                {
                    Punct3D punct = XSint4P(S1[i], S1[i + 1], S2[j], S2[j + 1]);
                    if (punct.Offset >= S1[i].Offset && punct.Offset <= S1[i + 1].Offset)
                    {
                        S.Add(punct);
                    }
                }
            }

            if (S.Count > 0)
            {
                return(S);
            }
            else
            {
                return(null);
            }
        }