mirror of https://github.com/CGAL/cgal
switch to priority_queue
This commit is contained in:
parent
918bb62140
commit
762397776e
|
|
@ -15,6 +15,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <queue>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
|
@ -85,17 +86,6 @@ public:
|
||||||
face_descriptor seed;
|
face_descriptor seed;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The facet candidate to be queued.
|
|
||||||
struct FacetToIntegrate {
|
|
||||||
face_descriptor f;
|
|
||||||
std::size_t i;
|
|
||||||
FT fit_error;
|
|
||||||
|
|
||||||
bool operator<(const FacetToIntegrate &rhs) const {
|
|
||||||
return this->fit_error < rhs.fit_error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// The l21 metric, compute the fitting error from a facet to a plane proxy.
|
// The l21 metric, compute the fitting error from a facet to a plane proxy.
|
||||||
struct L21Metric {
|
struct L21Metric {
|
||||||
L21Metric(GeomTraits traits,
|
L21Metric(GeomTraits traits,
|
||||||
|
|
@ -413,14 +403,21 @@ private:
|
||||||
*/
|
*/
|
||||||
template<typename FacetSegmentMap>
|
template<typename FacetSegmentMap>
|
||||||
void flooding(FacetSegmentMap &seg_pmap) {
|
void flooding(FacetSegmentMap &seg_pmap) {
|
||||||
typedef std::multiset<FacetToIntegrate> CandidateSet;
|
// The facet candidate to be queued.
|
||||||
|
struct FacetToIntegrate {
|
||||||
|
face_descriptor f;
|
||||||
|
std::size_t i;
|
||||||
|
FT fit_error;
|
||||||
|
bool operator<(const FacetToIntegrate &rhs) const {
|
||||||
|
return fit_error > rhs.fit_error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
BOOST_FOREACH(face_descriptor f, faces(mesh))
|
BOOST_FOREACH(face_descriptor f, faces(mesh))
|
||||||
seg_pmap[f] = CGAL_NOT_TAGGED_ID;
|
seg_pmap[f] = CGAL_NOT_TAGGED_ID;
|
||||||
|
|
||||||
const std::size_t num_proxies = proxies.size();
|
std::priority_queue<FacetToIntegrate> facet_pqueue;
|
||||||
CandidateSet facet_candidates;
|
for (std::size_t i = 0; i < proxies.size(); ++i) {
|
||||||
for (std::size_t i = 0; i < num_proxies; ++i) {
|
|
||||||
face_descriptor f = proxies[i].seed;
|
face_descriptor f = proxies[i].seed;
|
||||||
seg_pmap[f] = i;
|
seg_pmap[f] = i;
|
||||||
|
|
||||||
|
|
@ -431,14 +428,14 @@ private:
|
||||||
cand.f = fadj;
|
cand.f = fadj;
|
||||||
cand.fit_error = fit_error(fadj, proxies[i]);
|
cand.fit_error = fit_error(fadj, proxies[i]);
|
||||||
cand.i = i;
|
cand.i = i;
|
||||||
facet_candidates.insert(cand);
|
facet_pqueue.push(cand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!facet_candidates.empty()) {
|
while (!facet_pqueue.empty()) {
|
||||||
const FacetToIntegrate &c = *(facet_candidates.begin());
|
const FacetToIntegrate c = facet_pqueue.top();
|
||||||
facet_candidates.erase(facet_candidates.begin());
|
facet_pqueue.pop();
|
||||||
if (seg_pmap[c.f] == CGAL_NOT_TAGGED_ID) {
|
if (seg_pmap[c.f] == CGAL_NOT_TAGGED_ID) {
|
||||||
seg_pmap[c.f] = c.i;
|
seg_pmap[c.f] = c.i;
|
||||||
BOOST_FOREACH(face_descriptor fadj, faces_around_face(halfedge(c.f, mesh), mesh)) {
|
BOOST_FOREACH(face_descriptor fadj, faces_around_face(halfedge(c.f, mesh), mesh)) {
|
||||||
|
|
@ -448,7 +445,7 @@ private:
|
||||||
cand.f = fadj;
|
cand.f = fadj;
|
||||||
cand.fit_error = fit_error(fadj, proxies[c.i]);
|
cand.fit_error = fit_error(fadj, proxies[c.i]);
|
||||||
cand.i = c.i;
|
cand.i = c.i;
|
||||||
facet_candidates.insert(cand);
|
facet_pqueue.push(cand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue