Commit 0ee31044 authored by untereiner's avatar untereiner

import des fichiers de l'iness + IHM3

parent 7dcd9b65
......@@ -37,11 +37,8 @@ namespace Algo
namespace IHM
{
template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3<Map3>
{
template<typename T> friend class AttributeHandler_IHM ;
public:
unsigned int m_curLevel ;
......@@ -53,7 +50,7 @@ public:
AttributeHandler<unsigned int> m_edgeId ;
AttributeHandler<unsigned int> m_faceId ;
AttribMultiVect<unsigned int>* m_nextLevelCell[NB_ORBITS] ;
AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;
public:
ImplicitHierarchicalMap3() ;
......@@ -62,13 +59,6 @@ public:
void init() ;
/***************************************************
* ATTRIBUTES MANAGEMENT *
***************************************************/
template <typename T>
AttributeHandler_IHM<T> addAttribute(unsigned int orbit, const std::string& nameAttr) ;
/***************************************************
* MAP TRAVERSAL *
***************************************************/
......@@ -79,12 +69,12 @@ public:
Dart phi_1(Dart d) ;
Dart phi2(Dart d) ;
private:
Dart phi2bis(Dart d) ;
public:
Dart phi2(Dart d) ;
Dart phi3(Dart d);
Dart alpha0(Dart d);
......@@ -141,13 +131,24 @@ public:
*/
unsigned int getNewEdgeId() ;
/**
* Return the id of the edge of d
*/
unsigned int getEdgeId(Dart d) ;
/**
* Set an edge id to all darts from an orbit of d
*/
//TODO changer l'ordre des parametres
void setEdgeId(Dart d, unsigned int i, unsigned int orbit);
/***************************************************
* FACE ID MANAGEMENT *
***************************************************/
/**
* Give a new unique id to all the faces of the map
*/
void initFaceId() ;
/**
......@@ -155,10 +156,19 @@ public:
*/
unsigned int getNewFaceId() ;
/**
* Return the id of the face of d
*/
unsigned int getFaceId(Dart d) ;
/**
* Set a face id to all darts from an orbit of d
*/
//TODO changer l'ordre des parametres
void setFaceId(Dart d, unsigned int i, unsigned int orbit);
void setFaceId(unsigned int orbit, Dart d);
/***************************************************
* CELLS INFORMATION *
***************************************************/
......@@ -174,22 +184,22 @@ public:
unsigned int edgeLevel(Dart d) ;
/**
*
* Return the level of the face of d in the current level map
*/
unsigned int faceLevel(Dart d);
/**
*
* Return the level of the volume of d in the current level map
*/
unsigned int volumeLevel(Dart d);
/**
*
* Return the oldest dart of the face of d in the current level map
*/
Dart faceOldestDart(Dart d);
/**
*
* Return the oldest dart of the volume of d in the current level map
*/
Dart volumeOldestDart(Dart d);
......@@ -200,52 +210,18 @@ public:
bool edgeIsSubdivided(Dart d) ;
/**
*
* Return true if the face of d in the current level map
* has already been subdivided to the next level
*/
bool faceIsSubdivided(Dart d) ;
/**
*
* Return true if the volume of d in the current level map
* has already been subdivided to the next level
*/
bool volumeIsSubdivided(Dart d);
} ;
template <typename T>
class AttributeHandler_IHM : public AttributeHandler<T>
{
public:
typedef T DATA_TYPE ;
AttributeHandler_IHM() : AttributeHandler<T>()
{}
AttributeHandler_IHM(GenericMap* m, unsigned int idAttr) : AttributeHandler<T>(m, idAttr)
{}
AttribMultiVect<T>* getDataVector() const
{
return AttributeHandler<T>::getDataVector() ;
}
bool isValid() const
{
return AttributeHandler<T>::isValid() ;
}
T& operator[](Dart d) ;
const T& operator[](Dart d) const ;
T& operator[](unsigned int a)
{
return AttributeHandler<T>::operator[](a) ;
}
const T& operator[](unsigned int a) const
{
return AttributeHandler<T>::operator[](a) ;
}
} ;
} //namespace IHM
......
......@@ -31,32 +31,6 @@ namespace Algo
namespace IHM
{
/***************************************************
* ATTRIBUTES MANAGEMENT *
***************************************************/
template <typename T>
AttributeHandler_IHM<T> ImplicitHierarchicalMap3::addAttribute(unsigned int orbit, const std::string& nameAttr)
{
bool addNextLevelCell = false ;
if(!isOrbitEmbedded(orbit))
addNextLevelCell = true ;
AttributeHandler<T> h = Map3::addAttribute<T>(orbit, nameAttr) ;
if(addNextLevelCell)
{
AttribContainer& cellCont = m_attribs[orbit] ;
unsigned int index = cellCont.addAttribute<unsigned int>("nextLevelCell") ;
AttribMultiVect<unsigned int>& amv = cellCont.getDataVector<unsigned int>(index) ;
m_nextLevelCell[orbit] = &amv ;
for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
amv[i] = EMBNULL ;
}
return AttributeHandler_IHM<T>(this, h.id()) ;
}
/***************************************************
* MAP TRAVERSAL *
***************************************************/
......@@ -84,7 +58,7 @@ inline Dart ImplicitHierarchicalMap3::phi1(Dart d)
finished = true ;
else
{
if(m_edgeId[it] != edgeId)
while(m_edgeId[it] != edgeId)
it = Map3::phi1(phi2bis(it));
}
} while(!finished) ;
......@@ -106,7 +80,7 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
else
{
it = Map3::phi_1(it) ;
if(m_edgeId[it] != edgeId)
while(m_edgeId[it] != edgeId)
it = Map3::phi_1(phi2bis(it)) ;
}
} while(!finished) ;
......@@ -117,20 +91,17 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
//TODO A verifier si besoin d'assertion
inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d)
{
//assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
unsigned int faceId = m_faceId[d];
Dart it = d;
it = Map3::phi2(it) ;
if(m_faceId[it] == faceId)
return it;
else
{
while(m_faceId[it] != faceId)
it = Map3::alpha_2(it);
it = Map3::phi2(Map3::phi3(it));
return it;
}
......@@ -160,48 +131,52 @@ inline Dart ImplicitHierarchicalMap3::alpha0(Dart d)
inline Dart ImplicitHierarchicalMap3::alpha1(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
return Map3::alpha1(d) ;
}
inline Dart ImplicitHierarchicalMap3::alpha2(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
Dart e = phi2(d);
Dart f = phi3(e);
if (f != e)
return f;
f = d;
e = phi3(f);
while (e != f)
{
f = phi2(e);
e = phi3(f);
}
return f;
// assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//
// Dart e = phi2(d);
// Dart f = phi3(e);
//
// if (f != e)
// return f;
//
// f = d;
// e = phi3(f);
// while (e != f)
// {
// f = phi2(e);
// e = phi3(f);
// }
// return f;
return Map3::alpha2(d);
}
inline Dart ImplicitHierarchicalMap3::alpha_2(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
Dart e = phi3(d);
if (e != d)
return phi2(e);
e = d;
Dart f = phi2(d);
while (phi3(f) != f)
{
e = phi3(f);
f = phi2(e);
}
return e;
// assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//
// Dart e = phi3(d);
//
// if (e != d)
// return phi2(e);
//
// e = d;
// Dart f = phi2(d);
// while (phi3(f) != f)
// {
// e = phi3(f);
// f = phi2(e);
// }
// return e;
return Map3::alpha_2(d);
}
inline Dart ImplicitHierarchicalMap3::begin()
......@@ -222,7 +197,7 @@ inline void ImplicitHierarchicalMap3::next(Dart& d)
do
{
Map3::next(d) ;
} while(m_dartLevel[d] > m_curLevel && d != Map3::end()) ;
} while(d != Map3::end() && m_dartLevel[d] > m_curLevel) ;
}
inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType& f)
......@@ -429,26 +404,28 @@ inline unsigned int ImplicitHierarchicalMap3::getFaceId(Dart d)
return m_faceId[d] ;
}
inline void ImplicitHierarchicalMap3::setFaceId(Dart d, unsigned int i, unsigned int orbit)
inline void ImplicitHierarchicalMap3::setFaceId(unsigned int orbit, Dart d)
{
//Mise a jour de l'id de face pour les brins autour d'une arete
if(orbit == EDGE_ORBIT)
{
Dart e = d;
unsigned int fid;
do
{
fid = getFaceId(e);
m_faceId[e] = fid;
m_faceId[Map3::phi2(e)] = fid;
m_faceId[Map3::phi1(e)] = m_faceId[e];
e = Map3::alpha2(e);
}while(e != d);
}
}
inline void ImplicitHierarchicalMap3::setFaceId(Dart d, unsigned int i, unsigned int orbit)
{
//Mise a jour de l'id de face pour les brins autour de la face
else if(orbit == FACE_ORBIT)
if(orbit == FACE_ORBIT)
{
Dart e = d;
......@@ -466,6 +443,9 @@ inline void ImplicitHierarchicalMap3::setFaceId(Dart d, unsigned int i, unsigned
else if(orbit == DART_ORBIT)
{
m_faceId[d] = i;
if(Map3::phi3(d) != d)
m_faceId[Map3::phi3(d)] = i;
}
}
......@@ -504,65 +484,6 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r;
}
template <typename T>
T& AttributeHandler_IHM<T>::operator[](Dart d)
{
ImplicitHierarchicalMap3* m = reinterpret_cast<ImplicitHierarchicalMap3*>(this->m_map) ;
assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ;
assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ;
unsigned int orbit = AttribContainer::orbitAttr(this->m_id) ;
unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
unsigned int index = m->getEmbedding(d, orbit) ;
if(index == EMBNULL && nbSteps == 0)
{
index = m->embedNewCell(orbit, d) ;
m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ;
return this->m_attrib->operator[](index);
}
AttribContainer& cont = m->getAttributeContainer(orbit) ;
unsigned int step = 0 ;
while(step < nbSteps)
{
step++ ;
unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ;
if (nextIdx == EMBNULL)
{
nextIdx = m->newCell(orbit) ;
m->copyCell(orbit, nextIdx, index) ;
m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ;
m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ;
cont.refLine(index) ;
}
index = nextIdx ;
}
return this->m_attrib->operator[](index);
}
//OK
template <typename T>
const T& AttributeHandler_IHM<T>::operator[](Dart d) const
{
ImplicitHierarchicalMap3* m = reinterpret_cast<ImplicitHierarchicalMap3*>(this->m_map) ;
assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ;
assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ;
unsigned int orbit = AttribContainer::orbitAttr(this->m_id) ;
unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
unsigned int index = m->getEmbedding(d, orbit) ;
unsigned int step = 0 ;
while(step < nbSteps)
{
step++ ;
unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ;
if(next != EMBNULL) index = next ;
else break ;
}
return this->m_attrib->operator[](index);
}
} //namespace IHM
......
......@@ -35,14 +35,28 @@ namespace Algo
namespace IHM
{
enum SubdivideType
{
S_TRI,
S_QUAD
} ;
template <typename PFP>
void subdivideEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ;
template <typename PFP>
Dart subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_QUAD);
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_QUAD);
template <typename PFP>
Dart subdivideFaceTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
void subdivideVolumeTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void catmullClarck(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
......
This diff is collapsed.
......@@ -122,7 +122,7 @@ void swap2To2(typename PFP::MAP& the_map, Dart d, typename PFP::TVEC3& positions
Dart e = d;
do
{
the_map.unsewFace(e);
//the_map.unsewFace(e);
e = the_map.phi1(e);
}
while (e != d);
......@@ -175,20 +175,20 @@ void swap3To2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positions)
Dart fi = map.phi2(en1);
//Decouture de la premiere face
map.unsewFace(map.phi2(en1));
map.unsewFace(map.phi2(en2));
//Decouture de la seconde face
en1 = map.phi1(map.phi2(en1));
en2 = map.phi_1(map.phi2(en2));
map.unsewFace(map.phi2(en1));
map.unsewFace(map.phi2(en2));
//Decouture de la troisieme face
en1 = map.phi1(map.phi2(en1));
en2 = map.phi_1(map.phi2(en2));
map.unsewFace(map.phi2(en1));
map.unsewFace(map.phi2(en2));
// map.unsewFace(map.phi2(en1));
// map.unsewFace(map.phi2(en2));
//
// //Decouture de la seconde face
// en1 = map.phi1(map.phi2(en1));
// en2 = map.phi_1(map.phi2(en2));
// map.unsewFace(map.phi2(en1));
// map.unsewFace(map.phi2(en2));
//
// //Decouture de la troisieme face
// en1 = map.phi1(map.phi2(en1));
// en2 = map.phi_1(map.phi2(en2));
// map.unsewFace(map.phi2(en1));
// map.unsewFace(map.phi2(en2));
//Faces interieurs
Dart fi2 = map.phi2(map.phi1(fi));
......
......@@ -147,13 +147,13 @@ public:
/*! @param d dart from the edge
* @param e dart from the face
*/
virtual void sewFace(Dart d, Dart e);
//virtual void sewFace(Dart d, Dart e);
//! Unsew a face d from an edge
/*! \pre Dart d is a dart from the face to unsew
* @param d the edge to unlink
*/
virtual void unsewFace(Dart d);
//virtual void unsewFace(Dart d);
//!
/*! Flip the edge of d (rotation in phi1 order)
......
......@@ -24,6 +24,7 @@
#include "Algo/ImplicitHierarchicalMesh/ihm3.h"
#include <math.h>
#include <limits>
namespace CGoGN
{
......@@ -34,18 +35,16 @@ namespace Algo
namespace IHM
{
//OK
ImplicitHierarchicalMap3::ImplicitHierarchicalMap3() : m_curLevel(0), m_maxLevel(0), m_edgeIdCount(0), m_faceIdCount(0)
{
m_dartLevel = Map3::addAttribute<unsigned int>(DART_ORBIT, "dartLevel") ;
m_edgeId = Map3::addAttribute<unsigned int>(DART_ORBIT, "edgeId") ;
m_faceId = Map3::addAttribute<unsigned int>(DART_ORBIT, "faceId") ;
m_edgeId = Map3::addAttribute<unsigned int>(DART_ORBIT, "edgeId") ;
for(unsigned int i = 0; i < NB_ORBITS; ++i)
m_nextLevelCell[i] = NULL ;
}
//OK
ImplicitHierarchicalMap3::~ImplicitHierarchicalMap3()
{
Map3::removeAttribute(m_edgeId) ;
......@@ -53,7 +52,6 @@ ImplicitHierarchicalMap3::~ImplicitHierarchicalMap3()
Map3::removeAttribute(m_dartLevel) ;
}
//OK
void ImplicitHierarchicalMap3::init()
{
initEdgeId() ;
......@@ -63,17 +61,15 @@ void ImplicitHierarchicalMap3::init()
{
if(m_nextLevelCell[orbit] != NULL)
{
AttribContainer& cellCont = m_attribs[orbit] ;
AttributeContainer& cellCont = m_attribs[orbit] ;
for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
m_nextLevelCell[orbit]->operator[](i) = EMBNULL ;
}
}
}
//OK
void ImplicitHierarchicalMap3::initEdgeId()
{
m_edgeIdCount = 0 ;
DartMarker edgeMark(*this) ;
for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
{
......@@ -96,10 +92,8 @@ void ImplicitHierarchicalMap3::initEdgeId()
}
}
//OK
void ImplicitHierarchicalMap3::initFaceId()
{
m_faceIdCount = 0 ;
DartMarker faceMark(*this) ;
for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
{
......@@ -111,10 +105,11 @@ void ImplicitHierarchicalMap3::initFaceId()
m_faceId[e] = m_faceIdCount ;
faceMark.mark(e);
if(Map3::phi3(e) != e)
Dart e3 = Map3::phi3(e);
if(e3 != e)
{
m_faceId[Map3::phi3(e)] = m_faceIdCount ;
faceMark.mark(Map3::phi3(e));
m_faceId[e3] = m_faceIdCount ;
faceMark.mark(e3);
}
e = Map3::phi1(e);
......@@ -125,7 +120,6 @@ void ImplicitHierarchicalMap3::initFaceId()
}
}
//OK
unsigned int ImplicitHierarchicalMap3::faceLevel(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
......@@ -135,14 +129,19 @@ unsigned int ImplicitHierarchicalMap3::faceLevel(Dart d)
Dart it = d ;
Dart old = it ;
unsigned int l_old = m_dartLevel[old] ;
unsigned int fLevel = edgeLevel(it) ;
do
{
it = phi1(it) ;
if(m_dartLevel[it] < m_dartLevel[old]) // in a first time, the level of a face
old = it ; // is the minimum of the levels
unsigned int l = edgeLevel(it) ; // of its edges
fLevel = l < fLevel ? l : fLevel ;
unsigned int dl = m_dartLevel[it] ;
if(dl < l_old) // compute the oldest dart of the face
{ // in the same time
old = it ;
l_old = dl ;
} // in a first time, the level of a face
unsigned int l = edgeLevel(it) ; // is the minimum of the levels
fLevel = l < fLevel ? l : fLevel ; // of its edges
} while(it != d) ;
unsigned int cur = m_curLevel ;
......@@ -150,10 +149,10 @@ unsigned int ImplicitHierarchicalMap3::faceLevel(Dart d)
unsigned int nbSubd = 0 ;
it = old ;
unsigned int eId = m_edgeId[old] ; // the particular case of a face
do // with all neighboring faces regularly subdivided
{ // but not the face itself
++nbSubd ; // is treated here
unsigned int eId = m_edgeId[old] ; // the particular case of a face
do // with all neighboring faces regularly subdivided
{ // but not the face itself
++nbSubd ; // is treated here
it = phi1(it) ;
} while(m_edgeId[it] == eId) ;
......@@ -166,10 +165,42 @@ unsigned int ImplicitHierarchicalMap3::faceLevel(Dart d)
m_curLevel = cur ;
return fLevel ;
}
// Dart it = d ;
// Dart old = it ;
// unsigned int fLevel = edgeLevel(it) ;
// do
// {
// it = phi1(it) ;
// if(m_dartLevel[it] < m_dartLevel[old]) // in a first time, the level of a face
// old = it ; // is the minimum of the levels
// unsigned int l = edgeLevel(it) ; // of its edges
// fLevel = l < fLevel ? l : fLevel ;
// } while(it != d) ;
//
// unsigned int cur = m_curLevel ;
// m_curLevel = fLevel ;
//
// unsigned int nbSubd = 0 ;
// it = old ;
// unsigned int eId = m_edgeId[old] ; // the particular case of a face
// do // with all neighboring faces regularly subdivided
// { // but not the face itself
// ++nbSubd ; // is treated here
// it = phi1(it) ;
// } while(m_edgeId[it] == eId) ;
//
// while(nbSubd > 1)
// {
// nbSubd /= 2 ;
// --fLevel ;
// }
//
// m_curLevel = cur ;
//
// return fLevel ;