Browse Source

filter with blobTre

master
gjj 6 months ago
parent
commit
4e423e630e
  1. 4
      algoim/organizer/blobtree.hpp
  2. 38
      algoim/organizer/organizer.hpp

4
algoim/organizer/blobtree.hpp

@ -97,9 +97,9 @@ int traverse(BlobTree& tree, const std::vector<int>& relatedPrimitives, const st
assert(relatedPrimitives.size() == primitiveInout.size()); assert(relatedPrimitives.size() == primitiveInout.size());
for (int primitiveIdx : relatedPrimitives) { for (int primitiveIdx : relatedPrimitives) {
propagate(tree, tree.primitiveNodeIdx[primitiveIdx], primitiveInout[primitiveIdx]); propagate(tree, tree.primitiveNodeIdx[primitiveIdx], primitiveInout[primitiveIdx]);
if (tree.structure.back().inOut != 0) { return tree.structure.back().inOut; } if (tree.structure.back().inOut != NODE_IN_OUT_UNKNOWN) { return tree.structure.back().inOut; }
} }
return 0; return NODE_IN_OUT_UNKNOWN;
} }
int traverse(BlobTree& tree, const int relatedPrimitive, const bool primitiveInout) int traverse(BlobTree& tree, const int relatedPrimitive, const bool primitiveInout)

38
algoim/organizer/organizer.hpp

@ -112,7 +112,7 @@ std::pair<uvector<int, 3>, uvector<int, 3>> getOneEightCellAABB(const uvector3&
} // namespace detail } // namespace detail
// TODO: delete it // TODO: delete it
bool keepQuadraturePoint(std::vector<tensor3>& originTensors, const uvector3& originPt) bool isPointInside(const std::vector<tensor3>& originTensors, const uvector3& originPt)
{ {
for (auto& t : originTensors) { for (auto& t : originTensors) {
if (evalPower(t, originPt) >= 0) { return false; } if (evalPower(t, originPt) >= 0) { return false; }
@ -120,14 +120,34 @@ bool keepQuadraturePoint(std::vector<tensor3>& originTensors, const uvector3& or
return true; return true;
} }
bool keepQuadraturePoint(const Scene& scene, const OcTreeNode& ocTreeNode, const uvector3& originPt) // bool isPointInside(const std::vector<CompleteTensorRep>& completeTensorReps, const uvector3& originPt)
// {
// for (auto& completeTensorRep : completeTensorReps) {
// if (isPointInside(completeTensorRep.originalPower, originPt)) { return false; }
// }
// return true;
// }
// 这里blobTree是拷贝传参
bool keepQuadraturePoint(const Scene& scene,
organizer::BlobTree blobTree,
const OcTreeNode& ocTreeNode,
const uvector3& originPt)
{ {
// 只需要考虑intersect polys,不用考虑fully contained polys // 只需要考虑intersect polys,不用考虑fully contained polys
for (auto& polyIntersectIdx : ocTreeNode.polyIntersectIndices) { const auto& polyIntersectIndices = ocTreeNode.polyIntersectIndices;
// TODO: std::vector<bool> primitiveInOuts(polyIntersectIndices.size());
} for (int i = 0; i < ocTreeNode.polyIntersectIndices.size(); ++i) {
primitiveInOuts[i] = isPointInside(scene.polys[polyIntersectIndices[i]].originalPower, originPt);
}
int res = organizer::traverse(blobTree, ocTreeNode.polyIntersectIndices, primitiveInOuts);
assert(res == organizer::NODE_IN || res == organizer::NODE_OUT);
if (res == organizer::NODE_OUT) {
return false;
} else {
return true; return true;
} }
}
// std::vector<std::shared_ptr<PrimitiveDesc>> primitives; // std::vector<std::shared_ptr<PrimitiveDesc>> primitives;
@ -415,7 +435,7 @@ void basicTask(const std::vector<std::shared_ptr<PrimitiveDesc>>& primitives, in
ipquad.integrate(AutoMixed, q, [&](const uvector<real, 3>& x, real w) { ipquad.integrate(AutoMixed, q, [&](const uvector<real, 3>& x, real w) {
auto realX = x * range + xmin; auto realX = x * range + xmin;
if (keepQuadraturePoint(originTensors, realX)) volume += w * integrand(realX); if (isPointInside(originTensors, realX)) volume += w * integrand(realX);
}); });
volume *= pow(xmax - xmin, 3); volume *= pow(xmax - xmin, 3);
std::cout << "Volume xxx: " << volume << std::endl; std::cout << "Volume xxx: " << volume << std::endl;
@ -425,7 +445,7 @@ void basicTask(const std::vector<std::shared_ptr<PrimitiveDesc>>& primitives, in
for (auto& p : originTensorStacks) delete p; for (auto& p : originTensorStacks) delete p;
}; };
BasicTaskRes basicTask(const Scene& scene, const OcTreeNode& node, int q = 20) BasicTaskRes basicTask(const Scene& scene, const organizer::BlobTree& blobTree, const OcTreeNode& node, int q = 20)
{ {
auto integrand = [](const uvector<real, 3>& x) { return 1.0; }; auto integrand = [](const uvector<real, 3>& x) { return 1.0; };
real volume = 0., surf = 0.; real volume = 0., surf = 0.;
@ -433,7 +453,7 @@ BasicTaskRes basicTask(const Scene& scene, const OcTreeNode& node, int q = 20)
ImplicitPolyQuadrature<3> ipquad(scene.polys); ImplicitPolyQuadrature<3> ipquad(scene.polys);
ipquad.integrate(AutoMixed, q, [&](const uvector<real, 3>& x, real w) { ipquad.integrate(AutoMixed, q, [&](const uvector<real, 3>& x, real w) {
auto realX = x * range + node.min; auto realX = x * range + node.min;
if (keepQuadraturePoint(scene, node, realX)) volume += w * integrand(realX); if (keepQuadraturePoint(scene, blobTree, node, realX)) volume += w * integrand(realX);
}); });
} }
@ -498,7 +518,7 @@ void quadratureScene(const std::vector<std::shared_ptr<PrimitiveDesc>>& primitiv
buildOcTree(scene, rootNode, leaves); buildOcTree(scene, rootNode, leaves);
for (const auto& leaf : leaves) { for (const auto& leaf : leaves) {
auto basicRes = basicTask(scene, leaf, xmin, xmax, 10); auto basicRes = basicTask(blobTree, scene, leaf, xmin, xmax, 10);
volume += basicRes.volume; volume += basicRes.volume;
} }

Loading…
Cancel
Save