From 2524177c4cac913013c910120a24d5d140adce5a Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 15 Apr 2021 17:26:29 +0100 Subject: [PATCH 01/12] Fix Architecture Engine compute #2462 --- Architecture_Engine/Compute/CeilingTiles.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Architecture_Engine/Compute/CeilingTiles.cs b/Architecture_Engine/Compute/CeilingTiles.cs index f0cc3eea0..7c22fa732 100644 --- a/Architecture_Engine/Compute/CeilingTiles.cs +++ b/Architecture_Engine/Compute/CeilingTiles.cs @@ -49,6 +49,12 @@ public static partial class Compute [Output("ceilingTiles", "Closed Ceiling Tile regions contained within the Ceiling.")] public static List CeilingTiles(Ceiling ceiling, List ceilingTileLines, double angleTolerance = BH.oM.Geometry.Tolerance.Angle, double distanceTolerance = BH.oM.Geometry.Tolerance.Distance, int decimalPlaces = 6) { + if(ceiling == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot compute the ceiling tiles for a null ceiling."); + return null; + } + List openingLines = ceiling.Surface.IInternalEdges().SelectMany(x => x.ISubParts()).Cast().ToList(); ceilingTileLines.AddRange(openingLines); From 43aeaa2cfecde24fe4f5276e24c3baf632e448aa Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 15 Apr 2021 17:29:25 +0100 Subject: [PATCH 02/12] Fix Modify folder of Architecture Engine #2462 --- Architecture_Engine/Modify/CleanRoom.cs | 6 ++++++ Architecture_Engine/Modify/SetGeometry.cs | 16 ++++++---------- .../Modify/SetOutlineElements1D.cs | 12 ++++++++++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Architecture_Engine/Modify/CleanRoom.cs b/Architecture_Engine/Modify/CleanRoom.cs index 950aaf7d4..851f2e874 100644 --- a/Architecture_Engine/Modify/CleanRoom.cs +++ b/Architecture_Engine/Modify/CleanRoom.cs @@ -42,6 +42,12 @@ public static partial class Modify [Output("cleanedRoom", "A room that has been cleaned")] public static Room CleanRoom(this Room room, double angleTolerance = Tolerance.Angle, double minimumSegmentLength = Tolerance.Distance) { + if(room == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot clean the geometry of a null room."); + return room; + } + Room clonedRoom = room.DeepClone(); clonedRoom.Perimeter = clonedRoom.Perimeter.ICollapseToPolyline(Tolerance.Angle).CleanPolyline(angleTolerance, minimumSegmentLength); return clonedRoom; diff --git a/Architecture_Engine/Modify/SetGeometry.cs b/Architecture_Engine/Modify/SetGeometry.cs index 383abbaa6..074e99ed3 100644 --- a/Architecture_Engine/Modify/SetGeometry.cs +++ b/Architecture_Engine/Modify/SetGeometry.cs @@ -34,16 +34,6 @@ public static partial class Modify /***************************************************/ /**** Public Methods ****/ /***************************************************/ - - [Deprecated("2.4", "BH.Engine.Architecture.Elements.Grid superseded by BH.oM.Geometry.SettingOut.Grid")] - public static Grid SetGeometry(this Grid grid, ICurve curve) - { - Grid clone = grid.ShallowClone() as Grid; - clone.Curve = curve.DeepClone(); - return clone; - } - - /***************************************************/ [Description("Assign new geometry to an Architecture Room. If either geometry is null then original geometry is used")] [Input("room", "An Architecture Room to set the geometry of")] @@ -52,6 +42,12 @@ public static Grid SetGeometry(this Grid grid, ICurve curve) [Output("room", "An Architecture Room with an updated geometry")] public static Room SetGeometry(this Room room, Point locationPoint = null, ICurve perimeterCurve = null) { + if(room == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot set the geometry of a null room."); + return room; + } + Room clone = room.DeepClone(); clone.Location = locationPoint == null ? room.Location.DeepClone() : locationPoint; clone.Perimeter = perimeterCurve == null ? room.Perimeter.DeepClone() : perimeterCurve; diff --git a/Architecture_Engine/Modify/SetOutlineElements1D.cs b/Architecture_Engine/Modify/SetOutlineElements1D.cs index a174263b2..bea16f477 100644 --- a/Architecture_Engine/Modify/SetOutlineElements1D.cs +++ b/Architecture_Engine/Modify/SetOutlineElements1D.cs @@ -44,6 +44,12 @@ public static partial class Modify [Output("room", "The updated Architecture Room")] public static Room SetOutlineElements1D(this Room room, List outlineElements1D) { + if(room == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot set the outline elements of a null room."); + return room; + } + Room r = room.ShallowClone() as Room; r.Perimeter = BH.Engine.Geometry.Compute.IJoin(outlineElements1D.Cast().ToList())[0]; return r; @@ -57,6 +63,12 @@ public static Room SetOutlineElements1D(this Room room, List outline [Output("ceiling", "The updated Architecture Ceiling")] public static Ceiling SetOutlineElements1D(this Ceiling ceiling, List outlineElements1D) { + if(ceiling == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot set the outline elements of a null ceiling."); + return ceiling; + } + ceiling.Surface = BH.Engine.Geometry.Create.PlanarSurface(BH.Engine.Geometry.Compute.IJoin(outlineElements1D.Cast().ToList())[0]); return ceiling; } From 12ece617de6c9a3929b71a008bb113191e3a4f4c Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 15 Apr 2021 17:32:50 +0100 Subject: [PATCH 03/12] Fix query nulls in Architecture Engine #2462 --- Architecture_Engine/Query/OutlineElements1D.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Architecture_Engine/Query/OutlineElements1D.cs b/Architecture_Engine/Query/OutlineElements1D.cs index af7cd0ff9..7fe71f1b4 100644 --- a/Architecture_Engine/Query/OutlineElements1D.cs +++ b/Architecture_Engine/Query/OutlineElements1D.cs @@ -47,6 +47,12 @@ public static partial class Query [Output("outlineElements", "A collection of outline 1D elements")] public static List OutlineElements1D(this Room room) { + if(room == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot query the outline 1D elements of a null room."); + return null; + } + return room.Perimeter.ISubParts().Cast().ToList(); } @@ -57,6 +63,12 @@ public static List OutlineElements1D(this Room room) [Output("outlineElements", "A collection of outline 1D elements")] public static List OutlineElements1D(this Ceiling ceiling) { + if(ceiling == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot query the outline 1D elements of a null ceiling."); + return null; + } + return ceiling.Surface.ISubParts().Cast().ToList(); } } From 2fb0b4d5c390db9ad7581b31e6d3a5ae107d8f0f Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 15 Apr 2021 21:56:40 +0100 Subject: [PATCH 04/12] Fix create methods for Architecture Engine #2462 --- .../Architecture_Engine.csproj | 2 + .../Create/Theatron/ActivityArea.cs | 12 ++- .../Create/Theatron/ProfileOrigin.cs | 12 ++- .../Create/Theatron/SeatingBlock.cs | 33 ++++--- .../Create/Theatron/TheatronFullProfile.cs | 42 +++++++- .../Create/Theatron/TheatronGeometry.cs | 44 ++++++++- .../Create/Theatron/TheatronPlan.cs | 22 ++++- .../Theatron/TheatronPlan/CircularPlan.cs | 6 ++ .../Theatron/TheatronPlan/EightArcPlan.cs | 6 ++ .../Theatron/TheatronPlan/NoCornersPlan.cs | 6 ++ .../Theatron/TheatronPlan/OrthogonalPlan.cs | 6 ++ .../Create/Theatron/TierProfile.cs | 55 +++-------- .../Modify/TransformProfile.cs | 99 +++++++++++++++++++ 13 files changed, 282 insertions(+), 63 deletions(-) create mode 100644 Architecture_Engine/Modify/TransformProfile.cs diff --git a/Architecture_Engine/Architecture_Engine.csproj b/Architecture_Engine/Architecture_Engine.csproj index 712caa71c..4cec30bcc 100644 --- a/Architecture_Engine/Architecture_Engine.csproj +++ b/Architecture_Engine/Architecture_Engine.csproj @@ -93,6 +93,7 @@ + @@ -123,6 +124,7 @@ + diff --git a/Architecture_Engine/Create/Theatron/ActivityArea.cs b/Architecture_Engine/Create/Theatron/ActivityArea.cs index c1cdd061c..cf9e8176a 100644 --- a/Architecture_Engine/Create/Theatron/ActivityArea.cs +++ b/Architecture_Engine/Create/Theatron/ActivityArea.cs @@ -51,6 +51,7 @@ public static ActivityArea ActivityArea(double scale = 1.0) } /***************************************************/ + [Description("Create an activityArea rectangle, focal point is at 0,0,0")] [Input("width", "Optional, width default is 60")] [Input("length", "Optional, length default is 90")] @@ -67,15 +68,24 @@ public static ActivityArea ActivityArea(double width = 60, double length = 90) } /***************************************************/ + [Description("Create an ActivityArea from any closed polyline and a focal point")] [Input("activityArea", "Closed polyline defining the activity area")] [Input("activityFocalPoint", "Point defining the centre of attention for the activity area")] public static ActivityArea ActivityArea(Polyline activityArea, Point activityFocalPoint) { + if(activityArea == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create an activty area from a null polyline."); + return null; + } + if (!activityArea.IsClosed()) { - throw new ArgumentException("activityArea must be closed"); ; + BH.Engine.Reflection.Compute.RecordError("activityArea must be closed"); + return null; } + return new ActivityArea { PlayingArea = activityArea, diff --git a/Architecture_Engine/Create/Theatron/ProfileOrigin.cs b/Architecture_Engine/Create/Theatron/ProfileOrigin.cs index 2c2d0a885..a0c769d9f 100644 --- a/Architecture_Engine/Create/Theatron/ProfileOrigin.cs +++ b/Architecture_Engine/Create/Theatron/ProfileOrigin.cs @@ -38,10 +38,18 @@ public static partial class Create [Description("Create a ProfileOrigin for a structural section, comprised of origin and section direction")] [Input("origin", "Origin point for the section")] [Input("direction", "Horizontal Vector defining the direction of the section")] - public static ProfileOrigin ProfileOrigin(Point origin,Vector direction) + public static ProfileOrigin ProfileOrigin(Point origin, Vector direction) { + if(direction == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a profile origin from a null direction."); + return null; + } + //enforce a horizontal vector - if (direction.Z != 0) direction.Z = 0; + if (direction.Z != 0) + direction.Z = 0; + return new ProfileOrigin { Origin = origin.ShallowClone(), diff --git a/Architecture_Engine/Create/Theatron/SeatingBlock.cs b/Architecture_Engine/Create/Theatron/SeatingBlock.cs index e7029ed97..5ce421c12 100644 --- a/Architecture_Engine/Create/Theatron/SeatingBlock.cs +++ b/Architecture_Engine/Create/Theatron/SeatingBlock.cs @@ -48,22 +48,27 @@ public static partial class Create [Input("aisleWidth", "Width of asile at vomitory")] public static SeatingBlock SeatingBlock(ProfileOrigin start, ProfileOrigin vom, ProfileOrigin end, SeatingBlockType t, double seatWidth, double aisleWidth) { + if(start == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a seating block with a null starting profile origin."); + return null; + } + + if(end == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a seating block with a null ending profile origin."); + return null; + } + return new SeatingBlock { Start = start, - Vomitory = vom, - End = end, - SeatWidth = seatWidth, - TypeOfSeatingBlock = t, - AisleWidth = aisleWidth, - - FrontRow = Geometry.Create.Line(start.Origin,end.Origin), - + FrontRow = Geometry.Create.Line(start.Origin, end.Origin), }; } @@ -77,19 +82,19 @@ private static void SetBlockProfiles(ref SeatingBlock block, TierProfile section Point source = origin.Origin; Vector scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.Start, block.Vomitory); double angle = Geometry.Query.Angle(origin.Direction, block.Start.Direction, Plane.XY); - var start = TransformProfile(sectionToMap, scaleVector, source, block.Start.Origin, angle); + var start = Modify.TransformProfile(sectionToMap, scaleVector, source, block.Start.Origin, angle); block.Sections.Add(start); //vomitory section no need for scalefactor scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.Vomitory, block.Vomitory); angle = Geometry.Query.Angle(origin.Direction, block.Vomitory.Direction, Plane.XY); - var vom = TransformProfile(sectionToMap, scaleVector, source, block.Vomitory.Origin, angle); + var vom = Modify.TransformProfile(sectionToMap, scaleVector, source, block.Vomitory.Origin, angle); block.Sections.Add(vom); //end section scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.End, block.Vomitory); angle = Geometry.Query.Angle(origin.Direction, block.End.Direction, Plane.XY); - var end = TransformProfile(sectionToMap, scaleVector, source, block.End.Origin, angle); + var end = Modify.TransformProfile(sectionToMap, scaleVector, source, block.End.Origin, angle); block.Sections.Add(end); } @@ -102,19 +107,19 @@ private static void SetTransitionProfiles(ref SeatingBlock block, TierProfile se Point source = origin.Origin; Vector scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.Start, prevVomitory); double angle = Geometry.Query.Angle(origin.Direction, block.Start.Direction, Plane.XY); - var start = TransformProfile(sectionToMap, scaleVector, source, block.Start.Origin, angle); + var start = Modify.TransformProfile(sectionToMap, scaleVector, source, block.Start.Origin, angle); block.Sections.Add(start); //end section scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.End, nextVomitory); angle = Geometry.Query.Angle(origin.Direction, block.End.Direction, Plane.XY); - var end = TransformProfile(sectionToMap, scaleVector, source, block.End.Origin, angle); + var end = Modify.TransformProfile(sectionToMap, scaleVector, source, block.End.Origin, angle); block.Sections.Add(end); } /***************************************************/ - private static void SetEyesBasic(ref SeatingBlock block) + private static void SetEyesBasic(ref SeatingBlock block) { block.Audience = new Audience(); int rows = block.Sections[0].EyePoints.Count; diff --git a/Architecture_Engine/Create/Theatron/TheatronFullProfile.cs b/Architecture_Engine/Create/Theatron/TheatronFullProfile.cs index d2698942c..eb05e1880 100644 --- a/Architecture_Engine/Create/Theatron/TheatronFullProfile.cs +++ b/Architecture_Engine/Create/Theatron/TheatronFullProfile.cs @@ -40,6 +40,12 @@ public static partial class Create [Input("parameters", "List of ProfileParameters")] public static TheatronFullProfile TheatronFullProfile(List parameters) { + if(parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron full profile from a null collection of profile parameters."); + return null; + } + //this assumes no relation with the plan geometry setting out is from the origin TheatronFullProfile fullProfile = new TheatronFullProfile(); double minDist = parameters[0].StartX - parameters[0].EyePositionParameters.EyePositionX; @@ -51,23 +57,55 @@ public static TheatronFullProfile TheatronFullProfile(List pa } /***************************************************/ + [Description("Create a full profile from one or more ProfileParameters and a TheatronPlan geometry. The worst case section will be found and used to define the profile geometry")] [Input("parameters", "List of ProfileParameters")] [Input("planGeometry", "A TheatronPlan")] public static TheatronFullProfile TheatronFullProfile(List parameters, TheatronPlan planGeometry) { - + if (parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron full profile from a null collection of profile parameters."); + return null; + } + + if(planGeometry == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron full profile from a null theatron plan."); + return null; + } + TheatronFullProfile fullProfile = new TheatronFullProfile(); GenerateMapProfiles(ref fullProfile, parameters.DeepClone(), planGeometry.MinDistToFocalCurve, planGeometry.SectionClosestToFocalCurve); return fullProfile; } + /***************************************************/ + [Description("Create a full profile from one or more ProfileParameters and a focal point and ProfileOrigin")] [Input("parameters", "List of ProfileParameters")] public static TheatronFullProfile TheatronFullProfile(List parameters, Point focalPoint, ProfileOrigin sectionOrigin) { + if (parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron full profile from a null collection of profile parameters."); + return null; + } + + if (focalPoint == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron full profile from a null focal point."); + return null; + } + + if (sectionOrigin == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron full profile from a null profile origin."); + return null; + } + //this assumes no relation with the plan geometry setting out is from the origin TheatronFullProfile fullProfile = new TheatronFullProfile(); Point lastpoint = new Point(); @@ -105,7 +143,7 @@ private static void GenerateMapProfiles(ref TheatronFullProfile fullProfile, Lis Point target = sectionOrigin.Origin; double angle = Math.Atan2(sectionOrigin.Direction.Y, sectionOrigin.Direction.X); Vector scaleVector = SetScaleVector(tierSection.SectionOrigin.Direction, tierSection.SectionOrigin, tierSection.SectionOrigin); - fullProfile.MappedProfiles.Add(TransformProfile(tierSection, scaleVector,source, target, angle)); + fullProfile.MappedProfiles.Add(Modify.TransformProfile(tierSection, scaleVector,source, target, angle)); lastpoint = tierSection.FloorPoints[tierSection.FloorPoints.Count - 1]; } diff --git a/Architecture_Engine/Create/Theatron/TheatronGeometry.cs b/Architecture_Engine/Create/Theatron/TheatronGeometry.cs index 818aa5614..de3e330dd 100644 --- a/Architecture_Engine/Create/Theatron/TheatronGeometry.cs +++ b/Architecture_Engine/Create/Theatron/TheatronGeometry.cs @@ -40,21 +40,58 @@ public static partial class Create [Input("profile", "The TheatronFullProfile used in defining the plan")] [Input("sParams", "The StadiaParameters")] [Input("pParams", "List of the ProfileParameters")] - public static TheatronGeometry TheatronGeometry(TheatronPlan planFull, TheatronFullProfile profile,StadiaParameters sParams, List pParams) + public static TheatronGeometry TheatronGeometry(TheatronPlan planFull, TheatronFullProfile profile, StadiaParameters sParams, List pParams) { - var theatron = CreateGeometry(planFull, profile, pParams,sParams.TypeOfBowl); + if(planFull == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry will a null theatron plan."); + return null; + } + + if (profile == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry will a null profile."); + return null; + } + + if (sParams == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry from a null set of stadia parameters."); + return null; + } + + var theatron = CreateGeometry(planFull, profile, pParams, sParams.TypeOfBowl); CopyGeneratorBlocks(ref theatron, planFull, sParams.TypeOfBowl); return theatron; } /***************************************************/ + [Description("Create a partial TheatronGeometry based on structural locations and a TheatronFullProfile, Cvalue is not used to define the TheatronFullProfile")] [Input("structuralOrigins", "List of ProfileOrigins to orientate of the structural sections")] [Input("profile", "The TheatronFullProfile")] [Input("pParams", "List of the ProfileParameters")] public static TheatronGeometry TheatronGeometry(List structuralOrigins, TheatronFullProfile profile, List pParams) { + if(structuralOrigins == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry from a null list of structural origins."); + return null; + } + + if (profile == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry will a null profile."); + return null; + } + + if (pParams == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry from a null collection of profile parameters."); + return null; + } + var plan = PlanGeometry(structuralOrigins, null); var theatron = CreateGeometry(plan, profile, pParams,StadiaType.Undefined); @@ -64,6 +101,7 @@ public static TheatronGeometry TheatronGeometry(List structuralOr } /***************************************************/ + [Description("Create a partial TheatronGeometry based on a partial plan and a profile, Cvalue is used to define the TheatronFullProfile")] [Input("planPart", "The partial TheatronPlan")] [Input("profile", "The TheatronFullProfile")] @@ -87,7 +125,9 @@ private static TheatronGeometry CreateGeometry(TheatronPlan plan, TheatronFullPr return theatron; } + /***************************************************/ + private static void SetGeneratorblocks(ref TheatronGeometry theatronGeom, TheatronFullProfile fullprofile, TheatronPlan theatronPlan,StadiaType stadiatype, List profileParameters) { //this defines the geometry of the seating blocks from which all others are created diff --git a/Architecture_Engine/Create/Theatron/TheatronPlan.cs b/Architecture_Engine/Create/Theatron/TheatronPlan.cs index 533118041..8501d3f1d 100644 --- a/Architecture_Engine/Create/Theatron/TheatronPlan.cs +++ b/Architecture_Engine/Create/Theatron/TheatronPlan.cs @@ -42,22 +42,40 @@ public static partial class Create [Input("focalPolyline", "The polyline used to define focal points for Cvalue profile generation")] public static TheatronPlan PlanGeometry(List structuralSections, Polyline focalPolyline) { + if(structuralSections == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron plan from a null collection of structural sections."); + return null; + } + + if(focalPolyline == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron plan from a null focal polyline."); + return null; + } + var planGeometry = new TheatronPlan { SectionOrigins = structuralSections, - FocalCurve = focalPolyline, }; planGeometry.SectionOrigins.ForEach(x => planGeometry.StructBayType.Add(BayType.Undefined)); SetPlanes(ref planGeometry); return planGeometry; - } + /***************************************************/ + [Description("Create a full TheatronPlan from StadiaParameters")] [Input("parameters", "StadiaParameters to define the TheatronPlan")] public static TheatronPlan PlanGeometry(StadiaParameters parameters) { + if(parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron plan from a null set of stadia parameters."); + return null; + } + //assuming its a full stadium TheatronPlan planGeometry = new TheatronPlan(); diff --git a/Architecture_Engine/Create/Theatron/TheatronPlan/CircularPlan.cs b/Architecture_Engine/Create/Theatron/TheatronPlan/CircularPlan.cs index 276986e59..9e0bc1be5 100644 --- a/Architecture_Engine/Create/Theatron/TheatronPlan/CircularPlan.cs +++ b/Architecture_Engine/Create/Theatron/TheatronPlan/CircularPlan.cs @@ -35,6 +35,12 @@ public static partial class Create /***************************************************/ public static TheatronPlan CircularPlan(StadiaParameters parameters) { + if(parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a theatron plan from a null set of stadia parameters."); + return null; + } + TheatronPlan plan = new TheatronPlan(); CircularPlaneSetUp(ref plan, parameters.TheatronRadius, parameters.StructBayWidth); return plan; diff --git a/Architecture_Engine/Create/Theatron/TheatronPlan/EightArcPlan.cs b/Architecture_Engine/Create/Theatron/TheatronPlan/EightArcPlan.cs index 0c19c17a8..f63b2feab 100644 --- a/Architecture_Engine/Create/Theatron/TheatronPlan/EightArcPlan.cs +++ b/Architecture_Engine/Create/Theatron/TheatronPlan/EightArcPlan.cs @@ -35,6 +35,12 @@ public static partial class Create /***************************************************/ public static TheatronPlan EightArcPlan(StadiaParameters parameters) { + if (parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create an eight arc plan from a null set of stadia parameters."); + return null; + } + TheatronPlan plan = new TheatronPlan(); RadialPlanSetUp(ref plan,parameters.PitchLength,parameters.PitchWidth, parameters.SideBound, parameters.SideRadius, parameters.EndBound, parameters.EndRadius, parameters.CornerRadius, parameters.NumCornerBays, parameters.StructBayWidth, diff --git a/Architecture_Engine/Create/Theatron/TheatronPlan/NoCornersPlan.cs b/Architecture_Engine/Create/Theatron/TheatronPlan/NoCornersPlan.cs index d9c2a5fa5..44428616d 100644 --- a/Architecture_Engine/Create/Theatron/TheatronPlan/NoCornersPlan.cs +++ b/Architecture_Engine/Create/Theatron/TheatronPlan/NoCornersPlan.cs @@ -35,6 +35,12 @@ public static partial class Create /***************************************************/ public static TheatronPlan NoCornersPlan(StadiaParameters parameters) { + if (parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a no corners plan from a null set of stadia parameters."); + return null; + } + TheatronPlan plan = new TheatronPlan(); NoCornerPlanSetUp(ref plan, parameters.PitchLength,parameters.PitchWidth, parameters.EndBound, parameters.StructBayWidth, parameters.SideBound); return plan; diff --git a/Architecture_Engine/Create/Theatron/TheatronPlan/OrthogonalPlan.cs b/Architecture_Engine/Create/Theatron/TheatronPlan/OrthogonalPlan.cs index d4c23e418..7ab24ea3b 100644 --- a/Architecture_Engine/Create/Theatron/TheatronPlan/OrthogonalPlan.cs +++ b/Architecture_Engine/Create/Theatron/TheatronPlan/OrthogonalPlan.cs @@ -35,6 +35,12 @@ public static partial class Create /***************************************************/ public static TheatronPlan OrthogonalPlan(StadiaParameters parameters) { + if (parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create an orthogonal plan from a null set of stadia parameters."); + return null; + } + TheatronPlan plan = new TheatronPlan(); OrthoPlanSetUp(ref plan, parameters.PitchLength,parameters.PitchWidth, parameters.EndBound, parameters.SideBound, parameters.CornerRadius, parameters.StructBayWidth, parameters.NumCornerBays); diff --git a/Architecture_Engine/Create/Theatron/TierProfile.cs b/Architecture_Engine/Create/Theatron/TierProfile.cs index 692d68d68..fe274281c 100644 --- a/Architecture_Engine/Create/Theatron/TierProfile.cs +++ b/Architecture_Engine/Create/Theatron/TierProfile.cs @@ -42,39 +42,31 @@ public static partial class Create [Input("lastPointPrevTier", "Spectator eye point from previous tier or 0,0,0 on first tier")] public static TierProfile TierProfile(ProfileParameters parameters, Point lastPointPrevTier) { + if(parameters == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a tier profile from a null set of profile parameters."); + return null; + } + + if(lastPointPrevTier == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create a tier profile from a null spectator eye point from a previous tier."); + return null; + } + TierProfile tierProfile = new TierProfile(); SetEyePoints(ref tierProfile, parameters, lastPointPrevTier.X, lastPointPrevTier.Z); SectionSurfPoints(ref tierProfile, parameters); - tierProfile.SectionOrigin = DefineTierOrigin(tierProfile.FloorPoints); + tierProfile.SectionOrigin = Modify.DefineTierOrigin(tierProfile.FloorPoints); tierProfile.Profile = Geometry.Create.Polyline(tierProfile.FloorPoints); return tierProfile; } - - /***************************************************/ - [Description("Scale, rotate and translate a TierProfile")] - [Input("originalSection", "TierProfile to transform")] - [Input("scale", "Scaling amount")] - [Input("source", "Origin point for the transform")] - [Input("target", "Target point for the transform")] - [Input("angle", "Rotation angle")] - //this should be a modify method - public static TierProfile TransformProfile(TierProfile originalSection, Vector scale, Point source, Point target, double angle) - { - TierProfile transformedTier = (TierProfile)originalSection.DeepClone(); - var xScale = Geometry.Create.ScaleMatrix(source, scale); - var xRotate = Geometry.Create.RotationMatrix(source, Vector.ZAxis, angle); - var xTrans = Geometry.Create.TranslationMatrix(target-source); - TransformTier(ref transformedTier, xScale); - TransformTier(ref transformedTier, xRotate); - TransformTier(ref transformedTier, xTrans); - return transformedTier; - } /***************************************************/ /**** Private Methods ****/ /***************************************************/ @@ -103,7 +95,7 @@ private static TierProfile MirrorTierYZ(TierProfile originalSection) } theMappedTier.Profile.ControlPoints = theMappedTier.FloorPoints; - theMappedTier.SectionOrigin = DefineTierOrigin(theMappedTier.FloorPoints); + theMappedTier.SectionOrigin = Modify.DefineTierOrigin(theMappedTier.FloorPoints); return theMappedTier; @@ -250,24 +242,7 @@ private static void SectionSurfPoints(ref TierProfile tierProfile, ProfileParame /***************************************************/ - private static ProfileOrigin DefineTierOrigin(List flrPoints) - { - ProfileOrigin profOrigin = Create.ProfileOrigin(flrPoints[0], flrPoints[1] - flrPoints[0]); - return profOrigin; - } - - /***************************************************/ - - private static void TransformTier(ref TierProfile profile, TransformMatrix xTrans) - { - profile.FloorPoints = profile.FloorPoints.Select(p => p.Transform(xTrans)).ToList(); - profile.EyePoints = profile.EyePoints.Select(p => p.Transform(xTrans)).ToList(); - profile.Profile.ControlPoints = profile.FloorPoints; - profile.FocalPoint = profile.FocalPoint.Transform(xTrans); - profile.SectionOrigin = DefineTierOrigin(profile.FloorPoints); - } - - /***************************************************/ + } diff --git a/Architecture_Engine/Modify/TransformProfile.cs b/Architecture_Engine/Modify/TransformProfile.cs new file mode 100644 index 000000000..613975d10 --- /dev/null +++ b/Architecture_Engine/Modify/TransformProfile.cs @@ -0,0 +1,99 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2021, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using BH.oM.Geometry; +using BH.oM.Architecture.Theatron; +using System; +using BH.Engine.Base; +using System.Linq; +using BH.Engine.Geometry; +using System.Collections.Generic; +using System.ComponentModel; +using BH.oM.Reflection.Attributes; + +namespace BH.Engine.Architecture.Theatron +{ + public static partial class Modify + { + [Description("Scale, rotate and translate a TierProfile")] + [Input("originalSection", "TierProfile to transform")] + [Input("scale", "Scaling amount")] + [Input("source", "Origin point for the transform")] + [Input("target", "Target point for the transform")] + [Input("angle", "Rotation angle")] + [PreviousVersion("4.2", "BH.Engine.Architecture.Theatron.Create.TransformProfile(BH.oM.Architecture.Theatron.TierProfile, BH.oM.Geometry.Vector, BH.oM.Geomtry.Point, BH.oM.Geometry.Point, System.Double")] + public static TierProfile TransformProfile(TierProfile originalSection, Vector scale, Point source, Point target, double angle) + { + if (originalSection == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot modify a null tier profile."); + return originalSection; + } + + if(scale == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile using a null scale vector."); + return originalSection; + } + + if(source == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile from a null source point."); + return originalSection; + } + + if(target == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile from a null target point."); + return originalSection; + } + + TierProfile transformedTier = (TierProfile)originalSection.DeepClone(); + var xScale = Geometry.Create.ScaleMatrix(source, scale); + var xRotate = Geometry.Create.RotationMatrix(source, Vector.ZAxis, angle); + var xTrans = Geometry.Create.TranslationMatrix(target - source); + TransformTier(ref transformedTier, xScale); + TransformTier(ref transformedTier, xRotate); + TransformTier(ref transformedTier, xTrans); + return transformedTier; + } + + /***************************************************/ + + public static ProfileOrigin DefineTierOrigin(List flrPoints) + { + ProfileOrigin profOrigin = Create.ProfileOrigin(flrPoints[0], flrPoints[1] - flrPoints[0]); + return profOrigin; + } + + /***************************************************/ + + public static void TransformTier(ref TierProfile profile, TransformMatrix xTrans) + { + profile.FloorPoints = profile.FloorPoints.Select(p => p.Transform(xTrans)).ToList(); + profile.EyePoints = profile.EyePoints.Select(p => p.Transform(xTrans)).ToList(); + profile.Profile.ControlPoints = profile.FloorPoints; + profile.FocalPoint = profile.FocalPoint.Transform(xTrans); + profile.SectionOrigin = DefineTierOrigin(profile.FloorPoints); + } + } +} From a45ccd6d5f061ec6b1945ff08697e6270738539f Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 15 Apr 2021 22:01:48 +0100 Subject: [PATCH 05/12] Fix remaining null checks --- .../Create/Theatron/TheatronGeometry.cs | 18 ++++++++++++++++++ Architecture_Engine/Modify/TransformProfile.cs | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Architecture_Engine/Create/Theatron/TheatronGeometry.cs b/Architecture_Engine/Create/Theatron/TheatronGeometry.cs index de3e330dd..868908208 100644 --- a/Architecture_Engine/Create/Theatron/TheatronGeometry.cs +++ b/Architecture_Engine/Create/Theatron/TheatronGeometry.cs @@ -108,6 +108,24 @@ public static TheatronGeometry TheatronGeometry(List structuralOr [Input("pParams", "List of the ProfileParameters")] public static TheatronGeometry TheatronGeometry(TheatronPlan planPart, TheatronFullProfile profile, List pParams) { + if (planPart == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry will a null theatron plan."); + return null; + } + + if (profile == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry will a null profile."); + return null; + } + + if (pParams == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot create theatron geometry from a null collection of profile parameters."); + return null; + } + var theatron = CreateGeometry(planPart, profile, pParams, StadiaType.Undefined); theatron.Tiers3d.ForEach(t => t.Generatorblocks.ForEach(g => { t.TierBlocks.Add(g); theatron.Audience.Add(g.Audience); })); return theatron; diff --git a/Architecture_Engine/Modify/TransformProfile.cs b/Architecture_Engine/Modify/TransformProfile.cs index 613975d10..8594f8569 100644 --- a/Architecture_Engine/Modify/TransformProfile.cs +++ b/Architecture_Engine/Modify/TransformProfile.cs @@ -89,6 +89,18 @@ public static ProfileOrigin DefineTierOrigin(List flrPoints) public static void TransformTier(ref TierProfile profile, TransformMatrix xTrans) { + if(profile == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot modify a null tier profile."); + return; + } + + if(xTrans == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot modify a tier profile with a null transformation matrix."); + return; + } + profile.FloorPoints = profile.FloorPoints.Select(p => p.Transform(xTrans)).ToList(); profile.EyePoints = profile.EyePoints.Select(p => p.Transform(xTrans)).ToList(); profile.Profile.ControlPoints = profile.FloorPoints; From 8e39c9395e97b87cd980b31aab1fe9608a8386aa Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 15 Apr 2021 22:34:37 +0100 Subject: [PATCH 06/12] Fix versioning for a stupid typo --- Architecture_Engine/Modify/TransformProfile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Architecture_Engine/Modify/TransformProfile.cs b/Architecture_Engine/Modify/TransformProfile.cs index 8594f8569..c837c1e3d 100644 --- a/Architecture_Engine/Modify/TransformProfile.cs +++ b/Architecture_Engine/Modify/TransformProfile.cs @@ -40,7 +40,7 @@ public static partial class Modify [Input("source", "Origin point for the transform")] [Input("target", "Target point for the transform")] [Input("angle", "Rotation angle")] - [PreviousVersion("4.2", "BH.Engine.Architecture.Theatron.Create.TransformProfile(BH.oM.Architecture.Theatron.TierProfile, BH.oM.Geometry.Vector, BH.oM.Geomtry.Point, BH.oM.Geometry.Point, System.Double")] + [PreviousVersion("4.2", "BH.Engine.Architecture.Theatron.Create.TransformProfile(BH.oM.Architecture.Theatron.TierProfile, BH.oM.Geometry.Vector, BH.oM.Geometry.Point, BH.oM.Geometry.Point, System.Double")] public static TierProfile TransformProfile(TierProfile originalSection, Vector scale, Point source, Point target, double angle) { if (originalSection == null) From 1e8bcecd2685853b86be6bfad1b72b6c721dc95c Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Fri, 16 Apr 2021 08:45:52 +0100 Subject: [PATCH 07/12] Fix versioning with another stupid typo --- Architecture_Engine/Modify/TransformProfile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Architecture_Engine/Modify/TransformProfile.cs b/Architecture_Engine/Modify/TransformProfile.cs index c837c1e3d..03ff68534 100644 --- a/Architecture_Engine/Modify/TransformProfile.cs +++ b/Architecture_Engine/Modify/TransformProfile.cs @@ -40,7 +40,7 @@ public static partial class Modify [Input("source", "Origin point for the transform")] [Input("target", "Target point for the transform")] [Input("angle", "Rotation angle")] - [PreviousVersion("4.2", "BH.Engine.Architecture.Theatron.Create.TransformProfile(BH.oM.Architecture.Theatron.TierProfile, BH.oM.Geometry.Vector, BH.oM.Geometry.Point, BH.oM.Geometry.Point, System.Double")] + [PreviousVersion("4.2", "BH.Engine.Architecture.Theatron.Create.TransformProfile(BH.oM.Architecture.Theatron.TierProfile, BH.oM.Geometry.Vector, BH.oM.Geometry.Point, BH.oM.Geometry.Point, System.Double)")] public static TierProfile TransformProfile(TierProfile originalSection, Vector scale, Point source, Point target, double angle) { if (originalSection == null) From fbb07586b880a4dbe112c50946510573cd397a6a Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 22 Apr 2021 14:14:07 +0100 Subject: [PATCH 08/12] Update Architecture_Engine/Compute/CeilingTiles.cs Co-authored-by: Pawel Baran --- Architecture_Engine/Compute/CeilingTiles.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Architecture_Engine/Compute/CeilingTiles.cs b/Architecture_Engine/Compute/CeilingTiles.cs index 7c22fa732..079037b22 100644 --- a/Architecture_Engine/Compute/CeilingTiles.cs +++ b/Architecture_Engine/Compute/CeilingTiles.cs @@ -52,7 +52,7 @@ public static List CeilingTiles(Ceiling ceiling, List ceiling if(ceiling == null) { BH.Engine.Reflection.Compute.RecordError("Cannot compute the ceiling tiles for a null ceiling."); - return null; + return new List(); } List openingLines = ceiling.Surface.IInternalEdges().SelectMany(x => x.ISubParts()).Cast().ToList(); @@ -72,4 +72,3 @@ public static List CeilingTiles(Ceiling ceiling, List ceiling } } } - From 6ada55a64fb2e81d1b3ff2b2f76c6844cb69bfc0 Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 22 Apr 2021 14:14:22 +0100 Subject: [PATCH 09/12] Update Architecture_Engine/Query/OutlineElements1D.cs Co-authored-by: Pawel Baran --- Architecture_Engine/Query/OutlineElements1D.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Architecture_Engine/Query/OutlineElements1D.cs b/Architecture_Engine/Query/OutlineElements1D.cs index 7fe71f1b4..d50fc3ee7 100644 --- a/Architecture_Engine/Query/OutlineElements1D.cs +++ b/Architecture_Engine/Query/OutlineElements1D.cs @@ -66,7 +66,7 @@ public static List OutlineElements1D(this Ceiling ceiling) if(ceiling == null) { BH.Engine.Reflection.Compute.RecordError("Cannot query the outline 1D elements of a null ceiling."); - return null; + return new List(); } return ceiling.Surface.ISubParts().Cast().ToList(); @@ -74,4 +74,3 @@ public static List OutlineElements1D(this Ceiling ceiling) } } - From f52b0d2182bd240d5cfa0da7863aa28d23d98d07 Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 22 Apr 2021 14:14:31 +0100 Subject: [PATCH 10/12] Update Architecture_Engine/Query/OutlineElements1D.cs Co-authored-by: Pawel Baran --- Architecture_Engine/Query/OutlineElements1D.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Architecture_Engine/Query/OutlineElements1D.cs b/Architecture_Engine/Query/OutlineElements1D.cs index d50fc3ee7..4dac29664 100644 --- a/Architecture_Engine/Query/OutlineElements1D.cs +++ b/Architecture_Engine/Query/OutlineElements1D.cs @@ -50,7 +50,7 @@ public static List OutlineElements1D(this Room room) if(room == null) { BH.Engine.Reflection.Compute.RecordError("Cannot query the outline 1D elements of a null room."); - return null; + return new List(); } return room.Perimeter.ISubParts().Cast().ToList(); @@ -73,4 +73,3 @@ public static List OutlineElements1D(this Ceiling ceiling) } } } - From 5bde3de9d370a98f17f3d2714d931f1af3f1d03b Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 22 Apr 2021 14:24:37 +0100 Subject: [PATCH 11/12] Revert moving transform profile to modify. --- .../Architecture_Engine.csproj | 1 - .../Create/Theatron/SeatingBlock.cs | 10 +- .../Create/Theatron/TheatronFullProfile.cs | 2 +- .../Create/Theatron/TierProfile.cs | 76 +++++++++++- .../Modify/TransformProfile.cs | 111 ------------------ 5 files changed, 78 insertions(+), 122 deletions(-) delete mode 100644 Architecture_Engine/Modify/TransformProfile.cs diff --git a/Architecture_Engine/Architecture_Engine.csproj b/Architecture_Engine/Architecture_Engine.csproj index 4cec30bcc..68ec96f04 100644 --- a/Architecture_Engine/Architecture_Engine.csproj +++ b/Architecture_Engine/Architecture_Engine.csproj @@ -93,7 +93,6 @@ - diff --git a/Architecture_Engine/Create/Theatron/SeatingBlock.cs b/Architecture_Engine/Create/Theatron/SeatingBlock.cs index 5ce421c12..a1dd69b5c 100644 --- a/Architecture_Engine/Create/Theatron/SeatingBlock.cs +++ b/Architecture_Engine/Create/Theatron/SeatingBlock.cs @@ -82,19 +82,19 @@ private static void SetBlockProfiles(ref SeatingBlock block, TierProfile section Point source = origin.Origin; Vector scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.Start, block.Vomitory); double angle = Geometry.Query.Angle(origin.Direction, block.Start.Direction, Plane.XY); - var start = Modify.TransformProfile(sectionToMap, scaleVector, source, block.Start.Origin, angle); + var start = TransformProfile(sectionToMap, scaleVector, source, block.Start.Origin, angle); block.Sections.Add(start); //vomitory section no need for scalefactor scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.Vomitory, block.Vomitory); angle = Geometry.Query.Angle(origin.Direction, block.Vomitory.Direction, Plane.XY); - var vom = Modify.TransformProfile(sectionToMap, scaleVector, source, block.Vomitory.Origin, angle); + var vom = TransformProfile(sectionToMap, scaleVector, source, block.Vomitory.Origin, angle); block.Sections.Add(vom); //end section scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.End, block.Vomitory); angle = Geometry.Query.Angle(origin.Direction, block.End.Direction, Plane.XY); - var end = Modify.TransformProfile(sectionToMap, scaleVector, source, block.End.Origin, angle); + var end = TransformProfile(sectionToMap, scaleVector, source, block.End.Origin, angle); block.Sections.Add(end); } @@ -107,13 +107,13 @@ private static void SetTransitionProfiles(ref SeatingBlock block, TierProfile se Point source = origin.Origin; Vector scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.Start, prevVomitory); double angle = Geometry.Query.Angle(origin.Direction, block.Start.Direction, Plane.XY); - var start = Modify.TransformProfile(sectionToMap, scaleVector, source, block.Start.Origin, angle); + var start = TransformProfile(sectionToMap, scaleVector, source, block.Start.Origin, angle); block.Sections.Add(start); //end section scaleVector = SetScaleVector(sectionToMap.SectionOrigin.Direction, block.End, nextVomitory); angle = Geometry.Query.Angle(origin.Direction, block.End.Direction, Plane.XY); - var end = Modify.TransformProfile(sectionToMap, scaleVector, source, block.End.Origin, angle); + var end = TransformProfile(sectionToMap, scaleVector, source, block.End.Origin, angle); block.Sections.Add(end); } diff --git a/Architecture_Engine/Create/Theatron/TheatronFullProfile.cs b/Architecture_Engine/Create/Theatron/TheatronFullProfile.cs index eb05e1880..cf094cc9d 100644 --- a/Architecture_Engine/Create/Theatron/TheatronFullProfile.cs +++ b/Architecture_Engine/Create/Theatron/TheatronFullProfile.cs @@ -143,7 +143,7 @@ private static void GenerateMapProfiles(ref TheatronFullProfile fullProfile, Lis Point target = sectionOrigin.Origin; double angle = Math.Atan2(sectionOrigin.Direction.Y, sectionOrigin.Direction.X); Vector scaleVector = SetScaleVector(tierSection.SectionOrigin.Direction, tierSection.SectionOrigin, tierSection.SectionOrigin); - fullProfile.MappedProfiles.Add(Modify.TransformProfile(tierSection, scaleVector,source, target, angle)); + fullProfile.MappedProfiles.Add(TransformProfile(tierSection, scaleVector,source, target, angle)); lastpoint = tierSection.FloorPoints[tierSection.FloorPoints.Count - 1]; } diff --git a/Architecture_Engine/Create/Theatron/TierProfile.cs b/Architecture_Engine/Create/Theatron/TierProfile.cs index fe274281c..44ac1b4d1 100644 --- a/Architecture_Engine/Create/Theatron/TierProfile.cs +++ b/Architecture_Engine/Create/Theatron/TierProfile.cs @@ -60,13 +60,56 @@ public static TierProfile TierProfile(ProfileParameters parameters, Point lastPo SectionSurfPoints(ref tierProfile, parameters); - tierProfile.SectionOrigin = Modify.DefineTierOrigin(tierProfile.FloorPoints); + tierProfile.SectionOrigin = DefineTierOrigin(tierProfile.FloorPoints); tierProfile.Profile = Geometry.Create.Polyline(tierProfile.FloorPoints); return tierProfile; } + [Description("Scale, rotate and translate a TierProfile")] + [Input("originalSection", "TierProfile to transform")] + [Input("scale", "Scaling amount")] + [Input("source", "Origin point for the transform")] + [Input("target", "Target point for the transform")] + [Input("angle", "Rotation angle")] + [PreviousVersion("4.2", "BH.Engine.Architecture.Theatron.Create.TransformProfile(BH.oM.Architecture.Theatron.TierProfile, BH.oM.Geometry.Vector, BH.oM.Geometry.Point, BH.oM.Geometry.Point, System.Double)")] + public static TierProfile TransformProfile(TierProfile originalSection, Vector scale, Point source, Point target, double angle) + { + if (originalSection == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot modify a null tier profile."); + return originalSection; + } + + if (scale == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile using a null scale vector."); + return originalSection; + } + + if (source == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile from a null source point."); + return originalSection; + } + + if (target == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile from a null target point."); + return originalSection; + } + + TierProfile transformedTier = (TierProfile)originalSection.DeepClone(); + var xScale = Geometry.Create.ScaleMatrix(source, scale); + var xRotate = Geometry.Create.RotationMatrix(source, Vector.ZAxis, angle); + var xTrans = Geometry.Create.TranslationMatrix(target - source); + TransformTier(ref transformedTier, xScale); + TransformTier(ref transformedTier, xRotate); + TransformTier(ref transformedTier, xTrans); + return transformedTier; + } + /***************************************************/ /**** Private Methods ****/ /***************************************************/ @@ -95,7 +138,7 @@ private static TierProfile MirrorTierYZ(TierProfile originalSection) } theMappedTier.Profile.ControlPoints = theMappedTier.FloorPoints; - theMappedTier.SectionOrigin = Modify.DefineTierOrigin(theMappedTier.FloorPoints); + theMappedTier.SectionOrigin = DefineTierOrigin(theMappedTier.FloorPoints); return theMappedTier; @@ -242,9 +285,34 @@ private static void SectionSurfPoints(ref TierProfile tierProfile, ProfileParame /***************************************************/ - + private static ProfileOrigin DefineTierOrigin(List flrPoints) + { + ProfileOrigin profOrigin = Create.ProfileOrigin(flrPoints[0], flrPoints[1] - flrPoints[0]); + return profOrigin; + } - + /***************************************************/ + + private static void TransformTier(ref TierProfile profile, TransformMatrix xTrans) + { + if (profile == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot modify a null tier profile."); + return; + } + + if (xTrans == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot modify a tier profile with a null transformation matrix."); + return; + } + + profile.FloorPoints = profile.FloorPoints.Select(p => p.Transform(xTrans)).ToList(); + profile.EyePoints = profile.EyePoints.Select(p => p.Transform(xTrans)).ToList(); + profile.Profile.ControlPoints = profile.FloorPoints; + profile.FocalPoint = profile.FocalPoint.Transform(xTrans); + profile.SectionOrigin = DefineTierOrigin(profile.FloorPoints); + } } } diff --git a/Architecture_Engine/Modify/TransformProfile.cs b/Architecture_Engine/Modify/TransformProfile.cs deleted file mode 100644 index 03ff68534..000000000 --- a/Architecture_Engine/Modify/TransformProfile.cs +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2021, the respective contributors. All rights reserved. - * - * Each contributor holds copyright over their respective contributions. - * The project versioning (Git) records all such contribution source information. - * - * - * The BHoM is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3.0 of the License, or - * (at your option) any later version. - * - * The BHoM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - */ - -using BH.oM.Geometry; -using BH.oM.Architecture.Theatron; -using System; -using BH.Engine.Base; -using System.Linq; -using BH.Engine.Geometry; -using System.Collections.Generic; -using System.ComponentModel; -using BH.oM.Reflection.Attributes; - -namespace BH.Engine.Architecture.Theatron -{ - public static partial class Modify - { - [Description("Scale, rotate and translate a TierProfile")] - [Input("originalSection", "TierProfile to transform")] - [Input("scale", "Scaling amount")] - [Input("source", "Origin point for the transform")] - [Input("target", "Target point for the transform")] - [Input("angle", "Rotation angle")] - [PreviousVersion("4.2", "BH.Engine.Architecture.Theatron.Create.TransformProfile(BH.oM.Architecture.Theatron.TierProfile, BH.oM.Geometry.Vector, BH.oM.Geometry.Point, BH.oM.Geometry.Point, System.Double)")] - public static TierProfile TransformProfile(TierProfile originalSection, Vector scale, Point source, Point target, double angle) - { - if (originalSection == null) - { - BH.Engine.Reflection.Compute.RecordError("Cannot modify a null tier profile."); - return originalSection; - } - - if(scale == null) - { - BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile using a null scale vector."); - return originalSection; - } - - if(source == null) - { - BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile from a null source point."); - return originalSection; - } - - if(target == null) - { - BH.Engine.Reflection.Compute.RecordError("Cannot transform a tier profile from a null target point."); - return originalSection; - } - - TierProfile transformedTier = (TierProfile)originalSection.DeepClone(); - var xScale = Geometry.Create.ScaleMatrix(source, scale); - var xRotate = Geometry.Create.RotationMatrix(source, Vector.ZAxis, angle); - var xTrans = Geometry.Create.TranslationMatrix(target - source); - TransformTier(ref transformedTier, xScale); - TransformTier(ref transformedTier, xRotate); - TransformTier(ref transformedTier, xTrans); - return transformedTier; - } - - /***************************************************/ - - public static ProfileOrigin DefineTierOrigin(List flrPoints) - { - ProfileOrigin profOrigin = Create.ProfileOrigin(flrPoints[0], flrPoints[1] - flrPoints[0]); - return profOrigin; - } - - /***************************************************/ - - public static void TransformTier(ref TierProfile profile, TransformMatrix xTrans) - { - if(profile == null) - { - BH.Engine.Reflection.Compute.RecordError("Cannot modify a null tier profile."); - return; - } - - if(xTrans == null) - { - BH.Engine.Reflection.Compute.RecordError("Cannot modify a tier profile with a null transformation matrix."); - return; - } - - profile.FloorPoints = profile.FloorPoints.Select(p => p.Transform(xTrans)).ToList(); - profile.EyePoints = profile.EyePoints.Select(p => p.Transform(xTrans)).ToList(); - profile.Profile.ControlPoints = profile.FloorPoints; - profile.FocalPoint = profile.FocalPoint.Transform(xTrans); - profile.SectionOrigin = DefineTierOrigin(profile.FloorPoints); - } - } -} From 93c54988476d9d7e5c8d767c8abe406803a7ce0c Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 22 Apr 2021 14:43:51 +0100 Subject: [PATCH 12/12] Remove attribute. --- Architecture_Engine/Architecture_Engine.csproj | 1 - Architecture_Engine/Create/Theatron/TierProfile.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/Architecture_Engine/Architecture_Engine.csproj b/Architecture_Engine/Architecture_Engine.csproj index 68ec96f04..712caa71c 100644 --- a/Architecture_Engine/Architecture_Engine.csproj +++ b/Architecture_Engine/Architecture_Engine.csproj @@ -123,7 +123,6 @@ - diff --git a/Architecture_Engine/Create/Theatron/TierProfile.cs b/Architecture_Engine/Create/Theatron/TierProfile.cs index 44ac1b4d1..37440f815 100644 --- a/Architecture_Engine/Create/Theatron/TierProfile.cs +++ b/Architecture_Engine/Create/Theatron/TierProfile.cs @@ -73,7 +73,6 @@ public static TierProfile TierProfile(ProfileParameters parameters, Point lastPo [Input("source", "Origin point for the transform")] [Input("target", "Target point for the transform")] [Input("angle", "Rotation angle")] - [PreviousVersion("4.2", "BH.Engine.Architecture.Theatron.Create.TransformProfile(BH.oM.Architecture.Theatron.TierProfile, BH.oM.Geometry.Vector, BH.oM.Geometry.Point, BH.oM.Geometry.Point, System.Double)")] public static TierProfile TransformProfile(TierProfile originalSection, Vector scale, Point source, Point target, double angle) { if (originalSection == null)