#pragma once #include namespace algoim::organizer { // bitfield struct Blob { unsigned int isPrimitive : 1; // 1 for leaf unsigned int nodeOp : 5; // 0 for intersection, 1 for union, 2 for difference // unsigned int ignoreMod : 2; // 目前用不到 unsigned int inOut : 2; // 0 for unknown, 1 for in, 2 for out unsigned int isLeft : 1; unsigned int ancestor : 23; }; bool isPrimitive(Blob b) { return b.isPrimitive == 1; } unsigned int type(Blob b) { return 0; } bool isLeft(Blob b) { return b.isLeft == 1; } struct BlobTree { std::vector structure; }; void propagate(BlobTree &tree, unsigned int nodeIdx, bool in) { const std::size_t rootIdx = tree.structure.size() - 1; for (unsigned int nowIdx = nodeIdx; nowIdx != rootIdx; ++nodeIdx) { unsigned int nextIdx = isLeft(tree.structure[nowIdx]) ? tree.structure[nowIdx].ancestor : nodeIdx + 1; if (tree.structure[nowIdx].inOut == 2) { // out if (tree.structure[nextIdx].nodeOp == 0) { // intersection tree.structure[nextIdx].inOut = 2; nextIdx = nowIdx; continue; } else if (tree.structure[nextIdx].nodeOp == 2 && isLeft(tree.structure[nowIdx])) { // difference tree.structure[nextIdx].inOut = 2; nextIdx = nowIdx; // continue; } else { return; } } else if (tree.structure[nowIdx].inOut == 1) { // in // TODO: } } return; } }; // namespace algoim::organizer