23 #ifndef __SUBSET_ITERATOR_H 24 #define __SUBSET_ITERATOR_H 30 #include "MeshEntity.h" 31 #include "MeshEntityIterator.h" 32 #include "MeshFunction.h" 48 : _entity(*labels.mesh(), labels.dim(), 0),
49 _subset(new std::vector<std::size_t>()), subset(*_subset)
54 !entity.
end(); ++entity)
56 if (labels[*entity] == label)
57 subset.push_back(entity->index());
59 info(
"Iterating over subset, found %d entities out of %d.",
60 subset.size(), labels.
size());
68 : _entity(subset_iter._entity), _subset(subset_iter._subset),
69 subset(*_subset), it(subset_iter.it) {}
91 return ((const_cast<SubsetIterator *>(
this))->
operator*()
92 == (const_cast<SubsetIterator *>(&sub_iter))->
operator*()
93 && it == sub_iter.it && &subset == &sub_iter.subset);
106 { _entity._local_index = *it;
return &_entity; }
110 {
return it == subset.end(); }
125 { it = subset.end(); }
131 std::shared_ptr<std::vector<std::size_t>> _subset;
134 std::vector<std::size_t>& subset;
137 std::vector<std::size_t>::iterator it;
SubsetIterator(const SubsetIterator &subset_iter)
Copy Constructor.
Definition: SubsetIterator.h:67
Definition: SubsetIterator.h:41
SubsetIterator & operator--()
Step back to previous mesh entity (prefix decrement)
Definition: SubsetIterator.h:82
SubsetIterator end_iterator()
Beyond end iterator.
Definition: SubsetIterator.h:113
std::size_t dim() const
Definition: MeshFunction.h:498
virtual ~SubsetIterator()
Destructor.
Definition: SubsetIterator.h:72
bool operator!=(const SubsetIterator &sub_iter) const
Comparison operator.
Definition: SubsetIterator.h:97
bool end() const
Check if iterator has reached the end.
Definition: MeshEntityIterator.h:188
Definition: MeshEntityIterator.h:64
SubsetIterator(const MeshFunction< std::size_t > &labels, std::size_t label)
Definition: SubsetIterator.h:47
SubsetIterator & operator++()
Step to next mesh entity (prefix increment)
Definition: SubsetIterator.h:75
bool end() const
Check if iterator has reached the end.
Definition: SubsetIterator.h:109
void info(std::string msg,...)
Print message.
Definition: log.cpp:72
Definition: MeshEntity.h:42
std::shared_ptr< const Mesh > mesh() const
Definition: MeshFunction.h:491
MeshEntity * operator->()
Member access operator.
Definition: SubsetIterator.h:105
MeshEntity & operator*()
Dereference operator.
Definition: SubsetIterator.h:101
bool operator==(const SubsetIterator &sub_iter) const
Comparison operator.
Definition: SubsetIterator.h:89
std::size_t size() const
Definition: MeshFunction.h:510