/***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static List <BH.oM.Geometry.Line> CeilingPattern(this Ceiling ceiling, RevitSettings settings, PlanarSurface surface = null)
        {
            CeilingType       ceilingType = ceiling.Document.GetElement(ceiling.GetTypeId()) as CeilingType;
            CompoundStructure comStruct   = ceilingType.GetCompoundStructure();

            Material material = null;

            if (comStruct != null && comStruct.GetLayers().Count > 0)
            {
                material = ceiling.Document.GetElement(comStruct.GetLayers().Last().MaterialId) as Material;
            }
            else
            {
                ElementId materialId = ceiling.GetMaterialIds(false)?.FirstOrDefault();

                if (materialId != null)
                {
                    material = ceiling.Document.GetElement(materialId) as Material;
                }
            }

            if (material == null)
            {
                BH.Engine.Reflection.Compute.RecordWarning(String.Format("Ceiling patterns could not be pulled because there is no material assigned to the ceiling. Revit ElementId: {0}", ceiling.Id));
                return(new List <oM.Geometry.Line>());
            }

            double rotation;
            XYZ    alignment = ceiling.CeilingPatternAlignment(material, settings, out rotation);

            List <oM.Geometry.Line> result = new List <oM.Geometry.Line>();

            if (surface == null)
            {
                //This would need to be extended to take openings from Values into account
                foreach (PlanarSurface srf in ceiling.PanelSurfaces(ceiling.FindInserts(true, true, true, true), settings).Keys)
                {
                    result.AddRange(material.CeilingPattern(srf, settings, alignment, rotation));
                }
            }
            else
            {
                result.AddRange(material.CeilingPattern(surface, settings, alignment, rotation));
            }

            return(result);
        }