diff --git a/include/Topology/generic/dart.h b/include/Topology/generic/dart.h index a9ba0b3ac599865da9624bb59cd73e31253a7f19..ddaa3e2e308e882068a0063a5d95c188d815eca4 100644 --- a/include/Topology/generic/dart.h +++ b/include/Topology/generic/dart.h @@ -31,18 +31,11 @@ namespace CGoGN { const unsigned int EMBNULL = 0xffffffff; -const unsigned int NB_THREAD = 16; - -//const unsigned int NB_ORBITS = 6; +const unsigned int MRNULL = 0xffffffff; -//const unsigned int VERTEX = 0; -//const unsigned int EDGE = 1; -//const unsigned int ORIENTED_FACE = 2; -//const unsigned int FACE = 3; -//const unsigned int VOLUME = 4; -//const unsigned int DART = 5; -// +const unsigned int NB_THREAD = 16; +// DO NOT MODIFY (ORBIT_IN_PARENT function in Map classes) const unsigned int NB_ORBITS = 11; diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index f79cd4b550308bb27b994887b287b01a8485a04a..59ffa2bc1c263ee5b43c27a41a3e3f6f0900d88e 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -101,27 +101,25 @@ protected: std::vector dartMarkers ; std::vector cellMarkers ; - /** * is map a multiresolution map */ #ifndef CGoGN_FORCE_MR bool m_isMultiRes; #elif CGoGN_FORCE_MR == 1 - static const bool m_isMultiRes=true; + static const bool m_isMultiRes = true ; #else - static const bool m_isMultiRes=false; + static const bool m_isMultiRes = false ; #endif AttributeContainer m_mrattribs ; - std::vector< AttributeMultiVector* > m_mrDarts; - AttributeMultiVector* m_mrLevels; - - unsigned int m_mrCurrentLevel; + std::vector< AttributeMultiVector* > m_mrDarts ; + AttributeMultiVector* m_mrLevels ; - std::vector m_mrLevelStack; + unsigned int m_mrCurrentLevel ; + std::vector m_mrLevelStack ; public: static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ; @@ -145,6 +143,39 @@ public: */ MarkSet& getMarkerSet(unsigned int orbit, unsigned int thread) { return m_marksets[orbit][thread]; } + /**************************************** + * MULTIRES * + ****************************************/ + + unsigned int getCurrentLevel() { return m_mrCurrentLevel ; } + + void setCurrentLevel(unsigned int l) + { + if(l < m_mrDarts.size()) + m_mrCurrentLevel = l ; + else + CGoGNout << "try to access inexisting resolution level" << CGoGNendl ; + } + + void pushLevel() { m_mrLevelStack.push_back(m_mrCurrentLevel) ; } + + void popLevel() { m_mrCurrentLevel = m_mrLevelStack.back() ; m_mrLevelStack.pop_back() ; } + + unsigned int getMaxLevel() { return m_mrDarts.size() - 1 ; } + + void addLevel() + { + unsigned int level = m_mrDarts.size() ; + std::stringstream ss ; + ss << "MRdart_"<< level ; + AttributeMultiVector* amvMR = m_mrattribs.addAttribute(ss.str()) ; + + m_mrDarts.push_back(amvMR) ; + // copy the darts pointers of the previous level + if(m_mrDarts.size() > 1) + m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[m_mrDarts.size() - 2]->getIndex()) ; + } + /**************************************** * DARTS MANAGEMENT * ****************************************/ @@ -459,8 +490,6 @@ public: virtual bool foreach_dart_of_edge2(Dart d, FunctorType& f, unsigned int thread = 0) { std::cerr<< "Not implemented"<< std::endl; return false;} virtual bool foreach_dart_of_face2(Dart d, FunctorType& f, unsigned int thread = 0) { std::cerr<< "Not implemented"<< std::endl; return false;} - - /** * execute functor for each orbit * @param dim the dimension of the orbit diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index 73e30d9004076a50501afc117253e44e302fd69c..57c9f8093be7cd373bf22146353e5d2a39dfffd8 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -24,32 +24,13 @@ namespace CGoGN { -//#ifndef CGoGN_FORCE_MR + inline unsigned int GenericMap::dartIndex(Dart d) { if (m_isMultiRes) - { - std::cout << "Not implemented"<< std::endl; - return 0xffffffff; - } + return m_mrDarts[m_mrCurrentLevel][d.index] ; return d.index; } -//#elif CGoGN_FORCE_MR == 1 -//inline unsigned int GenericMap::dartIndex(Dart d) -//{ -// std::cout << "Not implemented"<< std::endl; -// return 0xffffffff; -//} -//#else -//inline unsigned int GenericMap::dartIndex(Dart d) -//{ -// return d.index; -//} -//#endif - - - - /**************************************** * DARTS MANAGEMENT * @@ -57,15 +38,23 @@ inline unsigned int GenericMap::dartIndex(Dart d) inline Dart GenericMap::newDart() { - Dart d = Dart::create(m_attribs[DART].insertLine()); - unsigned int d_index = dartIndex(d); + unsigned int di = m_attribs[DART].insertLine(); for(unsigned int i = 0; i < NB_ORBITS; ++i) + { if (m_embeddings[i]) - { - (*m_embeddings[i])[d_index] = EMBNULL ; - } - - return d ; + (*m_embeddings[i])[di] = EMBNULL ; + } + if (m_isMultiRes) + { + unsigned int mrdi = m_mrattribs.insertLine() ; + m_mrLevels[mrdi] = m_mrCurrentLevel ; + for(unsigned int i = 0; i < m_mrCurrentLevel; ++i) + m_mrDarts[i][mrdi] = MRNULL ; + for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) + m_mrDarts[i][mrdi] = di ; + return Dart::create(mrdi) ; + } + return Dart::create(di) ; } inline void GenericMap::deleteDart(Dart d) @@ -90,15 +79,36 @@ inline void GenericMap::deleteDart(Dart d) } } } + + // hypothese : le brin MR pointe vers le même brin pour tous les niveaux >= au courant + if(m_isMultiRes) + { + if(m_mrCurrentLevel == 0) + m_mrattribs.removeLine(d.index) ; + else + { + unsigned int di = m_mrDarts[m_mrCurrentLevel - 1][d.index] ; + for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) + m_mrDarts[i][d.index] = di ; + } + } } inline bool GenericMap::isDartValid(Dart d) { - return !d.isNil() && m_attribs[DART].used( dartIndex(d)) ; + return !d.isNil() && m_attribs[DART].used(dartIndex(d)) ; } inline unsigned int GenericMap::getNbDarts() { + if(m_isMultiRes) + { + unsigned int nbDarts = 0 ; + for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i)) + if(m_mrLevels->operator[](i) <= m_mrCurrentLevel) + ++nbDarts ; + return nbDarts ; + } return m_attribs[DART].size() ; } diff --git a/include/Topology/map/map2MR/map2MR_Primal.h b/include/Topology/map/map2MR/map2MR_Primal.h new file mode 100644 index 0000000000000000000000000000000000000000..ed785ff8f7c30fc4dfbfa3e75b0ba13ab949378b --- /dev/null +++ b/include/Topology/map/map2MR/map2MR_Primal.h @@ -0,0 +1,39 @@ +/******************************************************************************* +* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * +* version 0.1 * +* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg * +* * +* This library is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by the * +* Free Software Foundation; either version 2.1 of the License, or (at your * +* option) any later version. * +* * +* This library is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this library; if not, write to the Free Software Foundation, * +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * +* * +* Web site: http://cgogn.u-strasbg.fr/ * +* Contact information: cgogn@unistra.fr * +* * +*******************************************************************************/ + +#ifndef __MAP2MR_PRIMAL__ +#define __MAP2MR_PRIMAL__ + +#include "Topology/map/map2.h" + +namespace CGoGN +{ + +class Map2MR_Primal : protected Map2 +{ +} ; + +} // namespace CGoGN + +#endif diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index 025eb44bb0cffcd1fa7af92cf432c00bb9fd873c..e5ac87b87b560716e7c7e8ae260488f814cc2571 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -91,6 +91,15 @@ GenericMap::GenericMap() : m_nbThreads(1) m_isMultiRes = false; #endif + if(m_isMultiRes) + { + m_mrDarts.reserve(16) ; + m_mrLevelStack.reserve(16) ; + + m_mrLevels = m_mrattribs.addAttribute("MRLevel") ; + addLevel() ; + setCurrentLevel(0) ; + } } GenericMap::~GenericMap()