Commit 10c7d948 authored by Pierre Kraemer's avatar Pierre Kraemer

ImplicitMaps -> simplification coarsenEdge + collapseEdge retourne un brin du sommet résultat

parent 44019bb7
...@@ -333,6 +333,10 @@ inline unsigned int ImplicitHierarchicalMap::edgeLevel(Dart d) ...@@ -333,6 +333,10 @@ inline unsigned int ImplicitHierarchicalMap::edgeLevel(Dart d)
return ld < ldd ? ldd : ld ; // insertion levels of its two darts return ld < ldd ? ldd : ld ; // insertion levels of its two darts
} }
/***************************************************
* ATTRIBUTE HANDLER *
***************************************************/
template <typename T> template <typename T>
T& AttributeHandler_IHM<T>::operator[](Dart d) T& AttributeHandler_IHM<T>::operator[](Dart d)
{ {
......
...@@ -149,11 +149,9 @@ void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ...@@ -149,11 +149,9 @@ void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
unsigned int cur = map.getCurrentLevel() ; unsigned int cur = map.getCurrentLevel() ;
Dart d2 = map.phi2(d) ; Dart d2 = map.phi2(d) ;
map.setCurrentLevel(cur + 1) ; map.setCurrentLevel(cur + 1) ;
map.unsewFaces(d) ; unsigned int dl = map.getDartLevel(d2) ;
map.unsewFaces(d2) ; map.setDartLevel(map.phi1(d2), dl) ;
map.collapseEdge(map.phi1(d)) ; map.collapseEdge(d2) ;
map.collapseEdge(map.phi1(d2)) ;
map.sewFaces(d, d2) ;
map.setCurrentLevel(cur) ; map.setCurrentLevel(cur) ;
} }
......
...@@ -173,13 +173,13 @@ void AttribMultiVect<T>::addBlock() ...@@ -173,13 +173,13 @@ void AttribMultiVect<T>::addBlock()
template <typename T> template <typename T>
void AttribMultiVect<T>::initElt(unsigned int id) void AttribMultiVect<T>::initElt(unsigned int id)
{ {
m_tableData[id/_BLOCKSIZE_][id%_BLOCKSIZE_] = T(0); m_tableData[id/_BLOCKSIZE_][id%_BLOCKSIZE_] = T(0);
} }
template <typename T> template <typename T>
void AttribMultiVect<T>::copyElt(unsigned int dst, unsigned int src) void AttribMultiVect<T>::copyElt(unsigned int dst, unsigned int src)
{ {
m_tableData[dst/_BLOCKSIZE_][dst%_BLOCKSIZE_] = m_tableData[src/_BLOCKSIZE_][src%_BLOCKSIZE_]; m_tableData[dst/_BLOCKSIZE_][dst%_BLOCKSIZE_] = m_tableData[src/_BLOCKSIZE_][src%_BLOCKSIZE_];
} }
template <typename T> template <typename T>
...@@ -192,7 +192,6 @@ void AttribMultiVect<T>::setNbBlocks(unsigned int nbb) ...@@ -192,7 +192,6 @@ void AttribMultiVect<T>::setNbBlocks(unsigned int nbb)
// T* ptr = new T[_BLOCKSIZE_]; // T* ptr = new T[_BLOCKSIZE_];
// m_tableData.push_back( ptr ); // m_tableData.push_back( ptr );
addBlock(); addBlock();
} }
} }
else else
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
* See 'collapseDegeneratedFace' to see what can happen to edges attributes * See 'collapseDegeneratedFace' to see what can happen to edges attributes
* Nothing has to be done for the faces (some degenerate ones can be deleted) * Nothing has to be done for the faces (some degenerate ones can be deleted)
*/ */
virtual void collapseEdge(Dart d, bool delDegenerateFaces = true) ; virtual Dart collapseEdge(Dart d, bool delDegenerateFaces = true) ;
/** /**
* No cell is created or deleted * No cell is created or deleted
......
...@@ -184,22 +184,22 @@ bool EmbeddedMap2<MAP2>::edgeCanCollapse(Dart d) ...@@ -184,22 +184,22 @@ bool EmbeddedMap2<MAP2>::edgeCanCollapse(Dart d)
} }
template <typename MAP2> template <typename MAP2>
void EmbeddedMap2<MAP2>::collapseEdge(Dart d, bool delDegenerateFaces) Dart EmbeddedMap2<MAP2>::collapseEdge(Dart d, bool delDegenerateFaces)
{ {
Dart dPrev2 = MAP2::phi2(MAP2::phi_1(d)) ;
unsigned int vEmb = EMBNULL ; unsigned int vEmb = EMBNULL ;
if (MAP2::isOrbitEmbedded(VERTEX_ORBIT)) if (MAP2::isOrbitEmbedded(VERTEX_ORBIT))
{ {
vEmb = MAP2::getEmbedding(d, VERTEX_ORBIT) ; vEmb = MAP2::getEmbedding(d, VERTEX_ORBIT) ;
} }
MAP2::collapseEdge(d, delDegenerateFaces); Dart dV = MAP2::collapseEdge(d, delDegenerateFaces);
if (MAP2::isOrbitEmbedded(VERTEX_ORBIT)) if (MAP2::isOrbitEmbedded(VERTEX_ORBIT))
{ {
MAP2::embedOrbit(VERTEX_ORBIT, dPrev2, vEmb) ; MAP2::embedOrbit(VERTEX_ORBIT, dV, vEmb) ;
} }
return dV ;
} }
template <typename MAP2> template <typename MAP2>
......
...@@ -120,8 +120,9 @@ public: ...@@ -120,8 +120,9 @@ public:
* was the only link between two border faces * was the only link between two border faces
* @param d a dart in the deleted edge * @param d a dart in the deleted edge
* @param delDegenerateFaces a boolean (default to true) * @param delDegenerateFaces a boolean (default to true)
* @return a dart of the resulting vertex
*/ */
virtual void collapseEdge(Dart d, bool delDegenerateFaces); virtual Dart collapseEdge(Dart d, bool delDegenerateFaces);
/** /**
* Flip the edge of d. (rotation in phi1 order) * Flip the edge of d. (rotation in phi1 order)
......
...@@ -132,14 +132,15 @@ public: ...@@ -132,14 +132,15 @@ public:
//! Collapse an edge (that is deleted) possibly merging its vertices //! Collapse an edge (that is deleted) possibly merging its vertices
/*! If delDegenerateFaces is true, the method checks that no degenerate /*! If delDegenerateFaces is true, the method checks that no degenerate
* faces are build (faces with less than 3 edges). If it occurs the faces * faces are built (faces with less than 3 edges). If it occurs the faces
* are deleted and the adjacencies are updated (see collapseDegeneratedFace). * are deleted and the adjacencies are updated (see collapseDegeneratedFace).
* \warning This may produce two distinct vertices if the edge * \warning This may produce two distinct vertices if the edge
* was the only link between two border faces * was the only link between two border faces
* @param d a dart in the deleted edge * @param d a dart in the deleted edge
* @param delDegenerateFaces a boolean (default to true) * @param delDegenerateFaces a boolean (default to true)
* @return a dart of the resulting vertex
*/ */
virtual void collapseEdge(Dart d, bool delDegenerateFaces = true); virtual Dart collapseEdge(Dart d, bool delDegenerateFaces = true);
/** /**
* Flip the edge of d. (rotation in phi1 order) * Flip the edge of d. (rotation in phi1 order)
......
...@@ -147,8 +147,13 @@ unsigned int ImplicitHierarchicalMap::faceLevel(Dart d) ...@@ -147,8 +147,13 @@ unsigned int ImplicitHierarchicalMap::faceLevel(Dart d)
++nbSubd ; // is treated here ++nbSubd ; // is treated here
it = phi1(it) ; it = phi1(it) ;
} while(m_edgeId[it] == eId) ; } while(m_edgeId[it] == eId) ;
// fLevel -= (unsigned int)(log2(nbSubd)) ; // PB WINDOWS log2 n'existe pas sous Visual 2010 !!
fLevel -= (unsigned int)(log((double)nbSubd)/log(2.0)) ; while(nbSubd > 1)
{
nbSubd /= 2 ;
--fLevel ;
}
m_curLevel = cur ; m_curLevel = cur ;
return fLevel ; return fLevel ;
......
...@@ -86,14 +86,24 @@ void GMap2::cutEdge(Dart d) ...@@ -86,14 +86,24 @@ void GMap2::cutEdge(Dart d)
} }
} }
void GMap2::collapseEdge(Dart d, bool delDegenerateFaces = true) Dart GMap2::collapseEdge(Dart d, bool delDegenerateFaces = true)
{ {
Dart f; // A dart in the face to check Dart resV ;
Dart e = phi2(d); // Test if an opposite edge exists
if (e != d) Dart e = phi2(d);
if (e != d) // Test if an opposite edge exists
{ {
f = phi1(e); // A dart in the face of e phi2unsew(d); // Unlink the opposite edges
phi2unsew(d); // Unlink the opposite edges Dart f = phi1(e) ;
Dart g = phi_1(e) ;
if(!isFaceTriangle(e))
resV = f ;
else if(phi2(g) != g)
resV = phi2(g) ;
else if(phi2(f) != f)
resV = phi1(phi2(f)) ;
if (f != e && delDegenerateFaces) if (f != e && delDegenerateFaces)
{ {
GMap1::collapseEdge(e); // Collapse edge e GMap1::collapseEdge(e); // Collapse edge e
...@@ -102,7 +112,20 @@ void GMap2::collapseEdge(Dart d, bool delDegenerateFaces = true) ...@@ -102,7 +112,20 @@ void GMap2::collapseEdge(Dart d, bool delDegenerateFaces = true)
else else
GMap1::collapseEdge(e); // Just collapse edge e GMap1::collapseEdge(e); // Just collapse edge e
} }
f = phi1(d); // A dart in the face of d
Dart f = phi1(d) ;
Dart g = phi_1(d) ;
if(resV == Dart::nil())
{
if(!isFaceTriangle(d))
resV = f ;
else if(phi2(g) != g)
resV = phi2(g) ;
else if(phi2(f) != f)
resV = phi1(phi2(f)) ;
}
if (f != d && delDegenerateFaces) if (f != d && delDegenerateFaces)
{ {
GMap1::collapseEdge(d); // Collapse edge d GMap1::collapseEdge(d); // Collapse edge d
...@@ -110,6 +133,8 @@ void GMap2::collapseEdge(Dart d, bool delDegenerateFaces = true) ...@@ -110,6 +133,8 @@ void GMap2::collapseEdge(Dart d, bool delDegenerateFaces = true)
} }
else else
GMap1::collapseEdge(d); // Just collapse edge d GMap1::collapseEdge(d); // Just collapse edge d
return resV ;
} }
bool GMap2::flipEdge(Dart d) bool GMap2::flipEdge(Dart d)
......
...@@ -88,14 +88,24 @@ void Map2::cutEdge(Dart d) ...@@ -88,14 +88,24 @@ void Map2::cutEdge(Dart d)
} }
} }
void Map2::collapseEdge(Dart d, bool delDegenerateFaces) Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces)
{ {
Dart f; // A dart in the face to check Dart resV ;
Dart e = phi2(d); // Test if an opposite edge exists
if (e != d) Dart e = phi2(d);
if (e != d) // Test if an opposite edge exists
{ {
f = phi1(e); // A dart in the face of e phi2unsew(d); // Unlink the opposite edges
phi2unsew(d); // Unlink the opposite edges Dart f = phi1(e) ;
Dart g = phi_1(e) ;
if(!isFaceTriangle(e))
resV = f ;
else if(phi2(g) != g)
resV = phi2(g) ;
else if(phi2(f) != f)
resV = phi1(phi2(f)) ;
if (f != e && delDegenerateFaces) if (f != e && delDegenerateFaces)
{ {
Map1::collapseEdge(e); // Collapse edge e Map1::collapseEdge(e); // Collapse edge e
...@@ -104,7 +114,20 @@ void Map2::collapseEdge(Dart d, bool delDegenerateFaces) ...@@ -104,7 +114,20 @@ void Map2::collapseEdge(Dart d, bool delDegenerateFaces)
else else
Map1::collapseEdge(e); // Just collapse edge e Map1::collapseEdge(e); // Just collapse edge e
} }
f = phi1(d); // A dart in the face of d
Dart f = phi1(d) ;
Dart g = phi_1(d) ;
if(resV == Dart::nil())
{
if(!isFaceTriangle(d))
resV = f ;
else if(phi2(g) != g)
resV = phi2(g) ;
else if(phi2(f) != f)
resV = phi1(phi2(f)) ;
}
if (f != d && delDegenerateFaces) if (f != d && delDegenerateFaces)
{ {
Map1::collapseEdge(d); // Collapse edge d Map1::collapseEdge(d); // Collapse edge d
...@@ -112,6 +135,8 @@ void Map2::collapseEdge(Dart d, bool delDegenerateFaces) ...@@ -112,6 +135,8 @@ void Map2::collapseEdge(Dart d, bool delDegenerateFaces)
} }
else else
Map1::collapseEdge(d); // Just collapse edge d Map1::collapseEdge(d); // Just collapse edge d
return resV ;
} }
bool Map2::flipEdge(Dart d) bool Map2::flipEdge(Dart d)
......
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