about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ext/wittle_generator/Panel.h101
1 files changed, 0 insertions, 101 deletions
diff --git a/ext/wittle_generator/Panel.h b/ext/wittle_generator/Panel.h index 95832b5..d152370 100644 --- a/ext/wittle_generator/Panel.h +++ b/ext/wittle_generator/Panel.h
@@ -340,107 +340,6 @@ class Panel {
340 int get_parity() { return (get_num_grid_points() + 1) % 2; } 340 int get_parity() { return (get_num_grid_points() + 1) % 2; }
341 341
342 private: 342 private:
343 std::pair<int, int> loc_to_xy(int location) {
344 int height2 = (_height - 1) / 2;
345 int width2 = (_width + 1) / 2;
346
347 int x = 2 * (location % width2);
348 int y = 2 * (height2 - location / width2);
349 return {x, y};
350 }
351
352 int xy_to_loc(int x, int y) {
353 int height2 = (_height - 1) / 2;
354 int width2 = (_width + 1) / 2;
355
356 int rowsFromBottom = height2 - y / 2;
357 return rowsFromBottom * width2 + x / 2;
358 }
359
360 std::pair<int, int> dloc_to_xy(int location) {
361 int height2 = (_height - 3) / 2;
362 int width2 = _width / 2;
363
364 int x = 2 * (location % width2) + 1;
365 int y = 2 * (height2 - location / width2) + 1;
366 return {x, y};
367 }
368
369 int xy_to_dloc(int x, int y) {
370 int height2 = (_height - 3) / 2;
371 int width2 = _width / 2;
372
373 int rowsFromBottom = height2 - (y - 1) / 2;
374 return rowsFromBottom * width2 + (x - 1) / 2;
375 }
376
377 int locate_segment(int x, int y, std::vector<int>& connections_a,
378 std::vector<int>& connections_b) {
379 for (int i = 0; i < connections_a.size(); i++) {
380 std::pair<int, int> coord1 = loc_to_xy(connections_a[i]);
381 std::pair<int, int> coord2 = loc_to_xy(connections_b[i]);
382 int x1 = coord1.first, y1 = coord1.second, x2 = coord2.first,
383 y2 = coord2.second;
384 if ((x1 == x - 1 && x2 == x + 1 && y1 == y && y2 == y) ||
385 (y1 == y - 1 && y2 == y + 1 && x1 == x && x2 == x)) {
386 return i;
387 }
388 }
389 return -1;
390 }
391
392 bool break_segment(int x, int y, std::vector<int>& connections_a,
393 std::vector<int>& connections_b,
394 std::vector<float>& intersections,
395 std::vector<int>& intersectionFlags) {
396 int i = locate_segment(x, y, connections_a, connections_b);
397 if (i == -1) {
398 return false;
399 }
400 int other_connection = connections_b[i];
401 connections_b[i] = static_cast<int>(intersectionFlags.size());
402 connections_a.push_back(static_cast<int>(intersectionFlags.size()));
403 connections_b.push_back(other_connection);
404 intersections.push_back(static_cast<float>(minx + x * unitWidth));
405 intersections.push_back(
406 static_cast<float>(miny + (_height - 1 - y) * unitHeight));
407 intersectionFlags.push_back(_grid[x][y]);
408 return true;
409 }
410
411 bool break_segment_gap(int x, int y, std::vector<int>& connections_a,
412 std::vector<int>& connections_b,
413 std::vector<float>& intersections,
414 std::vector<int>& intersectionFlags) {
415 int i = locate_segment(x, y, connections_a, connections_b);
416 if (i == -1) {
417 return false;
418 }
419 int other_connection = connections_b[i];
420 connections_b[i] = static_cast<int>(intersectionFlags.size() + 1);
421 connections_a.push_back(other_connection);
422 connections_b.push_back(static_cast<int>(intersectionFlags.size()));
423 if (!(_grid[x][y] & IntersectionFlags::GAP)) {
424 _grid[x][y] |=
425 (x % 2 == 0 ? IntersectionFlags::COLUMN : IntersectionFlags::ROW);
426 connections_a.push_back(static_cast<int>(intersectionFlags.size()));
427 connections_b.push_back(static_cast<int>(intersectionFlags.size() + 1));
428 }
429 double xOffset = _grid[x][y] & IntersectionFlags::ROW ? 0.5 : 0;
430 double yOffset = _grid[x][y] & IntersectionFlags::COLUMN ? 0.5 : 0;
431 intersections.push_back(
432 static_cast<float>(minx + (x + xOffset) * unitWidth));
433 intersections.push_back(
434 static_cast<float>(miny + (_height - 1 - y - yOffset) * unitHeight));
435 intersections.push_back(
436 static_cast<float>(minx + (x - xOffset) * unitWidth));
437 intersections.push_back(
438 static_cast<float>(miny + (_height - 1 - y + yOffset) * unitHeight));
439 intersectionFlags.push_back(_grid[x][y]);
440 intersectionFlags.push_back(_grid[x][y]);
441 return true;
442 }
443
444 int _width, _height; 343 int _width, _height;
445 344
446 std::vector<std::vector<int>> _grid; 345 std::vector<std::vector<int>> _grid;