Commit 110a223b authored by Mike Kremer's avatar Mike Kremer

Moved boundary half-face-half-face iterator to topology kernel class.

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@216 66977474-1d4b-4f09-8fe9-267525286df2
parent 3f539b38
......@@ -468,6 +468,68 @@ HalfFaceVertexIter& HalfFaceVertexIter::operator++() {
return *this;
}
//================================================================================================
// BoundaryHalfFaceHalfFaceIter
//================================================================================================
BoundaryHalfFaceHalfFaceIter::BoundaryHalfFaceHalfFaceIter(const HalfFaceHandle& _ref_h,
const TopologyKernel* _mesh) :
BaseIter(_mesh, _ref_h) {
if(!_mesh->has_face_bottom_up_incidences()) {
std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
BaseIter::valid(false);
return;
}
// Go over all incident halfedges
std::vector<HalfEdgeHandle> halfedges = _mesh->halfface(_ref_h).halfedges();
for(std::vector<HalfEdgeHandle>::const_iterator he_it = halfedges.begin();
he_it != halfedges.end(); ++he_it) {
// Get outside halffaces
OpenVolumeMesh::HalfEdgeHalfFaceIter hehf_it = _mesh->hehf_iter(_mesh->opposite_halfedge_handle(*he_it));
for(; hehf_it.valid(); ++hehf_it) {
if(_mesh->is_boundary(*hehf_it)) {
neighbor_halffaces_.push_back(*hehf_it);
common_edges_.push_back(_mesh->edge_handle(*he_it));
}
}
}
cur_it_ = neighbor_halffaces_.begin();
edge_it_ = common_edges_.begin();
BaseIter::valid(cur_it_ != neighbor_halffaces_.end());
if(BaseIter::valid()) {
BaseIter::cur_handle(*cur_it_);
}
}
BoundaryHalfFaceHalfFaceIter& BoundaryHalfFaceHalfFaceIter::operator--() {
--cur_it_;
--edge_it_;
if(cur_it_ >= neighbor_halffaces_.begin()) {
BaseIter::cur_handle(*cur_it_);
} else {
BaseIter::valid(false);
}
return *this;
}
BoundaryHalfFaceHalfFaceIter& BoundaryHalfFaceHalfFaceIter::operator++() {
++cur_it_;
++edge_it_;
if(cur_it_ != neighbor_halffaces_.end()) {
BaseIter::cur_handle(*cur_it_);
} else {
BaseIter::valid(false);
}
return *this;
}
////================================================================================================
//// BoundaryFaceIter
////================================================================================================
......
......@@ -571,6 +571,73 @@ private:
//===========================================================================
class BoundaryHalfFaceHalfFaceIter : public BaseIterator<HalfFaceHandle,
HalfFaceHandle> {
private:
typedef BaseIterator<HalfFaceHandle,
HalfFaceHandle> BaseIter;
public:
BoundaryHalfFaceHalfFaceIter(const HalfFaceHandle& _ref_h,
const TopologyKernel* _mesh);
BoundaryHalfFaceHalfFaceIter& operator=(const BoundaryHalfFaceHalfFaceIter& _c) {
BaseIter::operator=(_c);
neighbor_halffaces_ = _c.neighbor_halffaces_;
cur_it_ = neighbor_halffaces_.begin();
return *this;
}
// Post increment/decrement operator
BoundaryHalfFaceHalfFaceIter operator++(int) {
BoundaryHalfFaceHalfFaceIter cpy = *this;
++(*this);
return cpy;
}
BoundaryHalfFaceHalfFaceIter operator--(int) {
BoundaryHalfFaceHalfFaceIter cpy = *this;
--(*this);
return cpy;
}
BoundaryHalfFaceHalfFaceIter operator+(int _n) {
BoundaryHalfFaceHalfFaceIter cpy = *this;
for(int i = 0; i < _n; ++i) {
++cpy;
}
return cpy;
}
BoundaryHalfFaceHalfFaceIter operator-(int _n) {
BoundaryHalfFaceHalfFaceIter cpy = *this;
for(int i = 0; i < _n; ++i) {
--cpy;
}
return cpy;
}
BoundaryHalfFaceHalfFaceIter& operator+=(int _n) {
for(int i = 0; i < _n; ++i) {
++(*this);
}
return *this;
}
BoundaryHalfFaceHalfFaceIter& operator-=(int _n) {
for(int i = 0; i < _n; ++i) {
--(*this);
}
return *this;
}
const EdgeHandle& common_edge() const { return *edge_it_; }
BoundaryHalfFaceHalfFaceIter& operator++();
BoundaryHalfFaceHalfFaceIter& operator--();
private:
std::vector<HalfFaceHandle> neighbor_halffaces_;
std::vector<EdgeHandle> common_edges_;
std::vector<HalfFaceHandle>::const_iterator cur_it_;
std::vector<EdgeHandle>::const_iterator edge_it_;
};
//===========================================================================
class VertexIter : public BaseIterator<
VertexHandle,
VertexHandle> {
......
......@@ -84,6 +84,8 @@ public:
void idx(const int& _idx) { idx_ = _idx; }
inline operator int() const { return idx_; }
void reset() { idx_ = -1; }
private:
......
......@@ -92,6 +92,7 @@ public:
friend class CellVertexIter;
friend class CellCellIter;
friend class HalfFaceVertexIter;
friend class BoundaryHalfFaceHalfFaceIter;
friend class BoundaryFaceIter;
friend class VertexIter;
friend class EdgeIter;
......@@ -128,6 +129,10 @@ public:
return HalfFaceVertexIter(_h, this);
}
BoundaryHalfFaceHalfFaceIter bhfhf_iter(const HalfFaceHandle& _ref_h) const {
return BoundaryHalfFaceHalfFaceIter(_ref_h, this);
}
BoundaryFaceIter bf_iter() const {
return BoundaryFaceIter(this);
}
......
......@@ -201,71 +201,6 @@ HalfFaceSheetHalfFaceIter& HalfFaceSheetHalfFaceIter::operator++() {
return *this;
}
//================================================================================================
// OutsideNeighborHalfFaceIter
//================================================================================================
OutsideNeighborHalfFaceIter::OutsideNeighborHalfFaceIter(const HalfFaceHandle& _ref_h,
const HexahedralMeshTopologyKernel* _mesh) :
BaseIter(_mesh, _ref_h) {
if(!_mesh->has_face_bottom_up_incidences()) {
std::cerr << "This iterator needs bottom-up incidences!" << std::endl;
BaseIter::valid(false);
return;
}
// Go over all incident halfedges
std::vector<HalfEdgeHandle> halfedges = _mesh->halfface(_ref_h).halfedges();
for(std::vector<HalfEdgeHandle>::const_iterator he_it = halfedges.begin();
he_it != halfedges.end(); ++he_it) {
// Get outside halffaces
OpenVolumeMesh::HalfEdgeHalfFaceIter hehf_it = _mesh->hehf_iter(_mesh->opposite_halfedge_handle(*he_it));
for(; hehf_it.valid(); ++hehf_it) {
if(_mesh->is_boundary(*hehf_it)) {
neighbor_halffaces_.push_back(*hehf_it);
common_edges_.push_back(_mesh->edge_handle(*he_it));
}
}
}
cur_it_ = neighbor_halffaces_.begin();
edge_it_ = common_edges_.begin();
BaseIter::valid(cur_it_ != neighbor_halffaces_.end());
if(BaseIter::valid()) {
BaseIter::cur_handle(*cur_it_);
}
}
OutsideNeighborHalfFaceIter& OutsideNeighborHalfFaceIter::operator--() {
--cur_it_;
--edge_it_;
if(cur_it_ >= neighbor_halffaces_.begin()) {
BaseIter::cur_handle(*cur_it_);
} else {
BaseIter::valid(false);
}
return *this;
}
OutsideNeighborHalfFaceIter& OutsideNeighborHalfFaceIter::operator++() {
++cur_it_;
++edge_it_;
if(cur_it_ != neighbor_halffaces_.end()) {
BaseIter::cur_handle(*cur_it_);
} else {
BaseIter::valid(false);
}
return *this;
}
//================================================================================================
// HexVertexIter
//================================================================================================
......
......@@ -178,72 +178,6 @@ private:
std::vector<EdgeHandle>::const_iterator edge_it_;
};
class OutsideNeighborHalfFaceIter : public BaseIterator<HalfFaceHandle,
HalfFaceHandle> {
private:
typedef BaseIterator<HalfFaceHandle,
HalfFaceHandle> BaseIter;
public:
OutsideNeighborHalfFaceIter(const HalfFaceHandle& _ref_h,
const HexahedralMeshTopologyKernel* _mesh);
OutsideNeighborHalfFaceIter& operator=(const OutsideNeighborHalfFaceIter& _c) {
BaseIter::operator=(_c);
neighbor_halffaces_ = _c.neighbor_halffaces_;
cur_it_ = neighbor_halffaces_.begin();
return *this;
}
// Post increment/decrement operator
OutsideNeighborHalfFaceIter operator++(int) {
OutsideNeighborHalfFaceIter cpy = *this;
++(*this);
return cpy;
}
OutsideNeighborHalfFaceIter operator--(int) {
OutsideNeighborHalfFaceIter cpy = *this;
--(*this);
return cpy;
}
OutsideNeighborHalfFaceIter operator+(int _n) {
OutsideNeighborHalfFaceIter cpy = *this;
for(int i = 0; i < _n; ++i) {
++cpy;
}
return cpy;
}
OutsideNeighborHalfFaceIter operator-(int _n) {
OutsideNeighborHalfFaceIter cpy = *this;
for(int i = 0; i < _n; ++i) {
--cpy;
}
return cpy;
}
OutsideNeighborHalfFaceIter& operator+=(int _n) {
for(int i = 0; i < _n; ++i) {
++(*this);
}
return *this;
}
OutsideNeighborHalfFaceIter& operator-=(int _n) {
for(int i = 0; i < _n; ++i) {
--(*this);
}
return *this;
}
const EdgeHandle& common_edge() const { return *edge_it_; }
OutsideNeighborHalfFaceIter& operator++();
OutsideNeighborHalfFaceIter& operator--();
private:
std::vector<HalfFaceHandle> neighbor_halffaces_;
std::vector<EdgeHandle> common_edges_;
std::vector<HalfFaceHandle>::const_iterator cur_it_;
std::vector<EdgeHandle>::const_iterator edge_it_;
};
/** \brief Iterate over all vertices of a hexahedron in a specific order
*
* Vertices are addressed in the following order:
......
......@@ -142,12 +142,10 @@ public:
friend class CellSheetCellIter;
friend class HalfFaceSheetHalfFaceIter;
friend class OutsideNeighborHalfFaceIter;
friend class HexVertexIter;
typedef class CellSheetCellIter CellSheetCellIter;
typedef class HalfFaceSheetHalfFaceIter HalfFaceSheetHalfFaceIter;
typedef class OutsideNeighborHalfFaceIter OutsideNeighborHalfFaceIter;
typedef class HexVertexIter HexVertexIter;
CellSheetCellIter csc_iter(const CellHandle& _ref_h, const unsigned char _orthDir) const {
......@@ -158,10 +156,6 @@ public:
return HalfFaceSheetHalfFaceIter(_ref_h, this);
}
OutsideNeighborHalfFaceIter onhf_iter(const HalfFaceHandle& _ref_h) const {
return OutsideNeighborHalfFaceIter(_ref_h, this);
}
HexVertexIter hv_iter(const CellHandle& _ref_h) const {
return HexVertexIter(_ref_h, this);
}
......
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