BuildingCoder.CmdSlabBoundary.GetBoundary C# (CSharp) Method

GetBoundary() static private method

Determine the boundary polygons of the lowest horizontal planar face of the given solid.
static private GetBoundary ( List polygons, Solid solid ) : bool
polygons List Return polygonal boundary /// loops of lowest horizontal face, i.e. profile of /// circumference and holes
solid Solid Input solid
return bool
        static bool GetBoundary(
            List<List<XYZ>> polygons,
            Solid solid)
        {
            PlanarFace lowest = null;
              FaceArray faces = solid.Faces;
              foreach( Face f in faces )
              {
            PlanarFace pf = f as PlanarFace;
            if( null != pf && Util.IsHorizontal( pf ) )
            {
              if( ( null == lowest )
            || ( pf.Origin.Z < lowest.Origin.Z ) )
              {
            lowest = pf;
              }
            }
              }
              if( null != lowest )
              {
            XYZ p, q = XYZ.Zero;
            bool first;
            int i, n;
            EdgeArrayArray loops = lowest.EdgeLoops;
            foreach( EdgeArray loop in loops )
            {
              List<XYZ> vertices = new List<XYZ>();
              first = true;
              foreach( Edge e in loop )
              {
            IList<XYZ> points = e.Tessellate();
            p = points[0];
            if( !first )
            {
              Debug.Assert( p.IsAlmostEqualTo( q ),
                "expected subsequent start point"
                + " to equal previous end point" );
            }
            n = points.Count;
            q = points[n - 1];
            for( i = 0; i < n - 1; ++i )
            {
              XYZ v = points[i];
              v -= _offset * XYZ.BasisZ;
              vertices.Add( v );
            }
              }
              q -= _offset * XYZ.BasisZ;
              Debug.Assert( q.IsAlmostEqualTo( vertices[0] ),
            "expected last end point to equal"
            + " first start point" );
              polygons.Add( vertices );
            }
              }
              return null != lowest;
        }