Commit 0ee31044 authored by untereiner's avatar untereiner
Browse files

import des fichiers de l'iness + IHM3

parent 7dcd9b65
...@@ -37,11 +37,8 @@ namespace Algo ...@@ -37,11 +37,8 @@ namespace Algo
namespace IHM namespace IHM
{ {
template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3<Map3> class ImplicitHierarchicalMap3 : public EmbeddedMap3<Map3>
{ {
template<typename T> friend class AttributeHandler_IHM ;
public: public:
unsigned int m_curLevel ; unsigned int m_curLevel ;
...@@ -53,7 +50,7 @@ public: ...@@ -53,7 +50,7 @@ public:
AttributeHandler<unsigned int> m_edgeId ; AttributeHandler<unsigned int> m_edgeId ;
AttributeHandler<unsigned int> m_faceId ; AttributeHandler<unsigned int> m_faceId ;
AttribMultiVect<unsigned int>* m_nextLevelCell[NB_ORBITS] ; AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;
public: public:
ImplicitHierarchicalMap3() ; ImplicitHierarchicalMap3() ;
...@@ -62,13 +59,6 @@ public: ...@@ -62,13 +59,6 @@ public:
void init() ; void init() ;
/***************************************************
* ATTRIBUTES MANAGEMENT *
***************************************************/
template <typename T>
AttributeHandler_IHM<T> addAttribute(unsigned int orbit, const std::string& nameAttr) ;
/*************************************************** /***************************************************
* MAP TRAVERSAL * * MAP TRAVERSAL *
***************************************************/ ***************************************************/
...@@ -79,12 +69,12 @@ public: ...@@ -79,12 +69,12 @@ public:
Dart phi_1(Dart d) ; Dart phi_1(Dart d) ;
Dart phi2(Dart d) ;
private: private:
Dart phi2bis(Dart d) ; Dart phi2bis(Dart d) ;
public: public:
Dart phi2(Dart d) ;
Dart phi3(Dart d); Dart phi3(Dart d);
Dart alpha0(Dart d); Dart alpha0(Dart d);
...@@ -141,13 +131,24 @@ public: ...@@ -141,13 +131,24 @@ public:
*/ */
unsigned int getNewEdgeId() ; unsigned int getNewEdgeId() ;
/**
* Return the id of the edge of d
*/
unsigned int getEdgeId(Dart 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); void setEdgeId(Dart d, unsigned int i, unsigned int orbit);
/*************************************************** /***************************************************
* FACE ID MANAGEMENT * * FACE ID MANAGEMENT *
***************************************************/ ***************************************************/
/**
* Give a new unique id to all the faces of the map
*/
void initFaceId() ; void initFaceId() ;
/** /**
...@@ -155,10 +156,19 @@ public: ...@@ -155,10 +156,19 @@ public:
*/ */
unsigned int getNewFaceId() ; unsigned int getNewFaceId() ;
/**
* Return the id of the face of d
*/
unsigned int getFaceId(Dart 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(Dart d, unsigned int i, unsigned int orbit);
void setFaceId(unsigned int orbit, Dart d);
/*************************************************** /***************************************************
* CELLS INFORMATION * * CELLS INFORMATION *
***************************************************/ ***************************************************/
...@@ -174,22 +184,22 @@ public: ...@@ -174,22 +184,22 @@ public:
unsigned int edgeLevel(Dart d) ; unsigned int edgeLevel(Dart d) ;
/** /**
* * Return the level of the face of d in the current level map
*/ */
unsigned int faceLevel(Dart d); unsigned int faceLevel(Dart d);
/** /**
* * Return the level of the volume of d in the current level map
*/ */
unsigned int volumeLevel(Dart d); unsigned int volumeLevel(Dart d);
/** /**
* * Return the oldest dart of the face of d in the current level map
*/ */
Dart faceOldestDart(Dart d); Dart faceOldestDart(Dart d);
/** /**
* * Return the oldest dart of the volume of d in the current level map
*/ */
Dart volumeOldestDart(Dart d); Dart volumeOldestDart(Dart d);
...@@ -200,52 +210,18 @@ public: ...@@ -200,52 +210,18 @@ public:
bool edgeIsSubdivided(Dart d) ; 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) ; 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); 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 } //namespace IHM
......
...@@ -31,32 +31,6 @@ namespace Algo ...@@ -31,32 +31,6 @@ namespace Algo
namespace IHM 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 * * MAP TRAVERSAL *
***************************************************/ ***************************************************/
...@@ -84,7 +58,7 @@ inline Dart ImplicitHierarchicalMap3::phi1(Dart d) ...@@ -84,7 +58,7 @@ inline Dart ImplicitHierarchicalMap3::phi1(Dart d)
finished = true ; finished = true ;
else else
{ {
if(m_edgeId[it] != edgeId) while(m_edgeId[it] != edgeId)
it = Map3::phi1(phi2bis(it)); it = Map3::phi1(phi2bis(it));
} }
} while(!finished) ; } while(!finished) ;
...@@ -106,7 +80,7 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d) ...@@ -106,7 +80,7 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
else else
{ {
it = Map3::phi_1(it) ; it = Map3::phi_1(it) ;
if(m_edgeId[it] != edgeId) while(m_edgeId[it] != edgeId)
it = Map3::phi_1(phi2bis(it)) ; it = Map3::phi_1(phi2bis(it)) ;
} }
} while(!finished) ; } while(!finished) ;
...@@ -117,20 +91,17 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d) ...@@ -117,20 +91,17 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
//TODO A verifier si besoin d'assertion //TODO A verifier si besoin d'assertion
inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d) 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]; unsigned int faceId = m_faceId[d];
Dart it = d; Dart it = d;
it = Map3::phi2(it) ; it = Map3::phi2(it) ;
if(m_faceId[it] == faceId) if(m_faceId[it] == faceId)
return it; return it;
else else
{ {
while(m_faceId[it] != faceId) while(m_faceId[it] != faceId)
it = Map3::alpha_2(it); it = Map3::phi2(Map3::phi3(it));
return it; return it;
} }
...@@ -160,48 +131,52 @@ inline Dart ImplicitHierarchicalMap3::alpha0(Dart d) ...@@ -160,48 +131,52 @@ inline Dart ImplicitHierarchicalMap3::alpha0(Dart d)
inline Dart ImplicitHierarchicalMap3::alpha1(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) ; return Map3::alpha1(d) ;
} }
inline Dart ImplicitHierarchicalMap3::alpha2(Dart d) inline Dart ImplicitHierarchicalMap3::alpha2(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") ;
//
Dart e = phi2(d); // Dart e = phi2(d);
Dart f = phi3(e); // Dart f = phi3(e);
//
if (f != e) // if (f != e)
return f; // return f;
//
f = d; // f = d;
e = phi3(f); // e = phi3(f);
while (e != f) // while (e != f)
{ // {
f = phi2(e); // f = phi2(e);
e = phi3(f); // e = phi3(f);
} // }
return f; // return f;
return Map3::alpha2(d);
} }
inline Dart ImplicitHierarchicalMap3::alpha_2(Dart d) inline Dart ImplicitHierarchicalMap3::alpha_2(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") ;
//
Dart e = phi3(d); // Dart e = phi3(d);
//
if (e != d) // if (e != d)
return phi2(e); // return phi2(e);
//
e = d; // e = d;
Dart f = phi2(d); // Dart f = phi2(d);
while (phi3(f) != f) // while (phi3(f) != f)
{ // {
e = phi3(f); // e = phi3(f);
f = phi2(e); // f = phi2(e);
} // }
return e; // return e;
return Map3::alpha_2(d);
} }
inline Dart ImplicitHierarchicalMap3::begin() inline Dart ImplicitHierarchicalMap3::begin()
...@@ -222,7 +197,7 @@ inline void ImplicitHierarchicalMap3::next(Dart& d) ...@@ -222,7 +197,7 @@ inline void ImplicitHierarchicalMap3::next(Dart& d)
do do
{ {
Map3::next(d) ; 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) inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType& f)
...@@ -429,26 +404,28 @@ inline unsigned int ImplicitHierarchicalMap3::getFaceId(Dart d) ...@@ -429,26 +404,28 @@ inline unsigned int ImplicitHierarchicalMap3::getFaceId(Dart d)
return m_faceId[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 //Mise a jour de l'id de face pour les brins autour d'une arete
if(orbit == EDGE_ORBIT) if(orbit == EDGE_ORBIT)
{ {
Dart e = d; Dart e = d;
unsigned int fid;
do do
{ {
fid = getFaceId(e); m_faceId[Map3::phi1(e)] = m_faceId[e];
m_faceId[e] = fid;
m_faceId[Map3::phi2(e)] = fid;
e = Map3::alpha2(e); e = Map3::alpha2(e);
}while(e != d); }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 //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; Dart e = d;
...@@ -466,6 +443,9 @@ inline void ImplicitHierarchicalMap3::setFaceId(Dart d, unsigned int i, unsigned ...@@ -466,6 +443,9 @@ inline void ImplicitHierarchicalMap3::setFaceId(Dart d, unsigned int i, unsigned
else if(orbit == DART_ORBIT) else if(orbit == DART_ORBIT)
{ {
m_faceId[d] = i; 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) ...@@ -504,65 +484,6 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r; 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 } //namespace IHM
......
...@@ -35,14 +35,28 @@ namespace Algo ...@@ -35,14 +35,28 @@ namespace Algo
namespace IHM namespace IHM
{ {
enum SubdivideType
{
S_TRI,
S_QUAD
} ;
template <typename PFP> template <typename PFP>
void subdivideEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ; void subdivideEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ;
template <typename PFP> 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);