MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / countRun

Method countRun

app/src/UI/Widgets/PlotCurve.cpp:455–487  ·  view source on GitHub ↗

* @brief Counts one run's vertices and indices; the walk, direction fallback and fanSegments() * call MUST stay textually identical to emitRun or the passes disagree and overrun the * geometry buffer. qsizetype accumulators tolerate an undecimated raw series. */

Source from the content-addressed store, hash-verified

453 * geometry buffer. qsizetype accumulators tolerate an undecimated raw series.
454 */
455void Widgets::PlotCurve::countRun(const QPointF* px,
456 const qsizetype start,
457 const qsizetype len,
458 qsizetype& vertexCount,
459 qsizetype& indexCount) const
460{
461 Q_ASSERT(px != nullptr);
462 Q_ASSERT(len >= 2);
463
464 auto dirAt = [&](const qsizetype i, const QPointF& fallback) {
465 QPointF dir = fallback;
466 (void)unitDir(px[start + i], px[start + i + 1], dir);
467 return dir;
468 };
469
470 QPointF prevDir = dirAt(0, QPointF(1, 0));
471 for (qsizetype i = 0; i + 1 < len; ++i) {
472 const QPointF dir = dirAt(i, prevDir);
473 vertexCount += 8;
474 indexCount += 18;
475
476 if (i + 2 < len) {
477 const QPointF dOut = dirAt(i + 1, dir);
478 const int nFan = fanSegments(dir, dOut);
479 if (nFan >= 1) {
480 vertexCount += 2 * nFan + 3;
481 indexCount += 9 * nFan;
482 }
483 }
484
485 prevDir = dir;
486 }
487}
488
489/**
490 * @brief Counts ribbon vertices and indices over each visible run of two or more points, by

Callers

nothing calls this directly

Calls 2

unitDirFunction · 0.85
fanSegmentsFunction · 0.85

Tested by

no test coverage detected