File: point_set.cpp

package info (click to toggle)
cgal 4.13-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 101,504 kB
  • sloc: cpp: 703,154; ansic: 163,044; sh: 674; fortran: 616; python: 411; makefile: 115
file content (69 lines) | stat: -rw-r--r-- 2,031 bytes parent folder | download
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
64
65
66
67
68
69
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Point_set_3.h>

#include <fstream>
#include <limits>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;

typedef CGAL::Point_set_3<Point> Point_set;

void print_point_set (const Point_set& point_set)
{
  std::cerr << "Content of point set:" << std::endl;
  for (Point_set::const_iterator it = point_set.begin();
       it != point_set.end(); ++ it)
    std::cerr << "* Point " << *it
              << ": " << point_set.point(*it) // or point_set[it]
              << " with normal " << point_set.normal(*it)
              << std::endl;
}

int main (int, char**)
{
  Point_set point_set;
  
  // Add points
  point_set.insert (Point (0., 0., 0.));
  point_set.insert (Point (0., 0., 1.));
  point_set.insert (Point (0., 1., 0.));

  point_set.add_normal_map();

  print_point_set(point_set); // Normals have default values

  // Change normal values
  Point_set::iterator it = point_set.begin();
  point_set.normal(*(it++)) = Vector (1., 0., 0.);
  point_set.normal(*(it++)) = Vector (0., 1., 0.);
  point_set.normal(*(it++)) = Vector (0., 0., 1.);

  // Add point + normal
  point_set.insert (Point (1., 2., 3.), Vector (4., 5., 6.));

  print_point_set(point_set); 

  // Add new item
  Point_set::iterator new_item = point_set.insert(Point (7., 8., 9.));
  point_set.normal(*new_item) = Vector (10., 11., 12.);

  print_point_set(point_set); // New item has default values

  point_set.remove (point_set.begin() + 2,
                    point_set.begin() + 4);

  print_point_set(point_set); // New item has default values
  
  // Display information
  std::cerr << "Number of removed points: " <<point_set.number_of_removed_points() << std::endl;

  point_set.collect_garbage();
  
  // Display information (garbage should be gone)
  std::cerr << "After garbage collection: " <<point_set.number_of_removed_points() << std::endl;

  return 0;
}