Code_TYMPAN  4.2.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){}
36  ~PostFilter() { _tabRays = NULL; }
37 
42  virtual unsigned int Process() { return 0; }
43 
48  inline virtual unsigned int buildFamilies(families& mapFamilies, typeevent typeEv)
49  {
50  for (unsigned int i = 0; i < _tabRays->size(); i++)
51  {
52  mapFamilies[_tabRays->at(i)->getSignature(typeEv)].push_back(_tabRays->at(i));
53  }
54 
55  return mapFamilies.size();
56  }
57 
61  inline virtual void rebuildTabRays(families& mapFamilies)
62  {
63  _tabRays->clear();
64 
65  // Relecture des familles
66  std::map< signature, std::deque<Ray*> >::iterator it_families;
67  for (it_families = mapFamilies.begin(); it_families != mapFamilies.end(); it_families++)
68  {
69  std::deque<Ray*>& aTabRay= (*it_families).second; // Get list of Rays
70  for (unsigned int i=0; i<aTabRay.size(); i++)
71  {
72  _tabRays->push_back( aTabRay.at(i) );
73  }
74  }
75  }
76 
80  inline virtual sequenceMap buildSequenceMap(const signature& sig, std::vector<Ray*> tabRay, const typeevent& evType)
81  {
82  sequenceMap seqMap;
83 
84  for (unsigned int i = 0; i < tabRay.size(); i++)
85  {
86  sequence seq = buildSequence(sig, tabRay.at(i), evType);
87  seqMap[seq].push_back(tabRay.at(i));
88  }
89 
90  return seqMap;
91  }
92 
98  inline decimal minimum_distance(const decimal& thickness, const decimal& d_R) const
99  {
100  return sqrt(thickness * thickness + d_R * d_R);
101  }
102 
103 protected:
107  inline virtual sequence buildSequence(const signature& sig, Ray* ray, const typeevent& evType)
108  {
109  sequence res;
110 
111  for (unsigned int i = 0; i < ray->getNbEvents(); i++)
112  {
113  if (ray->getEvents()->at(i).get()->getType() == evType) { res.push_back(ray->getEvents()->at(i).get()); }
114  }
115 
116  return res;
117  }
119  inline virtual std::deque<Ray*>::iterator erase_element(std::deque<Ray*>& tabRays, std::deque<Ray*>::iterator& iter)
120  {
121  delete(*iter);
122  (*iter) = NULL;
123 
124  return tabRays.erase(iter);
125  }
126 
127 
128 
129 protected:
130 
131  std::deque<Ray*> *_tabRays;
132 };
133 
134 #endif //POST_FILTER_H
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:98
Base class of Event, Material, PostFilter, Ray, Repere, Scene, Shape, Simulation, Source...
Definition: Base.h:24
std::pair< bitSet, bitSet > signature
Definition: Ray.h:31
std::list< Event * > sequence
Definition: PostFilter.h:24
Class to apply a filter to the group of valid rays found by ray tracing.
Definition: PostFilter.h:30
unsigned int getNbEvents() const
Return the total number of events.
Definition: Ray.h:173
std::vector< boost::shared_ptr< Event > > * getEvents()
Return the events array encountered by the ray.
Definition: Ray.h:180
~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:42
typeevent
Definition: Event.h:24
std::deque< Ray * > * _tabRays
Rays tab: pointers list of rays.
Definition: PostFilter.h:131
: 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
std::map< signature, std::deque< Ray * > > families
Definition: PostFilter.h:23
float decimal
Definition: mathlib.h:46
std::map< sequence, std::deque< Ray * > > sequenceMap
Definition: PostFilter.h:25
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:119
virtual void rebuildTabRays(families &mapFamilies)
Rebuild rays tab after treatment.
Definition: PostFilter.h:61
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:80
virtual sequence buildSequence(const signature &sig, Ray *ray, const typeevent &evType)
Build the sequence of physical shape encountered by the ray.
Definition: PostFilter.h:107
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:48
PostFilter(std::deque< Ray *> *tabRay)
Constructor.
Definition: PostFilter.h:34