/// <summary> /// Returns minimal and maximal Bases point /// </summary> /// <returns>Array of 2 elements where [0] is Max and [1] is Min</returns> public static BasePoint[] GetMaxMinPoint(IEnumerable<Entity> solids) { var result = new BasePoint[2]; var xMax = double.MinValue; var yMax = double.MinValue; var zMax = double.MinValue; var xMin = double.MaxValue; var yMin = double.MaxValue; var zMin = double.MaxValue; foreach (var solid in solids) { try { var brep = new Brep(solid); using (brep) { foreach (var edg in brep.Edges) { var tmp = CastHelper.ConvertToBasePoint(edg.Vertex1.Point); if (tmp.X > xMax) xMax = tmp.X; if (tmp.X < xMin) xMin = tmp.X; if (tmp.Y > yMax) yMax = tmp.Y; if (tmp.Y < yMin) yMin = tmp.Y; if (tmp.Z > zMax) zMax = tmp.Z; if (tmp.Z < zMin) zMin = tmp.Z; } } } catch (Autodesk.AutoCAD.BoundaryRepresentation.Exception) { Debug.WriteLine("Exception occured"); } } result[0] = new BasePoint(xMin, yMin, zMin); result[1] = new BasePoint(xMax, yMax, zMax); return result; }
/// <summary> /// Returns minimal and maximal Bases point /// </summary> /// <returns>Array of 2 elements where [0] is Max and [1] is Min</returns> private static BasePoint[] GetMaxMinPoint(IEnumerable <Solid3d> solids) { var result = new BasePoint[2]; double xMax = double.MinValue; double yMax = double.MinValue; double zMax = double.MinValue; double xMin = double.MaxValue; double yMin = double.MaxValue; double zMin = double.MaxValue; foreach (Solid3d solid in solids) { Brep brep = new Brep(solid); using (brep) { foreach (Complex cmp in brep.Complexes) { foreach (Shell shl in cmp.Shells) { foreach (Face fce in shl.Faces) { foreach (BoundaryLoop lp in fce.Loops) { foreach (Edge edg in lp.Edges) { BasePoint tmp = CastHelper.ConvertToBasePoint(edg.Vertex1.Point); if (tmp.X > xMax) { xMax = tmp.X; } if (tmp.X < xMin) { xMin = tmp.X; } if (tmp.Y > yMax) { yMax = tmp.Y; } if (tmp.Y < yMin) { yMin = tmp.Y; } if (tmp.Z > zMax) { zMax = tmp.Z; } if (tmp.Z < zMin) { zMin = tmp.Z; } } } } } } } } // xMin = Math.Round(xMin, 0); // yMin = Math.Round(yMin, 0); // zMin = Math.Round(zMin, 0); // xMax = Math.Round(xMax, 0); // yMax = Math.Round(yMax, 0); // zMax = Math.Round(zMax, 0); result[0] = new BasePoint(xMin, yMin, zMin); result[1] = new BasePoint(xMax, yMax, zMax); return(result); }