File: sm_points.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 (35 lines) | stat: -rw-r--r-- 985 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
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/convex_hull_3.h>

typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef Mesh::Vertex_index vertex_descriptor;
typedef Mesh::Face_index face_descriptor;

int main()
{
  Mesh m;
  vertex_descriptor v0 = m.add_vertex(K::Point_3(0,0,0));
  vertex_descriptor v1 = m.add_vertex(K::Point_3(1,0,0));
  vertex_descriptor v2 = m.add_vertex(K::Point_3(0,1,0));
  vertex_descriptor v3 = m.add_vertex(K::Point_3(0,0,1));

  face_descriptor fd = m.add_face(v0, v1, v2);
  m.add_face(v1, v0, v3);

  // Access the point for a given vertex
  for(vertex_descriptor vd : vertices_around_face(m.halfedge(fd), m)){
    std ::cout << m.point(vd) << std::endl;
  }

  // Access the range of all points of the mesh
  for( const K::Point_3& p : m.points()){
    std::cout << p << std::endl;
  }

  Mesh ch;
  CGAL::convex_hull_3(m.points().begin(), m.points().end(), ch);

  return 0;
}