Commit 5b0741d1 authored by Pierre Kraemer's avatar Pierre Kraemer

debut grosse update classes de carte...

parent ed9da781
/*******************************************************************************
* 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 ECELL_H_
#define ECELL_H_
#include <vector>
#include <map>
#include "Topology/generic/genericmap.h"
#include "Topology/generic/marker.h"
namespace CGoGN
{
/**
* ECellDart class
* Allow operation on a line of attribute in algorithm
* \warning: use a map and a container as static variable
* Use setMap and setContainer when changing the map
*
*/
template <int DIM>
class ECellDart
{
protected:
/// map (static)
static GenericMap* s_map;
///container ptr acces (static, all ECellDart)
static AttributeContainer* s_cont;
///id of cell
unsigned int m_id;
public:
/**
* constructor without container ( previous constructor must have been called once before)
* @param i index of cell
*/
ECellDart(unsigned int i);
/**
* constructor without container ( previous constructor must have be call once before)
* @param i index of cell
*/
ECellDart();
/**
* copy constructor
* @param ec the ECellDart copy
*/
ECellDart(const ECellDart<DIM>& ec);
/**
* Destructor
* Remove attributes line if tempo
*/
~ECellDart();
/**
* assign container
*/
static void setContainer(AttributeContainer& cont);
/**
* assign map
*/
static void setMap(GenericMap& map);
/**
* affect initial value to all attributes of cell
*/
void zero();
/**
* affectation operator
*/
void operator =(const ECellDart<DIM>& ec);
/**
* auto-addition operator
*/
void operator +=(const ECellDart<DIM>& ec);
/**
* auto-substraction operator
*/
void operator -=(const ECellDart<DIM>& ec);
/**
* auto-multiplication operator
*/
void operator *=(double a);
/**
* auto-division operator
*/
void operator /=(double a);
/**
* linear interpolation
*/
void lerp(const ECellDart<DIM>& ec1, const ECellDart<DIM>& ec2, double a);
/**
* + operator return a new ECellDart<DIM> (temporary)
*/
ECellDart<DIM> operator +(const ECellDart<DIM>& ec);
/**
* - operator return a new ECellDart<DIM> (temporary)
*/
ECellDart<DIM> operator -(const ECellDart<DIM>& ec);
/**
* * operator return a new ECellDart<DIM> (temporary)
*/
ECellDart<DIM> operator *(double a);
/**
* / operator return a new ECellDart<DIM> (temporary)
*/
ECellDart<DIM> operator /(double a);
/**
* fake [] operator in fact call the constructor
* allow to consider ECell as a vector of itself !
*/
ECellDart<DIM> operator[](Dart d);
/**
* fake at operator in fact call the constructor
* allow to consider ECell as a vector of itself !
*/
ECellDart<DIM> at(unsigned int i);
// friend std::ostream& operator<<(std::ostream& s, ECellDart<DIM> e) {
// s_cont << e.output();
// return s;
// }
};
/**
* Some typedef
*/
typedef ECellDart<0> EVertex;
typedef ECellDart<1> EEdge;
typedef ECellDart<2> EFace;
typedef ECellDart<3> EVolume;
} //namespace CGoGN
#include "ecell.hpp"
#endif /* ECELL_H_ */
/*******************************************************************************
* 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 GENERIC_FUNC
#define GENERIC_FUNC
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <list>
#include <vector>
#include "Topology/generic/functor.h"
#include "Utils/marker.h"
namespace CGoGN
{
///**
//* mark darts of a cell with marker m
//* Warning: works only if any darts of vertex is already marked
//* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
//* @param MF type of Map used for traversals
//* @param d a dart of the cc
//* @param m index of the marker
//*/
//template <typename MF, typename MM>
//void markOrbitGen(int dim, typename MM::Dart d, Marker m, MM *ptr, unsigned int th=0);
//
///**
//* unmark darts of a cell with marker m
//* Warning: works only if any darts of vertex is already marked
//* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
//* @param MF type of Map used for traversals
//* @param d a dart of the cc
//* @param m index of the marker
//*/
//template <typename MF, typename MM>
//void unmarkOrbitGen(int dim, typename MM::Dart d, Marker m, MM* ptr, unsigned int th=0);
//
///**
//* execute functor for each cell
//* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
//* @param MF type of Map used for traversals
//* @param f the functor
//*/
//template <typename MF, typename MM>
//void foreach_orbitGen(int dim, FunctorType<typename MM>& fonct, MM* ptr, unsigned int th=0);
//
//template <typename MF, typename MM>
//void foreach_orbitGen_sel(int dim, FunctorType<typename MM>& fonct, MM* ptr, FunctorType<typename MM>& good, unsigned int th=0);
//
///**
//* Associate an embedding to all darts of a vertex
//* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
//* @param MF type of Map used for traversals
//* @param d a dart of the topological vertex
//* @param index the index of Embedding to use
//* @param em the embedding to associate
//* ptr an ptr on the Map
//*/
//template <typename MF, typename MM>
//void setOrbitEmbeddingGen(int dim, typename MM::Dart d, int index, Embedding* em, MM* ptr, unsigned int th=0);
/**
* execute functor for each cell
* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
* @param MF type of Map used for traversals
* @param f the functor
*/
//template <typename MAP, typename TRAV>
//bool foreach_dart_of_orbit_gen(unsigned int orbit, Dart d, FunctorType& f, MAP *ptrMap, unsigned int thread=0)
//{
// switch(orbit)
// {
// case DART: return f(d);
// case VERTEX: return ptrMap->TRAV::foreach_dart_of_vertex(d, f,thread);
// case EDGE: return ptrMap->TRAV::foreach_dart_of_edge(d, f,thread);
// case FACE: return ptrMap->TRAV::foreach_dart_of_face(d, f,thread);
// case VOLUME: return ptrMap->TRAV::foreach_dart_of_volume(d, f, thread);
//// case -1: return foreach_dart_of_cc(d,f,thread);
// default: assert(!"Cells of this dimension are not handled");
// }
// return false;
//}
} //namespace CGoGN
//#include "Topology/generic/genericFunc.hpp"
#endif
......@@ -47,20 +47,6 @@
namespace CGoGN
{
/**
* Class that allows to browse a map
* This is a pure virtual class that can be overloaded in:
* - a MapBrowserSelector
* - a MapBrowserLinked (Attr or Auto)
*/
//class MapBrowser
//{
//public:
// virtual Dart begin() const = 0;
// virtual Dart end() const = 0;
// virtual void next(Dart& d) const = 0;
//};
class AttributeHandlerGen ;
class DartMarkerGen ;
class CellMarkerGen ;
......@@ -80,11 +66,6 @@ class GenericMap
protected:
/**
* @brief current MapBrowser used to traverse the map
*/
// MapBrowser* m_currentBrowser;
/**
* Attributes Containers
*/
......@@ -181,7 +162,6 @@ public:
virtual unsigned int dimension() const = 0 ;
// static const unsigned int DIMENSION = 0 ;
/**
* Clear the map
* @param removeAttrib
......@@ -196,12 +176,6 @@ public:
template <unsigned int ORBIT>
MarkSet& getMarkerSet(unsigned int thread = 0) { return m_marksets[ORBIT][thread]; }
// /**
// * @brief set the current MapBrowser
// * @param mb pointer on MapBrowser to use (default is map itself)
// */
// void setBrowser(MapBrowser* mb) { m_currentBrowser = mb; }
/****************************************
* RESOLUTION LEVELS MANAGEMENT *
****************************************/
......@@ -722,13 +696,6 @@ public:
* DARTS TRAVERSALS *
****************************************/
// Dart realBegin() const;
// Dart realEnd() const;
// void realNext(Dart& d) const;
/**
* Begin of map
* @return the first dart of the map
......@@ -820,8 +787,6 @@ public:
protected:
/// boundary markers
// Mark m_boundaryMarker2 ;
// Mark m_boundaryMarker3 ;
Mark m_boundaryMarkers[2] ; // 0 for dim 2 / 1 for dim 3
/**
......
......@@ -22,139 +22,101 @@
* *
*******************************************************************************/
namespace CGoGN
{
template <int DIM>
ECellDart<DIM>::ECellDart(unsigned int i): m_id(i)
{
s_cont->refLine(m_id);
}
template <int DIM>
ECellDart<DIM>::ECellDart()
{
m_id = s_cont->insertLine(); /*CGoGNout << "NEW CELL "<< m_id<< CGoGNendl;*/
}
template <int DIM>
ECellDart<DIM>::ECellDart(const ECellDart<DIM>& ec)
{
m_id = ec.m_id;
s_cont->refLine(m_id);
}
template <int DIM>
ECellDart<DIM>::~ECellDart()
{
s_cont->unrefLine(m_id);
}
template <int DIM>
void ECellDart<DIM>::setContainer(AttributeContainer& cont)
{
s_cont = &cont;
}
template <int DIM>
void ECellDart<DIM>::setMap(GenericMap& map)
{
s_map = &map;
}
template <int DIM>
void ECellDart<DIM>::zero()
{
s_cont->initLine(m_id);
}
template <int DIM>
void ECellDart<DIM>::operator =(const ECellDart<DIM>& ec)
{
s_cont->affect(m_id,ec.m_id);
}
#ifndef __MAP_MONO__
#define __MAP_MONO__
template <int DIM>
void ECellDart<DIM>::operator +=(const ECellDart<DIM>& ec)
{
s_cont->add(m_id,ec.m_id);
}
template <int DIM>
void ECellDart<DIM>::operator -=(const ECellDart<DIM>& ec)
{
s_cont->sub(m_id,ec.m_id);
}
template <int DIM>
void ECellDart<DIM>::operator *=(double a)
{
s_cont->mult(m_id,a);
}
template <int DIM>
void ECellDart<DIM>::operator /=(double a)
{
s_cont->div(m_id,a);
}
template <int DIM>
void ECellDart<DIM>::lerp(const ECellDart<DIM>& ec1, const ECellDart<DIM>& ec2, double a)
{
s_cont->lerp(m_id, ec1.m_id, ec2.m_id, a);
}
#include "attribmap.h"
template <int DIM>
ECellDart<DIM> ECellDart<DIM>::operator +(const ECellDart<DIM>& ec)
{
ECellDart<DIM> x;
s_cont->affect(x.m_id, m_id);
s_cont->add(x.m_id, ec.m_id);
return x;
}
template <int DIM>
ECellDart<DIM> ECellDart<DIM>::operator -(const ECellDart<DIM>& ec)
{
ECellDart<DIM> x;
s_cont->affect(x.m_id, m_id);
s_cont->sub(x.m_id, ec.m_id);
return x;
}
template <int DIM>
ECellDart<DIM> ECellDart<DIM>::operator *(double a)
{
ECellDart<DIM> x;
s_cont->affect(x.m_id, m_id);
s_cont->mult(x.m_id,a);
return x;
}
template <int DIM>
ECellDart<DIM> ECellDart<DIM>::operator /(double a)
{
ECellDart<DIM> x;
s_cont->affect(x.m_id, m_id);
s_cont->div(x.m_id, a);
return x;
}
template <int DIM>
ECellDart<DIM> ECellDart<DIM>::operator[](Dart d)
namespace CGoGN
{
unsigned int a = s_map->getEmbedding(d,DIM);
if (a == EMBNULL)
a = s_map->setOrbitEmbeddingOnNewCell(DIM, d);
return ECellDart<DIM>(a);
}
template <int DIM>
ECellDart<DIM> ECellDart<DIM>::at(unsigned int i)
{
return ECellDart<DIM>(i);
}
class MapMono : public AttribMap
{
protected:
std::vector<AttributeMultiVector<Dart>*> m_permutation;
std::vector<AttributeMultiVector<Dart>*> m_permutation_inv;
std::vector<AttributeMultiVector<Dart>*> m_involution;
virtual Dart newDart()
{
}
void addInvolution()
{
std::stringstream sstm;
sstm << "involution_" << m_involution.size();
m_involution.push_back(addRelation(sstm.str()));
}
void addPermutation()
{
std::stringstream sstm;
sstm << "permutation_" << m_permutation.size();
m_permutation.push_back(addRelation(sstm.str()));
std::stringstream sstm2;
sstm2 << "permutation_inv_" << m_permutation_inv.size();
m_permutation_inv.push_back(addRelation(sstm2.str()));
}
template <int I>
Dart getInvolution(Dart d)
{
return (*m_involution[I])[d.index];
}
template <int I>
Dart getPermutation(Dart d)
{
return (*m_permutation[I])[d.index];
}
template <int I>
Dart getPermutationInv(Dart d)
{
return (*m_permutation_inv[I])[d.index];
}
template <int I>
void permutationSew(Dart d, Dart e)
{
Dart f = (*m_permutation[I])[d.index] ;
Dart g = (*m_permutation[I])[e.index] ;
(*m_permutation[I])[d.index] = g ;
(*m_permutation[I])[e.index] = f ;
(*m_permutation_inv[I])[g.index] = d ;
(*m_permutation_inv[I])[f.index] = e ;
}
template <int I>
void permutationUnsew(Dart d)
{
Dart e = (*m_permutation[I])[d.index] ;
Dart f = (*m_permutation[I])[e.index] ;
(*m_permutation[I])[d.index] = f ;
(*m_permutation[I])[e.index] = e ;
(*m_permutation_inv[I])[f.index] = d ;
(*m_permutation_inv[I])[e.index] = e ;
}
template <int I>
void involutionSew(Dart d, Dart e)
{
assert((*m_phi2)[d.index] == d) ;
assert((*m_phi2)[e.index] == e) ;
(*m_involution[I])[d.index] = e ;
(*m_involution[I])[e.index] = d ;
}
template <int I>
void involutionUnsew(Dart d)
{
Dart e = (*m_involution[I])[d.index] ;
(*m_involution[I])[d.index] = d ;
(*m_involution[I])[e.index] = e ;
}
} ;
} //namespace CGoGN
#endif
......@@ -22,87 +22,20 @@
* *
*******************************************************************************/
#ifndef __MAP_MULTI__
#define __MAP_MULTI__
namespace CGoGN
{
#include "attribmap.h"
template <typename MF, typename MM>
void markOrbitGen(int dim, typename MM::Dart d, Marker m, unsigned int th)
{
FunctorMark<MM> f(m);
MF::foreach_dart_of_orbit(dim, d, f, th);
}
template <typename MF, typename MM>
void unmarkOrbitGen(int dim, typename MM::Dart d, Marker m, unsigned int th)
namespace CGoGN
{
FunctorUnmark<MM> f(m);
MF::foreach_dart_of_orbit(dim, d, f, th);
}
template <typename MF, typename MM>
void foreach_orbitGen_sel(int dim, FunctorType<typename MM>& f, MM* ptr, FunctorType<typename MM>& good, unsigned int th )
class MapMulti : public AttribMap
{
// lock a marker
DartMarker markerCell(*ptr,th);
// scan all dart of the map
for(typename MM::Dart d = ptr->begin(); d != ptr->end(); ptr->next(d))
{
if (good(d))
{
if (!markerCell.isMarked(d)) // if not marked
{
if ((f)(d)) // call the functor and
{
d=ptr->end();
--d;
}
else
markOrbitGen<MF,MM>(dim, d, markerCell, ptr, th); // mark all dart of the vertex
}
}
}
}
} ;
template <typename MF, typename MM>
void foreach_orbitGen(int dim, FunctorType<typename MM>& fonct, MM* ptr, unsigned int th)
{
// lock a marker
// Marker markerCell = ptr->getNewMarker();
//
// // scan all dart of the map
// for(typename MM::Dart d = ptr->begin(); d != ptr->end(); ptr->next(d))
// {
// if (!ptr->isMarkedDart(d,markerCell)) // if not marked
// {
// if ((fonct)(d)) // call the functor and
// {
// d=ptr->end();
// --d;
// }
// else
// markOrbitGen<MF,MM>(dim,d,markerCell,ptr); // mark all dart of the vertex
// }
// }
// ptr->unmarkAll(markerCell);
// ptr->releaseMarker(markerCell);
}
template <typename MF, typename MM>
void setOrbitEmbeddingGen(int dim, typename MM::Dart d, int index, Embedding* em, MM* ptr)
{
// if (em!=NULL)
// {
// FunctorSetEmb<typename MM::Dart> fse(index,em);
// ptr->foreach_dart_of_orbit(dim, d, fse);
// }
// else
// {
// FunctorUnsetEmb<typename MM::Dart> fse(index);
// ptr->foreach_dart_of_orbit(dim, d, fse);
// }
}
} //namespace CGoGN
#endif
This diff is collapsed.
......@@ -25,13 +25,14 @@
#ifndef __MAP1_H__
#define __MAP1_H__
#include "Topology/generic/attribmap.h"
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/cellmarker.h"
namespace CGoGN
{
class MapMono;
/*! \brief The class of dual 1-dimensional combinatorial maps: set of oriented faces.
* - A dual 1-map is made of darts linked by the phi1 permutation.
* - In this class darts are interpreted as oriented edges.
......@@ -40,13 +41,18 @@ namespace CGoGN
* - Faces with only one edge (sometime called loops) are accepted.
* - Degenerated faces with only two edges are accepted.
*/
class Map1 : public AttribMap