Skip to content

Commit

Permalink
Support for relNests in alignment issue #878
Browse files Browse the repository at this point in the history
  • Loading branch information
QuimMoya committed Jul 12, 2024
1 parent 52fce6d commit 3c43aa2
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 7 deletions.
63 changes: 59 additions & 4 deletions src/cpp/geometry/IfcGeometryLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace webifc::geometry
{

IfcGeometryLoader::IfcGeometryLoader(const webifc::parsing::IfcLoader &loader, const webifc::schema::IfcSchemaManager &schemaManager, uint16_t circleSegments)
: _loader(loader), _schemaManager(schemaManager), _relVoidRel(PopulateRelVoidsRelMap()), _relVoids(PopulateRelVoidsMap()), _relAggregates(PopulateRelAggregatesMap()),
: _loader(loader), _schemaManager(schemaManager), _relVoidRel(PopulateRelVoidsRelMap()), _relVoids(PopulateRelVoidsMap()), _relAggregates(PopulateRelAggregatesMap()), _relNests(PopulateRelNestsMap()),
_relElementAggregates(PopulateRelElementAggregatesMap()), _styledItems(PopulateStyledItemMap()), _relMaterials(PopulateRelMaterialsMap()), _materialDefinitions(PopulateMaterialDefinitionsMap()), _circleSegments(circleSegments)
{
ReadLinearScalingFactor();
Expand Down Expand Up @@ -328,6 +328,16 @@ namespace webifc::geometry
}
}

auto &relNestsVector = GetRelNests();
if (relNestsVector.count(expressID) == 1)
{
auto &relNest = relNestsVector.at(expressID);
for (auto expressID : relNest)
{
alignment = GetAlignment(expressID, alignment, transform * transform_t, expressID);
}
}

break;
}
case schema::IFCALIGNMENTHORIZONTAL:
Expand Down Expand Up @@ -365,6 +375,25 @@ namespace webifc::geometry
}
}

auto &relNestVector = GetRelNests();
if (relNestVector.count(expressID) == 1)
{
auto &relNest = relNestVector.at(expressID);
for (auto expressID : relNest)
{
alignment.Horizontal.curves.push_back(GetAlignmentCurve(expressID, sourceExpressID));
}

for (size_t i = 0; i < alignment.Horizontal.curves.size(); i++)
{
for (size_t j = 0; j < alignment.Horizontal.curves[i].points.size(); j++)
{
alignment.Horizontal.curves[i].points[j] =
glm::dvec4(alignment.Horizontal.curves[i].points[j].x, alignment.Horizontal.curves[i].points[j].y, 0, 1) * transform * transform_t;
}
}
}

break;
}
case schema::IFCALIGNMENTVERTICAL:
Expand Down Expand Up @@ -3287,11 +3316,11 @@ IfcProfile IfcGeometryLoader::GetProfile(uint32_t expressID) const
std::unordered_map<uint32_t, std::vector<uint32_t>> IfcGeometryLoader::PopulateRelAggregatesMap()
{
std::unordered_map<uint32_t, std::vector<uint32_t>> resultVector;
auto relVoids = _loader.GetExpressIDsWithType(schema::IFCRELAGGREGATES);
auto relAggregates = _loader.GetExpressIDsWithType(schema::IFCRELAGGREGATES);

for (uint32_t relVoidID : relVoids)
for (uint32_t relAggregateID : relAggregates)
{
_loader.MoveToArgumentOffset(relVoidID, 4);
_loader.MoveToArgumentOffset(relAggregateID, 4);

uint32_t relatingBuildingElement = _loader.GetRefArgument();
auto aggregates = _loader.GetSetArgument();
Expand All @@ -3305,6 +3334,27 @@ IfcProfile IfcGeometryLoader::GetProfile(uint32_t expressID) const
return resultVector;
}

std::unordered_map<uint32_t, std::vector<uint32_t>> IfcGeometryLoader::PopulateRelNestsMap()
{
std::unordered_map<uint32_t, std::vector<uint32_t>> resultVector;
auto relNests = _loader.GetExpressIDsWithType(schema::IFCRELNESTS);

for (uint32_t relNestID : relNests)
{
_loader.MoveToArgumentOffset(relNestID, 4);

uint32_t relatingBuildingElement = _loader.GetRefArgument();
auto nests = _loader.GetSetArgument();

for (auto &nest : nests)
{
uint32_t nestID = _loader.GetRefArgument(nest);
resultVector[relatingBuildingElement].push_back(nestID);
}
}
return resultVector;
}

std::unordered_map<uint32_t, std::vector<uint32_t>> IfcGeometryLoader::PopulateRelElementAggregatesMap()
{
std::unordered_map<uint32_t, std::vector<uint32_t>> resultVector;
Expand Down Expand Up @@ -3567,6 +3617,11 @@ IfcProfile IfcGeometryLoader::GetProfile(uint32_t expressID) const
return _relAggregates;
}

const std::unordered_map<uint32_t, std::vector<uint32_t>> &IfcGeometryLoader::GetRelNests() const
{
return _relNests;
}

const std::unordered_map<uint32_t, std::vector<uint32_t>> &IfcGeometryLoader::GetRelElementAggregates() const
{
return _relElementAggregates;
Expand Down
5 changes: 4 additions & 1 deletion src/cpp/geometry/IfcGeometryLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace webifc::geometry
bool GetColor(const uint32_t expressID, const glm::dvec4 &outputColor) const;
const std::unordered_map<uint32_t, std::vector<uint32_t>> &GetRelVoids() const;
const std::unordered_map<uint32_t, std::vector<uint32_t>> &GetRelVoidRels() const;
const std::unordered_map<uint32_t, std::vector<uint32_t>> &GetRelNests() const;
const std::unordered_map<uint32_t, std::vector<uint32_t>> &GetRelAggregates() const;
const std::unordered_map<uint32_t, std::vector<uint32_t>> &GetRelElementAggregates() const;
const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &GetStyledItems() const;
Expand All @@ -69,7 +70,8 @@ namespace webifc::geometry
const webifc::parsing::IfcLoader &_loader;
const webifc::schema::IfcSchemaManager &_schemaManager;
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relVoidRel;
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relVoids;
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relVoids;
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relNests;
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relAggregates;
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relElementAggregates;
const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> _styledItems;
Expand All @@ -85,6 +87,7 @@ namespace webifc::geometry
mutable std::vector<uint32_t> LocalcurvesIndices;
std::unordered_map<uint32_t, std::vector<uint32_t>> PopulateRelVoidsMap();
std::unordered_map<uint32_t, std::vector<uint32_t>> PopulateRelVoidsRelMap();
std::unordered_map<uint32_t, std::vector<uint32_t>> PopulateRelNestsMap();
std::unordered_map<uint32_t, std::vector<uint32_t>> PopulateRelAggregatesMap();
std::unordered_map<uint32_t, std::vector<uint32_t>> PopulateRelElementAggregatesMap();
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> PopulateStyledItemMap();
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/web-ifc-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ int main()

// return 0;

std::string content = ReadFile("C:/Users/qmoya/Desktop/Element3D 1.ifc");
std::string content = ReadFile("C:/Users/qmoya/Desktop/File2.ifc");

struct LoaderSettings
{
Expand Down Expand Up @@ -326,7 +326,7 @@ int main()
SpecificLoadTest(loader, geometryLoader, 17);

// auto meshes = LoadAllTest(loader, geometryLoader, 5557);
// auto alignments = GetAlignments(loader, geometryLoader);
auto alignments = GetAlignments(loader, geometryLoader);

time = ms() - start;

Expand Down

0 comments on commit 3c43aa2

Please sign in to comment.