Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYGeometryNode.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 /*
17  *
18  */
19 
20 #ifndef __TY_GEOMETRY_NODE__
21 #define __TY_GEOMETRY_NODE__
22 
23 #if _MSC_VER > 1000
24  #pragma once
25 #endif // _MSC_VER > 1000
26 
27 #ifdef _MSC_VER
28  #pragma warning(disable : 4284)
29 #endif
30 
32 #include "TYRepere.h"
34 
43 class TYGeometryNode;
44 typedef std::map<TYElement*, TYGeometryNode*> TYMapPtrGeoNode;
46 typedef std::list<TYGeometryNode*> TYListPtrGeoNode;
47 
48 class TYGeometryNode : public TYElement
49 {
51 public:
63  TYGeometryNode(TYElement* pElt, TYElement* pParent = NULL);
64 
71  TYGeometryNode(LPTYElement pElt, TYElement* pParent = NULL);
72 
79  TYGeometryNode(const TYRepere& repere, TYElement* pElt);
80 
87  TYGeometryNode(const TYRepere& repere, LPTYElement pElt);
88 
95  TYGeometryNode(TYElement* pElt, const OMatrix& matrix);
96 
103  TYGeometryNode(LPTYElement pElt, const OMatrix& matrix);
104 
110  TYGeometryNode(const TYGeometryNode& other);
111 
115  virtual ~TYGeometryNode();
116 
117  virtual DOM_Element toXML(DOM_Element& domElement);
118  virtual int fromXML(DOM_Element domElement);
119 
120  virtual void getChilds(LPTYElementArray& childs, bool recursif = true);
121 
128  {
129  return _pElement._pObj;
130  }
131 
137  void setElement(LPTYElement pElt);
138 
144  void setElement(TYElement* pElt);
145 
149  void delElement();
150 
154  const ORepere3D& getORepere3D() const
155  {
156  return _repere;
157  }
158 
160  {
161  return _repere;
162  }
163 
164  void setRepere(const ORepere3D& repere)
165  {
166  _repere = repere;
167  }
168 
173  {
174  return _repere.asMatrix();
175  }
176 
180  void setMatrix(const OMatrix& matrix);
181 
185  TYGeometryNode& operator=(const TYGeometryNode& other);
186 
190  bool operator==(const TYGeometryNode& other) const;
191 
195  bool operator!=(const TYGeometryNode& other) const;
196 
205  virtual bool deepCopy(const TYElement* pOther, bool copyId = true, bool pUseCopyTag = false);
206 
210  OMatrix localToGlobal() const;
211 
215  OMatrix localToGeoNode(TYGeometryNode* pGeoNode) const;
216 
220  OMatrix globalToLocal() const;
221 
225  void setPosition(const OPoint3D& pos);
226 
231  {
232  return _repere._origin;
233  }
234 
238  void setRotation(const OPoint3D& rot);
239 
243  OPoint3D rotation();
244 
248  double getHauteur()
249  {
250  return _hauteur;
251  }
252 
256  void setHauteur(const double& hauteur)
257  {
258  _hauteur = hauteur;
259  }
260 
261 #if TY_USE_IHM
262  virtual LPTYElementGraphic getGraphicObject();
263 #endif // TY_USE_IHM
264 
265  static TYGeometryNode* GetGeoNode(TYElement* pElement);
267  void GetGeoNodeParentList(TYListPtrGeoNode& GetGeoNodeParents);
268  // Membres
269 protected:
270  // Problematique d'obtention du geoNode d'un element
271  //- Cette fonctionalite est necessaire pour former une hierarchie de geoNode, car celle-ci decoule de
272  // celle des objets (les 'pElement').
273  //- Cette information de correspondance Element-GeoNode n'est malheureusement pas stockee/stockable cote
274  // Element, car elle peut changer au cours du temps. D'ou l'interet d'une map. Map permettant d'acceder
275  // rapidement au GeoNode connaissant l'element sur lequel il pointe, pour obtenir rapidement le geoNode de
276  // l'element:
278  static TYMapPtrGeoNode* GetGeoNodeMap();
279  // En theorie, il ne peut y avoir qu'un GeoNode pour un element; en pratique, ce n'est (temporairement)
280  // pas le cas: voir operateur =, setElement,...et toutes les methodes ou figure _pElement. Afin de ne pas
281  // perdre d'information de correspondance, on maintient une liste "de doublons" contenant tous les GeoNode
282  // pointant sur un element deja reference par un autre geoNode de la map.
285 
286  // Enregistre this comme geoNode officiel de this->_pElement:
287  void addToTheMap();
288  // Supprime toute reference a this comme geoNode officiel de this->_pElement:
289  void removeFromTheMap();
290 
293 
296 
298  double _hauteur;
299 };
300 
301 #if TY_USE_IHM
303 #endif
304 
306 
307 #endif //__TY_GEOMETRY_NODE__
All base classes related to 3D manipulation.
QDomElement DOM_Element
Definition: QT2DOM.h:30
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:345
#define OPROTODECL(classname)
Definition: TYElement.h:65
Representation graphique d'un GeometryNode (fichier header)
std::map< TYElement *, TYGeometryNode * > TYMapPtrGeoNode
SmartPtr< TYGeometryNode > LPTYGeometryNode
std::list< TYGeometryNode * > TYListPtrGeoNode
Liste ordonnee de pointeurs de TYElement.
The 4x4 matrix class.
Definition: 3d.h:625
The 3D point class.
Definition: 3d.h:487
3D frame with a point and 3 vectors.
Definition: 3d.h:1211
OPoint3D _origin
The origin point.
Definition: 3d.h:1279
OMatrix asMatrix() const
return the transformation matrix from unity to this pose such as this = transform * unity
Definition: 3d.cpp:1462
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
static TYListPtrGeoNode * GetGeoNodeDoublonsList()
const ORepere3D & getORepere3D() const
void setMatrix(const OMatrix &matrix)
static TYMapPtrGeoNode * GetGeoNodeMap()
OMatrix localToGlobal() const
OMatrix globalToLocal() const
virtual DOM_Element toXML(DOM_Element &domElement)
void setRotation(const OPoint3D &rot)
Set the rotation angle along axis x, y & z represented as an OPoint3D.
OMatrix localToGeoNode(TYGeometryNode *pGeoNode) const
TYGeometryNode & operator=(const TYGeometryNode &other)
ORepere3D & getORepere3D()
LPTYElement _pElement
L'instance de l'element geometrique.
TYRepere _repere
Le repere definissant la position et l'orientation de l'element.
static TYMapPtrGeoNode * _geoNodeMap
bool operator!=(const TYGeometryNode &other) const
virtual int fromXML(DOM_Element domElement)
TYGeometryNode * GetGeoNodeParent() const
void GetGeoNodeParentList(TYListPtrGeoNode &GetGeoNodeParents)
void setHauteur(const double &hauteur)
Set the heigth above the ground.
void setElement(LPTYElement pElt)
double _hauteur
Hauteur de l'element par rapport au sol.
static TYListPtrGeoNode * _geoNodeDoublonsList
double getHauteur()
Get the height above the ground.
OPoint3D position()
Get the position of the element.
bool operator==(const TYGeometryNode &other) const
TYElement * getElement() const
virtual ~TYGeometryNode()
OPoint3D rotation()
Get the rotation angle along axis x, y & z represented as an OPoint3D.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
OMatrix getMatrix() const
static TYGeometryNode * GetGeoNode(TYElement *pElement)
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
void setPosition(const OPoint3D &pos)
Set the position of the element.
void setRepere(const ORepere3D &repere)