Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 6a50a13f authored by untereiner's avatar untereiner
Browse files

Merge cgogn:~kraemer/CGoGN

parents 50ad264b 278bef22
......@@ -198,6 +198,11 @@ public:
*/
void addLevel() ;
/**
* add a resolution level and duplicate all darts (use only in MRMaps)
*/
void addLevelDuplicate() ;
/**
* get the insertion level of a dart (use only in MRMaps)
*/
......
......@@ -46,7 +46,7 @@ inline void GenericMap::setCurrentLevel(unsigned int l)
if(l < m_mrDarts.size())
m_mrCurrentLevel = l ;
else
CGoGNout << "setCurrentLevel : try to access inexisting resolution level" << CGoGNendl ;
CGoGNout << "setCurrentLevel : try to access nonexistent resolution level" << CGoGNendl ;
}
inline void GenericMap::pushLevel()
......@@ -86,10 +86,22 @@ inline Dart GenericMap::newDart()
{
unsigned int mrdi = m_mrattribs.insertLine() ;
m_mrLevels->operator[](mrdi) = m_mrCurrentLevel ;
for(unsigned int i = 0; i < m_mrCurrentLevel; ++i)
m_mrDarts[i]->operator[](mrdi) = MRNULL ;
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i)
m_mrDarts[i]->operator[](mrdi) = di ;
m_mrDarts[m_mrCurrentLevel]->operator[](mrdi) = di ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
{
unsigned int dj = m_attribs[DART].insertLine();
for(unsigned int o = 0; o < NB_ORBITS; ++o)
{
if (m_embeddings[o])
(*m_embeddings[o])[dj] = EMBNULL ;
}
m_mrDarts[i]->operator[](mrdi) = dj ;
}
return Dart::create(mrdi) ;
}
return Dart::create(di) ;
......@@ -284,7 +296,7 @@ inline void GenericMap::next(Dart& d)
do
{
m_mrattribs.next(d.index) ;
} while ((d.index != m_mrattribs.end() ) && (getDartLevel(d.index) > m_mrCurrentLevel)) ;
} while (d.index != m_mrattribs.end() && getDartLevel(d) > m_mrCurrentLevel) ;
}
else
m_attribs[DART].next(d.index) ;
......
......@@ -31,189 +31,6 @@
namespace CGoGN
{
//
//template <typename MAP>
//class TraversorCell
//{
//private:
// MAP& m ;
// unsigned int m_orbit ;
// DartMarker* dmark ;
// CellMarker* cmark ;
// Dart current ;
// bool firstTraversal ;
// const FunctorSelect& m_good ;
//
//public:
// TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good = allDarts, bool forceDartMarker = false, unsigned int thread = 0) :
// m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
// {
// if(!forceDartMarker && map.isOrbitEmbedded(m_orbit))
// cmark = new CellMarker(map, m_orbit, thread) ;
// else
// dmark = new DartMarker(map, thread) ;
// }
//
// ~TraversorCell()
// {
// if(dmark)
// delete dmark ;
// else
// delete cmark ;
// }
//
// Dart begin()
// {
// if(!firstTraversal)
// {
// if(dmark)
// dmark->unmarkAll() ;
// else
// cmark->unmarkAll() ;
// }
//
// current = m.begin() ;
// while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
// m.next(current) ;
//
// if(current == m.end())
// current = NIL ;
// else
// {
// if(dmark)
// dmark->markOrbit(m_orbit, current) ;
// else
// cmark->mark(current) ;
// }
//
// firstTraversal = false ;
// return current ;
// }
//
// Dart end() { return NIL ; }
//
// Dart next()
// {
// if(current != NIL)
// {
// bool ismarked ;
// if(dmark)
// ismarked = dmark->isMarked(current) ;
// else
// ismarked = cmark->isMarked(current) ;
//
// while(current != NIL && (ismarked || m.isBoundaryMarked(current) || !m_good(current)))
// {
// m.next(current) ;
// if(current == m.end())
// current = NIL ;
// else
// {
// if(dmark)
// ismarked = dmark->isMarked(current) ;
// else
// ismarked = cmark->isMarked(current) ;
// }
// }
//
// if(current != NIL)
// {
// if(dmark)
// dmark->markOrbit(m_orbit, current) ;
// else
// cmark->mark(current) ;
// }
// }
// return current ;
// }
//
// void mark(Dart d)
// {
// if(dmark)
// dmark->markOrbit(m_orbit, d) ;
// else
// cmark->mark(d) ;
// }
//} ;
//
//template <typename MAP>
//class TraversorV : public TraversorCell<MAP>
//{
//public:
// TraversorV(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VERTEX, good, thread)
// {}
//};
//
//template <typename MAP>
//class TraversorE : public TraversorCell<MAP>
//{
//public:
// TraversorE(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, EDGE, good, thread)
// {}
//};
//
////template <typename MAP>
////class TraversorOF : public TraversorCell<MAP>
////{
////public:
//// TraversorOF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, ORIENTED_FACE, good, thread)
//// {}
////};
//
//
//template <typename MAP>
//class TraversorF : public TraversorCell<MAP>
//{
//public:
// TraversorF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, FACE, good, thread)
// {}
//};
//
//template <typename MAP>
//class TraversorW : public TraversorCell<MAP>
//{
//public:
// TraversorW(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VOLUME, good, thread)
// {}
//};
//
//
//
//template <typename MAP>
//class TraversorDartsOfOrbit
//{
//private:
// std::vector<Dart>::iterator m_current;
// std::vector<Dart> m_vd;
//
//public:
// TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0)
// {
// m_vd.reserve(16);
// FunctorStoreNotBoundary<MAP> fs(map,m_vd);
// map.foreach_dart_of_orbit(orbit, d, fs, thread);
// m_vd.push_back(NIL);
// m_current=m_vd.begin();
// }
//
// Dart begin()
// {
// m_current=m_vd.begin();
// return *m_current;
// }
//
// Dart end(){ return NIL;}
//
// Dart next()
// {
// if (*m_current != NIL)
// m_current++;
// return *m_current;
// }
//} ;
template <typename MAP>
class TraversorCell
......@@ -275,13 +92,12 @@ public:
};
template <typename MAP>
class TraversorDartsOfOrbit
{
private:
std::vector<Dart>::iterator m_current;
std::vector<Dart> m_vd;
std::vector<Dart>::iterator m_current ;
std::vector<Dart> m_vd ;
public:
TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0) ;
......
......@@ -27,7 +27,7 @@ namespace CGoGN
template <typename MAP>
TraversorCell<MAP>::TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) :
m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
{
if(!forceDartMarker && map.isOrbitEmbedded(m_orbit))
cmark = new CellMarker(map, m_orbit, thread) ;
......@@ -73,10 +73,11 @@ Dart TraversorCell<MAP>::begin()
return current ;
}
template <typename MAP>
Dart TraversorCell<MAP>::end() { return NIL ; }
Dart TraversorCell<MAP>::end()
{
return NIL ;
}
template <typename MAP>
Dart TraversorCell<MAP>::next()
......@@ -124,12 +125,11 @@ void TraversorCell<MAP>::mark(Dart d)
}
template <typename MAP>
TraversorDartsOfOrbit<MAP>::TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread)
{
m_vd.reserve(16);
FunctorStoreNotBoundary<MAP> fs(map,m_vd);
FunctorStoreNotBoundary<MAP> fs(map, m_vd);
map.foreach_dart_of_orbit(orbit, d, fs, thread);
m_vd.push_back(NIL);
}
......@@ -137,7 +137,7 @@ TraversorDartsOfOrbit<MAP>::TraversorDartsOfOrbit(MAP& map, unsigned int orbit,
template <typename MAP>
Dart TraversorDartsOfOrbit<MAP>::begin()
{
m_current=m_vd.begin();
m_current = m_vd.begin();
return *m_current;
}
......@@ -155,5 +155,4 @@ Dart TraversorDartsOfOrbit<MAP>::next()
return *m_current;
}
}
} // namespace CGoGN
......@@ -69,9 +69,21 @@ inline void Map1::update_topo_shortcuts()
inline Dart Map1::newDart()
{
Dart d = GenericMap::newDart() ;
unsigned int d_index = dartIndex(d);
unsigned int d_index = dartIndex(d) ;
(*m_phi1)[d_index] = d ;
(*m_phi_1)[d_index] = d ;
if(m_isMultiRes)
{
pushLevel() ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
{
setCurrentLevel(i) ;
unsigned int d_index = dartIndex(d) ;
(*m_phi1)[d_index] = d ;
(*m_phi_1)[d_index] = d ;
}
popLevel() ;
}
return d ;
}
......
......@@ -67,14 +67,22 @@ inline void Map2::update_topo_shortcuts()
inline Dart Map2::newDart()
{
Dart d = Map1::newDart() ;
// unsigned int d_index = dartIndex(d);
(*m_phi2)[dartIndex(d)] = d ;
if(m_isMultiRes)
{
pushLevel() ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
{
setCurrentLevel(i) ;
(*m_phi2)[dartIndex(d)] = d ;
}
popLevel() ;
}
return d ;
}
inline Dart Map2::phi2(Dart d)
{
// unsigned int d_index = dartIndex(d);
return (*m_phi2)[dartIndex(d)] ;
}
......@@ -139,8 +147,7 @@ inline void Map2::phi2unsew(Dart d)
unsigned int d_index = dartIndex(d);
Dart e = (*m_phi2)[d_index] ;
(*m_phi2)[d_index] = d ;
unsigned int e_index = dartIndex(e);
(*m_phi2)[e_index] = e ;
(*m_phi2)[dartIndex(e)] = e ;
}
/*! @name Topological Queries
......
......@@ -65,8 +65,17 @@ inline void Map3::update_topo_shortcuts()
inline Dart Map3::newDart()
{
Dart d = Map2::newDart() ;
unsigned int d_index = dartIndex(d);
(*m_phi3)[d_index] = d ;
(*m_phi3)[dartIndex(d)] = d ;
if(m_isMultiRes)
{
pushLevel() ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
{
setCurrentLevel(i) ;
(*m_phi3)[dartIndex(d)] = d ;
}
popLevel() ;
}
return d ;
}
......
......@@ -170,15 +170,27 @@ void GenericMap::clear(bool removeAttrib)
void GenericMap::addLevel()
{
unsigned int level = m_mrDarts.size() ;
unsigned int newLevel = m_mrDarts.size() ;
std::stringstream ss ;
ss << "MRdart_"<< level ;
ss << "MRdart_"<< newLevel ;
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()) ;
m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[newLevel - 1]->getIndex()) ;
// duplicate all the darts in the new level
for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
{
unsigned int oldi = amvMR->operator[](i) ;
unsigned int newi = m_attribs[DART].insertLine() ;
m_attribs[DART].copyLine(newi, oldi) ;
amvMR->operator[](i) = newi ;
for(unsigned int t = 0; t < m_nbThreads; ++t)
m_markTables[DART][t]->operator[](newi).clear() ;
}
}
/****************************************
......@@ -206,7 +218,7 @@ void GenericMap::setDartEmbedding(unsigned int orbit, Dart d, unsigned int emb)
if (emb != EMBNULL)
m_attribs[orbit].refLine(emb);
// affect the embedding to the dart
(*m_embeddings[orbit])[d.index] = emb ;
(*m_embeddings[orbit])[dartIndex(d)] = emb ;
}
/****************************************
......@@ -785,17 +797,17 @@ void GenericMap::viewAttributesTables()
void GenericMap::boundaryMark(Dart d)
{
m_markTables[DART][0]->operator[](d.index).setMark(m_boundaryMarker);
m_markTables[DART][0]->operator[](dartIndex(d)).setMark(m_boundaryMarker);
}
void GenericMap::boundaryUnmark(Dart d)
{
m_markTables[DART][0]->operator[](d.index).unsetMark(m_boundaryMarker);
m_markTables[DART][0]->operator[](dartIndex(d)).unsetMark(m_boundaryMarker);
}
bool GenericMap::isBoundaryMarked(Dart d)
{
return m_markTables[DART][0]->operator[](d.index).testMark(m_boundaryMarker);
return m_markTables[DART][0]->operator[](dartIndex(d)).testMark(m_boundaryMarker);
}
void GenericMap::boundaryMarkOrbit(unsigned int orbit, Dart d)
......
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#include "Topology/map/map2MR/map2MR_Primal.h"
namespace CGoGN
{
Map2MR_Primal::Map2MR_Primal()
{
initMR() ;
}
/***************************************************
* CELLS INFORMATION *
***************************************************/
unsigned int Map2MR_Primal::vertexInsertionLevel(Dart d)
{
assert(getDartLevel(d) <= getCurrentLevel() || !"vertexInsertionLevel : called with a dart introduced after current level") ;
return getDartLevel(d) ;
}
unsigned int Map2MR_Primal::edgeLevel(Dart d)
{
assert(getDartLevel(d) <= getCurrentLevel() || !"edgeLevel : called with a dart introduced after current level") ;
unsigned int ld = getDartLevel(d) ;
unsigned int ldd = getDartLevel(phi2(d)) ; // the level of an edge is the maximum of the
return ld > ldd ? ld : ldd ; // insertion levels of its two darts
}
unsigned int Map2MR_Primal::faceLevel(Dart d)
{
assert(getDartLevel(d) <= getCurrentLevel() || !"faceLevel : called with a dart introduced after current level") ;
if(getCurrentLevel() == 0)
return 0 ;
Dart it = d ;
unsigned int min1 = getDartLevel(it) ; // the level of a face is the second minimum of the
it = phi1(it) ;
unsigned int min2 = getDartLevel(it) ; // insertion levels of its darts
if(min2 < min1)
{
unsigned int tmp = min1 ;
min1 = min2 ;
min2 = tmp ;
}
it = phi1(it) ;
while(it != d)
{
unsigned int dl = getDartLevel(it) ;
if(dl < min2)
{
if(dl < min1)
{
min2 = min1 ;
min1 = dl ;
}
else
min2 = dl ;
}
it = phi1(it) ;
}
return min2 ;
}
Dart Map2MR_Primal::faceOrigin(Dart d)
{
assert(getDartLevel(d) <= getCurrentLevel() || !"faceOrigin : called with a dart introduced after current level") ;
pushLevel() ;
Dart p = d ;
unsigned int pLevel = getDartLevel(p) ;
while(pLevel > 0)
{
p = faceOldestDart(p) ;
pLevel = getDartLevel(p) ;
setCurrentLevel(pLevel) ;
}
popLevel() ;
return p ;
}
Dart Map2MR_Primal::faceOldestDart(Dart d)
{
assert(getDartLevel(d) <= getCurrentLevel() || !"faceOldestDart : called with a dart introduced after current level") ;
Dart it = d ;
Dart oldest = it ;
unsigned int l_old = getDartLevel(oldest) ;
do
{
unsigned int l = getDartLevel(it) ;
if(l == 0)
return it ;
if(l < l_old)
{
oldest = it ;
l_old = l ;
}
it = phi1(it) ;
} while(it != d) ;
return oldest ;
}
bool Map2MR_Primal::edgeIsSubdivided(Dart d)
{
assert(getDartLevel(d) <= getCurrentLevel() || !"edgeIsSubdivided : called with a dart introduced after current level") ;
if(getCurrentLevel() == getMaxLevel())
return false ;
Dart d2 = phi2(d) ;
setCurrentLevel(getCurrentLevel() + 1) ;
Dart d2_l = phi2(d) ;
setCurrentLevel(getCurrentLevel() - 1) ;
if(d2 != d2_l)
return true ;
else
return false ;
}
bool Map2MR_Primal::edgeCanBeCoarsened(Dart d)
{
assert(getDartLevel(d) <= getCurrentLevel() || !"edgeCanBeCoarsened : called with a dart introduced after current level") ;
if(edgeIsSubdivided(d))
{
bool subdOnce = true ;
bool degree2 = false ;
Dart d2 = phi2(d) ;
setCurrentLevel(getCurrentLevel() + 1) ;
if(vertexDegree(phi1(d)) == 2)
{
degree2 = true ;