File: dynamic_properties.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 (39 lines) | stat: -rw-r--r-- 1,365 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

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/generators.h>

#include <string>

typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Mesh;

int main()
{
  Mesh mesh;
  CGAL::make_triangle(Point_3(0,0,0),Point_3(1,0,0),Point_3(1,1,0), mesh);

  typedef boost::property_map<Mesh, CGAL::dynamic_vertex_property_t<std::string> >::type VertexNameMap;
  VertexNameMap vnm  = get(CGAL::dynamic_vertex_property_t<std::string>(), mesh, std::string("default"));
  put(vnm, *(vertices(mesh).first), "Paris");

  assert(get(vnm, *(vertices(mesh).first))=="Paris");
  assert(get(vnm, *(std::next(vertices(mesh).first)))=="default");

  std::cout << get(vnm, *(vertices(mesh).first)) << std::endl;
  std::cout << get(vnm, *(std::next(vertices(mesh).first))) << std::endl;

  typedef boost::property_map<Mesh, CGAL::dynamic_halfedge_property_t<double> >::type TrafficDensityMap;
  TrafficDensityMap tdm = get(CGAL::dynamic_halfedge_property_t<double>(), mesh, -1.);
  put(tdm, *(halfedges(mesh).first), 0.7);

  assert(get(tdm, *(halfedges(mesh).first))==0.7);
  assert(get(tdm, *(std::next(halfedges(mesh).first)))==-1.);

  std::cout << get(tdm, *(halfedges(mesh).first)) << std::endl;
  std::cout << get(tdm, *(std::next(halfedges(mesh).first))) << std::endl;

  return 0;
}