Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions src/ScatterplotPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,15 +605,33 @@ void ScatterplotPlugin::loadColors(const Dataset<Clusters>& clusters)
std::vector<Vector3f> globalColors(totalNumPoints);
std::vector<Vector3f> localColors(_positions.size());

// Loop over all clusters and populate global colors
for (const auto& cluster : clusters->getClusters())
for (const auto& index : cluster.getIndices())
globalColors[index] = Vector3f(cluster.getColor().redF(), cluster.getColor().greenF(), cluster.getColor().blueF());
std::int32_t localColorIndex = 0;

// Loop over all global indices and find the corresponding local color
for (const auto& globalIndex : globalIndices)
localColors[localColorIndex++] = globalColors[globalIndex];
const auto& clusterVec = clusters->getClusters();

if (totalNumPoints == _positions.size() && clusterVec.size() == totalNumPoints)
{
for (size_t i = 0; i < static_cast<size_t>(clusterVec.size()); i++)
{
const auto color = clusterVec[i].getColor();
localColors[i] = Vector3f(color.redF(), color.greenF(), color.blueF());
}

}
else
{
// Loop over all clusters and populate global colors
for (const auto& cluster : clusterVec)
{
const auto color = cluster.getColor();
for (const auto& index : cluster.getIndices())
globalColors[index] = Vector3f(color.redF(), color.greenF(), color.blueF());

}

// Loop over all global indices and find the corresponding local color
std::int32_t localColorIndex = 0;
for (const auto& globalIndex : globalIndices)
localColors[localColorIndex++] = globalColors[globalIndex];
}

// Apply colors to scatter plot widget without modification
_scatterPlotWidget->setColors(localColors);
Expand Down
Loading