Work towards space boundaries fix

This commit is contained in:
Thomas Krijnen
2019-10-06 19:03:31 +02:00
parent f391b425ba
commit a5de17228a
13 changed files with 292 additions and 28 deletions
+7 -5
View File
@@ -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;
+6 -4
View File
@@ -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);
+6 -2
View File
@@ -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() {