OpenMEEG
interface.h
Go to the documentation of this file.
1 // Project Name: OpenMEEG (http://openmeeg.github.io)
2 // © INRIA and ENPC under the French open source license CeCILL-B.
3 // See full copyright notice in the file LICENSE.txt
4 // If you make a copy of this file, you must either:
5 // - provide also LICENSE.txt and modify this header to refer to it.
6 // - replace this header by the LICENSE.txt content.
7 
8 #pragma once
9 
10 #include <string>
11 #include <sstream>
12 #include <vector>
13 #include <cstdlib>
14 #include <ctime>
15 #include <om_common.h>
16 #include <mesh.h>
17 
18 namespace OpenMEEG {
19 
20  class Mesh;
21 
23 
24  class OrientedMesh {
25  public:
26 
27  typedef enum { Normal=1, Opposite=-1 } Orientation ;
28 
30 
31  OrientedMesh(Mesh& m,const Orientation o): meshptr(&m),orient(o) { }
32 
33  Mesh& mesh() { return *meshptr; }
34  const Mesh& mesh() const { return *meshptr; }
35 
36  int orientation() const { return orient; }
37 
38  void change_orientation() { orient = -orient; }
39 
40  private:
41 
42  Mesh* meshptr;
43  int orient;
44  };
45 
48 
49  class OPENMEEG_EXPORT Interface {
50  public:
51 
52  // using OrientedMesh::Orientation;
53 
54  typedef std::vector<OrientedMesh> OrientedMeshes;
55 
57 
58  Interface() { }
59 
61 
62  Interface(const std::string& interfname): interface_name(interfname) { }
63 
64  const std::string& name() const { return interface_name; }
65 
66  OrientedMeshes& oriented_meshes() { return orientedmeshes; }
67  const OrientedMeshes& oriented_meshes() const { return orientedmeshes; }
68 
69  bool outermost() const { return outermost_interface; }
71 
72  bool contains(const Vect3& p) const;
73 
74  bool is_mesh_orientations_coherent(const bool doublechecked=false);
75 
77 
78  size_t nb_vertices() const {
79  size_t nb = 0;
80  for (const auto& omesh : oriented_meshes())
81  nb += omesh.mesh().vertices().size();
82  return nb;
83  }
84 
86 
87  size_t nb_triangles() const {
88  size_t nb = 0;
89  for (const auto& omesh : oriented_meshes())
90  nb += omesh.mesh().triangles().size();
91  return nb;
92  }
93 
95 
97  TrianglesRefs triangles;
98  for (const auto& omesh : oriented_meshes()) {
99  const TrianglesRefs& tri = omesh.mesh().adjacent_triangles(t);
100  triangles.insert(triangles.end(),tri.begin(),tri.end());
101  }
102  return triangles;
103  }
104 
105  private:
106 
107  double solid_angle(const Vect3& p) const;
108 
109  std::string interface_name = "";
110  bool outermost_interface = false;
111  OrientedMeshes orientedmeshes;
112  };
113 
115 
116  typedef std::vector<Interface> Interfaces;
117 }
Interface class An interface is a closed-shape composed of oriented meshes (vector of oriented meshes...
Definition: interface.h:49
size_t nb_triangles() const
Definition: interface.h:87
size_t nb_vertices() const
Definition: interface.h:78
void set_to_outermost()
set all interface meshes to outermost state.
const OrientedMeshes & oriented_meshes() const
Definition: interface.h:67
bool contains(const Vect3 &p) const
OrientedMeshes & oriented_meshes()
Definition: interface.h:66
bool is_mesh_orientations_coherent(const bool doublechecked=false)
Check the global orientation.
std::vector< OrientedMesh > OrientedMeshes
Definition: interface.h:54
Interface(const std::string &interfname)
Constructor from a name.
Definition: interface.h:62
Interface()
Default Constructor.
Definition: interface.h:58
bool outermost() const
Definition: interface.h:69
const std::string & name() const
Definition: interface.h:64
TrianglesRefs adjacent_triangles(const Triangle &t) const
Definition: interface.h:96
An Oriented Mesh is a mesh associated with a boolean stating if it is well oriented.
Definition: interface.h:24
int orientation() const
orientation is +1 or -1 ?
Definition: interface.h:36
Mesh & mesh()
access mesh
Definition: interface.h:33
OrientedMesh(Mesh &m, const Orientation o)
Definition: interface.h:31
const Mesh & mesh() const
access mesh
Definition: interface.h:34
Triangle Triangle class.
Definition: triangle.h:45
Vect3.
Definition: vect3.h:28
std::vector< Triangle * > TrianglesRefs
Definition: triangle.h:139
std::vector< Interface > Interfaces
A vector of Interface is called Interfaces.
Definition: interface.h:116