File: incident_vertices_lcc.cpp

package info (click to toggle)
cgal 6.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 144,952 kB
  • sloc: cpp: 811,597; ansic: 208,576; sh: 493; python: 411; makefile: 286; javascript: 174
file content (63 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <CGAL/Simple_cartesian.h>

#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/IO/polygon_mesh_io.h>

#include <iostream>
#include <fstream>

typedef CGAL::Simple_cartesian<double>              Kernel;
typedef CGAL::Linear_cell_complex_traits<3, Kernel> LCC_traits;

typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper
          <2, 3, LCC_traits>::type LCC;

typedef boost::graph_traits<LCC>                   GraphTraits;
typedef GraphTraits::vertex_descriptor             vertex_descriptor;
typedef CGAL::Halfedge_around_target_iterator<LCC> halfedge_around_target_iterator;

template <typename OutputIterator>
OutputIterator
adjacent_vertices_V1(const LCC& g,
                     vertex_descriptor vd,
                     OutputIterator out)
{
  typename GraphTraits::halfedge_descriptor hb = halfedge(vd,g), done(hb);
  do
  {
    *out++ = source(hb,g);
    hb = opposite(next(hb,g),g);
  }
  while(hb!= done);
  return out;
}


template <typename OutputIterator>
OutputIterator adjacent_vertices_V2(const LCC& g,
                                    vertex_descriptor vd,
                                    OutputIterator out)
{
  halfedge_around_target_iterator hi, he;
  for(std::tie(hi, he) = halfedges_around_target(halfedge(vd,g),g); hi != he; ++hi)
  {
    *out++ = source(*hi,g);
  }
  return out;
}


int main(int argc, char** argv)
{
  LCC lcc;
  CGAL::IO::read_polygon_mesh((argc>1)?argv[1]:CGAL::data_file_path("meshes/cube_poly.off"), lcc);

  GraphTraits::vertex_iterator vi = vertices(lcc).first;
  std::list<vertex_descriptor> V;
  adjacent_vertices_V1(lcc, *vi, std::back_inserter(V));
  ++vi;
  adjacent_vertices_V2(lcc, *vi, std::back_inserter(V));
  std::cerr << "done\n";
  return 0;
}