@@ -1197,27 +1197,38 @@ namespace bimGeometry
11971197 dpts.erase (dpts.begin ());
11981198 }
11991199
1200- // connect the curves
1201- for (size_t i = 1 ; i < dpts.size (); i++)
1200+ std::vector<std::vector<uint32_t >> curvePointIndices;
1201+ curvePointIndices.reserve (curves.size ());
1202+ for (size_t i = 0 ; i < curves.size (); ++i)
12021203 {
1203- glm::dvec3 p1 = dpts[i - 1 ];
1204- glm::dvec3 p2 = dpts[i];
1205- glm::dvec3 dir = p1 - p2;
1206- glm::dvec4 ddir = glm::dvec4 (dir, 0 );
1207- const double di = glm::distance (p1, p2);
1204+ auto & pts = curves[i];
1205+ std::vector<uint32_t >& indices = curvePointIndices.emplace_back ();
1206+ indices.reserve (pts.size ());
1207+ const glm::dvec3 center = dpts[i];
12081208
1209- // Only segments smaller than 10 cm will be represented, those that are bigger will be standardized
1210-
1211- const auto &c1 = curves[i - 1 ];
1212- const auto &c2 = curves[i];
1209+ for (glm::dvec3& p : pts)
1210+ {
1211+ // Radially outward normals
1212+ glm::dvec3 n = p - center;
1213+ const double len2 = glm::dot (n, n);
1214+ n = (len2 > 0.0 ) ? n / std::sqrt (len2) : glm::dvec3 (0.0 , 0.0 , 1.0 );
1215+ geom.AddPoint (p, n);
1216+ indices.push_back (geom.numPoints - 1 );
1217+ }
1218+ }
1219+ // connect consecutive circles with faces
1220+ for (size_t i = 1 ; i < dpts.size (); i++)
1221+ {
1222+ const auto & idx1 = curvePointIndices[i - 1 ];
1223+ const auto & idx2 = curvePointIndices[i];
12131224
1214- uint32_t capSize = c1 .size ();
1225+ const uint32_t capSize = static_cast < uint32_t >(idx1 .size () );
12151226 for (size_t j = 1 ; j < capSize; j++)
12161227 {
1217- glm::dvec3 bl = c1 [j - 1 ];
1218- glm::dvec3 br = c1 [j - 0 ];
1219- glm::dvec3 tl = c2 [j - 1 ];
1220- glm::dvec3 tr = c2 [j - 0 ];
1228+ const uint32_t bl = idx1 [j - 1 ];
1229+ const uint32_t br = idx1 [j - 0 ];
1230+ const uint32_t tl = idx2 [j - 1 ];
1231+ const uint32_t tr = idx2 [j - 0 ];
12211232
12221233 geom.AddFace (tl, br, bl);
12231234 geom.AddFace (tl, tr, br);
0 commit comments