From 291303798551faf7be4987270057f73c58ad9a5f Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Thu, 24 Apr 2014 10:17:47 +0200 Subject: [PATCH] traversor & foreach macros tutos --- Apps/CMakeLists.txt | 2 ++ Apps/Tuto/CMakeLists.txt | 10 +++++----- include/Topology/generic/cells.h | 2 ++ include/Topology/generic/cells_macros.h | 11 +++++++++++ include/Topology/generic/dart.h | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Apps/CMakeLists.txt b/Apps/CMakeLists.txt index 4d77569e..dc7ba048 100644 --- a/Apps/CMakeLists.txt +++ b/Apps/CMakeLists.txt @@ -34,3 +34,5 @@ IF (WITH_QT) ENDIF (WITH_QT) add_subdirectory(Examples/Tests) + +add_subdirectory(Tuto/Traversals) diff --git a/Apps/Tuto/CMakeLists.txt b/Apps/Tuto/CMakeLists.txt index b0cff03a..5c0bfd3d 100644 --- a/Apps/Tuto/CMakeLists.txt +++ b/Apps/Tuto/CMakeLists.txt @@ -71,11 +71,11 @@ add_executable( tuto_orbits tuto_orbits.cpp ${tuto_orbits_ui} ${tuto_orbits_moc} target_link_libraries( tuto_orbits ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) -QT4_WRAP_UI( show_traversors_ui show_traversors.ui ) -QT4_WRAP_CPP(show_traversors_moc show_traversors.h) -add_executable( show_traversors show_traversors.cpp ${show_traversors_ui} ${show_traversors_moc}) -target_link_libraries( show_traversors - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +#QT4_WRAP_UI( show_traversors_ui show_traversors.ui ) +#QT4_WRAP_CPP(show_traversors_moc show_traversors.h) +#add_executable( show_traversors show_traversors.cpp ${show_traversors_ui} ${show_traversors_moc}) +#target_link_libraries( show_traversors +# ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) add_executable( tuto_subdivision tuto_subdivision.cpp) target_link_libraries( tuto_subdivision diff --git a/include/Topology/generic/cells.h b/include/Topology/generic/cells.h index 77d7d760..e5a31603 100644 --- a/include/Topology/generic/cells.h +++ b/include/Topology/generic/cells.h @@ -52,6 +52,8 @@ public: inline Cell(const Cell& c): dart(c.dart) {} /// Dart cast operator inline operator Dart() const {return dart;} + friend std::ostream& operator<<( std::ostream &out, const Cell& fa ) { return out << fa.dart; } + inline bool valid() const { return !dart.isNil();} }; typedef Cell Vertex; diff --git a/include/Topology/generic/cells_macros.h b/include/Topology/generic/cells_macros.h index dc602682..9a2bed71 100644 --- a/include/Topology/generic/cells_macros.h +++ b/include/Topology/generic/cells_macros.h @@ -101,6 +101,17 @@ for (Cell Cell_ITER ( Cell_ITER##_TraversalMacroLocalLoop##LNN.begin()), #define foreachCellMT(ORBIT, Cell_ITER, MAP_TYPE, MAP_PARAM, THREAD) XforeachCellMT(ORBIT, Cell_ITER, MAP_TYPE, MAP_PARAM, THREAD,__LINE__) +#define YfindCell(ORBIT, Cell_ITER, MAP_TYPE, MAP_PARAM, COND, LNN)\ +TraversorCell Cell_ITER##_TraversalMacroLocalLoop##LNN(MAP_PARAM);\ +Dart Cell_ITER##_endTMLoop = Cell_ITER##_TraversalMacroLocalLoop##LNN.end();\ +Cell_ITER = Cell_ITER##_TraversalMacroLocalLoop##LNN.begin(); \ +while( (Cell_ITER.dart != Cell_ITER##_endTMLoop) && (!(COND)) )\ +Cell_ITER.dart = Cell_ITER##_TraversalMacroLocalLoop##LNN.next(); + +#define XfindCell(ORBIT, Cell_ITER, MAP_TYPE, MAP_PARAM, COND, LNN) YfindCell(ORBIT, Cell_ITER, MAP_TYPE, MAP_PARAM,COND,LNN) +#define findCell(ORBIT, Cell_ITER, MAP_TYPE, MAP_PARAM, COND) XfindCell(ORBIT, Cell_ITER, MAP_TYPE, MAP_PARAM,COND,__LINE__) + + } #endif /* __CELLS_MACRO_H_ */ diff --git a/include/Topology/generic/dart.h b/include/Topology/generic/dart.h index d6fad0bd..7311b396 100644 --- a/include/Topology/generic/dart.h +++ b/include/Topology/generic/dart.h @@ -67,7 +67,7 @@ struct Dart Dart(unsigned int v): index(v) {} - bool isNil() { return index == 0xffffffff ; } + bool isNil() const { return index == 0xffffffff ; } /** * affectation operator -- GitLab