MEPP2 Project
test_not_2_manifold_linear_cell_complex.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #include <iostream>
12 #include <fstream>
13 
14 #include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
16 
17 #include <CGAL/Linear_cell_complex_incremental_builder.h>
18 #include <CGAL/Combinatorial_map_constructors.h>
19 
20 #include <CGAL/Cartesian.h>
21 
22 typedef CGAL::Cartesian< double > Kernel;
23 typedef Kernel::Point_3 Point;
24 typedef Kernel::Vector_3 Vector;
25 typedef CGAL::Linear_cell_complex_traits< 3, Kernel > MyTraits;
26 
27 struct Myitem
28 {
29  template< class Refs >
30  struct Dart_wrapper
31  {
32  typedef CGAL::Tag_true Darts_with_id;
33  typedef CGAL::Cell_attribute_with_point_and_id< Refs > Vertex_attribute;
34  typedef CGAL::Cell_attribute_with_id< Refs > Face_attribute;
35  typedef CGAL::cpp11::tuple< Vertex_attribute, void, Face_attribute >
37  };
38 };
39 
40 typedef CGAL::
41  Linear_cell_complex_for_combinatorial_map< 2, 3, MyTraits, Myitem >
42  LCC;
43 
44 //------------------------------------------------------------------------------
45 int
46 main(void)
47 {
48  LCC lcc;
49  typedef LCC::Dart_handle Dart_handle;
50 
51  try
52  {
53 #if 1
54  //Dart_handle s1 = lcc.make_segment(
55  // Point(1, 0, 10), Point(0, 0, 10)); // add a dangling edge (non-manifold)
56 
57  Dart_handle t1 =
58  lcc.make_triangle(Point(1, 0, 1), Point(0, 0, 0), Point(1, 1, 0));
59  Dart_handle t2 =
60  lcc.make_triangle(Point(1, 1, 1), Point(0, 0, 0), Point(1, 1, 0));
61  Dart_handle t3 =
62  lcc.make_triangle(Point(1, -1, 1), Point(0, 0, 0), Point(1, 1, 0));
63 #else
64  Dart_handle s1 = lcc.make_edge();
65  Dart_handle t1 = lcc.make_combinatorial_polygon(3);
66  Dart_handle t2 = lcc.make_combinatorial_polygon(3);
67  Dart_handle t3 = lcc.make_combinatorial_polygon(3);
68 #endif
69  // std::cout << "Before sewing: triangle 1, p1: " <<
70  // lcc.attribute<0>(t1)->point() << std::endl; std::cout << "Before sewing:
71  // triangle 1, p2: " << lcc.attribute<0>(lcc.beta(t1, 1))->point() <<
72  // std::endl; std::cout << "Before sewing: triangle 1, p3: " <<
73  // lcc.attribute<0>(lcc.beta(t1, 0))->point() << std::endl;
74  lcc.sew< 2 >(lcc.beta(t1, 1), lcc.beta(t2, 1));
75  // std::cout << "After sewing: triangle 1, p1: " <<
76  // lcc.attribute<0>(t1)->point() << std::endl; std::cout << "After sewing:
77  // triangle 1, p2: " << lcc.attribute<0>(lcc.beta(t1, 1))->point() <<
78  // std::endl; std::cout << "After sewing: triangle 1, p3: " <<
79  // lcc.attribute<0>(lcc.beta(t1, 0))->point() << std::endl;
80 
81  // lcc.display_characteristics(std::cout);
82  // std::cout << std::endl;
83 
84  lcc.sew< 2 >(
85  lcc.beta(t2, 1),
86  lcc.beta(
87  t3,
88  1)); // try to sew 3 triangles around the same edge => exception,
89  // because LCC cannot handle non-manifold topologies
90  }
91  catch(...)
92  {
93  std::cerr << "test_not_2_manifold_linear_cell_complex: LCC and "
94  "combinatorial maps cannot handle non-manifold topologies"
95  << std::endl;
96  }
97 
98  return EXIT_SUCCESS;
99 }
main
int main(void)
Definition: test_not_2_manifold_linear_cell_complex.cpp:46
LCC
CGAL::Linear_cell_complex_for_combinatorial_map< 2, 3, MyTraits, Myitem > LCC
Definition: test_not_2_manifold_linear_cell_complex.cpp:42
Myitem
Definition: test_complying_concepts_linear_cell_complex.cpp:26
LCC
CGAL::Linear_cell_complex_for_combinatorial_map< 2, 3, MyTraits, Myitem > LCC
Definition: test_linear_cell_complex.cpp:54
Myitem::Dart_wrapper::Face_attribute
CGAL::Cell_attribute_with_id< Refs > Face_attribute
Definition: test_not_2_manifold_linear_cell_complex.cpp:34
Point
Kernel::Point_3 Point
Definition: test_not_2_manifold_linear_cell_complex.cpp:23
Vector
Kernel::Vector_3 Vector
Definition: test_not_2_manifold_linear_cell_complex.cpp:24
Kernel
CGAL::Cartesian< double > Kernel
Definition: test_not_2_manifold_linear_cell_complex.cpp:22
Myitem::Dart_wrapper::Vertex_attribute
CGAL::Cell_attribute_with_point_and_id< Refs > Vertex_attribute
Definition: test_not_2_manifold_linear_cell_complex.cpp:33
Myitem::Dart_wrapper::Darts_with_id
CGAL::Tag_true Darts_with_id
Definition: test_not_2_manifold_linear_cell_complex.cpp:32
Myitem::Dart_wrapper::Attributes
CGAL::cpp11::tuple< Vertex_attribute, void, Face_attribute > Attributes
Definition: test_not_2_manifold_linear_cell_complex.cpp:36
MyTraits
CGAL::Linear_cell_complex_traits< 3, Kernel > MyTraits
Definition: test_not_2_manifold_linear_cell_complex.cpp:25
Geometry_traits_cgal_linear_cell_complex.h