| 44 | |
| 45 | template <typename T> |
| 46 | void process_mapping(bool& matched, taxonomy::ptr& item, IfcUtil::IfcBaseInterface const * inst) { |
| 47 | if (!item && inst->as<T>()) { |
| 48 | matched = true; |
| 49 | try { |
| 50 | item = map_impl(inst->as<T>()); |
| 51 | if (item != nullptr) { |
| 52 | if (item->instance == nullptr) { |
| 53 | item->instance = inst; |
| 54 | } |
| 55 | try { |
| 56 | if (inst->as<IfcSchema::IfcRepresentationItem>() && !inst->as<IfcSchema::IfcStyledItem>() && |
| 57 | /* @todo */ |
| 58 | (item->kind() == taxonomy::SOLID || item->kind() == taxonomy::SHELL || item->kind() == taxonomy::COLLECTION || item->kind() == taxonomy::EXTRUSION || item->kind() == taxonomy::LOFT || item->kind() == taxonomy::BOOLEAN_RESULT || item->kind() == taxonomy::REVOLVE || item->kind() == taxonomy::SWEEP_ALONG_CURVE || item->kind() == taxonomy::FACE) |
| 59 | ) { |
| 60 | auto style = find_style(inst->as<IfcSchema::IfcRepresentationItem>()); |
| 61 | if (style) { |
| 62 | auto mstyle = map(style); |
| 63 | if (mstyle) { |
| 64 | taxonomy::cast<taxonomy::geom_item>(item)->surface_style = taxonomy::cast<taxonomy::style>(mstyle); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } catch (const std::exception& e) { |
| 69 | Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", inst); |
| 70 | } |
| 71 | } else if (failed_on_purpose_.find(inst) == failed_on_purpose_.end()) { |
| 72 | Logger::Message(Logger::LOG_ERROR, "Failed to convert:", inst); |
| 73 | } |
| 74 | } catch (const std::exception& e) { |
| 75 | Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", inst); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | const IfcSchema::IfcStyledItem* find_style(const IfcSchema::IfcRepresentationItem*); |
| 80 | public: |
| 81 | POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file, Settings& settings) : abstract_mapping(settings), file_(file), placement_rel_to_type_(0), placement_rel_to_instance_(0) { |