Commit fa58e623 authored by Pierre Kraemer's avatar Pierre Kraemer

multires : the beginning !

parent dd2af627
...@@ -31,18 +31,11 @@ namespace CGoGN ...@@ -31,18 +31,11 @@ namespace CGoGN
{ {
const unsigned int EMBNULL = 0xffffffff; const unsigned int EMBNULL = 0xffffffff;
const unsigned int NB_THREAD = 16; const unsigned int MRNULL = 0xffffffff;
//const unsigned int NB_ORBITS = 6;
//const unsigned int VERTEX = 0; const unsigned int NB_THREAD = 16;
//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;
//
// DO NOT MODIFY (ORBIT_IN_PARENT function in Map classes)
const unsigned int NB_ORBITS = 11; const unsigned int NB_ORBITS = 11;
......
...@@ -101,27 +101,25 @@ protected: ...@@ -101,27 +101,25 @@ protected:
std::vector<DartMarkerGen*> dartMarkers ; std::vector<DartMarkerGen*> dartMarkers ;
std::vector<CellMarkerGen*> cellMarkers ; std::vector<CellMarkerGen*> cellMarkers ;
/** /**
* is map a multiresolution map * is map a multiresolution map
*/ */
#ifndef CGoGN_FORCE_MR #ifndef CGoGN_FORCE_MR
bool m_isMultiRes; bool m_isMultiRes;
#elif CGoGN_FORCE_MR == 1 #elif CGoGN_FORCE_MR == 1
static const bool m_isMultiRes=true; static const bool m_isMultiRes = true ;
#else #else
static const bool m_isMultiRes=false; static const bool m_isMultiRes = false ;
#endif #endif
AttributeContainer m_mrattribs ; AttributeContainer m_mrattribs ;
std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts; std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts ;
AttributeMultiVector<unsigned char>* m_mrLevels; AttributeMultiVector<unsigned char>* m_mrLevels ;
unsigned int m_mrCurrentLevel;
std::vector<unsigned int> m_mrLevelStack; unsigned int m_mrCurrentLevel ;
std::vector<unsigned int> m_mrLevelStack ;
public: public:
static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ; static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ;
...@@ -145,6 +143,39 @@ public: ...@@ -145,6 +143,39 @@ public:
*/ */
MarkSet& getMarkerSet(unsigned int orbit, unsigned int thread) { return m_marksets[orbit][thread]; } 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<unsigned int>* amvMR = m_mrattribs.addAttribute<unsigned int>(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 * * DARTS MANAGEMENT *
****************************************/ ****************************************/
...@@ -459,8 +490,6 @@ public: ...@@ -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_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;} 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 * execute functor for each orbit
* @param dim the dimension of the orbit * @param dim the dimension of the orbit
......
...@@ -24,32 +24,13 @@ ...@@ -24,32 +24,13 @@
namespace CGoGN namespace CGoGN
{ {
//#ifndef CGoGN_FORCE_MR
inline unsigned int GenericMap::dartIndex(Dart d) inline unsigned int GenericMap::dartIndex(Dart d)
{ {
if (m_isMultiRes) if (m_isMultiRes)
{ return m_mrDarts[m_mrCurrentLevel][d.index] ;
std::cout << "Not implemented"<< std::endl;
return 0xffffffff;
}
return 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 * * DARTS MANAGEMENT *
...@@ -57,15 +38,23 @@ inline unsigned int GenericMap::dartIndex(Dart d) ...@@ -57,15 +38,23 @@ inline unsigned int GenericMap::dartIndex(Dart d)
inline Dart GenericMap::newDart() inline Dart GenericMap::newDart()
{ {
Dart d = Dart::create(m_attribs[DART].insertLine()); unsigned int di = m_attribs[DART].insertLine();
unsigned int d_index = dartIndex(d);
for(unsigned int i = 0; i < NB_ORBITS; ++i) for(unsigned int i = 0; i < NB_ORBITS; ++i)
{
if (m_embeddings[i]) if (m_embeddings[i])
{ (*m_embeddings[i])[di] = EMBNULL ;
(*m_embeddings[i])[d_index] = EMBNULL ; }
} if (m_isMultiRes)
{
return d ; 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) inline void GenericMap::deleteDart(Dart d)
...@@ -90,15 +79,36 @@ 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) 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() 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() ; return m_attribs[DART].size() ;
} }
......
/*******************************************************************************
* 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
...@@ -91,6 +91,15 @@ GenericMap::GenericMap() : m_nbThreads(1) ...@@ -91,6 +91,15 @@ GenericMap::GenericMap() : m_nbThreads(1)
m_isMultiRes = false; m_isMultiRes = false;
#endif #endif
if(m_isMultiRes)
{
m_mrDarts.reserve(16) ;
m_mrLevelStack.reserve(16) ;
m_mrLevels = m_mrattribs.addAttribute<unsigned char>("MRLevel") ;
addLevel() ;
setCurrentLevel(0) ;
}
} }
GenericMap::~GenericMap() GenericMap::~GenericMap()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment