diff --git a/include/Algo/Import/importMRDAT.h b/include/Algo/Import/importMRDAT.h index 64c6ae1627effb6f7ea7bdf551fb040399d83a6e..ba660d6dd5630a8540316444d6747ccf2e2519de 100644 --- a/include/Algo/Import/importMRDAT.h +++ b/include/Algo/Import/importMRDAT.h @@ -101,6 +101,7 @@ public: unsigned int newEmb = vID[children[0]->indices[idx]] ; if(oldEmb == EMBNULL) { + //std::cout << "oldEmb == NULL"<< std::endl; map.template setOrbitEmbedding(dd, newEmb) ; map.pushLevel() ; for(unsigned int i = map.getCurrentLevel() + 1; i <= map.getMaxLevel(); ++i) @@ -111,11 +112,16 @@ public: map.popLevel() ; } else + { + //std::cout << "oldEmb != NULL"<< std::endl; assert(oldEmb == newEmb) ; + } + map.decCurrentLevel() ; it = next ; } while(it != d) ; + //embed the 4 children (begin with the center child) map.incCurrentLevel() ; Dart d0 = map.phi2(map.phi1(d)) ; children[0]->embed(map, d0, vID) ; @@ -155,6 +161,7 @@ public: std::vector roots ; std::vector darts ; std::vector verticesID ; + unsigned int depth; ~QuadTree() { diff --git a/include/Algo/Import/importMRDAT.hpp b/include/Algo/Import/importMRDAT.hpp index a84f26ee4c8bbc77e71415735db3bdb72cecbbc3..1d20f5d602f969ce64b019ab1fd77664b5e1fa3c 100644 --- a/include/Algo/Import/importMRDAT.hpp +++ b/include/Algo/Import/importMRDAT.hpp @@ -77,7 +77,8 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto std::stringstream oss(line) ; std::string s ; oss >> s ; - oss >> depth ; + oss >> qt.depth ; + depth = qt.depth; } std::cout << " MR depth -> " << depth << std::endl ; @@ -253,19 +254,6 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto return false ; } - std::cout << "..done" << std::endl ; - std::cout << " Create finer resolution levels.." << std::flush ; - - for(unsigned int i = 0; i < depth; ++i) - map.addNewLevel(false) ; - - std::cout << "..done" << std::endl ; - std::cout << " Embed finer resolution levels.." << std::flush ; - - map.setCurrentLevel(0) ; - qt.embed(map) ; - map.setCurrentLevel(map.getMaxLevel()) ; - std::cout << "..done" << std::endl ; return true ; diff --git a/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp b/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp index c8fcbcc1416b1aae36995df24db82c36336795ae..a7fc8f7e53a19c1c12515a75d0d96762b1ffcae7 100644 --- a/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp +++ b/include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp @@ -39,8 +39,8 @@ namespace Regular template IHM2::IHM2(typename PFP::MAP& map) : - m_map(map), - shareVertexEmbeddings(true) + m_map(map), + shareVertexEmbeddings(true) { } @@ -49,109 +49,113 @@ IHM2::IHM2(typename PFP::MAP& map) : template void IHM2::addNewLevel(bool triQuad) { - unsigned int cur = m_map.getCurrentLevel() ; //pushLevel + unsigned int cur = m_map.getCurrentLevel() ; //pushLevel m_map.setCurrentLevel(m_map.getMaxLevel() + 1) ; - // cut edges - TraversorE travE(m_map) ; - for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) - { - Dart dd = m_map.phi2(d) ; - - m_map.cutEdge(d) ; - unsigned int eId = m_map.getEdgeId(d) ; - m_map.setEdgeId(m_map.phi1(d), eId) ; - m_map.setEdgeId(m_map.phi1(dd), eId) ; - - travE.skip(d) ; - travE.skip(m_map.phi1(d)) ; - } - - // split faces - TraversorF travF(m_map) ; - for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) - { - Dart old = d ; - - if(m_map.getDartLevel(old) == m_map.getMaxLevel()) - old = m_map.phi1(old) ; - - m_map.decCurrentLevel(); - unsigned int degree = m_map.faceDegree(old) ; - m_map.incCurrentLevel(); - - if((degree == 3) && triQuad) // if subdividing a triangle - { - Dart dd = m_map.phi1(old) ; - Dart e = m_map.phi1(m_map.phi1(dd)) ; - m_map.splitFace(dd, e) ; // insert a new edge - travF.skip(dd) ; - unsigned int id = m_map.getNewEdgeId() ; - m_map.setEdgeId(m_map.phi_1(dd), id) ; // set the edge id of the inserted - m_map.setEdgeId(m_map.phi_1(e), id) ; // edge to the next available id - - dd = e ; - e = m_map.phi1(m_map.phi1(dd)) ; - m_map.splitFace(dd, e) ; - travF.skip(dd) ; - id = m_map.getNewEdgeId() ; - m_map.setEdgeId(m_map.phi_1(dd), id) ; - m_map.setEdgeId(m_map.phi_1(e), id) ; - - dd = e ; - e = m_map.phi1(m_map.phi1(dd)) ; - m_map.splitFace(dd, e) ; - travF.skip(dd) ; - id = m_map.getNewEdgeId() ; - m_map.setEdgeId(m_map.phi_1(dd), id) ; - m_map.setEdgeId(m_map.phi_1(e), id) ; - - travF.skip(e) ; - } - else // if subdividing a polygonal face - { - Dart dd = m_map.phi1(old) ; - Dart next = m_map.phi1(m_map.phi1(dd)) ; - m_map.splitFace(dd, next) ; // insert a first edge - - Dart ne = m_map.phi2(m_map.phi_1(dd)) ; - Dart ne2 = m_map.phi2(ne) ; - m_map.cutEdge(ne) ; // cut the new edge to insert the central vertex - travF.skip(dd) ; - unsigned int id = m_map.getNewEdgeId() ; - m_map.setEdgeId(ne, id) ; - m_map.setEdgeId(m_map.phi2(ne), id) ; // set the edge id of the inserted - id = m_map.getNewEdgeId() ; - m_map.setEdgeId(ne2, id) ; // edges to the next available ids - m_map.setEdgeId(m_map.phi2(ne2), id) ; - - dd = m_map.phi1(m_map.phi1(next)) ; - while(dd != ne) // turn around the face and insert new edges - { // linked to the central vertex - Dart tmp = m_map.phi1(ne) ; - m_map.splitFace(tmp, dd) ; - travF.skip(tmp) ; - Dart nne = m_map.phi2(m_map.phi_1(dd)) ; - id = m_map.getNewEdgeId() ; - m_map.setEdgeId(nne, id) ; - m_map.setEdgeId(m_map.phi2(nne), id) ; - dd = m_map.phi1(m_map.phi1(dd)) ; - } - travF.skip(ne) ; - } - } - - m_map.setCurrentLevel(cur) ; + // cut edges + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + Dart dd = m_map.phi2(d) ; + + m_map.cutEdge(d) ; + unsigned int eId = m_map.getEdgeId(d) ; + m_map.setEdgeId(m_map.phi1(d), eId) ; + m_map.setEdgeId(m_map.phi1(dd), eId) ; + + travE.skip(d) ; + travE.skip(m_map.phi1(d)) ; + } + + // split faces + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + Dart old = d ; + + if(m_map.getDartLevel(old) == m_map.getMaxLevel()) + old = m_map.phi1(old) ; + + m_map.decCurrentLevel(); + unsigned int degree = m_map.faceDegree(old) ; + m_map.incCurrentLevel(); + + if((degree == 3) && triQuad) // if subdividing a triangle + { + Dart dd = m_map.phi1(old) ; + Dart e = m_map.phi1(m_map.phi1(dd)) ; + m_map.splitFace(dd, e) ; // insert a new edge + travF.skip(dd) ; + //unsigned int id = m_map.getNewEdgeId() ; + unsigned int id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd)); + m_map.setEdgeId(m_map.phi_1(dd), id) ; // set the edge id of the inserted + m_map.setEdgeId(m_map.phi_1(e), id) ; // edge to the next available id + + dd = e ; + e = m_map.phi1(m_map.phi1(dd)) ; + m_map.splitFace(dd, e) ; + travF.skip(dd) ; + //id = m_map.getNewEdgeId() ; + id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd)); + m_map.setEdgeId(m_map.phi_1(dd), id) ; + m_map.setEdgeId(m_map.phi_1(e), id) ; + + dd = e ; + e = m_map.phi1(m_map.phi1(dd)) ; + m_map.splitFace(dd, e) ; + travF.skip(dd) ; + //id = m_map.getNewEdgeId() ; + id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd)); + m_map.setEdgeId(m_map.phi_1(dd), id) ; + m_map.setEdgeId(m_map.phi_1(e), id) ; + + travF.skip(e) ; + } + else // if subdividing a polygonal face + { + Dart dd = m_map.phi1(old) ; + Dart next = m_map.phi1(m_map.phi1(dd)) ; + m_map.splitFace(dd, next) ; // insert a first edge + + Dart ne = m_map.phi2(m_map.phi_1(dd)) ; + Dart ne2 = m_map.phi2(ne) ; + m_map.cutEdge(ne) ; // cut the new edge to insert the central vertex + travF.skip(dd) ; + //unsigned int id = m_map.getNewEdgeId() ; + unsigned int id = m_map.getQuadRefinementEdgeId(m_map.phi2(ne)); + m_map.setEdgeId(ne, id) ; + m_map.setEdgeId(m_map.phi2(ne), id) ; // set the edge id of the inserted + //id = m_map.getNewEdgeId() ; + id = m_map.getQuadRefinementEdgeId(ne2); + m_map.setEdgeId(ne2, id) ; // edges to the next available ids + m_map.setEdgeId(m_map.phi2(ne2), id) ; + + dd = m_map.phi1(m_map.phi1(next)) ; + while(dd != ne) // turn around the face and insert new edges + { // linked to the central vertex + Dart tmp = m_map.phi1(ne) ; + m_map.splitFace(tmp, dd) ; + travF.skip(tmp) ; + Dart nne = m_map.phi2(m_map.phi_1(dd)) ; + //id = m_map.getNewEdgeId() ; + id = m_map.getQuadRefinementEdgeId(m_map.phi2(nne)); + m_map.setEdgeId(nne, id) ; + m_map.setEdgeId(m_map.phi2(nne), id) ; + dd = m_map.phi1(m_map.phi1(dd)) ; + } + travF.skip(ne) ; + } + } + + m_map.setCurrentLevel(cur) ; } template void IHM2::addLevelFront() { - DartMarker md(m_map); - - std::vector visitedVertices; - visitedVertices.reserve(1024); + std::vector irregVertices; + irregVertices.reserve(1024); //look for an irregular vertex @@ -162,77 +166,154 @@ void IHM2::addLevelFront() if(m_map.vertexDegree(d) != 6) { found = true; - visitedVertices.push_back(d); + irregVertices.push_back(d); } } - std::cout << "d = " << visitedVertices[0] << std::endl; + //found the number of levels + bool finished = false; + Dart dit = irregVertices[0]; + unsigned int nbSteps = 0; + do + { + dit = m_map.phi1(m_map.phi2(m_map.phi1(m_map.phi2(m_map.phi1(dit))))); + ++nbSteps; + + if(m_map.vertexDegree(m_map.phi1(dit)) != 6) + finished = true; + }while(!finished); - for(unsigned int i = 0 ; i < visitedVertices.size() ; ++i) + ++nbSteps; + + unsigned int nbLevel = 0; + while(nbSteps > 1) { - Dart d = visitedVertices[i]; + nbSteps /= 2 ; + ++nbLevel ; + } + m_map.setMaxLevel(nbLevel); + + std::cout << "nb levels = " << nbLevel+1 << std::endl; - Traversor2VE tve(m_map, d); - for(Dart eit = tve.begin() ; eit != tve.end() ; eit = tve.next()) + unsigned int curLevel = nbLevel; + + do + { + m_map.setCurrentLevel(curLevel); + + DartMarker md(m_map); + std::vector visitedVertices(irregVertices); + + std::cout << "getCurrentLevel = " << m_map.getCurrentLevel() << std::endl; + + for(unsigned int i = 0 ; i < visitedVertices.size() ; ++i) { - //coarse all faces around the vertex - if(!md.isMarked(eit)) - { - unsigned int degree = m_map.faceDegree(eit); + Dart d = visitedVertices[i]; - if(degree == 3) + Traversor2VE tve(m_map, d); + for(Dart eit = tve.begin() ; eit != tve.end() ; eit = tve.next()) + { + //coarse all faces around the vertex + if(!md.isMarked(eit)) { Dart fit1 = m_map.phi2(m_map.phi1(eit)); Dart fit2 = m_map.phi1(fit1); Dart fit3 = m_map.phi1(fit2); - unsigned int id = m_map.getNewEdgeId() ; - m_map.setEdgeId(fit1, id) ; - id = m_map.getNewEdgeId() ; - m_map.setEdgeId(fit2, id) ; - id = m_map.getNewEdgeId() ; - m_map.setEdgeId(fit3, id) ; - md.markOrbit(fit1); md.markOrbit(m_map.phi2(fit2)); md.markOrbit(m_map.phi2(fit3)); + md.markOrbit(eit); + + visitedVertices.push_back(m_map.phi_1(m_map.phi2(fit2))); + visitedVertices.push_back(m_map.phi_1(m_map.phi2(fit3))); + + m_map.setDartLevel(fit1, curLevel); + m_map.setDartLevel(m_map.phi2(fit1), curLevel); + m_map.setDartLevel(m_map.phi1(m_map.phi2(fit1)), curLevel); + + m_map.setDartLevel(fit2, curLevel); + m_map.setDartLevel(m_map.phi2(fit2), curLevel); + m_map.setDartLevel(m_map.phi1(m_map.phi2(fit2)), curLevel); + + m_map.setDartLevel(fit3, curLevel); + m_map.setDartLevel(m_map.phi2(fit3), curLevel); + m_map.setDartLevel(m_map.phi1(m_map.phi2(fit3)), curLevel); + + if(curLevel == maxLevel) + { + unsigned int id = m_map.getTriRefinementEdgeId(m_map.phi2(fit1)); + m_map.setEdgeId(m_map.phi2(fit1), id); + m_map.setEdgeId(fit1, id); + + id = m_map.getTriRefinementEdgeId(m_map.phi2(fit2)); + m_map.setEdgeId(m_map.phi2(fit2), id); + m_map.setEdgeId(fit2, id); + + id = m_map.getTriRefinementEdgeId(m_map.phi2(fit3)); + m_map.setEdgeId(m_map.phi2(fit3), id); + m_map.setEdgeId(fit3, id); + } + 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; + +// 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; + +// 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; +// } } - else - { + } + } - } + curLevel = curLevel - 1; - visitedVertices.push_back(m_map.phi1(m_map.phi1(eit))); - visitedVertices.push_back(m_map.phi_1(m_map.phi_1(eit))); - md.markOrbit(eit); + }while(curLevel > 1); - } - } - } + m_map.setCurrentLevel(nbLevel); //m_maxLevel } template void IHM2::analysis() { - assert(m_map.getCurrentLevel() > 0 || !"analysis : called on level 0") ; + assert(m_map.getCurrentLevel() > 0 || !"analysis : called on level 0") ; - m_map.decCurrentLevel() ; + m_map.decCurrentLevel() ; - for(unsigned int i = 0; i < analysisFilters.size(); ++i) - (*analysisFilters[i])() ; + for(unsigned int i = 0; i < analysisFilters.size(); ++i) + (*analysisFilters[i])() ; } template void IHM2::synthesis() { - assert(m_map.getCurrentLevel() < m_map.getMaxLevel() || !"synthesis : called on max level") ; + assert(m_map.getCurrentLevel() < m_map.getMaxLevel() || !"synthesis : called on max level") ; - for(unsigned int i = 0; i < synthesisFilters.size(); ++i) - (*synthesisFilters[i])() ; + for(unsigned int i = 0; i < synthesisFilters.size(); ++i) + (*synthesisFilters[i])() ; - m_map.incCurrentLevel() ; + m_map.incCurrentLevel() ; } } // namespace Regular diff --git a/include/Algo/Multiresolution/Map2MR/Masks/catmullClark.h b/include/Algo/Multiresolution/Map2MR/Masks/catmullClark.h index 7a623f2c042d3ad6fb549da743df34273a7f64ab..257095c0af840d93f36b25ddba8addac338265cc 100644 --- a/include/Algo/Multiresolution/Map2MR/Masks/catmullClark.h +++ b/include/Algo/Multiresolution/Map2MR/Masks/catmullClark.h @@ -75,7 +75,7 @@ public: np2 += m_position[dd] ; dd = m_map.phi1(dd) ; } while(dd != end) ; - it = m_map.alpha1(it) ; + it = m_map.phi2(m_map.phi_1(it)) ; } while(it != d) ; float beta = 3.0 / (2.0 * degree1) ; diff --git a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.h b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.h index 12d528a779e08f43839866ad32880b3f629f469e..0eaa6a277015b8979a26e96adfeeaa18cc1ff1e8 100644 --- a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.h +++ b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.h @@ -68,7 +68,7 @@ public: ~Map2MR(); //if true : tri and quad else quad - void addNewLevel(bool triQuad = true) ; + void addNewLevel(bool triQuad = true, bool embedNewVertices = false) ; void addNewLevelSqrt3(); @@ -84,6 +84,8 @@ public: void synthesis() ; void addLevelFront(); + + void import(Algo::Surface::Import::QuadTree& qt); } ; } // namespace Regular diff --git a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp index 8bceb93c175e4da33bf70dc87bb4514120847f35..e9179d3662dcb7418a182361315f693f5c252cf0 100644 --- a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp +++ b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp @@ -22,6 +22,8 @@ * * *******************************************************************************/ +#include "Algo/Import/importMRDAT.h" + namespace CGoGN { @@ -62,7 +64,7 @@ Map2MR::~Map2MR() } template -void Map2MR::addNewLevel(bool triQuad) +void Map2MR::addNewLevel(bool triQuad, bool embedNewVertices) { m_map.pushLevel() ; @@ -74,18 +76,22 @@ void Map2MR::addNewLevel(bool triQuad) TraversorE travE(m_map) ; for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) { - // if(!shareVertexEmbeddings) - // { - // if(m_map.template getEmbedding(d) == EMBNULL) - // m_map.template setOrbitEmbeddingOnNewCell(d) ; - // if(m_map.template getEmbedding(m_map.phi1(d)) == EMBNULL) - // m_map.template setOrbitEmbeddingOnNewCell(d) ; - // } +// if(!shareVertexEmbeddings && embedNewVertices) +// { +// if(m_map.template getEmbedding(d) == EMBNULL) +// m_map.template setOrbitEmbeddingOnNewCell(d) ; +// if(m_map.template getEmbedding(m_map.phi1(d)) == EMBNULL) +// m_map.template setOrbitEmbeddingOnNewCell(d) ; +// } m_map.cutEdge(d) ; travE.skip(d) ; travE.skip(m_map.phi1(d)) ; + //std::cout << "is EMB NULL : " << ( m_map.template getEmbedding(m_map.phi1(d)) == EMBNULL ? "true" : "false" ) << std::endl; + + //if(embedNewVertices) + // m_map.template setOrbitEmbeddingOnNewCell(m_map.phi1(d)) ; } // split faces @@ -129,6 +135,9 @@ void Map2MR::addNewLevel(bool triQuad) m_map.cutEdge(ne) ; // cut the new edge to insert the central vertex travF.skip(dd) ; + //if(embedNewVertices) + // m_map.template setOrbitEmbeddingOnNewCell(m_map.phi1(ne)) ; + dd = m_map.phi1(m_map.phi1(next)) ; while(dd != ne) // turn around the face and insert new edges { // linked to the central vertex @@ -342,6 +351,24 @@ void Map2MR::addLevelFront() } } +template +void Map2MR::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, false) ; + + 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 diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index 9bf180e61bd38a1a9fc312074fa4caaa4cb4718d..d6585f1e94296cc7b0a65f26e7956eb2e798eaa0 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -281,7 +281,7 @@ public: /** * duplicate darts from level-1 to level */ - void duplicateDarts(unsigned int level); + void duplicateDarts(unsigned int newlevel); /** * duplicate a dart starting from current level diff --git a/include/Topology/ihmap/ihm2.h b/include/Topology/ihmap/ihm2.h index a160daeb96a6bfed87b7e0497e4a446636fee475..a26d840fb940d1ec5a94587f39c958759cecbce2 100644 --- a/include/Topology/ihmap/ihm2.h +++ b/include/Topology/ihmap/ihm2.h @@ -141,6 +141,8 @@ public: void setDartLevel(Dart d, unsigned int i) ; + void setMaxLevel(unsigned int l); + /*************************************************** * EDGE ID MANAGEMENT * ***************************************************/ @@ -159,6 +161,10 @@ public: void setEdgeId(Dart d, unsigned int i) ; + unsigned int getTriRefinementEdgeId(Dart d); + + unsigned int getQuadRefinementEdgeId(Dart d); + /*************************************************** * CELLS INFORMATION * ***************************************************/ diff --git a/include/Topology/ihmap/ihm2.hpp b/include/Topology/ihmap/ihm2.hpp index ced3dd560076402953fa17099e755ead6dab1092..cc6e31532b5db017f7ad7cffabaed8915e4398e0 100644 --- a/include/Topology/ihmap/ihm2.hpp +++ b/include/Topology/ihmap/ihm2.hpp @@ -314,6 +314,12 @@ inline void ImplicitHierarchicalMap2::setDartLevel(Dart d, unsigned int l) m_dartLevel[d] = l ; } +inline void ImplicitHierarchicalMap2::setMaxLevel(unsigned int l) +{ + m_maxLevel = l; +} + + /*************************************************** * EDGE ID MANAGEMENT * ***************************************************/ @@ -333,6 +339,42 @@ inline void ImplicitHierarchicalMap2::setEdgeId(Dart d, unsigned int i) m_edgeId[d] = i ; } +inline unsigned int ImplicitHierarchicalMap2::getTriRefinementEdgeId(Dart d) +{ + unsigned int dId = getEdgeId(phi_1(d)); + unsigned int eId = getEdgeId(phi1(d)); + + unsigned int id = dId + eId; + + if(id == 0) + return 1; + else if(id == 1) + return 2; + else if(id == 2) + if(dId == eId) + return 0; + else + return 1; + //else if(id == 3) + return 0; +} + +inline unsigned int ImplicitHierarchicalMap2::getQuadRefinementEdgeId(Dart d) +{ + unsigned int eId = getEdgeId(phi1(d)); + + if(eId == 0) + return 1; + + //else if(eId == 1) + return 0; +} + +inline void ImplicitHierarchicalMap2::setTriRefinementEdgeId(Dart d) +{ + +} + /*************************************************** * CELLS INFORMATION * ***************************************************/ diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index 2ff8d7fc6da56829e302a61647c028f287975f3e..e256bbbba80cacd42cb9b993cc48a78f572e3c5d 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -244,13 +244,16 @@ void GenericMap::addLevelBack() std::stringstream ss ; ss << "MRdart_"<< newLevel ; AttributeMultiVector* newAttrib = m_mrattribs.addAttribute(ss.str()) ; - AttributeMultiVector* prevAttrib = m_mrDarts[newLevel - 1]; - - // copy the indices of previous level into new level - m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->getIndex()) ; m_mrDarts.push_back(newAttrib) ; m_mrNbDarts.push_back(0) ; + + if(m_mrDarts.size() > 1 ) + { + // copy the indices of previous level into new level + AttributeMultiVector* prevAttrib = m_mrDarts[newLevel - 1]; + m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->getIndex()) ; + } } void GenericMap::addLevelFront() @@ -341,13 +344,22 @@ void GenericMap::copyLevel(unsigned int level) m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->getIndex()) ; } -void GenericMap::duplicateDarts(unsigned int level) +void GenericMap::duplicateDarts(unsigned int newlevel) { - AttributeMultiVector* attrib = m_mrDarts[level] ; +// AttributeMultiVector* attrib = m_mrDarts[level] ; //is a copy of the mrDarts at level-1 or level+1 + +// for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i)) +// { +// unsigned int oldi = (*attrib)[i] ; // get the index of the dart in previous level +// (*attrib)[i] = copyDartLine(oldi) ; // copy the dart and affect it to the new level +// } + + AttributeMultiVector* attrib = m_mrDarts[newlevel] ; //is a copy of the mrDarts at level-1 or level+1 + AttributeMultiVector* prevAttrib = m_mrDarts[newlevel - 1] ; // copy the indices of for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i)) { - unsigned int oldi = (*attrib)[i] ; // get the index of the dart in previous level + unsigned int oldi = (*prevAttrib)[i] ; // get the index of the dart in previous level (*attrib)[i] = copyDartLine(oldi) ; // copy the dart and affect it to the new level } } diff --git a/src/Topology/ihmap/ihm2.cpp b/src/Topology/ihmap/ihm2.cpp index f5e0152b1cfd15aae7a92b1ba80e8e4c34473afa..81068e4f8cff7d399049f5872797b1f64e5b3217 100644 --- a/src/Topology/ihmap/ihm2.cpp +++ b/src/Topology/ihmap/ihm2.cpp @@ -57,13 +57,13 @@ void ImplicitHierarchicalMap2::clear(bool removeAttrib) void ImplicitHierarchicalMap2::initImplicitProperties() { - initEdgeId() ; + //initEdgeId() ; -// //init each edge Id at 0 -// for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d)) -// { -// m_edgeId[d] = 0; -// } + //init each edge Id at 0 + for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d)) + { + m_edgeId[d] = 0; + } for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) { diff --git a/src/Topology/map/embeddedMap2.cpp b/src/Topology/map/embeddedMap2.cpp index e1d6ba6b03cd3c00ad471f172a597550990c4342..4d932be181e96a7888fb43f2c1821f6c96ce203b 100644 --- a/src/Topology/map/embeddedMap2.cpp +++ b/src/Topology/map/embeddedMap2.cpp @@ -695,13 +695,16 @@ bool EmbeddedMap2::check() CGoGNout << "Check: embedding ok" << CGoGNendl ; std::cout << "nb vertex orbits : " << getNbOrbits() << std::endl ; - std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ; + if (isOrbitEmbedded()) + std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ; std::cout << "nb edge orbits : " << getNbOrbits() << std::endl ; - std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ; + if (isOrbitEmbedded()) + std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ; std::cout << "nb face orbits : " << getNbOrbits() << std::endl ; - std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ; + if (isOrbitEmbedded()) + std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ; return true ; }