From 9ed294c929d0ce4c5c863622caf1abbf017bb08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 29 Jan 2013 09:00:06 +0000 Subject: [PATCH] =?UTF-8?q?Make=20Hausdorff=20module=20thread=20safe.=20Re?= =?UTF-8?q?moved=20static=20point=20vector.=20(Thanks=20to=20Falko=20L?= =?UTF-8?q?=C3=B6ffler=20for=20the=20fix)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@796 fdac6126-5c0c-442c-9429-916003d36597 --- src/OpenMesh/Tools/Decimater/ModHausdorffT.cc | 13 +++++++------ src/OpenMesh/Tools/Decimater/ModHausdorffT.hh | 5 ++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/OpenMesh/Tools/Decimater/ModHausdorffT.cc b/src/OpenMesh/Tools/Decimater/ModHausdorffT.cc index d78acf77..5399c005 100644 --- a/src/OpenMesh/Tools/Decimater/ModHausdorffT.cc +++ b/src/OpenMesh/Tools/Decimater/ModHausdorffT.cc @@ -203,7 +203,6 @@ float ModHausdorffT:: collapse_priority(const CollapseInfo& _ci) { - static Points points; points.clear(); std::vector faces; faces.reserve(20); typename Mesh::VertexFaceIter vf_it; typename Mesh::FaceHandle fh; @@ -211,6 +210,9 @@ collapse_priority(const CollapseInfo& _ci) typename Mesh::CFVIter fv_it; bool ok; + // Clear the temporary point storage + tmp_points_.clear(); + // collect all points to be tested // collect all faces to be tested against for (vf_it=mesh_.vf_iter(_ci.v0); vf_it; ++vf_it) { @@ -220,16 +222,15 @@ collapse_priority(const CollapseInfo& _ci) faces.push_back(fh); Points& pts = mesh_.property(points_, fh); - std::copy(pts.begin(), pts.end(), std::back_inserter(points)); + std::copy(pts.begin(), pts.end(), std::back_inserter(tmp_points_)); } // add point to be removed - points.push_back(_ci.p0); + tmp_points_.push_back(_ci.p0); // setup iterators typename std::vector::iterator fh_it, fh_end(faces.end()); - typename Points::const_iterator p_it, p_end(points.end()); - + typename Points::const_iterator p_it, p_end(tmp_points_.end()); // simulate collapse mesh_.set_point(_ci.v0, _ci.p1); @@ -237,7 +238,7 @@ collapse_priority(const CollapseInfo& _ci) // for each point: try to find a face such that error is < tolerance ok = true; - for (p_it=points.begin(); ok && p_it!=p_end; ++p_it) { + for (p_it=tmp_points_.begin(); ok && p_it!=p_end; ++p_it) { ok = false; for (fh_it=faces.begin(); !ok && fh_it!=fh_end; ++fh_it) { diff --git a/src/OpenMesh/Tools/Decimater/ModHausdorffT.hh b/src/OpenMesh/Tools/Decimater/ModHausdorffT.hh index a3041a44..c58c91aa 100644 --- a/src/OpenMesh/Tools/Decimater/ModHausdorffT.hh +++ b/src/OpenMesh/Tools/Decimater/ModHausdorffT.hh @@ -137,7 +137,10 @@ class ModHausdorffT: public ModBaseT { private: - Mesh& mesh_; + /// Temporary point storage + Points tmp_points_; + + Mesh& mesh_; Scalar tolerance_; OpenMesh::FPropHandleT points_;