/// <summary> /// Determine the boundary polygons of the lowest /// horizontal planar face of the given solid. /// </summary> /// <param name="polygons">Return polygonal boundary /// loops of lowest horizontal face, i.e. profile of /// circumference and holes</param> /// <param name="solid">Input solid</param> /// <returns>False if no horizontal planar face was /// found, else true</returns> 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); }
/// <summary> /// Return the uppermost horizontal face /// of a given "horizontal" solid object /// such as a floor slab. Currently only /// supports planar faces. /// </summary> PlanarFace GetTopFace( Solid solid ) { PlanarFace topFace = null; FaceArray faces = solid.Faces; foreach( Face f in faces ) { PlanarFace pf = f as PlanarFace; if( null != pf && Util.IsHorizontal( pf ) ) { if( ( null == topFace ) || ( topFace.Origin.Z < pf.Origin.Z ) ) { topFace = pf; } } } return topFace; }