Commit e4faadd2 authored by Pierre Kraemer's avatar Pierre Kraemer

fonction generique degree(d) + applyFunctor dans les Traversors

parent 333cfee2
......@@ -35,7 +35,6 @@
#include <map>
#include <boost/thread/mutex.hpp>
#include "Container/attributeContainer.h"
#include "Topology/generic/dart.h"
......@@ -89,7 +88,7 @@ protected:
/**
* Direct access to the Dart attributes that store the orbits embeddings
* (only initialized when necessary)
* (only initialized when necessary, i.e. addEmbedding function)
*/
AttributeMultiVector<unsigned int>* m_embeddings[NB_ORBITS] ;
......@@ -114,14 +113,12 @@ protected:
/**
* Store links to created AttributeHandlers, DartMarkers and CellMarkers
*/
std::multimap<AttributeMultiVectorGen*, AttributeHandlerGen*> attributeHandlers ; // TODO think of MT (AttributeHandler creation & release are not thread safe!
std::multimap<AttributeMultiVectorGen*, AttributeHandlerGen*> attributeHandlers ; // TODO think of MT (AttributeHandler creation & release are not thread safe!)
boost::mutex attributeHandlersMutex;
std::vector<DartMarkerGen*> dartMarkers[NB_THREAD] ;
std::vector<CellMarkerGen*> cellMarkers[NB_THREAD] ;
/**
* is map a multiresolution map
*/
......@@ -170,6 +167,8 @@ public:
virtual std::string mapTypeName() const = 0 ;
virtual unsigned int dimension() const = 0 ;
/**
* Clear the map
* @param removeAttrib
......@@ -236,7 +235,6 @@ public:
// */
// AttributeMultiVector<unsigned int>* addLevel();
public:
/**
* add a resolution level in the back of the level table (use only in MRMaps)
*/
......@@ -314,7 +312,6 @@ public:
*/
void incDartLevel(Dart d) const ;
/**
* get the number of darts inserted in the given leveldart (use only in MRMaps)
*/
......@@ -685,6 +682,12 @@ public:
template <unsigned int ORBIT>
unsigned int getNbOrbits(const FunctorSelect& good = allDarts) ;
//! For an orbit of a given dimension, return the number of incident cells of an other given dimension
/*! @param d a dart
*/
template <unsigned int ORBIT, unsigned int INCIDENT>
unsigned int degree(Dart d);
protected:
/// boundary marker
Mark m_boundaryMarker ;
......
......@@ -24,6 +24,7 @@
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversorFactory.h"
namespace CGoGN
{
......@@ -611,6 +612,16 @@ unsigned int GenericMap::getNbOrbits(const FunctorSelect& good)
return fcount.getNb();
}
template <unsigned int ORBIT, unsigned int INCIDENT>
unsigned int GenericMap::degree(Dart d)
{
assert(ORBIT != INCIDENT || !"degree does not manage adjacency counting");
Traversor<GenericMap>* t = TraversorFactory<GenericMap>::createIncident(*this, d, dimension(), ORBIT, INCIDENT) ;
FunctorCount fcount ;
t->applyFunctor(fcount) ;
return fcount.getNb() ;
}
template <unsigned int ORBIT>
void GenericMap::boundaryMarkOrbit(Dart d)
{
......
......@@ -22,14 +22,11 @@
* *
*******************************************************************************/
#include "Topology/generic/traversorGen.h"
#ifndef __TRAVERSOR1_H__
#define __TRAVERSOR1_H__
#include "Topology/generic/dart.h"
#include "Topology/generic/traversorGen.h"
namespace CGoGN
{
......
......@@ -22,14 +22,11 @@
* *
*******************************************************************************/
#include "Topology/generic/traversorGen.h"
#ifndef __TRAVERSOR2_H__
#define __TRAVERSOR2_H__
#include "Topology/generic/dart.h"
#include "Topology/generic/traversorGen.h"
namespace CGoGN
{
......
......@@ -25,11 +25,11 @@
#ifndef __TRAVERSOR3_H__
#define __TRAVERSOR3_H__
#include "Topology/generic/dart.h"
#include "Topology/generic/cellmarker.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversorGen.h"
#include "Topology/generic/traversorDoO.h"
#include "Topology/generic/dart.h"
#include "Topology/generic/cellmarker.h"
namespace CGoGN
{
......
......@@ -80,7 +80,6 @@ public:
{}
};
template <typename MAP>
class TraversorF : public TraversorCell<MAP, FACE>
{
......
......@@ -153,35 +153,4 @@ void TraversorCell<MAP, ORBIT>::skip(Dart d)
cmark->mark(d) ;
}
//
//template <typename MAP, unsigned int ORBIT>
//TraversorDartsOfOrbit<MAP, ORBIT>::TraversorDartsOfOrbit(MAP& map, Dart d, unsigned int thread)
//{
// m_vd.reserve(16);
// FunctorStoreNotBoundary<MAP> fs(map, m_vd);
// map.template foreach_dart_of_orbit<ORBIT>(d, fs, thread);
// m_vd.push_back(NIL);
//}
//
//template <typename MAP, unsigned int ORBIT>
//Dart TraversorDartsOfOrbit<MAP, ORBIT>::begin()
//{
// m_current = m_vd.begin();
// return *m_current;
//}
//
//template <typename MAP, unsigned int ORBIT>
//Dart TraversorDartsOfOrbit<MAP, ORBIT>::end()
//{
// return NIL;
//}
//
//template <typename MAP, unsigned int ORBIT>
//Dart TraversorDartsOfOrbit<MAP, ORBIT>::next()
//{
// if (*m_current != NIL)
// m_current++;
// return *m_current;
//}
} // namespace CGoGN
......@@ -25,10 +25,8 @@
#ifndef __TRAVERSOR_DOO_H__
#define __TRAVERSOR_DOO_H__
#include "Topology/generic/traversorGen.h"
#include "Topology/generic/dart.h"
#include "Topology/generic/traversorGen.h"
namespace CGoGN
{
......
......@@ -25,11 +25,9 @@
#include "Topology/generic/genericmap.h"
#include "Topology/generic/functor.h"
namespace CGoGN
{
template <typename MAP, unsigned int ORBIT>
TraversorDartsOfOrbit<MAP, ORBIT>::TraversorDartsOfOrbit(MAP& map, Dart d, unsigned int thread)
{
......
......@@ -23,9 +23,7 @@
*******************************************************************************/
#ifndef __TRAVERSORFACTORY_H__
#define __TRAVERSORGEN_H__
#include "Topology/generic/traversorGen.h"
#define __TRAVERSORFACTORY_H__
namespace CGoGN
{
......
......@@ -21,6 +21,7 @@
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Topology/generic/traversor1.h"
#include "Topology/generic/traversor2.h"
#include "Topology/generic/traversor3.h"
......@@ -33,7 +34,6 @@ namespace CGoGN
template<typename MAP>
Traversor<MAP>* TraversorFactory<MAP>::createIncident(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY)
{
int code = 0x100*dim + 0x10*(orbX-VERTEX) + orbY-VERTEX;
switch(code)
......@@ -78,7 +78,6 @@ Traversor<MAP>* TraversorFactory<MAP>::createIncident(MAP& map, Dart dart, unsig
return new Traversor3XY<MAP, VOLUME, FACE>(map,dart);
break;
case 0x201:
return new Traversor2VE<MAP>(map,dart);
break;
......@@ -112,12 +111,9 @@ Traversor<MAP>* TraversorFactory<MAP>::createIncident(MAP& map, Dart dart, unsig
return NULL;
}
template<typename MAP>
Traversor<MAP>* TraversorFactory<MAP>::createAdjacent(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY)
{
int code = 0x100*dim + 0x10*(orbX-VERTEX) + orbY-VERTEX;
switch(code)
......@@ -162,7 +158,6 @@ Traversor<MAP>* TraversorFactory<MAP>::createAdjacent(MAP& map, Dart dart, unsig
return new Traversor3XXaY<MAP, VOLUME, FACE>(map,dart);
break;
case 0x201:
return new Traversor2VVaE<MAP>(map,dart);
break;
......@@ -182,7 +177,6 @@ Traversor<MAP>* TraversorFactory<MAP>::createAdjacent(MAP& map, Dart dart, unsig
return new Traversor2FFaE<MAP>(map,dart);
break;
case 0x101:
return new Traversor1VVaE<MAP>(map,dart);
break;
......@@ -197,7 +191,6 @@ Traversor<MAP>* TraversorFactory<MAP>::createAdjacent(MAP& map, Dart dart, unsig
return NULL;
}
template<typename MAP>
Traversor<MAP>* TraversorFactory<MAP>::createCell(MAP& map, unsigned int orb, const FunctorSelect& good, bool forceDartMarker, unsigned int thread)
{
......@@ -280,7 +273,4 @@ Traversor<MAP>* TraversorFactory<MAP>::createDartsOfOrbits(MAP& map, Dart dart,
}
}
}
......@@ -26,6 +26,7 @@
#define __TRAVERSORGEN_H__
#include "Topology/generic/dart.h"
#include "Topology/generic/functor.h"
namespace CGoGN
{
......@@ -39,6 +40,17 @@ public:
virtual Dart end() = 0;
virtual Dart next() = 0;
bool applyFunctor(FunctorType& f, const FunctorSelect& good = allDarts)
{
for (Dart d = begin(); d != end(); d = next())
{
if (good(d))
if (f(d))
return true;
}
return false;
}
/**
* Factory of incident traversors creation
* @param map the map in which we work
......@@ -48,7 +60,7 @@ public:
* @param orbY incident to cell
* @return a ptr on Generic Traversor
*/
static Traversor<MAP>* createIncident(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY);
// static Traversor<MAP>* createIncident(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY);
/**
* Factory of adjacent traversors creation
......@@ -59,7 +71,7 @@ public:
* @param orbY incident to cell
* @return a ptr on Generic Traversor
*/
static Traversor<MAP>* createAdjacent(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY);
// static Traversor<MAP>* createAdjacent(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY);
/**
* Factory of darts of orbit traversors creation
......@@ -68,7 +80,7 @@ public:
* @param orb the orbit
* @return a ptr on Generic Traversor
*/
static Traversor<MAP>* createDartsOfOrbits(MAP& map, Dart dart, unsigned int orb);
// static Traversor<MAP>* createDartsOfOrbits(MAP& map, Dart dart, unsigned int orb);
/**
* Factory of incident traversors creation
......@@ -78,13 +90,9 @@ public:
* @param thread (default value 0)
* @return a ptr on Generic Traversor
*/
static Traversor<MAP>* createCell(MAP& map, unsigned int orb, const FunctorSelect& good = allDarts, bool forceDartMarker = false, unsigned int thread = 0);
// static Traversor<MAP>* createCell(MAP& map, unsigned int orb, const FunctorSelect& good = allDarts, bool forceDartMarker = false, unsigned int thread = 0);
};
} // namespace CGoGN
//#include "Topology/generic/traversorGen.hpp"
#endif
......@@ -48,7 +48,7 @@ public:
virtual std::string mapTypeName() const;
virtual unsigned int dimension();
virtual unsigned int dimension() const;
virtual void clear(bool removeAttrib);
......
......@@ -42,7 +42,7 @@ inline std::string GMap0::mapTypeName() const
return "GMap0";
}
inline unsigned int GMap0::dimension()
inline unsigned int GMap0::dimension() const
{
return 0;
}
......
......@@ -47,7 +47,7 @@ public:
virtual std::string mapTypeName() const;
virtual unsigned int dimension();
virtual unsigned int dimension() const;
virtual void clear(bool removeAttrib);
......
......@@ -40,7 +40,7 @@ inline std::string GMap1::mapTypeName() const
return "GMap1";
}
inline unsigned int GMap1::dimension()
inline unsigned int GMap1::dimension() const
{
return 1;
}
......
......@@ -54,7 +54,7 @@ public:
virtual std::string mapTypeName() const;
virtual unsigned int dimension();
virtual unsigned int dimension() const;
virtual void clear(bool removeAttrib);
......
......@@ -40,7 +40,7 @@ inline std::string GMap2::mapTypeName() const
return "GMap2";
}
inline unsigned int GMap2::dimension()
inline unsigned int GMap2::dimension() const
{
return 2;
}
......
......@@ -60,7 +60,7 @@ public:
virtual std::string mapTypeName() const;
virtual unsigned int dimension();
virtual unsigned int dimension() const;
virtual void clear(bool removeAttrib);
......
......@@ -40,7 +40,7 @@ inline std::string GMap3::mapTypeName() const
return "GMap3";
}
inline unsigned int GMap3::dimension()
inline unsigned int GMap3::dimension() const
{
return 3;
}
......
......@@ -53,7 +53,7 @@ public:
virtual std::string mapTypeName() const;
virtual unsigned int dimension();
virtual unsigned int dimension() const;
virtual void clear(bool removeAttrib);
......
......@@ -43,7 +43,7 @@ inline std::string Map1::mapTypeName() const
return "Map1" ;
}
inline unsigned int Map1::dimension()
inline unsigned int Map1::dimension() const
{
return 1 ;
}
......
......@@ -66,7 +66,7 @@ public:
virtual std::string mapTypeName() const;
virtual unsigned int dimension();
virtual unsigned int dimension() const;
virtual void clear(bool removeAttrib);
......
......@@ -42,7 +42,7 @@ inline std::string Map2::mapTypeName() const
return "Map2" ;
}
inline unsigned int Map2::dimension()
inline unsigned int Map2::dimension() const
{
return 2 ;
}
......
......@@ -74,7 +74,7 @@ public:
virtual std::string mapTypeName() const;
virtual unsigned int dimension();
virtual unsigned int dimension() const;
virtual void clear(bool removeAttrib);
......
......@@ -40,7 +40,7 @@ inline std::string Map3::mapTypeName() const
return "Map3";
}
inline unsigned int Map3::dimension()
inline unsigned int Map3::dimension() const
{
return 3;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment