Skip to content

Commit

Permalink
Merge pull request #1277 from ThatOpen/NewFunc
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
beachtom authored Feb 17, 2025
2 parents 19564fb + 39dab21 commit c8151f2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 41 deletions.
76 changes: 36 additions & 40 deletions src/cpp/web-ifc/parsing/IfcLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,50 +643,46 @@ namespace webifc::parsing {
}
}

uint32_t IfcLoader::GetNoLineArguments() const
uint32_t IfcLoader::GetNoLineArguments(uint32_t expressID) const
{
uint32_t noArguments = 0;
uint32_t setDepth = 0;
while (true)
{
if (setDepth == 1) noArguments++;

IfcTokenType t = static_cast<IfcTokenType>(_tokenStream->Read<char>());

switch (t)
{
case IfcTokenType::LINE_END: return noArguments;
case IfcTokenType::UNKNOWN:
case IfcTokenType::EMPTY:
break;
case IfcTokenType::SET_BEGIN:
setDepth++;
break;
case IfcTokenType::SET_END:
setDepth--;
if (setDepth == 0) return noArguments;
break;
case IfcTokenType::STRING:
case IfcTokenType::ENUM:
case IfcTokenType::LABEL:
case IfcTokenType::INTEGER:
case IfcTokenType::REAL:
{
uint16_t length = _tokenStream->Read<uint16_t>();
_tokenStream->Forward(length);
break;
}
case IfcTokenType::REF:
{
_tokenStream->Read<uint32_t>();
break;
}
default:
break;
if (!_lines.contains(expressID)) return 0;
_tokenStream->MoveTo(_lines.at(expressID)->tapeOffset);
_tokenStream->Read<char>();
_tokenStream->Read<uint32_t>();
_tokenStream->Read<char>();
uint16_t length = _tokenStream->Read<uint16_t>();
_tokenStream->Forward(length);
_tokenStream->Read<char>();
uint32_t noArguments = 0;

while (true) {
IfcTokenType t = static_cast<IfcTokenType>(_tokenStream->Read<char>());
if (t == SET_END || t==LINE_END) return noArguments;
if (t == UNKNOWN || t==EMPTY) {
noArguments++;
continue;
}
if (t==SET_BEGIN) {
StepBack();
GetSetArgument();
continue;
}
if (t == IfcTokenType::STRING || t == IfcTokenType::INTEGER || t == IfcTokenType::REAL || t == IfcTokenType::LABEL || t == IfcTokenType::ENUM) {
uint16_t length = _tokenStream->Read<uint16_t>();
_tokenStream->Forward(length);
noArguments++;
continue;
}
if (t == REF) {
_tokenStream->Read<uint32_t>();
noArguments++;
continue;
}
}
}
return noArguments;
return noArguments;
}


void IfcLoader::MoveToArgumentOffset(const uint32_t expressID, const uint32_t argumentIndex) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/web-ifc/parsing/IfcLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace webifc::parsing
std::vector<uint32_t> GetAllLines() const;
const std::vector<std::vector<uint32_t>> GetSetListArgument() const;
void MoveToArgumentOffset(const uint32_t expressID, const uint32_t argumentIndex) const;
uint32_t GetNoLineArguments() const;
uint32_t GetNoLineArguments(uint32_t expressID) const;
void StepBack() const;
IFC_SCHEMA GetSchema() const;
void Push(void *v, const uint64_t size);
Expand Down

0 comments on commit c8151f2

Please sign in to comment.