Browse Source

blobtree

master
gjj 6 months ago
parent
commit
46af775a55
  1. 54
      algoim/organizer/blobtree.hpp
  2. 18
      gjj/primitiveDebug.hpp

54
algoim/organizer/blobtree.hpp

@ -0,0 +1,54 @@
#pragma once
#include <vector>
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<Blob> 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

18
gjj/primitiveDebug.hpp

@ -24,6 +24,8 @@
#include "organizer/primitive.hpp"
#include "organizer/organizer.hpp"
#include "organizer/blobtree.hpp"
using namespace algoim::Organizer;
using namespace algoim;
@ -187,9 +189,23 @@ void testDeCasteljau()
std::cout << "sign = " << sign << std::endl;
}
void testBlob()
{
orgzer::Blob blob = {5, 3, 4, 5, 6};
// std::cout << blob.isPrimitive << std::endl;
// std::cout << blob.nodeOp << std::endl;
// std::cout << blob.ignoreMod << std::endl;
// std::cout << blob.isLeft << std::endl;
// std::cout << blob.ancestor << std::endl;
std::cout << sizeof(blob) << std::endl;
std::cout << sizeof(int) << std::endl;
}
void testPrimitive()
{
// casePolyhedron1();
// casePolyhedronSphere();
testDeCasteljau();
// testDeCasteljau();
testBlob();
}
Loading…
Cancel
Save