Commit 12e440a5 authored by Mike Kremer's avatar Mike Kremer

Abandoned cast to int operator for handle types.

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@182 66977474-1d4b-4f09-8fe9-267525286df2
parent a1b27325
......@@ -60,61 +60,61 @@ public:
~StatusAttrib();
const OpenVolumeMeshStatus& operator[](const VertexHandle& _h) const {
return v_status_[_h];
return v_status_[_h.idx()];
}
OpenVolumeMeshStatus& operator[](const VertexHandle& _h) {
return v_status_[_h];
return v_status_[_h.idx()];
}
const OpenVolumeMeshStatus& operator[](const EdgeHandle& _h) const {
return e_status_[_h];
return e_status_[_h.idx()];
}
OpenVolumeMeshStatus& operator[](const EdgeHandle& _h) {
return e_status_[_h];
return e_status_[_h.idx()];
}
const OpenVolumeMeshStatus& operator[](const HalfEdgeHandle& _h) const {
return he_status_[_h];
return he_status_[_h.idx()];
}
OpenVolumeMeshStatus& operator[](const HalfEdgeHandle& _h) {
return he_status_[_h];
return he_status_[_h.idx()];
}
const OpenVolumeMeshStatus& operator[](const FaceHandle& _h) const {
return f_status_[_h];
return f_status_[_h.idx()];
}
OpenVolumeMeshStatus& operator[](const FaceHandle& _h) {
return f_status_[_h];
return f_status_[_h.idx()];
}
const OpenVolumeMeshStatus& operator[](const HalfFaceHandle& _h) const {
return hf_status_[_h];
return hf_status_[_h.idx()];
}
OpenVolumeMeshStatus& operator[](const HalfFaceHandle& _h) {
return hf_status_[_h];
return hf_status_[_h.idx()];
}
const OpenVolumeMeshStatus& operator[](const CellHandle& _h) const {
return c_status_[_h];
return c_status_[_h.idx()];
}
OpenVolumeMeshStatus& operator[](const CellHandle& _h) {
return c_status_[_h];
return c_status_[_h.idx()];
}
const OpenVolumeMeshStatus& mesh_status() const {
OpenVolumeMeshHandle h(0);
return m_status_[h];
return m_status_[h.idx()];
}
OpenVolumeMeshStatus& mesh_status() {
OpenVolumeMeshHandle h(0);
return m_status_[h];
return m_status_[h.idx()];
}
typedef VertexPropertyT<OpenVolumeMeshStatus>::const_iterator const_vstatus_iterator;
......
......@@ -86,7 +86,7 @@ public:
/// Get point _vh's coordinates
const VecT& vertex(const VertexHandle& _vh) const {
return vertices_[_vh];
return vertices_[_vh.idx()];
}
virtual VertexIter delete_vertex(const VertexHandle& _h) {
......
......@@ -65,19 +65,19 @@ cur_index_(0) {
return;
}
if((unsigned int)_ref_h >= BaseIter::mesh()->outgoing_hes_per_vertex_.size()) {
if((unsigned int)_ref_h.idx() >= BaseIter::mesh()->outgoing_hes_per_vertex_.size()) {
BaseIter::valid(false);
}
if(BaseIter::valid()) {
if((unsigned int)cur_index_ >= BaseIter::mesh()->outgoing_hes_per_vertex_[_ref_h].size()) {
if((unsigned int)cur_index_ >= BaseIter::mesh()->outgoing_hes_per_vertex_[_ref_h.idx()].size()) {
BaseIter::valid(false);
}
}
if(BaseIter::valid()) {
BaseIter::cur_handle((
BaseIter::mesh()->outgoing_hes_per_vertex_[_ref_h])[cur_index_]);
BaseIter::mesh()->outgoing_hes_per_vertex_[_ref_h.idx()])[cur_index_]);
}
}
......@@ -90,7 +90,7 @@ VertexOHalfEdgeIter& VertexOHalfEdgeIter::operator--() {
BaseIter::valid(false);
} else {
BaseIter::cur_handle((
BaseIter::mesh()->outgoing_hes_per_vertex_[BaseIter::ref_handle()])[cur_index_]);
BaseIter::mesh()->outgoing_hes_per_vertex_[BaseIter::ref_handle().idx()])[cur_index_]);
}
return *this;
......@@ -101,11 +101,11 @@ VertexOHalfEdgeIter& VertexOHalfEdgeIter::operator++() {
++cur_index_;
if((unsigned int)cur_index_ >= BaseIter::mesh()->outgoing_hes_per_vertex_[BaseIter::ref_handle()].size()) {
if((unsigned int)cur_index_ >= BaseIter::mesh()->outgoing_hes_per_vertex_[BaseIter::ref_handle().idx()].size()) {
BaseIter::valid(false);
} else {
BaseIter::cur_handle((
BaseIter::mesh()->outgoing_hes_per_vertex_[BaseIter::ref_handle()])[cur_index_]);
BaseIter::mesh()->outgoing_hes_per_vertex_[BaseIter::ref_handle().idx()])[cur_index_]);
}
return *this;
......@@ -127,19 +127,19 @@ cur_index_(0) {
return;
}
if((unsigned int)_ref_h >= BaseIter::mesh()->incident_hfs_per_he_.size()) {
if((unsigned int)_ref_h.idx() >= BaseIter::mesh()->incident_hfs_per_he_.size()) {
BaseIter::valid(false);
}
if(BaseIter::valid()) {
if((unsigned int)cur_index_ >= BaseIter::mesh()->incident_hfs_per_he_[_ref_h].size()) {
if((unsigned int)cur_index_ >= BaseIter::mesh()->incident_hfs_per_he_[_ref_h.idx()].size()) {
BaseIter::valid(false);
}
}
if(BaseIter::valid()) {
BaseIter::cur_handle((
BaseIter::mesh()->incident_hfs_per_he_[_ref_h])[cur_index_]);
BaseIter::mesh()->incident_hfs_per_he_[_ref_h.idx()])[cur_index_]);
}
}
......@@ -152,7 +152,7 @@ HalfEdgeHalfFaceIter& HalfEdgeHalfFaceIter::operator--() {
BaseIter::valid(false);
} else {
BaseIter::cur_handle((
BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle()])[cur_index_]);
BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle().idx()])[cur_index_]);
}
return *this;
......@@ -163,11 +163,11 @@ HalfEdgeHalfFaceIter& HalfEdgeHalfFaceIter::operator++() {
++cur_index_;
if((unsigned int)cur_index_ >= BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle()].size()) {
if((unsigned int)cur_index_ >= BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle().idx()].size()) {
BaseIter::valid(false);
} else {
BaseIter::cur_handle((
BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle()])[cur_index_]);
BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle().idx()])[cur_index_]);
}
return *this;
......@@ -188,22 +188,22 @@ BaseIter(_mesh, _ref_h) {
return;
}
if((unsigned int)_ref_h >= BaseIter::mesh()->outgoing_hes_per_vertex_.size()) {
if((unsigned int)_ref_h.idx() >= BaseIter::mesh()->outgoing_hes_per_vertex_.size()) {
BaseIter::valid(false);
return;
}
// Build up cell list
std::vector<HalfEdgeHandle> incidentHalfedges = BaseIter::mesh()->outgoing_hes_per_vertex_[_ref_h];
std::vector<HalfEdgeHandle> incidentHalfedges = BaseIter::mesh()->outgoing_hes_per_vertex_[_ref_h.idx()];
for(std::vector<HalfEdgeHandle>::const_iterator it = incidentHalfedges.begin(); it != incidentHalfedges.end(); ++it) {
if(*it < 0 || (unsigned int)*it >= BaseIter::mesh()->incident_hfs_per_he_.size()) continue;
std::vector<HalfFaceHandle> incidentHalfFaces = BaseIter::mesh()->incident_hfs_per_he_[*it];
if(*it < 0 || (unsigned int)it->idx() >= BaseIter::mesh()->incident_hfs_per_he_.size()) continue;
std::vector<HalfFaceHandle> incidentHalfFaces = BaseIter::mesh()->incident_hfs_per_he_[it->idx()];
for(std::vector<HalfFaceHandle>::const_iterator hf_it = incidentHalfFaces.begin();
hf_it != incidentHalfFaces.end(); ++hf_it) {
if((unsigned int)*hf_it < BaseIter::mesh()->incident_cell_per_hf_.size()) {
CellHandle c_idx = BaseIter::mesh()->incident_cell_per_hf_[*hf_it];
if((unsigned int)hf_it->idx() < BaseIter::mesh()->incident_cell_per_hf_.size()) {
CellHandle c_idx = BaseIter::mesh()->incident_cell_per_hf_[hf_it->idx()];
if(c_idx != TopologyKernel::InvalidCellHandle)
cells_.insert(c_idx);
}
......@@ -256,24 +256,24 @@ cur_index_(0) {
return;
}
if((unsigned int)_ref_h >= BaseIter::mesh()->incident_hfs_per_he_.size()) {
if((unsigned int)_ref_h.idx() >= BaseIter::mesh()->incident_hfs_per_he_.size()) {
BaseIter::valid(false);
return;
}
if((unsigned int)cur_index_ >= BaseIter::mesh()->incident_hfs_per_he_[_ref_h].size()) {
if((unsigned int)cur_index_ >= BaseIter::mesh()->incident_hfs_per_he_[_ref_h.idx()].size()) {
BaseIter::valid(false);
return;
}
if((unsigned int)((BaseIter::mesh()->incident_hfs_per_he_[_ref_h])[cur_index_]) >=
if((unsigned int)((BaseIter::mesh()->incident_hfs_per_he_[_ref_h.idx()])[cur_index_]).idx() >=
BaseIter::mesh()->incident_cell_per_hf_.size()) {
BaseIter::valid(false);
return;
}
BaseIter::cur_handle(BaseIter::mesh()->incident_cell_per_hf_[((BaseIter::mesh()->incident_hfs_per_he_[_ref_h])[cur_index_])]);
BaseIter::cur_handle(BaseIter::mesh()->incident_cell_per_hf_[((BaseIter::mesh()->incident_hfs_per_he_[_ref_h.idx()])[cur_index_]).idx()]);
}
......@@ -285,7 +285,7 @@ HalfEdgeCellIter& HalfEdgeCellIter::operator--() {
return *this;
}
BaseIter::cur_handle(BaseIter::mesh()->incident_cell_per_hf_[(
(BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle()])[cur_index_])]);
(BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle().idx()])[cur_index_]).idx()]);
return *this;
}
......@@ -293,19 +293,19 @@ HalfEdgeCellIter& HalfEdgeCellIter::operator--() {
HalfEdgeCellIter& HalfEdgeCellIter::operator++() {
++cur_index_;
if((unsigned int)cur_index_ >= BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle()].size()) {
if((unsigned int)cur_index_ >= BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle().idx()].size()) {
BaseIter::valid(false);
return *this;
}
if((unsigned int)((BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle()])[cur_index_]) >=
if((unsigned int)((BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle().idx()])[cur_index_]).idx() >=
BaseIter::mesh()->incident_cell_per_hf_.size()) {
BaseIter::valid(false);
return *this;
}
BaseIter::cur_handle(BaseIter::mesh()->incident_cell_per_hf_[(
(BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle()])[cur_index_])]);
(BaseIter::mesh()->incident_hfs_per_he_[BaseIter::ref_handle().idx()])[cur_index_]).idx()]);
return *this;
}
......@@ -377,7 +377,7 @@ BaseIter(_mesh, _ref_h) {
for(; hf_iter != BaseIter::mesh()->cell(_ref_h).halffaces().end(); ++hf_iter) {
HalfFaceHandle opp_hf = BaseIter::mesh()->opposite_halfface_handle(*hf_iter);
CellHandle ch = BaseIter::mesh()->incident_cell_per_hf_[opp_hf];
CellHandle ch = BaseIter::mesh()->incident_cell_per_hf_[opp_hf.idx()];
if(ch != TopologyKernel::InvalidCellHandle) {
adjacent_cells_.insert(ch);
}
......
......@@ -44,6 +44,25 @@
namespace OpenVolumeMesh {
bool operator==(const int& _lhs, const OpenVolumeMeshHandle& _rhs) {
return _lhs == _rhs.idx();
}
bool operator==(const unsigned int& _lhs, const OpenVolumeMeshHandle& _rhs) {
return _lhs == (unsigned int)_rhs.idx();
}
bool operator!=(const int& _lhs, const OpenVolumeMeshHandle& _rhs) {
return !(_lhs == _rhs);
}
bool operator!=(const unsigned int& _lhs, const OpenVolumeMeshHandle& _rhs) {
return !(_lhs == _rhs);
}
std::ostream& operator<<(std::ostream& _ostr, const OpenVolumeMeshHandle& _handle) {
_ostr << _handle.idx();
return _ostr;
......
......@@ -72,13 +72,21 @@ public:
inline bool operator<(int _idx) const { return idx_ < _idx; }
inline bool operator>(const OpenVolumeMeshHandle& _idx) const { return (this->idx_ > _idx.idx_); }
inline bool operator>(int _idx) const { return idx_ > _idx; }
inline bool operator==(const OpenVolumeMeshHandle& _h) const { return _h.idx_ == this->idx_; }
inline bool operator!=(const OpenVolumeMeshHandle& _h) const { return _h.idx_ != this->idx_; }
inline const int& idx() const { return idx_; }
void idx(const int& _idx) { idx_ = _idx; }
void reset() { idx_ = -1; }
inline operator int() const { return idx_; }
//inline operator int() const { return idx_; }
private:
int idx_;
......@@ -139,6 +147,14 @@ private:
CellHandle thld_;
};
bool operator==(const int& _lhs, const OpenVolumeMeshHandle& _rhs);
bool operator==(const unsigned int& _lhs, const OpenVolumeMeshHandle& _rhs);
bool operator!=(const int& _lhs, const OpenVolumeMeshHandle& _rhs);
bool operator!=(const unsigned int& _lhs, const OpenVolumeMeshHandle& _rhs);
std::ostream& operator<<(std::ostream& _ostr, const OpenVolumeMeshHandle& _handle);
std::istream& operator>>(std::istream& _istr, OpenVolumeMeshHandle& _handle);
......
......@@ -95,6 +95,9 @@ public:
reference operator[](size_t _idx) { return (*ptr::shared_ptr<PropT>::get())[_idx]; }
const_reference operator[](size_t _idx) const { return (*ptr::shared_ptr<PropT>::get())[_idx]; }
reference operator[](const OpenVolumeMeshHandle& _h) { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
const_reference operator[](const OpenVolumeMeshHandle& _h) const { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
virtual OpenVolumeMeshHandle handle() const;
virtual bool persistent() const { return ptr::shared_ptr<PropT>::get()->persistent(); }
......
This diff is collapsed.
......@@ -314,7 +314,7 @@ public:
return 0u;
}
assert((unsigned int)halfedge_handle(_eh, 0) < incident_hfs_per_he_.size());
return incident_hfs_per_he_[halfedge_handle(_eh, 0)].size();
return incident_hfs_per_he_[halfedge_handle(_eh, 0).idx()].size();
}
/// Get valence of face (number of incident edges)
......@@ -500,7 +500,7 @@ public:
bool is_boundary(const HalfFaceHandle& _halfFaceHandle) const {
return _halfFaceHandle.idx() >= 0 && (unsigned int)_halfFaceHandle.idx() < incident_cell_per_hf_.size() &&
incident_cell_per_hf_[_halfFaceHandle] == InvalidCellHandle;
incident_cell_per_hf_[_halfFaceHandle.idx()] == InvalidCellHandle;
}
bool is_boundary(const FaceHandle& _faceHandle) const {
......@@ -598,7 +598,7 @@ public:
static inline HalfFaceHandle halfface_handle(const FaceHandle& _h, const unsigned char _subIdx) {
// Is handle in range?
if(_h.idx() < 0 || _subIdx > 1) return InvalidHalfFaceHandle;
return HalfFaceHandle((2 * _h) + (_subIdx ? 1 : 0));
return HalfFaceHandle((2 * _h.idx()) + (_subIdx ? 1 : 0));
}
/// Handle conversion
......
......@@ -655,20 +655,20 @@ TEST_F(PolyhedralMeshBase, PolyhedralMeshProperties) {
VertexPropertyT<Vec3d> vp = mesh_.request_vertex_property<Vec3d>("VProp");
for(VertexIter v_it = mesh_.v_iter(); v_it.valid(); ++v_it) {
vp[*v_it] = Vec3d(1.0, 0.0, 0.0);
vp[v_it->idx()] = Vec3d(1.0, 0.0, 0.0);
}
for(VertexIter v_it = mesh_.v_iter(); v_it.valid(); ++v_it) {
Vec3d t;
t = vp[*v_it];
t = vp[v_it->idx()];
EXPECT_DOUBLE_EQ(1.0, t[0]);
EXPECT_DOUBLE_EQ(0.0, t[1]);
EXPECT_DOUBLE_EQ(0.0, t[2]);
}
VertexHandle vh = mesh_.add_vertex(Vec3d(3.0,3.0,3.0));
vp[vh] = Vec3d(0.0);
Vec3d p = vp[vh];
vp[vh.idx()] = Vec3d(0.0);
Vec3d p = vp[vh.idx()];
EXPECT_DOUBLE_EQ(0.0, p[0]);
EXPECT_DOUBLE_EQ(0.0, p[1]);
EXPECT_DOUBLE_EQ(0.0, p[2]);
......@@ -677,25 +677,25 @@ TEST_F(PolyhedralMeshBase, PolyhedralMeshProperties) {
unsigned int i = 0;
for(EdgeIter e_it = mesh_.e_iter(); e_it.valid(); ++e_it) {
ep[*e_it] = i++;
ep[e_it->idx()] = i++;
}
i = 0;
for(EdgeIter e_it = mesh_.e_iter(); e_it.valid(); ++e_it) {
EXPECT_EQ(i++, ep[*e_it]);
EXPECT_EQ(i++, ep[e_it->idx()]);
}
HalfFacePropertyT<bool> hfp = mesh_.request_halfface_property<bool>("HFProp");
bool b = false;
for(HalfFaceIter hf_it = mesh_.hf_iter(); hf_it.valid(); ++hf_it) {
hfp[*hf_it] = b;
hfp[hf_it->idx()] = b;
b = !b;
}
b = false;
for(HalfFaceIter hf_it = mesh_.hf_iter(); hf_it.valid(); ++hf_it) {
EXPECT_EQ(b, hfp[*hf_it]);
EXPECT_EQ(b, hfp[hf_it->idx()]);
b = !b;
}
......@@ -703,11 +703,11 @@ TEST_F(PolyhedralMeshBase, PolyhedralMeshProperties) {
CellPropertyT<std::string> cp = mesh_.request_cell_property<std::string>("CProp");
for(CellIter c_it = mesh_.c_iter(); c_it.valid(); ++c_it) {
cp[*c_it] = std::string("MyTestString");
cp[c_it->idx()] = std::string("MyTestString");
}
for(CellIter c_it = mesh_.c_iter(); c_it.valid(); ++c_it) {
EXPECT_EQ(std::string("MyTestString"), cp[*c_it]);
EXPECT_EQ(std::string("MyTestString"), cp[c_it->idx()]);
}
}
......@@ -941,17 +941,29 @@ TEST_F(HexahedralMeshBase, GarbageCollectionTestProps1) {
FacePropertyT<int> fprop = mesh_.request_face_property<int>("FProp");
fprop[FaceHandle(0)] = 11;
fprop[FaceHandle(1)] = 10;
fprop[FaceHandle(2)] = 9;
fprop[FaceHandle(3)] = 8;
fprop[FaceHandle(4)] = 7;
fprop[FaceHandle(5)] = 6;
fprop[FaceHandle(6)] = 5;
fprop[FaceHandle(7)] = 4;
fprop[FaceHandle(8)] = 3;
fprop[FaceHandle(9)] = 2;
fprop[FaceHandle(10)] = 1;
FaceHandle fh0(0);
FaceHandle fh1(1);
FaceHandle fh2(2);
FaceHandle fh3(3);
FaceHandle fh4(4);
FaceHandle fh5(5);
FaceHandle fh6(6);
FaceHandle fh7(7);
FaceHandle fh8(8);
FaceHandle fh9(9);
FaceHandle fh10(10);
fprop[fh0] = 11;
fprop[fh1] = 10;
fprop[fh2] = 9;
fprop[fh3] = 8;
fprop[fh4] = 7;
fprop[fh5] = 6;
fprop[fh6] = 5;
fprop[fh7] = 4;
fprop[fh8] = 3;
fprop[fh9] = 2;
fprop[fh10] = 1;
status[VertexHandle(0)].set_deleted(true);
......@@ -964,7 +976,7 @@ TEST_F(HexahedralMeshBase, GarbageCollectionTestProps1) {
std::set<int> fprops_i;
for(FaceIter f_it = mesh_.f_iter(); f_it.valid(); ++f_it) {
fprops_i.insert(fprop[*f_it]);
fprops_i.insert(fprop[f_it->idx()]);
}
EXPECT_EQ(0, fprops_i.count(11));
......@@ -988,17 +1000,29 @@ TEST_F(HexahedralMeshBase, GarbageCollectionTestProps2) {
FacePropertyT<int> fprop = mesh_.request_face_property<int>("FProp");
fprop[FaceHandle(0)] = 11;
fprop[FaceHandle(1)] = 10;
fprop[FaceHandle(2)] = 9;
fprop[FaceHandle(3)] = 8;
fprop[FaceHandle(4)] = 7;
fprop[FaceHandle(5)] = 6;
fprop[FaceHandle(6)] = 5;
fprop[FaceHandle(7)] = 4;
fprop[FaceHandle(8)] = 3;
fprop[FaceHandle(9)] = 2;
fprop[FaceHandle(10)] = 1;
FaceHandle fh0(0);
FaceHandle fh1(1);
FaceHandle fh2(2);
FaceHandle fh3(3);
FaceHandle fh4(4);
FaceHandle fh5(5);
FaceHandle fh6(6);
FaceHandle fh7(7);
FaceHandle fh8(8);
FaceHandle fh9(9);
FaceHandle fh10(10);
fprop[fh0] = 11;
fprop[fh1] = 10;
fprop[fh2] = 9;
fprop[fh3] = 8;
fprop[fh4] = 7;
fprop[fh5] = 6;
fprop[fh6] = 5;
fprop[fh7] = 4;
fprop[fh8] = 3;
fprop[fh9] = 2;
fprop[fh10] = 1;
status[FaceHandle(0)].set_deleted(true);
......@@ -1011,7 +1035,7 @@ TEST_F(HexahedralMeshBase, GarbageCollectionTestProps2) {
std::set<int> fprops_i;
for(FaceIter f_it = mesh_.f_iter(); f_it.valid(); ++f_it) {
fprops_i.insert(fprop[*f_it]);
fprops_i.insert(fprop[f_it->idx()]);
}
EXPECT_EQ(0, fprops_i.count(11));
......
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