/// <summary> /// 获取线 /// </summary> /// <param name="face"></param> /// <returns></returns> private Line GetGeometryLine(Face face) { EdgeArrayArray edgeArrayArray = face.EdgeLoops; List <Line> linelist = new List <Line>(); Dictionary <Line, double> dic = new Dictionary <Line, double>(); foreach (EdgeArray array in edgeArrayArray) { foreach (Edge e in array) { Line li = e.AsCurve() as Line; if (li == null) { break; } dic.Add(li, li.Length); } } Line line = null; var liLength = dic.Values.Max(); for (int a = 0; a < dic.Count; a++) { if (dic.ElementAt(a).Value == liLength) { line = dic.ElementAt(a).Key; break; } break; } return(line); }
/// <summary> /// 筛选出楼板引出标注的位置,进行定位 /// </summary> /// <param name="face"></param> /// <param name="curve"></param> /// <returns></returns> private CurveArray GetCurveFromFloor(Face face, Curve curve) { CurveArray curvearray = new CurveArray(); Line l2 = curve as Line; EdgeArrayArray arrayArray = face.EdgeLoops; Dictionary <Curve, double> dic_angle = new Dictionary <Curve, double>(); foreach (EdgeArray array in arrayArray) { foreach (Edge e in array) { Curve cu = e.AsCurve(); Line l1 = cu as Line; if (cu.GetType() != typeof(Line)) { break; } var angle = GetAngle(l1, l2); dic_angle.Add(cu, angle); //将角度与对应曲线加入字典,之后根据相应数值进行提取 } } double angle_a = Math.PI / 2; for (int a = 0; a < dic_angle.Count; a++) { if (dic_angle.Values.ElementAt <double>(a) == angle_a) { curvearray.Append(dic_angle.Keys.ElementAt <Curve>(a)); } } return(curvearray); }
private List <XYZ> getAllPointOfFace(Face myFace) { List <XYZ> myListPointOnFace = new List <XYZ>(); EdgeArrayArray myEdgeArAr = myFace.EdgeLoops; foreach (EdgeArray myEdgeAr in myEdgeArAr) { foreach (Edge myEdge in myEdgeAr) { Curve myCurve = myEdge.AsCurve(); XYZ eP1 = new XYZ(Math.Round(myCurve.GetEndPoint(0).X, 6), Math.Round(myCurve.GetEndPoint(0).Y, 6), Math.Round(myCurve.GetEndPoint(0).Z, 6)); XYZ eP2 = new XYZ(Math.Round(myCurve.GetEndPoint(1).X, 6), Math.Round(myCurve.GetEndPoint(1).Y, 6), Math.Round(myCurve.GetEndPoint(1).Z, 6)); myListPointOnFace.Add(eP1); myListPointOnFace.Add(eP2); } } return(myListPointOnFace); }
/// <summary> /// Get all points of the Slab /// </summary> /// <returns>points array stores all the points on slab</returns> public EdgeArray GetFloorEdges() { EdgeArray edges = new EdgeArray(); Options options = m_commandData.Application.Application.Create.NewGeometryOptions(); options.DetailLevel = DetailLevels.Medium; //make sure references to geometric objects are computed. options.ComputeReferences = true; Autodesk.Revit.DB.GeometryElement geoElem = m_floor.get_Geometry(options); GeometryObjectArray gObjects = geoElem.Objects; //get all the edges in the Geometry object foreach (GeometryObject geo in gObjects) { Solid solid = geo as Solid; if (solid != null) { FaceArray faces = solid.Faces; foreach (Face face in faces) { EdgeArrayArray edgeArrarr = face.EdgeLoops; foreach (EdgeArray edgeArr in edgeArrarr) { foreach (Edge edge in edgeArr) { edges.Append(edge); } } } } } return(edges); }
private EdgeArrayArray GetRoomBoundaries(Room room, Transform transformValue) { var edgeArrayArray = new EdgeArrayArray(); try { var geomElem = room.ClosedShell; if (geomElem != null) { geomElem = geomElem.GetTransformed(transformValue); foreach (var geomObj in geomElem) { var solid = geomObj as Solid; if (solid != null) { foreach (Face face in solid.Faces) { var uv = new UV(0, 0); var normal = face.ComputeNormal(uv); if (normal.IsAlmostEqualTo(new XYZ(0, 0, -1))) //bottom face { edgeArrayArray = face.EdgeLoops; } } } } } } catch (Exception ex) { MessageBox.Show("Cannot get room boundaries.\n" + ex.Message, "Get Room Boundaries", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(edgeArrayArray); }
public static List <Curve> GetFaceOuterBoundary(PlanarFace face) { EdgeArrayArray eaa = face.EdgeLoops; List <Curve> curves = new List <Curve>(); double mainArrayLength = 0; foreach (EdgeArray ea in eaa) { List <Curve> curCurves = new List <Curve>(); double curArrayLength = 0; foreach (Edge e in ea) { Curve line = e.AsCurve(); //XYZ[] pts = e.Tessellate().ToArray<XYZ>(); //int m = pts.Length; //XYZ p = pts[0]; //XYZ q = pts[m - 1]; //Line line = Line.CreateBound(p, q); curCurves.Add(line); curArrayLength += line.Length; } if (curArrayLength > mainArrayLength) { curves = curCurves; mainArrayLength = curArrayLength; } } return(curves); }
public static Plane Faceby3pointPlane(this Face face) { Plane plane = null; var planarFace = face as PlanarFace; if (planarFace == null) { return(plane); } List <XYZ> Points = new List <XYZ>(); EdgeArrayArray edgeArrayArray = planarFace.EdgeLoops; foreach (EdgeArray item in edgeArrayArray) { foreach (Edge item2 in item) { Curve curve = item2.AsCurve(); XYZ startpoint = curve.GetEndPoint(0); XYZ endpoint = curve.GetEndPoint(1); Points.Add(startpoint); Points.Add(endpoint); } } var newlist = Points.OrderBy(p => p.X).ThenBy(p => p.Y).ThenBy(p => p.Z).ToList(); Removeduplicatepoint(newlist); plane = Plane.CreateByThreePoints(newlist[0], newlist[1], newlist[3]); return(plane); }
public static void ShowCurve( string caption, EdgeArrayArray eaa, AnalyticalDirection dropCoordinate) { float width = 400; float height = 400; Bitmap bmp = new Bitmap( (int) width, (int) height ); //List<PointF[]> pointcurve = Make2DCurvesFromXYZ3DDataJustDroppingZ( curves ); List<PointF[]> pointLoops = GetPointLoops( eaa, dropCoordinate ); float origox = 0; float origoy = 0; float scalex = 1; float scaley = 1; float translatex = 0; float translatey = 0; SizeF fwantedsize = new SizeF( width, height ); FinnMinMaxSkaleringOrigo( pointLoops, fwantedsize, ref origox, ref origoy, ref scalex, ref scaley, ref translatex, ref translatey, out width, out height, false ); Graphics gr = Graphics.FromImage( bmp ); DrawCurvesOnGraphics( gr, bmp.Size, pointLoops, true, translatex, translatey, scalex, scaley, System.Drawing.Color.Black, 1 ); PictureBox pb = new PictureBox(); pb.Image = bmp; pb.Size = bmp.Size; System.Windows.Forms.Form form = new System.Windows.Forms.Form(); form.Size = new Size( bmp.Width + 10, bmp.Height + 10 ); form.Text = caption; pb.Parent = form; pb.Location = new System.Drawing.Point( 0, 0 ); form.Show(); }
public static EdgeArray OuterLoop(Face F) { EdgeArray eaMin = null; EdgeArrayArray loops = F.EdgeLoops; double uMin = double.MaxValue; foreach (EdgeArray a in loops) { double uMin2 = double.MaxValue; foreach (Edge e in a) { double min = MinU(e.AsCurve(), F); if (min < uMin2) { uMin2 = min; } } if (uMin2 < uMin) { uMin = uMin2; eaMin = a; } } return(eaMin); }
/// <summary> /// Get edges of element's profile /// </summary> /// <param name="elem">Selected element</param> public List <List <Edge> > GetFaces(Autodesk.Revit.DB.Element elem) { List <List <Edge> > faceEdges = new List <List <Edge> >(); Options options = m_appCreator.NewGeometryOptions(); options.DetailLevel = DetailLevels.Medium; options.ComputeReferences = true; Autodesk.Revit.DB.GeometryElement geoElem = elem.get_Geometry(options); GeometryObjectArray gObjects = geoElem.Objects; foreach (GeometryObject geo in gObjects) { Solid solid = geo as Solid; if (solid != null) { EdgeArray edges = solid.Edges; FaceArray faces = solid.Faces; foreach (Face face in faces) { EdgeArrayArray edgeArrarr = face.EdgeLoops; foreach (EdgeArray edgeArr in edgeArrarr) { List <Edge> edgesList = new List <Edge>(); foreach (Edge edge in edgeArr) { edgesList.Add(edge); } faceEdges.Add(edgesList); } } } } return(faceEdges); }
public void Createline(Document doc, FamilyInstance familyInstance, XYZ point) { var dic = GetTypeFace(familyInstance); using (Transaction t = new Transaction(doc, "Create detail line")) { t.Start(); var list = dic.Keys.ToList(); foreach (var item in list) { foreach (var i in dic[item]) { EdgeArrayArray edgeArrayArray = i.EdgeLoops; foreach (EdgeArray j in edgeArrayArray) { foreach (Edge k in j) { try { Curve curve = k.AsCurve(); View view = doc.ActiveView; var detailCurve = doc.Create.NewDetailCurve(view, curve); ElementTransformUtils.MoveElement(doc, detailCurve.Id, point); } catch { } } } } } t.Commit(); } }
/// <summary> 转换曲线集合的格式,并进行空间变换 </summary> public static void Convert(EdgeArrayArray sourceCurves, Transform transf, out CurveArrArray targetCurves) { List <List <Curve> > llc; Convert(sourceCurves, transf, out llc); // Convert(llc, out targetCurves); }
/// <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); }
public static void Convert(EdgeArrayArray sourceCurves, out List <Curve> targetCurves) { targetCurves = new List <Curve>(); foreach (EdgeArray cl in sourceCurves) { foreach (Edge c in cl) { targetCurves.Add(c.AsCurve()); } } }
private static CurveLoop GetOuterFaceBoundary(Face face, XYZ baseLoopOffset, bool polygonalOnly, out FaceBoundaryType faceBoundaryType) { faceBoundaryType = FaceBoundaryType.Polygonal; EdgeArrayArray faceBoundaries = face.EdgeLoops; foreach (EdgeArray faceOuterBoundary in faceBoundaries) { return(GetFaceBoundary(face, faceOuterBoundary, baseLoopOffset, polygonalOnly, out faceBoundaryType)); } return(null); }
/// <summary> /// Retrieve the boundary loops of the given slab /// top face, which is assumed to be horizontal. /// </summary> Polygons GetBoundaryLoops(CeilingAndFloor slab) { int n; Polygons polys = null; Document doc = slab.Document; Autodesk.Revit.ApplicationServices.Application app = doc.Application; Options opt = app.Create.NewGeometryOptions(); GeometryElement geo = slab.get_Geometry(opt); foreach (GeometryObject obj in geo) { Solid solid = obj as Solid; if (null != solid) { foreach (Face face in solid.Faces) { PlanarFace pf = face as PlanarFace; if (null != pf && pf.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ)) { EdgeArrayArray loops = pf.EdgeLoops; n = loops.Size; polys = new Polygons(n); foreach (EdgeArray loop in loops) { n = loop.Size; Polygon poly = new Polygon(n); foreach (Edge edge in loop) { IList <XYZ> pts = edge.Tessellate(); n = pts.Count; foreach (XYZ p in pts) { poly.Add(GetIntPoint(p)); } } polys.Add(poly); } } } } } return(polys); }
/// <summary> 转换曲线集合的格式,并进行空间变换 </summary> public static void Convert(EdgeArrayArray sourceCurves, Transform transf, out List <List <Curve> > targetCurves) { targetCurves = new List <List <Curve> >(); foreach (EdgeArray cl in sourceCurves) { var curveloop = new List <Curve>(); foreach (Edge c in cl) { curveloop.Add(c.AsCurve().CreateTransformed(transf)); } targetCurves.Add(curveloop); } }
/// <summary> /// Gets the outer and inner boundaries of a Face as CurveLoops. /// </summary> /// <param name="face">The face.</param> /// <param name="baseLoopOffset">The amount to translate the origin of the face plane. This is used if the start of the extrusion /// is offset from the base face. The argument is null otherwise.</param> /// <param name="faceBoundaryTypes">Returns whether the boundaries consist of lines only, lines and arcs, or complex curves.</param> /// <returns>1 outer and 0 or more inner curve loops corresponding to the face boundaries.</returns> public static IList <CurveLoop> GetFaceBoundaries(Face face, XYZ baseLoopOffset, out IList <FaceBoundaryType> faceBoundaryTypes) { faceBoundaryTypes = new List <FaceBoundaryType>(); EdgeArrayArray faceBoundaries = face.EdgeLoops; IList <CurveLoop> extrusionBoundaryLoops = new List <CurveLoop>(); foreach (EdgeArray faceBoundary in faceBoundaries) { FaceBoundaryType currFaceBoundaryType; CurveLoop currLoop = GetFaceBoundary(face, faceBoundary, baseLoopOffset, false, out currFaceBoundaryType); faceBoundaryTypes.Add(currFaceBoundaryType); extrusionBoundaryLoops.Add(currLoop); } return(extrusionBoundaryLoops); }
public static void ExportFace(Face face, string header) { CheckFolder(); List <Curve> wallCurves = new List <Curve>(); EdgeArrayArray edgeArrayArray = face.EdgeLoops; foreach (EdgeArray edgeArray in edgeArrayArray) { foreach (Edge edge in edgeArray) { wallCurves.Add(edge.AsCurve()); } } ExportCurves(wallCurves, header); }
public static void ExportFaces(List <Face> faces, string header) { List <Curve> wallCurves = new List <Curve>(); foreach (Face face in faces) { EdgeArrayArray edgeArrayArray = face.EdgeLoops; foreach (EdgeArray edgeArray in edgeArrayArray) { foreach (Edge edge in edgeArray) { wallCurves.Add(edge.AsCurve()); } } } ExportCurves(wallCurves, header); }
/***************************************************/ public static List <oM.Geometry.PolyCurve> FromRevit(this EdgeArrayArray edgeArrArray) { if (edgeArrArray == null) { return(null); } List <oM.Geometry.PolyCurve> result = new List <oM.Geometry.PolyCurve>(); foreach (EdgeArray edgeArray in edgeArrArray) { result.Add(new oM.Geometry.PolyCurve { Curves = edgeArray.FromRevit() }); } return(result); }
public static void ExportFaces(List <PlanarFace> planarFaces, string header) { CheckFolder(); List <Curve> wallCurves = new List <Curve>(); foreach (PlanarFace planarFace in planarFaces) { EdgeArrayArray edgeArrayArray = planarFace.EdgeLoops; foreach (EdgeArray edgeArray in edgeArrayArray) { foreach (Edge edge in edgeArray) { wallCurves.Add(edge.AsCurve()); } } } ExportCurves(wallCurves, header); }
double GetLength(IList <Solid> solids) { Solid maxVolumeSolid = solids.OrderByDescending(s => s.Volume).ElementAt(0); double maxLength = 0; FaceArray faceArray = maxVolumeSolid.Faces; FaceArrayIterator itr = faceArray.ForwardIterator(); while (itr.MoveNext()) { Face curFace = itr.Current as Face; if (curFace is CylindricalFace) { EdgeArrayArray edgeArrArr = ((CylindricalFace)curFace).EdgeLoops; foreach (EdgeArray edgeArr in edgeArrArr) { foreach (Edge edge in edgeArr) { if (edge.ApproximateLength > maxLength) { maxLength = edge.ApproximateLength; } } } return(maxLength); } else { EdgeArrayArray edgeArrArr = curFace.EdgeLoops; foreach (EdgeArray edgeArr in edgeArrArr) { foreach (Edge edge in edgeArr) { if (edge.ApproximateLength > maxLength) { maxLength = edge.ApproximateLength; } } } } } return(maxLength); }
bool GetBoundary(List <XYZ> ploygons, Solid solid) { PlanarFace heightest = null; FaceArray faceArrays = solid.Faces; heightest = faceArrays.get_Item(0) as PlanarFace; foreach (Face face in faceArrays) { //比较表面原点的Z轴确定最高点 PlanarFace pf = face as PlanarFace; if (null != pf && IsHorizontal(pf)) { if (null == heightest && pf.Origin.Z > heightest.Origin.Z) { heightest = pf; } } } if (null != heightest) { EdgeArrayArray loops = heightest.EdgeLoops; foreach (EdgeArray loop in loops) { foreach (Edge edge in loop) { IList <XYZ> points = edge.Tessellate(); foreach (var point in points) { bool isEqual = false; foreach (var item in ploygons) //去除相同的顶点 { isEqual = IsEqualXYZ(item, point); } if (!isEqual) { ploygons.Add(ResetPoint(point)); } } } } } return(null != heightest); }
/// <summary> /// Return the vertices from the first /// and only face edge loop /// </summary> static List <XYZ> GetFirstEdgeLoopVertices( PlanarFace f) { EdgeArrayArray loops = f.EdgeLoops; int n = loops.Size; if (1 < n) { App.Log(string.Format("top face has {0} " + "loops; we only support one", n)); //throw new ArgumentException( string.Format( // "top face has {0} loops; we only support one", // n ) ); } return(GetEdgeLoopVertices(loops.get_Item(0))); }
private double getElevetionOfFace(Face myFAce) { //get array EdgeArray EdgeArrayArray myEdgeArAr = myFAce.EdgeLoops; XYZ testPoint = new XYZ(); foreach (EdgeArray edgeAr in myEdgeArAr) { foreach (Edge myEdge in edgeAr) { // Get one test point testPoint = myEdge.Evaluate(0.5); break; } break; } return(testPoint.Z); }
/// <summary> /// Return a list of points representing /// the bottom face of the given Revit element. /// </summary> public List <XYZ> GetBottomFacePoints(Element e) { List <XYZ> resultingPts = new List <XYZ>(); FaceExtractor faceExtractor = new FaceExtractor(e); FaceArray faces = faceExtractor.Faces; if (faces.Size == 0) { return(resultingPts); } foreach (Face face in faces) { PlanarFace pf = face as PlanarFace; if (pf == null) { continue; } if (pf.Normal.IsAlmostEqualTo(-XYZ.BasisZ)) { EdgeArrayArray edgeLoops = face.EdgeLoops; foreach (EdgeArray edgeArray in edgeLoops) { foreach (Edge edge in edgeArray) { List <XYZ> points = edge.Tessellate() as List <XYZ>; resultingPts.AddRange(points); } } } } return(resultingPts); }
public static EdgeArray PlanarFaceOuterLoop(Face F) { PlanarFace face = F as PlanarFace; if (face == null) { return(null); } Transform T = Transform.Identity; T.BasisZ = face.FaceNormal; T.BasisX = face.XVector; T.BasisY = face.YVector; T.Origin = face.Origin; Transform Tinv = T.Inverse; EdgeArray eaMin = null; EdgeArrayArray loops = F.EdgeLoops; double uMin = double.MaxValue; foreach (EdgeArray a in loops) { double uMin2 = double.MaxValue; foreach (Edge e in a) { double min = MinX(e.AsCurve(), Tinv); if (min < uMin2) { uMin2 = min; } } if (uMin2 < uMin) { uMin = uMin2; eaMin = a; } } return(eaMin); }
/// <summary> /// Get edges of element's profile /// </summary> /// <param name="elem">selected element</param> /// <returns>all the faces in the selected Element</returns> public virtual List <List <Edge> > GetFaces(Autodesk.Revit.DB.Element elem) { List <List <Edge> > faceEdges = new List <List <Edge> >(); Options options = m_appCreator.NewGeometryOptions(); options.DetailLevel = ViewDetailLevel.Medium; //make sure references to geometric objects are computed. options.ComputeReferences = true; Autodesk.Revit.DB.GeometryElement geoElem = elem.get_Geometry(options); //GeometryObjectArray gObjects = geoElem.Objects; IEnumerator <GeometryObject> Objects = geoElem.GetEnumerator(); //get all the edges in the Geometry object //foreach (GeometryObject geo in gObjects) while (Objects.MoveNext()) { GeometryObject geo = Objects.Current; Solid solid = geo as Solid; if (solid != null) { FaceArray faces = solid.Faces; foreach (Face face in faces) { EdgeArrayArray edgeArrarr = face.EdgeLoops; foreach (EdgeArray edgeArr in edgeArrarr) { List <Edge> edgesList = new List <Edge>(); foreach (Edge edge in edgeArr) { edgesList.Add(edge); } faceEdges.Add(edgesList); } } } } return(faceEdges); }
// Function to find the centroid of a face private XYZ GetFaceCentroid(Face face) { List <double> xValues = new List <double>(); List <double> yValues = new List <double>(); List <double> zValues = new List <double>(); EdgeArrayArray frameEdgeLoop = face.EdgeLoops; foreach (EdgeArray edgeArray in frameEdgeLoop) { foreach (Edge edge in edgeArray) { double edgeP1X = edge.AsCurve().GetEndPoint(0).X; double edgeP2X = edge.AsCurve().GetEndPoint(1).X; double edgeMidX = (edgeP1X + edgeP2X) / 2; double edgeP1Y = edge.AsCurve().GetEndPoint(0).Y; double edgeP2Y = edge.AsCurve().GetEndPoint(1).Y; double edgeMidY = (edgeP1Y + edgeP2Y) / 2; double edgeP1Z = edge.AsCurve().GetEndPoint(0).Z; double edgeP2Z = edge.AsCurve().GetEndPoint(1).Z; double edgeMidZ = (edgeP1Z + edgeP2Z) / 2; xValues.Add(edgeMidX); yValues.Add(edgeMidY); zValues.Add(edgeMidZ); } } double xCen = xValues.Sum() / xValues.Count; double yCen = yValues.Sum() / yValues.Count; double zCen = zValues.Sum() / zValues.Count; XYZ faceCentroid = new XYZ(xCen, yCen, zCen); return(faceCentroid); }
/// <summary> /// 拿到一条线投影到一个面上面 /// </summary> /// <param name="line"></param> /// <param name="face_refer"></param> /// <returns></returns> public Curve FindFacecurve(Curve line, PlanarFace face) { TaskDialog.Show("ss", "已经在函数里面了"); EdgeArrayArray edgeArrays = face.EdgeLoops; List <XYZ> facepoints = new List <XYZ>(); foreach (EdgeArray edges in edgeArrays) { foreach (Edge edge in edges) { // Get one test point facepoints.Add(edge.Evaluate(0)); } } XYZ point_start = Project(facepoints, line.GetEndPoint(0)); XYZ point_end = Project(facepoints, line.GetEndPoint(1)); Curve curve = Line.CreateBound(point_start, point_end); return(curve); }
static List<PointF[]> GetPointLoops( EdgeArrayArray eaa, AnalyticalDirection dropCoordinate) { int n = eaa.Size; List<PointF[]> loops = new List<PointF[]>( n ); foreach( EdgeArray ea in eaa ) { PointF[] loop = new PointF[ea.Size + 1]; int i = 0; XYZ p0 = null; foreach( Edge e in ea ) { XYZ p = e.AsCurve().GetEndPoint( 0 ); loop[i] = GetPointF( p, dropCoordinate ); if( null == p0 ) { p0 = p; } ++i; } loop[i] = GetPointF( p0, dropCoordinate ); loops.Add( loop ); } return loops; }
/// <summary> /// Convert an EdgeArrayArray to a CurveArray, /// possibly including multiple loops. /// All non-linear segments are approximated by /// the edge curve tesselation. /// </summary> CurveArray Convert( EdgeArrayArray eaa ) { CurveArray ca = new CurveArray(); List<XYZ> pts = new List<XYZ>(); XYZ q; string s; int iLoop = 0; foreach( EdgeArray ea in eaa ) { q = null; s = string.Empty; pts.Clear(); foreach( Edge e in ea ) { IList<XYZ> a = e.Tessellate(); bool first = true; //XYZ p0 = null; foreach( XYZ p in a ) { if( first ) { if( null == q ) { s += Util.PointString( p ); pts.Add( p ); } else { Debug.Assert( p.IsAlmostEqualTo( q ), "expected connected sequential edges" ); } first = false; //p0 = p; q = p; } else { s += " --> " + Util.PointString( p ); //ca.Append( Line.get_Bound( q, p ) ); pts.Add( p ); q = p; } } //ca.Append( Line.get_Bound( q, p0 ) ); } Debug.Print( "{0}: {1}", iLoop++, s ); // test case: break after first edge loop, // which we assume to be the outer: //break; { // try reversing all the inner loops: if( 1 < iLoop ) { pts.Reverse(); } bool first = true; foreach( XYZ p in pts ) { if( first ) { first = false; } else { ca.Append( Line.get_Bound( q, p ) ); } q = p; } } } return ca; }