diff --git a/Components/GH_postArray.cs b/Components/GH_postArray.cs
index fc21027..73c1d0c 100644
--- a/Components/GH_postArray.cs
+++ b/Components/GH_postArray.cs
@@ -53,7 +53,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
{"windRose", windParams},
{"type", "comfort"},
{"roughness", roughness},
- {"comfortScale", "lawson_lddc"}
+ {"comfortScale", "lawson_2001"}
};
string bodyJson = JsonConvert.SerializeObject(body);
DA.SetData(0, bodyJson);
diff --git a/Components/GH_terrainArrays.cs b/Components/GH_terrainArrays.cs
index d446450..fc94fb0 100644
--- a/Components/GH_terrainArrays.cs
+++ b/Components/GH_terrainArrays.cs
@@ -40,6 +40,8 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager
{
pManager.AddTextParameter("Height Dictionary", "HeightDict", "HeightDict", GH_ParamAccess.item);
pManager.AddMeshParameter("Analysis Mesh", "AnalysisMesh", "AnalysisMesh", GH_ParamAccess.item);
+ pManager.AddGenericParameter("Debug", "Debug", "Debug", GH_ParamAccess.item);
+
}
@@ -59,7 +61,9 @@ protected override void SolveInstance(IGH_DataAccess DA)
var rayTerrain = HitPointsHeight(gridPoints, terrainToMesh);
Rhino.Geometry.Mesh ProbMesh = CreateMeshFromGridPoints(HitPoints(analysisPoints, terrainToMesh),201,201);
-
+ //Rhino.Geometry.Mesh ProbMesh = CreateMeshFromGridPoints(HitPoints(analysisPoints, terrainToMesh), 200, 200);
+
+
var rayTerrainAndBuilding = HitPointsHeight(gridPoints, terrainAndBuildingsToMesh);
double apiMin = rayTerrainAndBuilding.Min();
@@ -101,6 +105,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
DA.SetData(0, jsonString);
DA.SetData(1, ProbMesh);
+ //DA.SetDataList(2, gridPoints);
}
diff --git a/Helpers/MeshHelper.cs b/Helpers/MeshHelper.cs
index b0a774e..5f16755 100644
--- a/Helpers/MeshHelper.cs
+++ b/Helpers/MeshHelper.cs
@@ -34,14 +34,21 @@ public static Rhino.Geometry.Mesh Remesh(IGH_GeometricGoo goo)
return getMesh[0].Mesh();
}
+ ///
+ /// Get the rectangle to generate the grids
+ /// The rectangle is 750 X 750
+ /// https://app.autodeskforma.com/forma-embedded-view-sdk/docs/types/predictive_analysis.HeightMaps.html
+ ///
+ ///
+ ///
public static Rectangle3d GetBase(Rhino.Geometry.Mesh mesh)
{
BoundingBox box = mesh.GetBoundingBox(false);
-
- double zOffset = 100;
+
+ double zOffset = 100;
Point3d center = new Point3d((box.Min.X + box.Max.X) / 2, (box.Min.Y + box.Max.Y) / 2, box.Max.Z + zOffset);
- double length = 500;
- double width = 500;
+ double length = 750;
+ double width = 750;
Point3d rectStart = new Point3d(center.X - length / 2, center.Y - width / 2, center.Z);
Point3d rectEnd = new Point3d(center.X + length / 2, center.Y + width / 2, center.Z);
Rectangle3d rect = new Rectangle3d(new Plane(center, Vector3d.ZAxis), rectStart, rectEnd);
@@ -49,25 +56,27 @@ public static Rectangle3d GetBase(Rhino.Geometry.Mesh mesh)
return rect;
}
+ ///
+ /// Gets the points for the large grid
+ ///
+ /// Base rectangle
+ ///
public static Point3d[] GetPoints(Rectangle3d rect)
{
- int divisions = (int)Math.Sqrt(250000) - 1;
- double width = rect.Width;
- double height = rect.Height;
- double spacingX = width / divisions;
- double spacingY = height / divisions;
+ int divisions = 500;
+ double spacingX = rect.Width / (divisions - 1);
+ double spacingY = rect.Height / (divisions - 1);
- int arrayLength = (divisions + 1) * (divisions + 1);
+ int arrayLength = divisions * divisions;
Point3d[] points = new Point3d[arrayLength];
- for (int i = 0; i <= divisions; i++)
+ for (int i = 0; i < divisions; i++)
{
- for (int j = 0; j <= divisions; j++)
+ for (int j = 0; j < divisions; j++)
{
-
double x = rect.Corner(0).X + (j * spacingX);
double y = rect.Corner(0).Y + (i * spacingY);
Point3d pt = new Point3d(x, y, rect.Corner(0).Z);
- int index = (i * (divisions + 1)) + j;
+ int index = (i * divisions) + j;
points[index] = pt;
}
}
@@ -75,36 +84,46 @@ public static Point3d[] GetPoints(Rectangle3d rect)
return points;
}
-
+ ///
+ /// Get the analysis points for the interest area
+ /// https://app.autodeskforma.com/forma-embedded-view-sdk/docs/types/predictive_analysis.HeightMaps.html
+ ///
+ ///
+ ///
public static Point3d[] GetPointsAnalysis(Rectangle3d rect)
{
-
Point3d center = new Point3d(
- (rect.Corner(0).X + rect.Corner(2).X) / 2,
- (rect.Corner(0).Y + rect.Corner(2).Y) / 2,
- rect.Corner(0).Z);
+ (rect.Corner(0).X + rect.Corner(2).X) / 2,
+ (rect.Corner(0).Y + rect.Corner(2).Y) / 2,
+ rect.Corner(0).Z);
+
+ double desiredLength = 300; // Total length in x
+ double desiredWidth = 300; // Total length in y
+ int desiredPointsX = 201; // Desired number of points in x
+ int desiredPointsY = 201; // Desired number of points in y
- double desiredLength = 200;
- double desiredWidth = 200;
+ double spacingX = desiredLength / (desiredPointsX - 1); // Spacing between points in x
+ double spacingY = desiredWidth / (desiredPointsY - 1); // Spacing between points in y
- Point3d newRectStart = new Point3d(center.X - desiredLength / 2, center.Y - desiredWidth / 2, center.Z);
- Point3d newRectEnd = new Point3d(center.X + desiredLength / 2, center.Y + desiredWidth / 2, center.Z);
+ int divisionsX = desiredPointsX; // Number of divisions in x
+ int divisionsY = desiredPointsY; // Number of divisions in y
+
+ double actualLength = spacingX * (divisionsX - 1); // Actual total length in x
+ double actualWidth = spacingY * (divisionsY - 1); // Actual total length in y
+
+ Point3d newRectStart = new Point3d(center.X - actualLength / 2, center.Y - actualWidth / 2, center.Z);
+ Point3d newRectEnd = new Point3d(center.X + actualLength / 2, center.Y + actualWidth / 2, center.Z);
Rectangle3d newRect = new Rectangle3d(new Plane(center, Vector3d.ZAxis), newRectStart, newRectEnd);
- int divisions = (int)Math.Sqrt(40000);
- double width = newRect.Width;
- double height = newRect.Height;
- double spacingX = width / divisions;
- double spacingY = height / divisions;
- Point3d[] points = new Point3d[(divisions + 1) * (divisions + 1)]; // Adjust for one extra in each dimension
+ Point3d[] points = new Point3d[desiredPointsX * desiredPointsY];
- for (int i = 0; i <= divisions; i++)
+ for (int i = 0; i < divisionsY; i++)
{
- for (int j = 0; j <= divisions; j++)
+ for (int j = 0; j < divisionsX; j++)
{
double x = newRect.Corner(0).X + (j * spacingX);
double y = newRect.Corner(0).Y + (i * spacingY);
- points[i * (divisions + 1) + j] = new Point3d(x, y, newRect.Corner(0).Z); // Assuming flat Z
+ points[i * divisionsX + j] = new Point3d(x, y, newRect.Corner(0).Z);
}
}
@@ -112,8 +131,6 @@ public static Point3d[] GetPointsAnalysis(Rectangle3d rect)
}
-
-
public static Mesh CreateMeshFromGridPoints(Point3d[] points, int gridWidth, int gridHeight)
{
if (points == null || points.Length == 0)
diff --git a/Supporting Grasshopper Scripts/forma-api.gh b/Supporting Grasshopper Scripts/forma-api.gh
index bb44df3..c4c0329 100644
Binary files a/Supporting Grasshopper Scripts/forma-api.gh and b/Supporting Grasshopper Scripts/forma-api.gh differ
diff --git a/Supporting Grasshopper Scripts/rhino/sample.3dm b/Supporting Grasshopper Scripts/rhino/sample.3dm
index 21fc56d..e9f2dbb 100644
Binary files a/Supporting Grasshopper Scripts/rhino/sample.3dm and b/Supporting Grasshopper Scripts/rhino/sample.3dm differ
diff --git a/Supporting Grasshopper Scripts/rhino/sample.3dm.rhl b/Supporting Grasshopper Scripts/rhino/sample.3dm.rhl
deleted file mode 100644
index 4ded24c..0000000
--- a/Supporting Grasshopper Scripts/rhino/sample.3dm.rhl
+++ /dev/null
@@ -1,3 +0,0 @@
-ARZE
-DK-PF2JSP4F
-Friday, February 16, 2024
\ No newline at end of file
diff --git a/Supporting Grasshopper Scripts/rhino/sample.3dmbak b/Supporting Grasshopper Scripts/rhino/sample.3dmbak
index 4268a11..0a2360a 100644
Binary files a/Supporting Grasshopper Scripts/rhino/sample.3dmbak and b/Supporting Grasshopper Scripts/rhino/sample.3dmbak differ