private void Stream(ArrayList data, Edge edge) { data.Add(new Snoop.Data.ClassSeparator(typeof(Edge))); // Curve Type { string curveType = "None"; if (edge.AsCurve() != null) { Curve crv = edge.AsCurve(); if (crv is Arc) curveType = "Arc"; else if (crv is CylindricalHelix) curveType = "CylindricalHelix"; else if (crv is Ellipse) curveType = "Ellipse"; else if (crv is HermiteSpline) curveType = "HermiteSpline"; else if (crv is Line) curveType = "Line"; else if (crv is NurbSpline) curveType = "NurbSpline"; } data.Add(new Snoop.Data.String("Curve Type", curveType)); } try { data.Add(new Snoop.Data.Object("Curve", edge.AsCurve())); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Curve", ex)); } try { data.Add(new Snoop.Data.Object("Start point reference", edge.GetEndPointReference(0))); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Start point reference", ex)); } try { data.Add(new Snoop.Data.Object("End point reference", edge.GetEndPointReference(1))); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("End point reference", ex)); } data.Add(new Snoop.Data.Object("Reference", edge.Reference)); data.Add(new Snoop.Data.Double("Approximate length", edge.ApproximateLength)); data.Add(new Snoop.Data.Object("Face [0]", edge.GetFace(0))); data.Add(new Snoop.Data.Object("Face [1]", edge.GetFace(1))); data.Add(new Snoop.Data.CategorySeparator("Tesselated Points")); System.Collections.Generic.IList<XYZ> pts = edge.Tessellate(); int i = 0; foreach (XYZ pt in pts) { data.Add(new Snoop.Data.Xyz(string.Format("PT [{0:d}]", i++), pt)); } // TBD: not sure how to use these yet... // TesselateOnFace ?? }
/// <summary> /// Determines whether a edge is vertical. /// </summary> /// <param name="edge">The edge to be determined.</param> /// <returns>Return true if this edge is vertical, or else return false.</returns> public static bool IsVerticalEdge(Edge edge) { List<XYZ> polyline = edge.Tessellate() as List<XYZ>; Autodesk.Revit.DB.XYZ verticalVct = new Autodesk.Revit.DB.XYZ (0, 0, 1); Autodesk.Revit.DB.XYZ pointBuffer = polyline[0]; for (int i = 1; i < polyline.Count; i = i + 1) { Autodesk.Revit.DB.XYZ temp = polyline[i]; Autodesk.Revit.DB.XYZ vector = GetVector(pointBuffer, temp); if (Equal(vector, verticalVct)) { return true; } else { continue; } } return false; }
/// <summary> /// Constructor takes Edge as parameter. /// </summary> /// <param name="edge">Edge</param> public EdgeBinding(Edge edge) { m_points = edge.Tessellate(); m_pen = new Pen(System.Drawing.Color.White); Reset(); }
public virtual void Stream(Edge edge) { IList<XYZ> ptArray = edge.Tessellate(); int len = ptArray.Count; for (int i=0; i < (len - 1); i++) { Stream(ptArray[i], ptArray[i + 1]); } }
/// <summary> /// check whether 2 edges are parallel /// </summary> /// <param name="edgeA"> /// the edge to be checked /// </param> /// <param name="edgeB"> /// the edge to be checked /// </param> /// <returns> /// if they're parallel, return true; otherwise false /// </returns> private bool IsLinesParallel(Edge edgeA, Edge edgeB) { List<XYZ> pointsA = edgeA.Tessellate() as List<XYZ>; List<XYZ> pointsB = edgeB.Tessellate() as List<XYZ>; Autodesk.Revit.DB.XYZ vectorA = pointsA[1] - pointsA[0]; Autodesk.Revit.DB.XYZ vectorB = pointsB[1] - pointsB[0]; Utility.Vector4 vec4A = new Utility.Vector4(vectorA); Utility.Vector4 vec4B = new Utility.Vector4(vectorB); return IsLinesParallel(vec4A, vec4B); }
/// <summary> /// compute the cross product of 2 edges /// </summary> /// <param name="edgeA"> /// the edge for the cross product /// </param> /// <param name="edgeB"> /// the edge for the cross product /// </param> /// <returns> /// the cross product of 2 edges /// </returns> private Utility.Vector4 ComputeCrossProduct(Edge edgeA, Edge edgeB) { List<XYZ> pointsA = edgeA.Tessellate() as List<XYZ>; List<XYZ> pointsB = edgeB.Tessellate() as List<XYZ>; Autodesk.Revit.DB.XYZ vectorA = pointsA[1] - pointsA[0]; Autodesk.Revit.DB.XYZ vectorB = pointsB[1] - pointsB[0]; Utility.Vector4 vec4A = new Utility.Vector4(vectorA); Utility.Vector4 vec4B = new Utility.Vector4(vectorB); return Utility.Vector4.CrossProduct(vec4A, vec4B); }