Close to working executable

This commit is contained in:
Thomas Krijnen
2019-08-18 15:53:26 +02:00
parent 8f88c601c6
commit 94aa7dfab4
7 changed files with 49 additions and 16 deletions
@@ -51,6 +51,8 @@ namespace ifcopenshell { namespace geometry { namespace kernels {
virtual bool convert_impl(const taxonomy::face*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); } virtual bool convert_impl(const taxonomy::face*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::extrusion*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); } virtual bool convert_impl(const taxonomy::extrusion*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::node*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); } virtual bool convert_impl(const taxonomy::node*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::colour*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::collection*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); }
}; };
AbstractKernel* construct(const std::string& geometry_library, IfcParse::IfcFile*); AbstractKernel* construct(const std::string& geometry_library, IfcParse::IfcFile*);
+10 -8
View File
@@ -6,16 +6,18 @@
if (l->declaration().is(IfcSchema::T::Class())) { \ if (l->declaration().is(IfcSchema::T::Class())) { \
try { \ try { \
taxonomy::item* item = map((IfcSchema::T*)l); \ taxonomy::item* item = map((IfcSchema::T*)l); \
item->instance = l; \ if (item != nullptr) { \
try { \ item->instance = l; \
if (l->as<IfcSchema::IfcRepresentationItem>()) { \ try { \
auto style = find_style(l->as<IfcSchema::IfcRepresentationItem>()); \ if (l->as<IfcSchema::IfcRepresentationItem>()) { \
if (style) { \ auto style = find_style(l->as<IfcSchema::IfcRepresentationItem>()); \
((taxonomy::geom_item*)item)->surface_style = as<taxonomy::style>(map(style)); \ if (style) { \
((taxonomy::geom_item*)item)->surface_style = as<taxonomy::style>(map(style)); \
} \
} \ } \
} catch (const std::exception& e) { \
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l); \
} \ } \
} catch (const std::exception& e) { \
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l); \
} \ } \
return item; \ return item; \
} catch (const std::exception& e) { \ } catch (const std::exception& e) { \
+17 -1
View File
@@ -126,7 +126,6 @@ namespace {
taxonomy::item* mapping::map(const IfcSchema::IfcExtrudedAreaSolid* inst) { taxonomy::item* mapping::map(const IfcSchema::IfcExtrudedAreaSolid* inst) {
// @todo length unit // @todo length unit
return new taxonomy::extrusion( return new taxonomy::extrusion(
inst,
as<taxonomy::matrix4>(map(inst->Position())), as<taxonomy::matrix4>(map(inst->Position())),
as<taxonomy::face>(map(inst->SweptArea())), as<taxonomy::face>(map(inst->SweptArea())),
as<taxonomy::direction3>(map(inst->ExtrudedDirection())), as<taxonomy::direction3>(map(inst->ExtrudedDirection())),
@@ -134,6 +133,23 @@ taxonomy::item* mapping::map(const IfcSchema::IfcExtrudedAreaSolid* inst) {
); );
} }
taxonomy::item* mapping::map(const IfcSchema::IfcRepresentation* inst) {
auto c = new taxonomy::collection();
IfcSchema::IfcRepresentationItem::list::ptr items = inst->Items();
if (items->size()) {
for (IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++it) {
if (auto r = map(*it)) {
c->children.push_back(r);
}
}
}
if (c->children.empty()) {
delete c;
return nullptr;
}
return c;
}
taxonomy::item* mapping::map(const IfcSchema::IfcAxis2Placement3D* inst) { taxonomy::item* mapping::map(const IfcSchema::IfcAxis2Placement3D* inst) {
// @todo length unit // @todo length unit
return new taxonomy::matrix4(); return new taxonomy::matrix4();
+1 -1
View File
@@ -26,7 +26,7 @@
// BIND(IfcShellBasedSurfaceModel); // BIND(IfcShellBasedSurfaceModel);
// BIND(IfcFaceBasedSurfaceModel); // BIND(IfcFaceBasedSurfaceModel);
// BIND(IfcRepresentation); BIND(IfcRepresentation);
// BIND(IfcMappedItem); // BIND(IfcMappedItem);
// IfcFacetedBrep included // IfcFacetedBrep included
// IfcAdvancedBrep included // IfcAdvancedBrep included
@@ -35,6 +35,11 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
ifcopenshell::geometry::ConversionResults shapes; ifcopenshell::geometry::ConversionResults shapes;
auto rep_item = mapping_->map(representation); auto rep_item = mapping_->map(representation);
// @todo should map() throw an exception instead?
if (rep_item == nullptr) {
return nullptr;
}
// @todo decide how to get placement from product // @todo decide how to get placement from product
auto placement = (taxonomy::geom_item*) mapping_->map(product); auto placement = (taxonomy::geom_item*) mapping_->map(product);
kernel_->convert(rep_item, shapes); kernel_->convert(rep_item, shapes);
@@ -209,6 +209,7 @@ namespace ifcopenshell { namespace geometry {
const double unit_magnitude() const { return unit_magnitude_; } const double unit_magnitude() const { return unit_magnitude_; }
bool initialize() { bool initialize() {
converter_ = new Converter(geometry_library_, ifc_file);
converter_->mapping()->get_representations(tasks_, filters_, settings_); converter_->mapping()->get_representations(tasks_, filters_, settings_);
if (tasks_.size() == 0) { if (tasks_.size() == 0) {
+13 -6
View File
@@ -19,7 +19,7 @@ namespace geometry {
namespace taxonomy { namespace taxonomy {
enum kinds { MATRIX4, POINT3, DIRECTION3, LINE, CIRCLE, ELLIPSE, BSPLINE, EDGE, LOOP, FACE, EXTRUSION, NODE, COLOUR, STYLE }; enum kinds { MATRIX4, POINT3, DIRECTION3, LINE, CIRCLE, ELLIPSE, BSPLINE, EDGE, LOOP, FACE, EXTRUSION, NODE, COLOUR, STYLE, COLLECTION };
struct item { struct item {
const IfcUtil::IfcBaseClass* instance; const IfcUtil::IfcBaseClass* instance;
@@ -83,6 +83,7 @@ struct geom_item : public item {
geom_item(const IfcUtil::IfcBaseClass* instance = nullptr) : item(instance) {} geom_item(const IfcUtil::IfcBaseClass* instance = nullptr) : item(instance) {}
geom_item(const IfcUtil::IfcBaseClass* instance, matrix4 m) : item(instance), matrix(m) {} geom_item(const IfcUtil::IfcBaseClass* instance, matrix4 m) : item(instance), matrix(m) {}
geom_item(matrix4 m) : matrix(m) {}
}; };
template <size_t N> template <size_t N>
@@ -160,8 +161,8 @@ struct face : public geom_item {
struct sweep : public geom_item { struct sweep : public geom_item {
face basis; face basis;
sweep(const IfcUtil::IfcBaseClass* instance, face b) : geom_item(instance), basis(b) {} sweep(face b) : basis(b) {}
sweep(const IfcUtil::IfcBaseClass* instance, matrix4 m, face b) : geom_item(instance, m), basis(b) {} sweep(matrix4 m, face b) : geom_item(m), basis(b) {}
}; };
struct extrusion : public sweep { struct extrusion : public sweep {
@@ -171,7 +172,14 @@ struct extrusion : public sweep {
virtual item* clone() const { return new extrusion(*this); } virtual item* clone() const { return new extrusion(*this); }
virtual kinds kind() const { return EXTRUSION; } virtual kinds kind() const { return EXTRUSION; }
extrusion(const IfcUtil::IfcBaseClass* instance, matrix4 m, face basis, direction3 dir, double d) : sweep(instance, m, basis), direction(dir), depth(d) {} extrusion(matrix4 m, face basis, direction3 dir, double d) : sweep(m, basis), direction(dir), depth(d) {}
};
struct collection : public geom_item {
std::vector<item*> children;
virtual item* clone() const { return new collection(*this); }
virtual kinds kind() const { return COLLECTION; }
}; };
struct node : public geom_item { struct node : public geom_item {
@@ -185,8 +193,7 @@ struct node : public geom_item {
}; };
namespace impl { namespace impl {
// enum kinds { MATRIX4, POINT3, DIRECTION3, LINE, CIRCLE, ELLIPSE, BSPLINE, EDGE, LOOP, FACE, EXTRUSION, NODE }; typedef std::tuple<matrix4, point3, direction3, line, circle, ellipse, bspline, edge, loop, face, extrusion, node, collection> KindsTuple;
typedef std::tuple<matrix4, point3, direction3, line, circle, ellipse, bspline, edge, loop, face, extrusion, node> KindsTuple;
} }
struct type_by_kind { struct type_by_kind {