Skip to content

Commit 3b797a3

Browse files
committed
multi connect arch
1 parent 7d3767c commit 3b797a3

File tree

3 files changed

+338
-192
lines changed

3 files changed

+338
-192
lines changed

grid.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "grid.hpp"
2+
#include <algorithm>
3+
#include <cstddef>
4+
#include <iterator>
25
#include <stdio.h>
36
#include <stdlib.h>
47
#include <stdbool.h>
@@ -10,6 +13,21 @@ void delete_zgrid(struct zgrid *grid) {
1013
delete[] grid->blocks;
1114
}
1215

16+
int grid_copy(struct zgrid *grid, struct zgrid *new_grid) {
17+
*new_grid = *grid;
18+
new_grid->blocks = new zblock[new_grid->nzblocks];
19+
20+
if (!new_grid->blocks) {
21+
return 1;
22+
}
23+
24+
for (size_t i = 0; i < grid->nzblocks; i++) {
25+
std::copy(std::begin(grid->blocks[i].nodes), std::end(grid->blocks[i].nodes), std::begin(new_grid->blocks[i].nodes));
26+
}
27+
28+
return 0;
29+
}
30+
1331
void create_zgrid(struct zgrid *grid) {
1432
size_t nzblocks = align_div(grid->width, ZWIDTH) * align_div(grid->height, ZHEIGHT);
1533

grid.hpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ struct vec2 {
3939
};
4040
}
4141
};
42-
struct lead {
43-
struct vec2 orig;
44-
int width;
45-
int height;
46-
};
47-
48-
struct component {
49-
struct lead leads[2];
50-
};
5142

5243
struct node {
5344
struct point p;
@@ -87,4 +78,6 @@ struct point vector_to_point(Vector2 vec);
8778

8879
vec2 scale_vec(vec2 vec);
8980

81+
int grid_copy(struct zgrid *grid, struct zgrid *new_grid);
82+
9083
#endif

0 commit comments

Comments
 (0)