File: exploration_SM.cpp

package info (click to toggle)
cgal 4.0-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 65,068 kB
  • sloc: cpp: 500,870; ansic: 102,544; sh: 321; python: 92; makefile: 75; xml: 2
file content (49 lines) | stat: -rw-r--r-- 1,877 bytes parent folder | download | duplicates (3)
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
#include <CGAL/Gmpz.h>
#include <CGAL/Homogeneous.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/IO/Nef_polyhedron_iostream_3.h>

typedef CGAL::Homogeneous<CGAL::Gmpz> Kernel;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron_3;


int main() {

  // We've put the typedefs here as VC7 gives us an ICE if they are global typedefs
  typedef Nef_polyhedron_3::Vertex_const_iterator Vertex_const_iterator;
  typedef Nef_polyhedron_3::Nef_polyhedron_S2 Nef_polyhedron_S2;
  typedef Nef_polyhedron_S2::SVertex_const_handle SVertex_const_handle;
  typedef Nef_polyhedron_S2::SHalfedge_const_handle SHalfedge_const_handle;
  typedef Nef_polyhedron_S2::SHalfloop_const_handle SHalfloop_const_handle;
  typedef Nef_polyhedron_S2::SFace_const_iterator SFace_const_iterator;
  typedef Nef_polyhedron_S2::SFace_cycle_const_iterator
    SFace_cycle_const_iterator;

  Nef_polyhedron_3 N;
  std::cin >> N;

  Vertex_const_iterator v = N.vertices_begin();
  Nef_polyhedron_S2 S(N.get_sphere_map(v));

  int i=0;
  SFace_const_iterator sf;
  for(sf = S.sfaces_begin(); sf != S.sfaces_end(); sf++) {
    SFace_cycle_const_iterator it;
    std::cout << "the sface cycles of sface " << i++ << " start with an\n";
    for(it = sf->sface_cycles_begin(); it != sf->sface_cycles_end(); it++) {
      if (it.is_svertex())
        std::cout << "  svertex at position "
                  << SVertex_const_handle(it)->point() << std::endl;
      else if (it.is_shalfedge())
        std::cout << "  shalfedge from "
                  << SHalfedge_const_handle(it)->source()->point() << " to "
                  << SHalfedge_const_handle(it)->target()->point() << std::endl;
      else if (it.is_shalfloop())
        std::cout << "  shalfloop lying in the plane "
                  << SHalfloop_const_handle(it)->circle() << std::endl;
      // other cases can not occur.
    }
  }

  return 0;
}