MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / object_id_unique

Method object_id_unique

src/serializers/USDSerializer.cpp:120–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120std::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
145template <typename T>
146T USDSerializer::writeNode(const IfcGeom::Element* o, const IfcGeom::Element* p) {

Callers

nothing calls this directly

Calls 9

object_idFunction · 0.85
to_stringFunction · 0.85
toPathFunction · 0.85
substrMethod · 0.80
findMethod · 0.45
idMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected