public TransForm ( Vector4 point ) : Vector4 | ||
point | Vector4 | Point needed to be transformed |
Résultat | Vector4 |
/// <summary> /// Draw profile of wall or floor in 2D /// </summary> /// <param name="graphics">form graphic</param> /// <param name="pen">pen use to draw line in pictureBox</param> /// <param name="matrix4">matrix used to transform points between 3d and 2d.</param>> public void Draw2D(Graphics graphics, Pen pen, Matrix4 matrix4) { foreach (Edge edge in m_face) { List <XYZ> points = edge.Tessellate() as List <XYZ>; for (int i = 0; i < points.Count - 1; i++) { Autodesk.Revit.DB.XYZ point1 = points[i]; Autodesk.Revit.DB.XYZ point2 = points[i + 1]; Vector4 v1 = new Vector4(point1); Vector4 v2 = new Vector4(point2); v1 = matrix4.TransForm(v1); v2 = matrix4.TransForm(v2); graphics.DrawLine(pen, new Point((int)v1.X, (int)v1.Y), new Point((int)v2.X, (int)v2.Y)); } } }
/// <summary> /// Get Face Bounds /// </summary> public PointF[] GetFaceBounds() { Matrix4 matrix = To2DMatrix(); Matrix4 inverseMatrix = matrix.Inverse(); float minX = 0, maxX = 0, minY = 0, maxY = 0; bool bFirstPoint = true; foreach (Edge edge in m_face) { List <XYZ> points = edge.Tessellate() as List <XYZ>; foreach (Autodesk.Revit.DB.XYZ point in points) { Vector4 v = new Vector4(point); Vector4 v1 = inverseMatrix.TransForm(v); if (bFirstPoint) { minX = maxX = v1.X; minY = maxY = v1.Y; bFirstPoint = false; } else { if (v1.X < minX) { minX = v1.X; } else if (v1.X > maxX) { maxX = v1.X; } if (v1.Y < minY) { minY = v1.Y; } else if (v1.Y > maxY) { maxY = v1.Y; } } } } PointF[] resultPoints = new PointF[2] { new PointF(minX, minY), new PointF(maxX, maxY) }; return(resultPoints); }
/// <summary> /// Transform the point on Form to 3d world coordinate of Revit /// </summary> /// <param name="ps">contain the points to be transform</param> private List <Vector4> TransForm2DTo3D(Point[] ps) { List <Vector4> result = new List <Vector4>(); TransFormPoints(ps); Matrix4 transFormMatrix = Matrix4.Multiply( m_scaleMatrix.Inverse(), m_moveToCenterMatrix); transFormMatrix = Matrix4.Multiply(transFormMatrix, m_to2DMatrix); foreach (Point point in ps) { Vector4 v = new Vector4(point.X, point.Y, 0); v = transFormMatrix.TransForm(v); result.Add(v); } return(result); }
/// <summary> /// Draw profile of wall or floor in 2D /// </summary> /// <param name="graphics">form graphic</param> /// <param name="pen">pen use to draw line in pictureBox</param> /// <param name="matrix4">matrix used to transform points between 3d and 2d.</param>> public void Draw2D(Graphics graphics, Pen pen, Matrix4 matrix4) { foreach (Edge edge in m_face) { List<XYZ> points = edge.Tessellate() as List<XYZ>; for (int i = 0; i < points.Count - 1; i++) { Autodesk.Revit.DB.XYZ point1 = points[i]; Autodesk.Revit.DB.XYZ point2 = points[i + 1]; Vector4 v1 = new Vector4(point1); Vector4 v2 = new Vector4(point2); v1 = matrix4.TransForm(v1); v2 = matrix4.TransForm(v2); graphics.DrawLine(pen, new Point((int)v1.X, (int)v1.Y), new Point((int)v2.X, (int)v2.Y)); } } }