From 61f30dd200c5e61662036d2ef40555de4b21c659 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 8 Aug 2026 17:08:26 +0200 Subject: [PATCH] Silence obvious compiler warnings Generated with the assistance of an AI coding tool. --- src/ifcgeom/converter.cpp | 21 +------- src/ifcgeom/function_item_evaluator.cpp | 12 ++--- src/ifcgeom/function_item_evaluator.h | 2 +- src/ifcgeom/infra_sweep_helper.cpp | 18 ++----- src/ifcgeom/iterator.cpp | 2 +- .../kernels/cgal/cgal_conversion_result.cpp | 31 ++++++----- .../kernels/cgal/cgal_conversion_result.h | 2 +- src/ifcgeom/kernels/cgal/cgal_kernel.cpp | 51 +++++++++++-------- .../kernels/cgal/nef_to_halfspace_tree.h | 2 +- src/ifcgeom/mapping/IfcBooleanResult.cpp | 2 - .../mapping/IfcCenterLineProfileDef.cpp | 2 +- src/ifcgeom/profile_helper.cpp | 14 ++--- src/ifcgeom/representation.cpp | 4 +- src/ifcgeom/taxonomy.cpp | 21 ++------ src/ifcgeom/taxonomy.h | 28 +++++----- src/ifcparse/entity_instance_data.cpp | 13 +++++ src/ifcparse/express.h | 1 - src/ifcparse/file.cpp | 25 ++++++--- src/ifcparse/global_id.cpp | 2 + src/ifcparse/instance_data.h | 8 +-- src/ifcparse/parse.cpp | 30 ++++++++--- src/ifcparse/rocksdb_map_adapter.h | 13 ++++- src/ifcparse/rocksdb_set_view.h | 3 ++ src/ifcparse/si_prefix.h | 2 +- src/serializers/json_serializer.h | 2 +- .../schema_dependent/json_serializer.cpp | 4 +- .../schema_dependent/xml_serializer.cpp | 8 +-- src/serializers/xml_serializer.h | 2 +- 28 files changed, 175 insertions(+), 150 deletions(-) diff --git a/src/ifcgeom/converter.cpp b/src/ifcgeom/converter.cpp index ecc4952700..23c8710ecd 100644 --- a/src/ifcgeom/converter.cpp +++ b/src/ifcgeom/converter.cpp @@ -17,24 +17,6 @@ ifcopenshell::geom::converter::~converter() { delete mapping_; } -namespace { - void substitute_with_box_based_on_density(ifcopenshell::logger& logger, std::vector& items, double& density) { - int nv = 0; - void* box = nullptr; - double volume = 0.; - for (auto& i : items) { - nv += i.shape()->num_vertices(); - volume = i.shape()->bounding_box(box); - } - density = nv / volume; - if (density > 1e5) { - items[0].shape()->set_box(box); - items.erase(items.begin() + 1, items.end()); - logger.notice("GEO", 30, "Substituted element with " + boost::lexical_cast(density) + " vertices / m3 with a bounding box"); - } - } -} - ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for_representation_and_product(taxonomy::ptr representation_node, const express::base product_, const taxonomy::matrix4::ptr& place_) { auto product = product_.as(); @@ -179,7 +161,8 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for const bool no_openings = openings.empty(); const bool disable_opening_subtractions = settings_.get().get(); - const bool above_limit = settings_.get().has() && settings_.get().get() != 0 && openings.size() > settings_.get().get(); + const auto max_voids = settings_.get(); + const bool above_limit = max_voids.has() && max_voids.get() != 0 && openings.size() > static_cast(max_voids.get()); if (above_limit) { logger_.warning("GEO", 403, "Element has more openings than the maximum allowed. Openings will not be processed for this element:", product); diff --git a/src/ifcgeom/function_item_evaluator.cpp b/src/ifcgeom/function_item_evaluator.cpp index 0c55dab7f2..9d4dc4935a 100644 --- a/src/ifcgeom/function_item_evaluator.cpp +++ b/src/ifcgeom/function_item_evaluator.cpp @@ -89,9 +89,9 @@ struct piecewise_fn_evaluator : public fn_evaluator { struct gradient_fn_evaluator : public fn_evaluator { gradient_fn_evaluator(taxonomy::gradient_function::const_ptr fn, const ifcopenshell::geom::settings& settings) : fn_evaluator(settings), - fn_(fn), horizontal_evaluator_(settings, fn->get_horizontal()), - vertical_evaluator_(settings, fn->get_vertical()) + vertical_evaluator_(settings, fn->get_vertical()), + fn_(fn) { start_ = fn_->get_vertical()->start(); } @@ -121,9 +121,9 @@ struct gradient_fn_evaluator : public fn_evaluator { struct cant_fn_evaluator : public fn_evaluator { cant_fn_evaluator(taxonomy::cant_function::const_ptr fn, const ifcopenshell::geom::settings& settings) : fn_evaluator(settings), - fn_(fn), gradient_evaluator_(settings, fn->get_gradient()), - cant_evaluator_(settings, fn->get_cant()) { + cant_evaluator_(settings, fn->get_cant()), + fn_(fn) { start_ = fn_->get_cant()->start(); } @@ -185,9 +185,9 @@ struct cant_fn_evaluator : public fn_evaluator { struct offset_fn_evaluator : public fn_evaluator { offset_fn_evaluator(taxonomy::offset_function::const_ptr fn, const ifcopenshell::geom::settings& settings) : fn_evaluator(settings), - fn_(fn), basis_evaluator_(settings, fn->get_basis()), - offset_evaluator_(settings, fn->get_offset()) { + offset_evaluator_(settings, fn->get_offset()), + fn_(fn) { } fn_evaluator* clone() const override { return new offset_fn_evaluator(*this); } diff --git a/src/ifcgeom/function_item_evaluator.h b/src/ifcgeom/function_item_evaluator.h index 88238239f2..8637b9806f 100644 --- a/src/ifcgeom/function_item_evaluator.h +++ b/src/ifcgeom/function_item_evaluator.h @@ -15,7 +15,7 @@ IFC_GEOM_API std::vector helmert_curve_point(double A0, double A1, doubl /// On the C++ side, the dcast operator take care of this, but dcast is not accessible on the python side. /// @param loop /// @return -static taxonomy::function_item::ptr convert_loop_to_function_item(taxonomy::loop::ptr loop) { +inline taxonomy::function_item::ptr convert_loop_to_function_item(taxonomy::loop::ptr loop) { return ifcopenshell::geom::taxonomy::dcast(loop); } diff --git a/src/ifcgeom/infra_sweep_helper.cpp b/src/ifcgeom/infra_sweep_helper.cpp index 6b12c6177f..babdd89dff 100644 --- a/src/ifcgeom/infra_sweep_helper.cpp +++ b/src/ifcgeom/infra_sweep_helper.cpp @@ -334,10 +334,10 @@ taxonomy::loft::ptr ifcopenshell::geom::make_loft(const ifcopenshell::geom::sett continue; } - const auto& p1 = tag_to_point_on_w1[t]; - const auto& p2 = tag_to_point_on_w2[t]; + const auto& tagged_point_on_w1 = tag_to_point_on_w1[t]; + const auto& tagged_point_on_w2 = tag_to_point_on_w2[t]; - auto p3 = (lerp(p1->ccomponents(), p2->ccomponents(), relative_dist_along) + interpolated_offset).eval(); + auto p3 = (lerp(tagged_point_on_w1->ccomponents(), tagged_point_on_w2->ccomponents(), relative_dist_along) + interpolated_offset).eval(); std::set tags_for_this_point_on_subsequent_profile = {t}; @@ -432,18 +432,6 @@ taxonomy::loft::ptr ifcopenshell::geom::make_loft(const ifcopenshell::geom::sett loft->children.back()->matrix->components() = m; } - auto find_closest = [](const std::vector& v, double target) -> std::vector::const_iterator { - auto it = std::lower_bound(v.begin(), v.end(), target); - - if (it == v.begin()) { - return it; - } - - double after = *it; - double before = *(it - 1); - - return (std::abs(after - target) < std::abs(target - before)) ? it : (it - 1); - }; } return loft; diff --git a/src/ifcgeom/iterator.cpp b/src/ifcgeom/iterator.cpp index b3f385c4cf..577668d715 100644 --- a/src/ifcgeom/iterator.cpp +++ b/src/ifcgeom/iterator.cpp @@ -87,7 +87,7 @@ bool ifcopenshell::geom::iterator::initialize() { if (folded.size() < tasks_.size()) { auto old_size = tasks_.size(); tasks_.clear(); - size_t i = 0; + int i = 0; for (auto& p : folded) { tasks_.emplace_back(); tasks_.back().index = i++; diff --git a/src/ifcgeom/kernels/cgal/cgal_conversion_result.cpp b/src/ifcgeom/kernels/cgal/cgal_conversion_result.cpp index 1402ac0a6e..fff1dfce0a 100644 --- a/src/ifcgeom/kernels/cgal/cgal_conversion_result.cpp +++ b/src/ifcgeom/kernels/cgal/cgal_conversion_result.cpp @@ -138,7 +138,7 @@ namespace { p[i] += point.cartesian(i); } } - kernel_::FT n(wire.size()); + kernel_::FT n(static_cast(wire.size())); return cgal_point(p[0] / n, p[1] / n, p[2] / n); } @@ -563,14 +563,14 @@ void ifcopenshell::geom::cgal_shape::triangulate(ifcopenshell::geom::settings se } while (current_halfedge != face->facet_begin()); t->addFace(item_id, surface_style_id, vertexidx[0], vertexidx[1], vertexidx[2]); - for (size_t i = 0; i < 3; ++i) { - if (is_face_boundary[i]) { + for (size_t boundary_index = 0; boundary_index < 3; ++boundary_index) { + if (is_face_boundary[boundary_index]) { // In CGAL, the vertex of a halfedge is the incident vertex, i.e // the second vertex of the edge, so in order to get corresponding // vertex and edge indices we need to find vertexids (i-1, i) for // the boundary registered in i. - auto a = vertexidx[(i + 2) % 3]; - auto b = vertexidx[(i + 3) % 3]; + auto a = vertexidx[(boundary_index + 2) % 3]; + auto b = vertexidx[(boundary_index + 3) % 3]; if (a > b) { std::swap(a, b); } @@ -766,7 +766,7 @@ opaque_coordinate<3> ifcopenshell::geom::cgal_shape::position() p[i] += it->cartesian(i); } } - kernel_::FT N(std::distance(shp.points_begin(), shp.points_end())); + kernel_::FT N(static_cast(std::distance(shp.points_begin(), shp.points_end()))); for (int i = 0; i < 3; ++i) { p[i] /= N; } @@ -816,6 +816,7 @@ opaque_coordinate<4> ifcopenshell::geom::cgal_shape::plane_equation() std::vector ifcopenshell::geom::cgal_shape::convex_decomposition() { #ifdef IFOPSH_SIMPLE_KERNEL + (void)other; throw std::runtime_error("Not implemented"); #else std::vector result; @@ -842,6 +843,7 @@ std::vector ifcopenshell::geom::cgal_shape::convex_dec conversion_result_shape* ifcopenshell::geom::cgal_shape::halfspaces() { #ifdef IFOPSH_SIMPLE_KERNEL + (void)other; throw std::runtime_error("Not implemented"); #else return new cgal_shape_half_space_decomposition(nef(), convex_tag_); @@ -932,6 +934,7 @@ std::vector ifcopenshell::geom::cgal_shape::facets() conversion_result_shape* ifcopenshell::geom::cgal_shape::add(conversion_result_shape* other) { #ifdef IFOPSH_SIMPLE_KERNEL + (void)other; throw std::runtime_error("Not implemented"); #else return new cgal_shape(this->nef() + ((cgal_shape*)other)->nef()); @@ -1028,18 +1031,18 @@ std::size_t ifcopenshell::geom::cgal_shape::map(const std::vector ifcopenshell::geom::cgal_shape_half_space_ return res; } -conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::add(conversion_result_shape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::add(conversion_result_shape*) { throw std::runtime_error("Not implemented"); } -conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::subtract(conversion_result_shape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::subtract(conversion_result_shape*) { throw std::runtime_error("Not implemented"); } -conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::intersect(conversion_result_shape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::intersect(conversion_result_shape*) { throw std::runtime_error("Not implemented"); } @@ -1192,7 +1195,7 @@ std::pair, opaque_coordinate<3>> ifcopenshell::geom::cgal_s throw std::runtime_error("Not implemented"); } -double ifcopenshell::geom::cgal_shape_half_space_decomposition::bounding_box(void *& b) const { +double ifcopenshell::geom::cgal_shape_half_space_decomposition::bounding_box(void*&) const { throw std::runtime_error("Not implemented"); } diff --git a/src/ifcgeom/kernels/cgal/cgal_conversion_result.h b/src/ifcgeom/kernels/cgal/cgal_conversion_result.h index e8a7603cbe..472c51aa82 100644 --- a/src/ifcgeom/kernels/cgal/cgal_conversion_result.h +++ b/src/ifcgeom/kernels/cgal/cgal_conversion_result.h @@ -364,7 +364,7 @@ namespace ifcopenshell { namespace geom { virtual std::size_t map(const std::vector>& from, const std::vector>& to); virtual conversion_result_shape* moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const; - virtual bool surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const { + virtual bool surface_area_along_direction(double, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double&, double&, double&) const { return false; } }; diff --git a/src/ifcgeom/kernels/cgal/cgal_kernel.cpp b/src/ifcgeom/kernels/cgal/cgal_kernel.cpp index 96731d4637..2b2f2acaa7 100644 --- a/src/ifcgeom/kernels/cgal/cgal_kernel.cpp +++ b/src/ifcgeom/kernels/cgal/cgal_kernel.cpp @@ -174,7 +174,8 @@ bool cgal_kernel::convert(const taxonomy::shell::ptr l, cgal_polyhedron& shape) } } } - if (false && l->children.size() > 100) { +#if 0 + if (l->children.size() > 100) { static double inf = 1.e9; // std::numeric_limits::infinity(); std::pair minmax( Eigen::Vector3d(+inf, +inf, +inf), @@ -206,6 +207,7 @@ bool cgal_kernel::convert(const taxonomy::shell::ptr l, cgal_polyhedron& shape) return true; } } +#endif std::list face_list; for (auto& f : l->children) { @@ -576,7 +578,7 @@ namespace { std::swap(aid, bid); } - if (((aid + 1) == bid) || ((aid == 0) && (bid = (segments.size() - 1)))) { + if (((aid + 1) == bid) || ((aid == 0) && (static_cast(bid) == segments.size() - 1))) { // consecutive segments. return; } @@ -814,6 +816,7 @@ bool cgal_kernel::convert(const taxonomy::loop::ptr loop, cgal_wire& result) { } auto delta_dot = max_dot - min_dot; + (void)delta_dot; // @todo this can be used to assess face planarity. /* @@ -900,6 +903,11 @@ namespace { bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::base& entity, const std::vector>& openings, const std::vector & entity_shapes, const ifcopenshell::geom::taxonomy::matrix4 & entity_trsf, std::vector & cut_shapes) { #ifdef IFOPSH_SIMPLE_KERNEL + (void)entity; + (void)openings; + (void)entity_shapes; + (void)entity_trsf; + (void)cut_shapes; return false; #else CGAL::Nef_nary_union_3> second_operand_collector; @@ -1075,13 +1083,13 @@ bool cgal_kernel::process_extrusion(const cgal_face& bottom_face, taxonomy::dire if (i0 > i1) { std::swap(i0, i1); } - auto p = external_edges.insert({ { i0, i1 }, { i, j} }); - if (!p.second) { + auto insertion = external_edges.insert({ { i0, i1 }, { i, j} }); + if (!insertion.second) { // Mark as internal before erasure in external // This is {i,j} at the time the edge use was inserted. - internal_edges.insert(p.first->second); + internal_edges.insert(insertion.first->second); // not inserted, remove - external_edges.erase(p.first); + external_edges.erase(insertion.first); // @nb note the difference here in indices, {i0, i1} is point indices in // point_map. i is index in faces_to_extrude, j is segment index in wire. @@ -1109,11 +1117,11 @@ bool cgal_kernel::process_extrusion(const cgal_face& bottom_face, taxonomy::dire const bool reverse = fnorm * dir > 0; if (reverse) { - cgal_face bottom_face; + cgal_face reversed_bottom_face; for (auto vertex = w.rbegin(); vertex != w.rend(); ++vertex) { - bottom_face.outer.push_back(*vertex); + reversed_bottom_face.outer.push_back(*vertex); } - face_list.push_back(bottom_face); + face_list.push_back(reversed_bottom_face); } else { face_list.push_back(cgal_face{ w }); } @@ -1421,6 +1429,7 @@ bool cgal_kernel::preprocess_boolean_operand(const express::base& log_reference, for (auto it = shape.vertices_begin(); it != shape.vertices_end(); ++it) { for (auto& x : first_operands) { + (void)x; // @nb snapping_tolerance 'snaps' the barycentric coords to 0 or 1 // so that not only the point aligns to the face, but to an edge // as well. Snapping only to face would cause a rotation of line b: @@ -1767,7 +1776,7 @@ namespace { } } -bool cgal_kernel::process_as_2d_polygon(const std::list>>& operands, std::list>& loops, double& z0, double& z1) { +bool cgal_kernel::process_as_2d_polygon(const std::list>>& operands, std::list>&, double&, double&) { if (operands.front().size() != 1) { return false; } @@ -1888,10 +1897,10 @@ bool cgal_kernel::convert_impl(const taxonomy::boolean_result::ptr br, std::vect logger().notice("GEO", 101, "Holes are not disjoint"); CGAL::Polygon_set_2 result; - auto it = loops.begin(); - result.insert(*it++); - for (; it != loops.end(); ++it) { - result.difference(*it); + auto loop_it = loops.begin(); + result.insert(*loop_it++); + for (; loop_it != loops.end(); ++loop_it) { + result.difference(*loop_it); } result.polygons_with_holes(std::back_inserter(pwhs)); #endif @@ -1906,8 +1915,8 @@ bool cgal_kernel::convert_impl(const taxonomy::boolean_result::ptr br, std::vect #endif std::list> decom_polies; - for (auto& pwh : pwhs) { - decompositor(pwh, std::back_inserter(decom_polies)); + for (auto& polygon_with_holes : pwhs) { + decompositor(polygon_with_holes, std::back_inserter(decom_polies)); } std::transform(decom_polies.begin(), decom_polies.end(), std::back_inserter(results), [this, &br, &z0, &z1, &first_item_style](const CGAL::Polygon_2& p2) { @@ -2020,8 +2029,8 @@ bool cgal_kernel::convert_impl(const taxonomy::boolean_result::ptr br, std::vect auto& w = fs.front().outer; CGAL::Polygon_2 ps; - for (auto& p : w) { - ps.push_back({ p.x(), p.y() }); + for (auto& wire_point : w) { + ps.push_back({ wire_point.x(), wire_point.y() }); } if (!ps.is_simple()) { logger().warning("GEO", 103, "Polygonal boundary not simple", face->children[0]->instance); @@ -2252,10 +2261,10 @@ void polyhedron_builder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds std::list> decom_polies; decompositor(pwh, std::back_inserter(decom_polies)); - for (auto& p : decom_polies) { + for (auto& decomposed_polygon : decom_polies) { facet_vertices.emplace_back(); - for (auto it = p.vertices_begin(); it != p.vertices_end(); ++it) { - auto pit = points_2d.find(*it); + for (auto vertex_it = decomposed_polygon.vertices_begin(); vertex_it != decomposed_polygon.vertices_end(); ++vertex_it) { + auto pit = points_2d.find(*vertex_it); if (pit == points_2d.end()) { // Likely there are intersections in the polygonal boundaries. // For now let's just skip over the triangle. We can also use diff --git a/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h b/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h index baf0c2004b..70860c0f88 100644 --- a/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h +++ b/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h @@ -196,7 +196,7 @@ plane_map snap_halfspaces(const std::list>& planes kdtree.search(std::back_inserter(results_neg), fsn); auto sum = std::accumulate(++results_pos.begin(), results_pos.end(), results_pos.front(), [](point_d a, point_d b) {return point_d(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]); }); - int N = results_pos.size(); + std::size_t N = results_pos.size(); auto sum2 = std::accumulate(results_neg.begin(), results_neg.end(), sum, [](point_d a, point_d b) {return point_d(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3]); }); N += results_neg.size(); diff --git a/src/ifcgeom/mapping/IfcBooleanResult.cpp b/src/ifcgeom/mapping/IfcBooleanResult.cpp index 29668d7fa3..d6547ab60f 100644 --- a/src/ifcgeom/mapping/IfcBooleanResult.cpp +++ b/src/ifcgeom/mapping/IfcBooleanResult.cpp @@ -40,8 +40,6 @@ namespace { taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBooleanResult& inst) { IfcSchema::IfcBooleanOperand operand1 = inst.FirstOperand(); IfcSchema::IfcBooleanOperand operand2 = inst.SecondOperand(); - bool has_halfspace_operand = false; - std::vector operands; operands.push_back(operand2); diff --git a/src/ifcgeom/mapping/IfcCenterLineProfileDef.cpp b/src/ifcgeom/mapping/IfcCenterLineProfileDef.cpp index 04c32ef73b..fbb3ba34b6 100644 --- a/src/ifcgeom/mapping/IfcCenterLineProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCenterLineProfileDef.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) using namespace ifcopenshell::geom; -taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCenterLineProfileDef& inst) { +taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCenterLineProfileDef&) { return nullptr; /* diff --git a/src/ifcgeom/profile_helper.cpp b/src/ifcgeom/profile_helper.cpp index c57b94d3f5..bbb450849e 100644 --- a/src/ifcgeom/profile_helper.cpp +++ b/src/ifcgeom/profile_helper.cpp @@ -4,8 +4,9 @@ using namespace ifcopenshell::geom; taxonomy::loop::ptr ifcopenshell::geom::fillet_loop(taxonomy::loop::ptr loop, double radius) { std::vector pps(loop->children.size()); - for (int b = 0; b < loop->children.size(); ++b) { - int c = (b - 1) % loop->children.size(); + const auto child_count = static_cast(loop->children.size()); + for (int b = 0; b < child_count; ++b) { + int c = (b + child_count - 1) % child_count; pps[b] = { std::get(loop->children[c]->start)->ccomponents(), radius, loop->children[c], loop->children[b] @@ -59,7 +60,7 @@ void ifcopenshell::geom::remove_duplicate_points_from_loop(std::vector pps(points.size()); - for (int b = 0; b < points.size(); ++b) { - int c = (b + points.size() - 1) % points.size(); + const auto point_count = static_cast(points.size()); + for (int b = 0; b < point_count; ++b) { + int c = (b + point_count - 1) % point_count; pps[b] = { Eigen::Vector2d(points[b].xy[0], points[b].xy[1]), points[b].radius, loop->children[c], loop->children[b] }; } @@ -215,7 +217,7 @@ std::pair, std::vector> for (;;) { bool removed = false; - int n = polygon.size() - (closed ? 0 : 1); + const std::size_t n = polygon.size() - (closed ? 0u : 1u); for (size_t i = 0; i < n; ++i) { // wrap around to the first point in case of a closed loop auto j = (i + 1) % polygon.size(); diff --git a/src/ifcgeom/representation.cpp b/src/ifcgeom/representation.cpp index 5e5fbca6f5..0a1591c6e6 100644 --- a/src/ifcgeom/representation.cpp +++ b/src/ifcgeom/representation.cpp @@ -211,7 +211,7 @@ void ifcopenshell::geom::triangulation::registerEdgeCount(int n1, int n2, std::m } const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::item(int i) const { - if (i >= 0 && i < shapes_.size()) { + if (i >= 0 && static_cast(i) < shapes_.size()) { return shapes_[i].shape()->moved(shapes_[i].placement()); } else { return nullptr; @@ -219,7 +219,7 @@ const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::ite } int ifcopenshell::geom::brep::item_id(int i) const { - if (i >= 0 && i < shapes_.size()) { + if (i >= 0 && static_cast(i) < shapes_.size()) { return shapes_[i].ItemId(); } else { return 0; diff --git a/src/ifcgeom/taxonomy.cpp b/src/ifcgeom/taxonomy.cpp index 272b3bc01b..4cadf86c81 100644 --- a/src/ifcgeom/taxonomy.cpp +++ b/src/ifcgeom/taxonomy.cpp @@ -187,19 +187,6 @@ namespace { throw std::runtime_error("not implemented"); } - bool compare(const style& a, const style& b) { - const int order[5] = { - less_to_order(a.name, b.name), - less_to_order(a.diffuse, b.diffuse), - less_to_order(a.specular, b.specular), - less_to_order(a.specularity, b.specularity), - less_to_order(a.transparency, b.transparency) - }; - auto it = std::find_if(std::begin(order), std::end(order), [](int x) { return x; }); - if (it == std::end(order)) return false; - return *it == -1; - } - /* A compile-time for loop over the taxonomy kinds */ template struct dispatch_comparison { @@ -245,10 +232,10 @@ bool ifcopenshell::geom::taxonomy::less(item::const_ptr a, item::const_ptr b) { namespace { bool compare(const trimmed_curve& a, const trimmed_curve& b) { - int a_which_start = a.start.index(); - int a_which_end = a.end.index(); - int b_which_start = b.start.index(); - int b_which_end = b.end.index(); + std::size_t a_which_start = a.start.index(); + std::size_t a_which_end = a.end.index(); + std::size_t b_which_start = b.start.index(); + std::size_t b_which_end = b.end.index(); if (std::tie(a.orientation, a_which_start, a_which_end) == std::tie(b.orientation, b_which_start, b_which_end)) { diff --git a/src/ifcgeom/taxonomy.h b/src/ifcgeom/taxonomy.h index 79782075cd..d2a224b584 100644 --- a/src/ifcgeom/taxonomy.h +++ b/src/ifcgeom/taxonomy.h @@ -1629,20 +1629,20 @@ typedef item const* ptr; for (auto& i : deep->children) { // @todo Sad... now that we have templated collection members, // we can't generally use collection_base anymore as a cast target. - if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geom::visit(s, fn); - } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geom::visit(s, fn); - } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geom::visit(s, fn); - } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geom::visit(s, fn); - } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geom::visit(s, fn); - } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geom::visit(s, fn); - } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geom::visit(s, fn); + if (auto collection = std::dynamic_pointer_cast(i)) { + ifcopenshell::geom::visit(collection, fn); + } else if (auto loop = std::dynamic_pointer_cast(i)) { + ifcopenshell::geom::visit(loop, fn); + } else if (auto face = std::dynamic_pointer_cast(i)) { + ifcopenshell::geom::visit(face, fn); + } else if (auto shell = std::dynamic_pointer_cast(i)) { + ifcopenshell::geom::visit(shell, fn); + } else if (auto solid = std::dynamic_pointer_cast(i)) { + ifcopenshell::geom::visit(solid, fn); + } else if (auto loft = std::dynamic_pointer_cast(i)) { + ifcopenshell::geom::visit(loft, fn); + } else if (auto boolean_result = std::dynamic_pointer_cast(i)) { + ifcopenshell::geom::visit(boolean_result, fn); } else { fn(i); diff --git a/src/ifcparse/entity_instance_data.cpp b/src/ifcparse/entity_instance_data.cpp index f90b8c9974..e42b504f1b 100644 --- a/src/ifcparse/entity_instance_data.cpp +++ b/src/ifcparse/entity_instance_data.cpp @@ -79,11 +79,16 @@ namespace { return val; } #endif + throw std::logic_error("RocksDB storage is unavailable"); } template inline bool dispatch_has_(attribute_value::pointer_type array_, uint8_t storage_model_, size_t instance_name_, const ifcopenshell::declaration* entity_or_type, uint8_t index_) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)instance_name_; + (void)entity_or_type; +#endif if (storage_model_ == 0) { return array_.storage_ptr->has(index_); } @@ -103,10 +108,15 @@ namespace { return str[0] == type_encoder::encode_type(); } #endif + throw std::logic_error("RocksDB storage is unavailable"); } inline size_t dispatch_index_(attribute_value::pointer_type array_, uint8_t storage_model_, size_t instance_name_, const ifcopenshell::declaration* entity_or_type, uint8_t index_) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)instance_name_; + (void)entity_or_type; +#endif if (storage_model_ == 0) { return array_.storage_ptr->index(index_); } @@ -123,6 +133,7 @@ namespace { return (size_t) str[0] - 'A'; } #endif + throw std::logic_error("RocksDB storage is unavailable"); } } @@ -196,6 +207,7 @@ attribute_value::operator enumeration_reference() const return enumeration_reference(decl, v); } #endif + throw std::logic_error("RocksDB storage is unavailable"); } attribute_value::operator boost::dynamic_bitset<>() const @@ -229,6 +241,7 @@ attribute_value::operator express::base () const } } #endif + throw std::logic_error("RocksDB storage is unavailable"); } attribute_value::operator std::vector() const diff --git a/src/ifcparse/express.h b/src/ifcparse/express.h index 9052135872..409bb3cab0 100644 --- a/src/ifcparse/express.h +++ b/src/ifcparse/express.h @@ -266,7 +266,6 @@ typename std::conditional_t< std::vector> cast_vector(const std::vector& values) { if constexpr (is_std_vector::value) { - using value_type = typename U::value_type; std::vector> result; result.reserve(values.size()); for (const auto& value : values) { diff --git a/src/ifcparse/file.cpp b/src/ifcparse/file.cpp index 88ddd48c00..a8125122b3 100644 --- a/src/ifcparse/file.cpp +++ b/src/ifcparse/file.cpp @@ -33,6 +33,10 @@ ifcopenshell::impl::rocks_db_file_storage::rocksdb_types_iterator::value_type co } express::base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t number, instance_ref r) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)number; + (void)r; +#endif #ifdef IFOPSH_WITH_ROCKSDB std::lock_guard lock(instance_cache_mutex_); @@ -81,6 +85,10 @@ express::base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t namespace { std::unique_ptr init_db(const std::string& filepath, bool readonly) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)filepath; + (void)readonly; +#endif #ifdef IFOPSH_WITH_ROCKSDB rocksdb::Options options; // options.disable_auto_compactions = true; @@ -93,7 +101,7 @@ namespace { /* tbo.block_size = 16 * 1024; - tbo.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10 /*bits/key/, false)); + tbo.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10, false)); // bits/key tbo.partition_filters = true; tbo.index_type = rocksdb::BlockBasedTableOptions::kHashSearch; tbo.cache_index_and_filter_blocks = true; @@ -143,14 +151,14 @@ namespace { // @todo naming ifcopenshell::impl::rocks_db_file_storage::rocks_db_file_storage(const std::string& filepath, ifcopenshell::file* ffile, bool readonly) - : file(ffile) - , db(init_db(filepath, readonly)) - // @todo streaming serializer does not populate the byguid map - , byguid_internal_(db.get(), "g|"), - byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::base& v) { return v.identity(); }) + : db(init_db(filepath, readonly)) + , file(ffile) , instance_ids_(db.get(), "i|") , instance_by_name_(&instance_ids_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }) , bytype_(db.get(), "t|") + // @todo streaming serializer does not populate the byguid map + , byguid_internal_(db.get(), "g|"), + byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::base& v) { return v.identity(); }) , byref_excl_(db.get(), "v|") // @todo by_identity is probably not correct here, this mapping is Name -> Identity, so Fn should have access to full pair? // , byidentity_(&byid_, [this](size_t v) { return assert_existance(v, by_identity); }, [](ifcopenshell::IfcBaseClass* v) { return v->identity(); }) @@ -192,6 +200,9 @@ express::base ifcopenshell::impl::rocks_db_file_storage::instance_by_id(int id) void ifcopenshell::impl::rocks_db_file_storage::process_deletion_inverse(const express::base& inst) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)inst; +#endif #ifdef IFOPSH_WITH_ROCKSDB auto id = inst.id(); @@ -337,6 +348,8 @@ ifcopenshell::filetype ifcopenshell::guess_file_type(const std::string& fn) { } express::base ifcopenshell::impl::rocks_db_file_storage::create(const ifcopenshell::declaration* decl, int id) { + (void)decl; + (void)id; return express::base{}; /* if (decl->as_entity() || decl->as_type_declaration()) { diff --git a/src/ifcparse/global_id.cpp b/src/ifcparse/global_id.cpp index 1e987150c5..f31e8c23b0 100644 --- a/src/ifcparse/global_id.cpp +++ b/src/ifcparse/global_id.cpp @@ -95,6 +95,7 @@ void expand(const std::string& s, std::vector& v) { #endif ifcopenshell::global_id::global_id(logger& logger) { + (void)logger; uuid_data_ = gen(); std::vector v(uuid_data_.size()); std::copy(uuid_data_.begin(), uuid_data_.end(), v.begin()); @@ -118,6 +119,7 @@ ifcopenshell::global_id::global_id(logger& logger) { ifcopenshell::global_id::global_id(const std::string& string, logger& logger) : string_data_(string) { + (void)logger; std::vector result; expand(string_data_, result); std::copy(result.begin(), result.end(), uuid_data_.begin()); diff --git a/src/ifcparse/instance_data.h b/src/ifcparse/instance_data.h index 96737cdeac..029da0f5ed 100644 --- a/src/ifcparse/instance_data.h +++ b/src/ifcparse/instance_data.h @@ -245,10 +245,6 @@ class IFC_PARSE_API mutable_attribute_value { uint8_t index_; }; -namespace impl { - class IFC_PARSE_API rocks_db_file_storage; -} - } // namespace ifcopenshell #ifdef IFOPSH_WITH_ROCKSDB @@ -579,12 +575,15 @@ class IFC_PARSE_API instance_data { void set_attribute_value(std::size_t attribute_index, T&& value) { if (storage_) { storage_->set(attribute_index, value); + return; } #ifdef IFOPSH_WITH_ROCKSDB else { rocks_db_attribute_storage{}.set(get_storage_of_type(), declaration_, id_ ? id_ : identity_, attribute_index, value); + return; } #endif + throw std::logic_error("RocksDB storage is unavailable"); } template @@ -597,6 +596,7 @@ class IFC_PARSE_API instance_data { return rocks_db_attribute_storage{}.has(get_storage_of_type(), declaration_, id_ ? id_ : identity_, attribute_index); } #endif + throw std::logic_error("RocksDB storage is unavailable"); } void to_string(std::ostream& stream, bool uppercase = false) const; diff --git a/src/ifcparse/parse.cpp b/src/ifcparse/parse.cpp index efd5db6f9b..5fb2ad7acb 100644 --- a/src/ifcparse/parse.cpp +++ b/src/ifcparse/parse.cpp @@ -1074,6 +1074,12 @@ namespace { } void ifcopenshell::impl::rocks_db_file_storage::register_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, int inst_id, int attribute_index) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)id_from; + (void)from_entity; + (void)inst_id; + (void)attribute_index; +#endif #ifdef IFOPSH_WITH_ROCKSDB static std::string s; uint32_t v = id_from; @@ -1096,6 +1102,12 @@ void ifcopenshell::impl::rocks_db_file_storage::register_inverse(unsigned id_fro } void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::base& inst, int attribute_index) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)id_from; + (void)from_entity; + (void)inst; + (void)attribute_index; +#endif #ifdef IFOPSH_WITH_ROCKSDB static std::string s; auto inst_id = inst.id(); @@ -1118,6 +1130,9 @@ void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_f void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::base& new_entity) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)new_entity; +#endif #ifdef IFOPSH_WITH_ROCKSDB size_t v; std::string s(sizeof(size_t), ' '); @@ -1148,6 +1163,9 @@ void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::base void ifcopenshell::impl::rocks_db_file_storage::remove_type_ref(const express::base& new_entity) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)new_entity; +#endif #ifdef IFOPSH_WITH_ROCKSDB if (new_entity.declaration().as_entity()) { std::string s; @@ -1444,7 +1462,7 @@ unsigned ifcopenshell::IfcBaseEntity::set_id(const std::optional& i) { namespace { // @todo remove redundancy with python wrapper code (which is not identical due to // different handling of enumerations) -ifcopenshell::argument_type get_argument_type(const ifcopenshell::declaration* decl, size_t i) { +[[maybe_unused]] ifcopenshell::argument_type get_argument_type(const ifcopenshell::declaration* decl, size_t i) { const ifcopenshell::parameter_type* pt = 0; if (decl->as_entity() != nullptr) { pt = decl->as_entity()->attribute_by_index(i)->type_of_attribute(); @@ -1613,10 +1631,7 @@ express::base::set_attribute_value(size_t i, const T& t) { apply_individual_instance_visitor(current_attribute, (int)i).apply(visitor); } - { - void* const storage = std::visit([](const auto& m) { return (void*)&m; }, file()->storage_); - data()->set_attribute_value(i, t); - } + data()->set_attribute_value(i, t); auto new_attribute = get_attribute_value(i); // Register inverse indices in file @@ -2820,12 +2835,10 @@ void file::process_deletion_(const express::base& entity) { } break; case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: { std::vector> instance_list_list = attr; - bool updated = false; for (auto& li : instance_list_list) { auto it = std::remove(li.begin(), li.end(), entity); if (it != li.end()) { li.erase(it, li.end()); - updated = true; } } related_instance.set_attribute_value(i, instance_list_list); @@ -3432,6 +3445,9 @@ attribute_value instance_data::get_attribute_value(size_t index) const } bool ifcopenshell::impl::rocks_db_file_storage::read_schema(const ifcopenshell::schema_definition*& schema) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)schema; +#endif #ifdef IFOPSH_WITH_ROCKSDB std::string value; auto key = "h|file_schema|0"; diff --git a/src/ifcparse/rocksdb_map_adapter.h b/src/ifcparse/rocksdb_map_adapter.h index 2ea85bd215..189f092c94 100644 --- a/src/ifcparse/rocksdb_map_adapter.h +++ b/src/ifcparse/rocksdb_map_adapter.h @@ -294,6 +294,9 @@ public: } bool operator==(const iterator& other) const { +#ifndef IFOPSH_WITH_ROCKSDB + (void)other; +#endif #ifdef IFOPSH_WITH_ROCKSDB if (!it_ && !other.it_) return true; if (it_ && other.it_) @@ -322,7 +325,10 @@ public: return iterator(); } - iterator find(const key_type& key) const { + iterator find(const key_type& key) const { +#ifndef IFOPSH_WITH_ROCKSDB + (void)key; +#endif #ifdef IFOPSH_WITH_ROCKSDB std::string key_str = key_to_string(key); std::string full_key = prefix_ + key_str; @@ -334,7 +340,10 @@ public: return end(); } - size_t erase(const key_type& key) { + size_t erase(const key_type& key) { +#ifndef IFOPSH_WITH_ROCKSDB + (void)key; +#endif #ifdef IFOPSH_WITH_ROCKSDB std::string key_str = key_to_string(key); std::string full_key = prefix_ + key_str; diff --git a/src/ifcparse/rocksdb_set_view.h b/src/ifcparse/rocksdb_set_view.h index 971eb43f26..13e0f8e66e 100644 --- a/src/ifcparse/rocksdb_set_view.h +++ b/src/ifcparse/rocksdb_set_view.h @@ -163,6 +163,9 @@ public: } bool operator==(const iterator& other) const { +#ifndef IFOPSH_WITH_ROCKSDB + (void)other; +#endif #ifdef IFOPSH_WITH_ROCKSDB if (!it_ && !other.it_) return true; diff --git a/src/ifcparse/si_prefix.h b/src/ifcparse/si_prefix.h index ecb9c58e93..20c1fc3f4c 100644 --- a/src/ifcparse/si_prefix.h +++ b/src/ifcparse/si_prefix.h @@ -35,7 +35,7 @@ double get_SI_equivalent(const typename Schema::IfcNamedUnit& named_unit) { if (auto conv_unit = named_unit.template as()) { auto factor = conv_unit.ConversionFactor(); auto component = factor.UnitComponent(); - if (si_unit = component.concrete().template as()) { + if ((si_unit = component.concrete().template as())) { auto value = factor.ValueComponent(); scale = value.get_attribute_value(0); } diff --git a/src/serializers/json_serializer.h b/src/serializers/json_serializer.h index 57c3aceb9a..8b3546b661 100644 --- a/src/serializers/json_serializer.h +++ b/src/serializers/json_serializer.h @@ -24,7 +24,7 @@ class json_serializer : public ifcopenshell::geom::serializer { Dialect dialect_; public: - json_serializer(ifcopenshell::file* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX, ifcopenshell::logger& logger = ifcopenshell::logger::root()) + json_serializer(ifcopenshell::file* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX, ifcopenshell::logger& = ifcopenshell::logger::root()) : json_filename(json_filename) , dialect_(dialect) { diff --git a/src/serializers/schema_dependent/json_serializer.cpp b/src/serializers/schema_dependent/json_serializer.cpp index b2ebd593c9..2f5ed70ff2 100644 --- a/src/serializers/schema_dependent/json_serializer.cpp +++ b/src/serializers/schema_dependent/json_serializer.cpp @@ -60,7 +60,7 @@ class get_type_visitor : public boost::static_visitor { get_type_visitor() = default; template - std::string operator()(const T& t) const { + std::string operator()(const T&) const { // @todo more types return "number"; } @@ -416,7 +416,7 @@ void POSTFIX_SCHEMA(json_serializer)::finalize() { } #ifdef SCHEMA_HAS_IfcPreDefinedPropertySet // ifc2x3 does not have this type yet, just inherits from IfcPropertySetDefinition - } else if (auto pset = inst.as()) { + } else if (auto predefined_pset = inst.as()) { #else } else { #endif diff --git a/src/serializers/schema_dependent/xml_serializer.cpp b/src/serializers/schema_dependent/xml_serializer.cpp index fde10c1db4..06a1cc106d 100644 --- a/src/serializers/schema_dependent/xml_serializer.cpp +++ b/src/serializers/schema_dependent/xml_serializer.cpp @@ -132,8 +132,8 @@ std::optional format_attribute(ifcopenshell::geom::abstract_mapping // Appends to a node with possibly existing attributes ptree* format_entity_instance(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const express::base& instance, ptree& child, ptree& tree, bool as_link = false) { - const unsigned n = instance.declaration().as_entity()->attribute_count(); - for (unsigned i = 0; i < n; ++i) { + const std::size_t n = instance.declaration().as_entity()->attribute_count(); + for (std::size_t i = 0; i < n; ++i) { try { instance.get_attribute_value(i); } catch (const std::exception&) { @@ -792,9 +792,9 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() { } } else if (auto matlist = mat.concrete().as()) { auto mats = matlist.Materials(); - for (auto& mat : mats) { + for (auto& list_material : mats) { ptree subnode; - format_entity_instance(log, mapping_, mat, subnode, node); + format_entity_instance(log, mapping_, list_material, subnode, node); } } format_entity_instance(log, mapping_, mat.concrete(), node, materials); diff --git a/src/serializers/xml_serializer.h b/src/serializers/xml_serializer.h index bee5338e9d..8ce93d2f37 100644 --- a/src/serializers/xml_serializer.h +++ b/src/serializers/xml_serializer.h @@ -19,7 +19,7 @@ protected: std::string xml_filename; public: - xml_serializer(ifcopenshell::file* file, const std::string& xml_filename, ifcopenshell::logger& logger = ifcopenshell::logger::root()) + xml_serializer(ifcopenshell::file* file, const std::string& xml_filename, ifcopenshell::logger& = ifcopenshell::logger::root()) : xml_filename(xml_filename) { if (!file) {