Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYBoucheSurface.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 #include "TYBoucheSurface.h"
21 
23 
25 {
27 
28  distriSrcs();
29 
30  // Couleur par default
31  setColor(OColor(0.5f, 0.0f, 0.0f));
32 }
33 
35 {
36  *this = other;
37 }
38 
40 
42 {
43  int retVal = TYAcousticSurface::fromXML(domElement);
44 
45  // On recupere le rectangle de la surface pour l'affecter a la source bafflee
46  // LPTYAcousticRectangle pRectangle = new TYAcousticRectangle();
47  LPTYRectangle pRectangle = new TYRectangle();
48  // *pRectangle->getBoundingRect() = *getBoundingRect();
49  *pRectangle = *getBoundingRect();
50  LPTYSourceBafflee pSourceBafflee = this->getSourceBafflee();
51  if (pSourceBafflee == NULL)
52  {
53  pSourceBafflee = new TYSourceBafflee();
54  pSourceBafflee->setParent(this);
55  }
56 
57  pSourceBafflee->setAcousticRectangle(pRectangle);
58 
59  return retVal;
60 }
61 
63 {
64  if (this != &other)
65  {
67  }
68  return *this;
69 }
70 
72 {
73  if (this != &other)
74  {
75  if (TYAcousticRectangle::operator!=(other))
76  {
77  return false;
78  }
79  }
80  return true;
81 }
82 
84 {
85  return !operator==(other);
86 }
87 
88 std::string TYBoucheSurface::toString() const
89 {
90  return "TYBoucheSurface";
91 }
92 
94 {
95  if (surface() <= 1.E-8)
96  {
97  _pSrcSurf->purge();
98  return; // securite : pas de surface nulle
99  }
100  // La source surfacique est composee d'une seule
101  // source de type TYSourceBafflee
102  // Si la source n'est pas trouvee
103  if (!getSourceBafflee())
104  {
105  // On creait la source, cela devrait etre fait qu'une seule fois a l'init...
107  }
108  // To define directivity
109  double specificSize = getBoundingRect()->getCircleEqDiameter() / 2.0;
110  OVector3D faceNormal = normal();
111  faceNormal.normalize();
113  getSourceBafflee()->setDirectivity(new TYComputedDirectivity(faceNormal, type, specificSize));
114 }
115 
117 {
118  LPTYSourceBafflee pSrc = NULL;
119 
120  if (_pSrcSurf->getNbSrcs())
121  {
123  }
124 
125  return pSrc;
126 }
127 
129 {
130  // On s'assure du type
131  assert(TYSourceBafflee::safeDownCast(pSrc));
132 
133  // On vide, il doit y avoir qu'une seule face a l'index 0
134  _pSrcSurf->remAllSrc();
135 
136  // Ajout
137  LPTYPoint pPoint = pSrc->getPos();
138  pPoint->_z += _offsetSources;
139  _pSrcSurf->addSrc(pSrc);
140 
141  // Cette face est son parent
142  pSrc->setParent(this);
143 
144  // Cette face est aussi le support de la source bafflee associee
145  // Uniquement si 'this' est un smart pointer...
146  if (getRefCount() > 0)
147  {
148  // pSrc->setAcousticRectangle(this);
149  pSrc->setAcousticRectangle(this->getBoundingRect());
150  }
151  else
152  {
153  // LPTYAcousticRectangle temp = new TYAcousticRectangle(*this);
154  LPTYRectangle temp = new TYRectangle(*((*this).getBoundingRect()));
155  pSrc->setAcousticRectangle(temp);
156  }
157 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
outil IHM pour une bouche de ventilation (fichier header)
TY_EXTENSION_INST(TYBoucheSurface)
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)
LPTYSourceBafflee getSourceBafflee()
virtual ~TYBoucheSurface()
bool operator!=(const TYBoucheSurface &other) const
Operateur !=.
TYBoucheSurface & operator=(const TYBoucheSurface &other)
Operateur =.
virtual int fromXML(DOM_Element domElement)
bool operator==(const TYBoucheSurface &other) const
Operateur ==.
virtual void distriSrcs()
void setSourceBafflee(LPTYSourceBafflee pSrc)
virtual std::string toString() const
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)