Commit 9e2ce59c authored by untereiner's avatar untereiner

change subdiv algo for no_boundary

parent 7f08b177
......@@ -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 *
......@@ -171,50 +171,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 +492,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();
} ;
......
......@@ -169,7 +169,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,104 @@ void ImplicitHierarchicalMap3::init()
}
}
//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 +204,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 +497,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
}
......
......@@ -90,7 +90,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
std::vector<Dart> fstore;
fstore.reserve(128);
DartMarker mf(*this);
......@@ -237,7 +237,7 @@ Dart Map3::collapseEdge(Dart d, bool delDegenerateVolumes)
if(delDegenerateVolumes)
{
Map2::collapseEdge(e, true);
//collapseDegeneretedVolume(e);
collapseDegeneretedVolume(e);
}
else
Map2::collapseEdge(e, false);
......@@ -247,10 +247,10 @@ Dart Map3::collapseEdge(Dart d, bool delDegenerateVolumes)
}
}while(d != dit);
return resV;
}
......@@ -304,8 +304,7 @@ Dart Map3::collapseEdge(Dart d, bool delDegenerateVolumes)
// }
// }
return resV;
}
void Map3::splitFace(Dart d, Dart e)
{
......@@ -326,22 +325,18 @@ bool Map3::collapseDegeneretedVolume(Dart d)
Dart e1 = phi2(d);
Dart e2 = phi2(phi1(d));
//Si l'une des faces est du bord
if(isBoundaryFace(e1) || isBoundaryFace(e2))
//Si les deux faces ne sont pas du bord
if(!isBoundaryFace(e1) && !isBoundaryFace(e2))
{
//alors simple suppression du volume degenere
sewVolumes(phi3(e1),phi3(e2));
deleteVolume(d);
return true;
}
else
{
Dart e13 = e1;
Dart e23 = e2;
if(!isBoundaryFace(e1))
e13 = phi3(e1);
if(!isBoundaryFace(e2))
e23 = phi3(e2);
//if(faceDegree(e1) < faceDegree)
//alors simple suppression du volume degenere
deleteVolume(d);
return true;
}
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment