Commit 2ee42899 authored by Alexander Dielen's avatar Alexander Dielen
Browse files

Added six new circulators

- HalfFaceHalfEdgeIter
- HalfFaceEdgeIter
- FaceHalfEdgeIter
- FaceEdgeIter
- CellHalfEdgeIter
- CellEdgeIter
parent 39b25c46
Pipeline #6413 failed with stage
in 3 minutes and 34 seconds
......@@ -1062,9 +1062,209 @@ CellIter& CellIter::operator++() {
namespace Internal {
////================================================================================================
//// CellHalfFaceIterImpl
//// HalfFaceHalfEdgeIterImpl
////================================================================================================
HalfFaceHalfEdgeIterImpl::HalfFaceHalfEdgeIterImpl(const HalfFaceHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
cur_index_(0)
{
BaseIter::valid(_ref_h.is_valid() && _mesh->halfface(_ref_h).halfedges().size() > 0);
if (BaseIter::valid()) {
BaseIter::cur_handle(_mesh->halfface(_ref_h).halfedges()[cur_index_]);
}
}
HalfFaceHalfEdgeIterImpl& HalfFaceHalfEdgeIterImpl::operator--() {
const std::vector<HalfEdgeHandle> halfedges =
mesh()->halfface(ref_handle()).halfedges();
if (cur_index_ == 0) {
cur_index_ = halfedges.size() - 1;
--lap_;
if (lap_ < 0)
BaseIter::valid(false);
}
else {
--cur_index_;
}
BaseIter::cur_handle(halfedges[cur_index_]);
return *this;
}
HalfFaceHalfEdgeIterImpl& HalfFaceHalfEdgeIterImpl::operator++() {
const std::vector<HalfEdgeHandle> halfedges =
mesh()->halfface(ref_handle()).halfedges();
++cur_index_;
if (cur_index_ >= halfedges.size()) {
cur_index_ = 0;
++lap_;
if (lap_ >= max_laps_)
BaseIter::valid(false);
}
BaseIter::cur_handle(halfedges[cur_index_]);
return *this;
}
////================================================================================================
//// HalfFaceEdgeIterImpl
////================================================================================================
HalfFaceEdgeIterImpl::HalfFaceEdgeIterImpl(const HalfFaceHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
cur_index_(0)
{
BaseIter::valid(_ref_h.is_valid() && _mesh->halfface(_ref_h).halfedges().size() > 0);
if (BaseIter::valid()) {
HalfEdgeHandle he = _mesh->halfface(_ref_h).halfedges()[cur_index_];
BaseIter::cur_handle(_mesh->edge_handle(he));
}
}
HalfFaceEdgeIterImpl& HalfFaceEdgeIterImpl::operator--() {
const std::vector<HalfEdgeHandle> halfedges =
mesh()->halfface(ref_handle()).halfedges();
if (cur_index_ == 0) {
cur_index_ = halfedges.size() - 1;
--lap_;
if (lap_ < 0)
BaseIter::valid(false);
}
else {
--cur_index_;
}
BaseIter::cur_handle(mesh()->edge_handle(halfedges[cur_index_]));
return *this;
}
HalfFaceEdgeIterImpl& HalfFaceEdgeIterImpl::operator++() {
const std::vector<HalfEdgeHandle> halfedges =
mesh()->halfface(ref_handle()).halfedges();
++cur_index_;
if (cur_index_ >= halfedges.size()) {
cur_index_ = 0;
++lap_;
if (lap_ >= max_laps_)
BaseIter::valid(false);
}
BaseIter::cur_handle(mesh()->edge_handle(halfedges[cur_index_]));
return *this;
}
////================================================================================================
//// FaceHalfEdgeIterImpl
////================================================================================================
FaceHalfEdgeIterImpl::FaceHalfEdgeIterImpl(const FaceHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
HalfFaceHalfEdgeIterImpl(_mesh->halfface_handle(_ref_h, 0), _mesh, _max_laps) {}
////================================================================================================
//// FaceEdgeIterImpl
////================================================================================================
FaceEdgeIterImpl::FaceEdgeIterImpl(const FaceHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
HalfFaceEdgeIterImpl(_mesh->halfface_handle(_ref_h, 0), _mesh, _max_laps) {}
////================================================================================================
//// CellHalfEdgeIterImpl
////================================================================================================
CellHalfEdgeIterImpl::CellHalfEdgeIterImpl(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
cur_index_(0)
{
for (CellHalfFaceIter chf_iter =_mesh->chf_iter(_ref_h); chf_iter.valid(); ++chf_iter) {
for (HalfFaceHalfEdgeIter hfhe_iter =_mesh->hfhe_iter(*chf_iter); hfhe_iter.valid(); ++hfhe_iter) {
halfedges_.push_back(*hfhe_iter);
}
}
BaseIter::valid(halfedges_.size() > 0);
if (BaseIter::valid()) {
BaseIter::cur_handle(halfedges_[cur_index_]);
}
}
CellHalfEdgeIterImpl& CellHalfEdgeIterImpl::operator--() {
if (cur_index_ == 0) {
cur_index_ = halfedges_.size() - 1;
--lap_;
if (lap_ < 0)
BaseIter::valid(false);
}
else {
--cur_index_;
}
BaseIter::cur_handle(halfedges_[cur_index_]);
return *this;
}
CellHalfEdgeIterImpl& CellHalfEdgeIterImpl::operator++() {
++cur_index_;
if (cur_index_ >= halfedges_.size()) {
cur_index_ = 0;
++lap_;
if (lap_ >= max_laps_)
BaseIter::valid(false);
}
BaseIter::cur_handle(halfedges_[cur_index_]);
return *this;
}
////================================================================================================
//// CellEdgeIterImpl
////================================================================================================
CellEdgeIterImpl::CellEdgeIterImpl(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
cur_index_(0)
{
for (CellHalfEdgeIter che_iter = _mesh->che_iter(_ref_h); che_iter.valid(); ++che_iter) {
edges_.push_back(_mesh->edge_handle(*che_iter));
}
// Remove all duplicate entries
std::sort(edges_.begin(), edges_.end());
edges_.resize(std::unique(edges_.begin(), edges_.end()) - edges_.begin());
BaseIter::valid(edges_.size() > 0);
if (BaseIter::valid()) {
BaseIter::cur_handle(edges_[cur_index_]);
}
}
CellEdgeIterImpl& CellEdgeIterImpl::operator--() {
if (cur_index_ == 0) {
cur_index_ = edges_.size() - 1;
--lap_;
if (lap_ < 0)
BaseIter::valid(false);
}
else {
--cur_index_;
}
BaseIter::cur_handle(edges_[cur_index_]);
return *this;
}
CellEdgeIterImpl& CellEdgeIterImpl::operator++() {
++cur_index_;
if (cur_index_ >= edges_.size()) {
cur_index_ = 0;
++lap_;
if (lap_ >= max_laps_)
BaseIter::valid(false);
}
BaseIter::cur_handle(edges_[cur_index_]);
return *this;
}
////================================================================================================
//// CellHalfFaceIterImpl
////================================================================================================
CellHalfFaceIterImpl::CellHalfFaceIterImpl(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
......@@ -1106,11 +1306,11 @@ CellHalfFaceIterImpl& CellHalfFaceIterImpl::operator++() {
return *this;
}
////================================================================================================
//// CellFaceIterImpl
////================================================================================================
CellFaceIterImpl::CellFaceIterImpl(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
hf_iter_(BaseIter::mesh()->cell(_ref_h).halffaces().begin())
......@@ -1153,11 +1353,11 @@ CellFaceIterImpl& CellFaceIterImpl::operator++() {
}
////================================================================================================
//// BoundaryItemIter
////================================================================================================
template <>
size_t BoundaryItemIter<VertexIter, VertexHandle>::n_items() const {
return BaseIter::mesh()->n_vertices();
......
......@@ -1162,10 +1162,101 @@ namespace Internal {
//===========================================================================
class HalfFaceHalfEdgeIterImpl : public BaseCirculator<HalfFaceHandle, HalfEdgeHandle> {
public:
typedef BaseCirculator<HalfFaceHandle, HalfEdgeHandle> BaseIter;
typedef HalfFaceHandle CenterEntityHandle;
HalfFaceHalfEdgeIterImpl(const HalfFaceHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
HalfFaceHalfEdgeIterImpl& operator++();
HalfFaceHalfEdgeIterImpl& operator--();
private:
size_t cur_index_;
};
//===========================================================================
class HalfFaceEdgeIterImpl : public BaseCirculator<HalfFaceHandle, EdgeHandle> {
public:
typedef BaseCirculator<HalfFaceHandle, EdgeHandle> BaseIter;
typedef HalfFaceHandle CenterEntityHandle;
HalfFaceEdgeIterImpl(const HalfFaceHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
HalfFaceEdgeIterImpl& operator++();
HalfFaceEdgeIterImpl& operator--();
private:
size_t cur_index_;
};
//===========================================================================
class FaceHalfEdgeIterImpl : public HalfFaceHalfEdgeIterImpl {
public:
typedef FaceHandle CenterEntityHandle;
FaceHalfEdgeIterImpl(const FaceHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
};
//===========================================================================
class FaceEdgeIterImpl : public HalfFaceEdgeIterImpl {
public:
typedef FaceHandle CenterEntityHandle;
FaceEdgeIterImpl(const FaceHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
};
//===========================================================================
class CellHalfEdgeIterImpl : public BaseCirculator<CellHandle, HalfEdgeHandle> {
public:
typedef BaseCirculator<CellHandle, HalfEdgeHandle> BaseIter;
typedef CellHandle CenterEntityHandle;
CellHalfEdgeIterImpl(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
CellHalfEdgeIterImpl& operator++();
CellHalfEdgeIterImpl& operator--();
private:
std::vector<HalfEdgeHandle> halfedges_;
size_t cur_index_;
};
//===========================================================================
class CellEdgeIterImpl : public BaseCirculator<CellHandle, EdgeHandle> {
public:
typedef BaseCirculator<CellHandle, EdgeHandle> BaseIter;
typedef CellHandle CenterEntityHandle;
CellEdgeIterImpl(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
CellEdgeIterImpl& operator++();
CellEdgeIterImpl& operator--();
private:
std::vector<EdgeHandle> edges_;
size_t cur_index_;
};
//===========================================================================
class CellHalfFaceIterImpl : public BaseCirculator<CellHandle, HalfFaceHandle> {
public:
typedef BaseCirculator<CellHandle, HalfFaceHandle> BaseIter;
typedef CellHandle CenterEntityHandle;
CellHalfFaceIterImpl(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
......@@ -1182,6 +1273,7 @@ class CellFaceIterImpl : public BaseCirculator<CellHandle, FaceHandle> {
public:
typedef BaseCirculator<CellHandle, FaceHandle> BaseIter;
typedef CellHandle CenterEntityHandle;
CellFaceIterImpl(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
......@@ -1202,7 +1294,7 @@ template <class CirculatorImpl>
class GenericCirculator : public CirculatorImpl {
public:
GenericCirculator(const CellHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1) :
GenericCirculator(const typename CirculatorImpl::CenterEntityHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1) :
CirculatorImpl(_ref_h, _mesh, _max_laps) {}
GenericCirculator& operator++() {
......@@ -1257,6 +1349,14 @@ public:
//===========================================================================
typedef GenericCirculator<Internal::HalfFaceHalfEdgeIterImpl> HalfFaceHalfEdgeIter;
typedef GenericCirculator<Internal::HalfFaceEdgeIterImpl> HalfFaceEdgeIter;
typedef GenericCirculator<Internal::FaceHalfEdgeIterImpl> FaceHalfEdgeIter;
typedef GenericCirculator<Internal::FaceEdgeIterImpl> FaceEdgeIter;
typedef GenericCirculator<Internal::CellHalfEdgeIterImpl> CellHalfEdgeIter;
typedef GenericCirculator<Internal::CellEdgeIterImpl> CellEdgeIter;
typedef GenericCirculator<Internal::CellHalfFaceIterImpl> CellHalfFaceIter;
typedef GenericCirculator<Internal::CellFaceIterImpl> CellFaceIter;
......
......@@ -173,6 +173,42 @@ public:
return std::make_pair(begin, make_end_circulator(begin));
}
HalfFaceHalfEdgeIter hfhe_iter(const HalfFaceHandle& _h, int _max_laps = 1) const {
return HalfFaceHalfEdgeIter(_h, this, _max_laps);
}
std::pair<HalfFaceHalfEdgeIter, HalfFaceHalfEdgeIter> halfface_halfedges(const HalfFaceHandle& _h, int _max_laps = 1) const {
HalfFaceHalfEdgeIter begin = hfhe_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
HalfFaceEdgeIter hfe_iter(const HalfFaceHandle& _h, int _max_laps = 1) const {
return HalfFaceEdgeIter(_h, this, _max_laps);
}
std::pair<HalfFaceEdgeIter, HalfFaceEdgeIter> halfface_edges(const HalfFaceHandle& _h, int _max_laps = 1) const {
HalfFaceEdgeIter begin = hfe_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
FaceHalfEdgeIter fhe_iter(const FaceHandle& _h, int _max_laps = 1) const {
return FaceHalfEdgeIter(_h, this, _max_laps);
}
std::pair<FaceHalfEdgeIter, FaceHalfEdgeIter> face_halfedges(const FaceHandle& _h, int _max_laps = 1) const {
FaceHalfEdgeIter begin = fhe_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
FaceEdgeIter fe_iter(const FaceHandle& _h, int _max_laps = 1) const {
return FaceEdgeIter(_h, this, _max_laps);
}
std::pair<FaceEdgeIter, FaceEdgeIter> face_edges(const FaceHandle& _h, int _max_laps = 1) const {
FaceEdgeIter begin = fe_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
CellVertexIter cv_iter(const CellHandle& _h, int _max_laps = 1) const {
return CellVertexIter(_h, this, _max_laps);
}
......@@ -182,6 +218,24 @@ public:
return std::make_pair(begin, make_end_circulator(begin));
}
CellHalfEdgeIter che_iter(const CellHandle& _h, int _max_laps = 1) const {
return CellHalfEdgeIter(_h, this, _max_laps);
}
std::pair<CellHalfEdgeIter, CellHalfEdgeIter> cell_halfedges(const CellHandle& _h, int _max_laps = 1) const {
CellHalfEdgeIter begin = che_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
CellEdgeIter ce_iter(const CellHandle& _h, int _max_laps = 1) const {
return CellEdgeIter(_h, this, _max_laps);
}
std::pair<CellEdgeIter, CellEdgeIter> cell_edges(const CellHandle& _h, int _max_laps = 1) const {
CellEdgeIter begin = ce_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
CellHalfFaceIter chf_iter(const CellHandle& _h, int _max_laps = 1) const {
return CellHalfFaceIter(_h, this, _max_laps);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment