1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
for (it1 = layer_grids.begin(); it1 != layer_grids.end(); it1++) { int x = it1->first.first, y = it1->first.second; for (int k = 0; k < 9; k++) { int next_x = x + dir[k][0], next_y = y + dir[k][1]; if (vis.find(std::make_pair(std::make_pair(x, y), std::make_pair(next_x, next_y))) != vis.end())continue; vis.insert(std::make_pair(std::make_pair(next_x, next_y), std::make_pair(x, y))); vis.insert(std::make_pair(std::make_pair(next_x, next_y), std::make_pair(x, y))); it2 = layer_grids.find(std::make_pair(next_x, next_y)); if (it2 == layer_grids.end())continue; for (int j1 = 0; j1 < layers[i].size(); j1++) if (it1->second.grids[j1].size()) { for (int j2 = 0; j2 < layers[i].size(); j2++)if (it2->second.grids[j2].size()) { if (IsInner[j1] && IsInner[j2] && j1 != j2) { for (int k1 = 0; k1 < it1->second.grids[j1].size(); k1++) { for (int k2 = 0; k2 < it2->second.grids[j2].size(); k2++) { pa p[3][3], optimal_dir, offdir[3]; p[1][1] = it1->second.grids[j1][k1].first, p[1][2] = it1->second.grids[j1][k1].second; p[2][1] = it2->second.grids[j2][k2].first, p[2][2] = it2->second.grids[j2][k2].second; optimal_dir = furthestdir(p); double line_dis = sqrt(dot(optimal_dir, optimal_dir)); double move = (MIN_DIS - line_dis); if (move < 0)continue; std::vector<int> a; a.push_back(x); a.push_back(y); a.push_back(j1); a.push_back(k1); std::vector<int> b; b.push_back(next_x); b.push_back(next_y); b.push_back(j2); b.push_back(k2); layer_offdis.dis[j1][lineincontour[a]] = max(move*0.5, layer_offdis.dis[j1][lineincontour[a]]); layer_offdis.dis[j2][lineincontour[b]] = max(move*0.5, layer_offdis.dis[j2][lineincontour[b]]); } } } else if (IsInner[j1] && !IsInner[j2] && j1 != j2) { for (int k1 = 0; k1 < it1->second.grids[j1].size(); k1++) { for (int k2 = 0; k2 < it2->second.grids[j2].size(); k2++) { pa p[3][3], optimal_dir, offdir[3]; p[1][1] = it1->second.grids[j1][k1].first, p[1][2] = it1->second.grids[j1][k1].second; p[2][1] = it2->second.grids[j2][k2].first, p[2][2] = it2->second.grids[j2][k2].second; optimal_dir = furthestdir(p); double line_dis = sqrt(dot(optimal_dir, optimal_dir)); double move = (MIN_DIS - line_dis); if (move < 0)continue; std::vector<int> a; a.push_back(x); a.push_back(y); a.push_back(j1); a.push_back(k1); std::vector<int> b; b.push_back(next_x); b.push_back(next_y); b.push_back(j2); b.push_back(k2); layer_offdis.dis[j1][lineincontour[a]] = max(move, layer_offdis.dis[j1][lineincontour[a]]); } } } else if (!IsInner[j1] && IsInner[j2] && j1 != j2) { for (int k1 = 0; k1 < it1->second.grids[j1].size(); k1++) { for (int k2 = 0; k2 < it2->second.grids[j2].size(); k2++) { pa p[3][3], optimal_dir, offdir[3]; p[1][1] = it1->second.grids[j1][k1].first, p[1][2] = it1->second.grids[j1][k1].second; p[2][1] = it2->second.grids[j2][k2].first, p[2][2] = it2->second.grids[j2][k2].second; optimal_dir = furthestdir(p); double line_dis = sqrt(dot(optimal_dir, optimal_dir)); double move = (MIN_DIS - line_dis); if (move < 0)continue; std::vector<int> a; a.push_back(x); a.push_back(y); a.push_back(j1); a.push_back(k1); std::vector<int> b; b.push_back(next_x); b.push_back(next_y); b.push_back(j2); b.push_back(k2); layer_offdis.dis[j2][lineincontour[b]] = max(move, layer_offdis.dis[j2][lineincontour[b]]); } } } else if (!IsInner[j1] && !IsInner[j2] && j1 == j2) { for (int k1 = 0; k1 < it1->second.grids[j1].size(); k1++) { for (int k2 = 0; k2 < it2->second.grids[j2].size(); k2++) if (k1 != k2) { pa p[3][3], optimal_dir, offdir[3]; p[1][1] = it1->second.grids[j1][k1].first, p[1][2] = it1->second.grids[j1][k1].second; p[2][1] = it2->second.grids[j2][k2].first, p[2][2] = it2->second.grids[j2][k2].second; optimal_dir = furthestdir(p); double line_dis = sqrt(dot(optimal_dir, optimal_dir)); double move = (MIN_DIS - line_dis); if (move < 0)continue; pa p1, p2; p1.first = p[1][1].first - p[1][2].first; p1.second = p[1][1].second - p[1][2].second; p2.first = p[2][1].first - p[2][2].first; p2.second = p[2][1].second - p[2][2].second; if (dot(p1, p2) > 0)continue; std::vector<int> a; a.push_back(x); a.push_back(y); a.push_back(j1); a.push_back(k1); std::vector<int> b; b.push_back(next_x); b.push_back(next_y); b.push_back(j2); b.push_back(k2); layer_offdis.dis[j2][lineincontour[b]] = max(move, layer_offdis.dis[j2][lineincontour[b]]); } } } } } } } offdis.push_back(layer_offdis);
|
近期评论