Silence obvious compiler warnings

Generated with the assistance of an AI coding tool.
This commit is contained in:
Thomas Krijnen
2026-08-08 17:08:26 +02:00
parent b706121f53
commit 61f30dd200
28 changed files with 175 additions and 150 deletions
+2 -19
View File
@@ -17,24 +17,6 @@ ifcopenshell::geom::converter::~converter() {
delete mapping_;
}
namespace {
void substitute_with_box_based_on_density(ifcopenshell::logger& logger, std::vector<ifcopenshell::geom::conversion_result>& 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<std::string>(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<express::entity>();
@@ -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<ifcopenshell::geom::settings::DisableOpeningSubtractions>().get();
const bool above_limit = settings_.get<ifcopenshell::geom::settings::MaxVoidsPerElement>().has() && settings_.get<ifcopenshell::geom::settings::MaxVoidsPerElement>().get() != 0 && openings.size() > settings_.get<ifcopenshell::geom::settings::MaxVoidsPerElement>().get();
const auto max_voids = settings_.get<ifcopenshell::geom::settings::MaxVoidsPerElement>();
const bool above_limit = max_voids.has() && max_voids.get() != 0 && openings.size() > static_cast<std::size_t>(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);
+6 -6
View File
@@ -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); }
+1 -1
View File
@@ -15,7 +15,7 @@ IFC_GEOM_API std::vector<double> 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<taxonomy::function_item>(loop);
}
+3 -15
View File
@@ -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<std::string> 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<double>& v, double target) -> std::vector<double>::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;
+1 -1
View File
@@ -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++;
@@ -138,7 +138,7 @@ namespace {
p[i] += point.cartesian(i);
}
}
kernel_::FT n(wire.size());
kernel_::FT n(static_cast<double>(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<double>(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<conversion_result_shape*> ifcopenshell::geom::cgal_shape::convex_decomposition()
{
#ifdef IFOPSH_SIMPLE_KERNEL
(void)other;
throw std::runtime_error("Not implemented");
#else
std::vector<conversion_result_shape*> result;
@@ -842,6 +843,7 @@ std::vector<conversion_result_shape*> 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<conversion_result_shape*> 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<opaque_coordin
throw std::runtime_error("Not implemented");
}
bool ifcopenshell::geom::cgal_shape::surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const {
bool ifcopenshell::geom::cgal_shape::surface_area_along_direction(double, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double&, double&, double&) const {
// @todo
return false;
}
#ifndef IFOPSH_SIMPLE_KERNEL
void ifcopenshell::geom::cgal_shape_half_space_decomposition::triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
void ifcopenshell::geom::cgal_shape_half_space_decomposition::triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4&, ifcopenshell::geom::triangulation*, int, int, ifcopenshell::logger&) const {
throw std::runtime_error("Not implemented");
}
void ifcopenshell::geom::cgal_shape_half_space_decomposition::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const {
void ifcopenshell::geom::cgal_shape_half_space_decomposition::serialize(const ifcopenshell::geom::taxonomy::matrix4&, std::string&) const {
throw std::runtime_error("Not implemented");
}
@@ -1047,7 +1050,7 @@ int ifcopenshell::geom::cgal_shape_half_space_decomposition::num_vertices() cons
throw std::runtime_error("Not implemented");
}
void ifcopenshell::geom::cgal_shape_half_space_decomposition::set_box(void * b) {
void ifcopenshell::geom::cgal_shape_half_space_decomposition::set_box(void*) {
throw std::runtime_error("Not implemented");
}
@@ -1172,17 +1175,17 @@ std::vector<conversion_result_shape*> 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>, 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");
}
@@ -364,7 +364,7 @@ namespace ifcopenshell { namespace geom {
virtual std::size_t map(const std::vector<opaque_coordinate<4>>& from, const std::vector<opaque_coordinate<4>>& 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;
}
};
+30 -21
View File
@@ -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<double>::infinity();
std::pair<Eigen::Vector3d, Eigen::Vector3d> 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<cgal_face> 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<std::size_t>(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<std::pair<taxonomy::ptr, ifcopenshell::geom::taxonomy::matrix4>>& openings, const std::vector<ifcopenshell::geom::conversion_result> & entity_shapes, const ifcopenshell::geom::taxonomy::matrix4 & entity_trsf, std::vector<ifcopenshell::geom::conversion_result> & 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<CGAL::Nef_polyhedron_3<kernel_>> 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<std::list<std::pair<express::base, cgal_polyhedron>>>& operands, std::list<CGAL::Polygon_2<kernel_>>& loops, double& z0, double& z1) {
bool cgal_kernel::process_as_2d_polygon(const std::list<std::list<std::pair<express::base, cgal_polyhedron>>>& operands, std::list<CGAL::Polygon_2<kernel_>>&, 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<kernel_> 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<CGAL::Polygon_2<kernel_>> 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<kernel_>& 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<kernel_> 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<kernel_>::HalfedgeDS &hds
std::list<CGAL::Polygon_2<kernel_>> 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
@@ -196,7 +196,7 @@ plane_map<Kernel> snap_halfspaces(const std::list<CGAL::Plane_3<Kernel>>& 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();
-2
View File
@@ -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<IfcSchema::IfcBooleanOperand> operands;
operands.push_back(operand2);
@@ -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;
/*
+8 -6
View File
@@ -4,8 +4,9 @@ using namespace ifcopenshell::geom;
taxonomy::loop::ptr ifcopenshell::geom::fillet_loop(taxonomy::loop::ptr loop, double radius) {
std::vector<profile_point_with_edges_3d> 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<int>(loop->children.size());
for (int b = 0; b < child_count; ++b) {
int c = (b + child_count - 1) % child_count;
pps[b] = {
std::get<taxonomy::point3::ptr>(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<taxonomy:
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();
@@ -153,8 +154,9 @@ taxonomy::loop::ptr ifcopenshell::geom::profile_helper(const taxonomy::matrix4::
}
std::vector<profile_point_with_edges> 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<int>(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<taxonomy::point3::ptr>, std::vector<std::set<std::string>>
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();
+2 -2
View File
@@ -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<std::size_t>(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<std::size_t>(i) < shapes_.size()) {
return shapes_[i].ItemId();
} else {
return 0;
+4 -17
View File
@@ -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 <size_t N>
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)) {
+14 -14
View File
@@ -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<taxonomy::collection>(i)) {
ifcopenshell::geom::visit<taxonomy::collection>(s, fn);
} else if (auto s = std::dynamic_pointer_cast<taxonomy::loop>(i)) {
ifcopenshell::geom::visit<taxonomy::loop>(s, fn);
} else if (auto s = std::dynamic_pointer_cast<taxonomy::face>(i)) {
ifcopenshell::geom::visit<taxonomy::face>(s, fn);
} else if (auto s = std::dynamic_pointer_cast<taxonomy::shell>(i)) {
ifcopenshell::geom::visit<taxonomy::shell>(s, fn);
} else if (auto s = std::dynamic_pointer_cast<taxonomy::solid>(i)) {
ifcopenshell::geom::visit<taxonomy::solid>(s, fn);
} else if (auto s = std::dynamic_pointer_cast<taxonomy::loft>(i)) {
ifcopenshell::geom::visit<taxonomy::loft>(s, fn);
} else if (auto s = std::dynamic_pointer_cast<taxonomy::boolean_result>(i)) {
ifcopenshell::geom::visit<taxonomy::boolean_result>(s, fn);
if (auto collection = std::dynamic_pointer_cast<taxonomy::collection>(i)) {
ifcopenshell::geom::visit<taxonomy::collection>(collection, fn);
} else if (auto loop = std::dynamic_pointer_cast<taxonomy::loop>(i)) {
ifcopenshell::geom::visit<taxonomy::loop>(loop, fn);
} else if (auto face = std::dynamic_pointer_cast<taxonomy::face>(i)) {
ifcopenshell::geom::visit<taxonomy::face>(face, fn);
} else if (auto shell = std::dynamic_pointer_cast<taxonomy::shell>(i)) {
ifcopenshell::geom::visit<taxonomy::shell>(shell, fn);
} else if (auto solid = std::dynamic_pointer_cast<taxonomy::solid>(i)) {
ifcopenshell::geom::visit<taxonomy::solid>(solid, fn);
} else if (auto loft = std::dynamic_pointer_cast<taxonomy::loft>(i)) {
ifcopenshell::geom::visit<taxonomy::loft>(loft, fn);
} else if (auto boolean_result = std::dynamic_pointer_cast<taxonomy::boolean_result>(i)) {
ifcopenshell::geom::visit<taxonomy::boolean_result>(boolean_result, fn);
}
else {
fn(i);
+13
View File
@@ -79,11 +79,16 @@ namespace {
return val;
}
#endif
throw std::logic_error("RocksDB storage is unavailable");
}
template<typename T>
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<T>(index_);
}
@@ -103,10 +108,15 @@ namespace {
return str[0] == type_encoder::encode_type<T>();
}
#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<int64_t>() const
-1
View File
@@ -266,7 +266,6 @@ typename std::conditional_t<
std::vector<T>>
cast_vector(const std::vector<U>& values) {
if constexpr (is_std_vector<U>::value) {
using value_type = typename U::value_type;
std::vector<std::vector<T>> result;
result.reserve(values.size());
for (const auto& value : values) {
+19 -6
View File
@@ -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<std::mutex> lock(instance_cache_mutex_);
@@ -81,6 +85,10 @@ express::base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t
namespace {
std::unique_ptr<rocksdb::DB> 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()) {
+2
View File
@@ -95,6 +95,7 @@ void expand(const std::string& s, std::vector<unsigned char>& v) {
#endif
ifcopenshell::global_id::global_id(logger& logger) {
(void)logger;
uuid_data_ = gen();
std::vector<unsigned char> 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<unsigned char> result;
expand(string_data_, result);
std::copy(result.begin(), result.end(), uuid_data_.begin());
+4 -4
View File
@@ -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<ifcopenshell::impl::rocks_db_file_storage>(), declaration_, id_ ? id_ : identity_, attribute_index, value);
return;
}
#endif
throw std::logic_error("RocksDB storage is unavailable");
}
template<typename T>
@@ -597,6 +596,7 @@ class IFC_PARSE_API instance_data {
return rocks_db_attribute_storage{}.has<T>(get_storage_of_type<ifcopenshell::impl::rocks_db_file_storage>(), 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;
+23 -7
View File
@@ -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<unsigned>& 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<std::vector<express::base>> 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";
+11 -2
View File
@@ -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;
+3
View File
@@ -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;
+1 -1
View File
@@ -35,7 +35,7 @@ double get_SI_equivalent(const typename Schema::IfcNamedUnit& named_unit) {
if (auto conv_unit = named_unit.template as<typename Schema::IfcConversionBasedUnit>()) {
auto factor = conv_unit.ConversionFactor();
auto component = factor.UnitComponent();
if (si_unit = component.concrete().template as<typename Schema::IfcSIUnit>()) {
if ((si_unit = component.concrete().template as<typename Schema::IfcSIUnit>())) {
auto value = factor.ValueComponent();
scale = value.get_attribute_value(0);
}
+1 -1
View File
@@ -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)
{
@@ -60,7 +60,7 @@ class get_type_visitor : public boost::static_visitor<std::string> {
get_type_visitor() = default;
template <typename T>
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<IfcSchema::IfcPreDefinedPropertySet>()) {
} else if (auto predefined_pset = inst.as<IfcSchema::IfcPreDefinedPropertySet>()) {
#else
} else {
#endif
@@ -132,8 +132,8 @@ std::optional<std::string> 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<IfcSchema::IfcMaterialList>()) {
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);
+1 -1
View File
@@ -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) {