Goosefoot Mesher - CGAL
PolyhedronUtils.h
1 // Copyright (C) 2012 Benjamin Kehlet
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // First added: 2012-10-31
19 // Last changed: 2012-11-14
20 
21 // Some utilities for working with cgal polyhedrons
22 
23 
24 #ifndef __POLYHEDRON_UTILS_H
25 #define __POLYHEDRON_UTILS_H
26 
27 #include "mesher_cgal.h"
28 
29 #include "self_intersect.h"
30 
32 {
33  static bool _compare_ending(std::string filename, const char* ending);
34 
35 public:
36  static bool readSurfaceFile(std::string filename, Exact_polyhedron& p);
37  static bool readSTLFile(std::string filename, Exact_polyhedron& p);
38  static bool readVTKFile(std::string filename, Exact_polyhedron& p);
39  static bool readVTKXMLFile(std::string filename, Exact_polyhedron& p);
40  static CGAL::Bbox_3 getBoundingBox(Polyhedron& polyhedron);
41  static double getBoundingSphereRadius(Polyhedron& polyhedron);
42  static bool has_degenerate_facets(Exact_polyhedron& p, double threshold);
43  static void remove_degenerate_facets(Exact_polyhedron& p, const double threshold);
44 
45  template <typename Polyhedron>
46  bool has_self_intersections(Polyhedron& p)
47  {
48  typedef typename Polyhedron::Triangle_3 Triangle;
49  typedef typename std::back_insert_iterator<std::list<Triangle> > OutputIterator;
50 
51  std::list<Triangle> triangles; // intersecting triangles
52  ::self_intersect<Polyhedron::Polyhedron_3, Polyhedron::Kernel, OutputIterator>(p, std::back_inserter(triangles));
53 
54  // if(triangles.size() != 0)
55  // cout << triangles.size() << " found." << endl;
56  // else
57  // cout << "The polyhedron does not self-intersect." << endl;
58 
59  return triangles.size() > 0;
60  }
61 };
62 
63 
64 #endif
65 
66 #include "PolyhedronUtils.imp.h"
Definition: PolyhedronUtils.h:31