* Copyright (c) , Huawei Technologies Co., Ltd. 2025-2025 .All rights reserved.
*/
#include "GraphLine.h"
#include <algorithm>
using namespace Insight::Scalar::Protocol;
using namespace Insight::Scalar;
std::vector<ScalarPoint> GraphLine::GetLinePoints()
{
std::for_each(lineOps_.begin(), lineOps_.end(), [&](auto& op) {
op->Process(this->subLineData_);
});
std::for_each(subLineData_.begin(), subLineData_.end(), [this](LineData& lineData) {
AddLineData(std::move(lineData.GetElements()));
});
return std::move(linePoints_);
}
std::vector<LineData>& GraphLine::GetLineData()
{
return subLineData_;
}
void GraphLine::AddLineData(std::vector<ScalarPoint>&& points)
{
if (points.empty()) {
return;
}
const uint64_t left = points[0].step_;
const auto it = std::lower_bound(linePoints_.begin(), linePoints_.end(), left,
[](const ScalarPoint& point, uint64_t left) {
return point.step_ < left;
});
linePoints_.erase(it, linePoints_.end());
std::move(points.begin(), points.end(), std::back_inserter(linePoints_));
}