Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYGeometryNode.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 /*
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<const 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 
159  void setRepere(const ORepere3D& repere);
160 
165  {
166  return _repere.asMatrix();
167  }
168 
172  void setMatrix(const OMatrix& matrix);
173 
177  TYGeometryNode& operator=(const TYGeometryNode& other);
178 
182  bool operator==(const TYGeometryNode& other) const;
183 
187  bool operator!=(const TYGeometryNode& other) const;
188 
197  virtual bool deepCopy(const TYElement* pOther, bool copyId = true, bool pUseCopyTag = false);
198 
202  OMatrix localToGlobal() const;
203 
207  OMatrix localToGeoNode(const TYGeometryNode* pGeoNode) const;
208 
212  OMatrix globalToLocal() const;
213 
217  void setPosition(const OPoint3D& pos);
218 
223  {
224  return _repere._origin;
225  }
226 
230  void setRotation(const OPoint3D& rot);
231 
235  OPoint3D rotation();
236 
240  double getHauteur()
241  {
242  return _hauteur;
243  }
244 
248  void setHauteur(const double& hauteur)
249  {
250  _hauteur = hauteur;
251  }
252 
253 #if TY_USE_IHM
254  virtual LPTYElementGraphic getGraphicObject();
255 #endif // TY_USE_IHM
256 
257  static TYGeometryNode* GetGeoNode(TYElement* pElement);
258  static const TYGeometryNode* GetGeoNode(const TYElement* pElement);
260  void GetGeoNodeParentList(TYListPtrGeoNode& GetGeoNodeParents);
261  // Membres
262 protected:
263  // Problematique d'obtention du geoNode d'un element
264  //- Cette fonctionalite est necessaire pour former une hierarchie de geoNode, car celle-ci decoule de
265  // celle des objets (les 'pElement').
266  //- Cette information de correspondance Element-GeoNode n'est malheureusement pas stockee/stockable cote
267  // Element, car elle peut changer au cours du temps. D'ou l'interet d'une map. Map permettant d'acceder
268  // rapidement au GeoNode connaissant l'element sur lequel il pointe, pour obtenir rapidement le geoNode de
269  // l'element:
271  static TYMapPtrGeoNode* GetGeoNodeMap();
272  // En theorie, il ne peut y avoir qu'un GeoNode pour un element; en pratique, ce n'est (temporairement)
273  // pas le cas: voir operateur =, setElement,...et toutes les methodes ou figure _pElement. Afin de ne pas
274  // perdre d'information de correspondance, on maintient une liste "de doublons" contenant tous les GeoNode
275  // pointant sur un element deja reference par un autre geoNode de la map.
278 
279  // Enregistre this comme geoNode officiel de this->_pElement:
280  void addToTheMap();
281  // Supprime toute reference a this comme geoNode officiel de this->_pElement:
282  void removeFromTheMap();
283 
286 
289 
291  double _hauteur;
292 };
293 
295 
296 #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:344
#define OPROTODECL(classname)
Definition: TYElement.h:64
SmartPtr< TYGeometryNode > LPTYGeometryNode
std::map< const TYElement *, TYGeometryNode * > TYMapPtrGeoNode
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:1263
OPoint3D _origin
The origin point.
Definition: 3d.h:1331
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.
TYGeometryNode & operator=(const TYGeometryNode &other)
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
OMatrix localToGeoNode(const TYGeometryNode *pGeoNode) 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)