From 28c9c1d34da21eea15dda831568b7179c149c81a Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 9 Aug 2026 09:04:28 +0200 Subject: [PATCH] Silence remaining compiler warnings Generated with the assistance of an AI coding tool. --- src/ifcconvert/IfcConvert.cpp | 16 ++- .../kernels/opencascade/boolean_result.cpp | 41 +------- .../kernels/opencascade/boolean_utils.cpp | 48 ++++----- src/ifcgeom/kernels/opencascade/face.cpp | 2 +- .../kernels/opencascade/face_definition.cpp | 2 +- .../kernels/opencascade/faceset_helper.cpp | 4 +- src/ifcgeom/kernels/opencascade/layerset.cpp | 2 +- src/ifcgeom/kernels/opencascade/tree.h | 98 +++++++++---------- .../kernels/opencascade/wire_utils.cpp | 10 +- .../passthrough_conversion_result.cpp | 9 +- .../mapping/IfcRectangularTrimmedSurface.cpp | 2 +- src/ifcgeom/mapping/IfcRightCircularCone.cpp | 2 +- .../mapping/IfcRightCircularCylinder.cpp | 2 +- src/ifcgeom/mapping/IfcSphericalSurface.cpp | 2 +- src/ifcgeom/mapping/IfcSweptDiskSolid.cpp | 17 +--- src/ifcgeom/mapping/IfcTrimmedCurve.cpp | 1 - src/ifcgeom/mapping/mapping.cpp | 4 +- src/ifcgeomserver/IfcGeomServer.cpp | 8 +- src/ifcparse/alignment_helper.cpp | 4 +- src/ifcparse/logger.h | 30 ++++-- src/ifcparse/schema_plugin.cpp | 4 +- src/serializers/svg_serializer.cpp | 17 ++-- src/serializers/svg_serializer.h | 10 +- src/serializers/ttl_wkt_serializer.cpp | 18 ++-- 24 files changed, 140 insertions(+), 213 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index e6c4834307..afe407df8f 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -396,8 +396,6 @@ int main(int argc, char** argv) { #ifdef HAVE_ICU std::string unicode_mode; #endif - short precision; - po::options_description serializer_options("Serialization options"); serializer_options.add_options() #ifdef HAVE_ICU @@ -807,7 +805,7 @@ int main(int argc, char** argv) { if (model_rotation) { std::vector rotation(4); int n = 0; - if (sscanf(rotation_str.c_str(), "%lf;%lf;%lf;%lf %n", &rotation[0], &rotation[1], &rotation[2], &rotation[3], &n) != 4 || n != rotation_str.size()) { + if (sscanf(rotation_str.c_str(), "%lf;%lf;%lf;%lf %n", &rotation[0], &rotation[1], &rotation[2], &rotation[3], &n) != 4 || static_cast(n) != rotation_str.size()) { cerr_ << "[error] Invalid use of --model-rotation\n"; ifcopenshell::path::delete_file(ifcopenshell::path::to_utf8(output_temp_filename)); print_options(serializer_options); @@ -828,7 +826,7 @@ int main(int argc, char** argv) { if (model_offset && !(center_model || center_model_geometry)) { std::vector offset(3); int n = 0; - if (sscanf(offset_str.c_str(), "%lf;%lf;%lf %n", &offset[0], &offset[1], &offset[2], &n) != 3 || n != offset_str.size()) { + if (sscanf(offset_str.c_str(), "%lf;%lf;%lf %n", &offset[0], &offset[1], &offset[2], &n) != 3 || static_cast(n) != offset_str.size()) { cerr_ << "[error] Invalid use of --model-offset\n"; ifcopenshell::path::delete_file(ifcopenshell::path::to_utf8(output_temp_filename)); print_options(serializer_options); @@ -847,8 +845,8 @@ int main(int argc, char** argv) { ifcopenshell::geom::iterator tmp_context_iterator(ifcopenshell::geom::kernels::construct(ifc_file, geometry_kernel, settings), settings, ifc_file, filter_funcs, num_threads, logger); - time_t start, end; - time(&start); + time_t bounds_start, bounds_end; + time(&bounds_start); if (!quiet) logger.status("Computing bounds..."); if (center_model_geometry) { @@ -865,8 +863,8 @@ int main(int argc, char** argv) { tmp_context_iterator.compute_bounds(center_model_geometry); - time(&end); - if (!quiet) logger.status("Done ! Bounds computed in " + format_duration(start, end)); + time(&bounds_end); + if (!quiet) logger.status("Done ! Bounds computed in " + format_duration(bounds_start, bounds_end)); auto center = (tmp_context_iterator.bounds_min().ccomponents() + tmp_context_iterator.bounds_max().ccomponents()) * 0.5; offset[0] = -center(0); @@ -1204,7 +1202,7 @@ void parse_filter(geom_filter &filter, const std::vector& values) filter.values.insert(values.begin() + (filter.type == geom_filter::ENTITY_ARG ? 2 : 1), values.end()); } -void validate(boost::any& v, const std::vector& values, verbosity_counter*, long) { +void validate(boost::any& v, const std::vector&, verbosity_counter*, long) { if (v.empty()) v = verbosity_counter{ 1 }; else ++boost::any_cast(v).count; } diff --git a/src/ifcgeom/kernels/opencascade/boolean_result.cpp b/src/ifcgeom/kernels/opencascade/boolean_result.cpp index 663980d1d8..96fdd7e674 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_result.cpp +++ b/src/ifcgeom/kernels/opencascade/boolean_result.cpp @@ -6,46 +6,6 @@ using namespace ifcopenshell::geom; using namespace ifcopenshell::geom::kernels; -// @todo should we reapply the technique to apply openings in batches? -namespace { - struct opening_sorter { - bool operator()(const std::pair& a, const std::pair& b) const { - return a.first > b.first; - } - }; - - bool apply_in_batches(ifcopenshell::geom::util::boolean_settings bst, const TopoDS_Shape& first_operand, std::vector< std::pair >& opening_vector, BOPAlgo_Operation occ_op, TopoDS_Shape& result) { - auto it = opening_vector.begin(); - auto jt = it; - - result = first_operand; - for (;; ++it) { - if (it == opening_vector.end() || jt->first / it->first > 10.) { - - NCollection_List opening_list; - for (auto kt = jt; kt < it; ++kt) { - opening_list.Append(kt->second); - } - - TopoDS_Shape intermediate_result; - if (ifcopenshell::geom::util::boolean_operation(bst, result, opening_list, occ_op, intermediate_result)) { - result = intermediate_result; - } else { - return false; - } - - jt = it; - } - - if (it == opening_vector.end()) { - break; - } - } - - return true; - } -} - namespace { BOPAlgo_Operation op_to_occt(taxonomy::boolean_result::operation_type t) { switch (t) { @@ -53,6 +13,7 @@ namespace { case taxonomy::boolean_result::INTERSECTION: return BOPAlgo_COMMON; case taxonomy::boolean_result::SUBTRACTION: return BOPAlgo_CUT; } + throw std::invalid_argument("Unsupported boolean operation"); } bool get_single_child(const TopoDS_Shape& s, TopoDS_Shape& child) { diff --git a/src/ifcgeom/kernels/opencascade/boolean_utils.cpp b/src/ifcgeom/kernels/opencascade/boolean_utils.cpp index 9e28fea2fa..035ef9b99c 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/boolean_utils.cpp @@ -310,13 +310,13 @@ bool ifcopenshell::geom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape // top face. When neither of these categories the shape is not a extrusion // or the extrusion direction is not orthogonal to its basis. for (int i = 1; i < mapping.Extent(); ++i) { - auto& s = mapping.FindKey(i); - if (s.ShapeType() != TopAbs_EDGE) { + auto& shape = mapping.FindKey(i); + if (shape.ShapeType() != TopAbs_EDGE) { continue; } // @todo use a linear tolernace and the face extrimities, see #2218 - const TopoDS_Edge& e = TopoDS::Edge(s); + const TopoDS_Edge& e = TopoDS::Edge(shape); if (!get_edge_axis(e, ax)) { // curved curved_orthogonal.Add(e); @@ -585,7 +585,7 @@ bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS std::map edge_index_to_shape_index; std::vector shapes; - std::vector> edges; + std::vector> edges; // First is the outer wire std::vector wires; @@ -646,19 +646,19 @@ bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS BRepBndLib::Add(exp.Current(), b); b.Enlarge(eps); - for (auto& i : edge_tree.select_box(b)) { - if (i == edge_index) { + for (auto& candidate_index : edge_tree.select_box(b)) { + if (candidate_index == edge_index) { // Skip self-selection continue; } - if (edges[i].first == shape_index) { + if (edges[candidate_index].first == shape_index) { // Skip edges of the same operand continue; } const TopoDS_Edge& e0 = TopoDS::Edge(exp.Current()); - const TopoDS_Edge& e1 = edges[i].second; + const TopoDS_Edge& e1 = edges[candidate_index].second; double u11, u12, u21, u22, U1, U2; @@ -670,9 +670,9 @@ bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS if (!ecc.Extrema().IsParallel() && ecc.NbExtrema() >= 1) { // @todo: extend this to work in case of multiple extrema and curved segments. - for (int i = 1; i <= ecc.NbExtrema(); ++i) { + for (int extrema_index = 1; extrema_index <= ecc.NbExtrema(); ++extrema_index) { gp_Pnt p1, p2; - ecc.Points(i, p1, p2); + ecc.Points(extrema_index, p1, p2); // #3616 Only take into account orthogonal distance between closest points on curve // to see whether inside tolerance. Current DY is hardcoded. The sensible default @@ -685,7 +685,7 @@ bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS const bool unbounded_intersects = ortho_distance < eps; if (unbounded_intersects) { - ecc.Parameters(i, U1, U2); + ecc.Parameters(extrema_index, U1, U2); if (u11 > u12) { std::swap(u11, u12); @@ -734,10 +734,10 @@ bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS } // First check for containment in outer wire - for (auto it = ++wires.begin(); it != wires.end(); ++it) { + for (auto wire_it = ++wires.begin(); wire_it != wires.end(); ++wire_it) { // Considering a single vertex is sufficient because we have already // guaranteed that the edges of different operands do not cross. - TopoDS_Iterator it_ed(*it); + TopoDS_Iterator it_ed(*wire_it); auto& ed = it_ed.Value(); TopoDS_Iterator it_v(ed); @@ -749,7 +749,7 @@ bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS // A wire is not contained in the outer wire, it's a subtraction without // any effect and marked as redundant. Feeding it to the builder algo // will likely cause problems. - redundant[std::distance(wires.begin(), it)] = true; + redundant[std::distance(wires.begin(), wire_it)] = true; logger.notice("GEO", 124, "Subtraction operand outside of outer bound"); } } @@ -758,7 +758,7 @@ bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS // NB first wire is *not* in this tree ifcopenshell::geom::impl::tree wire_tree; for (size_t wire_index = 1; wire_index < wires.size(); ++wire_index) { - wire_tree.add(wire_index, wires[wire_index]); + wire_tree.add(static_cast(wire_index), wires[wire_index]); } for (size_t wire_index = 1; wire_index < wires.size(); ++wire_index) { @@ -775,7 +775,7 @@ bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS // than the second element. for (auto& other_index : wire_tree.select_box(b, true)) { // other_index is fully contained in wire_index - if (wire_index == other_index) { + if (wire_index == static_cast(other_index)) { continue; } @@ -1144,21 +1144,7 @@ bool ifcopenshell::geom::util::boolean_operation(const boolean_settings& setting builder->Build(); } if (builder->IsDone()) { - if (false && builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertAcquiredSelfIntersection))) { - settings.log().notice("GEO", 144, "Builder reports self-intersection in output"); - success = false; - - /* - const auto& ws = builder->DSFiller()->GetReport()->GetAlerts(Message_Warning); - for (const auto& w : ws) { - if (w->DynamicType() == STANDARD_TYPE(BOPAlgo_AlertAcquiredSelfIntersection)) { - const auto& x = Handle(BOPAlgo_AlertAcquiredSelfIntersection)::DownCast(w)->GetShape(); - BRepTools::Write(x, "debug_x.brep"); - BRepTools::Write(*builder, "debug_r.brep"); - } - } - */ - } else if(builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertBadPositioning)) && !TopoDS_Iterator(*builder).More()) { + if (builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertBadPositioning)) && !TopoDS_Iterator(*builder).More()) { settings.log().notice("GEO", 145, "Builder reports bad positioning and result is empty"); success = false; } else { diff --git a/src/ifcgeom/kernels/opencascade/face.cpp b/src/ifcgeom/kernels/opencascade/face.cpp index 89fb8438e2..4031315fa3 100644 --- a/src/ifcgeom/kernels/opencascade/face.cpp +++ b/src/ifcgeom/kernels/opencascade/face.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ifcgeom/kernels/opencascade/face_definition.cpp b/src/ifcgeom/kernels/opencascade/face_definition.cpp index 8fcc2d8c8e..2a42486334 100644 --- a/src/ifcgeom/kernels/opencascade/face_definition.cpp +++ b/src/ifcgeom/kernels/opencascade/face_definition.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include /* Returns whether wire conforms to a polyhedron, i.e. only edges with linear curves*/ bool ifcopenshell::geom::util::is_polyhedron(const TopoDS_Wire & wire) { diff --git a/src/ifcgeom/kernels/opencascade/faceset_helper.cpp b/src/ifcgeom/kernels/opencascade/faceset_helper.cpp index 29a0218fb4..2b9dfb1e7f 100644 --- a/src/ifcgeom/kernels/opencascade/faceset_helper.cpp +++ b/src/ifcgeom/kernels/opencascade/faceset_helper.cpp @@ -65,7 +65,7 @@ ifcopenshell::geom::open_cascade_kernel::faceset_helper::faceset_helper( gp_Pnt* p = new gp_Pnt(convert_xyz(*points[i])); pnts[i].reset(p); B.MakeVertex(vertices[i], *p, ::Precision::Confusion()); - tree.add(i, vertices[i]); + tree.add(static_cast(i), vertices[i]); box.Add(*p); } @@ -148,7 +148,7 @@ ifcopenshell::geom::open_cascade_kernel::faceset_helper::faceset_helper( auto num_retained = std::count(retained.begin(), retained.end(), true); - if (unique.size() != num_retained) { + if (unique.size() != static_cast(num_retained)) { ifcopenshell::logger::root().notice("GEO", 168, "Collapsed vertices from " + std::to_string(pnts.size()) + " (" + std::to_string(unique.size()) + " unique) to " + std::to_string(num_retained)); } diff --git a/src/ifcgeom/kernels/opencascade/layerset.cpp b/src/ifcgeom/kernels/opencascade/layerset.cpp index eaa14f59db..5ec499dbcc 100644 --- a/src/ifcgeom/kernels/opencascade/layerset.cpp +++ b/src/ifcgeom/kernels/opencascade/layerset.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/ifcgeom/kernels/opencascade/tree.h b/src/ifcgeom/kernels/opencascade/tree.h index eb66227934..63d57c3d02 100644 --- a/src/ifcgeom/kernels/opencascade/tree.h +++ b/src/ifcgeom/kernels/opencascade/tree.h @@ -151,9 +151,9 @@ namespace ifcopenshell::geom { bool should_check_again = false ) const { ray v_ray; - v_ray.origin[0] = v.X(); - v_ray.origin[1] = v.Y(); - v_ray.origin[2] = v.Z(); + v_ray.origin[0] = static_cast(v.X()); + v_ray.origin[1] = static_cast(v.Y()); + v_ray.origin[2] = static_cast(v.Z()); if (should_check_again) { // The first check may be incorrect if it intersects @@ -194,12 +194,12 @@ namespace ifcopenshell::geom { box box; // + 1e-5 for tolerance - box.corners[0][0] = min_point[0] - 1e-5; - box.corners[0][1] = min_point[1] - 1e-5; - box.corners[0][2] = min_point[2] - 1e-5; - box.corners[1][0] = max_point[0] + 1e-5; - box.corners[1][1] = max_point[1] + 1e-5; - box.corners[1][2] = max_point[2] + 1e-5; + box.corners[0][0] = static_cast(min_point[0] - 1e-5); + box.corners[0][1] = static_cast(min_point[1] - 1e-5); + box.corners[0][2] = static_cast(min_point[2] - 1e-5); + box.corners[1][0] = static_cast(max_point[0] + 1e-5); + box.corners[1][1] = static_cast(max_point[1] + 1e-5); + box.corners[1][2] = static_cast(max_point[2] + 1e-5); /* std::cout << "Ray " << v_ray.origin[0] << " " @@ -273,22 +273,22 @@ namespace ifcopenshell::geom { gp_Vec ray_vector = e2 - e1; double edge_length = ray_vector.Magnitude(); - std::array min_int; - std::array max_int; + std::array min_int{}; + std::array max_int{}; ray_vector.Normalize(); ray v_ray; - v_ray.origin[0] = ray_origin.X(); - v_ray.origin[1] = ray_origin.Y(); - v_ray.origin[2] = ray_origin.Z(); + v_ray.origin[0] = static_cast(ray_origin.X()); + v_ray.origin[1] = static_cast(ray_origin.Y()); + v_ray.origin[2] = static_cast(ray_origin.Z()); - v_ray.dir[0] = ray_vector.X(); - v_ray.dir[1] = ray_vector.Y(); - v_ray.dir[2] = ray_vector.Z(); - v_ray.dir_inv[0] = 1.0f / ray_vector.X(); - v_ray.dir_inv[1] = 1.0f / ray_vector.Y(); - v_ray.dir_inv[2] = 1.0f / ray_vector.Z(); + v_ray.dir[0] = static_cast(ray_vector.X()); + v_ray.dir[1] = static_cast(ray_vector.Y()); + v_ray.dir[2] = static_cast(ray_vector.Z()); + v_ray.dir_inv[0] = static_cast(1.0 / ray_vector.X()); + v_ray.dir_inv[1] = static_cast(1.0 / ray_vector.Y()); + v_ray.dir_inv[2] = static_cast(1.0 / ray_vector.Z()); double min_distance = std::numeric_limits::infinity(); double max_distance = -std::numeric_limits::infinity(); @@ -305,12 +305,12 @@ namespace ifcopenshell::geom { box box; // + 1e-5 for tolerance - box.corners[0][0] = min_point[0] - 1e-5; - box.corners[0][1] = min_point[1] - 1e-5; - box.corners[0][2] = min_point[2] - 1e-5; - box.corners[1][0] = max_point[0] + 1e-5; - box.corners[1][1] = max_point[1] + 1e-5; - box.corners[1][2] = max_point[2] + 1e-5; + box.corners[0][0] = static_cast(min_point[0] - 1e-5); + box.corners[0][1] = static_cast(min_point[1] - 1e-5); + box.corners[0][2] = static_cast(min_point[2] - 1e-5); + box.corners[1][0] = static_cast(max_point[0] + 1e-5); + box.corners[1][1] = static_cast(max_point[1] + 1e-5); + box.corners[1][2] = static_cast(max_point[2] + 1e-5); if ( ! is_intersect_ray_box(&v_ray, &box)) { continue; @@ -491,12 +491,12 @@ namespace ifcopenshell::geom { std::unordered_set points_not_in_b_cache; double protrusion = -std::numeric_limits::infinity(); - std::array protrusion_point; - std::array surface_point; + std::array protrusion_point{}; + std::array surface_point{}; double pierce = -std::numeric_limits::infinity(); - std::array pierce_point1; - std::array pierce_point2; + std::array pierce_point1{}; + std::array pierce_point2{}; for (const auto& pair : bvh_clashes) { const int bvh_a_i = pair.first; @@ -573,14 +573,14 @@ namespace ifcopenshell::geom { const gp_Vec& normal_a = normals_a[i]; double v_protrusion = std::numeric_limits::infinity(); - std::array v_protrusion_point; - std::array v_surface_point; + std::array v_protrusion_point{}; + std::array v_surface_point{}; // Check for protrusions. for (const auto& bvh_b_i : bvh_b_is) { for (int j=bvh_b->BegPrimitive(bvh_b_i); j<=bvh_b->EndPrimitive(bvh_b_i); ++j) { - const std::array& tri = tris_b[j]; - const gp_Vec& normal_b = normals_b[j]; + const std::array& tri_b = tris_b[j]; + const gp_Vec& normal_b = normals_b[j]; tri_count_++; @@ -591,9 +591,9 @@ namespace ifcopenshell::geom { continue; } - gp_Vec ta(verts_b[tri[0]].XYZ()); - gp_Vec tb(verts_b[tri[1]].XYZ()); - gp_Vec tc(verts_b[tri[2]].XYZ()); + gp_Vec ta(verts_b[tri_b[0]].XYZ()); + gp_Vec tb(verts_b[tri_b[1]].XYZ()); + gp_Vec tc(verts_b[tri_b[2]].XYZ()); for (const auto& v : points_in_b) { gp_Vec ray_origin(v.XYZ()); @@ -688,10 +688,10 @@ namespace ifcopenshell::geom { for (const auto& bvh_b_i : bvh_b_is) { for (int j=bvh_b->BegPrimitive(bvh_b_i); j<=bvh_b->EndPrimitive(bvh_b_i); ++j) { - const std::array& tri = tris_b[j]; - const gp_Pnt& v1_b_pnt = verts_b[tri[0]]; - const gp_Pnt& v2_b_pnt = verts_b[tri[1]]; - const gp_Pnt& v3_b_pnt = verts_b[tri[2]]; + const std::array& tri_b = tris_b[j]; + const gp_Pnt& v1_b_pnt = verts_b[tri_b[0]]; + const gp_Pnt& v2_b_pnt = verts_b[tri_b[1]]; + const gp_Pnt& v3_b_pnt = verts_b[tri_b[2]]; const gp_Vec& normal_b = normals_b[j]; tri_count_++; @@ -795,8 +795,8 @@ namespace ifcopenshell::geom { const std::vector& verts_b = verts_.find(tB)->second; double min_clearance = std::numeric_limits::infinity(); - std::array clearance_point1; - std::array clearance_point2; + std::array clearance_point1{}; + std::array clearance_point2{}; for (const auto& pair : bvh_clashes) { const int bvh_a_i = pair.first; @@ -816,10 +816,10 @@ namespace ifcopenshell::geom { for (const auto& bvh_b_i : bvh_b_is) { for (int j=bvh_b->BegPrimitive(bvh_b_i); j<=bvh_b->EndPrimitive(bvh_b_i); ++j) { - const std::array& tri = tris_b[j]; - const gp_Pnt& v1_b_pnt = verts_b[tri[0]]; - const gp_Pnt& v2_b_pnt = verts_b[tri[1]]; - const gp_Pnt& v3_b_pnt = verts_b[tri[2]]; + const std::array& tri_b = tris_b[j]; + const gp_Pnt& v1_b_pnt = verts_b[tri_b[0]]; + const gp_Pnt& v2_b_pnt = verts_b[tri_b[1]]; + const gp_Pnt& v3_b_pnt = verts_b[tri_b[2]]; tri_count_++; @@ -1690,7 +1690,7 @@ namespace ifcopenshell::geom { const auto builder = new BVH_LinearBuilder(BVH_Constants_LeafNodeSizeDefault, BVH_Constants_MaxTreeDepth); BVH_Triangulation triangulation(builder); - for (int i = 0; i < elem_verts.size(); i += 3) { + for (size_t i = 0; i < elem_verts.size(); i += 3) { #if OCC_VERSION_HEX >= 0x80000 triangulation.Vertices.Append(BVH_Vec3d(elem_verts[i], elem_verts[i + 1], elem_verts[i + 2])); #else @@ -1699,7 +1699,7 @@ namespace ifcopenshell::geom { verts.push_back(gp_Pnt(elem_verts[i], elem_verts[i + 1], elem_verts[i + 2])); } - for (int i = 0; i < elem_faces.size(); i += 3) { + for (size_t i = 0; i < elem_faces.size(); i += 3) { const auto& v1_pnt = verts[elem_faces[i]]; const auto& v2_pnt = verts[elem_faces[i + 1]]; const auto& v3_pnt = verts[elem_faces[i + 2]]; diff --git a/src/ifcgeom/kernels/opencascade/wire_utils.cpp b/src/ifcgeom/kernels/opencascade/wire_utils.cpp index 4321229075..99ce27401a 100644 --- a/src/ifcgeom/kernels/opencascade/wire_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/wire_utils.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -218,11 +218,11 @@ ifcopenshell::geom::util::triangulate_wire_result ifcopenshell::geom::util::tria if (!tri.IsNull()) { - const NCollection_Array1& triangles = tri->Triangles(); - for (int i = 1; i <= triangles.Length(); ++i) { + for (int i = 1; i <= tri->NbTriangles(); ++i) { + const Poly_Triangle& triangle = tri->Triangle(i); if (face.Orientation() == TopAbs_REVERSED) - triangles(i).Get(n123[2], n123[1], n123[0]); - else triangles(i).Get(n123[0], n123[1], n123[2]); + triangle.Get(n123[2], n123[1], n123[0]); + else triangle.Get(n123[0], n123[1], n123[2]); // Create polygons from the mesh vertices BRepBuilderAPI_MakeWire mp2; diff --git a/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.cpp b/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.cpp index cb71607d3f..ef4119546f 100644 --- a/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.cpp +++ b/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.cpp @@ -77,13 +77,6 @@ namespace { return a < b ? edge_key{ a, b } : edge_key{ b, a }; } - Eigen::Matrix4d item_matrix(const taxonomy::geom_item::ptr& item) { - if (item && item->matrix) { - return item->matrix->ccomponents(); - } - return Eigen::Matrix4d::Identity(); - } - Eigen::Vector3d transform_point(const Eigen::Matrix4d& m, const Eigen::Vector3d& p) { Eigen::Vector4d v(p(0), p(1), p(2), 1.); return (m * v).head<3>(); @@ -155,7 +148,7 @@ namespace { if (!face_points(face, points)) { continue; } - auto total = external * part_matrix; // *item_matrix(face) * item_matrix(face->children.front()); + auto total = external * part_matrix; std::vector indices; indices.reserve(points.size()); for (const auto& point : points) { diff --git a/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp b/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp index 0ab5b62e42..eec3ef01d9 100644 --- a/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp +++ b/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) using namespace ifcopenshell::geom; -taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface& inst) { +taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface&) { // @todo we'll need to add support for p-curves at some point, but not now. return nullptr; diff --git a/src/ifcgeom/mapping/IfcRightCircularCone.cpp b/src/ifcgeom/mapping/IfcRightCircularCone.cpp index 6b8b3a0328..8074b14d39 100644 --- a/src/ifcgeom/mapping/IfcRightCircularCone.cpp +++ b/src/ifcgeom/mapping/IfcRightCircularCone.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) using namespace ifcopenshell::geom; -taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCone& inst) { +taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCone&) { // @todo return nullptr; /* diff --git a/src/ifcgeom/mapping/IfcRightCircularCylinder.cpp b/src/ifcgeom/mapping/IfcRightCircularCylinder.cpp index c035bfcc0b..aed54cd978 100644 --- a/src/ifcgeom/mapping/IfcRightCircularCylinder.cpp +++ b/src/ifcgeom/mapping/IfcRightCircularCylinder.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) using namespace ifcopenshell::geom; -taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCylinder& inst) { +taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCylinder&) { // @todo return nullptr; /* diff --git a/src/ifcgeom/mapping/IfcSphericalSurface.cpp b/src/ifcgeom/mapping/IfcSphericalSurface.cpp index 06c9246a30..e0703761f5 100644 --- a/src/ifcgeom/mapping/IfcSphericalSurface.cpp +++ b/src/ifcgeom/mapping/IfcSphericalSurface.cpp @@ -23,7 +23,7 @@ using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcSphericalSurface -taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSphericalSurface& inst) { +taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSphericalSurface&) { return nullptr; /* diff --git a/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp b/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp index 10ba2c1f5b..b8e764df69 100644 --- a/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp +++ b/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp @@ -52,23 +52,8 @@ namespace { taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid& inst) { auto loop = taxonomy::cast(map(inst.Directrix())); - // Start- EndParam became optional in IFC4 -#ifdef SCHEMA_IfcSweptDiskSolid_StartParam_IS_OPTIONAL - auto sp = inst.StartParam(); - auto ep = inst.EndParam(); -#else - std::optional sp, ep; - try { - sp = inst.StartParam(); - ep = inst.EndParam(); - } catch (const ifcopenshell::exception& e) { - logger_.warning("GEO", 293, e); - } -#endif - - const double tol = settings_.get().get(); - #ifdef SCHEMA_HAS_IfcSweptDiskSolidPolygonal + const double tol = settings_.get().get(); if (inst.as()) { auto fr = inst.as().FilletRadius(); if (fr && *fr > tol) { diff --git a/src/ifcgeom/mapping/IfcTrimmedCurve.cpp b/src/ifcgeom/mapping/IfcTrimmedCurve.cpp index 02cb0abe08..a2bcdb84f2 100644 --- a/src/ifcgeom/mapping/IfcTrimmedCurve.cpp +++ b/src/ifcgeom/mapping/IfcTrimmedCurve.cpp @@ -73,7 +73,6 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve& inst) { const double tol = settings_.get().get(); trim_cartesian &= has_pnts[0] && has_pnts[1]; - bool trim_cartesian_failed = !trim_cartesian; if (trim_cartesian) { if ((pnts[0]->ccomponents() - pnts[1]->ccomponents()).norm() < (2 * tol)) { logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 295, "Skipping segment with length below tolerance level:", inst); diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index f2bee147b6..b5c8f19696 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -665,7 +665,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceStyle& style) { auto styles = style.Styles(); IfcSchema::IfcSurfaceStyleShading shading; for (auto& s : styles) { - if (shading = s.as()) { + if ((shading = s.as())) { break; } } @@ -989,7 +989,7 @@ void mapping::initialize_settings() { bool selected_sub_context = false; auto subs = context.HasSubContexts(); for (auto& sub : subs) { - if (cids.find(context.id()) != cids.end()) { + if (cids.find(sub.id()) != cids.end()) { selected_sub_context = true; break; } diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index 06b63f7033..53528d569c 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -372,12 +372,12 @@ protected: int new_index = 0; for (size_t orig = 0; orig < diffuse_color_array.size(); ++orig) { - auto& m = diffuse_color_array[orig]; - if (m) { + auto& material = diffuse_color_array[orig]; + if (material) { for (int i = 0; i < 4; ++i) { - diffuse_color_array_condensed.push_back((*m)[i]); + diffuse_color_array_condensed.push_back((*material)[i]); } - orig_to_condensed_index_map[orig] = new_index++; + orig_to_condensed_index_map[static_cast(orig)] = new_index++; } } diff --git a/src/ifcparse/alignment_helper.cpp b/src/ifcparse/alignment_helper.cpp index 78f988cb69..814bb6788f 100644 --- a/src/ifcparse/alignment_helper.cpp +++ b/src/ifcparse/alignment_helper.cpp @@ -777,8 +777,6 @@ std::pair mapAlignme auto start_height = segment.StartHeight(); auto start_gradient = segment.StartGradient(); auto end_gradient = segment.EndGradient(); - auto radius_of_curvature = segment.RadiusOfCurvature(); - auto type = segment.PredefinedType(); if (type == Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CONSTANTGRADIENT) { @@ -862,7 +860,7 @@ std::pair mapAlignme return result; } -std::pair mapAlignmentCantSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, ifcopenshell::logger& logger) { +std::pair mapAlignmentCantSegment(hierarchy_helper&, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, ifcopenshell::logger& logger) { std::pair result; auto type = segment.PredefinedType(); if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_BLOSSCURVE) { diff --git a/src/ifcparse/logger.h b/src/ifcparse/logger.h index b2ba557b2b..9726c83eb8 100644 --- a/src/ifcparse/logger.h +++ b/src/ifcparse/logger.h @@ -23,7 +23,6 @@ #include "ifc_parse_api.h" #include "express.h" -#include #include #include #include @@ -156,15 +155,28 @@ class IFC_PARSE_API logger { // `logger_or_root` is just covering the boilerplate for this pattern. inline logger& logger_or_root(logger* logger) { return logger ? *logger : logger::root(); } +namespace detail { +class performance_scope { + std::string label_; + + public: + explicit performance_scope(const std::string& label) : label_(label) { + logger::root().message(logger::LOG_PERF, label_); + } + + ~performance_scope() { + logger::root().message(logger::LOG_PERF, "done " + label_); + } + + performance_scope(const performance_scope&) = delete; + performance_scope& operator=(const performance_scope&) = delete; +}; +} // namespace detail + } // namespace ifcopenshell -#define PERF(x) \ - \ - ::ifcopenshell::logger::root().message(::ifcopenshell::logger::LOG_PERF, x); \ - \ - BOOST_SCOPE_EXIT(void) { \ - ::ifcopenshell::logger::root().message(::ifcopenshell::logger::LOG_PERF, "done " + std::string(x)); \ - } \ - BOOST_SCOPE_EXIT_END +#define IFCOPENSHELL_PERF_NAME_IMPL(line) ifcopenshell_performance_scope_##line +#define IFCOPENSHELL_PERF_NAME(line) IFCOPENSHELL_PERF_NAME_IMPL(line) +#define PERF(x) ::ifcopenshell::detail::performance_scope IFCOPENSHELL_PERF_NAME(__LINE__)(x) #endif diff --git a/src/ifcparse/schema_plugin.cpp b/src/ifcparse/schema_plugin.cpp index d37e321fca..4ae369e6c1 100644 --- a/src/ifcparse/schema_plugin.cpp +++ b/src/ifcparse/schema_plugin.cpp @@ -25,9 +25,7 @@ #include "macros.h" #include "si_prefix.h" -#define INCLUDE_SCHEMA(x) STRINGIFY(schemas/x.h) -#include INCLUDE_SCHEMA(IfcSchema) -#undef INCLUDE_SCHEMA +#include INCLUDE_SCHEMA(schemas, IfcSchema) #define CAT(a, b) a##b #define EXPAND_AND_CAT(a, b) CAT(a, b) diff --git a/src/serializers/svg_serializer.cpp b/src/serializers/svg_serializer.cpp index ea086aa154..92971291b0 100644 --- a/src/serializers/svg_serializer.cpp +++ b/src/serializers/svg_serializer.cpp @@ -857,7 +857,6 @@ void svg_serializer::write(const ifcopenshell::geom::native_element* brep_obj) { double pu, pv; Extrema_ExtPElS ext; ext.Perform(gp::Origin(), *pln, 1.e-5); - auto P0 = pln->Location(); pln->SetLocation(ext.Point(1).Value()); ext.Point(1).Parameter(pu, pv); @@ -896,7 +895,6 @@ void svg_serializer::write(const ifcopenshell::geom::native_element* brep_obj) { } { - bool any_wires_converted_to_face = false; BRep_Builder BB; TopoDS_Compound comp2; BB.MakeCompound(comp2); @@ -908,7 +906,6 @@ void svg_serializer::write(const ifcopenshell::geom::native_element* brep_obj) { TopoDS_Compound faces; ifcopenshell::geom::util::convert_wire_to_faces(TopoDS::Wire(s), faces, wts); BB.Add(comp2, faces); - any_wires_converted_to_face = true; } else { BB.Add(comp2, s); } @@ -1132,7 +1129,7 @@ void svg_serializer::write(const geometry_data& data) { section_heights_used = section_data_ ? std::addressof(*section_data_) : nullptr; } else { if (data.storey) { - section_heights_storage.push_back(horizontal_plan{ data.storey, data.storey_elevation, +1. }); + section_heights_storage.push_back(horizontal_plan{ data.storey, data.storey_elevation, +1., std::numeric_limits::infinity() }); } else { logger().warning("SER", 24, "No global section height and unable to determine building storey for:", data.product); return; @@ -2456,14 +2453,14 @@ void svg_serializer::finalize() { gp_Pnt((xmin + xmax) / 2., (ymin + ymax) / 2., 0.), gp_Dir(-1, 0, 0), gp_Dir(0, -1, 0))); - deferred_section_data_->push_back(vertical_section{ pln , "Section North South", true }); + deferred_section_data_->push_back(vertical_section{ pln , "Section North South", true, std::nullopt, std::nullopt }); } { gp_Pln pln(gp_Ax3( gp_Pnt((xmin + xmax) / 2., (ymin + ymax) / -2., 0.), gp_Dir(0, -1, 0), gp_Dir(1, 0, 0))); - deferred_section_data_->push_back(vertical_section{ pln , "Section East West", true }); + deferred_section_data_->push_back(vertical_section{ pln , "Section East West", true, std::nullopt, std::nullopt }); } } @@ -2473,28 +2470,28 @@ void svg_serializer::finalize() { gp_Pnt(0., -(ymin - 0.1), 0.), gp_Dir(0, 1, 0), gp_Dir(-1, 0, 0))); - deferred_section_data_->push_back(vertical_section{ pln , "Elevation South", true }); + deferred_section_data_->push_back(vertical_section{ pln , "Elevation South", true, std::nullopt, std::nullopt }); } { gp_Pln pln(gp_Ax3( gp_Pnt(xmax + 0.1, 0., 0.), gp_Dir(1, 0, 0), gp_Dir(0, 1, 0))); - deferred_section_data_->push_back(vertical_section{ pln , "Elevation East", true }); + deferred_section_data_->push_back(vertical_section{ pln , "Elevation East", true, std::nullopt, std::nullopt }); } { gp_Pln pln(gp_Ax3( gp_Pnt(0., -(ymax + 0.1), 0.), gp_Dir(0, -1, 0), gp_Dir(1, 0, 0))); - deferred_section_data_->push_back(vertical_section{ pln , "Elevation North", true }); + deferred_section_data_->push_back(vertical_section{ pln , "Elevation North", true, std::nullopt, std::nullopt }); } { gp_Pln pln(gp_Ax3( gp_Pnt(xmin - 0.1, 0., 0.), gp_Dir(-1, 0, 0), gp_Dir(0, -1, 0))); - deferred_section_data_->push_back(vertical_section{ pln , "Elevation West", true }); + deferred_section_data_->push_back(vertical_section{ pln , "Elevation West", true, std::nullopt, std::nullopt }); } } diff --git a/src/serializers/svg_serializer.h b/src/serializers/svg_serializer.h index 8336c4ced8..f7540b51ec 100644 --- a/src/serializers/svg_serializer.h +++ b/src/serializers/svg_serializer.h @@ -385,12 +385,12 @@ namespace { public: prefiltered_hlr(ifcopenshell::logger& logger, bool use_prefiltering, bool use_hlr_poly, bool segment_projection, const gp_Pln& view_direction) - : logger_(logger) - , use_prefiltering_(use_prefiltering) + : use_prefiltering_(use_prefiltering) , use_hlr_poly_(use_hlr_poly) , segment_projection_(segment_projection) // @nb negative z in accordance with occt projector convention (and opengl) , view_direction_(view_direction.Axis()) + , logger_(logger) { if (use_hlr_poly_) { engine_ = new HLRBRep_PolyAlgo; @@ -648,9 +648,9 @@ public: , polygonal_(false) , emit_building_storeys_(true) , no_css_(false) + , unify_inputs_(false) , mirror_y_(false) , mirror_x_(false) - , unify_inputs_(false) , profile_threshold_(-1) , svg_ridge_angle_min_deg_(45.) , svg_valley_angle_min_deg_(12.) @@ -774,7 +774,7 @@ public: only_valid_ = b; } - bool getOnlyValid(bool b) const { + bool getOnlyValid(bool) const { return only_valid_; } @@ -795,7 +795,7 @@ public: void addDrawing(const gp_Pnt& pos, const gp_Dir& dir, const gp_Dir& ref, const std::string& name, bool include_projection) { deferred_section_data_.emplace(); - deferred_section_data_->push_back(vertical_section{ gp_Pln(gp_Ax3(pos, dir, ref)), name, include_projection }); + deferred_section_data_->push_back(vertical_section{ gp_Pln(gp_Ax3(pos, dir, ref)), name, include_projection, std::nullopt, std::nullopt }); } void setSubtractionSettings(subtract_before_project sbp) { diff --git a/src/serializers/ttl_wkt_serializer.cpp b/src/serializers/ttl_wkt_serializer.cpp index 1ed0c38a59..2b5460c6d6 100644 --- a/src/serializers/ttl_wkt_serializer.cpp +++ b/src/serializers/ttl_wkt_serializer.cpp @@ -215,7 +215,7 @@ namespace { << std::hex << std::setw(4) << std::setfill('0') << (c & 0xFFFF); } else { - escaped.put(c); + escaped.put(static_cast(c)); } break; } @@ -339,7 +339,7 @@ void ttl_wkt_serializer::write(const ifcopenshell::geom::triangulation_element* } else { filename_.stream << ttl_object_id(o, "_geometry") << " a geo:Geometry ;\n"; bool force_2d = true; - double z_value; + double z_value = 0.; for (size_t i = 2; i < o->geometry().verts().size(); i += 3) { const auto& cur = o->geometry().verts()[i]; if (i == 2) { @@ -457,18 +457,18 @@ void ttl_wkt_serializer::write(const ifcopenshell::geom::native_element* brep_ob BRepGProp::SurfaceProperties(face, props); auto area = props.Mass(); - BRepTools_WireExplorer it(wire); + BRepTools_WireExplorer wire_it(wire); std::vector loop_coords; - for (; it.More(); it.Next()) { - const auto& v = it.CurrentVertex(); + for (; wire_it.More(); wire_it.Next()) { + const auto& v = wire_it.CurrentVertex(); auto pnt = BRep_Tool::Pnt(v); loop_coords.push_back(pnt.X()); loop_coords.push_back(pnt.Y()); loop_coords.push_back(pnt.Z()); } std::vector loop_idxs(loop_coords.size() / 3); - for (int i = 0; i < loop_idxs.size(); ++i) { - loop_idxs[i] = i; + for (std::size_t loop_index = 0; loop_index < loop_idxs.size(); ++loop_index) { + loop_idxs[loop_index] = static_cast(loop_index); } std::string postfix = "_section_geometry_" + std::to_string(N++); @@ -509,7 +509,7 @@ std::string ttl_wkt_serializer::ttl_object_id(const ifcopenshell::geom::element* { auto oid = boost::replace_all_copy(object_id(o), "-", "_"); if (oid.find('$') == std::string::npos) { - return "base:" + oid + (postfix ? postfix : (const char* const)""); + return "base:" + oid + (postfix ? postfix : ""); } else { std::string base; if (settings_.get().has()) { @@ -517,7 +517,7 @@ std::string ttl_wkt_serializer::ttl_object_id(const ifcopenshell::geom::element* } else { base = "http://example.org/"; } - return "<" + base + oid + (postfix ? postfix : (const char* const)"") + ">"; + return "<" + base + oid + (postfix ? postfix : "") + ">"; } }