Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit 324560fb authored by untereiner's avatar untereiner
Browse files

modifs dans map3 et ihm3

parent 92875e5f
......@@ -36,11 +36,11 @@ namespace Algo
namespace IHM
{
template<typename T> class AttributeHandler_IHM ;
//template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3
{
template<typename T> friend class AttributeHandler_IHM ;
//template<typename T> friend class AttributeHandler_IHM ;
public:
unsigned int m_curLevel ;
......@@ -65,11 +65,11 @@ public:
* ATTRIBUTES MANAGEMENT *
***************************************************/
template <typename T>
AttributeHandler_IHM<T> addAttribute(unsigned int orbit, const std::string& nameAttr) ;
//template <typename T>
//AttributeHandler_IHM<T> addAttribute(unsigned int orbit, const std::string& nameAttr) ;
template <typename T>
AttributeHandler_IHM<T> getAttribute(unsigned int orbit, const std::string& nameAttr) ;
//template <typename T>
//AttributeHandler_IHM<T> getAttribute(unsigned int orbit, const std::string& nameAttr) ;
/***************************************************
......@@ -117,15 +117,6 @@ public:
virtual bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0) ;
/****************************************************
* EMBEDDED FUNCTIONS *
****************************************************/
// virtual void cutEdge(Dart d);
// virtual void splitFace(Dart d, Dart e);
// virtual void sewVolumes(Dart d, Dart e);
/***************************************************
* LEVELS MANAGEMENT *
***************************************************/
......@@ -278,42 +269,42 @@ public:
bool coarsenNeighborhoodLevelDiffersByOne(Dart d);
} ;
template <typename T>
class AttributeHandler_IHM : public AttributeHandler<T>
{
public:
typedef T DATA_TYPE ;
AttributeHandler_IHM() : AttributeHandler<T>()
{}
AttributeHandler_IHM(GenericMap* m, AttributeMultiVector<T>* amv) : AttributeHandler<T>(m, amv)
{}
AttributeMultiVector<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) ;
}
} ;
//template <typename T>
//class AttributeHandler_IHM : public AttributeHandler<T>
//{
//public:
// typedef T DATA_TYPE ;
//
// AttributeHandler_IHM() : AttributeHandler<T>()
// {}
//
// AttributeHandler_IHM(GenericMap* m, AttributeMultiVector<T>* amv) : AttributeHandler<T>(m, amv)
// {}
//
// AttributeMultiVector<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,37 +31,37 @@ 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)
{
AttributeContainer& cellCont = m_attribs[orbit] ;
AttributeMultiVector<unsigned int>* amv = cellCont.addAttribute<unsigned int>("nextLevelCell") ;
m_nextLevelCell[orbit] = amv ;
for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
amv->operator[](i) = EMBNULL ;
}
return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
}
template <typename T>
AttributeHandler_IHM<T> ImplicitHierarchicalMap3::getAttribute(unsigned int orbit, const std::string& nameAttr)
{
AttributeHandler<T> h = Map2::getAttribute<T>(orbit, nameAttr) ;
return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
}
///***************************************************
// * 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)
// {
// AttributeContainer& cellCont = m_attribs[orbit] ;
// AttributeMultiVector<unsigned int>* amv = cellCont.addAttribute<unsigned int>("nextLevelCell") ;
// m_nextLevelCell[orbit] = amv ;
// for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
// amv->operator[](i) = EMBNULL ;
// }
//
// return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
//}
//
//template <typename T>
//AttributeHandler_IHM<T> ImplicitHierarchicalMap3::getAttribute(unsigned int orbit, const std::string& nameAttr)
//{
// AttributeHandler<T> h = Map2::getAttribute<T>(orbit, nameAttr) ;
// return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
//}
/***************************************************
* MAP TRAVERSAL *
......@@ -363,66 +363,6 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_cc(Dart d, FunctorType& f,
return foreach_dart_of_oriented_volume(d, f) ;
}
/**************************************************
* EMBEDDED FUNCTIONS *
**************************************************/
//void ImplicitHierarchicalMap3::cutEdge(Dart d)
//{
// Dart dd = phi2(d) ;
// EmbeddedMap3::cutEdge(d);
//
// //
// //mise a jour de l'id d'arrete sur chaque moitie d'arete
// //
//
// //
// //mise a jour de l'id de face sur chaque brin de chaque moitie d'arete
// //
//
//}
//
//void ImplicitHierarchicalMap3::splitFace(Dart d, Dart e)
//{
// //
// //Verification que les brins precedents ceux que l'on split n'ont pas le meme id
// //
// if(m_edgeId[d] == m_edgeId[Map3::phi_1(d)])
// {
// unsigned int eId = getNewEdgeId() ;
//
// Dart e = d;
// do
// {
// m_edgeId[e] = eId; //cas ou l'arete n'est pas du tout plonge
// m_edgeId[Map3::phi2(e)] = eId;
//
// e = Map3::alpha2(e);
// } while(e != d);
// }
//
// EmbeddedMap3<Map3>::splitFace(d,e);
//
// //
// //creation d'un id d'arete sur la nouvelle arete
// //
//
// unsigned int eId = getNewEdgeId() ;
// Dart a =Map3:: phi_1(d);
//
// do
// {
// m_edgeId[a] = eId;
// m_edgeId[Map3::phi2(a)] = eId;
//
// a = Map3::alpha2(a);
// } while(a != Map3::phi_1(d));
//
//}
//
//void ImplicitHierarchicalMap3::sewVolumes(Dart d, Dart e)
//{
//
//}
/***************************************************
* LEVELS MANAGEMENT *
......@@ -583,67 +523,67 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r;
}
/***************************************************
* ATTRIBUTE HANDLER *
***************************************************/
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 = this->getOrbit() ;
unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
unsigned int index = m->getEmbedding(orbit, d) ;
if(index == EMBNULL)
{
index = m->embedNewCell(orbit, d) ;
m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ;
}
AttributeContainer& 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);
}
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 = this->getOrbit() ;
unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
unsigned int index = m->getEmbedding(orbit, d) ;
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);
}
///***************************************************
// * ATTRIBUTE HANDLER *
// ***************************************************/
//
//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 = this->getOrbit() ;
// unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
// unsigned int index = m->getEmbedding(orbit, d) ;
//
// if(index == EMBNULL)
// {
// index = m->embedNewCell(orbit, d) ;
// m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ;
// }
//
// AttributeContainer& 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);
//}
//
//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 = this->getOrbit() ;
// unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
// unsigned int index = m->getEmbedding(orbit, d) ;
//
// 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
......
......@@ -141,7 +141,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
id = map.getNewEdgeId() ;
map.setEdgeId(ne2, id, EDGE) ;
position[map.phi2(ne)] = p ;
position[map.phi1(ne)] = p ;
dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ;
while(dd != ne)
......@@ -170,6 +170,202 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
map.setCurrentLevel(cur) ;
}
template <typename PFP>
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.volumeIsSubdivided(d) || !"Trying to subdivide an already subdivided volume") ;
unsigned int vLevel = map.volumeLevel(d);
Dart old = map.volumeOldestDart(d);
unsigned int cur = map.getCurrentLevel();
map.setCurrentLevel(vLevel);
/*
* au niveau du volume courant i
* stockage d'un brin de chaque face de celui-ci
* avec calcul du centroid
*/
DartMarkerStore mf(map); // Lock a face marker to save one dart per face
DartMarkerStore mv(map);
typename PFP::VEC3 volCenter;
unsigned count = 0 ;
//Store faces that are traversed and start with the face of d
std::vector<Dart> visitedFaces;
visitedFaces.reserve(200);
visitedFaces.push_back(old);
//Store the edges before the cutEdge
std::vector<Dart> oldEdges;
oldEdges.reserve(20);
mf.markOrbit(FACE, old) ;
for(std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
Dart e = *face ;
do
{
//add one old edge per vertex to the old edge list
//compute volume centroid
if(!mv.isMarked(e))
{
mv.markOrbit(VERTEX, e);
volCenter += position[e];
++count;
oldEdges.push_back(e);
}
// add all face neighbours to the table
Dart ee = map.phi2(e) ;
if(!mf.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mf.markOrbit(FACE, ee) ;
}
e = map.phi1(e) ;
} while(e != *face) ;
}
volCenter /= typename PFP::REAL(count) ;
/*
* Subdivision
*/
//Store the darts from quadrangulated faces
std::vector<std::pair<Dart,Dart> > subdividedfaces;
subdividedfaces.reserve(25);
//First step : subdivide edges and faces
//creates a i+1 edge level and i+1 face level
for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
Dart d = *face;
//if needed subdivide face
if(!map.faceIsSubdivided(d))
Algo::IHM::subdivideFace<PFP>(map, d, position, Algo::IHM::S_QUAD);
//save a dart from the subdivided face
unsigned int cur = map.getCurrentLevel() ;
unsigned int fLevel = map.faceLevel(d) + 1; //puisque dans tous les cas, la face est subdivisee
map.setCurrentLevel(fLevel) ;
//le brin est forcement du niveau cur
Dart cf = map.phi1(d);
Dart e = cf;
do
{
subdividedfaces.push_back(std::pair<Dart,Dart>(e,map.phi2(e)));
e = map.phi2(map.phi1(e));
}while (e != cf);
map.setCurrentLevel(cur);
}
map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision
std::vector<Dart> newEdges; //save darts from inner edges
newEdges.reserve(50);
//Second step : deconnect each corner, close each hole, subdivide each new face into 3
for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
{
Dart e = *edge;
Dart f1 = map.phi1(*edge);
do
{
map.unsewFaces(map.phi1(map.phi1(e)));
map.unsewFaces(map.phi1(e));
e = map.phi2(map.phi_1(e));
}
while(e != *edge);
map.closeHole(f1);
Dart old = map.phi2(map.phi1(e));
Dart dd = map.phi1(map.phi1(old)) ;
map.splitFace(old,dd) ;
Dart ne = map.phi1(map.phi1(old)) ;
map.cutEdge(ne);
position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
newEdges.push_back(ne);
newEdges.push_back(map.phi1(ne));
Dart stop = map.phi2(map.phi1(ne));
ne = map.phi2(ne);
do
{
dd = map.phi1(map.phi1(map.phi1(ne)));
//A Verifier !!
map.splitFace(ne, dd) ;
newEdges.push_back(map.phi1(dd));
ne = map.phi2(map.phi_1(ne));
dd = map.phi1(map.phi1(dd));
}
while(dd != stop);
}
//Third step : 3-sew internal faces
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{
Dart f1 = (*it).first;
Dart f2 = (*it).second;
if(map.phi3(map.phi2(f1)) == map.phi2(f1) && map.phi3(map.phi2(f2)) == map.phi2(f2))
{
//id pour toutes les faces interieures
map.sewVolumes(map.phi2(f1), map.phi2(f2));
//Fais a la couture !!!!!
unsigned int idface = map.getNewFaceId();
map.setFaceId(map.phi2(f1),idface, FACE);
}
//FAIS a la couture !!!!!!!
//id pour toutes les aretes exterieurs des faces quadrangulees
unsigned int idedge = map.getEdgeId(f1);
map.setEdgeId(map.phi2(f1), idedge, DART);
map.setEdgeId( map.phi2(f2), idedge, DART);
}
//LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!!
//id pour les aretes interieurs : (i.e. 6 pour un hexa)
DartMarker mne(map);
for(std::vector<Dart>::iterator it = newEdges.begin() ; it != newEdges.end() ; ++it)
{
if(!mne.isMarked(*it))
{
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(*it, idedge, EDGE);
mne.markOrbit(EDGE,*it);
}
}
map.setCurrentLevel(cur) ;
return subdividedfaces.begin()->first;
}