MCPcopy Create free account
hub / github.com/BIMCoderLiang/LNLib / IsUniform

Method IsUniform

src/LNLib/Algorithm/KnotVectorUtils.cpp:278–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278bool 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected