Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYReflectionPathFinder.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 #ifndef __TY_REFLECTION_PATH_FINDER__
17 #define __TY_REFLECTION_PATH_FINDER__
18 
21 
22 #include <gtest/gtest_prod.h>
23 
29 {
32  std::deque<OPoint3D> reflectionPoints;
33  std::vector<const TYSIntersection*> reflectingSegments;
34 };
35 
40 {
41 public:
42  virtual ~TYAbstractReflectionPathFinder() = default;
43 
47  virtual std::unique_ptr<TYAbstractReflectionPathFinder> instanciate() const = 0;
48 
59  virtual bool setup(size_t maxOrder, const std::deque<TYSIntersection>& tabIntersect,
60  const OPoint3D& source, const OPoint3D& receptor) = 0;
61 
67  virtual bool remainingPaths() const = 0;
68 
74  virtual TYReflectionPath popPath() = 0;
75 
76 protected:
78 };
79 
84 {
85 public:
92  TYReflectionPathFinderART(unsigned int nbRays, double rcptRadius);
93 
98  std::unique_ptr<TYAbstractReflectionPathFinder> instanciate() const override;
99 
100  bool setup(size_t maxOrder, const std::deque<TYSIntersection>& tabIntersect, const OPoint3D& source,
101  const OPoint3D& receptor) override;
102 
103  bool remainingPaths() const override;
104 
105  TYReflectionPath popPath() override;
106 
107 protected:
109 
113  void setupConfiguration(size_t maxOrder);
114 
129  bool setupScene(const std::deque<TYSIntersection>& tabIntersect, const OPoint3D& sourcePoint,
130  const OPoint3D& receptorPoint);
131 
136 
140  void setupSolver();
141 
145  void computeRaytracing();
146 
154  void buildReflectionPaths(const OPoint3D& source, const OPoint3D& receptor);
155 
164  bool processIntersectingSegment(const TYSIntersection& inter);
165 
187 
215 
227  void buildQuadranglePointsFromInter(const TYSIntersection& inter, OPoint3D& p1Top, OPoint3D& p1Bottom,
228  OPoint3D& p2Top, OPoint3D& p2Bottom) const;
229 
250  void addOrientedQuadrangle(const OPoint3D& p1Top, const OPoint3D& p1Bottom, const OPoint3D& p2Top,
251  const OPoint3D& p2Bottom, const OVector3D vExt,
252  const TYSIntersection& sourceInter);
253 
265  Shape* addOrientedTriangle(const OPoint3D& p1, const OPoint3D& p2, const OPoint3D& p3,
266  const OVector3D& vExt);
267 
276  OVector3D computeELPlaneNormal(const OPoint3D& source, const OPoint3D& receptor);
277 
287  bool isPathValid(const TYReflectionPath& path);
288 
296  bool isPathAlreadyFound(const TYReflectionPath& path) const;
297 
305 
307  std::unique_ptr<Solver> _pSolver;
308  std::set<std::vector<const TYSIntersection*>> _foundSequences;
309  std::deque<TYReflectionPath> _paths;
310  std::unordered_map<const Shape*, const TYSIntersection*> _shapeToTYSIntersection;
311  unsigned int _nbRays;
312  double _rcptRadius;
315 
316  FRIEND_TEST(test_ReflectionPathFinderART, computeELPlaneNormal_horizontalPlane1);
317  FRIEND_TEST(test_ReflectionPathFinderART, computeELPlaneNormal_horizontalPlane2);
318  FRIEND_TEST(test_ReflectionPathFinderART, computeELPlaneNormal_nonHorizontalPlane);
319 };
320 
321 #endif // __TY_REFLECTION_PATH_FINDER__
The 3D point class.
Definition: 3d.h:487
The 3D vector class.
Definition: 3d.h:298
base class for shapes (Cylindre, Mesh, Sphere, Triangle,...)
Definition: Shape.h:57
Class hosting all the informations needed for ray tracing. It contains the function to launch the ray...
Definition: Simulation.h:44
Interface for multiple reflection paths computation algorithms.
virtual std::unique_ptr< TYAbstractReflectionPathFinder > instanciate() const =0
Instanciate a new reflection path finder of the same type.
virtual TYReflectionPath popPath()=0
Give the last computed reflection path, and remove it from the set of remaining paths.
virtual ~TYAbstractReflectionPathFinder()=default
virtual bool remainingPaths() const =0
Tell if some paths remain in the set of remaining paths.
virtual bool setup(size_t maxOrder, const std::deque< TYSIntersection > &tabIntersect, const OPoint3D &source, const OPoint3D &receptor)=0
Set the scene to be treated by the path finder.
Reflection path finder relying on ray-tracing using the AcousticRaytracer module.
std::unique_ptr< TYAbstractReflectionPathFinder > instanciate() const override
Instanciate a new TYReflectionPathFinderART. The configuration of the former path finder (number of r...
void computeRaytracing()
Perform raytracing simulation.
void setupConfiguration(size_t maxOrder)
Setup ART' Simulation configuration.
bool processIntersectingSegment(const TYSIntersection &inter)
Process an intersecting segment in EL-plane to add equivalent faces in the AcousticRaytracer' simulat...
std::unique_ptr< Solver > _pSolver
bool setup(size_t maxOrder, const std::deque< TYSIntersection > &tabIntersect, const OPoint3D &source, const OPoint3D &receptor) override
Set the scene to be treated by the path finder.
std::unordered_map< const Shape *, const TYSIntersection * > _shapeToTYSIntersection
Shape * addOrientedTriangle(const OPoint3D &p1, const OPoint3D &p2, const OPoint3D &p3, const OVector3D &vExt)
Add an oriented triangle to the AcousticRaytracer' simulation scene. The vertices (v1 = p1,...
void setupAcceleratingDataStructure()
Setup accelerating data-structure using ART' Simulation configuration.
bool remainingPaths() const override
Tell if some paths remain in the set of remaining paths.
FRIEND_TEST(test_ReflectionPathFinderART, computeELPlaneNormal_horizontalPlane1)
bool setupScene(const std::deque< TYSIntersection > &tabIntersect, const OPoint3D &sourcePoint, const OPoint3D &receptorPoint)
Build an AcousticRaytracer scene containing one source, one receptor, and a collection of faces....
void buildQuadranglePointsFromInter(const TYSIntersection &inter, OPoint3D &p1Top, OPoint3D &p1Bottom, OPoint3D &p2Top, OPoint3D &p2Bottom) const
Compute points forming a quadrangle from an intersecting segment in EL-plane. Points are obtained by ...
FRIEND_TEST(test_ReflectionPathFinderART, computeELPlaneNormal_nonHorizontalPlane)
std::deque< TYReflectionPath > _paths
bool isPathAlreadyFound(const TYReflectionPath &path) const
Check if a path has already been found.
bool processTopoIntersectingSegment(const TYSIntersection &inter)
Process a topography intersecting segment in EL-plane to add equivalent faces in the AcousticRaytrace...
void buildReflectionPaths(const OPoint3D &source, const OPoint3D &receptor)
Build reflection paths from valid rays found by the solver. For each sequence of reflecting barriers,...
TYReflectionPathFinderART()=default
TYReflectionPath popPath() override
Give the last computed reflection path, and remove it from the set of remaining paths.
OVector3D computeELPlaneNormal(const OPoint3D &source, const OPoint3D &receptor)
Compute a normal vector of the EL-plane Hypothesis: source and receptor are not aligned along a verti...
bool processInfraIntersectingSegment(const TYSIntersection &inter)
Process an infrastructure intersecting segment in EL-plane to add equivalent faces in the AcousticRay...
void setupSolver()
Setup ART' simulation solver.
FRIEND_TEST(test_ReflectionPathFinderART, computeELPlaneNormal_horizontalPlane2)
std::set< std::vector< const TYSIntersection * > > _foundSequences
bool isPathValid(const TYReflectionPath &path)
Check if a path is valid. In plus of validation performed during raytracing, it has to be verified:
bool isLastSegmentIntersectingSceneElement(const TYReflectionPath &path)
Check if the last segment of a path intersects a scene element.
void addOrientedQuadrangle(const OPoint3D &p1Top, const OPoint3D &p1Bottom, const OPoint3D &p2Top, const OPoint3D &p2Bottom, const OVector3D vExt, const TYSIntersection &sourceInter)
Add an oriented quadrangle to the AcousticRaytracer' simulation scene. The quadrangle is oriented usi...
Data-structure representing a reflection path It stores all needed data to build a TYChemin.
std::deque< OPoint3D > reflectionPoints
std::vector< const TYSIntersection * > reflectingSegments
Data structure for intersections.