Commit b066d4a5 authored by Pierre Kraemer's avatar Pierre Kraemer

deplacement fonctions .cpp -> .hpp

parent 7594d4f2
......@@ -88,6 +88,8 @@ protected:
template <int I>
inline void involutionUnsew(Dart d);
inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/****************************************
* DARTS TRAVERSALS *
****************************************/
......
......@@ -126,6 +126,31 @@ inline void MapMono::involutionUnsew(Dart d)
(*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 *
****************************************/
......
......@@ -151,6 +151,8 @@ protected:
template <int I>
inline void involutionUnsew(Dart d);
inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/****************************************
* MR CONTAINER MANAGEMENT *
****************************************/
......
......@@ -34,12 +34,12 @@ namespace CGoGN
* Class of 2-dimensional G-maps
* with managed embeddings
*/
class EmbeddedGMap2 : public GMap2
class EmbeddedGMap2 : public GMap2<MapMono>
{
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
......
......@@ -34,12 +34,12 @@ namespace CGoGN
* Class of 3-dimensional G-maps
* with managed embeddings
*/
class EmbeddedGMap3 : public GMap3
class EmbeddedGMap3 : public GMap3<MapMono>
{
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:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
virtual Dart newDart();
Dart beta0(const Dart d) const;
void beta0sew(Dart d, Dart e);
......
......@@ -73,19 +73,39 @@ inline void GMap0<MAP>::update_topo_shortcuts()
template <class MAP>
inline Dart GMap0<MAP>::beta0(Dart d) const
{
return MAP::getInvolution<0>(d);
return MAP::template getInvolution<0>(d);
}
template <class MAP>
inline void GMap0<MAP>::beta0sew(Dart d, Dart e)
{
MAP::involutionSew<0>(d,e);
MAP::template involutionSew<0>(d,e);
}
template <class MAP>
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
......
......@@ -54,8 +54,6 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......@@ -94,12 +92,6 @@ public:
*/
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
/*! @param d a dart of the face
*/
......
......@@ -71,7 +71,7 @@ inline void GMap1<MAP>::update_topo_shortcuts()
template <class MAP>
inline Dart GMap1<MAP>::beta1(Dart d) const
{
return MAP::getInvolution<1>(d);
return MAP::template getInvolution<1>(d);
}
template <class MAP>
......@@ -105,7 +105,7 @@ inline Dart GMap1<MAP>::phi1(Dart d) const
template <class MAP>
inline Dart GMap1<MAP>::phi_1(Dart d) const
{
return beta0(beta1(d)) ;
return this->beta0(beta1(d)) ;
}
template <class MAP>
......@@ -143,13 +143,47 @@ inline Dart GMap1<MAP>::alpha_1(Dart d) const
template <class MAP>
inline void GMap1<MAP>::beta1sew(Dart d, Dart e)
{
MAP::involutionSew<1>(d,e);
MAP::template involutionSew<1>(d,e);
}
template <class MAP>
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
......
......@@ -61,8 +61,6 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
This diff is collapsed.
......@@ -67,8 +67,6 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
This diff is collapsed.
......@@ -59,8 +59,6 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......@@ -107,12 +105,6 @@ public:
*/
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
/*! @param d a dart of the face
*/
......
......@@ -127,6 +127,33 @@ inline void Map1<MAP>::phi1unsew(Dart 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
* Topological operations on 1-maps
*************************************************************************/
......@@ -134,14 +161,14 @@ inline void Map1<MAP>::phi1unsew(Dart d)
template <class MAP>
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)
if (this->isBoundaryMarked2(d))
MAP::boundaryMark2(e);
this->boundaryMark2(e);
if (MAP::isBoundaryMarked3(d))
MAP::boundaryMark3(e);
if (this->isBoundaryMarked3(d))
this->boundaryMark3(e);
return e ;
}
......@@ -151,14 +178,14 @@ inline void Map1<MAP>::uncutEdge(Dart d)
{
Dart d1 = phi1(d) ;
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>
inline void Map1<MAP>::collapseEdge(Dart d)
{
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>
......@@ -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
}
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
* Return or set various topological information
*************************************************************************/
......
......@@ -73,8 +73,6 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......@@ -116,8 +114,7 @@ protected:
void phi2unsew(Dart d);
public:
void rdfi(Dart t, DartMarker& m1, DartMarker& m2);
// void rdfi(Dart t, DartMarker& m1, DartMarker& m2);
//void propagateDartRelation(Dart d) ;
......@@ -352,12 +349,6 @@ public:
*/
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
/*! @param d a dart
* @param e a dart
......@@ -398,6 +389,12 @@ public:
*/
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
/*! @param d a dart
* @param e a dart
......
This diff is collapsed.
......@@ -81,8 +81,6 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -582,13 +582,13 @@ bool EmbeddedGMap2::check()
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 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 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 ;
return true ;
......
......@@ -461,16 +461,16 @@ bool EmbeddedGMap3::check()
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 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 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 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 ;
return true ;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Topology/gmap/gmap0.h"
namespace CGoGN
{
void GMap0::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))
{
Dart& d = m_beta0->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d != e)
d = e;
}
}
/*! @name Constructors and Destructors
* To generate or delete edges in a 0-G-map
*************************************************************************/
Dart GMap0::newEdge()
{
Dart d1 = newDart();
Dart d2 = newDart();
beta0sew(d1,d2);
return d1;
}
void GMap0::deleteEdge(Dart d)
{
deleteDart(beta0(d));
deleteDart(d);
}
} // namespace CGoGN
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Topology/gmap/gmap1.h"
namespace CGoGN
{
void GMap1::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))
{
{
Dart& d = m_beta0->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d != e)
d = e;
}
{
Dart& d = m_beta1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d != e)
d = e;
}
}
}
/*! @name Constructors and Destructors
* To generate or delete faces in a 1-G-map
*************************************************************************/
Dart GMap1::newCycle(unsigned int nbEdges)
{
assert(nbEdges > 0 || !"Cannot create a face with no edge") ;
Dart d0 = GMap0::newEdge(); // create the first edge
Dart dp = beta0(d0); // store an extremity
for (unsigned int i = 1; i < nbEdges; ++i)
{
Dart di = GMap0::newEdge(); // create the next edge
beta1sew(dp,di);
dp = beta0(di); // change the preceding
}
beta1sew(dp,d0); // sew the last with the first
return d0;
}
//Dart GMap1::newBoundaryCycle(unsigned int nbEdges)
//{
// assert(nbEdges > 0 || !"Cannot create a face with no edge") ;
//
// Dart d0 = GMap0::newEdge(); // create the first edge
// boundaryMark2(d0);
// boundaryMark2(beta0(d0));
// Dart dp = beta0(d0); // store an extremity
// for (unsigned int i = 1; i < nbEdges; ++i)
// {
// Dart di = GMap0::newEdge(); // create the next edge
// boundaryMark2(di);
// boundaryMark2(beta0(di));
// beta1sew(dp,di);
// dp = beta0(di); // change the preceding
// }
// beta1sew(dp,d0); // sew the last with the first
// return d0;
//}
void GMap1::deleteCycle(Dart d)
{
Dart e = phi1(d);
while (e != d)
{
Dart f = phi1(e);
deleteEdge(e);
e = f;
}
deleteEdge(d);
}
} // namespace CGoGN
This diff is collapsed.
This diff is collapsed.