Commit dd6cef5c authored by Pierre Kraemer's avatar Pierre Kraemer

Merge cgogn:~untereiner/CGoGN

parents 25f6a07c 010b5977
......@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 2.8)
project(CGoGN)
#SET( CMAKE_VERBOSE_MAKEFILE 1 )
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR})
# for GLEW
......
......@@ -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 = Map3::getAttribute<T>(orbit, nameAttr) ;
return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
}
/***************************************************
* MAP TRAVERSAL *
......@@ -123,7 +123,6 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
return it ;
}
//TODO A verifier si besoin d'assertion
inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d)
{
unsigned int faceId = m_faceId[d];
......@@ -171,50 +170,21 @@ inline Dart ImplicitHierarchicalMap3::alpha1(Dart d)
{
//assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
return Map3::alpha1(d) ;
return phi3(phi_1(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;
//return Map3::alpha2(d);
return phi3(phi2(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;
//return Map3::alpha_2(d);
return phi2(phi3(d));
}
inline Dart ImplicitHierarchicalMap3::begin()
......@@ -521,67 +491,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
......
......@@ -54,6 +54,11 @@ public:
*/
virtual bool uncutEdge(Dart d);
//!
/*!
*/
virtual Dart deleteEdge(Dart d);
/*!
*
*/
......
......@@ -37,69 +37,69 @@ class EmbeddedMap3 : public Map3
public:
typedef Map3 TOPO_MAP;
//!
/*!
*
*/
virtual Dart deleteVertex(Dart d);
/*! No attribute is attached to the new vertex
* The attributes attached to the old edge are duplicated on both resulting edges
//! No attribute is attached to the new vertex
/*! The attributes attached to the old edge are duplicated on both resulting edges
* @param d a dart
*/
virtual Dart cutEdge(Dart d);
/*! The attributes attached to the edge of d are kept on the resulting edge
* @param d a dart of the edge to cut
//! The attributes attached to the edge of d are kept on the resulting edge
/*! @param d a dart of the edge to cut
*/
virtual bool uncutEdge(Dart d);
//!
/*!
*
*/
virtual Dart deleteEdge(Dart d);
//!
/*!
*
*/
bool edgeCanCollapse(Dart d);
//!
/*!
*
*/
virtual Dart collapseEdge(Dart d, bool delDegenerateVolumes=true);
//!
/*!
*
*/
virtual void splitFace(Dart d, Dart e);
//!
/*!
*
*/
virtual void sewVolumes(Dart d, Dart e, bool withBoundary = true);
//!
/*!
*
*/
virtual void unsewVolumes(Dart d);
//!
/*!
*
*/
virtual bool mergeVolumes(Dart d);
//!
/*!
*
*/
virtual void splitVolume(std::vector<Dart>& vd);
/**
* No attribute is attached to the new volume
//!
/*! No attribute is attached to the new volume
*/
virtual unsigned int closeHole(Dart d, bool forboundary = true);
//!
/*!
*
*/
virtual bool check();
} ;
......
......@@ -173,7 +173,7 @@ public:
* @param d a dart of the face
* @return true if the collapse has been executed, false otherwise
*/
virtual bool collapseDegeneretedVolume(Dart d);
bool collapseDegeneretedVolume(Dart d);
//! Sew two oriented volumes along their faces.
/*! The oriented faces should not be phi3-linked and have the same degree
......
......@@ -68,6 +68,191 @@ void ImplicitHierarchicalMap3::init()
}
}
Dart ImplicitHierarchicalMap3::beginSplittingPath(Dart d, DartMarker& m)
{
Dart dres = NIL;
Dart dit = d;
bool found = false;
// Recherche d'un brin de depart du chemin d'arete
do
{
Dart eit = phi1(dit);
if(!m.isMarked(eit) && getDartLevel(eit) == getCurrentLevel())
{
found = true;
dres = eit;
}
dit = phi2(phi_1(dit));
}
while(!found && dit != d);
return dres;
}
void ImplicitHierarchicalMap3::constructSplittingPath(Dart d, std::vector<Dart>& v, DartMarker& m)
{
//Construction du chemin d'arete
Dart cit = d;
v.push_back(cit);
m.markOrbit(EDGE, cit);
do
{
if(std::min(getDartLevel(phi1(cit)),getDartLevel(phi2(phi1(cit)))) == getDartLevel(d))
{
if(m.isMarked(phi1(cit)))
{
cit = phi1(phi2(phi1(cit)));
std::cout << "1_1" << std::endl;
}
}
else if(std::min(getDartLevel(phi1(cit)),getDartLevel(phi2(phi1(cit)))) < getDartLevel(d))
{
cit = phi1(phi2(phi1(cit)));
std::cout << "2" << std::endl;
}
else
cit = phi1(cit);
v.push_back(cit);
m.markOrbit(EDGE, cit);
}
while(cit != d);
// do
// {
// v.push_back(cit);
// m.markOrbit(EDGE, cit);
//
// cit = phi1(cit);
//
// //std::cout << "cit = " << cit << std::endl;
//
// if(std::min(getDartLevel(cit), getDartLevel(phi2(cit))) == getDartLevel(d))
// {
// if(m.isMarked(cit))
// {
// cit = phi1(phi2(cit));
// //std::cout << "1_1" << std::endl;
// }
// }
// else if(std::min(getDartLevel(cit),getDartLevel(phi2(cit))) < getDartLevel(d))
// {
// cit = phi1(phi2(cit));
// //std::cout << "2" << std::endl;
// }
//
// }while(cit != d);
}
//Dart ImplicitHierarchicalMap3::cutEdge(Dart d)
//{
// Dart resV = EmbeddedMap3::cutEdge(d);
//
// unsigned int eId = getEdgeId(d);
// Dart dit = d;
// do
// {
// //EdgeId
// m_edgeId[phi1(dit)] = eId;
// m_edgeId[phi3(dit)] = eId;
//
// //FaceId
// unsigned int fId = getFaceId(dit);
// m_faceId[phi1(dit)] = fId;
// m_edgeId[phi3(dit)] = fId;
//
// dit = alpha2(dit);
// }
// while(dit != d);
//
// return resV;
//}
//
//bool ImplicitHierarchicalMap3::uncutEdge(Dart d)
//{
// return EmbeddedMap3::uncutEdge(d);
//}
//
//void ImplicitHierarchicalMap3::splitFace(Dart d, Dart e)
//{
// EmbeddedMap3::splitFace(d,e);
//
// unsigned int eId = getNewEdgeId();
// unsigned int fId = getFaceId(d);
//
// Dart ne = phi_1(d);
// Dart ne3 = phi3(ne);
//
// m_edgeId[ne] = eId;
// m_edgeId[phi2(ne)] = eId;
// m_edgeId[ne3] = eId;
// m_edgeId[phi2(ne3)] = eId;
//
// m_faceId[ne] = fId;
// m_faceId[phi2(ne)] = fId;
// m_faceId[ne3] = fId;
// m_faceId[phi2(ne3)] = fId;
//}
//
//void ImplicitHierarchicalMap3::sewVolumes(Dart d, Dart e, bool withBoundary)
//{
// EmbeddedMap3::sewVolumes(d,e);
//
// unsigned int fId;
//
// if(m_faceId[d] < m_faceId[phi3(d)])
// fId = m_faceId[d] ;
// else
// fId = m_edgeId[phi3(d)];
//
// Dart dit = d;
// do
// {
// //EdgeId
//// if(m_edgeId[dit] < m_edgeId[phi3(dit)])
//// m_edgeId[phi3(dit)] = m_edgeId[dit] ;
//// else
//// m_edgeId[dit] = m_edgeId[phi3(dit)];
//
// //FaceId
// m_faceId[dit] = fId;
// m_faceId[phi3(dit)] = fId;
//
// dit = phi1(dit);
// }
// while(dit != d);
//}
//
//void ImplicitHierarchicalMap3::splitVolume(std::vector<Dart>& vd)
//{
// EmbeddedMap3::splitVolume(vd);
//
// unsigned int fId = getNewFaceId();
//
// for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
// {
// Dart dit = *it;
//
// //Edge Id
// m_edgeId[phi2(dit)] = m_edgeId[dit];
//
// //Face Id
// m_faceId[phi2(dit)] = fId;
// }
//}
void ImplicitHierarchicalMap3::initEdgeId()
{
DartMarker edgeMark(*this) ;
......@@ -106,11 +291,8 @@ void ImplicitHierarchicalMap3::initFaceId()
faceMark.mark(e);
Dart e3 = Map3::phi3(e);
if(e3 != e)
{
m_faceId[e3] = m_faceIdCount ;
faceMark.mark(e3);
}
m_faceId[e3] = m_faceIdCount ;
faceMark.mark(e3);
e = Map3::phi1(e);
} while(e != d);
......@@ -402,7 +584,7 @@ bool ImplicitHierarchicalMap3::volumeIsSubdivided(Dart d)
std::vector<Dart>::iterator face;
Dart old = d ;
// Dart old = d ;
bool facesAreSubdivided = faceIsSubdivided(d) ;
//parcours les faces du volume au niveau courant
......
......@@ -108,6 +108,19 @@ bool EmbeddedGMap3::uncutEdge(Dart d)
return false ;
}
Dart EmbeddedGMap3::deleteEdge(Dart d)
{
Dart v = GMap3::deleteEdge(d) ;
if(v != NIL)
{
if (isOrbitEmbedded(VOLUME))
{
embedOrbit(VOLUME, v, getEmbedding(VOLUME, v)) ;
}
}
return v ;
}
void EmbeddedGMap3::splitFace(Dart d, Dart e)
{
Dart dd = beta1(beta3(d));
......
......@@ -109,7 +109,7 @@ bool EmbeddedMap3::uncutEdge(Dart d)
Dart EmbeddedMap3::deleteEdge(Dart d)
{
Dart v = Map3::deleteVertex(d) ;
Dart v = Map3::deleteEdge(d) ;
if(v != NIL)
{
if(isOrbitEmbedded(VOLUME))
......@@ -125,7 +125,7 @@ bool EmbeddedMap3::edgeCanCollapse(Dart d)
//Criteres sur le bord
if(isBoundaryEdge(d))
{
//fusion de deux bord
//fusion de deux bords
//deconnection du bord
}
......
......@@ -121,7 +121,7 @@ Dart Map3::deleteVertex(Dart d)
FunctorStore fs(fstoretmp);
foreach_dart_of_vertex(d, fs);
// just one dart per face
// just one dart per face