MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / remove_duplicate_points_from_loop

Method remove_duplicate_points_from_loop

src/ifcgeom/profile_helper.cpp:57–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void ifcopenshell::geometry::remove_duplicate_points_from_loop(std::vector<taxonomy::point3::ptr>& polygon, bool closed, double tol) {
58 tol *= tol;
59
60 for (;;) {
61 bool removed = false;
62 int n = polygon.size() - (closed ? 0 : 1);
63 for (size_t i = 0; i < n; ++i) {
64 // wrap around to the first point in case of a closed loop
65 auto j = (i + 1) % polygon.size();
66 double dist = (polygon[i]->ccomponents() - polygon[j]->ccomponents()).squaredNorm();
67 if (dist < tol) {
68 // do not remove the first or last point to
69 // maintain connectivity with other wires
70 if ((closed && j == 0) || (!closed && j == (n - 1))) {
71 polygon.erase(polygon.begin() + i);
72 } else {
73 polygon.erase(polygon.begin() + j);
74 }
75 removed = true;
76 break;
77 }
78 }
79 if (!removed) break;
80 }
81}
82
83taxonomy::loop::ptr ifcopenshell::geometry::polygon_from_points(const std::vector<taxonomy::point3::ptr>& ps, bool external) {
84 auto loop = taxonomy::make<taxonomy::loop>();

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected