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) ...@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 2.8)
project(CGoGN) project(CGoGN)
#SET( CMAKE_VERBOSE_MAKEFILE 1 )
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}) SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR})
# for GLEW # for GLEW
......
...@@ -31,37 +31,37 @@ namespace Algo ...@@ -31,37 +31,37 @@ namespace Algo
namespace IHM namespace IHM
{ {
///*************************************************** /***************************************************
// * ATTRIBUTES MANAGEMENT * * ATTRIBUTES MANAGEMENT *
// ***************************************************/ ***************************************************/
//
//template <typename T> template <typename T>
//AttributeHandler_IHM<T> ImplicitHierarchicalMap3::addAttribute(unsigned int orbit, const std::string& nameAttr) AttributeHandler_IHM<T> ImplicitHierarchicalMap3::addAttribute(unsigned int orbit, const std::string& nameAttr)
//{ {
// bool addNextLevelCell = false ; bool addNextLevelCell = false ;
// if(!isOrbitEmbedded(orbit)) if(!isOrbitEmbedded(orbit))
// addNextLevelCell = true ; addNextLevelCell = true ;
//
// AttributeHandler<T> h = Map3::addAttribute<T>(orbit, nameAttr) ; AttributeHandler<T> h = Map3::addAttribute<T>(orbit, nameAttr) ;
//
// if(addNextLevelCell) if(addNextLevelCell)
// { {
// AttributeContainer& cellCont = m_attribs[orbit] ; AttributeContainer& cellCont = m_attribs[orbit] ;
// AttributeMultiVector<unsigned int>* amv = cellCont.addAttribute<unsigned int>("nextLevelCell") ; AttributeMultiVector<unsigned int>* amv = cellCont.addAttribute<unsigned int>("nextLevelCell") ;
// m_nextLevelCell[orbit] = amv ; m_nextLevelCell[orbit] = amv ;
// for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i)) for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
// amv->operator[](i) = EMBNULL ; amv->operator[](i) = EMBNULL ;
// } }
//
// return AttributeHandler_IHM<T>(this, h.getDataVector()) ; return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
//} }
//
//template <typename T> template <typename T>
//AttributeHandler_IHM<T> ImplicitHierarchicalMap3::getAttribute(unsigned int orbit, const std::string& nameAttr) AttributeHandler_IHM<T> ImplicitHierarchicalMap3::getAttribute(unsigned int orbit, const std::string& nameAttr)
//{ {
// AttributeHandler<T> h = Map2::getAttribute<T>(orbit, nameAttr) ; AttributeHandler<T> h = Map3::getAttribute<T>(orbit, nameAttr) ;
// return AttributeHandler_IHM<T>(this, h.getDataVector()) ; return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
//} }
/*************************************************** /***************************************************
* MAP TRAVERSAL * * MAP TRAVERSAL *
...@@ -123,7 +123,6 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d) ...@@ -123,7 +123,6 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
return it ; return it ;
} }
//TODO A verifier si besoin d'assertion
inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d) inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d)
{ {
unsigned int faceId = m_faceId[d]; unsigned int faceId = m_faceId[d];
...@@ -171,50 +170,21 @@ inline Dart ImplicitHierarchicalMap3::alpha1(Dart 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") ; //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) 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); return phi3(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) 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); return phi2(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() inline Dart ImplicitHierarchicalMap3::begin()
...@@ -521,67 +491,67 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d) ...@@ -521,67 +491,67 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r; return r;
} }
///*************************************************** /***************************************************
// * ATTRIBUTE HANDLER * * ATTRIBUTE HANDLER *
// ***************************************************/ ***************************************************/
//
//template <typename T> template <typename T>
//T& AttributeHandler_IHM<T>::operator[](Dart d) T& AttributeHandler_IHM<T>::operator[](Dart d)
//{ {
// ImplicitHierarchicalMap3* m = reinterpret_cast<ImplicitHierarchicalMap3*>(this->m_map) ; 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->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") ; 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 orbit = this->getOrbit() ;
// unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ; unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
// unsigned int index = m->getEmbedding(orbit, d) ; unsigned int index = m->getEmbedding(orbit, d) ;
//
// if(index == EMBNULL) if(index == EMBNULL)
// { {
// index = m->embedNewCell(orbit, d) ; index = m->embedNewCell(orbit, d) ;
// m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ; m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ;
// } }
//
// AttributeContainer& cont = m->getAttributeContainer(orbit) ; AttributeContainer& cont = m->getAttributeContainer(orbit) ;
// unsigned int step = 0 ; unsigned int step = 0 ;
// while(step < nbSteps) while(step < nbSteps)
// { {
// step++ ; step++ ;
// unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ; unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ;
// if (nextIdx == EMBNULL) if (nextIdx == EMBNULL)
// { {
// nextIdx = m->newCell(orbit) ; nextIdx = m->newCell(orbit) ;
// m->copyCell(orbit, nextIdx, index) ; m->copyCell(orbit, nextIdx, index) ;
// m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ; m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ;
// m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ; m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ;
// cont.refLine(index) ; cont.refLine(index) ;
// } }
// index = nextIdx ; index = nextIdx ;
// } }
// return this->m_attrib->operator[](index); return this->m_attrib->operator[](index);
//} }
//
//template <typename T> template <typename T>
//const T& AttributeHandler_IHM<T>::operator[](Dart d) const const T& AttributeHandler_IHM<T>::operator[](Dart d) const
//{ {
// ImplicitHierarchicalMap3* m = reinterpret_cast<ImplicitHierarchicalMap3*>(this->m_map) ; 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->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") ; 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 orbit = this->getOrbit() ;
// unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ; unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
// unsigned int index = m->getEmbedding(orbit, d) ; unsigned int index = m->getEmbedding(orbit, d) ;
//
// unsigned int step = 0 ; unsigned int step = 0 ;
// while(step < nbSteps) while(step < nbSteps)
// { {
// step++ ; step++ ;
// unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ; unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ;
// if(next != EMBNULL) index = next ; if(next != EMBNULL) index = next ;
// else break ; else break ;
// } }
// return this->m_attrib->operator[](index); return this->m_attrib->operator[](index);
//} }
} //namespace IHM } //namespace IHM
......
...@@ -54,6 +54,11 @@ public: ...@@ -54,6 +54,11 @@ public:
*/ */
virtual bool uncutEdge(Dart d); virtual bool uncutEdge(Dart d);
//!
/*!
*/
virtual Dart deleteEdge(Dart d);
/*! /*!
* *
*/ */
......
...@@ -37,69 +37,69 @@ class EmbeddedMap3 : public Map3 ...@@ -37,69 +37,69 @@ class EmbeddedMap3 : public Map3
public: public:
typedef Map3 TOPO_MAP; typedef Map3 TOPO_MAP;
//!
/*! /*!
*
*/ */
virtual Dart deleteVertex(Dart d); virtual Dart deleteVertex(Dart d);
/*! No attribute is attached to the new vertex //! No attribute is attached to the new vertex
* The attributes attached to the old edge are duplicated on both resulting edges /*! The attributes attached to the old edge are duplicated on both resulting edges
* @param d a dart * @param d a dart
*/ */
virtual Dart cutEdge(Dart d); virtual Dart cutEdge(Dart d);
/*! The attributes attached to the edge of d are kept on the resulting edge //! The attributes attached to the edge of d are kept on the resulting edge
* @param d a dart of the edge to cut /*! @param d a dart of the edge to cut
*/ */
virtual bool uncutEdge(Dart d); virtual bool uncutEdge(Dart d);
//!
/*! /*!
*
*/ */
virtual Dart deleteEdge(Dart d); virtual Dart deleteEdge(Dart d);
//!
/*! /*!
*
*/ */
bool edgeCanCollapse(Dart d); bool edgeCanCollapse(Dart d);
//!
/*! /*!
*
*/ */
virtual Dart collapseEdge(Dart d, bool delDegenerateVolumes=true); virtual Dart collapseEdge(Dart d, bool delDegenerateVolumes=true);
//!
/*! /*!
*
*/ */
virtual void splitFace(Dart d, Dart e); virtual void splitFace(Dart d, Dart e);
//!
/*! /*!
*
*/ */
virtual void sewVolumes(Dart d, Dart e, bool withBoundary = true); virtual void sewVolumes(Dart d, Dart e, bool withBoundary = true);
//!
/*! /*!
*
*/ */
virtual void unsewVolumes(Dart d); virtual void unsewVolumes(Dart d);
//!
/*! /*!
*
*/ */
virtual bool mergeVolumes(Dart d); virtual bool mergeVolumes(Dart d);
//!
/*! /*!
*
*/ */
virtual void splitVolume(std::vector<Dart>& vd); 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 unsigned int closeHole(Dart d, bool forboundary = true);
//!
/*! /*!
*
*/ */
virtual bool check(); virtual bool check();
} ; } ;
......
...@@ -173,7 +173,7 @@ public: ...@@ -173,7 +173,7 @@ public:
* @param d a dart of the face * @param d a dart of the face
* @return true if the collapse has been executed, false otherwise * @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. //! Sew two oriented volumes along their faces.
/*! The oriented faces should not be phi3-linked and have the same degree /*! The oriented faces should not be phi3-linked and have the same degree
......
...@@ -68,6 +68,191 @@ void ImplicitHierarchicalMap3::init() ...@@ -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() void ImplicitHierarchicalMap3::initEdgeId()
{ {
DartMarker edgeMark(*this) ;