Commit 9e05d46b authored by Alexander Dielen's avatar Alexander Dielen
Browse files

Added six new circulators

- VertexIHalfEdgeIter
- VertexEdgeIter
- VertexHalfFaceIter
- EdgeHalfFaceIter
- EdgeFaceIter
- EdgeCellIter
parent 9e3d6128
Pipeline #6467 passed with stage
in 4 minutes and 28 seconds
......@@ -1061,6 +1061,117 @@ CellIter& CellIter::operator++() {
namespace Internal {
////================================================================================================
//// VertexIHalfEdgeIterImpl
////================================================================================================
VertexIHalfEdgeIterImpl::VertexIHalfEdgeIterImpl(const VertexHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
voh_iter_(_mesh->voh_iter(_ref_h, _max_laps))
{
BaseIter::valid(voh_iter_.valid());
if (BaseIter::valid()) {
BaseIter::cur_handle(mesh()->opposite_halfedge_handle(*voh_iter_));
}
}
VertexIHalfEdgeIterImpl& VertexIHalfEdgeIterImpl::operator--() {
--voh_iter_;
BaseIter::lap(voh_iter_.lap());
BaseIter::valid(voh_iter_.valid());
BaseIter::cur_handle(mesh()->opposite_halfedge_handle(*voh_iter_));
return *this;
}
VertexIHalfEdgeIterImpl& VertexIHalfEdgeIterImpl::operator++() {
++voh_iter_;
BaseIter::lap(voh_iter_.lap());
BaseIter::valid(voh_iter_.valid());
BaseIter::cur_handle(mesh()->opposite_halfedge_handle(*voh_iter_));
return *this;
}
////================================================================================================
//// VertexEdgeIterImpl
////================================================================================================
VertexEdgeIterImpl::VertexEdgeIterImpl(const VertexHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
voh_iter_(_mesh->voh_iter(_ref_h, _max_laps))
{
BaseIter::valid(voh_iter_.valid());
if (BaseIter::valid()) {
BaseIter::cur_handle(mesh()->edge_handle(*voh_iter_));
}
}
VertexEdgeIterImpl& VertexEdgeIterImpl::operator--() {
--voh_iter_;
BaseIter::lap(voh_iter_.lap());
BaseIter::valid(voh_iter_.valid());
BaseIter::cur_handle(mesh()->edge_handle(*voh_iter_));
return *this;
}
VertexEdgeIterImpl& VertexEdgeIterImpl::operator++() {
++voh_iter_;
BaseIter::lap(voh_iter_.lap());
BaseIter::valid(voh_iter_.valid());
BaseIter::cur_handle(mesh()->edge_handle(*voh_iter_));
return *this;
}
////================================================================================================
//// VertexHalfFaceIterImpl
////================================================================================================
VertexHalfFaceIterImpl::VertexHalfFaceIterImpl(const VertexHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
cur_index_(0)
{
for (VertexEdgeIter ve_iter = _mesh->ve_iter(_ref_h); ve_iter.valid(); ++ve_iter) {
for (EdgeHalfFaceIter ehf_iter = _mesh->ehf_iter(*ve_iter); ehf_iter.valid(); ++ehf_iter) {
halffaces_.push_back(*ehf_iter);
}
}
// Remove all duplicate entries
std::sort(halffaces_.begin(), halffaces_.end());
halffaces_.resize(std::unique(halffaces_.begin(), halffaces_.end()) - halffaces_.begin());
BaseIter::valid(halffaces_.size() > 0);
if (BaseIter::valid()) {
BaseIter::cur_handle(halffaces_[cur_index_]);
}
}
VertexHalfFaceIterImpl& VertexHalfFaceIterImpl::operator--() {
if (cur_index_ == 0) {
cur_index_ = halffaces_.size() - 1;
--lap_;
if (lap_ < 0)
BaseIter::valid(false);
}
else {
--cur_index_;
}
BaseIter::cur_handle(halffaces_[cur_index_]);
return *this;
}
VertexHalfFaceIterImpl& VertexHalfFaceIterImpl::operator++() {
++cur_index_;
if (cur_index_ >= halffaces_.size()) {
cur_index_ = 0;
++lap_;
if (lap_ >= max_laps_)
BaseIter::valid(false);
}
BaseIter::cur_handle(halffaces_[cur_index_]);
return *this;
}
////================================================================================================
//// HalfEdgeFaceIterImpl
////================================================================================================
......@@ -1110,6 +1221,69 @@ HalfEdgeFaceIterImpl& HalfEdgeFaceIterImpl::operator++() {
}
////================================================================================================
//// EdgeHalfFaceIterImpl
////================================================================================================
EdgeHalfFaceIterImpl::EdgeHalfFaceIterImpl(const EdgeHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
BaseIter(_mesh, _ref_h, _max_laps),
cur_index_(0)
{
const HalfEdgeHandle he = _mesh->halfedge_handle(_ref_h, 0);
for (HalfEdgeHalfFaceIter hehf_iter = _mesh->hehf_iter(he); hehf_iter.valid(); ++hehf_iter) {
halffaces_.push_back(*hehf_iter);
halffaces_.push_back(_mesh->opposite_halfface_handle(*hehf_iter));
}
BaseIter::valid(halffaces_.size() > 0);
if (BaseIter::valid()) {
BaseIter::cur_handle(halffaces_[cur_index_]);
}
}
EdgeHalfFaceIterImpl& EdgeHalfFaceIterImpl::operator--() {
if (cur_index_ == 0) {
cur_index_ = halffaces_.size() - 1;
--lap_;
if (lap_ < 0)
BaseIter::valid(false);
}
else {
--cur_index_;
}
BaseIter::cur_handle(halffaces_[cur_index_]);
return *this;
}
EdgeHalfFaceIterImpl& EdgeHalfFaceIterImpl::operator++() {
++cur_index_;
if (cur_index_ >= halffaces_.size()) {
cur_index_ = 0;
++lap_;
if (lap_ >= max_laps_)
BaseIter::valid(false);
}
BaseIter::cur_handle(halffaces_[cur_index_]);
return *this;
}
////================================================================================================
//// EdgeFaceIterImpl
////================================================================================================
EdgeFaceIterImpl::EdgeFaceIterImpl(const EdgeHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
HalfEdgeFaceIterImpl(_mesh->halfedge_handle(_ref_h, 0), _mesh, _max_laps) {}
////================================================================================================
//// EdgeCellIterImpl
////================================================================================================
EdgeCellIterImpl::EdgeCellIterImpl(const EdgeHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps) :
HalfEdgeCellIter(_mesh->halfedge_handle(_ref_h, 0), _mesh, _max_laps) {}
////================================================================================================
//// HalfFaceHalfEdgeIterImpl
////================================================================================================
......
......@@ -1162,6 +1162,58 @@ namespace Internal {
//===========================================================================
class VertexIHalfEdgeIterImpl : public BaseCirculator<VertexHandle, HalfEdgeHandle> {
public:
typedef BaseCirculator<VertexHandle, HalfEdgeHandle> BaseIter;
typedef VertexHandle CenterEntityHandle;
VertexIHalfEdgeIterImpl(const VertexHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
VertexIHalfEdgeIterImpl& operator++();
VertexIHalfEdgeIterImpl& operator--();
private:
VertexOHalfEdgeIter voh_iter_;
};
//===========================================================================
class VertexEdgeIterImpl : public BaseCirculator<VertexHandle, EdgeHandle> {
public:
typedef BaseCirculator<VertexHandle, EdgeHandle> BaseIter;
typedef VertexHandle CenterEntityHandle;
VertexEdgeIterImpl(const VertexHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
VertexEdgeIterImpl& operator++();
VertexEdgeIterImpl& operator--();
private:
VertexOHalfEdgeIter voh_iter_;
};
//===========================================================================
class VertexHalfFaceIterImpl : public BaseCirculator<VertexHandle, HalfFaceHandle> {
public:
typedef BaseCirculator<VertexHandle, HalfFaceHandle> BaseIter;
typedef VertexHandle CenterEntityHandle;
VertexHalfFaceIterImpl(const VertexHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
VertexHalfFaceIterImpl& operator++();
VertexHalfFaceIterImpl& operator--();
private:
std::vector<HalfFaceHandle> halffaces_;
size_t cur_index_;
};
//===========================================================================
class HalfEdgeFaceIterImpl : public BaseCirculator<HalfEdgeHandle, FaceHandle> {
public:
......@@ -1180,6 +1232,44 @@ private:
//===========================================================================
class EdgeHalfFaceIterImpl : public BaseCirculator<EdgeHandle, HalfFaceHandle> {
public:
typedef BaseCirculator<EdgeHandle, HalfFaceHandle> BaseIter;
typedef EdgeHandle CenterEntityHandle;
EdgeHalfFaceIterImpl(const EdgeHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
EdgeHalfFaceIterImpl& operator++();
EdgeHalfFaceIterImpl& operator--();
private:
std::vector<HalfFaceHandle> halffaces_;
size_t cur_index_;
};
//===========================================================================
class EdgeFaceIterImpl : public HalfEdgeFaceIterImpl {
public:
typedef EdgeHandle CenterEntityHandle;
EdgeFaceIterImpl(const EdgeHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
};
//===========================================================================
class EdgeCellIterImpl : public HalfEdgeCellIter {
public:
typedef EdgeHandle CenterEntityHandle;
EdgeCellIterImpl(const EdgeHandle& _ref_h, const TopologyKernel* _mesh, int _max_laps = 1);
};
//===========================================================================
class HalfFaceHalfEdgeIterImpl : public BaseCirculator<HalfFaceHandle, HalfEdgeHandle> {
public:
......@@ -1377,8 +1467,16 @@ public:
//===========================================================================
typedef GenericCirculator<Internal::VertexIHalfEdgeIterImpl> VertexIHalfEdgeIter;
typedef GenericCirculator<Internal::VertexEdgeIterImpl> VertexEdgeIter;
typedef GenericCirculator<Internal::VertexHalfFaceIterImpl> VertexHalfFaceIter;
typedef GenericCirculator<Internal::HalfEdgeFaceIterImpl> HalfEdgeFaceIter;
typedef GenericCirculator<Internal::EdgeHalfFaceIterImpl> EdgeHalfFaceIter;
typedef GenericCirculator<Internal::EdgeFaceIterImpl> EdgeFaceIter;
typedef GenericCirculator<Internal::EdgeCellIterImpl> EdgeCellIter;
typedef GenericCirculator<Internal::HalfFaceHalfEdgeIterImpl> HalfFaceHalfEdgeIter;
typedef GenericCirculator<Internal::HalfFaceEdgeIterImpl> HalfFaceEdgeIter;
......
......@@ -119,6 +119,15 @@ protected:
public:
VertexVertexIter vv_iter(const VertexHandle& _h, int _max_laps = 1) const {
return VertexVertexIter(_h, this, _max_laps);
}
std::pair<VertexVertexIter, VertexVertexIter> vertex_vertices(const VertexHandle& _h, int _max_laps = 1) const {
VertexVertexIter begin = vv_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
VertexOHalfEdgeIter voh_iter(const VertexHandle& _h, int _max_laps = 1) const {
return VertexOHalfEdgeIter(_h, this, _max_laps);
}
......@@ -128,12 +137,30 @@ public:
return std::make_pair(begin, make_end_circulator(begin));
}
VertexVertexIter vv_iter(const VertexHandle& _h, int _max_laps = 1) const {
return VertexVertexIter(_h, this, _max_laps);
VertexIHalfEdgeIter vih_iter(const VertexHandle& _h, int _max_laps = 1) const {
return VertexIHalfEdgeIter(_h, this, _max_laps);
}
std::pair<VertexVertexIter, VertexVertexIter> vertex_vertices(const VertexHandle& _h, int _max_laps = 1) const {
VertexVertexIter begin = vv_iter(_h, _max_laps);
std::pair<VertexIHalfEdgeIter, VertexIHalfEdgeIter> incoming_halfedges(const VertexHandle& _h, int _max_laps = 1) const {
VertexIHalfEdgeIter begin = vih_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
VertexEdgeIter ve_iter(const VertexHandle& _h, int _max_laps = 1) const {
return VertexEdgeIter(_h, this, _max_laps);
}
std::pair<VertexEdgeIter, VertexEdgeIter> vertex_edges(const VertexHandle& _h, int _max_laps = 1) const {
VertexEdgeIter begin = ve_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
VertexHalfFaceIter vhf_iter(const VertexHandle& _h, int _max_laps = 1) const {
return VertexHalfFaceIter(_h, this, _max_laps);
}
std::pair<VertexHalfFaceIter, VertexHalfFaceIter> vertex_halffaces(const VertexHandle& _h, int _max_laps = 1) const {
VertexHalfFaceIter begin = vhf_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
......@@ -182,6 +209,33 @@ public:
return std::make_pair(begin, make_end_circulator(begin));
}
EdgeHalfFaceIter ehf_iter(const EdgeHandle& _h, int _max_laps = 1) const {
return EdgeHalfFaceIter(_h, this, _max_laps);
}
std::pair<EdgeHalfFaceIter, EdgeHalfFaceIter> edge_halffaces(const EdgeHandle& _h, int _max_laps = 1) const {
EdgeHalfFaceIter begin = ehf_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
EdgeFaceIter ef_iter(const EdgeHandle& _h, int _max_laps = 1) const {
return EdgeFaceIter(_h, this, _max_laps);
}
std::pair<EdgeFaceIter, EdgeFaceIter> edge_faces(const EdgeHandle& _h, int _max_laps = 1) const {
EdgeFaceIter begin = ef_iter(_h, _max_laps);
return std::make_pair(begin, make_end_circulator(begin));
}
EdgeCellIter ec_iter(const EdgeHandle& _h, int _max_laps = 1) const {
return EdgeCellIter(_h, this, _max_laps);
}
std::pair<EdgeCellIter, EdgeCellIter> edge_cells(const EdgeHandle& _h, int _max_laps = 1) const {
EdgeCellIter begin = ec_iter(_h, _max_laps);
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);
}
......
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