From e0b35d8c142a4649692f879acb450b687b04dbd3 Mon Sep 17 00:00:00 2001 From: ponchio Date: Thu, 1 Jul 2004 21:40:25 +0000 Subject: [PATCH] First draft, created. --- apps/nexus/pintersect.h | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 apps/nexus/pintersect.h diff --git a/apps/nexus/pintersect.h b/apps/nexus/pintersect.h new file mode 100644 index 00000000..481dfed6 --- /dev/null +++ b/apps/nexus/pintersect.h @@ -0,0 +1,67 @@ +#ifndef PARTITION_INTERSECT_H +#define PARTITION_INTERSECT_H + +#include +#include + +namespace nxs { + +template class PIntersect { + public: + Partition &fine; + Partition &coarse; + + typedef typename Partition::Key Key; + + struct Pair { + Key fine; + Key coarse; + bool operator<(const Pair &p) const { + if(fine == p.fine) return coarse < p.coarse; + return fine < p.fine; + } + }; + struct Cell { + unsigned int index; + unsigned int count; + }; + + unsigned int last_cell; + std::map pairs; + std::set cells; + + PIntersect(Partition &f, Partition &c): + fine(f), coarse(c), last_cell(0) {} + + unsigned int Locate(const vcg::Point3f &p) { + Pair pp; + pp.fine = fine.Locate(p); + pp.coarse = coarse.Locate(p); + if(pairs.count(pp)) { //already there + Cell &cell = pairs[pp]; + cell.count++; + return cell.index; + } else { + Cell &cell = pairs[pp]; + cell.index = last_cell++; + cell.count = 1; + cells.insert(cell.index); + return cell.index; + } + + } + + unsigned int Relocate(const vcg::Point3f &p) { + //TODO!!!!!! + } + void Prune(unsigned int threshold) { + //TODO!!!!!! + } + unsigned int Count(unsigned int cell) { + return cells.count(cell); + } +}; + +} + +#endif