mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
Work towards v1.0 data model with encapsulated weak_ptr as basis for instances
This commit is contained in:
+19
-23
@@ -41,10 +41,6 @@
|
||||
#include <functional>
|
||||
|
||||
namespace IfcGeom {
|
||||
/// The filter function (free or member function) or function object (use boost::ref() to reference to it)
|
||||
/// should return true if the geometry for the product is wanted to be included in the output.
|
||||
/// http://www.boost.org/doc/libs/1_62_0/doc/html/function/tutorial.html
|
||||
typedef boost::function<bool(IfcUtil::IfcBaseEntity*)> filter_t;
|
||||
|
||||
struct filter
|
||||
{
|
||||
@@ -60,7 +56,7 @@ namespace IfcGeom {
|
||||
/// Optional description for the filtering criteria of this filter.
|
||||
std::string description;
|
||||
|
||||
bool match(IfcUtil::IfcBaseEntity* prod, const filter_t& pred) const {
|
||||
bool match(const express::Base& prod, const ifcopenshell::geometry::filter_t& pred) const {
|
||||
bool is_match = pred(prod);
|
||||
if (!is_match && traverse) {
|
||||
is_match = traverse_match(prod, pred);
|
||||
@@ -68,16 +64,16 @@ namespace IfcGeom {
|
||||
return is_match == include;
|
||||
}
|
||||
|
||||
bool traverse_match(IfcUtil::IfcBaseEntity* prod, const filter_t& pred) const
|
||||
bool traverse_match(const express::Base& prod, const ifcopenshell::geometry::filter_t& pred) const
|
||||
{
|
||||
IfcUtil::IfcBaseEntity* parent, *current = prod;
|
||||
express::Base parent, current = prod;
|
||||
// @todo examine if this can indeed be static. For now usage is only
|
||||
// in IfcConvert so invocation is bound to a single file with a single
|
||||
// schema.
|
||||
// @todo pass settings
|
||||
ifcopenshell::geometry::Settings s;
|
||||
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->file_, s);
|
||||
while ((parent = mapping->get_decomposing_entity(current, traverse_openings)) != nullptr) {
|
||||
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod.data()->file(), s);
|
||||
while ((parent = mapping->get_decomposing_entity(current, traverse_openings))) {
|
||||
if (pred(parent)) {
|
||||
return true;
|
||||
}
|
||||
@@ -136,9 +132,9 @@ namespace IfcGeom {
|
||||
attribute_filter(const std::string& attribute_name)
|
||||
: attribute_name(attribute_name) {}
|
||||
|
||||
std::string value(IfcUtil::IfcBaseEntity* prod) const {
|
||||
std::string value(const express::Base& prod) const {
|
||||
try {
|
||||
return (std::string) prod->get(attribute_name);
|
||||
return (std::string) prod.as<express::Entity>().get(attribute_name);
|
||||
} catch (...) {
|
||||
// Either
|
||||
// (a) not an attribute name for this entity instance
|
||||
@@ -150,11 +146,11 @@ namespace IfcGeom {
|
||||
}
|
||||
}
|
||||
|
||||
bool match(IfcUtil::IfcBaseEntity* prod) const {
|
||||
bool match(express::Base prod) const {
|
||||
return wildcard_filter::match(value(prod));
|
||||
}
|
||||
|
||||
bool operator()(IfcUtil::IfcBaseEntity* prod) const {
|
||||
bool operator()(express::Base prod) const {
|
||||
return filter::match(prod, std::bind(&attribute_filter::match, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
@@ -175,21 +171,21 @@ namespace IfcGeom {
|
||||
};
|
||||
|
||||
struct layer_filter : public wildcard_filter {
|
||||
typedef std::map<std::string, IfcUtil::IfcBaseEntity*> layer_map_t;
|
||||
typedef std::map<std::string, express::Base> layer_map_t;
|
||||
|
||||
layer_filter() {}
|
||||
layer_filter(bool include, bool traverse, const std::set<std::string>& patterns)
|
||||
: wildcard_filter(include, traverse, patterns) {}
|
||||
|
||||
bool match(IfcUtil::IfcBaseEntity* prod) const {
|
||||
bool match(express::Base prod) const {
|
||||
// @todo
|
||||
ifcopenshell::geometry::Settings s;
|
||||
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->file_, s);
|
||||
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod.data()->file(), s);
|
||||
layer_map_t layers = mapping->get_layers(prod);
|
||||
return std::find_if(layers.begin(), layers.end(), wildcards_match(values)) != layers.end();
|
||||
}
|
||||
|
||||
bool operator()(IfcUtil::IfcBaseEntity* prod) const {
|
||||
bool operator()(express::Base prod) const {
|
||||
return filter::match(prod, std::bind(&layer_filter::match, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
@@ -222,17 +218,17 @@ namespace IfcGeom {
|
||||
: filter(include, traverse)
|
||||
, entity_names(entity_names) {}
|
||||
|
||||
bool match(IfcUtil::IfcBaseEntity* prod) const {
|
||||
bool match(express::Base prod) const {
|
||||
// The set is iterated over to able to filter on subtypes.
|
||||
for (auto& name : entity_names) {
|
||||
if (prod->declaration().is(name)) {
|
||||
if (prod.declaration().is(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator()(IfcUtil::IfcBaseEntity* prod) const {
|
||||
bool operator()(express::Base prod) const {
|
||||
return filter::match(prod, std::bind(&entity_filter::match, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
@@ -254,11 +250,11 @@ namespace IfcGeom {
|
||||
: filter(include, traverse)
|
||||
, instance_ids_(instance_ids) {}
|
||||
|
||||
bool match(IfcUtil::IfcBaseEntity* prod) const {
|
||||
return instance_ids_.find(prod->id()) != instance_ids_.end();
|
||||
bool match(express::Base prod) const {
|
||||
return instance_ids_.find(prod.id()) != instance_ids_.end();
|
||||
}
|
||||
|
||||
bool operator()(IfcUtil::IfcBaseEntity* prod) const {
|
||||
bool operator()(express::Base prod) const {
|
||||
return filter::match(prod, std::bind(&instance_id_filter::match, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user