MeshLib
 
Loading...
Searching...
No Matches
MREdgeIterator.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{
9
10// The iterator to find all not-lone undirected edges in the mesh
12{
13public:
14 using iterator_category = std::forward_iterator_tag;
15 using value_type = UndirectedEdgeId;
16
17 // creates begin iterator
18 UndirectedEdgeIterator( const MeshTopology & topology ) : topology_( &topology )
19 {
20 if ( topology_->undirectedEdgeSize() == 0 )
21 return; // end has reached
22 edge_ = UndirectedEdgeId{0};
23 if ( topology_->isLoneEdge( edge_ ) )
25 }
26 // creates end iterator
28
30 {
31 assert( edge_.valid() );
32 for (;;)
33 {
34 ++edge_;
35 if ( edge_ >= topology_->undirectedEdgeSize() )
36 {
37 edge_ = UndirectedEdgeId{};
38 break;
39 }
40 if ( !topology_->isLoneEdge( edge_ ) )
41 break;
42 }
43 return * this;
44 }
45 UndirectedEdgeId operator *( ) const { return edge_; }
46
47private:
48 const MeshTopology * topology_ = nullptr;
49 UndirectedEdgeId edge_;
50};
51
53 { return *a == *b; }
54
56 { return *a != *b; }
57
60
61} //namespace MR
Definition MRMesh/MRMeshTopology.h:18
MRMESH_API bool isLoneEdge(EdgeId a) const
checks whether the edge is disconnected from all other edges and disassociated from all vertices and ...
size_t undirectedEdgeSize() const
returns the number of undirected edges (pairs of half-edges) including lone ones
Definition MRMesh/MRMeshTopology.h:39
Definition MREdgeIterator.h:12
std::forward_iterator_tag iterator_category
Definition MREdgeIterator.h:14
UndirectedEdgeIterator & operator++()
Definition MREdgeIterator.h:29
UndirectedEdgeIterator(const MeshTopology &topology)
Definition MREdgeIterator.h:18
UndirectedEdgeId operator*() const
Definition MREdgeIterator.h:45
UndirectedEdgeId value_type
Definition MREdgeIterator.h:15
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:259
Definition MRCameraOrientationPlugin.h:7
IteratorRange< UndirectedEdgeIterator > undirectedEdges(const MeshTopology &topology)
Definition MREdgeIterator.h:58
Definition MRMesh/MRMeshFwd.h:366