| 276 | } |
| 277 | |
| 278 | bool LNLib::KnotVectorUtils::IsUniform(const std::vector<double>& knotVector) |
| 279 | { |
| 280 | auto map = GetKnotMultiplicityMap(knotVector); |
| 281 | if (map.empty()) |
| 282 | { |
| 283 | return false; |
| 284 | } |
| 285 | std::vector<double> knots; |
| 286 | for (auto it = map.begin(); it != map.end(); ++it) |
| 287 | { |
| 288 | double key = it->first; |
| 289 | knots.emplace_back(key); |
| 290 | } |
| 291 | std::sort(knots.begin(), knots.end()); |
| 292 | if (map[knots[0]] != map[knots[knots.size() - 1]]) |
| 293 | { |
| 294 | return false; |
| 295 | } |
| 296 | double standard = knots[1] - knots[0]; |
| 297 | for (int i = 1; i < knots.size() - 1; i++) |
| 298 | { |
| 299 | double current = knots[i]; |
| 300 | double next = knots[i + 1]; |
| 301 | |
| 302 | double gap = next - current; |
| 303 | if (!MathUtils::IsAlmostEqualTo(gap, standard)) |
| 304 | { |
| 305 | return false; |
| 306 | } |
| 307 | int currentCounts = map[current]; |
| 308 | int nextCounts = map[next]; |
| 309 | if (currentCounts != nextCounts) |
| 310 | { |
| 311 | if (i + 1 == knots.size() - 1) |
| 312 | { |
| 313 | continue; |
| 314 | } |
| 315 | else |
| 316 | { |
| 317 | return false; |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | return true; |
| 322 | } |
| 323 | |
| 324 | |
| 325 |
nothing calls this directly
no outgoing calls
no test coverage detected