MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRingIterator.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshTopology.h"
4#include "MRIteratorRange.h"
5#include <iterator>
6
7namespace MR
8{
11
12
14template <typename N>
15class RingIterator : public N
16{
17public:
18 using iterator_category = std::forward_iterator_tag;
19 using value_type = EdgeId;
20 using difference_type = std::ptrdiff_t;
21
22 RingIterator( const MeshTopology & topology, EdgeId edge, bool first )
23 : N( topology ), edge_( edge ), first_( first )
24 {
25 }
27 {
28 first_ = false;
29 edge_ = N::next( edge_ );
30 return * this;
31 }
32 EdgeId operator *( ) const { return edge_; }
33 bool first() const { return first_; }
34
35 friend bool operator ==( const RingIterator & a, const RingIterator & b ) { return *a == *b && a.first() == b.first(); }
36 friend bool operator !=( const RingIterator & a, const RingIterator & b ) { return *a != *b || a.first() != b.first(); }
37
38private:
39 EdgeId edge_;
40 bool first_ = false;
41};
42
44{
45 const MeshTopology * topology_ = nullptr;
46
47public:
48 NextEdgeSameOrigin( const MeshTopology & topology ) : topology_( &topology ) { }
49 EdgeId next( EdgeId e ) const { return topology_->next( e ); }
50};
51
53
55{
56 const MeshTopology * topology_ = nullptr;
57
58public:
59 NextEdgeSameLeft( const MeshTopology & topology ) : topology_( &topology ) { }
60 EdgeId next( EdgeId e ) const { return topology_->prev( e.sym() ); }
61};
62
64
65
68inline IteratorRange<OrgRingIterator> orgRing( const MeshTopology & topology, EdgeId edge )
69 { return { OrgRingIterator( topology, edge, edge.valid() ), OrgRingIterator( topology, edge, false ) }; }
70inline IteratorRange<OrgRingIterator> orgRing( const MeshTopology & topology, VertId v )
71 { return orgRing( topology, topology.edgeWithOrg( v ) ); }
72
75inline IteratorRange<OrgRingIterator> orgRing0( const MeshTopology & topology, EdgeId edge )
76 { return { ++OrgRingIterator( topology, edge, true ), OrgRingIterator( topology, edge, false ) }; }
77
78
81inline IteratorRange<LeftRingIterator> leftRing( const MeshTopology & topology, EdgeId edge )
82 { return { LeftRingIterator( topology, edge, edge.valid() ), LeftRingIterator( topology, edge, false ) }; }
83inline IteratorRange<LeftRingIterator> leftRing( const MeshTopology & topology, FaceId f )
84 { return leftRing( topology, topology.edgeWithLeft( f ) ); }
85
88inline IteratorRange<LeftRingIterator> leftRing0( const MeshTopology & topology, EdgeId edge )
89 { return { ++LeftRingIterator( topology, edge, true ), LeftRingIterator( topology, edge, false ) }; }
90
91}
Definition MRMeshTopology.h:22
Definition MRRingIterator.h:55
Definition MRRingIterator.h:44
The iterator to find all edges in a ring of edges (e.g. all edges with same origin or all edges with ...
Definition MRRingIterator.h:16
EdgeId next(EdgeId e) const
Definition MRRingIterator.h:60
RingIterator< NextEdgeSameOrigin > OrgRingIterator
Definition MRRingIterator.h:52
EdgeId next(EdgeId e) const
Definition MRRingIterator.h:49
EdgeId next(EdgeId he) const
next (counter clock wise) half-edge in the origin ring
Definition MRMeshTopology.h:87
RingIterator & operator++()
Definition MRRingIterator.h:26
std::forward_iterator_tag iterator_category
Definition MRRingIterator.h:18
NextEdgeSameOrigin(const MeshTopology &topology)
Definition MRRingIterator.h:48
EdgeId operator*() const
Definition MRRingIterator.h:32
IteratorRange< LeftRingIterator > leftRing0(const MeshTopology &topology, EdgeId edge)
Definition MRRingIterator.h:88
std::ptrdiff_t difference_type
Definition MRRingIterator.h:20
EdgeId edgeWithLeft(FaceId a) const
returns valid edge if given vertex is present in the mesh
Definition MRMeshTopology.h:232
friend bool operator!=(const RingIterator &a, const RingIterator &b)
Definition MRRingIterator.h:36
EdgeId prev(EdgeId he) const
previous (clock wise) half-edge in the origin ring
Definition MRMeshTopology.h:90
NextEdgeSameLeft(const MeshTopology &topology)
Definition MRRingIterator.h:59
EdgeId edgeWithOrg(VertId a) const
returns valid edge if given vertex is present in the mesh
Definition MRMeshTopology.h:184
EdgeId value_type
Definition MRRingIterator.h:19
IteratorRange< LeftRingIterator > leftRing(const MeshTopology &topology, EdgeId edge)
Definition MRRingIterator.h:81
IteratorRange< OrgRingIterator > orgRing(const MeshTopology &topology, EdgeId edge)
Definition MRRingIterator.h:68
IteratorRange< OrgRingIterator > orgRing0(const MeshTopology &topology, EdgeId edge)
Definition MRRingIterator.h:75
RingIterator< NextEdgeSameLeft > LeftRingIterator
Definition MRRingIterator.h:63
bool first() const
Definition MRRingIterator.h:33
friend bool operator==(const RingIterator &a, const RingIterator &b)
Definition MRRingIterator.h:35
RingIterator(const MeshTopology &topology, EdgeId edge, bool first)
Definition MRRingIterator.h:22
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRIteratorRange.h:13