Beispiel #1
0
    {/// <summary>
     /// returns the contur of a list of triangles
     /// </summary>
     /// <param name="L">List of triangles</param>
     /// <returns></returns>
        public static Loxyz GetContour(List <Triangle> L)
        {
            Dictionary <xyz, xyz> D = new Dictionary <xyz, xyz>();

            for (int i = 0; i < L.Count; i++)
            {
                INeighbors N = L[i] as INeighbors;
                ITriangle  T = L[i];
                if ((T.GetB() - T.GetA() & T.GetC() - T.GetA()).length() < 0.0000001)
                {
                    continue;
                }
                if (N.GetNeighbor(0) == -1)
                {
                    D.Add(T.GetA().Toxyz(), T.GetB().Toxyz());
                }
                if (N.GetNeighbor(1) == -1)
                {
                    D.Add(T.GetB().Toxyz(), T.GetC().Toxyz());
                }
                if (N.GetNeighbor(2) == -1)
                {
                    D.Add(T.GetC().Toxyz(), T.GetA().Toxyz());
                }
            }
            Loxyz Result = new Loxyz();

            while (true)
            {
                if (D.Count == 0)
                {
                    break;
                }
                xyz First = new xyz(0, 0, 0);
                foreach (KeyValuePair <xyz, xyz> Pt in D)
                {
                    First = Pt.Key;
                    break;
                }
                xyz      Current = First;
                xyzArray A       = new xyzArray();
                Result.Add(A);
                while (true)
                {
                    if (D.ContainsKey(Current))
                    {
                        xyz C = D[Current];
                        A.Add(C);
                        D.Remove(Current);
                        Current = C;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(Result);
        }