mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-31 00:46:36 +00:00
Work towards space boundaries fix
This commit is contained in:
@@ -24,12 +24,12 @@ void ifcopenshell::geometry::impl::MappingFactoryImplementation::bind(const std:
|
||||
this->insert(std::make_pair(schema_name_lower, fn));
|
||||
}
|
||||
|
||||
ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(IfcParse::IfcFile* file) {
|
||||
ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(IfcParse::IfcFile* file, settings& s) {
|
||||
const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name());
|
||||
std::map<std::string, ifcopenshell::geometry::impl::mapping_fn>::const_iterator it;
|
||||
it = this->find(schema_name_lower);
|
||||
if (it == end()) {
|
||||
throw IfcParse::IfcException("No geometry mapping registered for " + schema_name_lower);
|
||||
}
|
||||
return it->second(file);
|
||||
return it->second(file, s);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,11 @@ namespace geometry {
|
||||
typedef boost::function<bool(IfcUtil::IfcBaseEntity*)> filter_t;
|
||||
|
||||
class abstract_mapping {
|
||||
protected:
|
||||
settings settings_;
|
||||
public:
|
||||
abstract_mapping(settings& s) : settings_(s) {}
|
||||
|
||||
virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseClass*) = 0;
|
||||
virtual void get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters, settings& s) = 0;
|
||||
virtual IfcUtil::IfcBaseEntity* get_decomposing_entity(IfcUtil::IfcBaseEntity* product, bool include_openings = true) = 0;
|
||||
@@ -37,13 +41,13 @@ namespace geometry {
|
||||
};
|
||||
|
||||
namespace impl {
|
||||
typedef boost::function1<abstract_mapping*, IfcParse::IfcFile*> mapping_fn;
|
||||
typedef boost::function2<abstract_mapping*, IfcParse::IfcFile*, settings&> mapping_fn;
|
||||
|
||||
class MappingFactoryImplementation : public std::map<std::string, mapping_fn> {
|
||||
public:
|
||||
MappingFactoryImplementation();
|
||||
void bind(const std::string& schema_name, mapping_fn);
|
||||
abstract_mapping* construct(IfcParse::IfcFile*);
|
||||
abstract_mapping* construct(IfcParse::IfcFile*, settings&);
|
||||
};
|
||||
|
||||
MappingFactoryImplementation& mapping_implementations();
|
||||
|
||||
@@ -447,6 +447,24 @@ CGAL::Polyhedron_3<Kernel_> CgalKernel::create_cube(double d) {
|
||||
return create_polyhedron(face_list);
|
||||
}
|
||||
|
||||
bool CgalKernel::thin_solid(const CGAL::Nef_polyhedron_3<Kernel_>& a, CGAL::Nef_polyhedron_3<Kernel_>& result) {
|
||||
// @todo this should be possible as a minkowski sum of facet & cube. rather than a set of boolean ops.
|
||||
|
||||
auto a_nonconst = a;
|
||||
auto ax = CGAL::minkowski_sum_3(a_nonconst, precision_cube_);
|
||||
auto x = ax - a;
|
||||
|
||||
result = x;
|
||||
return true;
|
||||
|
||||
auto yxy = CGAL::minkowski_sum_3(x, precision_cube_);
|
||||
auto y = yxy * a;
|
||||
auto zyz = CGAL::minkowski_sum_3(y, precision_cube_);
|
||||
result = yxy * zyz;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_reference, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3<Kernel_>& result, bool dilate) {
|
||||
cgal_shape_t shape = shape_const;
|
||||
|
||||
@@ -589,7 +607,10 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ifcopenshell::
|
||||
first = false;
|
||||
}
|
||||
|
||||
cgal_shape_t a_poly;
|
||||
cgal_shape_t a_poly, b_poly;
|
||||
|
||||
// CGAL::Nef_polyhedron_3<Kernel_> b;
|
||||
// thin_solid(a, b);
|
||||
|
||||
try {
|
||||
a.convert_to_polyhedron(a_poly);
|
||||
|
||||
@@ -99,6 +99,7 @@ namespace kernels {
|
||||
|
||||
CGAL::Polyhedron_3<Kernel_> create_cube(double d);
|
||||
bool preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_reference, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3<Kernel_>& result, bool dilate);
|
||||
bool thin_solid(const CGAL::Nef_polyhedron_3<Kernel_>& a, CGAL::Nef_polyhedron_3<Kernel_>& result);
|
||||
public:
|
||||
|
||||
CgalKernel()
|
||||
@@ -128,6 +129,8 @@ namespace kernels {
|
||||
virtual bool convert_impl(const taxonomy::shell*, ifcopenshell::geometry::ConversionResults&);
|
||||
virtual bool convert_impl(const taxonomy::extrusion*, ifcopenshell::geometry::ConversionResults&);
|
||||
virtual bool convert_impl(const taxonomy::boolean_result*, ifcopenshell::geometry::ConversionResults&);
|
||||
|
||||
const CGAL::Nef_polyhedron_3<Kernel_>& precision_cube() const { return precision_cube_; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
namespace {
|
||||
struct POSTFIX_SCHEMA(factory_t) {
|
||||
abstract_mapping* operator()(IfcParse::IfcFile* file) const {
|
||||
ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)(file);
|
||||
abstract_mapping* operator()(IfcParse::IfcFile* file, settings& settings) const {
|
||||
ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)(file, settings);
|
||||
return m;
|
||||
}
|
||||
};
|
||||
@@ -321,7 +321,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcProduct* inst) {
|
||||
auto c = new taxonomy::collection;
|
||||
c->matrix = as<taxonomy::matrix4>(map(inst->ObjectPlacement()));
|
||||
|
||||
if (openings->size()) {
|
||||
if (openings->size() && !settings_.get(settings::DISABLE_OPENING_SUBTRACTIONS)) {
|
||||
auto ci = c->matrix.components.inverse();
|
||||
|
||||
IfcEntityList::ptr operands(new IfcEntityList);
|
||||
|
||||
@@ -19,10 +19,10 @@ namespace geometry {
|
||||
double length_unit_, angle_unit_;
|
||||
std::string length_unit_name_;
|
||||
const IfcParse::declaration* placement_rel_to_;
|
||||
|
||||
|
||||
void initialize_units_();
|
||||
public:
|
||||
POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file) : file_(file), placement_rel_to_(0) {
|
||||
POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file, settings& settings) : abstract_mapping(settings), file_(file), placement_rel_to_(0) {
|
||||
initialize_units_();
|
||||
}
|
||||
virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseClass*);
|
||||
|
||||
@@ -2,19 +2,21 @@
|
||||
|
||||
#include "../../ifcgeom/schema_agnostic/IfcGeomElement.h"
|
||||
|
||||
ifcopenshell::geometry::Converter::Converter(const std::string& geometry_library, IfcParse::IfcFile* file) {
|
||||
ifcopenshell::geometry::Converter::Converter(const std::string& geometry_library, IfcParse::IfcFile* file, settings& s)
|
||||
: settings_(s)
|
||||
{
|
||||
kernel_ = kernels::construct(geometry_library, file);
|
||||
mapping_ = impl::mapping_implementations().construct(file);
|
||||
mapping_ = impl::mapping_implementations().construct(file, settings_);
|
||||
}
|
||||
|
||||
ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(
|
||||
const ifcopenshell::geometry::settings& settings, IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product) {
|
||||
IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product) {
|
||||
|
||||
std::stringstream representation_id_builder;
|
||||
|
||||
const std::string product_type = product->declaration().name();
|
||||
// @todo
|
||||
element_settings s(settings, 1.0 /*getValue(GV_LENGTH_UNIT) */, product_type);
|
||||
element_settings s(settings_, 1.0 /*getValue(GV_LENGTH_UNIT) */, product_type);
|
||||
|
||||
int parent_id = -1;
|
||||
try {
|
||||
@@ -210,7 +212,7 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
|
||||
}
|
||||
|
||||
ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create_brep_for_processed_representation(
|
||||
const ifcopenshell::geometry::settings& /* settings */, IfcUtil::IfcBaseEntity* /* representation */, IfcUtil::IfcBaseEntity* product,
|
||||
IfcUtil::IfcBaseEntity* /* representation */, IfcUtil::IfcBaseEntity* product,
|
||||
ifcopenshell::geometry::NativeElement* brep)
|
||||
{
|
||||
int parent_id = -1;
|
||||
|
||||
@@ -17,8 +17,10 @@ namespace ifcopenshell { namespace geometry {
|
||||
private:
|
||||
abstract_mapping* mapping_;
|
||||
kernels::AbstractKernel* kernel_;
|
||||
|
||||
ifcopenshell::geometry::settings settings_;
|
||||
public:
|
||||
kernels::AbstractKernel* kernel() { return kernel_; }
|
||||
|
||||
// Tolerances and settings for various geometrical operations:
|
||||
enum GeomValue {
|
||||
// Specifies the deflection of the mesher
|
||||
@@ -49,7 +51,7 @@ namespace ifcopenshell { namespace geometry {
|
||||
GV_DIMENSIONALITY
|
||||
};
|
||||
|
||||
Converter(const std::string& geometry_library, IfcParse::IfcFile* file);
|
||||
Converter(const std::string& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::settings& settings);
|
||||
|
||||
~Converter() {}
|
||||
|
||||
@@ -81,8 +83,8 @@ namespace ifcopenshell { namespace geometry {
|
||||
return results;
|
||||
}
|
||||
|
||||
ifcopenshell::geometry::NativeElement* create_brep_for_representation_and_product(const ifcopenshell::geometry::settings& settings, IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product);
|
||||
ifcopenshell::geometry::NativeElement* create_brep_for_processed_representation(const ifcopenshell::geometry::settings& settings, IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product, ifcopenshell::geometry::NativeElement* brep);
|
||||
ifcopenshell::geometry::NativeElement* create_brep_for_representation_and_product(IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product);
|
||||
ifcopenshell::geometry::NativeElement* create_brep_for_processed_representation(IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product, ifcopenshell::geometry::NativeElement* brep);
|
||||
|
||||
/*
|
||||
static int count(const ifcopenshell::geometry::ConversionResultShape*, int, bool unique=false);
|
||||
|
||||
@@ -69,7 +69,9 @@ namespace IfcGeom {
|
||||
// @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.
|
||||
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->data().file);
|
||||
// @todo pass settings
|
||||
ifcopenshell::geometry::settings s;
|
||||
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->data().file, s);
|
||||
while ((parent = mapping->get_decomposing_entity(current, traverse_openings)) != nullptr) {
|
||||
if (pred(parent)) {
|
||||
return true;
|
||||
@@ -175,7 +177,9 @@ namespace IfcGeom {
|
||||
: wildcard_filter(include, traverse, patterns) {}
|
||||
|
||||
bool match(IfcUtil::IfcBaseEntity* prod) const {
|
||||
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->data().file);
|
||||
// @todo
|
||||
ifcopenshell::geometry::settings 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();
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace {
|
||||
{
|
||||
IfcUtil::IfcBaseEntity* representation = rep->representation;
|
||||
IfcUtil::IfcBaseEntity* product = (IfcUtil::IfcBaseEntity*) *rep->products->begin();
|
||||
auto brep = converter->create_brep_for_representation_and_product(settings, representation, product);
|
||||
auto brep = converter->create_brep_for_representation_and_product(representation, product);
|
||||
if (!brep) {
|
||||
return;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ namespace {
|
||||
rep->elements = { elem };
|
||||
|
||||
for (auto it = rep->products->begin() + 1; it != rep->products->end(); ++it) {
|
||||
auto brep2 = converter->create_brep_for_processed_representation(settings, representation, (IfcUtil::IfcBaseEntity*) *it, brep);
|
||||
auto brep2 = converter->create_brep_for_processed_representation(representation, (IfcUtil::IfcBaseEntity*) *it, brep);
|
||||
if (brep2) {
|
||||
auto elem2 = process_based_on_settings(settings, brep, dynamic_cast<ifcopenshell::geometry::TriangulationElement*>(elem));
|
||||
if (elem2) {
|
||||
@@ -209,7 +209,7 @@ namespace ifcopenshell { namespace geometry {
|
||||
const double unit_magnitude() const { return unit_magnitude_; }
|
||||
|
||||
bool initialize() {
|
||||
converter_ = new Converter(geometry_library_, ifc_file);
|
||||
converter_ = new Converter(geometry_library_, ifc_file, settings_);
|
||||
converter_->mapping()->get_representations(tasks_, filters_, settings_);
|
||||
|
||||
if (tasks_.size() == 0) {
|
||||
@@ -243,7 +243,7 @@ namespace ifcopenshell { namespace geometry {
|
||||
std::vector<Converter*> kernel_pool;
|
||||
kernel_pool.reserve(conc_threads);
|
||||
for (unsigned i = 0; i < conc_threads; ++i) {
|
||||
kernel_pool.push_back(new Converter(geometry_library_, ifc_file));
|
||||
kernel_pool.push_back(new Converter(geometry_library_, ifc_file, settings_));
|
||||
}
|
||||
|
||||
std::vector<std::future<void>> threadpool;
|
||||
@@ -377,6 +377,8 @@ namespace ifcopenshell { namespace geometry {
|
||||
const gp_XYZ& bounds_min() const { return bounds_min_; }
|
||||
const gp_XYZ& bounds_max() const { return bounds_max_; }
|
||||
|
||||
Converter& converter() { return *converter_; }
|
||||
|
||||
private:
|
||||
// Move to the next IfcRepresentation
|
||||
void _nextShape() {
|
||||
|
||||
Reference in New Issue
Block a user