diff --git a/gjj/primitiveDebug.hpp b/gjj/primitiveDebug.hpp index 6624ee9..7b76dda 100644 --- a/gjj/primitiveDebug.hpp +++ b/gjj/primitiveDebug.hpp @@ -308,6 +308,61 @@ void caseScene30Objs() quadratureScene(primitiveDescriptions, sceneCenter - 0.5 * sceneSize - 0.2, sceneCenter + 0.5 * sceneSize + 0.2, blobTree); } +void caseScene16Objs() +{ + const int PRIMITIVE_CNT = 16; + std::vector> primitiveDescriptions(PRIMITIVE_CNT); + uvector3 sceneSize = 1.6, sceneCenter = 0.; + for (MultiLoop<3> i(0, 2); ~i; ++i) { + uvector3 center = sceneSize * i() - 0.5 * sceneSize + sceneCenter; + int idx = organizer::detail::binary2Decimal(i()); + primitiveDescriptions[2 * idx] = std::make_shared(CuboidDesc(center, 0.16)); + primitiveDescriptions[2 * idx + 1] = std::make_shared(SphereDesc(0.075, center, 1.)); + } // 16 primitives + + organizer::BlobTree blobTree; + blobTree.structure.resize(PRIMITIVE_CNT * 2 - 1); + blobTree.primitiveNodeIdx.resize(PRIMITIVE_CNT); + blobTree.structure[0] = {1, 0, 0, 0, 1, 2}; // cube1 + blobTree.structure[1] = {1, 0, 0, 0, 0, 0}; // sphere1 + blobTree.structure[2] = {0, OP_DIFFERENCE, 0, 0, 1, 6 - 2}; // Dif of = opNode1 + blobTree.structure[3] = {1, 0, 0, 0, 1, 5 - 3}; // cube2 + blobTree.structure[4] = {1, 0, 0, 0, 0, 0}; // sphere2 + blobTree.structure[5] = {0, OP_DIFFERENCE, 0, 0, 0, 0}; // Dif of = opNode2 + blobTree.structure[6] = {0, OP_UNION, 0, 0, 1, 14 - 6}; // Union of = opNode3 + blobTree.structure[7] = {1, 0, 0, 0, 1, 9 - 7}; // cube3 + blobTree.structure[8] = {1, 0, 0, 0, 0, 0}; // sphere3 + blobTree.structure[9] = {0, OP_DIFFERENCE, 0, 0, 1, 13 - 9}; // Dif of = opNode4 + blobTree.structure[10] = {1, 0, 0, 0, 1, 12 - 10}; // cube4 + blobTree.structure[11] = {1, 0, 0, 0, 0, 0}; // sphere4 + blobTree.structure[12] = {0, OP_DIFFERENCE, 0, 0, 0, 0}; // Dif of = opNode5 + blobTree.structure[13] = {0, OP_UNION, 0, 0, 0, 0}; // Union of = opNode6 + blobTree.structure[14] = {0, OP_UNION, 0, 0, 1, 30 - 14}; // Union of = opNode7 + blobTree.structure[15] = {1, 0, 0, 0, 1, 17 - 15}; // cube5 + blobTree.structure[16] = {1, 0, 0, 0, 0, 0}; // sphere5 + blobTree.structure[17] = {0, OP_DIFFERENCE, 0, 0, 1, 21 - 17}; // Dif of = opNode8 + blobTree.structure[18] = {1, 0, 0, 0, 1, 20 - 18}; // cube6 + blobTree.structure[19] = {1, 0, 0, 0, 0, 0}; // sphere6 + blobTree.structure[20] = {0, OP_DIFFERENCE, 0, 0, 0, 0}; // Dif of = opNode9 + blobTree.structure[21] = {0, OP_UNION, 0, 0, 1, 29 - 21}; // Union of = opNode10 + blobTree.structure[22] = {1, 0, 0, 0, 1, 24 - 22}; // cube7 + blobTree.structure[23] = {1, 0, 0, 0, 0, 0}; // sphere7 + blobTree.structure[24] = {0, OP_DIFFERENCE, 0, 0, 1, 28 - 24}; // Dif of = opNode11 + blobTree.structure[25] = {1, 0, 0, 0, 1, 27 - 25}; // cube8 + blobTree.structure[26] = {1, 0, 0, 0, 0, 0}; // sphere8 + blobTree.structure[27] = {0, OP_DIFFERENCE, 0, 0, 0, 0}; // Dif of = opNode12 + blobTree.structure[28] = {0, OP_UNION, 0, 0, 0, 0}; // Union of = opNode13 + blobTree.structure[29] = {0, OP_UNION, 0, 0, 0, 0}; // Union of = opNode14 + blobTree.structure[30] = {0, OP_UNION, 0, 0, 1, 32 - 30}; // Dif of = opNode15 + + int leafCnt = 0; + for (int i = 0; i < blobTree.structure.size(); ++i) { + if (blobTree.structure[i].isPrimitive) { blobTree.primitiveNodeIdx[leafCnt++] = i; } + } + assert(leafCnt == PRIMITIVE_CNT); + quadratureScene(primitiveDescriptions, sceneCenter - 0.5 * sceneSize - 0.2, sceneCenter + 0.5 * sceneSize + 0.2, blobTree); +} + void caseScene1() { const int PRIMITIVE_CNT = 2; @@ -541,6 +596,11 @@ void testRotation() std::cout << "after reduction, evalX = " << evalX << std::endl; } +void testBoolVector(const std::vector &boolVec) +{ + for (auto b : boolVec) { std::cout << b << " "; } +} + void testPrimitive() { // casePolyhedron2(); @@ -551,7 +611,10 @@ void testPrimitive() // testRotation(); // caseScene(); - caseScene30Objs(); + + // caseScene30Objs(); + // caseScene16Objs(); + // caseScene1(); // caseScene2(); // caseCone(); @@ -560,4 +623,7 @@ void testPrimitive() // caseTwoCube(); // testTensorInverse(); // testPlaneUniformSign(); + + std::vector boolVec = {true, false, false, false, true, true, false}; + testBoolVector(boolVec); } \ No newline at end of file