Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Mesh.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 #ifndef MESH_H
17 #define MESH_H
18 
19 #include "Shape.h"
20 
24 class Mesh : public Shape
25 {
26 
27 public:
29  Mesh(){};
30  Mesh(const Mesh& other){};
32  virtual ~Mesh()
33  {
34  clear();
35  };
37  void clear();
38 
40  std::vector<vec3>& getVertices()
41  {
42  return vertices;
43  }
44  void setVertices(const std::vector<vec3>& _vertices)
45  {
46  for (unsigned int i = 0; i < _vertices.size(); i++)
47  {
48  vertices.push_back(vec3(_vertices.at(i)));
49  }
50  }
51 
53  std::vector<ivec3>& getTriangles()
54  {
55  return triangles;
56  }
57  void setTriangles(const std::vector<ivec3>& _triangles)
58  {
59  for (unsigned int i = 0; i < _triangles.size(); i++)
60  {
61  triangles.push_back(ivec3(_triangles.at(i)));
62  }
63  }
65  bool addTriangle(const ivec3 newTriangle, Material* m);
66 
67  virtual bool getIntersection(Ray& ray, Intersection& inter)
68  {
69  return false;
70  }
71 
72 protected:
73  std::vector<vec3> vertices;
74  std::vector<ivec3> triangles;
75 };
76 #endif
Mesh class.
Definition: Mesh.h:25
Mesh()
Constructors.
Definition: Mesh.h:29
void setTriangles(const std::vector< ivec3 > &_triangles)
Definition: Mesh.h:57
void clear()
Clear arrays.
Definition: Mesh.cpp:19
std::vector< ivec3 > & getTriangles()
Get/Set triangles of the mesh.
Definition: Mesh.h:53
std::vector< ivec3 > triangles
Triangles of the mesh.
Definition: Mesh.h:74
std::vector< vec3 > & getVertices()
Get/Set the vertices of the mesh.
Definition: Mesh.h:40
void setVertices(const std::vector< vec3 > &_vertices)
Definition: Mesh.h:44
virtual bool getIntersection(Ray &ray, Intersection &inter)
Get the Intersection between a ray and this shape.
Definition: Mesh.h:67
virtual ~Mesh()
Destructor.
Definition: Mesh.h:32
std::vector< vec3 > vertices
Vertices of the mesh.
Definition: Mesh.h:73
bool addTriangle(const ivec3 newTriangle, Material *m)
Add a triangle to the mesh with the material m.
Definition: Mesh.cpp:25
Mesh(const Mesh &other)
Definition: Mesh.h:30
: Describes a ray by a pair of unsigned int. The first one gives the source number (in the range 0-40...
Definition: Ray.h:38
base class for shapes (Cylindre, Mesh, Sphere, Triangle,...)
Definition: Shape.h:57
base_vec3< decimal > vec3
Definition: mathlib.h:381
Intersection struct.
Definition: Shape.h:46