Commit a1cda248 authored by untereiner's avatar untereiner

ajout d'une fonction ds map2 : splitSurface

parent e0942ffc
......@@ -206,8 +206,7 @@ void Viewer::cb_mousePress(int button, int x, int y)
Dart d = m_renderTopo->picking<PFP>(myMap, x, y, allDarts);
if (d != Dart::nil())
{
//statusMsg("dart picked");
myMap.mergeFaces(d);
statusMsg("dart picked");
}
else
{
......
......@@ -143,6 +143,16 @@ public:
*/
void swapEdges(Dart d, Dart e);
//!
/*!
*
*/
void saveRelationsAroundVertex(Dart d, std::vector<std::pair<Dart, Dart> >& vd);
void unsewAroundVertex(std::vector<std::pair<Dart, Dart> >& vd);
Dart quadranguleFace(Dart d);
// //!
// /*!
// *
......
......@@ -403,8 +403,8 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
/*
* Subdivide Faces
*/
std::vector<std::pair<Dart,Dart> > subdividedfaces;
subdividedfaces.reserve(25);
std::vector<std::pair<Dart,Dart> > subdividedFaces;
subdividedFaces.reserve(128);
Traversor3WF<typename PFP::MAP> traF(map, old);
for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next())
......@@ -413,43 +413,18 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
if(!map.faceIsSubdivided(dit))
Algo::IHM::subdivideFace<PFP>(map, dit, position, Algo::IHM::S_QUAD);
//save a dart from the subdivided face
//save darts from the central vertex of each subdivided face
unsigned int cur = map.getCurrentLevel() ;
unsigned int fLevel = map.faceLevel(dit) + 1; //puisque dans tous les cas, la face est subdivisee
map.setCurrentLevel(fLevel) ;
//le brin est forcement du niveau cur
Dart cf = map.phi2(map.phi1(dit));
Dart e = cf;
do
{
subdividedfaces.push_back(std::pair<Dart,Dart>(e,map.phi2(e)));
e = map.phi2(map.phi_1(e));
}while (e != cf);
unsigned int fLevel = map.faceLevel(dit);
map.setCurrentLevel(fLevel + 1) ;
map.saveRelationsAroundVertex(map.phi2(map.phi1(dit)), subdividedFaces);
map.setCurrentLevel(cur);
}
unsigned int fLevel = map.faceLevel(old) + 1; //puisque dans tous les cas, la face est subdivisee
map.setCurrentLevel(fLevel) ;
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{
Dart f1 = (*it).first;
if(!map.Map2::isBoundaryEdge(f1))
{
Dart f2 = map.phi2(f1);
map.unsewFaces(f1);
map.copyDartEmbedding(VERTEX, map.phi2(f2), f1);
map.copyDartEmbedding(VERTEX, map.phi2(f1), f2);
}
}
cur = map.getCurrentLevel() ;
unsigned int fLevel = map.faceLevel(old);
map.setCurrentLevel(fLevel + 1) ;
map.unsewAroundVertex(subdividedFaces);
map.setCurrentLevel(cur);
/*
......@@ -469,58 +444,26 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
//volCenter += position[d];
//++degree;
Dart old = map.phi2(map.phi1(dit));
map.Map2::fillHole(old);
Dart dd = map.phi1(map.phi1(old)) ;
map.splitFace(old,dd) ;
unsigned int idface = map.getNewFaceId();
map.setFaceId(dd,idface, FACE);
Dart ne = map.phi1(map.phi1(old)) ;
map.cutEdge(ne);
centralDart = map.phi1(ne);
centralDart = map.quadranguleFace(dit);
position[centralDart] = volCenter;
newEdges.push_back(ne);
newEdges.push_back(map.phi1(ne));
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(ne, id, EDGE) ;
Dart stop = map.phi2(map.phi1(ne));
ne = map.phi2(ne);
do
{
dd = map.phi1(map.phi1(map.phi1(ne)));
map.splitFace(ne, dd) ;
unsigned int idface = map.getNewFaceId();
map.setFaceId(dd,idface, FACE);
newEdges.push_back(map.phi1(dd));
ne = map.phi2(map.phi_1(ne));
dd = map.phi1(map.phi1(dd));
}
while(dd != stop);
}
//volCenter /= double(degree);
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedFaces.begin(); it != subdividedFaces.end(); ++it)
{
Dart f1 = (*it).first;
Dart f2 = (*it).second;
Dart f1 = map.phi2((*it).first);
Dart f2 = map.phi2((*it).second);
if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2)))
if(map.isBoundaryFace(f1) && map.isBoundaryFace(f2))
{
map.sewVolumes(map.phi2(f1), map.phi2(f2));
std::cout << "plop" << std::endl;
map.sewVolumes(f1, f2, false);
}
}
//volCenter /= double(degree);
//position[centralDart] = volCenter;
// //Third step : 3-sew internal faces
......@@ -567,7 +510,7 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
map.setCurrentLevel(cur) ;
return subdividedfaces.begin()->first;
return subdividedFaces.front().first;
}
......@@ -658,8 +601,6 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
}
//if is not a tetrahedron
// unsigned int vdeg = map.vertexDegree(dit);
// if(vdeg > 3)
unsigned int fdeg = map.faceDegree(map.phi2(f1));
if(fdeg > 3)
{
......
......@@ -284,6 +284,13 @@ public:
* @return true if the merge has been executed, false otherwise
*/
virtual bool mergeVolumes(Dart d, Dart e);
//! Split a surface into two disconnected surfaces along a edge path
/*! @param vd a vector of darts
* @param FirstSideOpen : if false, one of the 2 sides of the surface remains closed (no hole)
* @param SecondSideOpen : if false, the other side of the surface remains closed (no hole)
*/
virtual void splitSurface(std::vector<Dart>& vd, bool FirstSideClosed = true, bool SecondSideClosed = true);
//@}
/*! @name Topological Queries
......
......@@ -189,6 +189,105 @@ void ImplicitHierarchicalMap3::swapEdges(Dart d, Dart e)
}
}
void ImplicitHierarchicalMap3::saveRelationsAroundVertex(Dart d, std::vector<std::pair<Dart, Dart> >& vd)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//le brin est forcement du niveau cur
Dart dit = d;
do
{
vd.push_back(std::pair<Dart,Dart>(dit,phi2(dit)));
dit = phi2(phi_1(dit));
}while(dit != d);
}
void ImplicitHierarchicalMap3::unsewAroundVertex(std::vector<std::pair<Dart, Dart> >& vd)
{
//unsew the edge path
for(std::vector<std::pair<Dart, Dart> >::iterator it = vd.begin() ; it != vd.end() ; ++it)
{
Dart dit = (*it).first;
Dart dit2 = (*it).second;
Map2::unsewFaces(dit);
if(isOrbitEmbedded(VERTEX))
{
copyDartEmbedding(VERTEX, phi2(dit2), dit);
copyDartEmbedding(VERTEX, phi2(dit), dit2);
}
if(isOrbitEmbedded(EDGE))
{
}
}
}
Dart ImplicitHierarchicalMap3::quadranguleFace(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
Dart centralDart = NIL;
Map2::fillHole(phi1(d));
Dart old = phi2(phi1(d));
Dart bc = newBoundaryCycle(faceDegree(old));
sewVolumes(old, bc, false);
if (isOrbitEmbedded(VERTEX))
{
Dart it = bc;
do
{
//copyDartEmbedding(VERTEX, it, phi1(phi3(it)));
embedOrbit(VERTEX, it, getEmbedding(VERTEX, phi1(phi3(it))));
it = phi1(it) ;
} while(it != bc) ;
}
Dart dd = phi1(phi1(old)) ;
splitFace(old,dd) ;
unsigned int idface = getNewFaceId();
setFaceId(dd,idface, FACE);
Dart ne = phi1(phi1(old)) ;
cutEdge(ne);
centralDart = phi1(ne);
//newEdges.push_back(ne);
//newEdges.push_back(map.phi1(ne));
unsigned int id = getNewEdgeId() ;
setEdgeId(ne, id, EDGE) ;
Dart stop = phi2(phi1(ne));
ne = phi2(ne);
do
{
dd = phi1(phi1(phi1(ne)));
splitFace(ne, dd) ;
unsigned int idface = getNewFaceId();
setFaceId(dd,idface, FACE);
//newEdges.push_back(map.phi1(dd));
ne = phi2(phi_1(ne));
dd = phi1(phi1(dd));
}
while(dd != stop);
return centralDart;
}
//Dart ImplicitHierarchicalMap3::cutEdge(Dart d)
//{
......
......@@ -526,6 +526,24 @@ bool Map2::mergeVolumes(Dart d, Dart e)
return true ;
}
void Map2::splitSurface(std::vector<Dart>& vd, bool FirstSideClosed, bool SecondSideClosed)
{
//assert(checkSimpleOrientedPath(vd));
Dart e = vd.front();
Dart e2 = phi2(e);
//unsew the edge path
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
unsewFaces(*it);
if(FirstSideClosed)
fillHole(e) ;
if(SecondSideClosed)
fillHole(e2) ;
}
/*! @name Topological Queries
* Return or set various topological information
*************************************************************************/
......
......@@ -511,12 +511,14 @@ void Map3::splitVolume(std::vector<Dart>& vd)
Dart e = vd.front();
Dart e2 = phi2(e);
//unsew the edge path
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
Map2::unsewFaces(*it);
// //unsew the edge path
// for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
// Map2::unsewFaces(*it);
//
// Map2::fillHole(e) ;
// Map2::fillHole(e2) ;
Map2::fillHole(e) ;
Map2::fillHole(e2) ;
Map2::splitSurface(vd,true,true);
//sew the two connected components
Map3::sewVolumes(phi2(e), phi2(e2), 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