Code_TYMPAN  4.4.0
Industrial site acoustic simulation
PostFilter.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 #include <map>
17 #include <deque>
18 #include "Ray/Ray.h"
19 
20 #ifndef POST_FILTER_H
21  #define POST_FILTER_H
22 
23 typedef std::map<signature, std::deque<Ray*>> families;
24 typedef std::list<Event*> sequence;
25 typedef std::map<sequence, std::deque<Ray*>> sequenceMap;
26 
30 class PostFilter : public Base
31 {
32 public:
34  PostFilter(std::deque<Ray*>* tabRay) : _tabRays(tabRay) {}
37  {
38  _tabRays = NULL;
39  }
40 
45  virtual unsigned int Process()
46  {
47  return 0;
48  }
49 
54  inline virtual unsigned int buildFamilies(families& mapFamilies, typeevent typeEv)
55  {
56  for (unsigned int i = 0; i < _tabRays->size(); i++)
57  {
58  mapFamilies[_tabRays->at(i)->getSignature(typeEv)].push_back(_tabRays->at(i));
59  }
60 
61  return mapFamilies.size();
62  }
63 
67  inline virtual void rebuildTabRays(families& mapFamilies)
68  {
69  _tabRays->clear();
70 
71  // Relecture des familles
72  std::map<signature, std::deque<Ray*>>::iterator it_families;
73  for (it_families = mapFamilies.begin(); it_families != mapFamilies.end(); it_families++)
74  {
75  std::deque<Ray*>& aTabRay = (*it_families).second; // Get list of Rays
76  for (unsigned int i = 0; i < aTabRay.size(); i++)
77  {
78  _tabRays->push_back(aTabRay.at(i));
79  }
80  }
81  }
82 
86  inline virtual sequenceMap buildSequenceMap(const signature& sig, std::vector<Ray*> tabRay,
87  const typeevent& evType)
88  {
89  sequenceMap seqMap;
90 
91  for (unsigned int i = 0; i < tabRay.size(); i++)
92  {
93  sequence seq = buildSequence(sig, tabRay.at(i), evType);
94  seqMap[seq].push_back(tabRay.at(i));
95  }
96 
97  return seqMap;
98  }
99 
105  inline decimal minimum_distance(const decimal& thickness, const decimal& d_R) const
106  {
107  return sqrt(thickness * thickness + d_R * d_R);
108  }
109 
110 protected:
114  inline virtual sequence buildSequence(const signature& sig, Ray* ray, const typeevent& evType)
115  {
116  sequence res;
117 
118  for (unsigned int i = 0; i < ray->getNbEvents(); i++)
119  {
120  if (ray->getEvents()->at(i).get()->getType() == evType)
121  {
122  res.push_back(ray->getEvents()->at(i).get());
123  }
124  }
125 
126  return res;
127  }
129  inline virtual std::deque<Ray*>::iterator erase_element(std::deque<Ray*>& tabRays,
130  std::deque<Ray*>::iterator& iter)
131  {
132  delete (*iter);
133  (*iter) = NULL;
134 
135  return tabRays.erase(iter);
136  }
137 
138 protected:
139  std::deque<Ray*>* _tabRays;
140 };
141 
142 #endif // POST_FILTER_H
typeevent
Definition: Event.h:24
std::map< signature, std::deque< Ray * > > families
Definition: PostFilter.h:23
std::map< sequence, std::deque< Ray * > > sequenceMap
Definition: PostFilter.h:25
std::list< Event * > sequence
Definition: PostFilter.h:24
std::pair< bitSet, bitSet > signature
Definition: Ray.h:30
Base class of Event, Material, PostFilter, Ray, Repere, Scene, Shape, Simulation, Source.
Definition: Base.h:25
Class to apply a filter to the group of valid rays found by ray tracing.
Definition: PostFilter.h:31
virtual std::deque< Ray * >::iterator erase_element(std::deque< Ray * > &tabRays, std::deque< Ray * >::iterator &iter)
Delete an element in the rays array.
Definition: PostFilter.h:129
virtual sequenceMap buildSequenceMap(const signature &sig, std::vector< Ray * > tabRay, const typeevent &evType)
Sort rays by events of type evType encountered along is path.
Definition: PostFilter.h:86
virtual unsigned int buildFamilies(families &mapFamilies, typeevent typeEv)
Group rays with the same signature (same source and receptor events of same kind in the same order)
Definition: PostFilter.h:54
PostFilter(std::deque< Ray * > *tabRay)
Constructor.
Definition: PostFilter.h:34
virtual sequence buildSequence(const signature &sig, Ray *ray, const typeevent &evType)
Build the sequence of physical shape encountered by the ray.
Definition: PostFilter.h:114
~PostFilter()
Destructor.
Definition: PostFilter.h:36
virtual unsigned int Process()
Apply a filter to the group of valid rays found by ray tracing.
Definition: PostFilter.h:45
decimal minimum_distance(const decimal &thickness, const decimal &d_R) const
compute minimum acceptable distance between two rays thickness is the thickness of a ray after a give...
Definition: PostFilter.h:105
virtual void rebuildTabRays(families &mapFamilies)
Rebuild rays tab after treatment.
Definition: PostFilter.h:67
std::deque< Ray * > * _tabRays
Rays tab: pointers list of rays.
Definition: PostFilter.h:139
: 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
unsigned int getNbEvents() const
Return the total number of events.
Definition: Ray.h:185
std::vector< boost::shared_ptr< Event > > * getEvents()
Return the events array encountered by the ray.
Definition: Ray.h:195
float decimal
Definition: mathlib.h:45