Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Triangle.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 TRIANGLE_H
17 #define TRIANGLE_H
18 
19 #include "Shape.h"
20 
24 class Triangle : public Shape
25 {
26 
27 public:
30  {
31  name = "unknown triangle";
32  };
34  Triangle(unsigned int p1, unsigned int p2, unsigned int p3, std::vector<vec3>* _vertices, Material* _m,
35  const bool& isSol = false);
37  Triangle(const vec3& p1, const vec3& p2, const vec3& p3, Material* m, const bool& isSol = false);
39  Triangle(const Triangle& other) : Shape(other)
40  {
41  box = other.box;
42  };
44  virtual ~Triangle() {}
45 
46  virtual void updateBBox();
47 
48  virtual bool getIntersection(Ray& ray, Intersection& inter);
49 
51  void setNormal(const vec3& _normal)
52  {
53  normal = _normal;
54  }
55  virtual vec3 getNormal(const vec3 pos = vec3())
56  {
57  return normal;
58  }
59 
61  virtual bool sample(decimal density, std::vector<vec3>& samples);
62 
63  virtual int form()
64  {
65  return TRIANGLE;
66  }
67 
68 protected:
69  vec3 p;
70  vec3 u;
71  vec3 v;
72 
74 };
75 
76 #endif
@ TRIANGLE
Definition: Shape.h:36
std::string name
Each instantiated object may be named.
Definition: Base.h:52
: 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
BBox box
Bounding box of the shape.
Definition: Shape.h:210
bool isSol() const
Get/Set the flag _isSol (ground or not)
Definition: Shape.h:194
Triangle class.
Definition: Triangle.h:25
virtual bool sample(decimal density, std::vector< vec3 > &samples)
Uncommented method cause not used.
Definition: Triangle.cpp:102
void setNormal(const vec3 &_normal)
Set/Get the normal.
Definition: Triangle.h:51
vec3 normal
Normal to triangle.
Definition: Triangle.h:73
virtual bool getIntersection(Ray &ray, Intersection &inter)
Get the Intersection between a ray and this shape.
Definition: Triangle.cpp:70
Triangle(const Triangle &other)
Copy constructor.
Definition: Triangle.h:39
virtual void updateBBox()
Update the bounding box:
Definition: Triangle.cpp:61
virtual int form()
Return type of the shape.
Definition: Triangle.h:63
virtual ~Triangle()
Destructor.
Definition: Triangle.h:44
vec3 v
Vector to reach the third vertex (vertex3=p+v)
Definition: Triangle.h:71
vec3 u
Vector to reach the second vertex (vertex2=p+u)
Definition: Triangle.h:70
Triangle()
Default constructor.
Definition: Triangle.h:29
vec3 p
First vertex (vertex1=p)
Definition: Triangle.h:69
virtual vec3 getNormal(const vec3 pos=vec3())
Get normal.
Definition: Triangle.h:55
float decimal
Definition: mathlib.h:45
base_vec3< decimal > vec3
Definition: mathlib.h:387
Intersection struct.
Definition: Shape.h:46