File: c3t3_example.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 (67 lines) | stat: -rw-r--r-- 1,889 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/Triangulation_3.h>
#include <CGAL/Triangulation_data_structure_3.h>
#include <CGAL/Simplicial_mesh_cell_base_3.h>
#include <CGAL/Simplicial_mesh_vertex_base_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>

#include <CGAL/tetrahedral_remeshing.h>

#include <CGAL/tags.h>

#include <CGAL/IO/File_medit.h>
#include <fstream>


using K = CGAL::Exact_predicates_inexact_constructions_kernel;

using Subdomain_index = int;
using Surface_patch_index = unsigned char;
using Curve_index = char;
using Corner_index = short;

using Cb = CGAL::Simplicial_mesh_cell_base_3<K, Subdomain_index, Surface_patch_index>;
using Vb = CGAL::Simplicial_mesh_vertex_base_3<K, Subdomain_index, Surface_patch_index,
                                                  Curve_index, Corner_index>;

using Tds = CGAL::Triangulation_data_structure_3<Vb, Cb, CGAL::Sequential_tag>;
using Triangulation = CGAL::Triangulation_3<K, Tds>;

using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3<Triangulation>;


int main(int argc, char* argv[])
{
  std::cout.precision(17);
  std::cerr.precision(17);

  std::string filename = (argc > 1) ? std::string(argv[1])
                       : CGAL::data_file_path("meshes/elephant.mesh");

  Triangulation tr;

  std::ifstream is(filename, std::ios_base::in);
  if(!CGAL::IO::read_MEDIT(is, tr))
  {
    std::cerr << "Failed to read" << std::endl;
    return EXIT_FAILURE;
  }

  // [call a remeshing algorithm]

  std::ofstream os("after_remeshing.mesh");
  CGAL::IO::write_MEDIT(os, tr, CGAL::parameters::all_vertices(true));
  os.close();

  Triangulation tr2;
  std::ifstream is2("after_remeshing.mesh");
  if(!CGAL::IO::read_MEDIT(is2, tr2))
  {
    std::cerr << "Failed to read (#2)" << std::endl;
    return EXIT_FAILURE;
  }

  std::cout << "Done" << std::endl;
  return EXIT_SUCCESS;
}