mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:23:41 +00:00
Const ptr references and address some warnings
This commit is contained in:
@@ -26,7 +26,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* inst) {
|
|||||||
const bool use_body = !this->settings_.get<settings::IncludeCurves>().get();
|
const bool use_body = !this->settings_.get<settings::IncludeCurves>().get();
|
||||||
|
|
||||||
auto items = map_to_collection(this, inst->Items());
|
auto items = map_to_collection(this, inst->Items());
|
||||||
if (items == nullptr) {
|
if (!items) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ Eigen::Matrix4d ifcopenshell::geometry::taxonomy::piecewise_function::evaluate(d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ifcopenshell::geometry::taxonomy::collection::ptr ifcopenshell::geometry::flatten(taxonomy::collection::ptr deep) {
|
ifcopenshell::geometry::taxonomy::collection::ptr ifcopenshell::geometry::flatten(const taxonomy::collection::ptr& deep) {
|
||||||
auto flat = make<taxonomy::collection>();
|
auto flat = make<taxonomy::collection>();
|
||||||
ifcopenshell::geometry::visit<taxonomy::collection>(deep, [&flat](taxonomy::ptr i) {
|
ifcopenshell::geometry::visit<taxonomy::collection>(deep, [&flat](taxonomy::ptr i) {
|
||||||
flat->children.push_back(taxonomy::cast<taxonomy::geom_item>(clone(i)));
|
flat->children.push_back(taxonomy::cast<taxonomy::geom_item>(clone(i)));
|
||||||
|
|||||||
+14
-11
@@ -120,7 +120,7 @@ typedef item const* ptr;
|
|||||||
return computed_hash_;
|
return computed_hash_;
|
||||||
}
|
}
|
||||||
|
|
||||||
item(const IfcUtil::IfcBaseInterface* instance = nullptr) : identity_(counter_++), instance(instance), computed_hash_(0) {}
|
item(const IfcUtil::IfcBaseInterface* instance = nullptr) : identity_(counter_++), computed_hash_(0), instance(instance) {}
|
||||||
|
|
||||||
virtual ~item() {}
|
virtual ~item() {}
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ typedef item const* ptr;
|
|||||||
// length of span, function to evaluate span
|
// length of span, function to evaluate span
|
||||||
std::vector<std::pair<double, std::function<Eigen::Matrix4d(double u)>>> spans;
|
std::vector<std::pair<double, std::function<Eigen::Matrix4d(double u)>>> spans;
|
||||||
|
|
||||||
void print(std::ostream& o, int indent = 0) const {
|
void print(std::ostream& o, int = 0) const {
|
||||||
o << "piecewise_function" << std::endl;
|
o << "piecewise_function" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ typedef item const* ptr;
|
|||||||
o << std::string(indent, ' ') << class_name;
|
o << std::string(indent, ' ') << class_name;
|
||||||
if (this->components_) {
|
if (this->components_) {
|
||||||
int n = T::RowsAtCompileTime * T::ColsAtCompileTime;
|
int n = T::RowsAtCompileTime * T::ColsAtCompileTime;
|
||||||
for (size_t i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
o << " " << (*components_)(i);
|
o << " " << (*components_)(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,8 +278,8 @@ typedef item const* ptr;
|
|||||||
size_t h = std::hash<size_t>{}(T::RowsAtCompileTime);
|
size_t h = std::hash<size_t>{}(T::RowsAtCompileTime);
|
||||||
boost::hash_combine(h, std::hash<size_t>{}(T::ColsAtCompileTime));
|
boost::hash_combine(h, std::hash<size_t>{}(T::ColsAtCompileTime));
|
||||||
if (components_) {
|
if (components_) {
|
||||||
for (size_t i = 0; i < components_->size(); ++i) {
|
for (int i = 0; i < components_->size(); ++i) {
|
||||||
auto elem = *(components_->data() + i);
|
auto elem = *(components_->data() + (size_t) i);
|
||||||
boost::hash_combine(h, std::hash<typename T::Scalar>()(elem));
|
boost::hash_combine(h, std::hash<typename T::Scalar>()(elem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -680,7 +680,9 @@ typedef item const* ptr;
|
|||||||
std::vector<typename T::ptr> children;
|
std::vector<typename T::ptr> children;
|
||||||
|
|
||||||
collection_base() {}
|
collection_base() {}
|
||||||
collection_base(const collection_base& other) {
|
collection_base(const collection_base& other)
|
||||||
|
: geom_item()
|
||||||
|
{
|
||||||
std::transform(other.children.begin(), other.children.end(), std::back_inserter(children), [](typename T::ptr p) { return clone(p); });
|
std::transform(other.children.begin(), other.children.end(), std::back_inserter(children), [](typename T::ptr p) { return clone(p); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,7 +1155,7 @@ typedef item const* ptr;
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, typename Fn>
|
template <typename U, typename Fn>
|
||||||
void visit(typename U::ptr deep, Fn fn) {
|
void visit(const typename U::ptr& deep, Fn fn) {
|
||||||
for (auto& i : deep->children) {
|
for (auto& i : deep->children) {
|
||||||
// @todo Sad... now that we have templated collection members,
|
// @todo Sad... now that we have templated collection members,
|
||||||
// we can't generally use collection_base anymore as a cast target.
|
// we can't generally use collection_base anymore as a cast target.
|
||||||
@@ -1185,7 +1187,7 @@ typedef item const* ptr;
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U, typename Fn>
|
template <typename T, typename U, typename Fn>
|
||||||
void visit_2(typename U::ptr c, const Fn& fn) {
|
void visit_2(const typename U::ptr& c, const Fn& fn) {
|
||||||
static_assert(std::is_same<T, taxonomy::point3>::value, "@todo Only implemented for point3");
|
static_assert(std::is_same<T, taxonomy::point3>::value, "@todo Only implemented for point3");
|
||||||
for (auto& i : c->children) {
|
for (auto& i : c->children) {
|
||||||
// @todo Sad... now that we have templated collection members,
|
// @todo Sad... now that we have templated collection members,
|
||||||
@@ -1226,10 +1228,10 @@ typedef item const* ptr;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taxonomy::collection::ptr flatten(taxonomy::collection::ptr deep);
|
taxonomy::collection::ptr flatten(const taxonomy::collection::ptr& deep);
|
||||||
|
|
||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
bool apply_predicate_to_collection(taxonomy::ptr i, Fn fn) {
|
bool apply_predicate_to_collection(const taxonomy::ptr& i, Fn fn) {
|
||||||
if (i->kind() == taxonomy::COLLECTION) {
|
if (i->kind() == taxonomy::COLLECTION) {
|
||||||
auto c = taxonomy::cast<taxonomy::collection>(i);
|
auto c = taxonomy::cast<taxonomy::collection>(i);
|
||||||
for (auto& child : c->children) {
|
for (auto& child : c->children) {
|
||||||
@@ -1237,6 +1239,7 @@ typedef item const* ptr;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return fn(i);
|
return fn(i);
|
||||||
@@ -1245,7 +1248,7 @@ typedef item const* ptr;
|
|||||||
|
|
||||||
// @nb traverses nested collections
|
// @nb traverses nested collections
|
||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
taxonomy::collection::ptr filter(taxonomy::collection::ptr collection, Fn fn) {
|
taxonomy::collection::ptr filter(const taxonomy::collection::ptr& collection, Fn fn) {
|
||||||
auto filtered = taxonomy::make<taxonomy::collection>();
|
auto filtered = taxonomy::make<taxonomy::collection>();
|
||||||
for (auto& child : collection->children) {
|
for (auto& child : collection->children) {
|
||||||
if (apply_predicate_to_collection(child, fn)) {
|
if (apply_predicate_to_collection(child, fn)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user