Wrap more classes into ifcopenshell:: namespace

This commit is contained in:
Thomas Krijnen
2026-08-08 13:58:39 +02:00
parent 2c47c9d4fa
commit 02481b3247
149 changed files with 678 additions and 627 deletions
+26 -26
View File
@@ -1606,7 +1606,7 @@ std::map<Point_2, std::vector<Point_2>> snap_points_to_box_axes(
const CenterLineGraphData& graph,
const std::vector<MergedBoxRecord>& boxes,
const K::FT& max_projection_distance,
logger& logger) {
ifcopenshell::logger& logger) {
std::vector<Point_2> snapped_points(graph.points.size());
for (size_t i = 0; i < graph.points.size(); ++i) {
@@ -1693,7 +1693,7 @@ std::map<Point_2, std::vector<Point_2>> snap_points_to_box_axes(
message << "Snapping distance exceeds maximum distance: "
<< std::sqrt(CGAL::to_double((snapped_points[i] - best.projection).squared_length()))
<< " > " << max_projection_distance;
logger.message(::logger::LOG_WARNING, "ARR", 1, message.str());
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 1, message.str());
}
}
@@ -1720,7 +1720,7 @@ Graph2D<K> join_segment_runs(
const std::map<Point_2, std::vector<Point_2>>& line_graph,
const std::map<Point_2, std::pair<Point_2, Point_2>>& midpoint_to_segment,
const K::FT& max_projection_distance,
logger& logger) {
ifcopenshell::logger& logger) {
auto graph = make_center_line_graph_data(line_graph, midpoint_to_segment);
auto runs = runs_from_graph(graph);
runs.erase(std::remove_if(runs.begin(), runs.end(), [](const LineRun& run) {
@@ -2250,7 +2250,7 @@ extend_end_vertices_based_on_input_simple(
const Polygon_list& outer_perimiter,
const K::FT& max_projection_distance,
int pass,
logger& logger)
ifcopenshell::logger& logger)
{
auto max_intersection_distance = max_projection_distance / 4;
@@ -2400,9 +2400,9 @@ extend_end_vertices_based_on_input_simple(
}
}
if (within_any_perimeter) {
logger.message(::logger::LOG_WARNING, "ARR", 2, "Within boundary but no projection or intersection solution was found");
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 2, "Within boundary but no projection or intersection solution was found");
} else {
logger.message(::logger::LOG_WARNING, "ARR", 3, "Point is outside all boundaries");
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 3, "Point is outside all boundaries");
}
return std::optional<Point_2>{};
};
@@ -2417,7 +2417,7 @@ extend_end_vertices_based_on_input_simple(
if (*result == M) {
std::ostringstream message;
message << "Point is already on perimeter (" << M.x() << " " << M.y() << ")";
logger.message(::logger::LOG_NOTICE, "ARR", 4, message.str());
logger.message(ifcopenshell::logger::LOG_NOTICE, "ARR", 4, message.str());
continue;
}
auto d = (M - *result).squared_length();
@@ -2426,7 +2426,7 @@ extend_end_vertices_based_on_input_simple(
std::ostringstream message;
message << "Unable to find projection or intersection point for interior boundary pass "
<< pass << " [round 1] (" << M.x() << " " << M.y() << ")";
logger.message(::logger::LOG_WARNING, "ARR", 5, message.str());
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 5, message.str());
}
}
}
@@ -2442,7 +2442,7 @@ extend_end_vertices_based_on_input_simple(
auto d = CGAL::squared_distance(point, *result);
std::ostringstream message;
message << "Projection or intersection distance: " << std::sqrt(CGAL::to_double(d));
logger.message(::logger::LOG_DEBUG, "ARR", 6, message.str());
logger.message(ifcopenshell::logger::LOG_DEBUG, "ARR", 6, message.str());
validation_segments.emplace_back(to_3d(point), to_3d(*result));
auto inserted_it = std::prev(validation_segments.end());
validation_tree.insert(inserted_it, validation_segments.end());
@@ -2450,7 +2450,7 @@ extend_end_vertices_based_on_input_simple(
std::ostringstream message;
message << "Unable to find projection or intersection point for interior boundary pass "
<< pass << " [round 2] (" << point.x() << " " << point.y() << ")";
logger.message(::logger::LOG_WARNING, "ARR", 7, message.str());
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 7, message.str());
}
}
@@ -2549,7 +2549,7 @@ class Segment_2_less {
}
};
std::vector<K::FT> arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2& left, Arrangement_2& right, logger& logger) {
std::vector<K::FT> arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2& left, Arrangement_2& right, ifcopenshell::logger& logger) {
using Walk_pl = CGAL::Arr_walk_along_line_point_location<Arrangement_2>;
Walk_pl walk_pl(right);
@@ -2631,7 +2631,7 @@ std::vector<K::FT> arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2
if (visited_faces_on_right.count(*v) > 0) {
// Maybe we should be more permissive, try some other points etc.
return_values.push_back(0);
logger.message(::logger::LOG_WARNING, "ARR", 8, "Already visited face on right; skipping point");
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 8, "Already visited face on right; skipping point");
} else {
// convert arr facet to polygon with holes
auto polygon_exterior = circ_to_poly((*v)->outer_ccb());
@@ -2669,7 +2669,7 @@ std::vector<K::FT> arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2
max_deviation_poly_pair = {pwh.outer_boundary(), pwh_right.outer_boundary()};
}
} else {
logger.message(::logger::LOG_WARNING, "ARR", 9, "No intersection; skipping point");
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 9, "No intersection; skipping point");
return_values.push_back(0);
}
}
@@ -2691,7 +2691,7 @@ std::vector<K::FT> arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2
return return_values;
}
void clean_noisy_paths(DebugWriter& debug_output, Arrangement_2& arr, SegmentLookup& segment_lookup, double& threshold, logger& logger) {
void clean_noisy_paths(DebugWriter& debug_output, Arrangement_2& arr, SegmentLookup& segment_lookup, double& threshold, ifcopenshell::logger& logger) {
using SK = CGAL::Simple_cartesian<double>;
CGAL::Cartesian_converter<K, SK> C{};
@@ -2907,7 +2907,7 @@ void clean_noisy_paths(DebugWriter& debug_output, Arrangement_2& arr, SegmentLoo
}
}
if (!removed) {
logger.message(::logger::LOG_WARNING, "ARR", 10, "Unable to locate edge for removal; skipping");
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 10, "Unable to locate edge for removal; skipping");
}
}
@@ -3328,7 +3328,7 @@ class timer {
entry(
std::map<std::string, std::chrono::high_resolution_clock::time_point>::const_iterator start_it,
logger& logger)
ifcopenshell::logger& logger)
: start_it(start_it)
, logger_(&logger) {}
@@ -3338,16 +3338,16 @@ class timer {
auto duration = std::chrono::duration<double, std::milli>(end - start_it.value()->second).count();
std::ostringstream message;
message << "Timing for " << start_it.value()->first << ": " << duration << " ms";
logger_->message(::logger::LOG_PERF, "ARR", 11, message.str());
logger_->message(ifcopenshell::logger::LOG_PERF, "ARR", 11, message.str());
}
}
private:
std::optional<std::map<std::string, std::chrono::high_resolution_clock::time_point>::const_iterator> start_it;
logger* logger_;
ifcopenshell::logger* logger_;
};
timer(logger& logger, bool enabled = true)
timer(ifcopenshell::logger& logger, bool enabled = true)
: logger_(logger)
, enabled_(enabled) {}
@@ -3365,7 +3365,7 @@ class timer {
std::chrono::high_resolution_clock::time_point>
timings_;
logger& logger_;
ifcopenshell::logger& logger_;
bool enabled_;
};
@@ -3385,7 +3385,7 @@ void arrange_cgal_polygons(
svgfill::arrange_polygon_settings settings,
const std::vector<Polygon_2>& input_polygons_,
std::vector<Polygon_2>& output_polygons,
logger& logger,
ifcopenshell::logger& logger,
double polygon_offset_distance = -1.) {
static const double OVERLAP_RESOLUTION_DISTANCE = 1.e-1;
@@ -3613,7 +3613,7 @@ void arrange_cgal_polygons(
for (int i = 0; i < 2; ++i) {
auto it = line_graph.find(e.first);
if (it == line_graph.end()) {
logger.message(::logger::LOG_WARNING, "ARR", 12, "Unable to locate vertex for elimination; skipping");
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 12, "Unable to locate vertex for elimination; skipping");
continue;
}
auto& neighbours = it->second;
@@ -3717,7 +3717,7 @@ void arrange_cgal_polygons(
std::ostringstream message;
message << "Significant difference between cleaned and original arrangement; using original for topology reconstruction: "
<< *it;
logger.message(::logger::LOG_WARNING, "ARR", 13, message.str());
logger.message(ifcopenshell::logger::LOG_WARNING, "ARR", 13, message.str());
fallback_to_line_cleaning_algo_1 = true;
apply_line_cleaning_algo_1();
} else {
@@ -3815,7 +3815,7 @@ bool svgfill::arrange_polygons(
arrange_polygon_settings settings,
const std::vector<svgfill::polygon_2>& polygons,
std::vector<svgfill::polygon_2>& arranged,
logger& logger) {
ifcopenshell::logger& logger) {
std::vector<Polygon_2> cgal_polygons, cgal_polygons_out;
std::transform(polygons.begin(), polygons.end(), std::back_inserter(cgal_polygons), [](auto& poly) {
Polygon_2 result;
@@ -3856,7 +3856,7 @@ int main(int argc, char** argv) {
std::vector<Polygon_2> input_polygons, output;
logger logger;
logger.set_output(&std::cout, &std::cerr);
logger.verbosity(::logger::LOG_PERF);
logger.verbosity(ifcopenshell::logger::LOG_PERF);
if (argc == 2) {
using json = nlohmann::json;
@@ -3865,7 +3865,7 @@ int main(int argc, char** argv) {
file >> jsonData;
size_t i = 0;
for (const auto& item : jsonData.items()) {
logger.message(::logger::LOG_NOTICE, "ARR", 14, "Processing arrangement " + std::to_string(i));
logger.message(ifcopenshell::logger::LOG_NOTICE, "ARR", 14, "Processing arrangement " + std::to_string(i));
i++;
input_polygons.clear();
const auto& polygonsData = item.value();
@@ -137,7 +137,7 @@ bool svgfill::arrange_polygons(
arrange_polygon_settings settings,
const std::vector<polygon_2>& polygons,
std::vector<polygon_2>& arranged,
logger& logger)
ifcopenshell::logger& logger)
{
return provider().api.arrange_polygons(settings, polygons, arranged, logger);
}
+1 -1
View File
@@ -56,7 +56,7 @@ struct api {
const std::string&,
const std::optional<std::string>&,
std::vector<polygon_2>&) = nullptr;
bool (*arrange_polygons)(arrange_polygon_settings, const std::vector<polygon_2>&, std::vector<polygon_2>&, logger&) = nullptr;
bool (*arrange_polygons)(arrange_polygon_settings, const std::vector<polygon_2>&, std::vector<polygon_2>&, ifcopenshell::logger&) = nullptr;
abstract_arrangement* (*create_arrangement)(solver) = nullptr;
void (*destroy_arrangement)(abstract_arrangement*) = nullptr;
};
+2 -2
View File
@@ -41,7 +41,7 @@
#include <optional>
#include <functional>
class logger;
namespace ifcopenshell { class logger; }
namespace svgfill {
typedef std::array<double, 2> point_2;
@@ -134,7 +134,7 @@ namespace svgfill {
double subdivision_factor = 16.;
};
SVGFILL_API bool arrange_polygons(arrange_polygon_settings settings, const std::vector<polygon_2>& polygons, std::vector<polygon_2>& arranged, logger& logger);
SVGFILL_API bool arrange_polygons(arrange_polygon_settings settings, const std::vector<polygon_2>& polygons, std::vector<polygon_2>& arranged, ifcopenshell::logger& logger);
}
#endif