Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Mesh.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
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:387
Intersection struct.
Definition: Shape.h:46