| 118 | } |
| 119 | |
| 120 | std::string USDSerializer::object_id_unique(const IfcGeom::Element* o) { |
| 121 | auto it = element_names_.find(o->id()); |
| 122 | if (it != element_names_.end()) { |
| 123 | return it->second; |
| 124 | } |
| 125 | int postfix = 0; |
| 126 | auto name = object_id(o); |
| 127 | auto suffix = "-" + boost::to_lower_copy(o->context()); |
| 128 | if (name.size() > suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), name.rbegin())) { |
| 129 | name = name.substr(0, name.size() - suffix.size()); |
| 130 | } |
| 131 | while (true) { |
| 132 | auto unique_name = name; |
| 133 | if (postfix) { |
| 134 | unique_name += "_" + std::to_string(postfix); |
| 135 | } |
| 136 | unique_name = usd_utils::toPath(unique_name); |
| 137 | if (emitted_names_.find(unique_name) == emitted_names_.end()) { |
| 138 | emitted_names_.insert(unique_name); |
| 139 | return element_names_[o->id()] = unique_name; |
| 140 | } |
| 141 | postfix += 1; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | template <typename T> |
| 146 | T USDSerializer::writeNode(const IfcGeom::Element* o, const IfcGeom::Element* p) { |