diff --git a/src/RhinoInside.Revit.External/DB/Extensions/Transform.cs b/src/RhinoInside.Revit.External/DB/Extensions/Transform.cs index 3755b0d01..923da3e2c 100644 --- a/src/RhinoInside.Revit.External/DB/Extensions/Transform.cs +++ b/src/RhinoInside.Revit.External/DB/Extensions/Transform.cs @@ -146,7 +146,7 @@ internal static UnitXYZ GetPrincipalComponent(this Transform covarianceMatrix, d } /// - /// Applies the transformation to the bouding box and returns the result. + /// Applies the transformation to a bouding box and returns the result. /// /// The transform to apply. /// The box to transform. @@ -162,7 +162,7 @@ public static BoundingBoxXYZ OfBoundingBoxXYZ(this Transform transform, Bounding } /// - /// Applies the transformation to the plane equation and returns the result. + /// Applies the transformation to a plane equation and returns the result. /// /// The transform to apply. /// The box to transform. @@ -178,5 +178,72 @@ internal static PlaneEquation OfPlaneEquation(this Transform transform, PlaneEqu transform.OfVector(equation.Normal).ToUnitXYZ() ); } + + /// + /// Applies the transformation to a point and returns the result. + /// + /// The transform to apply. + /// The point to transform. + /// The transformed point + /// + /// Transformation of a point is affected by the translational part of the transformation. + /// + public static Point OfPoint(this Transform transform, Point value) => Point.Create(transform.OfPoint(value.Coord), value.GraphicsStyleId); + + /// + /// Applies the transformation to a curve and returns the result. + /// + /// The transform to apply. + /// The curve to transform. + /// The transformed curve + /// + /// Transformation of a curve is affected by the translational part of the transformation. + /// + public static Curve OfCurve(this Transform transform, Curve value) => value.CreateTransformed(transform); + + /// + /// Applies the transformation to a mesh and returns the result. + /// + /// The transform to apply. + /// The mesh to transform. + /// The transformed mesh + /// + /// Transformation of a mesh is affected by the translational part of the transformation. + /// + public static Mesh OfMesh(this Transform transform, Mesh value) => value.get_Transformed(transform); + + /// + /// Applies the transformation to a solid and returns the result. + /// + /// The transform to apply. + /// The solid to transform. + /// The transformed solid + /// + /// Transformation of a solid is affected by the translational part of the transformation. + /// + public static Solid OfSolid(this Transform transform, Solid value) => SolidUtils.CreateTransformed(value, transform); + + /// + /// Applies the transformation to a geometry and returns the result. + /// + /// The transform to apply. + /// The geometry to transform. + /// The transformed geometry + /// + /// Transformation of a geometry is affected by the translational part of the transformation. + /// + public static GeometryObject OfGeometry(this Transform transform, GeometryObject value) + { + switch (value) + { + case Point point: return OfPoint(transform, point); + case Curve curve: return OfCurve(transform, curve); + case PolyLine pline: return pline.GetTransformed(transform); + case Mesh mesh: return OfMesh(transform, mesh); + case Solid solid: return OfSolid(transform, solid); + } + + throw new NotImplementedException($"{nameof(OfGeometry)} is not implemented for {value.GetType()}."); + } } }