Commit 86cc07a8 authored by Thomas's avatar Thomas

reorganisation code tout gmap pour coherence

parent c97d7f8d
......@@ -68,6 +68,7 @@ public:
* To generate or delete cells in a 0-G-map
*************************************************************************/
//@{
/**
* create an edge
* @return a dart of the edge
......@@ -79,6 +80,7 @@ public:
* @param d a dart of the edge
*/
void deleteEdge(Dart d);
//@}
/*! @name Cell Functors
* Apply functors to all darts of a cell
......
......@@ -112,6 +112,13 @@ public:
*************************************************************************/
//@{
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
void linkVertices(Dart d, Dart e);
//! Cut an edge inserting a new dart between d and its successor in the face
/*! @param d the edge to cut
* \image hmtl map1_cutEdge.png
......@@ -138,15 +145,6 @@ public:
* @param e a dart in the second face
*/
void mergeFaces(Dart d, Dart e);
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
void linkVertices(Dart d, Dart e);
//@}
/*! @name Topological Queries
......
......@@ -180,6 +180,14 @@ inline void GMap1::phi1unsew(Dart d)
* Topological operations on 1-maps
*************************************************************************/
inline void GMap1::linkVertices(Dart d, Dart e)
{
assert(d != e && !sameOrientedFace(d, e)) ;
GMap1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d)
GMap1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e)
phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts
}
inline void GMap1::cutEdge(Dart d)
{
Dart e = newDart();
......@@ -236,14 +244,6 @@ inline void GMap1::mergeFaces(Dart d, Dart e)
deleteEdge(e) ;
}
inline void GMap1::linkVertices(Dart d, Dart e)
{
assert(d != e && !sameOrientedFace(d, e)) ;
GMap1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d)
GMap1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e)
phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts
}
/*! @name Cell Functors
* Apply functors to all darts of a cell
*************************************************************************/
......
......@@ -113,6 +113,20 @@ public:
*/
virtual bool deleteVertex(Dart d) ;
//! Insert an edge after a dart in the vertex orbit
/*! \pre Dart d and e MUST be different and belong to distinct face
* \pre Dart e must be phi2-linked with its phi_1 dart
* @param d dart of the vertex
* @param e dart of the edge
*/
virtual void insertEdgeInVertex(Dart d, Dart e);
//! Remove an edge from a vertex orbit
/*! \pre Dart d must be phi2 sewn
* @param d the dart of the edge to remove from the vertex
*/
virtual void removeEdgeFromVertex(Dart d);
//! Cut the edge of d and its opposite edge if it exists
/*! @param d a dart of the edge to cut
*/
......@@ -151,20 +165,6 @@ public:
*/
virtual bool flipBackEdge(Dart d);
//! Insert an edge after a dart in the vertex orbit
/*! \pre Dart d and e MUST be different and belong to distinct face
* \pre Dart e must be phi2-linked with its phi_1 dart
* @param d dart of the vertex
* @param e dart of the edge
*/
virtual void insertEdgeInVertex(Dart d, Dart e);
//! Remove an edge from a vertex orbit
/*! \pre Dart d must be phi2 sewn
* @param d the dart of the edge to remove from the vertex
*/
virtual void removeEdgeFromVertex(Dart d);
//! Sew two faces along an edge (pay attention to the orientation !)
/*! \pre Darts d & e MUST be fixed point of phi2 relation
* @param d a dart of the first face
......@@ -234,13 +234,12 @@ public:
*/
virtual unsigned int closeHole(Dart d);
// /**
// * Mark half of dart defining an orientation
// * @param d a dart that belong to the orientation we want to mark
// * @return the marker which mark th orientation
// */
// DartMarker markCCOrientation(Dart d);
//! Close the map removing topological holes.
/*! Add faces to the map that close every existing hole.
* These faces are marked.
* \warning The embeddings of vertices are not updated
* @param marker
*/
void closeMap(DartMarker& marker);
//@}
......@@ -248,6 +247,7 @@ public:
* Return or set various topological information
*************************************************************************/
//@{
//! Test if dart d and e belong to the same oriented vertex
/*! @param d a dart
* @param e a dart
......@@ -260,6 +260,16 @@ public:
*/
bool sameVertex(Dart d, Dart e);
/**
* compute the number of edges of the vertex of d
*/
unsigned int vertexDegree(Dart d) ;
/**
* tell if the vertex of d is on the boundary of the map
*/
bool isBoundaryVertex(Dart d) ;
//! Test if dart d and e belong to the same oriented volume
/*! @param d a dart
* @param e a dart
......@@ -272,16 +282,6 @@ public:
*/
bool sameVolume(Dart d, Dart e);
/**
* compute the number of edges of the vertex of d
*/
unsigned int vertexDegree(Dart d) ;
/**
* tell if the vertex of d is on the boundary of the map
*/
bool isBoundaryVertex(Dart d) ;
/**
* Check if map is complete
*/
......
......@@ -85,13 +85,16 @@ public:
void phi3unsew(Dart d);
/*! @name Generator and Deletor
* To generate or delete volumes in a 3-map
*************************************************************************/
//@{
//! Delete a volume of
/*! @param d a dart of volume
//! Delete a volume erasing all its darts.
/*! The phi3-links around the volume are removed
* @param d a dart of the volume
*/
void deleteOrientedVolume(Dart d);
void deleteVolume(Dart d);
//@}
/*! @name Topological Operators
......@@ -99,6 +102,24 @@ public:
*************************************************************************/
//@{
//! Cut the edge of d
/*! @param d a dart of the edge to cut
*/
virtual void cutEdge(Dart d);
//! Split a face inserting an edge between two vertices
/*! \pre Dart d and e should belong to the same face and be distinct
* @param d dart of first vertex
* @param e dart of second vertex
* @return the dart of the new edge lying in the vertex of d after the cut
*/
virtual void splitFace(Dart d, Dart e);
//! Unsew the "ear" of the vertex of d
/*! @param d a dart
*/
virtual Dart cutSpike(Dart d);
//! Sew two oriented volumes along their faces.
/*! The oriented faces should not be phi3-linked and have the same length
* @param d a dart of the first volume
......@@ -115,46 +136,8 @@ public:
/*! @param d a dart of common face
*/
bool mergeVolumes(Dart d);
//@}
//! Split a face inserting an edge between two vertices
/*! \pre Dart d and e should belong to the same face and be distinct
* @param d dart of first vertex
* @param e dart of second vertex
* @return the dart of the new edge lying in the vertex of d after the cut
*/
virtual void splitFace(Dart d, Dart e);
//! Cut the edge of d
/*! @param d a dart of the edge to cut
*/
virtual void cutEdge(Dart d);
//! Collapse an edge (that is deleted) possibly merging its vertices
/*! If delDegenerateFaces is true, the method checks that no degenerate
* faces are build (faces with less than 3 edges). If it occurs the faces
* are deleted and the adjacencies are updated (see deleteIfDegenerated).
* \warning This may produce two distinct vertices if the edge
* was the only link between two border faces
* @param d a dart in the deleted edge
* @param delDegenerateFaces a boolean (default to true)
*/
virtual int collapseEdge(Dart d, bool delDegenerateFaces = true, bool delDegenerateVolumes = true);
//!
/*!
*
* @param
* @param
* @param
*/
virtual void collapseFace(Dart d, bool delDegenerateFaces = true, bool delDegenerateVolumes = true);
//!
/*!
*
*/
virtual Dart cutSpike(Dart d);
/*! @name Topological Queries
* Return or set various topological information
......@@ -173,7 +156,16 @@ public:
*/
bool sameVertex(Dart d, Dart e) ;
//@{
//! Compute the number of edges of the vertex of d
/*! @param d a dart
*/
unsigned int vertexDegree(Dart d) ;
//! Tell if the vertex of d is on the boundary
/*! @param d a dart
*/
virtual bool isBoundaryVertex(Dart d);
//! Test if dart d and e belong to the same oriented edge
/*! @param d a dart
* @param e a dart
......@@ -186,6 +178,11 @@ public:
*/
bool sameEdge(Dart d, Dart e) ;
//! Compute the number of volumes around the edge of d
/*! @param d a dart
*/
unsigned int edgeDegree(Dart d);
//!Test if dart d and e belong to the same oriented face
/*! @param d a dart
* @param e a dart
......@@ -198,34 +195,15 @@ public:
*/
bool sameFace(Dart d, Dart e);
/**
* compute the number of edges of the vertex of d
*/
unsigned int vertexDegree(Dart d) ;
/**
* compute the number of volumes around the edge of d
*/
virtual unsigned int edgeDegree(Dart d);
/**
* compute the number of faces in the volume of d
*/
unsigned int volumeDegree(Dart d);
virtual bool check();
//@}
/**
*
*/
virtual bool isBoundaryVertex(Dart d);
/*! @name Cell Functors
* Apply functors to all darts of a cell
*************************************************************************/
//@{
/**
* Apply a functor on each dart of a face
* @param d a dart of the face
......
......@@ -73,6 +73,20 @@ bool GMap2::deleteVertex(Dart d)
return true ;
}
void GMap2::insertEdgeInVertex(Dart d, Dart e)
{
assert(!sameVertex(d,e) && phi2(e)==phi_1(e));
phi1sew(phi_1(d),phi_1(e));
}
void GMap2::removeEdgeFromVertex(Dart d)
{
assert(phi2(d)!=d);
phi1sew(phi_1(d),phi2(d));
}
void GMap2::cutEdge(Dart d)
{
GMap1::cutEdge(d); // Cut the edge of d
......@@ -192,20 +206,6 @@ bool GMap2::flipBackEdge(Dart d)
return false ; // cannot flip a border edge
}
void GMap2::insertEdgeInVertex(Dart d, Dart e)
{
assert(!sameVertex(d,e) && phi2(e)==phi_1(e));
phi1sew(phi_1(d),phi_1(e));
}
void GMap2::removeEdgeFromVertex(Dart d)
{
assert(phi2(d)!=d);
phi1sew(phi_1(d),phi2(d));
}
void GMap2::sewFaces(Dart d, Dart e)
{
phi2sew(d, e);
......@@ -384,45 +384,6 @@ void GMap2::closeMap(DartMarker& marker)
}
}
//DartMarker GMap2::markCCOrientation(Dart d)
//{
// // lock a marker
// DartMarker markCC(*this);
//
// // init algo with parameter dart
// std::list<Dart> darts_list;
// darts_list.push_back(d);
// markCC.mark(d);
//
// // use iterator for begin of not yet treated darts
// std::list<Dart>::iterator beg = darts_list.begin();
//
// // until all darts treated
// while (beg != darts_list.end())
// {
// Dart d1 = *beg;
// // add phi<1> and phi<2> successor if they are not yet marked
// Dart d2 = beta2(beta0(d1));
// Dart d3 = beta1(beta0(d1));
//
// if (!markCC.isMarked(d2))
// {
// darts_list.push_back(d2);
// markCC.mark(d2);
//// markCC.mark(beta0(d2));
// }
// if (!markCC.isMarked(d3))
// {
// darts_list.push_back(d3);
// markCC.mark(d3);
//// markCC.mark(beta0(d3));
// }
// // step to next dart of list
// beg++;
// }
// return markCC;
//}
/*! @name Topological Queries
* Return or set various topological information
*************************************************************************/
......@@ -452,6 +413,30 @@ bool GMap2::sameVertex(Dart d, Dart e)
return false; // None is equal to e => vertices are distinct
}
unsigned int GMap2::vertexDegree(Dart d)
{
unsigned int count = 0 ;
Dart dNext = d ;
do
{
++count ;
dNext = alpha1(dNext) ;
} while (dNext != d) ;
return count ;
}
bool GMap2::isBoundaryVertex(Dart d)
{
Dart dNext = d ;
do
{
if(beta2(dNext) == dNext)
return true ;
dNext = alpha1(dNext) ;
} while (dNext != d) ;
return false ;
}
bool GMap2::sameOrientedVolume(Dart d, Dart e)
{
DartMarkerStore mark(*this); // Lock a marker
......@@ -514,30 +499,6 @@ bool GMap2::sameVolume(Dart d, Dart e)
return false;
}
unsigned int GMap2::vertexDegree(Dart d)
{
unsigned int count = 0 ;
Dart dNext = d ;
do
{
++count ;
dNext = alpha1(dNext) ;
} while (dNext != d) ;
return count ;
}
bool GMap2::isBoundaryVertex(Dart d)
{
Dart dNext = d ;
do
{
if(beta2(dNext) == dNext)
return true ;
dNext = alpha1(dNext) ;
} while (dNext != d) ;
return false ;
}
bool GMap2::check()
{
CGoGNout << "Check: topology begin" << CGoGNendl;
......
......@@ -28,7 +28,11 @@
namespace CGoGN
{
void GMap3::deleteOrientedVolume(Dart d)
/*! @name Generator and Deletor
* To generate or delete volumes in a 3-map
*************************************************************************/
void GMap3::deleteVolume(Dart d)
{
DartMarkerStore mark(*this); // Lock a marker
bool found = false; // Last functor return value
......@@ -71,61 +75,9 @@ void GMap3::deleteOrientedVolume(Dart d)
GMap1::deleteFace(*face);
}
void GMap3::sewVolumes(Dart d, Dart e)
{
assert(faceDegree(d) == faceDegree(e));
Dart fitD = d ;
Dart fitE = e ;
do
{
phi3sew(fitD,fitE);
fitD = phi1(fitD) ;
fitE = phi_1(fitE) ;
} while(fitD != d) ;
}
void GMap3::unsewVolumes(Dart d)
{
Dart fitD = d;
do
{
phi3unsew(fitD);
fitD = phi1(fitD);
} while(fitD != d);
}
bool GMap3::mergeVolumes(Dart d)
{
Dart e = phi3(d) ;
if(e != d)
{
unsewVolumes(d);
GMap2::mergeVolumes(d, e); // merge the two volumes along common face
return true ;
}
return false ;
}
void GMap3::splitFace(Dart d, Dart e)
{
GMap2::splitFace(d,e);
if (phi3(d) != d)
{
Dart dd = phi1(phi3(d));
Dart ee = phi1(phi3(e));
GMap2::splitFace(dd,ee);
phi3sew(phi_1(d), phi_1(ee));
phi3sew(phi_1(e), phi_1(dd));
}
}
/*! @name Topological Operators
* Topological operations on 3-maps
*************************************************************************/
void GMap3::cutEdge(Dart d)
{
......@@ -167,120 +119,20 @@ void GMap3::cutEdge(Dart d)
}
}
int GMap3::collapseEdge(Dart d, bool delDegenerateFaces,
bool delDegenerateVolumes)
{
Dart e = d;
int i = 0;
//stocke un brin par volume autour de l'arete
std::list<Dart> tmp;
do
{
tmp.push_back(e);
e = alpha2(e);
i++;
} while (e != d);
for (std::list<Dart>::iterator it = tmp.begin(); it != tmp.end(); ++it)
{
Dart e = phi2(*it);
cutSpike(e);
Dart t1=e,t2=e;
//si les faces opposées ont un tetraedre cousu
if(phi3(phi2(phi1(e))) != phi2(phi1(e))) {
t1 = phi3(phi2(phi1(e)));
unsewVolumes(t1);
}
if(phi3(phi2(phi_1(e))) != phi2(phi_1(e))) {
t2 = phi3(phi2(phi_1(e)));
unsewVolumes(t2);
}
if(t1 != e && t2 != e) {
sewVolumes(t1,t2);
}
//unsewVolumes(e);
//unsewVolumes(*it);
deleteOrientedVolume(*it);
}
return i;
}
//TODO
void GMap3::collapseFace(Dart d, bool delDegenerateFaces,
bool delDegenerateVolumes)
void GMap3::splitFace(Dart d, Dart e)
{
Dart e = d;
std::list<Dart> tmp;
//save a dart from the edge for all neighbors
do
{
//if(phi3(phi2(e)) != phi2(e))
// tmp.push_back(phi3(phi2(e)));
tmp.push_back(phi3(phi2(e)));
e = phi1(e);
}while(e != d);
//del the last one (n-1 edge collapse)
tmp.pop_back();
//CGoGNout << "#voisin=" << tmp.size() << CGoGNendl;
//collapse all the edges in the list
for(std::list<Dart>::iterator it = tmp.begin() ; it != tmp.end() ; ++it)
{
Dart d = *it;
//CGoGNout << "collapseEdge" << CGoGNendl;
//collapseEdge(*it, delDegenerateFaces, delDegenerateVolumes);
//stocke un brin par volume autour de l'arete
Dart e = d;
//stocke un brin par volume autour de l'arete
std::list<Dart> tmpedge;
do
{
tmpedge.push_back(e);
e = alpha2(e);
} while (e != d);
GMap2::splitFace(d,e);
for (std::list<Dart>::iterator it = tmpedge.begin(); it != tmpedge.end(); ++it)
if (phi3(d) != d)
{
Dart e = phi2(*it);
cutSpike(e);
Dart t1=e,t2=e;
//si les faces opposées ont un tetraedre cousu
if(phi3(phi2(phi1(e))) != phi2(phi1(e))) {
t1 = phi3(phi2(phi1(e)));
unsewVolumes(t1);
}
if(phi3(phi2(phi_1(e))) != phi2(phi_1(e))) {
t2 = phi3(phi2(phi_1(e)));
unsewVolumes(t2);
}
Dart dd = phi1(phi3(d));
Dart ee = phi1(phi3(e));
if(t1 != e && t2 != e) {
sewVolumes(t1,t2);
}
GMap2::splitFace(dd,ee);
//deleteOrientedVolume(*it);
}
phi3sew(phi_1(d), phi_1(ee));
phi3sew(phi_1(e), phi_1(dd));
}
// for(std::list<Dart>::iterator it = tmp.begin() ; it != tmp.end() ; ++it)
// {
// deleteOrientedVolume(*it);
// }
}
Dart GMap3::cutSpike(Dart d)
......@@ -345,6 +197,42 @@ Dart GMap3::cutSpike(Dart d)
return dNew;
}
void GMap3::sewVolumes(Dart d, Dart e)
{
assert(faceDegree(d) == faceDegree(e));
Dart fitD = d ;
Dart fitE = e ;
do
{
phi3sew(fitD,fitE);
fitD = phi1(fitD) ;
fitE = phi_1(fitE) ;
} while(fitD != d) ;
}
void GMap3::unsewVolumes(Dart d)
{
Dart fitD = d;
do
{
phi3unsew(fitD);
fitD = phi1(fitD);
} while(fitD != d);
}
bool GMap3::mergeVolumes(Dart d)
{
Dart e = phi3(d) ;
if(e != d)
{
unsewVolumes(d);
GMap2::mergeVolumes(d, e); // merge the two volumes along common face
return true ;
}
return false ;
}
/*! @name Topological Queries
* Return or set various topological information
*************************************************************************/
......@@ -430,6 +318,91 @@ bool GMap3::sameVertex(Dart d, Dart e)
return false;
}
unsigned int GMap3::vertexDegree(Dart