update
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include "VoxelSpace.h"
|
#include "VoxelSpace.h"
|
||||||
#include "SomaSolve.h"
|
#include "SomaSolve.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void get_dims_input(int dims[3]) {
|
void get_dims_input(int dims[3]) {
|
||||||
@@ -130,7 +131,7 @@ void backtrackSolve(Arena *arena, Solver *solver, uint64 working_solution, size_
|
|||||||
SomaSolutionList *solutions = solver->solutions;
|
SomaSolutionList *solutions = solver->solutions;
|
||||||
size_t start = offsets->data[curr_piece];
|
size_t start = offsets->data[curr_piece];
|
||||||
size_t end = offsets->data[curr_piece + 1];
|
size_t end = offsets->data[curr_piece + 1];
|
||||||
size_t num_pieces = offsets->length - 1;
|
size_t num_pieces = offsets->length;
|
||||||
for (size_t i = start; i < end; i++) {
|
for (size_t i = start; i < end; i++) {
|
||||||
bool successful_fuse = !collides(working_solution, input->data[i]);
|
bool successful_fuse = !collides(working_solution, input->data[i]);
|
||||||
if (successful_fuse) {
|
if (successful_fuse) {
|
||||||
@@ -139,9 +140,8 @@ void backtrackSolve(Arena *arena, Solver *solver, uint64 working_solution, size_
|
|||||||
if (curr_piece == num_pieces - 1) {
|
if (curr_piece == num_pieces - 1) {
|
||||||
VoxelSpaceReprList last_soln = solutions->data[solutions->length - 1];
|
VoxelSpaceReprList last_soln = solutions->data[solutions->length - 1];
|
||||||
VoxelSpaceReprList last_soln_copy = PushList(arena, VoxelSpaceReprList, last_soln.length);
|
VoxelSpaceReprList last_soln_copy = PushList(arena, VoxelSpaceReprList, last_soln.length);
|
||||||
last_soln_copy.capacity = last_soln.length;
|
|
||||||
last_soln_copy.length = last_soln.length;
|
last_soln_copy.length = last_soln.length;
|
||||||
memcpy(last_soln_copy.data, last_soln.data, last_soln.length * sizeof(uint64));
|
memcpy(last_soln_copy.data, last_soln.data, last_soln.length * ListElementSize(VoxelSpaceReprList));
|
||||||
AppendList(solutions, last_soln_copy);
|
AppendList(solutions, last_soln_copy);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -209,7 +209,7 @@ SomaSolutionList filterUnique(Arena *arena, SomaSolutionList *solutions, int dim
|
|||||||
SomaSolution solutionCopy = PushList(arena, SomaSolution, solution.length);
|
SomaSolution solutionCopy = PushList(arena, SomaSolution, solution.length);
|
||||||
solutionCopy.capacity = solution.length;
|
solutionCopy.capacity = solution.length;
|
||||||
solutionCopy.length = solution.length;
|
solutionCopy.length = solution.length;
|
||||||
memcpy(solutionCopy.data, solution.data, solution.length * sizeof(SomaSolutionList_underlying));
|
memcpy(solutionCopy.data, solution.data, ListElementSize(SomaSolutionList) * solution.length);
|
||||||
AppendList(&uniqueSolns, solutionCopy);
|
AppendList(&uniqueSolns, solutionCopy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
|||||||
|
|
||||||
OffsetList offsets = PushList(arena, OffsetList, reprs_in_count + 1);
|
OffsetList offsets = PushList(arena, OffsetList, reprs_in_count + 1);
|
||||||
|
|
||||||
VoxelSpaceReprList polycubes = PushList(arena, VoxelSpaceReprList, 0);
|
VoxelSpaceReprList polycubes = EmptyList();
|
||||||
|
|
||||||
Space empty_voxel_space = {
|
Space empty_voxel_space = {
|
||||||
0,
|
0,
|
||||||
@@ -244,16 +244,16 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
|||||||
uint64 possibleCombos = 0;
|
uint64 possibleCombos = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
VoxelSpaceReprList positions = {};
|
|
||||||
Space space = empty_voxel_space;
|
Space space = empty_voxel_space;
|
||||||
space.space = reprs_in[0];
|
space.space = reprs_in[0];
|
||||||
cullEmptySpace(&space);
|
cullEmptySpace(&space);
|
||||||
positions = getAllPositionsInPrism(permsArena, &space, dims);
|
VoxelSpaceReprList positions = getAllPositionsInPrism(permsArena, &space, dims);
|
||||||
possibleCombos += positions.length;
|
possibleCombos += positions.length;
|
||||||
VoxelSpaceReprList_underlying *insertion = PushArray(arena, uint64, positions.capacity);
|
VoxelSpaceReprList_underlying *insertion = PushArray(arena, uint64, positions.capacity);
|
||||||
|
polycubes.data = insertion;
|
||||||
polycubes.capacity += positions.capacity;
|
polycubes.capacity += positions.capacity;
|
||||||
polycubes.length += positions.length;
|
polycubes.length += positions.length;
|
||||||
memcpy(insertion, positions.data, positions.capacity * sizeof(VoxelSpaceReprList_underlying));
|
memcpy(insertion, positions.data, positions.capacity * ListElementSize(VoxelSpaceReprList));
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 1; i < reprs_in_count; i++) {
|
for (size_t i = 1; i < reprs_in_count; i++) {
|
||||||
@@ -263,10 +263,10 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
|||||||
cullEmptySpace(&space);
|
cullEmptySpace(&space);
|
||||||
VoxelSpaceReprList perms = getAllPermutationsInPrism(permsArena, &space, dims);
|
VoxelSpaceReprList perms = getAllPermutationsInPrism(permsArena, &space, dims);
|
||||||
possibleCombos *= perms.length;
|
possibleCombos *= perms.length;
|
||||||
VoxelSpaceReprList_underlying *insertion = PushArray(arena, uint64, perms.capacity);
|
VoxelSpaceReprList_underlying *insertion = PushArray(arena, VoxelSpaceReprList_underlying, perms.capacity);
|
||||||
polycubes.capacity += perms.capacity;
|
polycubes.capacity += perms.capacity;
|
||||||
polycubes.length += perms.length;
|
polycubes.length += perms.length;
|
||||||
memcpy(insertion, perms.data, perms.capacity * sizeof(VoxelSpaceReprList_underlying));
|
memcpy(insertion, perms.data, perms.capacity * ListElementSize(VoxelSpaceReprList));
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendList(&offsets, polycubes.length);
|
AppendList(&offsets, polycubes.length);
|
||||||
|
|||||||
Reference in New Issue
Block a user