Commit 7594d4f2 authored by Pierre Kraemer's avatar Pierre Kraemer

on continue avec les gcartes

parent 630fb1fd
...@@ -29,7 +29,7 @@ namespace CGoGN ...@@ -29,7 +29,7 @@ namespace CGoGN
* DARTS MANAGEMENT * * DARTS MANAGEMENT *
****************************************/ ****************************************/
inline virtual Dart MapMono::newDart() inline Dart MapMono::newDart()
{ {
Dart d = GenericMap::newDart() ; Dart d = GenericMap::newDart() ;
...@@ -70,19 +70,19 @@ inline void MapMono::addPermutation() ...@@ -70,19 +70,19 @@ inline void MapMono::addPermutation()
} }
template <int I> template <int I>
inline Dart MapMono::getInvolution(Dart d) inline Dart MapMono::getInvolution(Dart d) const
{ {
return (*m_involution[I])[d.index]; return (*m_involution[I])[d.index];
} }
template <int I> template <int I>
inline Dart MapMono::getPermutation(Dart d) inline Dart MapMono::getPermutation(Dart d) const
{ {
return (*m_permutation[I])[d.index]; return (*m_permutation[I])[d.index];
} }
template <int I> template <int I>
inline Dart MapMono::getPermutationInv(Dart d) inline Dart MapMono::getPermutationInv(Dart d) const
{ {
return (*m_permutation_inv[I])[d.index]; return (*m_permutation_inv[I])[d.index];
} }
...@@ -112,8 +112,8 @@ inline void MapMono::permutationUnsew(Dart d) ...@@ -112,8 +112,8 @@ inline void MapMono::permutationUnsew(Dart d)
template <int I> template <int I>
inline void MapMono::involutionSew(Dart d, Dart e) inline void MapMono::involutionSew(Dart d, Dart e)
{ {
assert((*m_phi2)[d.index] == d) ; assert((*m_involution[I])[d.index] == d) ;
assert((*m_phi2)[e.index] == e) ; assert((*m_involution[I])[e.index] == e) ;
(*m_involution[I])[d.index] = e ; (*m_involution[I])[d.index] = e ;
(*m_involution[I])[e.index] = d ; (*m_involution[I])[e.index] = d ;
} }
...@@ -130,17 +130,17 @@ inline void MapMono::involutionUnsew(Dart d) ...@@ -130,17 +130,17 @@ inline void MapMono::involutionUnsew(Dart d)
* DARTS TRAVERSALS * * DARTS TRAVERSALS *
****************************************/ ****************************************/
inline virtual Dart MapMono::begin() const inline Dart MapMono::begin() const
{ {
return Dart::create(m_attribs[DART].begin()) ; return Dart::create(m_attribs[DART].begin()) ;
} }
inline virtual Dart MapMono::end() const inline Dart MapMono::end() const
{ {
return Dart::create(m_attribs[DART].end()) ; return Dart::create(m_attribs[DART].end()) ;
} }
inline virtual void MapMono::next(Dart& d) const inline void MapMono::next(Dart& d) const
{ {
m_attribs[DART].next(d.index) ; m_attribs[DART].next(d.index) ;
} }
......
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#ifndef __BASEGMAP_H__
#define __BASEGMAP_H__
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <list>
#include <vector>
#include "Topology/generic/genericmap.h"
namespace CGoGN
{
template < typename DART >
class tBaseGMap : public tGenericMap<DART>
{
public:
typedef typename tGenericMap<DART>::Dart Dart;
public:
tBaseGMap() {
}
tBaseGMap(const tBaseGMap<DART>& bm) : tGenericMap<DART>(bm) {
}
~tBaseGMap() {
while (this->begin() != this->end()) {
deleteDart(this->begin(),false);
}
}
void deleteDart(Dart d,bool warning=true) {
if (warning && !isFree(d)) {
CGoGNout << "Warning: erasing a linked dart" << CGoGNendl;
}
tGenericMap<DART>::deleteDart(d);
}
//! Test if the dart is free of topological links
/*! @param d an iterator to the current dart
*/
bool isFree(Dart d) {
for (unsigned i=0; i<DART::nbRelations(); ++i)
if (beta(i,d) != d)
return false;
return true;
}
private:
/* A set of private basic topological operators.
* Translate topological links to combinatorial links.
*/
Dart beta_internal(Dart a, int i) const
{
// assert(????() || !"Only use with gmap darts");
// ajouter qqchose dans DP pour identifier les Gcartes
assert( ((i >=0)&&(i<DART::nbInvolutions())) || "Indices out of bounds");
return a->getInvolution(i);
}
void betaSew_internal(Dart a, unsigned i, Dart d)
{
assert(i < DART::nbInvolutions() || !"Out of bounds");
if (beta_internal(a,i) != d)
{
a->setInvolution(i,d);
}
else
{
CGoGNerr << "Warning: darts already linked with beta" << i << CGoGNendl;
}
}
void betaUnsew_internal(Dart a, unsigned i)
{
assert(i < DART::nbInvolutions() || !"Out of bounds");
a->unsetInvolution(i);
}
public:
Dart beta(unsigned int i, Dart d)
{
return beta_internal(d,i);
}
void betaSew(unsigned int i, Dart d, Dart e)
{
// verification GMAP ???
betaSew_internal(d,i,e);
}
void betaUnsew(unsigned int i, Dart d)
{
// verification GMAP ???
betaUnsew_internal(d,i);
}
Dart beta0(Dart d) {
return beta(0,d);
}
Dart beta1(Dart d) {
return beta(1,d);
}
Dart beta2(Dart d) {
return beta(2,d);
}
Dart beta3(Dart d) {
return beta(3,d);
}
void beta0Sew(Dart d, Dart e) {
betaSew(0,d,e);
}
void beta1Sew(Dart d, Dart e) {
betaSew(1,d,e);
}
void beta2Sew(Dart d, Dart e) {
betaSew(2,d,e);
}
void beta3Sew(Dart d, Dart e) {
betaSew(3,d,e);
}
Dart phi(int i, const Dart d)
{
if(i >= 0)
return beta(i,beta(0,d)) ;
else
{
unsigned j = -i ;
return beta(0,beta(j,d)) ;
}
}
Dart phi1( const Dart d) {
return phi( 1,d);
}
Dart phi_1(const Dart d) {
return phi_1(d);
}
Dart phi2( const Dart d) {
return phi( 2,d);
}
Dart phi_2(const Dart d) {
return phi(-2,d);
}
Dart phi3( const Dart d) {
return phi( 3,d);
}
Dart phi_3(const Dart d) {
return phi(-3,d);
}
Dart alpha(int i, const Dart d)
{
if(i >= 0)
return beta(i,beta(DART::nbInvolutions(),d)) ;
else
{
unsigned j = -i ;
return beta(DART::nbInvolutions(),beta(i,d)) ;
}
}
Dart alpha1( const Dart d) {
return alpha( 1,d);
}
Dart alpha_1(const Dart d) {
return alpha(-1,d);
}
Dart alpha2( const Dart d) {
return alpha( 2,d);
}
Dart alpha_2(const Dart d) {
return alpha(-2,d);
}
Dart alpha3( const Dart d) {
return alpha( 3,d);
}
Dart alpha_3(const Dart d) {
return alpha(-3,d);
}
template <int N>
Dart beta(const Dart d) {
if (N<10) return beta(N,d);
return beta(N%10, beta<N/10>(d));
}
template<int I, int J>
Dart beta(const Dart d) {
return beta(J,beta(I,d));
}
template<int I,int J,int K>
Dart beta(const Dart d) {
return beta(K,beta(J,beta(I,d)));
}
template<int I,int J,int K, int L>
Dart beta(const Dart d) {
return beta(L,beta(K,beta(J,beta(I,d))));
}
template <int N>
Dart phi(const Dart d) {
assert( (N >0 ) || !"negative parameters not allowed in template multi-phi");
if (N<10) return phi(N,d);
return phi(N%10, phi<N/10>(d));
}
template<int I, int J>
Dart phi(const Dart d) {
return phi(J,phi(I,d));
}
template<int I, int J, int K>
Dart phi(const Dart d) {
return phi(K,phi(J,phi(I,d)));
}
template<int I, int J, int K , int L>
Dart phi(const Dart d) {
return phi(L,phi(K,phi(J,phi(I,d))));
}
};
} //namespace CGoGN
#endif
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __GMAP0_H__ #ifndef __GMAP0_H__
#define __GMAP0_H__ #define __GMAP0_H__
#include "Topology/generic/attribmap.h" #include "Topology/generic/mapMono.h"
#include "Topology/generic/dartmarker.h" #include "Topology/generic/dartmarker.h"
#include "Topology/generic/cellmarker.h" #include "Topology/generic/cellmarker.h"
...@@ -36,15 +36,15 @@ namespace CGoGN ...@@ -36,15 +36,15 @@ namespace CGoGN
* The class of 0-GMap * The class of 0-GMap
* Warning here we use beta instead of classic alpha * Warning here we use beta instead of classic alpha
*/ */
class GMap0 : public AttribMap template <class MAP = MapMono>
class GMap0 : public MAP
{ {
protected: protected:
AttributeMultiVector<Dart>* m_beta0 ;
void init() ; void init() ;
public: public:
GMap0(); GMap0();
static const unsigned int DIMENSION = 0 ; static const unsigned int DIMENSION = 0 ;
virtual std::string mapTypeName() const; virtual std::string mapTypeName() const;
...@@ -97,14 +97,12 @@ public: ...@@ -97,14 +97,12 @@ public:
* @param f the functor to apply * @param f the functor to apply
*/ */
bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0) const; bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0) const;
// bool foreach_dart_of_vertex(Dart d, FunctorConstType& f, unsigned int thread = 0) const;
//! Apply a functor on every dart of an edge //! Apply a functor on every dart of an edge
/*! @param d a dart of the edge /*! @param d a dart of the edge
* @param f the functor to apply * @param f the functor to apply
*/ */
bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0) const; bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0) const;
// bool foreach_dart_of_edge(Dart d, FunctorConstType& f, unsigned int thread = 0) const;
// bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0); // bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0);
//@} //@}
......
...@@ -27,85 +27,79 @@ namespace CGoGN ...@@ -27,85 +27,79 @@ namespace CGoGN
/// INLINE FUNCTIONS /// INLINE FUNCTIONS
inline void GMap0::init() template <class MAP>
inline void GMap0<MAP>::init()
{ {
m_beta0 = addRelation("beta0") ; MAP::addInvolution() ;
} }
inline GMap0::GMap0() : AttribMap() template <class MAP>
inline GMap0<MAP>::GMap0() : MAP()
{ {
init() ; init() ;
} }
inline std::string GMap0::mapTypeName() const template <class MAP>
inline std::string GMap0<MAP>::mapTypeName() const
{ {
return "GMap0"; return "GMap0";
} }
inline unsigned int GMap0::dimension() const template <class MAP>
inline unsigned int GMap0<MAP>::dimension() const
{ {
return 0; return 0;
} }
inline void GMap0::clear(bool removeAttrib) template <class MAP>
inline void GMap0<MAP>::clear(bool removeAttrib)
{ {
AttribMap::clear(removeAttrib) ; MAP::clear(removeAttrib) ;
if (removeAttrib) if (removeAttrib)
init() ; init() ;
} }
inline void GMap0::update_topo_shortcuts() template <class MAP>
inline void GMap0<MAP>::update_topo_shortcuts()
{ {
GenericMap::update_topo_shortcuts(); MAP::update_topo_shortcuts();
m_beta0 = getRelation("beta0"); // m_beta0 = getRelation("beta0");
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
inline Dart GMap0::newDart() template <class MAP>
inline Dart GMap0<MAP>::beta0(Dart d) const
{ {
Dart d = GenericMap::newDart() ; return MAP::getInvolution<0>(d);
(*m_beta0)[d.index] = d ;
return d ;
} }
inline Dart GMap0::beta0(Dart d) const template <class MAP>
inline void GMap0<MAP>::beta0sew(Dart d, Dart e)
{ {
return (*m_beta0)[d.index] ; MAP::involutionSew<0>(d,e);
} }
inline void GMap0::beta0sew(Dart d, Dart e) template <class MAP>
inline void GMap0<MAP>::beta0unsew(Dart d)
{ {
assert((*m_beta0)[d.index] == d) ; MAP::involutionUnsew<0>(d);
assert((*m_beta0)[e.index] == e) ;
(*m_beta0)[d.index] = e ;
(*m_beta0)[e.index] = d ;
}
inline void GMap0::beta0unsew(Dart d)
{
Dart e = (*m_beta0)[d.index] ;
(*m_beta0)[d.index] = d ;
(*m_beta0)[e.index] = e ;
} }
/*! @name Cell Functors /*! @name Cell Functors
* Apply functors to all darts of a cell * Apply functors to all darts of a cell
*************************************************************************/ *************************************************************************/
inline bool GMap0::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int /*thread*/) const template <class MAP>
inline bool GMap0<MAP>::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int /*thread*/) const
{ {
return f(d) ; return f(d) ;
} }
//inline bool GMap0::foreach_dart_of_vertex(Dart d, FunctorConstType& f, unsigned int /*thread*/) const template <class MAP>
//{ inline bool GMap0<MAP>::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int /*thread*/) const
// return f(d) ;
//}
inline bool GMap0::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int /*thread*/) const
{ {
if (f(d)) return true; if (f(d)) return true;
Dart d1 = beta0(d); Dart d1 = beta0(d);
...@@ -113,15 +107,4 @@ inline bool GMap0::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int /*t ...@@ -113,15 +107,4 @@ inline bool GMap0::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int /*t
return false; return false;
} }
//inline bool GMap0::foreach_dart_of_edge(Dart d, FunctorConstType& f, unsigned int /*thread*/)
//{
// if (f(d)) return true;
// Dart d1 = beta0(d);
// if (d1 != d) return f(d1);
// return false;
//}
} // namespace CGoGN } // namespace CGoGN
...@@ -33,20 +33,17 @@ namespace CGoGN ...@@ -33,20 +33,17 @@ namespace CGoGN
/** /**
* The class of 1-GMap * The class of 1-GMap
*/ */
class GMap1 : public GMap0 template <class MAP>
class GMap1 : public GMap0<MAP>
{ {
protected: protected:
AttributeMultiVector<Dart>* m_beta1 ;
void init() ; void init() ;
public: public:
typedef GMap0 ParentMap; typedef GMap0<MAP> ParentMap;
static const unsigned int DIMENSION = 1 ; static const unsigned int DIMENSION = 1 ;
GMap1(); GMap1();
virtual std::string mapTypeName() const; virtual std::string mapTypeName() const;
...@@ -63,8 +60,6 @@ public: ...@@ -63,8 +60,6 @@ public:
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
virtual Dart newDart();
Dart beta1(const Dart d) const; Dart beta1(const Dart d) const;
template <int N> template <int N>
...@@ -205,7 +200,6 @@ public: ...@@ -205,7 +200,6 @@ public:
* @param fonct functor obj ref * @param fonct functor obj ref
*/ */
bool foreach_dart_of_vertex(Dart d, FunctorType& fonct, unsigned int thread=0) const; bool foreach_dart_of_vertex(Dart d, FunctorType& fonct, unsigned int thread=0) const;
// bool foreach_dart_of_vertex(Dart d, FunctorConstType& fonct, unsigned int thread=0);
/** /**
* Apply a functor on each dart of an edge * Apply a functor on each dart of an edge
...@@ -213,7 +207,6 @@ public: ...@@ -213,7 +207,6 @@ public:
* @param fonct functor obj ref * @param fonct functor obj ref
*/