| 388 | } |
| 389 | |
| 390 | void DescriptionEditService::correctConnections(ClusteredDataDescription& data, IntVector2D const& worldSize) |
| 391 | { |
| 392 | auto threshold = std::min(worldSize.x, worldSize.y) /3; |
| 393 | std::unordered_map<uint64_t, CellDescription&> cellById; |
| 394 | for (auto& cluster : data.clusters) { |
| 395 | for (auto& cell : cluster.cells) { |
| 396 | cellById.emplace(cell.id, cell); |
| 397 | } |
| 398 | } |
| 399 | for (auto& cluster : data.clusters) { |
| 400 | for (auto& cell: cluster.cells) { |
| 401 | std::vector<ConnectionDescription> newConnections; |
| 402 | float angleToAdd = 0; |
| 403 | for (auto connection : cell.connections) { |
| 404 | auto& connectingCell = cellById.at(connection.cellId); |
| 405 | if (/*spaceCalculator.distance*/Math::length(cell.pos - connectingCell.pos) > threshold) { |
| 406 | angleToAdd += connection.angleFromPrevious; |
| 407 | } else { |
| 408 | connection.angleFromPrevious += angleToAdd; |
| 409 | angleToAdd = 0; |
| 410 | newConnections.emplace_back(connection); |
| 411 | } |
| 412 | } |
| 413 | if (angleToAdd > NEAR_ZERO && !newConnections.empty()) { |
| 414 | newConnections.front().angleFromPrevious += angleToAdd; |
| 415 | } |
| 416 | cell.connections = newConnections; |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | void DescriptionEditService::randomizeCellColors(ClusteredDataDescription& data, std::vector<int> const& colorCodes) |
| 422 | { |
no outgoing calls