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

Environment_Engine: Provide protection around some aspects of engine code #1931

Merged
merged 1 commit into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Environment_Engine/Query/BottomLeft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public static Point BottomLeft(this Polyline polyline, List<Panel> panelsAsSpace
normal = polyline.Flip().Normal();

Point centre = polyline.Centroid();
if (centre == null)
centre = polyline.Centre();

if(normal == null)
return null;

Line line = new Line
{
Expand Down
5 changes: 5 additions & 0 deletions Environment_Engine/Query/BottomRight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public static Point BottomRight(this Polyline polyline, List<Panel> panelsAsSpac
normal = polyline.Flip().Normal();

Point centre = polyline.Centroid();
if (centre == null)
centre = polyline.Centre();

if(normal == null)
return null;

Line line = new Line
{
Expand Down
8 changes: 8 additions & 0 deletions Environment_Engine/Query/NormalAwayFromSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public static bool NormalAwayFromSpace(this Polyline polyline, List<Panel> panel
{
List<Point> centrePtList = new List<Point>();
Point centrePt = polyline.PointInRegion(false, tolerance); //Modifed to Centroid to fix special cases Point centrePt = polyline.Centre();

if (centrePt == null)
centrePt = polyline.Centroid();
if (centrePt == null)
centrePt = polyline.Centre();
if (centrePt == null)
return false; //Problems

centrePtList.Add(centrePt);

if (!polyline.IsClosed()) return false; //Prevent failures of the clockwise check
Expand Down
5 changes: 5 additions & 0 deletions Environment_Engine/Query/TopRight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public static Point TopRight(this Polyline polyline, List<Panel> panelsAsSpace)
normal = polyline.Flip().Normal();

Point centre = polyline.Centroid();
if (centre == null)
centre = polyline.Centre();

if(normal == null)
return null;

Line line = new Line
{
Expand Down