Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticRectangle.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 
16 #include "Tympan/core/logging.h"
18 #if TY_USE_IHM
21 #endif
22 #include "TYAcousticRectangle.h"
23 
26 
28 {
30 }
31 
33 {
34  *this = other;
35 }
36 
38 
40 {
41  if (this != &other)
42  {
44  }
45  return *this;
46 }
47 
49 {
50  if (this != &other)
51  {
52  if (TYAcousticSurface::operator!=(other))
53  {
54  return false;
55  }
56  }
57  return true;
58 }
59 
61 {
62  return !operator==(other);
63 }
64 
65 bool TYAcousticRectangle::deepCopy(const TYElement* pOther, bool copyId /*=true*/,
66  bool pUseCopyTag /*=false*/)
67 {
68  return TYAcousticSurface::deepCopy(pOther, copyId);
69 }
70 
71 std::string TYAcousticRectangle::toString() const
72 {
73  return "TYAcousticRectangle";
74 }
75 
77 {
78  DOM_Element domNewElem = TYAcousticSurface::toXML(domElement);
79  return domNewElem;
80 }
81 
83 {
84  return TYAcousticSurface::fromXML(domElement);
85 }
86 
88 {
90 }
91 
93 {
94  return TYSourcePonctuelle();
95 }
96 
98 {
99  // Suppression des sources existantes
100  _pSrcSurf->purge();
101 
102  if (!_isRayonnant || surface() <= 1.E-8) // Face non rayonnante
103  {
104  // Pas de calcul
105  return;
106  }
107 
108  // On cherche les vecteurs des cotes H et V du rectangle
111 
112  // On calcul le nb de source en H et V
113  int nbSrcsH = (int)(vecH.norme() / _pSrcSurf->getDensiteSrcsH());
114  int nbSrcsV = (int)(vecV.norme() / _pSrcSurf->getDensiteSrcsV());
115 
116  // On essaye de se rapprocher au mieux de la densite totale (H*V)
117  // (On veut au moins 1 source)
118  if ((nbSrcsH * nbSrcsV) != (surface() * _pSrcSurf->getDensiteSrcs()))
119  {
120  nbSrcsV ? nbSrcsV : nbSrcsV++;
121  nbSrcsH ? nbSrcsH : nbSrcsH++;
122  }
123 
124  // Nombre d'iterations (nbSrcsH * nbSrcsV);
125 
126  // Calcul des vecteurs pas en H et V (ecart entre chaque src)
127  vecH = vecH * (1.0 / (double)nbSrcsH);
128  vecV = vecV * (1.0 / (double)nbSrcsV);
129 
130  // Calcul du pt de depart pour le placement des srcs
131  OVector3D startPt = OVector3D(_pBoundingRect->_pts[0]) + (vecH * 0.5) + (vecV * 0.5);
132 
133  // To define directivity
134  double specificSize = this->getBoundingRect()->getDiagSize();
135  OVector3D faceNormal = normal();
136  faceNormal.normalize();
138 
139  // Scan V
140  for (int iV = 0; (iV < nbSrcsV); iV++)
141  {
142  // Petite economie de calcul
143  OVector3D offsetV = startPt + (vecV * iV);
144 
145  // Scan H
146  for (int iH = 0; (iH < nbSrcsH); iH++)
147  {
148 
149  // Creation d'une source ponctuelle
151  pSrc->setDirectivity(new TYComputedDirectivity(faceNormal, type, specificSize));
152 
153  // Positionnement, on "parcours" la surface par des multiples
154  // des vecteurs pas
155  *pSrc->getPos() = offsetV + (vecH * iH);
156 
157  // On decale les sources de la surface pour le lancer de rayons
158  pSrc->getPos()->_z = _offsetSources;
159 
160  // Attribution du parent
161  pSrc->setParent(this);
162 
163  // Definition des sources comme sources a directivite calculee
164  pSrc->setTypeRaynt(CALCULATED);
165 
166  // Ajout de la src ponct a la src surf
167  _pSrcSurf->addSrc(pSrc);
168  }
169  }
170 }
171 
173 {
174  return TYAcousticSurface::setSrcsLw(); // Appel de la methode generale
175 }
176 
178 {
179  return _pBoundingRect->surface();
180 }
181 
183 {
184  return _pBoundingRect->normal();
185 }
186 
188 {
189  return _pBoundingRect->plan();
190 }
191 
193 {
194  return _pBoundingRect->getContour(n);
195 }
196 
198 {
199  return _pBoundingRect->getOContour(n);
200 }
201 
203 {
204  return _pBoundingRect->intersects(pSurf, seg);
205 }
206 
208 {
209  return _pBoundingRect->intersects(seg, pt);
210 }
All base classes related to 3D manipulation.
QDomElement DOM_Element
Definition: QT2DOM.h:30
Representation graphique d'un rectangle acoustique (fichier header)
outil IHM pour un rectangle acoustique (fichier header)
TY_EXT_GRAPHIC_INST(TYAcousticRectangle)
TY_EXTENSION_INST(TYAcousticRectangle)
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
std::deque< OPoint3D > TYTabPoint3D
Collection de OPoint3D.
Definition: TYDefines.h:403
std::vector< LPTYSourcePonctuelleGeoNode > TYTabSourcePonctuelleGeoNode
Collection de noeuds geometriques de type TYSourcePonctuelle.
@ CALCULATED
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
Plan defined by its equation : ax+by+cz+d=0.
Definition: plan.h:31
The 3D point class.
Definition: 3d.h:487
virtual const char * getClassName() const
Definition: TYElement.h:249
Class to define a segment.
Definition: 3d.h:1089
The 3D vector class.
Definition: 3d.h:298
double norme() const
Computes the length of this vector.
Definition: 3d.cpp:215
void normalize()
Normalizes this vector.
Definition: 3d.cpp:225
double _offsetSources
Offset de decalage des sources ponctuelles sur les surfaces.
bool _isRayonnant
Etat courant de l'element (rayonnant ou non rayonnant)
virtual TYTabPoint getContour(int n=-1) const
virtual int intersects(const TYSurfaceInterface *pSurf, OSegment3D &seg) const
bool operator==(const TYAcousticRectangle &other) const
Operateur ==.
virtual int fromXML(DOM_Element domElement)
virtual TYTabPoint3D getOContour(int n=-1) const
TYAcousticRectangle & operator=(const TYAcousticRectangle &other)
Operateur =.
virtual DOM_Element toXML(DOM_Element &domElement)
virtual std::string toString() const
bool operator!=(const TYAcousticRectangle &other) const
Operateur !=.
virtual OPlan plan() const
virtual double surface() const
virtual OVector3D normal() const
virtual TYSourcePonctuelle srcPonctEquiv() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
TYAcousticSurface & operator=(const TYAcousticSurface &other)
Operateur =.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
LPTYRectangle _pBoundingRect
Rectangle englobant.
virtual bool setSrcsLw()
TYRectangle * getBoundingRect()
virtual DOM_Element toXML(DOM_Element &domElement)
LPTYSourceSurfacic _pSrcSurf
Source surfacique.
virtual int fromXML(DOM_Element domElement)
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
void setParent(TYElement *pParent)
Definition: TYElement.h:692
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
virtual int intersects(const TYSurfaceInterface *pSurf, OSegment3D &seg) const
double getDiagSize()
virtual OPlan plan() const
TYPoint _pts[4]
Sommets.
Definition: TYRectangle.h:274
virtual TYTabPoint getContour(int n=-1) const
virtual OVector3D normal() const
virtual TYTabPoint3D getOContour(int n=-1) const
virtual double surface() const
void setDirectivity(TYDirectivity *directivity_)
: Get/Set directivity to source
void setTypeRaynt(TYTypeRaynt type)
double getDensiteSrcsH() const
double getDensiteSrcs() const
bool addSrc(LPTYSourcePonctuelle pSrcPonct)
double getDensiteSrcsV() const