Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Architecture_Engine: Fix null handling #2463

Merged
merged 12 commits into from
Apr 22, 2021
7 changes: 6 additions & 1 deletion Architecture_Engine/Compute/CeilingTiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public static partial class Compute
[Output("ceilingTiles", "Closed Ceiling Tile regions contained within the Ceiling.")]
public static List<CeilingTile> CeilingTiles(Ceiling ceiling, List<Line> 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 new List<CeilingTile>();
}

List<Line> openingLines = ceiling.Surface.IInternalEdges().SelectMany(x => x.ISubParts()).Cast<Line>().ToList();

ceilingTileLines.AddRange(openingLines);
Expand All @@ -66,4 +72,3 @@ public static List<CeilingTile> CeilingTiles(Ceiling ceiling, List<Line> ceiling
}
}
}

12 changes: 11 additions & 1 deletion Architecture_Engine/Create/Theatron/ActivityArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions Architecture_Engine/Create/Theatron/ProfileOrigin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
23 changes: 14 additions & 9 deletions Architecture_Engine/Create/Theatron/SeatingBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand Down Expand Up @@ -114,7 +119,7 @@ private static void SetTransitionProfiles(ref SeatingBlock block, TierProfile se

/***************************************************/

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;
Expand Down
40 changes: 39 additions & 1 deletion Architecture_Engine/Create/Theatron/TheatronFullProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public static partial class Create
[Input("parameters", "List of ProfileParameters")]
public static TheatronFullProfile TheatronFullProfile(List<ProfileParameters> 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;
Expand All @@ -51,23 +57,55 @@ public static TheatronFullProfile TheatronFullProfile(List<ProfileParameters> 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<ProfileParameters> 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<ProfileParameters> 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();
Expand Down
62 changes: 60 additions & 2 deletions Architecture_Engine/Create/Theatron/TheatronGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProfileParameters> pParams)
public static TheatronGeometry TheatronGeometry(TheatronPlan planFull, TheatronFullProfile profile, StadiaParameters sParams, List<ProfileParameters> 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<ProfileOrigin> structuralOrigins, TheatronFullProfile profile, List<ProfileParameters> 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);

Expand All @@ -64,12 +101,31 @@ public static TheatronGeometry TheatronGeometry(List<ProfileOrigin> 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")]
[Input("pParams", "List of the ProfileParameters")]
public static TheatronGeometry TheatronGeometry(TheatronPlan planPart, TheatronFullProfile profile, List<ProfileParameters> 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;
Expand All @@ -87,7 +143,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> profileParameters)
{
//this defines the geometry of the seating blocks from which all others are created
Expand Down
22 changes: 20 additions & 2 deletions Architecture_Engine/Create/Theatron/TheatronPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProfileOrigin> 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading