public static Panel Transform(this Panel panel, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } Panel result = panel.ShallowClone(); result.ExternalEdges = result.ExternalEdges.Select(x => x.Transform(transform, tolerance)).ToList(); result.Openings = result.Openings.Select(x => x.Transform(transform, tolerance)).ToList(); Basis orientation = panel.LocalOrientation()?.Transform(transform); if (orientation != null) { result.OrientationAngle = orientation.Z.OrientationAngleAreaElement(orientation.X); } else { BH.Engine.Reflection.Compute.RecordWarning("Local orientation of the panel could not be transformed. Please note that the orientation of the resultant panel may be incorrect."); } return(result); }
/***************************************************/ private static IElement0D Transform(this IElement0D element0D, TransformMatrix transform, double tolerance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return null; } return element0D.ISetGeometry(Geometry.Modify.Transform(element0D.IGeometry(), transform)); }
/***************************************************/ /**** Public Methods - Solid ****/ /***************************************************/ public static BoundaryRepresentation Transform(this BoundaryRepresentation solid, TransformMatrix transform) { double volume = solid.Volume; if (transform.IsRigidTransformation()) { Reflection.Compute.RecordWarning("Transformation is not rigid. Therefore stored BoundaryRepresentation Volume will be invalidated and reset to NaN (not a number)"); volume = double.NaN; } return(new BoundaryRepresentation(solid.Surfaces.Select(x => x.ITransform(transform)), volume)); }
public static oM.Physical.Elements.ISurface Transform(this oM.Physical.Elements.ISurface panel, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } oM.Physical.Elements.ISurface result = panel.ShallowClone(); result.Location = result.Location?.ITransform(transform); result.Openings = result.Openings?.Select(x => x?.Transform(transform, tolerance)).ToList(); return(result); }
public static IOpening Transform(this IOpening opening, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } IOpening result = opening.ShallowClone(); result.Location = result.Location?.ITransform(transform); return(result); }
public static Opening Transform(this Opening opening, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } Opening result = opening.ShallowClone(); result.Edges = result.Edges.Select(x => x.Transform(transform, tolerance)).ToList(); return(result); }
public static Edge Transform(this Edge edge, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } Edge result = edge.ShallowClone(); result.Curve = result.Curve.ITransform(transform); return(result); }
public static Vertex Transform(this Vertex vertex, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } Vertex result = vertex.DeepClone(); result.Point = result.Point.Transform(transform); return(result); }
public static CeilingTile Transform(this CeilingTile tile, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } CeilingTile result = tile.ShallowClone(); result.Perimeter = result.Perimeter.ITransform(transform); return(result); }
public static RigidLink Transform(this RigidLink link, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } RigidLink result = link.ShallowClone(); result.PrimaryNode = result.PrimaryNode.Transform(transform, tolerance); result.SecondaryNodes = result.SecondaryNodes.Select(x => x.Transform(transform, tolerance)).ToList(); return(result); }
public static RenderMesh Transform(this RenderMesh renderMesh, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } RenderMesh result = renderMesh.DeepClone(); result.Vertices = result.Vertices.Select(x => x.Transform(transform, tolerance)).ToList(); return(result); }
public static CameraDevice Transform(this CameraDevice camera, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } CameraDevice result = camera.ShallowClone(); result.EyePosition = result.EyePosition.Transform(transform); result.TargetPosition = result.TargetPosition.Transform(transform); return(result); }
public static Luminaire Transform(this Luminaire luminaire, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } Luminaire result = luminaire.ShallowClone(); result.Position = result.Position.Transform(transform); result.Direction = result.Direction.Transform(transform); return(result); }
public static IInstance Transform(this IInstance instance, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } IInstance result = instance.GetShallowClone() as IInstance; result.Location = result.Location?.ITransform(transform); result.Orientation = result.Orientation?.Transform(transform); return(result); }
public static CurtainWall Transform(this CurtainWall wall, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } CurtainWall result = wall.ShallowClone(); result.ExternalEdges = result.ExternalEdges.Select(x => x.Transform(transform, tolerance)).ToList(); result.Openings = result.Openings.Select(x => x.Transform(transform, tolerance)).ToList(); return(result); }
/***************************************************/ public static ICurve Transform(this Circle curve, TransformMatrix transform) { if (transform.IsRigidTransformation() || transform.IsUniformScaling()) { return new Circle { Centre = curve.Centre.Transform(transform), Radius = (curve.StartPoint() - curve.Centre).Transform(transform).Length(), Normal = curve.Normal.Transform(transform) } } ; else { Reflection.Compute.RecordNote("Transformation is not rigid or uniform. Converting into NurbsCurve. Change in shape may occur."); return(curve.ToNurbsCurve().Transform(transform)); } }
/***************************************************/ /**** Public Methods - Curves ****/ /***************************************************/ public static ICurve Transform(this Arc curve, TransformMatrix transform) { if (transform.IsRigidTransformation() || transform.IsUniformScaling()) { return new Arc { Radius = (curve.StartPoint() - curve.CoordinateSystem.Origin).Transform(transform).Length(), StartAngle = curve.StartAngle, EndAngle = curve.EndAngle, CoordinateSystem = curve.CoordinateSystem.Transform(transform) } } ; else { Reflection.Compute.RecordNote("Transformation is not rigid or uniform. Converting into NurbsCurve. Change in shape may occur."); return(curve.ToNurbsCurve().Transform(transform)); } }
/***************************************************/ public static ICurve Transform(this Ellipse curve, TransformMatrix transform) { if (transform.IsRigidTransformation() || transform.IsUniformScaling()) { return new Ellipse { Centre = curve.Centre.Transform(transform), Axis1 = curve.Axis1.Transform(transform), Axis2 = curve.Axis2.Transform(transform), Radius1 = (curve.Axis1.Normalise() * curve.Radius1).Transform(transform).Length(), Radius2 = (curve.Axis2.Normalise() * curve.Radius2).Transform(transform).Length(), } } ; else { Reflection.Compute.RecordNote("Transformation is not rigid or uniform. Converting into NurbsCurve. Change in shape may occur."); return(curve.ToNurbsCurve().Transform(transform)); } }
public static FEMesh Transform(this FEMesh mesh, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } FEMesh result = mesh.ShallowClone(); result.Nodes = result.Nodes.Select(x => x.Transform(transform, tolerance)).ToList(); List <Basis> orientationsBefore = mesh.LocalOrientations(); result.Faces = new List <FEMeshFace>(mesh.Faces); for (int i = 0; i < orientationsBefore.Count; i++) { result.Faces[i] = result.Faces[i].SetLocalOrientation(result, orientationsBefore[i].Transform(transform).X); } return(result); }
public static FrameEdge Transform(this FrameEdge edge, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } FrameEdge result = edge.ShallowClone(); result.Curve = result.Curve.ITransform(transform); if (edge.FrameEdgeProperty != null) { if (edge.Curve is Line) { Line lineBefore = (Line)edge.Curve; Line lineAfter = (Line)result.Curve; List <ConstantFramingProperty> newProperties = new List <ConstantFramingProperty>(); foreach (ConstantFramingProperty property in edge.FrameEdgeProperty.SectionProperties) { ConstantFramingProperty newProperty = property.ShallowClone(); Vector normalBefore = lineBefore.ElementNormal(property.OrientationAngle); Vector normalAfter = normalBefore.Transform(transform); newProperty.OrientationAngle = normalAfter.OrientationAngleLinear(lineAfter); newProperties.Add(newProperty); } edge.FrameEdgeProperty.SectionProperties = newProperties; } else if (!edge.Curve.IIsPlanar(tolerance)) { BH.Engine.Reflection.Compute.RecordWarning($"The element's location is a nonlinear, nonplanar curve. Correctness of orientation angle after transform could not be ensured in 100%. BHoM_Guid: {edge.BHoM_Guid}"); } } return(result); }
/***************************************************/ /**** Private Methods - IElements ****/ /***************************************************/ private static IElement2D Transform(this IElement2D element2D, TransformMatrix transform, double tolerance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return null; } List<IElement1D> newOutline = new List<IElement1D>(); foreach (IElement1D element1D in element2D.IOutlineElements1D()) { newOutline.Add(element1D.Transform(transform, tolerance)); } IElement2D result = element2D.ISetOutlineElements1D(newOutline); List<IElement2D> newInternalOutlines = new List<IElement2D>(); foreach (IElement2D internalElement2D in result.IInternalElements2D()) { newInternalOutlines.Add(internalElement2D.Transform(transform, tolerance)); } result = result.ISetInternalElements2D(newInternalOutlines); return result; }
public static Duct Transform(this Duct duct, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } Duct result = duct.ShallowClone(); result.StartPoint = result.StartPoint.Transform(transform); result.EndPoint = result.EndPoint.Transform(transform); Vector normalBefore = new Line { Start = duct.StartPoint, End = duct.EndPoint }.ElementNormal(duct.OrientationAngle); Vector normalAfter = normalBefore.Transform(transform); result.OrientationAngle = normalAfter.OrientationAngleLinear(new Line { Start = result.StartPoint, End = result.EndPoint }); return(result); }
public static Bar Transform(this Bar bar, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } Bar result = bar.ShallowClone(); result.StartNode = result.StartNode.Transform(transform, tolerance); result.EndNode = result.EndNode.Transform(transform, tolerance); Vector normalBefore = new Line { Start = bar.StartNode.Position, End = bar.EndNode.Position }.ElementNormal(bar.OrientationAngle); Vector normalAfter = normalBefore.Transform(transform); result.OrientationAngle = normalAfter.OrientationAngleLinear(new Line { Start = result.StartNode.Position, End = result.EndNode.Position }); return(result); }
public static IFramingElement Transform(this IFramingElement framingElement, TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsRigidTransformation(tolerance)) { BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported."); return(null); } IFramingElement result = framingElement.ShallowClone(); result.Location = result.Location.ITransform(transform); ConstantFramingProperty property = result.Property as ConstantFramingProperty; if (property == null) { BH.Engine.Reflection.Compute.RecordWarning($"Orientation angle of the IFramingElement has not been transformed because its property is not ConstantFramingProperty. BHoM_Guid: {framingElement.BHoM_Guid}"); } else { if (framingElement.Location is Line) { ConstantFramingProperty newProperty = property.ShallowClone(); Vector normalBefore = ((Line)framingElement.Location).ElementNormal(property.OrientationAngle); Vector normalAfter = normalBefore.Transform(transform); newProperty.OrientationAngle = normalAfter.OrientationAngleLinear((Line)result.Location); result.Property = newProperty; } else if (!framingElement.Location.IIsPlanar(tolerance)) { BH.Engine.Reflection.Compute.RecordWarning($"The element's location is a nonlinear, nonplanar curve. Correctness of orientation angle after transform could not be ensured in 100%. BHoM_Guid: {framingElement.BHoM_Guid}"); } } return(result); }