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