mirror of https://github.com/CGAL/cgal
create the primitive only if the propagation was successful
This commit is contained in:
parent
464f5a0d46
commit
331323ea44
|
|
@ -223,14 +223,13 @@ namespace Shape_detection {
|
||||||
|
|
||||||
// Try to grow a new region from the index of the seed item.
|
// Try to grow a new region from the index of the seed item.
|
||||||
if (!get(m_visited, seed)) {
|
if (!get(m_visited, seed)) {
|
||||||
typename Region_type::Primitive primitive = m_region_type.primitive();
|
const bool is_success = propagate(seed, region);
|
||||||
const bool is_success = propagate(seed, region, primitive);
|
|
||||||
|
|
||||||
// Check global conditions.
|
// Check global conditions.
|
||||||
if (!is_success || !m_region_type.is_valid_region(region)) {
|
if (!is_success || !m_region_type.is_valid_region(region)) {
|
||||||
revert(region);
|
revert(region);
|
||||||
} else {
|
} else {
|
||||||
*(region_out++) = std::pair<typename RegionType::Primitive, Region>(primitive, region);
|
*(region_out++) = std::pair<typename RegionType::Primitive, Region>(m_region_type.primitive(), region);
|
||||||
fill_region_map(m_nb_regions++, region);
|
fill_region_map(m_nb_regions++, region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +335,7 @@ namespace Shape_detection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool propagate(const Item &seed, Region& region, typename RegionType::Primitive &primitive) {
|
bool propagate(const Item &seed, Region& region) {
|
||||||
region.clear();
|
region.clear();
|
||||||
|
|
||||||
// Use two queues, while running on this queue, push to the other queue;
|
// Use two queues, while running on this queue, push to the other queue;
|
||||||
|
|
@ -352,7 +351,6 @@ namespace Shape_detection {
|
||||||
|
|
||||||
// Update internal properties of the region.
|
// Update internal properties of the region.
|
||||||
const bool is_well_created = m_region_type.update(region);
|
const bool is_well_created = m_region_type.update(region);
|
||||||
primitive = m_region_type.primitive();
|
|
||||||
if (!is_well_created) return false;
|
if (!is_well_created) return false;
|
||||||
|
|
||||||
bool grown = true;
|
bool grown = true;
|
||||||
|
|
@ -423,9 +421,6 @@ namespace Shape_detection {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it fits, update the primitive.
|
|
||||||
primitive = m_region_type.primitive();
|
|
||||||
|
|
||||||
// Try to continue growing the region by considering formerly rejected elements.
|
// Try to continue growing the region by considering formerly rejected elements.
|
||||||
for (const std::pair<const Item, const Item>& p : rejected) {
|
for (const std::pair<const Item, const Item>& p : rejected) {
|
||||||
if (m_region_type.is_part_of_region(p.first, p.second, region)) {
|
if (m_region_type.is_part_of_region(p.first, p.second, region)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue