コード例 #1
0
        static void GetVertices(List <XYZ> vertices, Solid s)
        {
            Debug.Assert(0 < s.Edges.Size,
                         "expected a non-empty solid");

            Dictionary <XYZ, int> a
                = new Dictionary <XYZ, int>(
                      new XyzEqualityComparer());

            foreach (Face f in s.Faces)
            {
                Mesh m = f.Triangulate();
                foreach (XYZ p in m.Vertices)
                {
                    if (!a.ContainsKey(p))
                    {
                        a.Add(p, 1);
                    }
                    else
                    {
                        ++a[p];
                    }
                }
            }
            List <XYZ> keys = new List <XYZ>(a.Keys);

            Debug.Assert(8 == keys.Count,
                         "expected eight vertices for a rectangular column");

            keys.Sort((p, q) => Util.Compare(p, q));

            foreach (XYZ p in keys)
            {
                Debug.Assert(3 == a[p],
                             "expected every vertex of solid to appear in exactly three faces");

                vertices.Add(p);
            }
        }
コード例 #2
0
 int IComparable <XYZ> .CompareTo(XYZ a)
 {
     return(Util.Compare(this, a));
 }