Commit 86cc07a8 authored by Thomas's avatar Thomas

reorganisation code tout gmap pour coherence

parent c97d7f8d
...@@ -68,6 +68,7 @@ public: ...@@ -68,6 +68,7 @@ public:
* To generate or delete cells in a 0-G-map * To generate or delete cells in a 0-G-map
*************************************************************************/ *************************************************************************/
//@{
/** /**
* create an edge * create an edge
* @return a dart of the edge * @return a dart of the edge
...@@ -79,6 +80,7 @@ public: ...@@ -79,6 +80,7 @@ public:
* @param d a dart of the edge * @param d a dart of the edge
*/ */
void deleteEdge(Dart d); void deleteEdge(Dart d);
//@}
/*! @name Cell Functors /*! @name Cell Functors
* Apply functors to all darts of a cell * Apply functors to all darts of a cell
......
...@@ -112,6 +112,13 @@ public: ...@@ -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 //! Cut an edge inserting a new dart between d and its successor in the face
/*! @param d the edge to cut /*! @param d the edge to cut
* \image hmtl map1_cutEdge.png * \image hmtl map1_cutEdge.png
...@@ -138,15 +145,6 @@ public: ...@@ -138,15 +145,6 @@ public:
* @param e a dart in the second face * @param e a dart in the second face
*/ */
void mergeFaces(Dart d, Dart e); 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 /*! @name Topological Queries
......
...@@ -180,6 +180,14 @@ inline void GMap1::phi1unsew(Dart d) ...@@ -180,6 +180,14 @@ inline void GMap1::phi1unsew(Dart d)
* Topological operations on 1-maps * 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) inline void GMap1::cutEdge(Dart d)
{ {
Dart e = newDart(); Dart e = newDart();
...@@ -236,14 +244,6 @@ inline void GMap1::mergeFaces(Dart d, Dart e) ...@@ -236,14 +244,6 @@ inline void GMap1::mergeFaces(Dart d, Dart e)
deleteEdge(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 /*! @name Cell Functors
* Apply functors to all darts of a cell * Apply functors to all darts of a cell
*************************************************************************/ *************************************************************************/
......
...@@ -113,6 +113,20 @@ public: ...@@ -113,6 +113,20 @@ public:
*/ */
virtual bool deleteVertex(Dart d) ; 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 //! Cut the edge of d and its opposite edge if it exists
/*! @param d a dart of the edge to cut /*! @param d a dart of the edge to cut
*/ */
...@@ -151,20 +165,6 @@ public: ...@@ -151,20 +165,6 @@ public:
*/ */
virtual bool flipBackEdge(Dart d); 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 !) //! Sew two faces along an edge (pay attention to the orientation !)
/*! \pre Darts d & e MUST be fixed point of phi2 relation /*! \pre Darts d & e MUST be fixed point of phi2 relation
* @param d a dart of the first face * @param d a dart of the first face
...@@ -234,13 +234,12 @@ public: ...@@ -234,13 +234,12 @@ public:
*/ */
virtual unsigned int closeHole(Dart d); virtual unsigned int closeHole(Dart d);
// /** //! Close the map removing topological holes.
// * Mark half of dart defining an orientation /*! Add faces to the map that close every existing hole.
// * @param d a dart that belong to the orientation we want to mark * These faces are marked.
// * @return the marker which mark th orientation * \warning The embeddings of vertices are not updated
// */ * @param marker
// DartMarker markCCOrientation(Dart d); */
void closeMap(DartMarker& marker); void closeMap(DartMarker& marker);
//@} //@}
...@@ -248,6 +247,7 @@ public: ...@@ -248,6 +247,7 @@ public:
* Return or set various topological information * Return or set various topological information
*************************************************************************/ *************************************************************************/
//@{
//! Test if dart d and e belong to the same oriented vertex //! Test if dart d and e belong to the same oriented vertex
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
...@@ -260,6 +260,16 @@ public: ...@@ -260,6 +260,16 @@ public:
*/ */
bool sameVertex(Dart d, Dart e); 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 //! Test if dart d and e belong to the same oriented volume
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
...@@ -272,16 +282,6 @@ public: ...@@ -272,16 +282,6 @@ public:
*/ */
bool sameVolume(Dart d, Dart e); 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 * Check if map is complete
*/ */
......
...@@ -85,13 +85,16 @@ public: ...@@ -85,13 +85,16 @@ public:
void phi3unsew(Dart d); void phi3unsew(Dart d);
/*! @name Generator and Deletor
* To generate or delete volumes in a 3-map
*************************************************************************/
//@{ //@{
//! Delete a volume of //! Delete a volume erasing all its darts.
/*! @param d a dart of volume /*! 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 /*! @name Topological Operators
...@@ -99,6 +102,24 @@ public: ...@@ -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. //! Sew two oriented volumes along their faces.
/*! The oriented faces should not be phi3-linked and have the same length /*! The oriented faces should not be phi3-linked and have the same length
* @param d a dart of the first volume * @param d a dart of the first volume
...@@ -115,46 +136,8 @@ public: ...@@ -115,46 +136,8 @@ public:
/*! @param d a dart of common face /*! @param d a dart of common face
*/ */
bool mergeVolumes(Dart d); 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 /*! @name Topological Queries
* Return or set various topological information * Return or set various topological information
...@@ -173,7 +156,16 @@ public: ...@@ -173,7 +156,16 @@ public:
*/ */
bool sameVertex(Dart d, Dart e) ; 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 //! Test if dart d and e belong to the same oriented edge
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
...@@ -186,6 +178,11 @@ public: ...@@ -186,6 +178,11 @@ public:
*/ */
bool sameEdge(Dart d, Dart e) ; 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 //!Test if dart d and e belong to the same oriented face
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
...@@ -198,34 +195,15 @@ public: ...@@ -198,34 +195,15 @@ public:
*/ */
bool sameFace(Dart d, Dart e); 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 check();
//@}
/**
*
*/
virtual bool isBoundaryVertex(Dart d);
/*! @name Cell Functors /*! @name Cell Functors
* Apply functors to all darts of a cell * Apply functors to all darts of a cell
*************************************************************************/ *************************************************************************/
//@{ //@{
/** /**
* Apply a functor on each dart of a face * Apply a functor on each dart of a face
* @param d a dart of the face * @param d a dart of the face
......
...@@ -73,6 +73,20 @@ bool GMap2::deleteVertex(Dart d) ...@@ -73,6 +73,20 @@ bool GMap2::deleteVertex(Dart d)
return true ; 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) void GMap2::cutEdge(Dart d)
{ {
GMap1::cutEdge(d); // Cut the edge of d GMap1::cutEdge(d); // Cut the edge of d
...@@ -192,20 +206,6 @@ bool GMap2::flipBackEdge(Dart d) ...@@ -192,20 +206,6 @@ bool GMap2::flipBackEdge(Dart d)
return false ; // cannot flip a border edge 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) void GMap2::sewFaces(Dart d, Dart e)
{ {
phi2sew(d, e); phi2sew(d, e);
...@@ -384,45 +384,6 @@ void GMap2::closeMap(DartMarker& marker) ...@@ -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 /*! @name Topological Queries
* Return or set various topological information * Return or set various topological information
*************************************************************************/ *************************************************************************/
...@@ -452,6 +413,30 @@ bool GMap2::sameVertex(Dart d, Dart e) ...@@ -452,6 +413,30 @@ bool GMap2::sameVertex(Dart d, Dart e)
return false; // None is equal to e => vertices are distinct 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) bool GMap2::sameOrientedVolume(Dart d, Dart e)
{ {
DartMarkerStore mark(*this); // Lock a marker DartMarkerStore mark(*this); // Lock a marker
...@@ -514,30 +499,6 @@ bool GMap2::sameVolume(Dart d, Dart e) ...@@ -514,30 +499,6 @@ bool GMap2::sameVolume(Dart d, Dart e)
return false; 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() bool GMap2::check()
{ {
CGoGNout << "Check: topology begin" << CGoGNendl; CGoGNout << "Check: topology begin" << CGoGNendl;
......
...@@ -28,7 +28,11 @@ ...@@ -28,7 +28,11 @@
namespace CGoGN 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 DartMarkerStore mark(*this); // Lock a marker
bool found = false; // Last functor return value bool found = false; // Last functor return value
...@@ -71,61 +75,9 @@ void GMap3::deleteOrientedVolume(Dart d) ...@@ -71,61 +75,9 @@ void GMap3::deleteOrientedVolume(Dart d)
GMap1::deleteFace(*face); GMap1::deleteFace(*face);
} }
/*! @name Topological Operators
* Topological operations on 3-maps
*************************************************************************/
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 ;