Commit 7a132517 authored by Pierre Kraemer's avatar Pierre Kraemer

first lambdas..

parent a5ee3a10
...@@ -247,6 +247,8 @@ void Viewer::importMesh(std::string& filename) ...@@ -247,6 +247,8 @@ void Viewer::importMesh(std::string& filename)
setParamObject(bb.maxSize(), bb.center().data()) ; setParamObject(bb.maxSize(), bb.center().data()) ;
updateGLMatrices() ; updateGLMatrices() ;
std::cout << "#vertices -> " << Algo::Topo::getNbOrbits<VERTEX>(myMap) << std::endl;
} }
void Viewer::exportMesh(std::string& filename, bool askExportMode) void Viewer::exportMesh(std::string& filename, bool askExportMode)
......
...@@ -150,7 +150,7 @@ IF(WIN32) ...@@ -150,7 +150,7 @@ IF(WIN32)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE) set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
# set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE) # set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE)
ELSE(WIN32) ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Woverride-init -fPIC") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Woverride-init -fPIC")
# remove the 60000+ "no unused local typedefs" warnings with GCC4.8+ # remove the 60000+ "no unused local typedefs" warnings with GCC4.8+
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
......
...@@ -37,27 +37,11 @@ namespace Algo ...@@ -37,27 +37,11 @@ namespace Algo
namespace Topo namespace Topo
{ {
template <unsigned int ORBIT, typename MAP>
bool foreach_orbit(const MAP& map, FunctorType& fonct, unsigned int thread = 0)
{
TraversorCell<MAP, ORBIT> trav(map, true, thread);
bool found = false;
for (Dart d = trav.begin(); !found && d != trav.end(); d = trav.next())
{
if ((fonct)(d))
found = true;
}
return found;
}
template <unsigned int ORBIT, typename MAP> template <unsigned int ORBIT, typename MAP>
unsigned int getNbOrbits(const MAP& map) unsigned int getNbOrbits(const MAP& map)
{ {
unsigned int cpt = 0; unsigned int cpt = 0;
TraversorCell<MAP, ORBIT> trav(map, true); foreach_cell<ORBIT>(map, [&] (Dart) { ++cpt; }, true);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
++cpt;
return cpt; return cpt;
} }
...@@ -91,12 +75,11 @@ void initAllOrbitsEmbedding(MAP& map, bool realloc = false) ...@@ -91,12 +75,11 @@ void initAllOrbitsEmbedding(MAP& map, bool realloc = false)
if(!map.template isOrbitEmbedded<ORBIT>()) if(!map.template isOrbitEmbedded<ORBIT>())
map.template addEmbedding<ORBIT>() ; map.template addEmbedding<ORBIT>() ;
TraversorCell<MAP, ORBIT> trav(map, true); foreach_cell<ORBIT>(map, [&] (Dart d)
for(Dart d = trav.begin(); d != trav.end(); d = trav.next())
{ {
if(realloc || map.template getEmbedding<ORBIT>(d) == EMBNULL) if(realloc || map.template getEmbedding<ORBIT>(d) == EMBNULL)
map.template setOrbitEmbeddingOnNewCell<ORBIT>(d) ; map.template setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
} });
} }
/** /**
...@@ -125,8 +108,7 @@ void bijectiveOrbitEmbedding(MAP& map) ...@@ -125,8 +108,7 @@ void bijectiveOrbitEmbedding(MAP& map)
AttributeHandler<int, ORBIT, typename MAP::IMPL> counter = map.template addAttribute<int, ORBIT>("tmpCounter") ; AttributeHandler<int, ORBIT, typename MAP::IMPL> counter = map.template addAttribute<int, ORBIT>("tmpCounter") ;
counter.setAllValues(int(0)) ; counter.setAllValues(int(0)) ;
TraversorCell<MAP, ORBIT> trav(map, true); foreach_cell<ORBIT>(map, [&] (Dart d)
for(Dart d = trav.begin(); d != trav.end(); d = trav.next())
{ {
unsigned int emb = map.template getEmbedding<ORBIT>(d) ; unsigned int emb = map.template getEmbedding<ORBIT>(d) ;
if (emb != EMBNULL) if (emb != EMBNULL)
...@@ -138,7 +120,8 @@ void bijectiveOrbitEmbedding(MAP& map) ...@@ -138,7 +120,8 @@ void bijectiveOrbitEmbedding(MAP& map)
} }
counter[d]++ ; counter[d]++ ;
} }
} },
true);
map.removeAttribute(counter) ; map.removeAttribute(counter) ;
} }
......
...@@ -66,12 +66,10 @@ inline unsigned int MapCommon<MAP_IMPL>::getEmbedding(Dart d) const ...@@ -66,12 +66,10 @@ inline unsigned int MapCommon<MAP_IMPL>::getEmbedding(Dart d) const
{ {
assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded"); assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");
unsigned int d_index = this->dartIndex(d);
if (ORBIT == DART) if (ORBIT == DART)
return d_index; return this->dartIndex(d);
return (*this->m_embeddings[ORBIT])[d_index] ; return (*this->m_embeddings[ORBIT])[this->dartIndex(d)] ;
} }
template <typename MAP_IMPL> template <typename MAP_IMPL>
......
...@@ -30,22 +30,11 @@ ...@@ -30,22 +30,11 @@
#include "Topology/generic/cellmarker.h" #include "Topology/generic/cellmarker.h"
#include "Topology/generic/traversor/traversorGen.h" #include "Topology/generic/traversor/traversorGen.h"
#include <functional>
namespace CGoGN namespace CGoGN
{ {
/// Macro for simple syntax traversal (can be nested)
/// parameters:
/// - cell type
/// - name of iterator variable (automatically declared)
/// - map type
/// - map used
///
/// Ex: FOR_ALL_CELLS(VERTEX, di, myMap) { ... }
///
#define FOR_ALL_CELLS(ORBIT, NAME_ITER, MAP_TYPE, MAP_PARAM) TraversorCell<MAP_TYPE, (ORBIT)> NAME_ITER_TraversalMacroLocalLoop(MAP_PARAM); \
for (Dart NAME_ITER = NAME_ITER_TraversalMacroLocalLoop.begin(); NAME_ITER != NAME_ITER_TraversalMacroLocalLoop.end(); NAME_ITER = NAME_ITER_TraversalMacroLocalLoop.next())
template <typename MAP, unsigned int ORBIT> template <typename MAP, unsigned int ORBIT>
class TraversorCell //: public Traversor<MAP> class TraversorCell //: public Traversor<MAP>
{ {
...@@ -75,10 +64,32 @@ public: ...@@ -75,10 +64,32 @@ public:
inline Dart next() ; inline Dart next() ;
inline void skip(Dart d); inline void skip(Dart d);
inline void apply(std::function<bool (Dart)> f)
{
for (Dart d = begin(); d != end(); d = next())
if (f(d))
return;
}
inline void apply(std::function<void (Dart)> f)
{
for (Dart d = begin(); d != end(); d = next())
f(d);
}
} ; } ;
template <unsigned int ORBIT, typename MAP, typename FUNC>
inline void foreach_cell(const MAP& map, FUNC f, bool forceDartMarker = false, unsigned int thread = 0)
{
TraversorCell<MAP, ORBIT> trav(map, forceDartMarker, thread);
trav.apply(f);
}
template <typename MAP> template <typename MAP>
class TraversorV : public TraversorCell<MAP, VERTEX> class TraversorV : public TraversorCell<MAP, VERTEX>
{ {
......
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