Salome HOME
Version ok de MED avec MEDGUI.
[modules/med.git] / src / MEDMEM / MEDMEM_Coordinate.cxx
1 #include "MEDMEM_Coordinate.hxx"
2 #include "utilities.h"
3
4 /*! This class contains coordinates of the nodes */
5 //----------------------------------------------------------//
6 COORDINATE::COORDINATE():_coordinate((MEDARRAY<double>*)NULL),
7                          _coordinateName((string*)NULL),
8                          _coordinateUnit((string*)NULL),
9                          _nodeNumber((int*)NULL)
10 //----------------------------------------------------------//
11 {
12     BEGIN_OF("Default Constructor COORDINATE");
13 }
14
15 //------------------------------------------------------------------------------//
16 COORDINATE::COORDINATE(medModeSwitch Mode,int SpaceDimension, int NumberOfNodes):
17                         _nodeNumber((int*)NULL) 
18 //------------------------------------------------------------------------------//
19 {
20     BEGIN_OF("Constructor COORDINATE");
21     _coordinateName = new string[SpaceDimension] ;
22     _coordinateUnit = new string[SpaceDimension] ;
23     _coordinate = new MEDARRAY<double>(SpaceDimension,NumberOfNodes,Mode);
24 }
25 //----------------------//
26 COORDINATE::~COORDINATE()
27 //----------------------//
28 {
29     MESSAGE("Debut Destructeur COORDINATE");
30     if (_coordinate!=NULL)
31       delete _coordinate ;
32     if (_coordinateName!=NULL)
33       delete[] _coordinateName ;
34     if (_coordinateUnit!=NULL)
35       delete[] _coordinateUnit ;
36     if (_nodeNumber!=NULL)
37       delete[] _nodeNumber ;
38   }
39
40 /*! set the attribute _coordinate with Coordinate           */
41 //----------------------------------------------------------//
42 void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate) 
43 //----------------------------------------------------------//
44
45         _coordinate=Coordinate ; 
46 }
47
48 /*! set the attribute _coordinateName with CoordinateName   */
49 //----------------------------------------------------------//
50 void COORDINATE::setCoordinatesNames(string * CoordinateName) 
51 //----------------------------------------------------------//
52 {       
53         _coordinateName=CoordinateName ; 
54 }
55
56 /*! set the attribute _coordinateUnit with CoordinateUnit   */
57 //----------------------------------------------------------//
58 void COORDINATE::setCoordinatesUnits(string * CoordinateUnit) 
59 //----------------------------------------------------------//
60
61         _coordinateUnit=CoordinateUnit ; 
62 }
63
64 /*! set the attribute _nodeNumber with NodeNumber */
65 //------------------------------------------------//
66 void COORDINATE::setNodesNumbers(int * NodeNumber) 
67 //------------------------------------------------//
68 {       
69         _nodeNumber=NodeNumber ; 
70 }
71
72 /*! returns the number of nodes defined in the mesh*/
73 //-------------------------------------------------//
74 int * COORDINATE::getNodesNumbers() const
75 //-------------------------------------------------//
76 {
77         return _nodeNumber;
78 }
79
80 /*! returns the mode of coordinates (FULL_INTERLACE or NO_INTERLACE) */
81 //-------------------------------------------------------------------//
82 const double *  COORDINATE::getCoordinates (medModeSwitch Mode) 
83 //-------------------------------------------------------------------//
84 {
85         return _coordinate->get(Mode) ;
86 }
87
88 /* returns the coordinate of node Number on axis Axis */
89 //----------------------------------------------------//
90 double COORDINATE::getCoordinate(int Number,int Axis) 
91 //----------------------------------------------------//
92 {       
93         return _coordinate->getIJ(Number,Axis) ;
94 }
95
96 /* returns all nodes coordinates from  axis Axis      */
97 //----------------------------------------------------//
98 const double *  COORDINATE::getCoordinateAxis(int Axis) 
99 //----------------------------------------------------//
100 {                       //< return all nodes coordinates from axis Axis
101          return _coordinate->getI(MED_NO_INTERLACE,Axis) ;
102 }
103
104 /*! Returns an array with names of coordinates.
105       Example :
106       - x,y,z
107       - r,teta,phi
108       - ... */
109 //--------------------------------------//
110 string * COORDINATE::getCoordinatesNames() 
111 {
112         return _coordinateName ;
113 }
114
115 /* returns the name of axis Axis             */
116 //-------------------------------------------//
117 string COORDINATE::getCoordinateName(int Axis) 
118 //-------------------------------------------//
119 {
120         return _coordinateName[Axis-1];
121 }
122
123 /*!  Returns an array with units of coordinates (cm, m, mm, ...)
124      It could be empty. We suppose we are IS (meter).  */
125 //-----------------------------------------------------//
126 string * COORDINATE::getCoordinatesUnits() 
127 //-----------------------------------------------------//
128 {
129         return _coordinateUnit ;
130 }
131
132 /*! Returns the unit of axis Axis           */
133 //------------------------------------------//
134 string COORDINATE::getCoordinateUnit(int Axis) 
135 //------------------------------------------//
136 {
137         return _coordinateUnit[Axis-1] ;
138 }
139 /*! Returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/
140 //---------------------------------------------------//
141 string COORDINATE::getCoordinatesSystem() const
142 //---------------------------------------------------//
143 {
144   return _coordinateSystem ;
145 }