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

Function WriteSet

src/cpp/wasm/web-ifc-wasm.cpp:475–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473}
474
475bool WriteSet(uint32_t modelID, emscripten::val &val)
476{
477 bool responseCode = true;
478 auto loader = manager.GetIfcLoader(modelID);
479 loader->Push<uint8_t>(webifc::parsing::IfcTokenType::SET_BEGIN);
480
481 uint32_t size = val["length"].as<uint32_t>();
482 for (size_t i = 0; i < size; i++)
483 {
484 emscripten::val child = val[std::to_string(i)];
485 if (child.isNull())
486 loader->Push<uint8_t>(webifc::parsing::IfcTokenType::EMPTY);
487 else if (child.isUndefined())
488 loader->Push<uint8_t>(webifc::parsing::IfcTokenType::UNKNOWN);
489 else if (child.isArray())
490 WriteSet(modelID, child);
491 else if (child["value"].isArray())
492 {
493 emscripten::val innerVal = child["value"];
494 webifc::parsing::IfcTokenType type = static_cast<webifc::parsing::IfcTokenType>(child["type"].as<uint32_t>());
495 loader->Push(webifc::parsing::IfcTokenType::SET_BEGIN);
496 uint32_t sz = innerVal["length"].as<uint32_t>();
497 for (size_t z = 0; z < sz; z++)
498 {
499 loader->Push<uint8_t>(type);
500 if (type == webifc::parsing::IfcTokenType::INTEGER)
501 {
502 int value = innerVal[std::to_string(z)].as<int>();
503 loader->PushInt(value);
504 }
505 else
506 {
507 double value = innerVal[std::to_string(z)].as<double>();
508 loader->PushDouble(value);
509 }
510 }
511 loader->Push(webifc::parsing::IfcTokenType::SET_END);
512 }
513 else if (child["type"].isNumber())
514 {
515 webifc::parsing::IfcTokenType type = static_cast<webifc::parsing::IfcTokenType>(child["type"].as<uint32_t>());
516 loader->Push(type);
517 switch (type)
518 {
519 case webifc::parsing::IfcTokenType::LINE_END:
520 case webifc::parsing::IfcTokenType::EMPTY:
521 case webifc::parsing::IfcTokenType::SET_BEGIN:
522 case webifc::parsing::IfcTokenType::SET_END:
523 {
524 // ignore, we should not be seeing this
525 break;
526 }
527 case webifc::parsing::IfcTokenType::UNKNOWN:
528 {
529 // ignore, already pushed above, no further data
530 break;
531 }
532 case webifc::parsing::IfcTokenType::LABEL:

Callers 2

WriteHeaderLineFunction · 0.85
WriteLineFunction · 0.85

Calls 7

WriteValueFunction · 0.85
errorFunction · 0.85
GetIfcLoaderMethod · 0.80
PushIntMethod · 0.80
PushDoubleMethod · 0.80
sizeMethod · 0.80
PushMethod · 0.45

Tested by

no test coverage detected