Commit 3bb52406 authored by Pierre Kraemer's avatar Pierre Kraemer

Ajout Map2::deleteVertex

parent 11e22924
......@@ -552,6 +552,22 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break ;
}
case 'v':
{
srand(time(NULL)) ;
unsigned int nbDarts = myMap.getNbDarts() ;
unsigned int r = rand() % nbDarts ;
Dart d(r) ;
if(myMap.isDartValid(d))
{
myMap.deleteVertex(d) ;
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
}
}
case 'x':
{
Algo::Export::exportOFF<PFP>(myMap, position, "export.off") ;
......
......@@ -153,6 +153,17 @@ void coarsenFace(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.faceIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided face or a more than once subdivided face") ;
unsigned int cur = map.getCurrentLevel() ;
Dart fit = d ;
do
{
map.setCurrentLevel(cur + 1) ;
map.removeVertex(map.phi1(map.phi1(fit))) ;
map.setCurrentLevel(cur) ;
fit = map.phi1(fit) ;
} while(fit != d) ;
}
} //namespace IHM
......
......@@ -50,6 +50,13 @@ public:
*/
virtual void splitVertex(Dart d, Dart e) ;
/**
* Nothing has to be done for the vertices
* Nothing has to be done for the edges
* The attributes attached to the face of d are kept on the resulting face
*/
virtual bool deleteVertex(Dart d) ;
/**
* No attribute is attached to the new vertex
* The attributes attached to the old edge are duplicated on both resulting edges
......
......@@ -77,6 +77,39 @@ void EmbeddedMap2<MAP2>::splitVertex(Dart d, Dart e)
}
}
template <typename MAP2>
bool EmbeddedMap2<MAP2>::deleteVertex(Dart d)
{
if(MAP2::isOrbitEmbedded(VERTEX_ORBIT))
{
Dart vit = d ;
do
{
unsigned int vEmb = MAP2::getDartEmbedding(VERTEX_ORBIT, MAP2::phi2(vit)) ;
if(vEmb != EMBNULL)
MAP2::setDartEmbedding(VERTEX_ORBIT, MAP2::phi1(vit), vEmb) ;
vit = MAP2::alpha1(vit) ;
} while(vit != d) ;
}
Dart f = MAP2::phi1(d) ;
unsigned int fEmb = EMBNULL ;
if (MAP2::isOrbitEmbedded(FACE_ORBIT))
{
fEmb = MAP2::getEmbedding(d, FACE_ORBIT) ;
}
if(MAP2::deleteVertex(d))
{
if (MAP2::isOrbitEmbedded(FACE_ORBIT))
{
MAP2::embedOrbit(FACE_ORBIT, f, fEmb) ;
}
return true ;
}
return false ;
}
template <typename MAP2>
void EmbeddedMap2<MAP2>::cutEdge(Dart d)
{
......
......@@ -118,6 +118,13 @@ public:
*/
virtual void splitVertex(Dart d, Dart e);
//! Delete the vertex of d (works only for internal vertices)
/*! All the faces around the vertex are merged into one face
* @param d a dart of the vertex to delete
* @return true if the deletion has been executed, false otherwise
*/
virtual bool deleteVertex(Dart d) ;
//! Cut the edge of d and its opposite edge if it exists
/*! @param d a dart of the edge to cut
*/
......
......@@ -107,7 +107,7 @@ unsigned int ImplicitHierarchicalMap::faceLevel(Dart d)
++nbSubd ; // is treated here
it = phi1(it) ;
} while(m_edgeId[it] == eId) ;
//fLevel -= (unsigned int)(log2(nbSubd)) ; PB WINDOWS log2 n'existe pas sous Visual 2010 !!
// fLevel -= (unsigned int)(log2(nbSubd)) ; // PB WINDOWS log2 n'existe pas sous Visual 2010 !!
fLevel -= (unsigned int)(log((double)nbSubd)/log(2.0)) ;
m_curLevel = cur ;
......
......@@ -56,6 +56,23 @@ void Map2::splitVertex(Dart d, Dart e)
phi2sew(phi1(dd), phi1(ee));// Sew the two faces along the new edge
}
bool Map2::deleteVertex(Dart d)
{
if(isBoundaryVertex(d))
return false ;
Dart vit = d ;
do
{
Dart f = phi_1(phi2(vit)) ;
phi1sew(vit, f) ;
vit = alpha1(vit) ;
} while(vit != d) ;
Map1::deleteFace(d) ;
return true ;
}
void Map2::cutEdge(Dart d)
{
Map1::cutEdge(d); // Cut the edge of 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