Code_TYMPAN  4.4.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  {
35  }
36  Accelerator(std::vector<Shape*>* _shapes, BBox& _globalBox) : shapes(_shapes), globalBox(_globalBox)
37  {
40  }
42  Accelerator(const Accelerator& other)
43  {
44  shapes = other.shapes;
45  globalBox = other.globalBox;
48  }
50  virtual ~Accelerator() {}
51 
54  {
55  return intersectionChoice;
56  }
58  {
59  intersectionChoice = _intersectionChoice;
61  }
63  virtual bool build()
64  {
65  return false;
66  }
68  virtual decimal traverse(Ray* r, std::list<Intersection>& result) const
69  {
70  return -1.;
71  }
72 
73 protected:
76  {
77  switch (intersectionChoice)
78  {
81  break;
84  break;
87  break;
88  case leafTreatment::ALL:
90  break;
91  default:
93  break;
94  }
95  }
96 
97  decimal (*pLeafTreatmentFunction)(std::list<Intersection>&,
98  decimal);
99 
101 
102  std::vector<Shape*>* shapes;
104 };
105 
106 #endif
Base class for accelerators.
Definition: Accelerator.h:27
virtual bool build()
Build this accelerator.
Definition: Accelerator.h:63
Accelerator(std::vector< Shape * > *_shapes, BBox &_globalBox)
Definition: Accelerator.h:36
leafTreatment::treatment intersectionChoice
Intersection choice.
Definition: Accelerator.h:100
decimal(* pLeafTreatmentFunction)(std::list< Intersection > &, decimal)
Pointer to the treatment function of leaf.
Definition: Accelerator.h:97
Accelerator()
Constructors.
Definition: Accelerator.h:31
Accelerator(const Accelerator &other)
Copy constructor.
Definition: Accelerator.h:42
BBox globalBox
Global bounding box.
Definition: Accelerator.h:103
virtual ~Accelerator()
Destructor.
Definition: Accelerator.h:50
void setIntersectionChoice(leafTreatment::treatment _intersectionChoice=leafTreatment::FIRST)
Definition: Accelerator.h:57
leafTreatment::treatment getIntersectionChoice()
Get/Set the Intersection choice.
Definition: Accelerator.h:53
virtual decimal traverse(Ray *r, std::list< Intersection > &result) const
Run this accelerator.
Definition: Accelerator.h:68
void defineLeafFunction()
To define leaf function.
Definition: Accelerator.h:75
std::vector< Shape * > * shapes
Vector of pointers to shapes.
Definition: Accelerator.h:102
Definition of a bounding box which is aligned along the axis (BBox AABB).
Definition: BBox.h:32
: 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
float decimal
Definition: mathlib.h:45
decimal keepAll(std::list< Intersection > &currentIntersections, decimal currentTmin)
Keep all intersections before reaching currentTmin and return the tmin of the first one encountered.
@ ALL_BEFORE_TRIANGLE
ALL_BEFORE_TRIANGLE.
Definition: LeafTreatment.h:32
@ ALL_BEFORE_VISIBLE
ALL_BEFORE_VISIBLE.
Definition: LeafTreatment.h:33
decimal keepAllBeforeVisible(std::list< Intersection > &currentIntersections, decimal currentTmin)
Keep all intersections encountered before intersecting a triangle and before reaching currentTmin,...
decimal keepAllBeforeTriangle(std::list< Intersection > &currentIntersections, decimal currentTmin)
Keep all intersections encountered before intersecting a visible shape and before reaching currentTmi...
decimal keepFirst(std::list< Intersection > &currentIntersections, decimal currentTmin)
Keep only the first intersection encountered before reaching currentTmin and return its corresponding...