Code_TYMPAN  4.2.0
Industrial site acoustic simulation
Accelerator.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 ACCELERATOR_H
17 #define ACCELERATOR_H
18 
19 #include "Geometry/Shape.h"
20 #include "LeafTreatment.h"
21 #include <list>
22 
27 {
28 
29 public:
32  Accelerator(std::vector<Shape*> *_shapes, BBox& _globalBox) : shapes(_shapes),
33  globalBox(_globalBox)
34  {
37  }
39  Accelerator(const Accelerator& other)
40  {
41  shapes = other.shapes;
42  globalBox = other.globalBox;
45  }
47  virtual ~Accelerator() { }
48 
53  virtual bool build() { return false; }
55  virtual decimal traverse(Ray* r, std::list<Intersection> &result) const { return -1.; }
56 
57 protected:
60  {
61  switch (intersectionChoice)
62  {
65  break;
68  break;
71  break;
72  case leafTreatment::ALL:
74  break;
75  default:
77  break;
78  }
79  }
80 
81  decimal (*pLeafTreatmentFunction) (std::list<Intersection> &, decimal);
82 
84 
85  std::vector<Shape*> *shapes;
87 };
88 
89 #endif
decimal keepAllBeforeTriangle(std::list< Intersection > &currentIntersections, decimal currentTmin)
Keep all intersections encountered before intersecting a visible shape and before reaching currentTmi...
Accelerator()
Constructors.
Definition: Accelerator.h:31
virtual ~Accelerator()
Destructor.
Definition: Accelerator.h:47
BBox globalBox
Global bounding box.
Definition: Accelerator.h:86
decimal keepFirst(std::list< Intersection > &currentIntersections, decimal currentTmin)
Keep only the first intersection encountered before reaching currentTmin and return its corresponding...
virtual decimal traverse(Ray *r, std::list< Intersection > &result) const
Run this accelerator.
Definition: Accelerator.h:55
Accelerator(std::vector< Shape *> *_shapes, BBox &_globalBox)
Definition: Accelerator.h:32
decimal keepAllBeforeVisible(std::list< Intersection > &currentIntersections, decimal currentTmin)
Keep all intersections encountered before intersecting a triangle and before reaching currentTmin...
void defineLeafFunction()
To define leaf function.
Definition: Accelerator.h:59
std::vector< Shape * > * shapes
Vector of pointers to shapes.
Definition: Accelerator.h:85
Accelerator(const Accelerator &other)
Copy constructor.
Definition: Accelerator.h:39
: 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
virtual bool build()
Build this accelerator.
Definition: Accelerator.h:53
float decimal
Definition: mathlib.h:46
leafTreatment::treatment intersectionChoice
Intersection choice.
Definition: Accelerator.h:83
Definition of a bounding box which is aligned along the axis (BBox AABB).
Definition: BBox.h:31
leafTreatment::treatment getIntersectionChoice()
Get/Set the Intersection choice.
Definition: Accelerator.h:50
decimal(* pLeafTreatmentFunction)(std::list< Intersection > &, decimal)
Pointer to the treatment function of leaf.
Definition: Accelerator.h:81
Base class for accelerators.
Definition: Accelerator.h:26
decimal keepAll(std::list< Intersection > &currentIntersections, decimal currentTmin)
Keep all intersections before reaching currentTmin and return the tmin of the first one encountered...
void setIntersectionChoice(leafTreatment::treatment _intersectionChoice=leafTreatment::FIRST)
Definition: Accelerator.h:51