more function migrations
This commit is contained in:
@@ -47,6 +47,10 @@ namespace Voxel {
|
||||
return (a | b) != (a ^ b);
|
||||
}
|
||||
|
||||
inline auto collides(Space *a, Space *b) -> bool {
|
||||
return (a->space | b->space) != (a->space ^ b->space);
|
||||
}
|
||||
|
||||
inline auto filledAt(uint64_t space, int dims[3], int x, int y, int z) -> bool {
|
||||
auto mask = 1ull << (dims[1] * dims[2] * x + dims[2] * y + z);
|
||||
return (space & mask) != 0ull;
|
||||
@@ -173,6 +177,14 @@ namespace Voxel {
|
||||
}
|
||||
}
|
||||
|
||||
auto pushXAxisSpins(std::vector<Space> *existingSpaces, Space* spaceToSpin) -> void {
|
||||
auto refSpace = *spaceToSpin;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
rotate90X(&refSpace);
|
||||
existingSpaces->push_back(refSpace);
|
||||
}
|
||||
}
|
||||
|
||||
auto getUniqueRotations(Space *space) -> std::vector<Space> {
|
||||
auto rotations = std::vector<Space>();
|
||||
rotations.reserve(6*24);
|
||||
@@ -191,25 +203,23 @@ namespace Voxel {
|
||||
return rotations;
|
||||
}
|
||||
|
||||
/*
|
||||
getAllRotations(): Space[] {
|
||||
let rotations: Space[] = new Array<Space>();
|
||||
const refSpace = this.clone();
|
||||
rotations = rotations.concat(refSpace.getXAxisSpins());
|
||||
refSpace.rot90Y();
|
||||
rotations = rotations.concat(refSpace.getXAxisSpins());
|
||||
refSpace.rot90Y();
|
||||
rotations = rotations.concat(refSpace.getXAxisSpins());
|
||||
refSpace.rot90Y();
|
||||
rotations = rotations.concat(refSpace.getXAxisSpins());
|
||||
refSpace.rot90Z();
|
||||
rotations = rotations.concat(refSpace.getXAxisSpins());
|
||||
refSpace.rot90Z();
|
||||
refSpace.rot90Z();
|
||||
rotations = rotations.concat(refSpace.getXAxisSpins());
|
||||
auto getAllRotations(Space *space) -> std::vector<Space> {
|
||||
auto rotations = std::vector<Space>();
|
||||
rotations.reserve(6*24);
|
||||
auto dims = space->dims;
|
||||
auto refSpace = *space;
|
||||
pushXAxisSpins(&rotations, &refSpace);
|
||||
rotate90Y(&refSpace);
|
||||
pushXAxisSpins(&rotations, &refSpace);
|
||||
rotate90Y(&refSpace);
|
||||
pushXAxisSpins(&rotations, &refSpace);
|
||||
rotate90Z(&refSpace);
|
||||
pushXAxisSpins(&rotations, &refSpace);
|
||||
rotate90Z(&refSpace);
|
||||
rotate90Z(&refSpace);
|
||||
pushXAxisSpins(&rotations, &refSpace);
|
||||
return rotations;
|
||||
}
|
||||
*/
|
||||
|
||||
auto getAllPositionsInPrism(uint64_t space, int space_dims[3], int prism_dims[3]) -> std::vector<uint64_t> {
|
||||
auto cubePositions = std::vector<uint64_t>();
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Voxel {
|
||||
inline auto set(uint64_t space, int index, bool val) -> uint64_t;
|
||||
|
||||
inline auto collides(Space *a, Space *b) -> bool;
|
||||
inline auto collides(uint64_t a, uint64_t b) -> bool;
|
||||
|
||||
inline auto add(Space *a, Space *b) -> Space;
|
||||
|
||||
|
||||
2
main.cpp
2
main.cpp
@@ -59,7 +59,7 @@ auto backtrack_solve(std::vector<uint64_t> *polycube_input, std::vector<int> *of
|
||||
auto end = offsets->at(set + 1);
|
||||
std::cout << start << " " << end << "\n";
|
||||
for (int i = start; i < end; i++) {
|
||||
auto successful_fuse = (working_solution | polycube_input->at(i)) == (working_solution ^ polycube_input->at(i));
|
||||
auto successful_fuse = !Voxel::collides(working_solution, polycube_input->at(i));
|
||||
if (successful_fuse) {
|
||||
working_solution = working_solution | polycube_input->at(i);
|
||||
if (set == offsets->size() - 2) {
|
||||
|
||||
Reference in New Issue
Block a user