From daa191584bbc1464156f9c1c4c44a236f6304ece Mon Sep 17 00:00:00 2001 From: untereiner Date: Thu, 30 Jan 2014 10:36:03 +0100 Subject: [PATCH] some changes MRDAT working again --- include/Algo/Import/importMRDAT.h | 30 +++++--- .../Multiresolution/IHM2/ihm2_PrimalRegular.h | 12 +++- .../IHM2/ihm2_PrimalRegular.hpp | 71 ++++++++++++------- .../Map2MR/map2MR_PrimalRegular.hpp | 1 - include/Topology/ihmap/ihm2.hpp | 8 +-- 5 files changed, 80 insertions(+), 42 deletions(-) diff --git a/include/Algo/Import/importMRDAT.h b/include/Algo/Import/importMRDAT.h index ba660d6d..7b64a0d3 100644 --- a/include/Algo/Import/importMRDAT.h +++ b/include/Algo/Import/importMRDAT.h @@ -25,6 +25,8 @@ #ifndef __IMPORT_MR_DAT__ #define __IMPORT_MR_DAT__ +#include "Topology/generic/autoAttributeHandler.h" + namespace CGoGN { @@ -97,25 +99,31 @@ public: unsigned int idx = emb == v0 ? 0 : emb == v1 ? 1 : 2 ; map.incCurrentLevel() ; Dart dd = map.phi1(next) ; - unsigned int oldEmb = map.template getEmbedding(dd) ; +// unsigned int oldEmb = map.template getEmbedding(dd) ; unsigned int newEmb = vID[children[0]->indices[idx]] ; - if(oldEmb == EMBNULL) - { +// if(oldEmb == EMBNULL) +// { //std::cout << "oldEmb == NULL"<< std::endl; map.template setOrbitEmbedding(dd, newEmb) ; - map.pushLevel() ; + + //needed because the darts are duplicated at each level + //and the vertex orbits are initialized at the creation of each level with wrong embedding indices + + //map.pushLevel() ; + unsigned int cur = map.getCurrentLevel(); //necessary because IHM2 does not allow a Stack for(unsigned int i = map.getCurrentLevel() + 1; i <= map.getMaxLevel(); ++i) { map.setCurrentLevel(i) ; map.template setOrbitEmbedding(dd, newEmb) ; } - map.popLevel() ; - } - else - { - //std::cout << "oldEmb != NULL"<< std::endl; - assert(oldEmb == newEmb) ; - } + //map.popLevel() ; + map.setCurrentLevel(cur); +// } +// else +// { +// //std::cout << "oldEmb != NULL"<< std::endl; +// assert(oldEmb == newEmb) ; +// } map.decCurrentLevel() ; it = next ; diff --git a/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.h b/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.h index 78f44e26..7eb0afef 100644 --- a/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.h +++ b/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.h @@ -30,6 +30,8 @@ #include "Topology/generic/traversor2.h" #include "Algo/Multiresolution/filter.h" +#include "Algo/Import/importMRDAT.h" + #include @@ -39,6 +41,9 @@ namespace CGoGN namespace Algo { +namespace Surface +{ + namespace MR { @@ -77,14 +82,19 @@ public: void synthesis() ; void addLevelFront(); + + void import(Algo::Surface::Import::QuadTree& qt); + } ; -} // namespace Adaptive +} // namespace Regular } // namespace Primal } // namespace MR +} // namespace Surface + } // namespace Algo } // namespace CGoGN diff --git a/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp b/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp index a7fc8f7e..e7830d9b 100644 --- a/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp +++ b/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp @@ -22,12 +22,16 @@ * * *******************************************************************************/ + namespace CGoGN { namespace Algo { +namespace Surface +{ + namespace MR { @@ -154,10 +158,8 @@ void IHM2::addNewLevel(bool triQuad) template void IHM2::addLevelFront() { - std::vector irregVertices; - irregVertices.reserve(1024); - - //look for an irregular vertex + //1. look for an irregular vertex + Dart irregVertex = NIL; TraversorV tv(m_map); bool found = false; @@ -166,13 +168,13 @@ void IHM2::addLevelFront() if(m_map.vertexDegree(d) != 6) { found = true; - irregVertices.push_back(d); + irregVertex = d; } } - //found the number of levels + //2. found the number of levels bool finished = false; - Dart dit = irregVertices[0]; + Dart dit = irregVertex; unsigned int nbSteps = 0; do { @@ -191,10 +193,11 @@ void IHM2::addLevelFront() nbSteps /= 2 ; ++nbLevel ; } - m_map.setMaxLevel(nbLevel); + m_map.setMaxLevel(nbLevel); std::cout << "nb levels = " << nbLevel+1 << std::endl; + //3. construct the topology of the differents levels unsigned int curLevel = nbLevel; do @@ -202,7 +205,9 @@ void IHM2::addLevelFront() m_map.setCurrentLevel(curLevel); DartMarker md(m_map); - std::vector visitedVertices(irregVertices); + std::vector visitedVertices; + visitedVertices.reserve(1024); + visitedVertices.push_back(irregVertex); std::cout << "getCurrentLevel = " << m_map.getCurrentLevel() << std::endl; @@ -240,7 +245,7 @@ void IHM2::addLevelFront() m_map.setDartLevel(m_map.phi2(fit3), curLevel); m_map.setDartLevel(m_map.phi1(m_map.phi2(fit3)), curLevel); - if(curLevel == maxLevel) + if(curLevel == m_map.getMaxLevel()) { unsigned int id = m_map.getTriRefinementEdgeId(m_map.phi2(fit1)); m_map.setEdgeId(m_map.phi2(fit1), id); @@ -256,31 +261,28 @@ void IHM2::addLevelFront() } else { - - } -// if(curLevel == 2) -// { // unsigned int id = m_map.getTriRefinementEdgeId(m_map.phi2(fit1)); // m_map.setEdgeId(m_map.phi2(fit1), id); // m_map.setEdgeId(fit1, id); - //m_map.setEdgeId(fit1, id); -// /std::cout << "fit1 = " << fit1 << std::endl; - //std::cout << "m_map.phi2(fit1) = " << m_map.phi2(fit1) << std::endl; + +// m_map.incCurrentLevel(); +// m_map.setEdgeId(m_map.phi2(fit1), id); +// m_map.decCurrentLevel(); // id = m_map.getTriRefinementEdgeId(m_map.phi2(fit2)); // m_map.setEdgeId(m_map.phi2(fit2), id); // m_map.setEdgeId(fit2, id); - //m_map.setEdgeId(fit2, id); - //std::cout << "fit2 = " << fit2 << std::endl; - //std::cout << "m_map.phi2(fit2) = " << m_map.phi2(fit2) << std::endl; +// m_map.incCurrentLevel(); +// m_map.setEdgeId(m_map.phi2(fit2), id); +// m_map.decCurrentLevel(); // id = m_map.getTriRefinementEdgeId(m_map.phi2(fit3)); // m_map.setEdgeId(m_map.phi2(fit3), id); // m_map.setEdgeId(fit3, id); - //m_map.setEdgeId(fit3, id); - //std::cout << "fit3 = " << fit3 << std::endl; - //std::cout << "m_map.phi2(fit3) = " << m_map.phi2(fit3) << std::endl; -// } +// m_map.incCurrentLevel(); +// m_map.setEdgeId(m_map.phi2(fit3), id); +// m_map.decCurrentLevel(); + } } } } @@ -316,12 +318,33 @@ void IHM2::synthesis() m_map.incCurrentLevel() ; } +template +void IHM2::import(Algo::Surface::Import::QuadTree& qt) +{ + std::cout << " Create finer resolution levels.." << std::flush ; + + for(unsigned int i = 0; i < qt.depth; ++i) + addNewLevel(true) ; + + std::cout << "..done" << std::endl ; + std::cout << " Embed finer resolution levels.." << std::flush ; + + m_map.setCurrentLevel(0) ; + qt.embed(m_map) ; + m_map.setCurrentLevel(m_map.getMaxLevel()) ; + + std::cout << "..done" << std::endl ; +} + + } // namespace Regular } // namespace Primal } // namespace MR +} // namespace Surface + } // namespace Algo } // namespace CGoGN diff --git a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp index e9179d36..b0b07681 100644 --- a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp +++ b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp @@ -310,7 +310,6 @@ void Map2MR::addLevelFront() Dart fit1 = m_map.phi2(m_map.phi1(d)); //m_map.mergeFaces(fit1) ; - // Traversor2VE tve(m_map, d); // for(Dart eit = tve.begin() ; eit != tve.end() ; eit = tve.next()) // { diff --git a/include/Topology/ihmap/ihm2.hpp b/include/Topology/ihmap/ihm2.hpp index cc6e3153..39d719e0 100644 --- a/include/Topology/ihmap/ihm2.hpp +++ b/include/Topology/ihmap/ihm2.hpp @@ -351,10 +351,13 @@ inline unsigned int ImplicitHierarchicalMap2::getTriRefinementEdgeId(Dart d) else if(id == 1) return 2; else if(id == 2) + { if(dId == eId) return 0; else return 1; + } + //else if(id == 3) return 0; } @@ -370,11 +373,6 @@ inline unsigned int ImplicitHierarchicalMap2::getQuadRefinementEdgeId(Dart d) return 0; } -inline void ImplicitHierarchicalMap2::setTriRefinementEdgeId(Dart d) -{ - -} - /*************************************************** * CELLS INFORMATION * ***************************************************/ -- GitLab