Skip to content
Merged
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
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace bimGeometry {
void buildPlanes();
size_t AddPlane(const glm::dvec3 &normal, double d);
void AddFace(glm::dvec3 a, glm::dvec3 b, glm::dvec3 c, uint32_t pId = UINT32_MAX);
void AddFace(uint32_t a, uint32_t b, uint32_t c, uint32_t pId);
void AddFace(uint32_t a, uint32_t b, uint32_t c, uint32_t pId = UINT32_MAX);
void AddPoint(glm::dvec4& pt, glm::dvec3& n);
void AddPoint(const glm::dvec3& pt, const glm::dvec3& n);
void AddGeometry(Geometry geom);
Expand Down
43 changes: 27 additions & 16 deletions src/cpp/web-ifc/geometry/operations/bim-geometry/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1197,27 +1197,38 @@ namespace bimGeometry
dpts.erase(dpts.begin());
}

// connect the curves
for (size_t i = 1; i < dpts.size(); i++)
std::vector<std::vector<uint32_t>> curvePointIndices;
curvePointIndices.reserve(curves.size());
for (size_t i = 0; i < curves.size(); ++i)
{
glm::dvec3 p1 = dpts[i - 1];
glm::dvec3 p2 = dpts[i];
glm::dvec3 dir = p1 - p2;
glm::dvec4 ddir = glm::dvec4(dir, 0);
const double di = glm::distance(p1, p2);
auto& pts = curves[i];
std::vector<uint32_t>& indices = curvePointIndices.emplace_back();
indices.reserve(pts.size());
const glm::dvec3 center = dpts[i];

// Only segments smaller than 10 cm will be represented, those that are bigger will be standardized

const auto &c1 = curves[i - 1];
const auto &c2 = curves[i];
for (glm::dvec3& p : pts)
{
// Radially outward normals
glm::dvec3 n = p - center;
const double len2 = glm::dot(n, n);
n = (len2 > 0.0) ? n / std::sqrt(len2) : glm::dvec3(0.0, 0.0, 1.0);
geom.AddPoint(p, n);
indices.push_back(geom.numPoints - 1);
}
}
// connect consecutive circles with faces
for (size_t i = 1; i < dpts.size(); i++)
{
const auto& idx1 = curvePointIndices[i - 1];
const auto& idx2 = curvePointIndices[i];

uint32_t capSize = c1.size();
const uint32_t capSize = static_cast<uint32_t>(idx1.size());
for (size_t j = 1; j < capSize; j++)
{
glm::dvec3 bl = c1[j - 1];
glm::dvec3 br = c1[j - 0];
glm::dvec3 tl = c2[j - 1];
glm::dvec3 tr = c2[j - 0];
const uint32_t bl = idx1[j - 1];
const uint32_t br = idx1[j - 0];
const uint32_t tl = idx2[j - 1];
const uint32_t tr = idx2[j - 0];

geom.AddFace(tl, br, bl);
geom.AddFace(tl, tr, br);
Expand Down
Loading