Small corrections on reverse orientations; reformating; start to add tests

This commit is contained in:
Guillaume Damiand 2013-06-13 11:14:03 +02:00
parent 0ac3e69120
commit 7f7788bd84
5 changed files with 133 additions and 53 deletions

View File

@ -89,6 +89,12 @@ namespace CGAL {
template<typename CMap, unsigned int i, typename T>
friend struct internal::Decrease_attribute_functor_run;
template <typename CMap, typename Attrib>
friend struct internal::Reverse_orientation_of_map_functor;
template <typename CMap, typename Attrib>
friend struct internal::Reverse_orientation_of_connected_component_functor;
public:
typedef Tag_false Supports_cell_dart;
@ -188,6 +194,12 @@ namespace CGAL {
template<typename CMap, unsigned int i, typename T>
friend struct internal::Decrease_attribute_functor_run;
template <typename CMap, typename Attrib>
friend struct internal::Reverse_orientation_of_map_functor;
template <typename CMap, typename Attrib>
friend struct internal::Reverse_orientation_of_connected_component_functor;
public:
typedef Tag_true Supports_cell_dart;

View File

@ -2022,7 +2022,7 @@ namespace CGAL {
*/
void reverse_orientation_connected_component (Dart_handle adart)
{
internal::Reverse_orientation_of_conected_component_functor<Self>::run(this, adart);
internal::Reverse_orientation_of_connected_component_functor<Self>::run(this, adart);
}
/** Count the marked cells (at least one marked dart).

View File

@ -77,7 +77,7 @@ namespace CGAL {
friend struct internal::Reverse_orientation_of_map_functor;
template <typename CMap, typename Attrib>
friend struct internal::Reverse_orientation_of_conected_component_functor;
friend struct internal::Reverse_orientation_of_connected_component_functor;
public:
typedef Dart<d,Refs> Self;

View File

@ -414,7 +414,8 @@ struct Set_i_attribute_of_dart_functor<CMap, i, CGAL::Void>
};
// ****************************************************************************
/// Functor to reverse the orientation of a combinatorial map
template <typename CMap, typename Attrib = typename CMap::Helper::template Attribute_type<0>::type>
template <typename CMap, typename Attrib =
typename CMap::Helper::template Attribute_type<0>::type>
struct Reverse_orientation_of_map_functor
{
static void run(CMap *amap)
@ -422,29 +423,45 @@ struct Reverse_orientation_of_map_functor
int mark = amap->get_new_mark();
CGAL_precondition(amap->is_whole_map_unmarked(mark));
CGAL_precondition(amap->is_valid());
for (typename CMap::Dart_range::iterator current_dart = amap->darts().begin(),
last_dart = amap->darts().end(); current_dart != last_dart; ++current_dart) {
for (typename CMap::Dart_range::iterator current_dart=amap->darts().begin(),
last_dart = amap->darts().end(); current_dart!=last_dart;
++current_dart)
{
if (amap->is_marked(current_dart, mark)) continue;
typename CMap::Dart_handle first_dart_in_cell = current_dart;
typename CMap::Dart_handle current_dart_in_cell = first_dart_in_cell->beta(1);
typename CMap::Helper::template Attribute_handle<0>::type attribute_for_first_dart = current_dart_in_cell->template attribute<0>();
typename CMap::Dart_handle first_dart_in_cell= current_dart;
typename CMap::Dart_handle current_dart_in_cell=
first_dart_in_cell->beta(1);
typename CMap::Helper::template Attribute_handle<0>::type
attribute_for_first_dart=current_dart_in_cell->template attribute<0>();
attribute_for_first_dart->inc_nb_refs();
do {
amap->mark(current_dart_in_cell, mark);
typename CMap::Dart_handle previous_dart_in_cell = current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell = current_dart_in_cell->beta(1);
typename CMap::Helper::template Attribute_handle<0>::type next_attribute = next_dart_in_cell->template attribute<0>();
amap->template set_attribute_of_dart<0>(current_dart_in_cell, next_attribute); // One line error???
typename CMap::Dart_handle previous_dart_in_cell=
current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell=
current_dart_in_cell->beta(1);
typename CMap::Helper::template Attribute_handle<0>::type
next_attribute=next_dart_in_cell->template attribute<0>();
// One line error???
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(amap, current_dart_in_cell, next_attribute);
current_dart_in_cell->basic_link_beta(previous_dart_in_cell, 1);
current_dart_in_cell->basic_link_beta(next_dart_in_cell, 0);
current_dart_in_cell = current_dart_in_cell->beta(0);
} while (current_dart_in_cell != first_dart_in_cell);
}
while (current_dart_in_cell != first_dart_in_cell);
amap->mark(current_dart_in_cell, mark);
typename CMap::Dart_handle previous_dart_in_cell = current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell = current_dart_in_cell->beta(1);
amap->template set_attribute_of_dart<0>(current_dart_in_cell, attribute_for_first_dart);
typename CMap::Dart_handle previous_dart_in_cell=
current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell=
current_dart_in_cell->beta(1);
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(amap, current_dart_in_cell, attribute_for_first_dart);
attribute_for_first_dart->dec_nb_refs();
current_dart_in_cell->basic_link_beta(previous_dart_in_cell, 1);
current_dart_in_cell->basic_link_beta(next_dart_in_cell, 0);
} amap->negate_mark(mark);
}
amap->negate_mark(mark);
CGAL_postcondition(amap->is_whole_map_unmarked(mark));
CGAL_postcondition(amap->is_valid());
amap->free_mark(mark);
@ -458,83 +475,128 @@ struct Reverse_orientation_of_map_functor<CMap, Void>
int mark = amap->get_new_mark();
CGAL_precondition(amap->is_whole_map_unmarked(mark));
CGAL_precondition(amap->is_valid());
for (typename CMap::Dart_range::iterator current_dart = amap->darts().begin(),
last_dart = amap->darts().end(); current_dart != last_dart; ++current_dart) {
for (typename CMap::Dart_range::iterator current_dart=amap->darts().begin(),
last_dart = amap->darts().end(); current_dart!=last_dart;
++current_dart)
{
if (amap->is_marked(current_dart, mark)) continue;
for (typename CMap::template Dart_of_cell_range<2>::iterator current_dart_in_cell = amap->template darts_of_cell<2>(current_dart).begin(),
last_dart_in_cell = amap->template darts_of_cell<2>(current_dart).end(); current_dart_in_cell != last_dart_in_cell; ++current_dart_in_cell) {
for (typename CMap::template Dart_of_cell_range<2>::iterator
current_dart_in_cell=amap->template darts_of_cell<2>(current_dart).
begin(), last_dart_in_cell=amap->template darts_of_cell<2>
(current_dart).end(); current_dart_in_cell!=last_dart_in_cell;
++current_dart_in_cell)
{
amap->mark(current_dart_in_cell, mark);
typename CMap::Dart_handle previous_dart_in_cell = current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell = current_dart_in_cell->beta(1);
typename CMap::Dart_handle previous_dart_in_cell=
current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell=
current_dart_in_cell->beta(1);
current_dart_in_cell->basic_link_beta(previous_dart_in_cell, 1);
current_dart_in_cell->basic_link_beta(next_dart_in_cell, 0);
}
} amap->negate_mark(mark);
}
amap->negate_mark(mark);
CGAL_postcondition(amap->is_whole_map_unmarked(mark));
CGAL_postcondition(amap->is_valid());
amap->free_mark(mark);
}
};
// ****************************************************************************
/// Functor to reverse the orientation of a set of connected components in a given map
template <typename CMap, typename Attrib = typename CMap::Helper::template Attribute_type<0>::type>
struct Reverse_orientation_of_conected_component_functor
/// Functor to reverse the orientation of a connected component in a given map
template <typename CMap, typename Attrib=
typename CMap::Helper::template Attribute_type<0>::type>
struct Reverse_orientation_of_connected_component_functor
{
static void run(CMap *amap, typename CMap::Dart_handle adart)
{
int mark = amap->get_new_mark();
CGAL_precondition(amap->is_whole_map_unmarked(mark));
for (typename CMap::template Dart_of_cell_range<CMap::dimension+1>::iterator current_dart = amap->template darts_of_cell<CMap::dimension+1>(adart).begin(),
last_dart = amap->template darts_of_cell<CMap::dimension+1>(adart).end(); current_dart != last_dart; ++current_dart) {
for (typename CMap::template Dart_of_cell_range<CMap::dimension+1>::iterator
current_dart=amap->template darts_of_cell<CMap::dimension+1>(adart).
begin(), last_dart=amap->template darts_of_cell<CMap::dimension+1>
(adart).end(); current_dart!=last_dart; ++current_dart)
{
if (amap->is_marked(current_dart, mark)) continue;
typename CMap::Dart_handle first_dart_in_cell = current_dart;
typename CMap::Dart_handle current_dart_in_cell = first_dart_in_cell->beta(1);
typename CMap::Helper::template Attribute_handle<0>::type attribute_for_first_dart = current_dart_in_cell->template attribute<0>();
typename CMap::Dart_handle first_dart_in_cell=current_dart;
typename CMap::Dart_handle current_dart_in_cell=
first_dart_in_cell->beta(1);
typename CMap::Helper::template Attribute_handle<0>::type
attribute_for_first_dart=current_dart_in_cell->template attribute<0>();
attribute_for_first_dart->inc_nb_refs();
do {
amap->mark(current_dart_in_cell, mark);
typename CMap::Dart_handle previous_dart_in_cell = current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell = current_dart_in_cell->beta(1);
typename CMap::Helper::template Attribute_handle<0>::type next_attribute = next_dart_in_cell->template attribute<0>();
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::run(amap, current_dart_in_cell, next_attribute);
typename CMap::Dart_handle previous_dart_in_cell=
current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell=
current_dart_in_cell->beta(1);
typename CMap::Helper::template Attribute_handle<0>::type
next_attribute=next_dart_in_cell->template attribute<0>();
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(amap, current_dart_in_cell, next_attribute);
current_dart_in_cell->basic_link_beta(previous_dart_in_cell, 1);
current_dart_in_cell->basic_link_beta(next_dart_in_cell, 0);
current_dart_in_cell = current_dart_in_cell->beta(0);
} while (current_dart_in_cell != first_dart_in_cell);
}
while (current_dart_in_cell != first_dart_in_cell);
amap->mark(current_dart_in_cell, mark);
typename CMap::Dart_handle previous_dart_in_cell = current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell = current_dart_in_cell->beta(1);
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::run(amap, current_dart_in_cell, attribute_for_first_dart);
typename CMap::Dart_handle previous_dart_in_cell=
current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell=
current_dart_in_cell->beta(1);
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(amap, current_dart_in_cell, attribute_for_first_dart);
attribute_for_first_dart->dec_nb_refs();
current_dart_in_cell->basic_link_beta(previous_dart_in_cell, 1);
current_dart_in_cell->basic_link_beta(next_dart_in_cell, 0);
} for (typename CMap::template Dart_of_cell_range<CMap::dimension+1>::iterator current_dart = amap->template darts_of_cell<CMap::dimension+1>(adart).begin(),
last_dart = amap->template darts_of_cell<CMap::dimension+1>(adart).end(); current_dart != last_dart; ++current_dart) {
}
for (typename CMap::template Dart_of_cell_range<CMap::dimension+1>::iterator
current_dart=amap->template darts_of_cell<CMap::dimension+1>(adart).
begin(), last_dart=amap->template darts_of_cell<CMap::dimension+1>
(adart).end(); current_dart!=last_dart; ++current_dart)
{
amap->unmark(current_dart, mark);
} CGAL_postcondition(amap->is_whole_map_unmarked(mark));
}
CGAL_postcondition(amap->is_whole_map_unmarked(mark));
amap->free_mark(mark);
}
};
template <typename CMap>
struct Reverse_orientation_of_conected_component_functor<CMap, Void>
struct Reverse_orientation_of_connected_component_functor<CMap, Void>
{
static void run(CMap *amap, typename CMap::Dart_handle adart)
{
int mark = amap->get_new_mark();
CGAL_precondition(amap->is_whole_map_unmarked(mark));
for (typename CMap::template Dart_of_cell_range<CMap::dimension+1>::iterator current_dart = amap->template darts_of_cell<CMap::dimension+1>(adart).begin(),
last_dart = amap->template darts_of_cell<CMap::dimension+1>(adart).end(); current_dart != last_dart; ++current_dart) {
for (typename CMap::template Dart_of_cell_range<CMap::dimension+1>::iterator
current_dart=amap->template darts_of_cell<CMap::dimension+1>(adart).
begin(), last_dart=amap->template darts_of_cell<CMap::dimension+1>
(adart).end(); current_dart!=last_dart; ++current_dart)
{
if (amap->is_marked(current_dart, mark)) continue;
for (typename CMap::template Dart_of_cell_range<2>::iterator current_dart_in_cell = amap->template darts_of_cell<2>(current_dart).begin(),
last_dart_in_cell = amap->template darts_of_cell<2>(current_dart).end(); current_dart_in_cell != last_dart_in_cell; ++current_dart_in_cell) {
for (typename CMap::template Dart_of_cell_range<2>::iterator
current_dart_in_cell=amap->template darts_of_cell<2>(current_dart).
begin(), last_dart_in_cell=amap->template darts_of_cell<2>
(current_dart).end(); current_dart_in_cell!=last_dart_in_cell;
++current_dart_in_cell)
{
amap->mark(current_dart_in_cell, mark);
typename CMap::Dart_handle previous_dart_in_cell = current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell = current_dart_in_cell->beta(1);
typename CMap::Dart_handle previous_dart_in_cell=
current_dart_in_cell->beta(0);
typename CMap::Dart_handle next_dart_in_cell=
current_dart_in_cell->beta(1);
current_dart_in_cell->basic_link_beta(previous_dart_in_cell, 1);
current_dart_in_cell->basic_link_beta(next_dart_in_cell, 0);
}
} for (typename CMap::template Dart_of_cell_range<CMap::dimension+1>::iterator current_dart = amap->template darts_of_cell<CMap::dimension+1>(adart).begin(),
last_dart = amap->template darts_of_cell<CMap::dimension+1>(adart).end(); current_dart != last_dart; ++current_dart) {
}
for (typename CMap::template Dart_of_cell_range<CMap::dimension+1>::iterator
current_dart=amap->template darts_of_cell<CMap::dimension+1>(adart).
begin(), last_dart=amap->template darts_of_cell<CMap::dimension+1>
(adart).end(); current_dart!=last_dart; ++current_dart)
{
amap->unmark(current_dart, mark);
} CGAL_postcondition(amap->is_whole_map_unmarked(mark));
}
CGAL_postcondition(amap->is_whole_map_unmarked(mark));
amap->free_mark(mark);
}
};

View File

@ -284,6 +284,12 @@ bool test_LCC_4()
return false;
}
lcc.reverse_orientation();
lcc.reverse_orientation();
lcc.reverse_orientation_connected_component(dh1);
lcc.reverse_orientation_connected_component(dh1);
/* import_from_polyhedron<LCC>(lcc,ap);
lcc.clear();