Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/cpp/web-ifc/geometry/IfcGeometryProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ namespace webifc::geometry
std::vector<IfcGeometry> geomVector = {geom}; // Wrap 'geom' in a vector
fusedVoids = BoolProcess(std::vector<IfcGeometry>{fusedVoids}, geomVector, "UNION", _settings);
}
if (fusedVoids.numFaces > _settings._CSG_MAX_NUM_FACES) {
spdlog::warn("High number of faces ({}) in voids for element {}, skipping further CSG operations", fusedVoids.numFaces, expressID);
break;
}
}

joinedVoidGeoms.push_back(fusedVoids);
Expand Down Expand Up @@ -339,6 +343,39 @@ namespace webifc::geometry
return mesh;
}

size_t numFacesGeoms = 0;
for (auto& geom : flatFirstMeshes) {
numFacesGeoms += geom.numFaces;
}
for (auto& geom : flatSecondMeshes) {
numFacesGeoms += geom.numFaces;
}

if (numFacesGeoms > _settings._CSG_MAX_NUM_FACES) {
spdlog::warn("High number of faces in CSG operand ({}), skipping further CSG operations", numFacesGeoms);

// Flatten the first operand (transformed and normalized, like in the normal path)
auto flatFirstMeshes = flatten(firstMesh, _expressIDToGeometry, normalizeMat);

// Merge into a single geometry (equivalent to the first operand without boolean)
IfcGeometry resultMesh;
for (const auto& g : flatFirstMeshes) {
resultMesh.MergeGeometry(g);
}

_expressIDToGeometry[expressID] = resultMesh;
mesh.hasGeometry = true;
mesh.transformation = glm::translate(origin);

if (!mesh.hasColor && firstMesh.hasColor) {
mesh.hasColor = true;
mesh.color = firstMesh.color;
}

// No need to set mesh = firstMesh; we're building a flat geometry here for consistency
return mesh;
}

IfcGeometry resultMesh = BoolProcess(flatFirstMeshes, flatSecondMeshes, std::string(op), _settings);

_expressIDToGeometry[expressID] = resultMesh;
Expand Down
1 change: 1 addition & 0 deletions src/cpp/web-ifc/geometry/IfcGeometryProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace webifc::geometry
double TOLERANCE_INSIDE_OUTSIDE_PERIMETER = 1.0E-10;
double TOLERANCE_BOUNDING_BOX = 1.0E-02;
uint16_t _BOOLEAN_UNION_THRESHOLD = 150;
uint16_t _CSG_MAX_NUM_FACES = 20000;
};

class booleanManager
Expand Down
Loading