MeshLib Documentation
Loading...
Searching...
No Matches
MRPolylineEdgeIterator.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRIteratorRange.h"
5#include <iterator>
6
7namespace MR
8{
9
13{
14public:
15 using iterator_category = std::forward_iterator_tag;
16 using value_type = UndirectedEdgeId;
17
18 // creates begin iterator
19 PolylineUndirectedEdgeIterator( const PolylineTopology & topology ) : topology_( &topology )
20 {
21 if ( topology_->undirectedEdgeSize() == 0 )
22 return; // end has reached
23 edge_ = UndirectedEdgeId{0};
24 if ( topology_->isLoneEdge( edge_ ) )
26 }
27 // creates end iterator
29
31 {
32 assert( edge_.valid() );
33 for (;;)
34 {
35 ++edge_;
36 if ( edge_ >= topology_->undirectedEdgeSize() )
37 {
38 edge_ = UndirectedEdgeId{};
39 break;
40 }
41 if ( !topology_->isLoneEdge( edge_ ) )
42 break;
43 }
44 return * this;
45 }
46 UndirectedEdgeId operator *( ) const { return edge_; }
47
48private:
49 const PolylineTopology * topology_ = nullptr;
50 UndirectedEdgeId edge_;
51};
52
55
57 { return *a == *b; }
58
60 { return *a != *b; }
61
62inline IteratorRange<PolylineUndirectedEdgeIterator> undirectedEdges( const PolylineTopology & topology )
63 { return { PolylineUndirectedEdgeIterator( topology ), PolylineUndirectedEdgeIterator() }; }
64
66
67} // namespace MR
Definition MRPolylineTopology.h:15
size_t undirectedEdgeSize() const
returns the number of undirected edges (pairs of half-edges) including lone ones
Definition MRPolylineTopology.h:43
MRMESH_API bool isLoneEdge(EdgeId a) const
checks whether the edge is disconnected from all other edges and disassociated from all vertices (as ...
Definition MRPolylineEdgeIterator.h:13
PolylineUndirectedEdgeIterator & operator++()
Definition MRPolylineEdgeIterator.h:30
PolylineUndirectedEdgeIterator(const PolylineTopology &topology)
Definition MRPolylineEdgeIterator.h:19
std::forward_iterator_tag iterator_category
Definition MRPolylineEdgeIterator.h:15
UndirectedEdgeId operator*() const
Definition MRPolylineEdgeIterator.h:46
UndirectedEdgeId value_type
Definition MRPolylineEdgeIterator.h:16
MRMESH_API bool operator==(const BitSet &a, const BitSet &b)
compare that two bit sets have the same set bits (they can be equal even if sizes are distinct but la...
bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:276
Definition MRCameraOrientationPlugin.h:8
IteratorRange< UndirectedEdgeIterator > undirectedEdges(const MeshTopology &topology)
Definition MREdgeIterator.h:58