mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Close to working executable
This commit is contained in:
@@ -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::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::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*);
|
||||
|
||||
@@ -6,16 +6,18 @@
|
||||
if (l->declaration().is(IfcSchema::T::Class())) { \
|
||||
try { \
|
||||
taxonomy::item* item = map((IfcSchema::T*)l); \
|
||||
item->instance = l; \
|
||||
try { \
|
||||
if (l->as<IfcSchema::IfcRepresentationItem>()) { \
|
||||
auto style = find_style(l->as<IfcSchema::IfcRepresentationItem>()); \
|
||||
if (style) { \
|
||||
((taxonomy::geom_item*)item)->surface_style = as<taxonomy::style>(map(style)); \
|
||||
if (item != nullptr) { \
|
||||
item->instance = l; \
|
||||
try { \
|
||||
if (l->as<IfcSchema::IfcRepresentationItem>()) { \
|
||||
auto style = find_style(l->as<IfcSchema::IfcRepresentationItem>()); \
|
||||
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; \
|
||||
} catch (const std::exception& e) { \
|
||||
|
||||
@@ -126,7 +126,6 @@ namespace {
|
||||
taxonomy::item* mapping::map(const IfcSchema::IfcExtrudedAreaSolid* inst) {
|
||||
// @todo length unit
|
||||
return new taxonomy::extrusion(
|
||||
inst,
|
||||
as<taxonomy::matrix4>(map(inst->Position())),
|
||||
as<taxonomy::face>(map(inst->SweptArea())),
|
||||
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) {
|
||||
// @todo length unit
|
||||
return new taxonomy::matrix4();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
// BIND(IfcShellBasedSurfaceModel);
|
||||
// BIND(IfcFaceBasedSurfaceModel);
|
||||
// BIND(IfcRepresentation);
|
||||
BIND(IfcRepresentation);
|
||||
// BIND(IfcMappedItem);
|
||||
// IfcFacetedBrep included
|
||||
// IfcAdvancedBrep included
|
||||
|
||||
@@ -35,6 +35,11 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
|
||||
ifcopenshell::geometry::ConversionResults shapes;
|
||||
|
||||
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
|
||||
auto placement = (taxonomy::geom_item*) mapping_->map(product);
|
||||
kernel_->convert(rep_item, shapes);
|
||||
|
||||
@@ -209,6 +209,7 @@ namespace ifcopenshell { namespace geometry {
|
||||
const double unit_magnitude() const { return unit_magnitude_; }
|
||||
|
||||
bool initialize() {
|
||||
converter_ = new Converter(geometry_library_, ifc_file);
|
||||
converter_->mapping()->get_representations(tasks_, filters_, settings_);
|
||||
|
||||
if (tasks_.size() == 0) {
|
||||
|
||||
+13
-6
@@ -19,7 +19,7 @@ namespace geometry {
|
||||
|
||||
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 {
|
||||
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, matrix4 m) : item(instance), matrix(m) {}
|
||||
geom_item(matrix4 m) : matrix(m) {}
|
||||
};
|
||||
|
||||
template <size_t N>
|
||||
@@ -160,8 +161,8 @@ struct face : public geom_item {
|
||||
struct sweep : public geom_item {
|
||||
face basis;
|
||||
|
||||
sweep(const IfcUtil::IfcBaseClass* instance, face b) : geom_item(instance), basis(b) {}
|
||||
sweep(const IfcUtil::IfcBaseClass* instance, matrix4 m, face b) : geom_item(instance, m), basis(b) {}
|
||||
sweep(face b) : basis(b) {}
|
||||
sweep(matrix4 m, face b) : geom_item(m), basis(b) {}
|
||||
};
|
||||
|
||||
struct extrusion : public sweep {
|
||||
@@ -171,7 +172,14 @@ struct extrusion : public sweep {
|
||||
virtual item* clone() const { return new extrusion(*this); }
|
||||
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 {
|
||||
@@ -185,8 +193,7 @@ struct node : public geom_item {
|
||||
};
|
||||
|
||||
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> KindsTuple;
|
||||
typedef std::tuple<matrix4, point3, direction3, line, circle, ellipse, bspline, edge, loop, face, extrusion, node, collection> KindsTuple;
|
||||
}
|
||||
|
||||
struct type_by_kind {
|
||||
|
||||
Reference in New Issue
Block a user