Commit 39ab4a00 authored by Mike Kremer's avatar Mike Kremer

Cache number of entities for faster access.

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@180 66977474-1d4b-4f09-8fe9-267525286df2
parent b3669c1c
......@@ -89,13 +89,8 @@ public:
return vertices_[_vh];
}
/// Override of n_vertices()
virtual unsigned int n_vertices() const {
return vertices_.size();
}
virtual VertexIter delete_vertex(const VertexHandle& _h) {
assert(_h.idx() < (int)n_vertices());
assert(_h.idx() < (int)TopologyKernel::n_vertices());
VertexIter nV = TopologyKernelT::delete_vertex(_h);
......
This diff is collapsed.
......@@ -206,15 +206,28 @@ public:
/// Get number of vertices in mesh
virtual unsigned int n_vertices() const { return n_vertices_; }
/// Get number of edges in mesh
virtual unsigned int n_edges() const { return edges_.size(); }
virtual unsigned int n_edges() const { return n_edges_; }
/// Get number of halfedges in mesh
virtual unsigned int n_halfedges() const { return (2u * edges_.size()); }
virtual unsigned int n_halfedges() const { return n_edges_ * 2u; }
/// Get number of faces in mesh
virtual unsigned int n_faces() const { return faces_.size(); }
virtual unsigned int n_faces() const { return n_faces_; }
/// Get number of halffaces in mesh
virtual unsigned int n_halffaces() const { return (2u * faces_.size()); }
virtual unsigned int n_halffaces() const { return n_faces_ * 2u; }
/// Get number of cells in mesh
virtual unsigned int n_cells() const { return cells_.size(); }
virtual unsigned int n_cells() const { return n_cells_; }
private:
// Cache total entity numbers
unsigned int n_vertices_;
unsigned int n_edges_;
unsigned int n_faces_;
unsigned int n_cells_;
public:
/// Add abstract vertex
virtual VertexHandle add_vertex();
......@@ -621,9 +634,6 @@ public:
protected:
// Number of (abstract) vertices
unsigned int n_vertices_;
// List of edges
std::vector<Edge> edges_;
......
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