Code_TYMPAN  4.2.0
Industrial site acoustic simulation
TYANIME3DRayTracerSolverAdapter.cpp
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 
31 
33 
34 bool TYANIME3DRayTracerSolverAdapter::postTreatmentScene(Scene* scene, std::vector<Source>& sources, std::vector<Recepteur>& recepteurs)
35 {
39 
40  if (config->UsePostFilters)
41  {
42  if (config->DebugUseCloseEventSelector) { selectorManagerValidation.addSelector( new CloseEventSelector<Ray>() ); }
43  if (config->DebugUseDiffractionAngleSelector) { selectorManagerValidation.addSelector(new DiffractionAngleSelector<Ray>()); }
44  if (config->DebugUseDiffractionPathSelector) { selectorManagerValidation.addSelector(new DiffractionPathSelector<Ray>(config->MaxPathDifference)); }
45  if (config->DebugUseFermatSelector) { selectorManagerValidation.addSelector( new FermatSelector<Ray>() ); }
46  if (config->DebugUseFaceSelector) { selectorManagerValidation.addSelector( new FaceSelector<Ray>(HISTORY_PRIMITIVE) ); }
47  }
48 
50  selectorManagerIntersection.addSelector( new ReflectionSelector<Ray>(config->MaxReflexion, config->UseSol) );
51 
52  // Ajoute des cylindres sur les arretes diffractantes
54 
55  return true;
56 }
57 
59 {
61  if (r->getEvents()->size() > static_cast<unsigned int>(config->MaxProfondeur)) { return false; }
62 
63  bool isValid = false;
64 
65  // If the intersected primitive is a TRIANGLE
66  if ( ( inter->forme == TRIANGLE ) &&
67  ( r->getReflex() < static_cast<unsigned int>(config->MaxReflexion) ) &&
68  !( !config->UseSol && inter->p->isSol() ) )
69  {
70  //Validate a REFLEXION event
72  }
73 
74  // If the intersected primitive is a CYLINDER
75  else if (inter->forme == CYLINDRE && r->getDiff() < static_cast<unsigned int>(config->MaxDiffraction))
76  {
77  //Validate a DIFFRACTION event
78  isValid = ValidRay::validCylindreWithDiffraction(r, inter);
79  }
80 
81 #ifdef _ALLOW_TARGETING_
82  if (isValid && config->EnableFullTargets) { ValidRay::appendDirectionToEvent(r->events.back(), targetManager); }
83 #endif //_ALLOW_TARGETING_
84 
85  return (isValid);
86 }
87 
89 {
91 #ifdef _DEBUG
92  if (selectorManagerValidation.getSelectedData().size() % 1000 == 0 )
93  {
94  std::cout << "Nombre de rayon valides = " << selectorManagerValidation.getSelectedData().size()<< std::endl;
95  }
96 
97 #endif
98  return true;
99 }
100 
102 {
103  if (!tympan::SolverConfiguration::get()->KeepDebugRay)
104  {
105  delete r;
106  r = NULL;
107  }
108  else
109  {
110  debug_rays.push_back(r);
111  }
112 
113  return true;
114 }
115 
117 {
118  std::map<unsigned long long int, Ray*> selectedData = selectorManagerValidation.getSelectedData();
119 
120  for (std::map<unsigned long long, Ray*>::iterator it = selectedData.begin(); it != selectedData.end(); it++)
121  {
122  valid_rays.push_back(it->second);
123  }
124 
127 
128  return;
129 }
unsigned int getDiff() const
Return the diffractions number encountered by the ray.
Definition: Ray.h:160
Intersection struct.
Definition: Shape.h:46
std::vector< boost::shared_ptr< Event > > events
Events list for the ray.
Definition: Ray.h:453
: To disable the rays which have a number of reflection events greater than a given threshold or refl...
deque< Ray * > valid_rays
Rays list which are validated by the solver.
Definition: Solver.h:123
bool validCylindreWithDiffraction(Ray *r, Intersection *inter)
Definition: ValidRay.cpp:182
This file provides class for solver configuration.
void addSelector(Selector< T > *selector)
Add a Selector to the list.
std::vector< boost::shared_ptr< Event > > * getEvents()
Return the events array encountered by the ray.
Definition: Ray.h:180
bool appendData(T *data)
Append data (typically a ray) and loop on Selectors to filter.
Rejects a ray if two of its events occur on the same shape (for example a diffraction close to a refl...
: Rays can be seen as long cones that get thicker as their length increases based on their associated...
: Rejects rays which have traveled a distance greater than a given length
std::map< unsigned long long, T * > & getSelectedData()
Get the selected data.
deque< Ray * > debug_rays
Rays list which are invalidated by the solver.
Definition: Solver.h:124
unsigned int getReflex() const
Return the reflections number encountered by the ray.
Definition: Ray.h:167
Definition: Shape.h:38
: To keep only one from two or more rays which have the same history (events on the same primitive) ...
Definition: FaceSelector.h:35
virtual bool valideRayon(Ray *r)
validate a ray by filtering it with the selectors for acceptance or rejection
Shape * p
Definition: Shape.h:50
bool validTriangleWithSpecularReflexion(Ray *r, Intersection *inter)
Definition: ValidRay.cpp:45
: 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
FORM forme
Definition: Shape.h:51
void reset()
Reset all the Selector and clear the local data.
Definition: Shape.h:37
Clean DoNothing events from ray events list \ –> After ray validation DoNothing events are no longer...
bool isSol() const
Get/Set the flag _isSol (ground or not)
Definition: Shape.h:134
virtual bool invalidRayon(Ray *r)
delete a ray or add it to the list of debug rays
virtual bool postTreatmentScene(Scene *scene, std::vector< Source > &sources, std::vector< Recepteur > &recepteurs)
Virtual function to post-process the Scene. It has two phases: transform the meta-objects and load th...
: Rejects rays if the cumulative length added by the diffractions events in comparison to the length ...
boost::shared_ptr< SolverConfiguration > LPSolverConfiguration
Definition: interfaces.h:24
This class mainly define a mesh (list of Shape) used by the Simulation object.
Definition: Scene.h:50
virtual void finish()
End the operations.
virtual bool valideIntersection(Ray *r, Intersection *inter)
validate intersections in function of the type of the intersected primitive
bool constructEdge(Scene *scene)
Build the edges list of a scene.
static LPSolverConfiguration get()
Get the configuration.
Definition: config.cpp:99
: To disable ray with a number of diffraction events greater than a threshold value ...
: Select diffracted rays that are launched in the shadow zone of the obstacle (closed angle) Other ar...