CGAL 6.0 - Combinatorial Maps
Loading...
Searching...
No Matches
Combinatorial_map/map_3_marks.cpp
#include <CGAL/Combinatorial_map.h>
#include <iostream>
#include <cstdlib>
typedef CMap_3::Dart_descriptor Dart_descriptor;
typedef CMap_3::size_type size_type;
int main()
{
CMap_3 cm;
// 1) Reserve a mark.
size_type amark;
try
{
amark = cm.get_new_mark();
}
catch (CMap_3::Exception_no_more_available_mark)
{
std::cerr<<"No more free mark, exit."<<std::endl;
exit(-1);
}
// 2) Create two tetrahedra.
Dart_descriptor d1 = cm.make_combinatorial_tetrahedron();
Dart_descriptor d2 = cm.make_combinatorial_tetrahedron();
// 3) 3-sew them.
cm.sew<3>(d1, d2);
// 4) Mark the darts belonging to the first tetrahedron.
for (CMap_3::Dart_of_cell_range<3>::iterator
it(cm.darts_of_cell<3>(d1).begin()),
itend(cm.darts_of_cell<3>(d1).end()); it!=itend; ++it)
cm.mark(it, amark);
// 4) Remove the common 2-cell between the two cubes:
// the two tetrahedra are merged.
cm.remove_cell<2>(d1);
// 5) Thanks to the mark, we know which darts come from the first tetrahedron.
unsigned int res=0;
for (CMap_3::Dart_range::iterator it(cm.darts().begin()),
itend(cm.darts().end()); it!=itend; ++it)
{
if ( cm.is_marked(it, amark) )
++res;
}
std::cout<<"Number of darts from the first tetrahedron: "<<res<<std::endl;
cm.free_mark(amark);
return EXIT_SUCCESS;
}
The class Combinatorial_map represents a dD combinatorial map.
Definition: Combinatorial_map.h:39