Skip to content

BHoM_Engine: Overall compliance fixes #3472

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

Merged
merged 17 commits into from
Mar 20, 2025
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
8 changes: 4 additions & 4 deletions BHoM_Engine/Query/ShallowClone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,30 @@
/**** Public Methods ****/
/***************************************************/

public static T ShallowClone<T>(this T obj)

Check warning on line 36 in BHoM_Engine/Query/ShallowClone.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

BHoM_Engine/Query/ShallowClone.cs#L36

Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Method must contain an Output or MultiOutput attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasOutputAttribute
{
return (T)_ShallowClone(obj as dynamic);
return (T)CreateShallowClone(obj as dynamic);
}

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

public static T ShallowClone<T>(this T obj, bool newGuid = false) where T : IBHoMObject

Check warning on line 43 in BHoM_Engine/Query/ShallowClone.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

BHoM_Engine/Query/ShallowClone.cs#L43

Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Method must contain an Output or MultiOutput attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasOutputAttribute
{
return (T)_ShallowClone(obj, newGuid);
return (T)CreateShallowClone(obj, newGuid);
}

/***************************************************/
/**** Private Methods ****/
/***************************************************/

private static IBHoMObject _ShallowClone(this IBHoMObject bhomObject, bool newGuid = false)
private static IBHoMObject CreateShallowClone(this IBHoMObject bhomObject, bool newGuid = false)
{
IBHoMObject clone = DeepClonerExtensions.ShallowClone(bhomObject);

if (bhomObject.CustomData != null)
clone.CustomData = new Dictionary<string, object>(bhomObject.CustomData);
else
clone.CustomData = new Dictionary<string, object>();

Check warning on line 59 in BHoM_Engine/Query/ShallowClone.cs

View check run for this annotation

BHoMBot-CI / code-compliance

BHoM_Engine/Query/ShallowClone.cs#L56-L59

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData

if (bhomObject.Tags != null)
clone.Tags = new HashSet<string>(bhomObject.Tags);
Expand All @@ -76,7 +76,7 @@

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

private static object _ShallowClone(this object obj)
private static object CreateShallowClone(this object obj)
{
return DeepClonerExtensions.ShallowClone(obj);
}
Expand Down
56 changes: 0 additions & 56 deletions Data_Engine/Compute/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**** Public Methods ****/
/***************************************************/

public static List<GraphNode<T>> Path<T>(this Graph<T> graph, GraphNode<T> startNode, GraphNode<T> endNode, Func<T, T, double> costHeuristic)

Check warning on line 36 in Data_Engine/Compute/Path.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Data_Engine/Compute/Path.cs#L36

Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Method must contain an Output or MultiOutput attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasOutputAttribute
{
// Create the inital close set
HashSet<GraphNode<T>> closedSet = new HashSet<GraphNode<T>>();
Expand Down Expand Up @@ -99,62 +99,6 @@
return path;
}


/***************************************************/
/**** Private Helper Classes ****/
/***************************************************/

private class PathItem<T> : IComparable<PathItem<T>>
{
/***************************************************/
/**** Properties ****/
/***************************************************/

public double StartCost { get; set; } // Cost of going from start to that node

public double EndCost { get; set; } // estimated cost of going from this node to the end

public GraphNode<T> Node { get; set; }

public PathItem<T> Previous { get; set; }

public bool IsValid { get { return Node != null; } }

public double Score { get { return StartCost + EndCost; } }


/***************************************************/
/**** Constructors ****/
/***************************************************/

public PathItem()
{
Node = null;
}

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

public PathItem(GraphNode<T> node, double startCost = 0, double endCost = 0)
{
Node = node;
StartCost = startCost;
EndCost = endCost;
Previous = null;
}


/***************************************************/
/**** Comparer ****/
/***************************************************/

int IComparable<PathItem<T>>.CompareTo(PathItem<T> other)
{
return Score.CompareTo(other.Score);
}

/***************************************************/
}

/***************************************************/
}
}
Expand Down
8 changes: 4 additions & 4 deletions Data_Engine/Modify/TransposeRectangularCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
{
public static partial class Modify
{
[Description("Get the transpose of a rectangular collection")]
[Input("lists", "The rectangular collection to transpose")]
[Output("The transposed rectangular collection")]
public static List<List<T>> TransposeRectangularCollection<T>(List<List<T>> lists)
[Description("Get the transpose of a rectangular collection.")]
[Input("lists", "The rectangular collection to transpose.")]
[Output("The transposed rectangular collection.")]
public static List<List<T>> TransposeRectangularCollection<T>(this List<List<T>> lists)

Check warning on line 39 in Data_Engine/Modify/TransposeRectangularCollection.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Data_Engine/Modify/TransposeRectangularCollection.cs#L39

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
var longest = lists.Any() ? lists.Max(l => l.Count) : 0;
List<List<T>> outer = new List<List<T>>(longest);
Expand Down
83 changes: 83 additions & 0 deletions Data_Engine/Objects/PathItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2025, 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 <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Data.Collections;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace BH.Engine.Data
{
[Description("Helper class used by the Path algorithm for Graph")]

Check warning on line 31 in Data_Engine/Objects/PathItem.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Data_Engine/Objects/PathItem.cs#L31

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
public class PathItem<T> : IComparable<PathItem<T>>
{
/***************************************************/
/**** Properties ****/
/***************************************************/

public double StartCost { get; set; } // Cost of going from start to that node

public double EndCost { get; set; } // estimated cost of going from this node to the end

public GraphNode<T> Node { get; set; }

public PathItem<T> Previous { get; set; }

public bool IsValid { get { return Node != null; } }

public double Score { get { return StartCost + EndCost; } }


/***************************************************/
/**** Constructors ****/
/***************************************************/

public PathItem()
{
Node = null;
}

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

public PathItem(GraphNode<T> node, double startCost = 0, double endCost = 0)
{
Node = node;
StartCost = startCost;
EndCost = endCost;
Previous = null;
}


/***************************************************/
/**** Comparer ****/
/***************************************************/

int IComparable<PathItem<T>>.CompareTo(PathItem<T> other)
{
return Score.CompareTo(other.Score);
}

/***************************************************/
}

}
18 changes: 9 additions & 9 deletions Data_Engine/Query/ChunkBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
/**** Public Methods ****/
/***************************************************/

[Description("Partition an enumerable collection into sublists based on the number of target sub-lists")]
[Input("collection", "An enumerable list of variable data types")]
[Input("nChunks", "The number of \"chunks\" into which the collection should be split")]
[Description("Partition an enumerable collection into sublists based on the number of target sub-lists.")]
[Input("collection", "An enumerable list of variable data types.")]
[Input("nChunks", "The number of \"chunks\" into which the collection should be split.")]
[Output("chunks", "The chunked list")]

Check warning on line 41 in Data_Engine/Query/ChunkBy.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Data_Engine/Query/ChunkBy.cs#L41

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
public static IEnumerable<List<T>> ChunkByNumber<T>(IEnumerable<T> collection, int nChunks)
public static IEnumerable<List<T>> ChunkByNumber<T>(this IEnumerable<T> collection, int nChunks)
{
int i = 0;
var splits = from item in collection
Expand All @@ -48,11 +48,11 @@
return splits;
}

[Description("Chunk an enumerable collection into sublists based on a maximum size of each sub-list")]
[Input("collection", "An enumerable list of variable data types")]
[Input("chunkSize", "The size of each \"chunk\" into which the collection should be split")]
[Output("chunks", "The chunked list")]
public static IEnumerable<List<T>> ChunkBySize<T>(List<T> collection, int chunkSize = 1)
[Description("Chunk an enumerable collection into sublists based on a maximum size of each sub-list.")]
[Input("collection", "An enumerable list of variable data types.")]
[Input("chunkSize", "The size of each \"chunk\" into which the collection should be split.")]
[Output("chunks", "The chunked list.")]
public static IEnumerable<List<T>> ChunkBySize<T>(this List<T> collection, int chunkSize = 1)
{
for (int i = 0; i < collection.Count; i += chunkSize)
{
Expand Down
14 changes: 7 additions & 7 deletions Data_Engine/Query/DepthDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
/***************************************************/
/**** Public Methods ****/
/***************************************************/
[Description("Gets the depth dictionary of a graph using breadth first search, each key value pair in the resulting dictionary is in the form <graph node, depth>")]
[Input("adjacency", "The adjacency dictionary to extract the depth dictionary from")]
[Input("startNode", "The graph node from which the depth dictionary is created")]
public static Dictionary<GraphNode<T>, int> DepthDictionary<T>(Dictionary<GraphNode<T>, List<GraphNode<T>>> adjacency, GraphNode<T> startNode)
[Description("Gets the depth dictionary of a graph using breadth first search, each key value pair in the resulting dictionary is in the form <graph node, depth>.")]
[Input("adjacency", "The adjacency dictionary to extract the depth dictionary from.")]
[Input("startNode", "The graph node from which the depth dictionary is created.")]
public static Dictionary<GraphNode<T>, int> DepthDictionary<T>(this Dictionary<GraphNode<T>, List<GraphNode<T>>> adjacency, GraphNode<T> startNode)

Check warning on line 40 in Data_Engine/Query/DepthDictionary.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Data_Engine/Query/DepthDictionary.cs#L40

Method must contain an Output or MultiOutput attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasOutputAttribute
{
//https://www.geeksforgeeks.org/level-node-tree-source-node-using-bfs/
// dictionary to store level of each node
Expand Down Expand Up @@ -81,10 +81,10 @@
return level;
}
/***************************************************/
[Description("Gets the depth dictionary of a graph using breadth first search, each key value pair in the resulting dictionary is in the form <graph node, depth>")]
[Input("graph", "The graph to extract the depth dictionary from")]
[Input("startNode", "The graph node from which the depth dictionary is created")]
[Description("Gets the depth dictionary of a graph using breadth first search, each key value pair in the resulting dictionary is in the form <graph node, depth>.")]
[Input("graph", "The graph to extract the depth dictionary from.")]
[Input("startNode", "The graph node from which the depth dictionary is created.")]
public static Dictionary<GraphNode<T>, int> DepthDictionary<T>(this Graph<T> graph, GraphNode<T> startNode)

Check warning on line 87 in Data_Engine/Query/DepthDictionary.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Data_Engine/Query/DepthDictionary.cs#L87

Method must contain an Output or MultiOutput attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasOutputAttribute
{
Dictionary<GraphNode<T>, List<GraphNode<T>>> adjacency = graph.AdjacencyDictionary();
return DepthDictionary<T>(adjacency, startNode);
Expand Down
2 changes: 1 addition & 1 deletion Data_Engine/Query/IsInRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static bool IsInRange(this Domain domain1, Domain domain2, double toleran
/***************************************************/

[Description("Queries if the value is in range of the domain.")]
[Input("domain1", "Domain to evaluate overlap with.")]
[Input("domain", "Domain to evaluate overlap with.")]
[Input("val", "Value to query overlap with the domain.")]
[Input("tolerance", "Numerical tolerance for the operation.")]
[Output("true if the value is in the domain.")]
Expand Down
4 changes: 3 additions & 1 deletion Data_Engine/Query/Peek.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Base.Attributes;
using BH.oM.Data.Collections;
using System;

namespace BH.Engine.Data
{
public static partial class Modify
public static partial class Query
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[PreviousVersion("8.1", "BH.Engine.Data.Modify.Peek(BH.oM.Data.Collections.PriorityQueue<System.IComparable<System.Object>>)")]
public static T Peek<T>(this PriorityQueue<T> queue) where T : IComparable<T>

Check warning on line 36 in Data_Engine/Query/Peek.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Data_Engine/Query/Peek.cs#L36

Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Method must contain an Output or MultiOutput attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasOutputAttribute
{
T frontItem = queue.Data[0];
return frontItem;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Environment_Engine/Modify/OffsetOpenings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
public static partial class Modify
{
[Description("Reduces the area of the opening(s) if the total area of the opening(s) is equal to the area of the panel itself. Returns an Environment Panel object.")]
[Input("panel", "An Environment Panel object")]

Check warning on line 41 in Environment_Engine/Modify/OffsetOpenings.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Environment_Engine/Modify/OffsetOpenings.cs#L41

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
[Output("panel", "An Environment Panel object")]

Check warning on line 42 in Environment_Engine/Modify/OffsetOpenings.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Environment_Engine/Modify/OffsetOpenings.cs#L42

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
public static Panel OffsetOpenings(Panel panel)
public static Panel OffsetOpenings(this Panel panel)

Check warning on line 43 in Environment_Engine/Modify/OffsetOpenings.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Environment_Engine/Modify/OffsetOpenings.cs#L43

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
if(panel == null)
{
Expand Down
2 changes: 1 addition & 1 deletion Environment_Engine/Query/IsLeft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
/**** Public Methods ****/
/***************************************************/

[Description("Determine whether a point falls on the left side of a line or not. The left side is defined as the left hand side of the line when standing on the start point and looking at the end point")]

Check warning on line 41 in Environment_Engine/Query/IsLeft.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Environment_Engine/Query/IsLeft.cs#L41

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
[Input("line", "The line to determine directionality")]

Check warning on line 42 in Environment_Engine/Query/IsLeft.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Environment_Engine/Query/IsLeft.cs#L42

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
[Input("check", "The point to check against")]

Check warning on line 43 in Environment_Engine/Query/IsLeft.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Environment_Engine/Query/IsLeft.cs#L43

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
[Output("isLeft", "True if the point is on the left hand side of the line. False if it is on the line or on the right hand side")]

Check warning on line 44 in Environment_Engine/Query/IsLeft.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Environment_Engine/Query/IsLeft.cs#L44

Documentation attribute should end with grammatically correct punctuation (., !, or ?) - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/AttributeHasEndingPunctuation
public static bool IsLeft(Line line, Point check)
public static bool IsLeft(this Line line, Point check)
{
if(line == null)
{
Expand Down
12 changes: 6 additions & 6 deletions Geometry_Engine/Compute/Eigenvalues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**** Public Methods ****/
/***************************************************/

public static double[] Eigenvalues(this TransformMatrix matrix, double tolerance = Tolerance.Distance)

Check warning on line 36 in Geometry_Engine/Compute/Eigenvalues.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Geometry_Engine/Compute/Eigenvalues.cs#L36

Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Method must contain an Output or MultiOutput attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasOutputAttribute
{
return matrix.Matrix.Eigenvalues(tolerance);
}
Expand Down Expand Up @@ -73,11 +73,11 @@

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

// Solve Ax^3 + Bx^2 + Cx + D = 0 following http://www.code-kings.com/2013/11/cubic-equation-roots-in-csharp-code.html
private static double[] RealCubicRoots(double A, double B, double C, double D)
// Solve ax^3 + bx^2 + cx + d = 0 following http://www.code-kings.com/2013/11/cubic-equation-roots-in-csharp-code.html
private static double[] RealCubicRoots(double a, double b, double c, double d)
{
double f = (3 * C / A - B * B / (A * A)) / 3;
double g = (2 * Math.Pow(B, 3) / Math.Pow(A, 3) - (9 * B * C) / Math.Pow(A, 2) + 27 * D / A) / 27;
double f = (3 * c / a - b * b / (a * a)) / 3;
double g = (2 * Math.Pow(b, 3) / Math.Pow(a, 3) - (9 * b * c) / Math.Pow(a, 2) + 27 * d / a) / 27;
double h = Math.Pow(g, 2) * 0.25 + Math.Pow(f, 3) / 27;

if (h <= 0)
Expand All @@ -88,8 +88,8 @@
double l = -j;
double m = Math.Cos(k / 3);
double n = Math.Pow(3, 0.5) * Math.Sin(k / 3);
double p = -B / (3 * A);
double x = 2 * j * Math.Cos(k / 3) - B / (3 * A);
double p = -b / (3 * a);
double x = 2 * j * Math.Cos(k / 3) - b / (3 * a);
double y = l * (m + n) + p;
double z = l * (m - n) + p;
return new double[] { x, y, z };
Expand Down
64 changes: 64 additions & 0 deletions Geometry_Engine/Compute/PointGrid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2025, 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 <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Geometry;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using BH.oM.Base.Attributes;
using BH.oM.Quantities.Attributes;

namespace BH.Engine.Geometry
{
public static partial class Compute
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[PreviousVersion("8.1", "BH.Engine.Geometry.Create.PointGrid(BH.oM.Geometry.Point, BH.oM.Geometry.Vector, BH.oM.Geometry.Vector, System.Int32, System.Int32)")]
[Description("Creates a two dimensional grid of points along the two provided vectors.")]
[Input("start", "Base point of the grid.")]
[Input("dir1", "First direction of the grid. Spacing in this direction will be determined by the length of the vector.")]
[Input("dir2", "Second direction of the grid. Spacing in this direction will be determined by the length of the vector.")]
[Input("nbPts1", "Number of points along the first direction.")]
[Input("nbPts2", "Number of points along the second direction.")]
[Output("grid", "The created grid of points as a nested list, where each inner list corresponds to all values along the first vector.")]
public static List<List<Point>> PointGrid(Point start, Vector dir1, Vector dir2, int nbPts1, int nbPts2)
{
List<List<Point>> pts = new List<List<Point>>();
for (int i = 0; i < nbPts1; i++)
{
List<Point> row = new List<Point>();
for (int j = 0; j < nbPts2; j++)
{
row.Add(start + i * dir1 + j * dir2);
}
pts.Add(row);
}

return pts;
}

/***************************************************/
}
}
File renamed without changes.
Loading