Commit b066d4a5 authored by Pierre Kraemer's avatar Pierre Kraemer

deplacement fonctions .cpp -> .hpp

parent 7594d4f2
...@@ -88,6 +88,8 @@ protected: ...@@ -88,6 +88,8 @@ protected:
template <int I> template <int I>
inline void involutionUnsew(Dart d); inline void involutionUnsew(Dart d);
inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/**************************************** /****************************************
* DARTS TRAVERSALS * * DARTS TRAVERSALS *
****************************************/ ****************************************/
......
...@@ -126,6 +126,31 @@ inline void MapMono::involutionUnsew(Dart d) ...@@ -126,6 +126,31 @@ inline void MapMono::involutionUnsew(Dart d)
(*m_involution[I])[e.index] = e ; (*m_involution[I])[e.index] = e ;
} }
inline void MapMono::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i))
{
for (unsigned int j = 0; j < m_permutation.size(); ++j)
{
Dart d = (*m_permutation[j])[i];
if (d.index != oldnew[d.index])
(*m_permutation[j])[i] = Dart(oldnew[d.index]);
}
for (unsigned int j = 0; j < m_permutation_inv.size(); ++j)
{
Dart d = (*m_permutation_inv[j])[i];
if (d.index != oldnew[d.index])
(*m_permutation_inv[j])[i] = Dart(oldnew[d.index]);
}
for (unsigned int j = 0; j < m_involution.size(); ++j)
{
Dart d = (*m_involution[j])[i];
if (d.index != oldnew[d.index])
(*m_involution[j])[i] = Dart(oldnew[d.index]);
}
}
}
/**************************************** /****************************************
* DARTS TRAVERSALS * * DARTS TRAVERSALS *
****************************************/ ****************************************/
......
...@@ -151,6 +151,8 @@ protected: ...@@ -151,6 +151,8 @@ protected:
template <int I> template <int I>
inline void involutionUnsew(Dart d); inline void involutionUnsew(Dart d);
inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/**************************************** /****************************************
* MR CONTAINER MANAGEMENT * * MR CONTAINER MANAGEMENT *
****************************************/ ****************************************/
......
...@@ -34,12 +34,12 @@ namespace CGoGN ...@@ -34,12 +34,12 @@ namespace CGoGN
* Class of 2-dimensional G-maps * Class of 2-dimensional G-maps
* with managed embeddings * with managed embeddings
*/ */
class EmbeddedGMap2 : public GMap2 class EmbeddedGMap2 : public GMap2<MapMono>
{ {
public: public:
typedef GMap2 TOPO_MAP; typedef GMap2<MapMono> TOPO_MAP;
static const unsigned int DIMENSION = 2 ; static const unsigned int DIMENSION = TOPO_MAP::DIMENSION ;
/** /**
* create a new face with managed embeddings * create a new face with managed embeddings
......
...@@ -34,12 +34,12 @@ namespace CGoGN ...@@ -34,12 +34,12 @@ namespace CGoGN
* Class of 3-dimensional G-maps * Class of 3-dimensional G-maps
* with managed embeddings * with managed embeddings
*/ */
class EmbeddedGMap3 : public GMap3 class EmbeddedGMap3 : public GMap3<MapMono>
{ {
public: public:
typedef GMap3 TOPO_MAP; typedef GMap3<MapMono> TOPO_MAP;
static const unsigned int DIMENSION = 3 ; static const unsigned int DIMENSION = TOPO_MAP::DIMENSION ;
/*! /*!
* *
......
...@@ -55,14 +55,10 @@ public: ...@@ -55,14 +55,10 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
virtual Dart newDart();
Dart beta0(const Dart d) const; Dart beta0(const Dart d) const;
void beta0sew(Dart d, Dart e); void beta0sew(Dart d, Dart e);
......
...@@ -73,19 +73,39 @@ inline void GMap0<MAP>::update_topo_shortcuts() ...@@ -73,19 +73,39 @@ inline void GMap0<MAP>::update_topo_shortcuts()
template <class MAP> template <class MAP>
inline Dart GMap0<MAP>::beta0(Dart d) const inline Dart GMap0<MAP>::beta0(Dart d) const
{ {
return MAP::getInvolution<0>(d); return MAP::template getInvolution<0>(d);
} }
template <class MAP> template <class MAP>
inline void GMap0<MAP>::beta0sew(Dart d, Dart e) inline void GMap0<MAP>::beta0sew(Dart d, Dart e)
{ {
MAP::involutionSew<0>(d,e); MAP::template involutionSew<0>(d,e);
} }
template <class MAP> template <class MAP>
inline void GMap0<MAP>::beta0unsew(Dart d) inline void GMap0<MAP>::beta0unsew(Dart d)
{ {
MAP::involutionUnsew<0>(d); MAP::template involutionUnsew<0>(d);
}
/*! @name Constructors and Destructors
* To generate or delete edges in a 0-G-map
*************************************************************************/
template <class MAP>
Dart GMap0<MAP>::newEdge()
{
Dart d1 = this->newDart();
Dart d2 = this->newDart();
beta0sew(d1,d2);
return d1;
}
template <class MAP>
void GMap0<MAP>::deleteEdge(Dart d)
{
this->deleteDart(beta0(d));
this->deleteDart(d);
} }
/*! @name Cell Functors /*! @name Cell Functors
......
...@@ -54,8 +54,6 @@ public: ...@@ -54,8 +54,6 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
...@@ -94,12 +92,6 @@ public: ...@@ -94,12 +92,6 @@ public:
*/ */
Dart newCycle(unsigned int nbEdges); Dart newCycle(unsigned int nbEdges);
//! Create an new face for boundary (marked)
/*! @param nbEdges the number of edges
* @return return a dart of the face
*/
// Dart newBoundaryCycle(unsigned int nbEdges);
//! Delete a face erasing all its darts //! Delete a face erasing all its darts
/*! @param d a dart of the face /*! @param d a dart of the face
*/ */
......
...@@ -71,7 +71,7 @@ inline void GMap1<MAP>::update_topo_shortcuts() ...@@ -71,7 +71,7 @@ inline void GMap1<MAP>::update_topo_shortcuts()
template <class MAP> template <class MAP>
inline Dart GMap1<MAP>::beta1(Dart d) const inline Dart GMap1<MAP>::beta1(Dart d) const
{ {
return MAP::getInvolution<1>(d); return MAP::template getInvolution<1>(d);
} }
template <class MAP> template <class MAP>
...@@ -105,7 +105,7 @@ inline Dart GMap1<MAP>::phi1(Dart d) const ...@@ -105,7 +105,7 @@ inline Dart GMap1<MAP>::phi1(Dart d) const
template <class MAP> template <class MAP>
inline Dart GMap1<MAP>::phi_1(Dart d) const inline Dart GMap1<MAP>::phi_1(Dart d) const
{ {
return beta0(beta1(d)) ; return this->beta0(beta1(d)) ;
} }
template <class MAP> template <class MAP>
...@@ -143,13 +143,47 @@ inline Dart GMap1<MAP>::alpha_1(Dart d) const ...@@ -143,13 +143,47 @@ inline Dart GMap1<MAP>::alpha_1(Dart d) const
template <class MAP> template <class MAP>
inline void GMap1<MAP>::beta1sew(Dart d, Dart e) inline void GMap1<MAP>::beta1sew(Dart d, Dart e)
{ {
MAP::involutionSew<1>(d,e); MAP::template involutionSew<1>(d,e);
} }
template <class MAP> template <class MAP>
inline void GMap1<MAP>::beta1unsew(Dart d) inline void GMap1<MAP>::beta1unsew(Dart d)
{ {
MAP::involutionUnsew<1>(d); MAP::template involutionUnsew<1>(d);
}
/*! @name Constructors and Destructors
* To generate or delete faces in a 1-G-map
*************************************************************************/
template <class MAP>
Dart GMap1<MAP>::newCycle(unsigned int nbEdges)
{
assert(nbEdges > 0 || !"Cannot create a face with no edge") ;
Dart d0 = ParentMap::newEdge(); // create the first edge
Dart dp = this->beta0(d0); // store an extremity
for (unsigned int i = 1; i < nbEdges; ++i)
{
Dart di = ParentMap::newEdge(); // create the next edge
beta1sew(dp,di);
dp = this->beta0(di); // change the preceding
}
beta1sew(dp,d0); // sew the last with the first
return d0;
}
template <class MAP>
void GMap1<MAP>::deleteCycle(Dart d)
{
Dart e = phi1(d);
while (e != d)
{
Dart f = phi1(e);
this->deleteEdge(e);
e = f;
}
this->deleteEdge(d);
} }
/*! @name Topological Operators /*! @name Topological Operators
......
...@@ -61,8 +61,6 @@ public: ...@@ -61,8 +61,6 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
This diff is collapsed.
...@@ -67,8 +67,6 @@ public: ...@@ -67,8 +67,6 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
This diff is collapsed.
...@@ -59,8 +59,6 @@ public: ...@@ -59,8 +59,6 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
...@@ -107,12 +105,6 @@ public: ...@@ -107,12 +105,6 @@ public:
*/ */
Dart newCycle(unsigned int nbEdges) ; Dart newCycle(unsigned int nbEdges) ;
//! Create an new face for boundary (marked)
/*! @param nbEdges the number of edges
* @return return a dart of the face
*/
// Dart newBoundaryCycle(unsigned int nbEdges);
//! Delete an oriented face erasing all its darts //! Delete an oriented face erasing all its darts
/*! @param d a dart of the face /*! @param d a dart of the face
*/ */
......
...@@ -127,6 +127,33 @@ inline void Map1<MAP>::phi1unsew(Dart d) ...@@ -127,6 +127,33 @@ inline void Map1<MAP>::phi1unsew(Dart d)
MAP::permutationUnsew<0>(d); MAP::permutationUnsew<0>(d);
} }
/*! @name Generator and Deletor
* To generate or delete faces in a 1-map
*************************************************************************/
template <class MAP>
Dart Map1<MAP>::newCycle(unsigned int nbEdges)
{
assert(nbEdges > 0 || !"Cannot create a face with no edge") ;
Dart d = this->newDart() ; // Create the first edge
for (unsigned int i = 1 ; i < nbEdges ; ++i)
Map1<MAP>::cutEdge(d) ; // Subdivide nbEdges-1 times this edge
return d ;
}
template <class MAP>
void Map1<MAP>::deleteCycle(Dart d)
{
Dart e = phi1(d) ;
while (e != d)
{
Dart f = phi1(e) ;
this->deleteDart(e) ;
e = f ;
}
this->deleteDart(d) ;
}
/*! @name Topological Operators /*! @name Topological Operators
* Topological operations on 1-maps * Topological operations on 1-maps
*************************************************************************/ *************************************************************************/
...@@ -134,14 +161,14 @@ inline void Map1<MAP>::phi1unsew(Dart d) ...@@ -134,14 +161,14 @@ inline void Map1<MAP>::phi1unsew(Dart d)
template <class MAP> template <class MAP>
inline Dart Map1<MAP>::cutEdge(Dart d) inline Dart Map1<MAP>::cutEdge(Dart d)
{ {
Dart e = MAP::newDart() ; // Create a new dart Dart e = this->newDart() ; // Create a new dart
phi1sew(d, e) ; // Insert dart e between d and phi1(d) phi1sew(d, e) ; // Insert dart e between d and phi1(d)
if (this->isBoundaryMarked2(d)) if (this->isBoundaryMarked2(d))
MAP::boundaryMark2(e); this->boundaryMark2(e);
if (MAP::isBoundaryMarked3(d)) if (this->isBoundaryMarked3(d))
MAP::boundaryMark3(e); this->boundaryMark3(e);
return e ; return e ;
} }
...@@ -151,14 +178,14 @@ inline void Map1<MAP>::uncutEdge(Dart d) ...@@ -151,14 +178,14 @@ inline void Map1<MAP>::uncutEdge(Dart d)
{ {
Dart d1 = phi1(d) ; Dart d1 = phi1(d) ;
phi1unsew(d) ; // Dart d is linked to the successor of its successor phi1unsew(d) ; // Dart d is linked to the successor of its successor
MAP::deleteDart(d1) ; // Dart d1 is erased this->deleteDart(d1) ; // Dart d1 is erased
} }
template <class MAP> template <class MAP>
inline void Map1<MAP>::collapseEdge(Dart d) inline void Map1<MAP>::collapseEdge(Dart d)
{ {
phi1unsew(phi_1(d)) ; // Dart before d is linked to its successor phi1unsew(phi_1(d)) ; // Dart before d is linked to its successor
MAP::deleteDart(d) ; // Dart d is erased this->deleteDart(d) ; // Dart d is erased
} }
template <class MAP> template <class MAP>
...@@ -184,6 +211,25 @@ inline void Map1<MAP>::linkCycles(Dart d, Dart e) ...@@ -184,6 +211,25 @@ inline void Map1<MAP>::linkCycles(Dart d, Dart e)
phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts
} }
template <class MAP>
void Map1<MAP>::reverseCycle(Dart d)
{
Dart e = phi1(d) ; // Dart e is the first edge of the new face
if (e == d) return ; // Only one edge: nothing to do
if (phi1(e) == d) return ; // Only two edges: nothing to do
phi1unsew(d) ; // Detach e from the face of d
Dart dNext = phi1(d) ; // While the face of d contains more than two edges
while (dNext != d)
{
phi1unsew(d) ; // Unsew the edge after d
phi1sew(e, dNext) ; // Sew it after e (thus in reverse order)
dNext = phi1(d) ;
}
phi1sew(e, d) ; // Sew the last edge
}
/*! @name Topological Queries /*! @name Topological Queries
* Return or set various topological information * Return or set various topological information
*************************************************************************/ *************************************************************************/
......
...@@ -73,8 +73,6 @@ public: ...@@ -73,8 +73,6 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
...@@ -116,8 +114,7 @@ protected: ...@@ -116,8 +114,7 @@ protected:
void phi2unsew(Dart d); void phi2unsew(Dart d);
public: public:
// void rdfi(Dart t, DartMarker& m1, DartMarker& m2);
void rdfi(Dart t, DartMarker& m1, DartMarker& m2);
//void propagateDartRelation(Dart d) ; //void propagateDartRelation(Dart d) ;
...@@ -352,12 +349,6 @@ public: ...@@ -352,12 +349,6 @@ public:
*/ */
Dart findBoundaryEdgeOfVertex(Dart d) const; Dart findBoundaryEdgeOfVertex(Dart d) const;
/**
* find the dart of edge that belong to the boundary
* return NIL if the face is not on the boundary
*/
Dart findBoundaryEdgeOfFace(Dart d) const;
//! Test if dart d and e belong to the same edge //! Test if dart d and e belong to the same edge
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
...@@ -398,6 +389,12 @@ public: ...@@ -398,6 +389,12 @@ public:
*/ */
bool isBoundaryFace(Dart d) const; bool isBoundaryFace(Dart d) const;
/**
* find the dart of edge that belong to the boundary
* return NIL if the face is not on the boundary
*/
Dart findBoundaryEdgeOfFace(Dart d) const;
//! 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
......
This diff is collapsed.
...@@ -81,8 +81,6 @@ public: ...@@ -81,8 +81,6 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -582,13 +582,13 @@ bool EmbeddedGMap2::check() ...@@ -582,13 +582,13 @@ bool EmbeddedGMap2::check()
CGoGNout << "Check: embedding ok" << CGoGNendl ; CGoGNout << "Check: embedding ok" << CGoGNendl ;
std::cout << "nb vertex orbits : " << getNbOrbits<VERTEX>() << std::endl ; std::cout << "nb vertex orbits : " << getNbOrbits<EmbeddedGMap2, VERTEX>() << std::endl ;
std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ; std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ;
std::cout << "nb edge orbits : " << getNbOrbits<EDGE>() << std::endl ; std::cout << "nb edge orbits : " << getNbOrbits<EmbeddedGMap2, EDGE>() << std::endl ;
std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ; std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ;
std::cout << "nb face orbits : " << getNbOrbits<FACE>() << std::endl ; std::cout << "nb face orbits : " << getNbOrbits<EmbeddedGMap2, FACE>() << std::endl ;
std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ; std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ;
return true ; return true ;
......
...@@ -461,16 +461,16 @@ bool EmbeddedGMap3::check() ...@@ -461,16 +461,16 @@ bool EmbeddedGMap3::check()
CGoGNout << "Check: embedding ok" << CGoGNendl ; CGoGNout << "Check: embedding ok" << CGoGNendl ;
std::cout << "nb vertex orbits : " << getNbOrbits<VERTEX>() << std::endl ; std::cout << "nb vertex orbits : " << getNbOrbits<EmbeddedGMap3, VERTEX>() << std::endl ;
std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ; std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ;
std::cout << "nb edge orbits : " << getNbOrbits<EDGE>() << std::endl ; std::cout << "nb edge orbits : " << getNbOrbits<EmbeddedGMap3, EDGE>() << std::endl ;
std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ; std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ;
std::cout << "nb face orbits : " << getNbOrbits<FACE>() << std::endl ; std::cout << "nb face orbits : " << getNbOrbits<EmbeddedGMap3, FACE>() << std::endl ;
std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ; std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ;
std::cout << "nb volume orbits : " << getNbOrbits<VOLUME>() << std::endl ; std::cout << "nb volume orbits : " << getNbOrbits<EmbeddedGMap3, VOLUME>() << std::endl ;
std::cout << "nb volume cells : " << m_attribs[VOLUME].size() << std::endl ; std::cout << "nb volume cells : " << m_attribs[VOLUME].size() << std::endl ;