diff --git a/Apps/Tuto/Attributes/simple_attribs.cpp b/Apps/Tuto/Attributes/simple_attribs.cpp index 3bbcf8ae07f13af840eaab38fc7b1cab7d74f3e3..3abc240ee86a989a3bc25d4890e7c0794ad60866 100644 --- a/Apps/Tuto/Attributes/simple_attribs.cpp +++ b/Apps/Tuto/Attributes/simple_attribs.cpp @@ -129,10 +129,18 @@ void dumpAttribute(const ATTRIB& attr) template void VertexTyped(MAP& map, T& va) { - foreach_cell(map,[&](Vertex v) // for all vertices - { - va[v] = 1.1 * va[v]; - }); + +// foreach_cell(map,[&](Vertex v) // for all vertices +// { +// va[v] = 1.1 * va[v]; +// }); + + // other syntax for traversal + for (Vertex v : allVertices(map)) + { + va[v] = 1.1 * va[v]; + std::cout << "V:" << v << " -> "< Vector(const Vector& v) ; + /** + * @brief Vector constructor from list init. (c++11) + * @param args {x,y,z} + */ + Vector(typename std::initializer_list args); + Vector(T x, T y) ; Vector(T x, T y, T z) ; diff --git a/include/Geometry/vector_gen.hpp b/include/Geometry/vector_gen.hpp index d8815b4647c9838fd2cb7b1f2759375b76691040..ca289b2e88ce80c041852055d08e741c6fb823c7 100644 --- a/include/Geometry/vector_gen.hpp +++ b/include/Geometry/vector_gen.hpp @@ -48,6 +48,19 @@ std::string Vector::CGoGNnameOfType() /* CONSTRUCTORS */ /**********************************************/ +template +Vector::Vector(typename std::initializer_list args) +{ + unsigned int i=0; + // fill from initializer list + for (auto iter = args.begin(); (iter != args.end()) && (i Vector::Vector() { diff --git a/include/Topology/generic/traversor/traversorCell.h b/include/Topology/generic/traversor/traversorCell.h index 1cde00abe257e346062a23634828264703441ad1..ba1625554a391c8dfab4d1cb2bd4c4e40c4e4c06 100644 --- a/include/Topology/generic/traversor/traversorCell.h +++ b/include/Topology/generic/traversor/traversorCell.h @@ -144,7 +144,6 @@ void foreach_cell(MAP& map, FUNC func, TraversalOptim opt = AUTO, unsigned int n - template class TraversorV : public TraversorCell { @@ -177,6 +176,88 @@ public: {} }; +template +class allCells: public TraversorCell +{ +public: + allCells(const MAP& map, bool forceDartMarker = false, unsigned int thread = 0): + TraversorCell(map,forceDartMarker,thread) {} + + + class iterator + { + Cell m_index; + TraversorCell* m_ptr; + + public: + + inline iterator(allCells* p, Cell i): m_ptr(p),m_index(i){} + + inline iterator& operator++() + { + m_index = m_ptr->next(); + return *this; + } + + inline Cell& operator*() + { + return m_index; + } + + inline bool operator!=(iterator it) + { + return m_index.dart != it.m_index.dart; + } + + }; + + inline iterator begin() + { + return iterator(this,TraversorCell::begin()); + } + + inline iterator end() + { + return iterator(this,TraversorCell::end()); + } + +}; + +template +class allVertices : public allCells +{ +public: + allVertices(const MAP& m, unsigned int thread = 0) : allCells(m, false, thread) + {} +}; + + +template +class allEdges : public allCells +{ +public: + allEdges(const MAP& m, unsigned int thread = 0) : allCells(m, false, thread) + {} +}; + +template +class allFaces : public allCells +{ +public: + allFaces(const MAP& m, unsigned int thread = 0) : allCells(m, false, thread) + {} +}; + +template +class allVolumes : public allCells +{ +public: + allVolumes(const MAP& m, unsigned int thread = 0) : allCells(m, false, thread) + {} +}; + + + } // namespace CGoGN