Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYChemineeSurface.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"
17 #if TY_USE_IHM
19 #endif
20 
21 #include "TYChemineeSurface.h"
22 
24 
26 {
28 
29  distriSrcs();
30 
31  // Couleur par default
32  setColor(OColor(1.0f, 0.5f, 0.0f));
33 }
34 
36 {
37  *this = other;
38 }
39 
41 
43 {
44  int retVal = TYAcousticSurface::fromXML(domElement);
45 
46  // On recupere le rectangle de la surface pour l'affecter a la source bafflee
47  // LPTYAcousticRectangle pRectangle = new TYAcousticRectangle();
48  LPTYRectangle pRectangle = new TYRectangle();
49  // *pRectangle->getBoundingRect() = *getBoundingRect();
50  *pRectangle = *getBoundingRect();
51 
52  LPTYSourceCheminee pSrcCheminee = this->getSourceCheminee();
53  if (pSrcCheminee == NULL)
54  {
55  pSrcCheminee = new TYSourceCheminee();
56  pSrcCheminee->setParent(this);
57  }
58 
59  pSrcCheminee->setAcousticRectangle(pRectangle);
60 
61  return retVal;
62 }
63 
65 {
66  if (this != &other)
67  {
69  }
70  return *this;
71 }
72 
74 {
75  if (this != &other)
76  {
77  if (TYAcousticRectangle::operator!=(other))
78  {
79  return false;
80  }
81  }
82  return true;
83 }
84 
86 {
87  return !operator==(other);
88 }
89 
90 std::string TYChemineeSurface::toString() const
91 {
92  return "TYChemineeSurface";
93 }
94 
96 {
97  if (surface() <= 1.E-8)
98  {
99  _pSrcSurf->purge();
100  return; // securite : pas de surface nulle
101  }
102 
103  // La source surfacique est composee d'une seule
104  // source de type TYSourceCheminee
105  // Si la source n'est pas trouvee
106  if (!getSourceCheminee())
107  {
108  // On creait la source, cela devrait etre fait qu'une seule fois a l'init...
110  }
111  // To define directivity
112  double specificSize = getBoundingRect()->getCircleEqDiameter() / 2.0;
113  OVector3D faceNormal = normal();
114  faceNormal.normalize();
116  getSourceCheminee()->setDirectivity(new TYComputedDirectivity(faceNormal, type, specificSize));
117 }
118 
120 {
121  LPTYSourceCheminee pSrc = NULL;
122 
123  if (_pSrcSurf->getNbSrcs())
124  {
126  }
127 
128  return pSrc;
129 }
130 
132 {
133  // On s'assure du type
134  assert(TYSourceCheminee::safeDownCast(pSrc));
135 
136  // On vide, il doit y avoir qu'une seule face a l'index 0
137  _pSrcSurf->remAllSrc();
138 
139  // Ajout
140  LPTYPoint pPoint = pSrc->getPos();
141  pPoint->_z += _offsetSources;
142  _pSrcSurf->addSrc(pSrc);
143 
144  // Cette face est son parent
145  pSrc->setParent(this);
146 
147  // Cette face est aussi le support de la source bafflee associee
148  // Uniquement si 'this' est un smart pointer...
149  if (getRefCount() > 0)
150  {
151  // pSrc->setAcousticRectangle(this);
152  pSrc->setAcousticRectangle(this->getBoundingRect());
153  }
154  else
155  {
156  // LPTYAcousticRectangle temp = new TYAcousticRectangle(*this);
157  LPTYRectangle temp = new TYRectangle(*((*this).getBoundingRect()));
158  pSrc->setAcousticRectangle(temp);
159  }
160 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
outil IHM pour une surface de cheminee (fichier header)
TY_EXTENSION_INST(TYChemineeSurface)
int getRefCount() const
Definition: smartptr.h:90
Definition: color.h:31
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
virtual const char * getClassName() const
Definition: TYElement.h:249
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
The 3D vector class.
Definition: 3d.h:298
void normalize()
Normalizes this vector.
Definition: 3d.cpp:225
double _offsetSources
Offset de decalage des sources ponctuelles sur les surfaces.
TYAcousticRectangle & operator=(const TYAcousticRectangle &other)
Operateur =.
virtual double surface() const
virtual OVector3D normal() const
TYRectangle * getBoundingRect()
LPTYSourceSurfacic _pSrcSurf
Source surfacique.
virtual int fromXML(DOM_Element domElement)
virtual int fromXML(DOM_Element domElement)
virtual std::string toString() const
LPTYSourceCheminee getSourceCheminee()
virtual void distriSrcs()
void setSourceCheminee(LPTYSourceCheminee pSrc)
TYChemineeSurface & operator=(const TYChemineeSurface &other)
Operateur =.
bool operator!=(const TYChemineeSurface &other) const
Operateur !=.
bool operator==(const TYChemineeSurface &other) const
Operateur ==.
virtual void setColor(const OColor &color)
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
double getCircleEqDiameter()
size_t getNbSrcs() const
LPTYSourcePonctuelle getSrc(int index)
bool addSrc(LPTYSourcePonctuelle pSrcPonct)