Commit 51a7ff1e authored by Mike Kremer's avatar Mike Kremer

Speed-up reading in files by disabling bottom-up incidences first while...

Speed-up reading in files by disabling bottom-up incidences first while reading and enabling it afterwards (if needed).

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@195 66977474-1d4b-4f09-8fe9-267525286df2
parent 730edfcc
......@@ -388,14 +388,14 @@ public:
public:
void enable_bottom_up_adjacencies(bool _enable) {
void enable_bottom_up_adjacencies(bool _enable = true) {
enable_vertex_bottom_up_adjacencies(_enable);
enable_edge_bottom_up_adjacencies(_enable);
enable_face_bottom_up_adjacencies(_enable);
}
void enable_vertex_bottom_up_adjacencies(bool _enable) {
void enable_vertex_bottom_up_adjacencies(bool _enable = true) {
if(_enable && !v_bottom_up_) {
// Vertex bottom-up adjacencies have to be
......@@ -410,7 +410,7 @@ public:
v_bottom_up_ = _enable;
}
void enable_edge_bottom_up_adjacencies(bool _enable) {
void enable_edge_bottom_up_adjacencies(bool _enable = true) {
if(_enable && !e_bottom_up_) {
// Edge bottom-up adjacencies have to be
......@@ -430,17 +430,15 @@ public:
e_bottom_up_ = _enable;
}
void enable_face_bottom_up_adjacencies(bool _enable) {
void enable_face_bottom_up_adjacencies(bool _enable = true) {
bool updateOrder = false;
if(_enable && !f_bottom_up_) {
// Face bottom-up adjacencies have to be
// recomputed for the whole mesh
compute_face_bottom_up_adjacencies();
if(e_bottom_up_) {
std::for_each(edges_begin(), edges_end(),
std::tr1::bind(&TopologyKernel::reorder_incident_halffaces, this, std::tr1::placeholders::_1));
}
updateOrder = true;
}
if(!_enable) {
......@@ -448,6 +446,13 @@ public:
}
f_bottom_up_ = _enable;
if(updateOrder) {
if(e_bottom_up_) {
std::for_each(edges_begin(), edges_end(),
std::tr1::bind(&TopologyKernel::reorder_incident_halffaces, this, std::tr1::placeholders::_1));
}
}
}
bool has_full_bottom_up_adjacencies() const {
......
......@@ -81,7 +81,10 @@ bool FileManager::readFile(const std::string& _filename, MeshT& _mesh,
unsigned int v1 = 0; unsigned int v2 = 0;
_mesh.clear();
_mesh.enable_bottom_up_adjacencies(_computeBottomUpAdjacencies);
// Temporarily disable bottom-up incidences
// since it's way faster to first add all the
// geometry and compute them in one pass afterwards
_mesh.enable_bottom_up_adjacencies(false);
/*
* Header
......@@ -179,7 +182,7 @@ bool FileManager::readFile(const std::string& _filename, MeshT& _mesh,
sstr.str(line);
sstr >> v1;
sstr >> v2;
_mesh.add_edge(VertexHandle(v1), VertexHandle(v2));
_mesh.add_edge(VertexHandle(v1), VertexHandle(v2), true);
}
}
......@@ -279,6 +282,11 @@ bool FileManager::readFile(const std::string& _filename, MeshT& _mesh,
iff.close();
if(_computeBottomUpAdjacencies) {
// Compute bottom-up incidences
_mesh.enable_bottom_up_adjacencies(true);
}
std::cerr << "######## openvolumemesh info #########" << std::endl;
std::cerr << "#vertices: " << _mesh.n_vertices() << std::endl;
std::cerr << "#edges: " << _mesh.n_edges() << std::endl;
......
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