Skip to content

Commit

Permalink
Merge branch 'release-0.6.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ipadjen committed Feb 27, 2025
2 parents 98049da + 7e51298 commit 1d3f74a
Show file tree
Hide file tree
Showing 30 changed files with 66 additions and 69 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Changelog
## [0.6.2] - 2025-02-27
### Changed
- Improved inserting surface layer polygons when terrain pc is missing
### Fixed
- Minor bugfixes

## [0.6.1] - 2025-02-06
### Fixed
- Docker image hotfix
Expand Down
2 changes: 0 additions & 2 deletions src/Boundary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Boundary::Boundary()
Boundary::Boundary(const int outputLayerID)
: TopoFeature(outputLayerID), m_sideOutputPts() {}

Boundary::~Boundary() = default;

//-- Static member definition
std::vector<Point_3> Boundary::s_outerPts;
double Boundary::s_outerBndHeight;
Expand Down
2 changes: 1 addition & 1 deletion src/Boundary.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Boundary : public TopoFeature {
public:
Boundary();
Boundary(const int outputLayerID);
virtual ~Boundary();
virtual ~Boundary() = default;

static void set_bnd_poly(Polygon_2& bndPoly, Polygon_2& pcBndPoly, Polygon_2& startBufferPoly);
static void set_bounds_to_buildings_pc(Point_set_3& pointCloud, const Polygon_2& pcBndPoly);
Expand Down
2 changes: 0 additions & 2 deletions src/BoundingRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@
#include <CGAL/convex_hull_2.h>
#include <CGAL/Delaunay_triangulation_2.h>

BoundingRegion::BoundingRegion() = default;
BoundingRegion::BoundingRegion(std::shared_ptr<Config::ReconRegion> reconRegion)
: m_reconSettings(reconRegion)
{}
BoundingRegion::~BoundingRegion() = default;

//-- Operators to read bounded region if explicitly defined in config
// called through boost:apply_visitor
Expand Down
4 changes: 2 additions & 2 deletions src/BoundingRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class BoundingRegion {
CDT m_projCDT;
std::shared_ptr<const Config::ReconRegion> m_reconSettings;

BoundingRegion();
BoundingRegion() = default;
BoundingRegion(std::shared_ptr<Config::ReconRegion> reconRegion);
~BoundingRegion();
~BoundingRegion() = default;

void operator()(double radius);
void operator()(Polygon_2& poly);
Expand Down
8 changes: 5 additions & 3 deletions src/Building.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ Building::Building(const Polygon_with_attr& poly)
m_ptsPtr(std::make_shared<Point_set_3>()), m_hasFailed(false), m_reconSettings(nullptr) {}
// 'true' here to check for polygon simplicity

Building::~Building() = default;

void Building::insert_point(const Point_3& pt) {
m_ptsPtr->insert(pt);
}
Expand Down Expand Up @@ -284,6 +282,10 @@ PointSet3Ptr Building::get_points() const {
return m_ptsPtr;
}

std::string Building::get_lod() const {
return m_reconSettings->lod;
}

void Building::get_cityjson_info(nlohmann::json& b) const {
b["type"] = "Building";
// b["attributes"];
Expand All @@ -294,7 +296,7 @@ void Building::get_cityjson_info(nlohmann::json& b) const {
b["attributes"]["measuredHeight"] = m_elevation - geomutils::avg(m_groundElevations[0]);
}

void Building::get_cityjson_semantics(nlohmann::json& g) const { // Temp for checking CGAL mesh properties
void Building::get_cityjson_semantics(nlohmann::json& g) const {
Face_property semantics;
auto semanticsMap = m_mesh.property_map<face_descriptor, std::string>("f:semantics");
if (semanticsMap.has_value()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Building.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Building : public PolyFeature {
Building();
Building(const nlohmann::json& poly);
Building(const Polygon_with_attr& poly);
~Building();
virtual ~Building() = default;

static void alpha_wrap_all(const BuildingsPtr& buildings, Mesh& newMesh);

Expand Down Expand Up @@ -65,6 +65,7 @@ class Building : public PolyFeature {
void set_to_zero_terrain();
double sq_max_dim();
PointSet3Ptr get_points() const;
std::string get_lod() const;

virtual void get_cityjson_info(nlohmann::json& b) const override;
virtual void get_cityjson_semantics(nlohmann::json& g) const override;
Expand Down
2 changes: 0 additions & 2 deletions src/ImportedBuilding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ ImportedBuilding::ImportedBuilding(Mesh& mesh)
mesh.clear();
}

ImportedBuilding::~ImportedBuilding() = default;

/*
* Calculate building elevation without reconstruction.
* Defined as the highest point
Expand Down
2 changes: 1 addition & 1 deletion src/ImportedBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ImportedBuilding : public Building {
ImportedBuilding(std::unique_ptr<nlohmann::json>& buildingJson,
PointSet3Ptr& importedBuildingPts);
ImportedBuilding(Mesh& mesh);
~ImportedBuilding();
~ImportedBuilding() = default;

virtual void calc_elevation() override;
virtual void reconstruct() override;
Expand Down
8 changes: 5 additions & 3 deletions src/Map3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
#include "Sides.h"
#include "Top.h"

Map3d::Map3d() = default;
Map3d::~Map3d() = default;

void Map3d::reconstruct() {
//-- Prepare features
this->set_features();
Expand Down Expand Up @@ -321,6 +318,11 @@ void Map3d::set_bnd() {
Boundary::set_bounds_to_terrain_pc(m_pointCloud.get_terrain(),
bndPoly, pcBndPoly, startBufferPoly);

// update the terrain DT for interpolation
m_dt.clear();
m_dt.insert(m_pointCloud.get_terrain().points().begin(),
m_pointCloud.get_terrain().points().end());

//-- Check feature scope for surface layers now that the full domain is known
for (auto& f: m_surfaceLayersPtr) {
f->check_feature_scope(bndPoly);
Expand Down
4 changes: 2 additions & 2 deletions src/Map3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

class Map3d {
public:
Map3d();
~Map3d();
Map3d() = default;
~Map3d() = default;

void reconstruct();

Expand Down
3 changes: 0 additions & 3 deletions src/PointCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
#include <CGAL/Straight_skeleton_builder_2.h>
#include <CGAL/compute_outer_frame_margin.h>

PointCloud::PointCloud() = default;
PointCloud::~PointCloud() = default;

void PointCloud::random_thin_pts() {
if (Config::get().terrainThinning > 0 + global::smallnum) {
std::cout <<"\nRandomly thinning terrain points" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/PointCloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

class PointCloud {
public:
PointCloud();
~PointCloud();
PointCloud() = default;
~PointCloud() = default;

void random_thin_pts();
void create_flat_terrain(const PolyFeaturesPtr& lsFeatures);
Expand Down
2 changes: 0 additions & 2 deletions src/PolyFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ PolyFeature::PolyFeature(const Polygon_with_attr& poly, const bool checkSimplici
PolyFeature::PolyFeature(const Polygon_with_attr& poly, const int outputLayerID)
: PolyFeature(poly, false, outputLayerID) {}

PolyFeature::~PolyFeature() = default;

int PolyFeature::s_numOfPolyFeatures = 0;

void PolyFeature::calc_footprint_elevation_nni(const DT& dt) {
Expand Down
2 changes: 1 addition & 1 deletion src/PolyFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PolyFeature : public TopoFeature {
PolyFeature(const Polygon_with_attr& poly, const bool checkSimplicity = false);
PolyFeature(const Polygon_with_attr& poly, const bool checkSimplicity, const int outputLayerID);
PolyFeature(const Polygon_with_attr& poly, const int outputLayerID);
virtual ~PolyFeature();
virtual ~PolyFeature() = default;

void calc_footprint_elevation_nni(const DT& dt);
#ifndef NDEBUG
Expand Down
41 changes: 23 additions & 18 deletions src/ReconstructedBuilding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ ReconstructedBuilding::ReconstructedBuilding(const std::shared_ptr<ImportedBuild
m_outputLayerID = importedBuilding->get_output_layer_id();
}

ReconstructedBuilding::~ReconstructedBuilding() = default;

/*
* Calculate building elevation without mesh reconstruction
*/
Expand Down Expand Up @@ -338,22 +336,29 @@ void ReconstructedBuilding::get_cityjson_info(nlohmann::json& b) const {
}

void ReconstructedBuilding::get_cityjson_semantics(nlohmann::json& g) const { // Temp for checking CGAL mesh properties
Face_property semantics;
auto semanticsMap = m_mesh.property_map<face_descriptor, std::string>("f:semantics");
if (semanticsMap.has_value()) {
semantics = semanticsMap.value();
} else throw city4cfd_error("Semantic property map not found!");

std::unordered_map<std::string, int> surfaceId;
surfaceId["RoofSurface"] = 0; g["semantics"]["surfaces"][0]["type"] = "RoofSurface";
surfaceId["GroundSurface"] = 1; g["semantics"]["surfaces"][1]["type"] = "GroundSurface";
surfaceId["WallSurface"] = 2; g["semantics"]["surfaces"][2]["type"] = "WallSurface";

for (auto faceIdx : m_mesh.faces()) {
auto it = surfaceId.find(semantics[faceIdx]);
if (it == surfaceId.end()) throw city4cfd_error("Could not find semantic attribute!");

g["semantics"]["values"][faceIdx.idx()] = it->second;
// for now handle only LoD1.2 with semantics, LoD1.3 and LoD2.2 loses information
// when making final repairs
if (m_reconSettings->lod == "1.2") {
Face_property semantics;
auto semanticsMap = m_mesh.property_map<face_descriptor, std::string>("f:semantics");
if (semanticsMap.has_value()) {
semantics = semanticsMap.value();
} else throw city4cfd_error("Semantic property map not found!");

std::unordered_map<std::string, int> surfaceId;
surfaceId["RoofSurface"] = 0;
g["semantics"]["surfaces"][0]["type"] = "RoofSurface";
surfaceId["GroundSurface"] = 1;
g["semantics"]["surfaces"][1]["type"] = "GroundSurface";
surfaceId["WallSurface"] = 2;
g["semantics"]["surfaces"][2]["type"] = "WallSurface";

for (auto faceIdx: m_mesh.faces()) {
auto it = surfaceId.find(semantics[faceIdx]);
if (it == surfaceId.end()) throw city4cfd_error("Could not find semantic attribute!");

g["semantics"]["values"][faceIdx.idx()] = it->second;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ReconstructedBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ReconstructedBuilding : public Building {
ReconstructedBuilding(const nlohmann::json& poly);
ReconstructedBuilding(const Polygon_with_attr& poly);
ReconstructedBuilding(const std::shared_ptr<ImportedBuilding>& importedBuilding);
~ReconstructedBuilding();
~ReconstructedBuilding() = default;

const std::vector<roofer::Mesh>& get_roofer_meshes() const;

Expand Down
2 changes: 0 additions & 2 deletions src/Sides.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ Sides::Sides(const int outputLayerID)
: Boundary(outputLayerID) {
}

Sides::~Sides() = default;

void Sides::reconstruct() {
std::vector<Mesh::vertex_index> meshVertexSide;

Expand Down
2 changes: 1 addition & 1 deletion src/Sides.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class Sides : public Boundary {
public:
Sides(const int outputLayerID);
~Sides();
~Sides() = default;

virtual void reconstruct() override;

Expand Down
2 changes: 0 additions & 2 deletions src/SurfaceLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ SurfaceLayer::SurfaceLayer(const Polygon_with_attr& poly)
SurfaceLayer::SurfaceLayer(const Polygon_with_attr& poly, const int outputLayerID)
: PolyFeature(poly, outputLayerID) {}

SurfaceLayer::~SurfaceLayer() = default;

void SurfaceLayer::check_feature_scope(const Polygon_2& bndPoly) {
//-- Exclude all polygons that have at least one
//-- vertex outside the domain
Expand Down
2 changes: 1 addition & 1 deletion src/SurfaceLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SurfaceLayer : public PolyFeature {
SurfaceLayer(const nlohmann::json& poly, const int outputLayerID);
SurfaceLayer(const Polygon_with_attr& poly);
SurfaceLayer(const Polygon_with_attr& poly, const int outputLayerID);
~SurfaceLayer();
~SurfaceLayer() = default;

void check_feature_scope(const Polygon_2& bndPoly);

Expand Down
2 changes: 0 additions & 2 deletions src/Terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ Terrain::Terrain(int pid)
m_constrainedPolys(), m_vertexFaceMap(), m_extraConstrainedEdges(),
m_searchTree() {}

Terrain::~Terrain() = default;

void Terrain::set_cdt(const Point_set_3& pointCloud) {
Converter<EPICK, EPECK> to_exact;

Expand Down
2 changes: 1 addition & 1 deletion src/Terrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Terrain : public TopoFeature {
using TopoFeature::TopoFeature;
Terrain();
Terrain(int pid);
~Terrain();
~Terrain() = default;

void set_cdt(const Point_set_3 &pointCloud);
void prep_constraints(const PolyFeaturesPtr& features, Point_set_3& pointCloud);
Expand Down
2 changes: 0 additions & 2 deletions src/Top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
Top::Top(const int outputLayerID)
: Boundary(outputLayerID) {}

Top::~Top() = default;

void Top::reconstruct() {
std::vector<Mesh::vertex_index> meshVertexTop;

Expand Down
2 changes: 1 addition & 1 deletion src/Top.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class Top : public Boundary {
public:
Top(const int outputLayerID);
~Top();
~Top() = default;

virtual void reconstruct() override;

Expand Down
2 changes: 0 additions & 2 deletions src/TopoFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ TopoFeature::TopoFeature(int outputLayerID)
if (m_outputLayerID >= s_numOfOutputLayers) s_numOfOutputLayers = m_outputLayerID + 1;
}

TopoFeature::~TopoFeature() = default;

int TopoFeature::s_numOfOutputLayers = 0;

void TopoFeature::add_recon_region_output_layers(const int numLayers) {
Expand Down
2 changes: 1 addition & 1 deletion src/TopoFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TopoFeature {
TopoFeature();
TopoFeature(std::string pid);
TopoFeature(int outputLayerID);
virtual ~TopoFeature();
virtual ~TopoFeature() = default;

static void add_recon_region_output_layers(const int numLayers);
static int get_num_output_layers();
Expand Down
14 changes: 8 additions & 6 deletions src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void IO::output_cityjson(const OutputFeaturesPtr& allFeatures) {
nlohmann::json j;

j["type"] = "CityJSON";
j["version"] = "1.0";
j["version"] = "2.0";
j["metadata"] = {};
std::vector<double> bbox = Boundary::get_domain_bbox();
j["metadata"]["geographicalExtent"] = Boundary::get_domain_bbox();
Expand All @@ -414,7 +414,12 @@ void IO::output_cityjson(const OutputFeaturesPtr& allFeatures) {

//-- Get feature geometry
nlohmann::json g;
IO::get_cityjson_geom(f->get_mesh(), g, dPts, f->get_cityjson_primitive());
g["type"] = f->get_cityjson_primitive();
// grab lod information for buildings
auto derivedClass = std::dynamic_pointer_cast<Building>(f);
if (derivedClass) g["lod"] = derivedClass->get_lod();

IO::get_cityjson_geom(f->get_mesh(), g, dPts);

//-- Get feature semantics
f->get_cityjson_semantics(g);
Expand Down Expand Up @@ -483,10 +488,7 @@ void IO::get_stl_pts(Mesh& mesh, std::string& fs) {
}
}

void IO::get_cityjson_geom(const Mesh& mesh, nlohmann::json& g, std::unordered_map<std::string, int>& dPts,
std::string primitive) {
g["type"] = primitive;
g["lod"] = "1.2"; //hardcoded for now
void IO::get_cityjson_geom(const Mesh& mesh, nlohmann::json& g, std::unordered_map<std::string, int>& dPts) {
g["boundaries"];
for (auto face: mesh.faces()) {
if (IO::is_degen(mesh, face)) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace IO {

void get_obj_pts(const Mesh& mesh, std::string& fs, std::string& bs, std::unordered_map<std::string, int>& dPts);
void get_stl_pts(Mesh& mesh, std::string& fs);
void get_cityjson_geom(const Mesh& mesh, nlohmann::json& g, std::unordered_map<std::string, int>& dPts, std::string primitive);
void get_cityjson_geom(const Mesh& mesh, nlohmann::json& g, std::unordered_map<std::string, int>& dPts);

bool not_same(std::vector<int> idxLst);
bool is_degen(const Mesh& mesh, Mesh::Face_index face);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <boost/algorithm/string/predicate.hpp>

std::string CITY4CFD_VERSION = "0.6.1";
std::string CITY4CFD_VERSION = "0.6.2";

void printWelcome() {
auto logo{
Expand Down

0 comments on commit 1d3f74a

Please sign in to comment.