Skip to content
Open
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ if(RF_BUILD_BINDINGS)
add_subdirectory(rooferpy)
endif()

add_subdirectory(roofersharp/cpp)

# EXECUTABLES
if(RF_BUILD_APPS OR RF_BUILD_DOC_HELPER)
add_subdirectory(apps)
Expand Down
3 changes: 3 additions & 0 deletions roofersharp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vs/*
.idea/*
lib/*
3 changes: 3 additions & 0 deletions roofersharp/RooferSharp.Test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/*
obj/*
.idea/*
26 changes: 26 additions & 0 deletions roofersharp/RooferSharp.Test/Model/GeometryPayload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Text.Json.Serialization;

namespace RooferSharp.Test.Model;

public sealed class GeometryPayload
{
[JsonPropertyName("pointsRoof")]
public List<Vec3> PointsRoof { get; set; }

[JsonPropertyName("pointsGround")]
public List<Vec3> PointsGround { get; set; }

[JsonPropertyName("footprintExterior")]
public List<Vec3> FootprintExterior { get; set; }

[JsonPropertyName("footprintInteriors")]
public List<List<Vec3>> FootprintInteriors { get; set; } // null => omitted if you want

public GeometryPayload()
{
PointsRoof = new List<Vec3>();
PointsGround = new List<Vec3>();
FootprintExterior = new List<Vec3>();
FootprintInteriors = null; // keep optional
}
}
11 changes: 11 additions & 0 deletions roofersharp/RooferSharp.Test/Model/TestPayloadExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Numerics;

namespace RooferSharp.Test.Model;

public static class TestPayloadExtensions
{
public static List<Vector3> ToVector3List(this List<Vec3> vec3List)
{
return vec3List.Select(v => new Vector3(v.X, v.Y, v.Z)).ToList();
}
}
28 changes: 28 additions & 0 deletions roofersharp/RooferSharp.Test/Model/Vec3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Numerics;
using System.Text.Json.Serialization;

namespace RooferSharp.Test.Model;

public sealed class Vec3
{
[JsonPropertyName("x")]
public float X { get; set; }

[JsonPropertyName("y")]
public float Y { get; set; }

[JsonPropertyName("z")]
public float Z { get; set; }

public Vec3() { } // for deserialization

public Vec3(float x, float y, float z)
{
X = x; Y = y; Z = z;
}

public Vector3 ToVector3()
{
return new Vector3(X, Y, Z);
}
}
8 changes: 8 additions & 0 deletions roofersharp/RooferSharp.Test/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"RooferSharp.Test": {
"commandName": "Project",
"nativeDebugging": true
}
}
}
43 changes: 43 additions & 0 deletions roofersharp/RooferSharp.Test/RooferSharp.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<Platform>x64</Platform>
<Platforms>x64</Platforms>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.7.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\RooferSharp\RooferSharp.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="testdata\boxBuilding.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="testdata\slantedroof.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions roofersharp/RooferSharp.Test/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Numerics;
using RooferSharp.Test.Model;

namespace RooferSharp.Test;

public class Tests
{
[SetUp]
public void Setup()
{


}

[Test]
public void Test1()
{
var config = new ReconstructionConfig();
config.ClipGround = false;
// example file containing roof points and ground points
var file = File.ReadAllText("testdata/slantedroof.json");
var payload = System.Text.Json.JsonSerializer.Deserialize<GeometryPayload>(file);

Assert.That(payload != null);
var result = RooferSharp.Reconstructor.ReconstructWithGround(config,
payload!.PointsRoof.ToVector3List(),
payload.PointsGround.ToVector3List(),
payload.FootprintExterior.ToVector3List());
var data = result[0];
var polygons = data.GetPolygons();
Assert.That(polygons.Count, Is.GreaterThan(0));
}
}
Loading