Make Hausdorff module thread safe. Removed static point vector. (Thanks to Falko Löffler for the fix)
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@796 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -203,7 +203,6 @@ float
|
|||||||
ModHausdorffT<MeshT>::
|
ModHausdorffT<MeshT>::
|
||||||
collapse_priority(const CollapseInfo& _ci)
|
collapse_priority(const CollapseInfo& _ci)
|
||||||
{
|
{
|
||||||
static Points points; points.clear();
|
|
||||||
std::vector<FaceHandle> faces; faces.reserve(20);
|
std::vector<FaceHandle> faces; faces.reserve(20);
|
||||||
typename Mesh::VertexFaceIter vf_it;
|
typename Mesh::VertexFaceIter vf_it;
|
||||||
typename Mesh::FaceHandle fh;
|
typename Mesh::FaceHandle fh;
|
||||||
@@ -211,6 +210,9 @@ collapse_priority(const CollapseInfo& _ci)
|
|||||||
typename Mesh::CFVIter fv_it;
|
typename Mesh::CFVIter fv_it;
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
|
// Clear the temporary point storage
|
||||||
|
tmp_points_.clear();
|
||||||
|
|
||||||
// collect all points to be tested
|
// collect all points to be tested
|
||||||
// collect all faces to be tested against
|
// collect all faces to be tested against
|
||||||
for (vf_it=mesh_.vf_iter(_ci.v0); vf_it; ++vf_it) {
|
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);
|
faces.push_back(fh);
|
||||||
|
|
||||||
Points& pts = mesh_.property(points_, 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
|
// add point to be removed
|
||||||
points.push_back(_ci.p0);
|
tmp_points_.push_back(_ci.p0);
|
||||||
|
|
||||||
// setup iterators
|
// setup iterators
|
||||||
typename std::vector<FaceHandle>::iterator fh_it, fh_end(faces.end());
|
typename std::vector<FaceHandle>::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
|
// simulate collapse
|
||||||
mesh_.set_point(_ci.v0, _ci.p1);
|
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
|
// for each point: try to find a face such that error is < tolerance
|
||||||
ok = true;
|
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;
|
ok = false;
|
||||||
|
|
||||||
for (fh_it=faces.begin(); !ok && fh_it!=fh_end; ++fh_it) {
|
for (fh_it=faces.begin(); !ok && fh_it!=fh_end; ++fh_it) {
|
||||||
|
|||||||
@@ -137,7 +137,10 @@ class ModHausdorffT: public ModBaseT<MeshT> {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Mesh& mesh_;
|
/// Temporary point storage
|
||||||
|
Points tmp_points_;
|
||||||
|
|
||||||
|
Mesh& mesh_;
|
||||||
Scalar tolerance_;
|
Scalar tolerance_;
|
||||||
|
|
||||||
OpenMesh::FPropHandleT<Points> points_;
|
OpenMesh::FPropHandleT<Points> points_;
|
||||||
|
|||||||
Reference in New Issue
Block a user