MCPcopy Create free account
hub / github.com/ThatOpen/engine_web-ifc / ReadLinearScalingFactor

Method ReadLinearScalingFactor

src/cpp/web-ifc/cache/IfcCache.cpp:184–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182 }
183
184 void IfcCache::ReadLinearScalingFactor()
185 {
186 auto projects = _loader.GetExpressIDsWithType(schema::IFCPROJECT);
187
188 if (projects.size() != 1)
189 {
190 spdlog::error("[ReadLinearScalingFactor()] unexpected empty ifc project");
191 return;
192 }
193
194 auto projectEID = projects[0];
195 _loader.MoveToArgumentOffset(projectEID, 8);
196 auto tk = _loader.GetTokenType();
197 _loader.StepBack();
198 if (tk != parsing::REF)
199 {
200 // IfcProject::UnitsInContext is an optional argument, no error or warning
201 return;
202 }
203
204 auto unitsID = _loader.GetRefArgument();
205 _loader.MoveToArgumentOffset(unitsID, 0);
206
207 tk = _loader.GetTokenType();
208 _loader.StepBack();
209 if (tk != parsing::SET_BEGIN)
210 {
211 // IfcUnitAssignment::Units vector can be empty. Avoid infinite loop in _loader.GetSetArgument()
212 return;
213 }
214 auto unitIds = _loader.GetSetArgument();
215
216 for (auto &unitID : unitIds)
217 {
218 auto unitRef = _loader.GetRefArgument(unitID);
219 auto lineType = _loader.GetLineType(unitRef);
220
221 if (lineType == schema::IFCSIUNIT)
222 {
223 _loader.MoveToArgumentOffset(unitRef, 1);
224 std::string_view unitType = _loader.GetStringArgument();
225
226 std::string_view unitPrefix;
227
228 _loader.MoveToArgumentOffset(unitRef, 2);
229 if (_loader.GetTokenType() == parsing::IfcTokenType::ENUM)
230 {
231 _loader.StepBack();
232 unitPrefix = _loader.GetStringArgument();
233 }
234
235 _loader.MoveToArgumentOffset(unitRef, 3);
236 std::string_view unitName = _loader.GetStringArgument();
237
238 if (unitType == "LENGTHUNIT" && unitName == "METRE")
239 {
240 double prefix = ConvertPrefix(unitPrefix);
241 _linearScalingFactor *= prefix;

Callers

nothing calls this directly

Calls 11

errorFunction · 0.85
GetExpressIDsWithTypeMethod · 0.80
sizeMethod · 0.80
MoveToArgumentOffsetMethod · 0.80
GetTokenTypeMethod · 0.80
StepBackMethod · 0.80
GetRefArgumentMethod · 0.80
GetSetArgumentMethod · 0.80
GetStringArgumentMethod · 0.80
GetDoubleArgumentMethod · 0.80
GetLineTypeMethod · 0.45

Tested by

no test coverage detected