Skip to content

Commit

Permalink
Update core and val3dity with cgal60
Browse files Browse the repository at this point in the history
  • Loading branch information
ipadjen committed Oct 2, 2024
1 parent 07bdc1a commit 93d1b63
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void Config::set_config(nlohmann::json& j) {
//- Domain boundaries
Config::get().set_region(domainBndConfig, "domain_bnd", j);
// Define domain type if using BPG
if (domainBndConfig.type() == typeid(bool)) {
if (std::holds_alternative<bool>(domainBndConfig)) {
if (j.contains("flow_direction"))
flowDirection = Vector_2(j["flow_direction"][0], j["flow_direction"][1]);

Expand All @@ -165,13 +165,13 @@ void Config::set_config(nlohmann::json& j) {
}

// Set domain side and top
if (domainBndConfig.type() == typeid(Polygon_2)) {
Polygon_2 poly = boost::get<Polygon_2>(domainBndConfig);
if (std::holds_alternative<Polygon_2>(domainBndConfig)) {
Polygon_2 poly = std::get<Polygon_2>(domainBndConfig);
numSides = poly.size();
for (int i = 0; i < poly.size(); ++i) {
outputSurfaces.emplace_back("Side_" + std::to_string(i % poly.size()));
}
} else if (domainBndConfig.type() == typeid(double) || bpgDomainType != RECTANGLE) {
} else if (std::holds_alternative<double>(domainBndConfig) || bpgDomainType != RECTANGLE) {
outputSurfaces.emplace_back("Sides");
} else if (bpgDomainType == RECTANGLE) { // Expand output surfaces with front and back
numSides = 4;
Expand Down Expand Up @@ -327,7 +327,7 @@ void Config::set_config(nlohmann::json& j) {
}

//-- influRegion and domainBndConfig flow control
void Config::set_region(boost::variant<bool, double, Polygon_2>& regionType,
void Config::set_region(std::variant<bool, double, Polygon_2>& regionType,
const std::string regionName,
nlohmann::json& j) {
if (j[regionName].is_string()) { // Search for GeoJSON polygon
Expand Down
6 changes: 3 additions & 3 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Config {
public:
void validate(nlohmann::json& j);
void set_config(nlohmann::json& j);
void set_region(boost::variant<bool, double, Polygon_2>& regionType,
void set_region(std::variant<bool, double, Polygon_2>& regionType,
const std::string regionName,
nlohmann::json& j);
static void write_to_log(const std::string& msg);
Expand All @@ -65,7 +65,7 @@ class Config {
//-- Domain setup
Point_2 pointOfInterest;
double topHeight = 0.;
boost::variant<bool, double, Polygon_2> domainBndConfig;
std::variant<bool, double, Polygon_2> domainBndConfig;
DomainType bpgDomainType;
bool bpgBlockageRatioFlag = false;
double bpgBlockageRatio = 0.03;
Expand Down Expand Up @@ -134,7 +134,7 @@ class Config {

//-- Struct for reconstruction regions (part of Buildings)
struct ReconRegion{
boost::variant<bool, double, Polygon_2> influRegionConfig;
std::variant<bool, double, Polygon_2> influRegionConfig;
std::string lod;
double bpgInfluExtra = 0.;
bool importAdvantage = true;
Expand Down
8 changes: 4 additions & 4 deletions src/Map3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void Map3d::set_features() {
for (auto& reconRegion : Config::get().reconRegions) {
m_reconRegions.emplace_back(reconRegion);
}
if (Config::get().domainBndConfig.type() == typeid(bool)) m_bndBPG = true;
if (std::holds_alternative<bool>(Config::get().domainBndConfig)) m_bndBPG = true;

//-- Apply area filtering
if (Config::get().minArea > 0.) {
Expand Down Expand Up @@ -256,15 +256,15 @@ void Map3d::set_influ_region() {
//-- Set the reconstruction (influence) regions --//
double maxDim = -1.; // this works if there's one point of interest
for (int i = 0; i < m_reconRegions.size(); ++i) {
if (m_reconRegions[i].m_reconSettings->influRegionConfig.type() == typeid(bool)) {// bool defines BPG request
if (std::holds_alternative<bool>(m_reconRegions[i].m_reconSettings->influRegionConfig)) {// bool defines BPG request
std::cout << "INFO: Reconstruction region "<< i << " not defined in config. "
<< "Calculating with BPG." << std::endl;
if (maxDim < 0.)
maxDim = m_reconRegions[i].calc_influ_region_bpg(m_dt, m_buildingsPtr);
else
m_reconRegions[i].calc_influ_region_bpg(maxDim);
} else
boost::apply_visitor(m_reconRegions[i], Config::get().reconRegions[i]->influRegionConfig);
std::visit(m_reconRegions[i], Config::get().reconRegions[i]->influRegionConfig);
}
// Check if regions get larger with increasing index
for (int i = 0; i < m_reconRegions.size(); ++i) {
Expand Down Expand Up @@ -303,7 +303,7 @@ void Map3d::set_bnd() {
m_domainBnd.calc_bnd_bpg(m_reconRegions.back().get_bounding_region(), m_buildingsPtr);
} else {
//-- Define boundary region with values set in config
boost::apply_visitor(m_domainBnd, Config::get().domainBndConfig);
std::visit(m_domainBnd, Config::get().domainBndConfig);
}
this->bnd_sanity_check(); // Check if outer bnd is larger than the influ region

Expand Down
4 changes: 2 additions & 2 deletions src/PolyFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ bool PolyFeature::flatten_polygon_inner_points(const Point_set_3& pointCloud,
bool& isNextToBuilding) {

typedef CGAL::Straight_skeleton_2<EPICK> Ss;
typedef boost::shared_ptr<CGAL::Polygon_with_holes_2<EPICK>> PolygonPtrWH;
typedef std::shared_ptr<CGAL::Polygon_with_holes_2<EPICK>> PolygonPtrWH;
typedef std::vector<PolygonPtrWH> PolygonPtrVectorWH;

#ifdef CITY4CFD_POLYFEATURE_VERBOSE
Expand All @@ -234,7 +234,7 @@ bool PolyFeature::flatten_polygon_inner_points(const Point_set_3& pointCloud,

std::vector<int> indices;
std::vector<double> originalHeights;
auto buildingPt = pointCloud.property_map<std::shared_ptr<Building>>("building_point").first;
auto buildingPt = pointCloud.property_map<std::shared_ptr<Building>>("building_point").value();
//-- Take tree subset bounded by the polygon
std::vector<Point_3> subsetPts;
Polygon_2 bbox = geomutils::calc_bbox_poly(m_poly.rings().front());
Expand Down
8 changes: 4 additions & 4 deletions src/ReconstructedBuilding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ 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;
bool foundProperty;
boost::tie(semantics, foundProperty) = m_mesh.property_map<face_descriptor, std::string>("f:semantics");
// auto semantics = m_mesh.property_map<face_descriptor, std::string>("f:semantics");
if (!foundProperty) throw city4cfd_error("Semantic property map not found!");
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ namespace linereg {
Segment_2 s(a_2d.target(), b_2d.source());
auto result = CGAL::intersection(l_a, l_b);
if (result) {
if (auto p = boost::get<Point_2>(&*result)) {
if (auto p = std::get<Point_2>(&*result)) {
if (CGAL::squared_distance(*p, s) < snap_threshold) {
double z = -plane.a()/plane.c() * p->x() - plane.b()/plane.c()*p->y() - plane.d()/plane.c();
ring_pts.push_back( Point_3(p->x(), p->y(), z) );
Expand Down
6 changes: 2 additions & 4 deletions thirdparty/val3dity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project( val3dity )



add_definitions(-std=c++14)
add_definitions(-std=c++17)

set( CMAKE_BUILD_TYPE "Release")
set( CMAKE_CXX_FLAGS "-O2" )
Expand All @@ -25,9 +25,7 @@ endif(MSVC)

# CGAL
find_package( CGAL QUIET COMPONENTS )
if ( CGAL_FOUND )
include( ${CGAL_USE_FILE} )
else()
if (NOT CGAL_FOUND )
message(SEND_ERROR "val3dity requires the CGAL library")
return()
endif()
Expand Down

0 comments on commit 93d1b63

Please sign in to comment.