File: reconstruction_class.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 (56 lines) | stat: -rw-r--r-- 1,822 bytes parent folder | download | duplicates (4)
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
#include <iostream>
#include <fstream>
#include <algorithm>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Advancing_front_surface_reconstruction.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Advancing_front_surface_reconstruction<> Reconstruction;
typedef Reconstruction::Triangulation_3 Triangulation_3;
typedef Reconstruction::Triangulation_data_structure_2 TDS_2;
typedef K::Point_3 Point_3;
typedef K::Vector_3 Vector_3;

int main(int argc, char* argv[])
{
  std::ifstream in((argc>1)?argv[1]:CGAL::data_file_path("points_3/half.xyz"));
  std::istream_iterator<Point_3> begin(in);
  std::istream_iterator<Point_3> end;

  Triangulation_3 dt(begin,end);

  Reconstruction reconstruction(dt);

  reconstruction.run();

  const TDS_2& tds = reconstruction.triangulation_data_structure_2();

  std::cout << "solid produced with CGAL::Advancing_front_surface_reconstruction\n";
  for(TDS_2::Face_iterator fit = tds.faces_begin();
      fit != tds.faces_end();
      ++fit){
    if(reconstruction.has_on_surface(fit)){
      Triangulation_3::Facet f = fit->facet();
      Triangulation_3::Cell_handle ch = f.first;
      int ci = f.second;
      Point_3 points[3];
      for(int i = 0, j = 0; i < 4; i++){
        if(ci != i){
          points[j] = ch->vertex(i)->point();
          j++;
        }
      }
      std::cout << "  facet normal "
                << CGAL::unit_normal(points[0],points[1], points[2]) << "\n"
                << "  outer loop\n"
                << "    vertex " << points[0]  << "\n"
                << "    vertex " << points[1]  << "\n"
                << "    vertex " << points[2]  << "\n"
                << "  endloop\n"
                << "  endfacet\n";
    }
  }
    std::cout << "endsolid" << std::endl;

  return 0;
}