]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_Coordinate.cxx
Salome HOME
NRI : Update 1.1a and New organisation.
[modules/med.git] / src / MEDMEM / MEDMEM_Coordinate.cxx
1 using namespace std;
2 #include "MEDMEM_Coordinate.hxx"
3 #include "utilities.h"
4
5 /*! This class contains coordinates of the nodes */
6 //----------------------------------------------------------//
7 COORDINATE::COORDINATE():_coordinate(),
8                          _coordinateName(),
9                          _coordinateUnit(),
10                          _coordinateSystem(""),
11                          _nodeNumber()
12 //----------------------------------------------------------//
13 {
14     BEGIN_OF("Default Constructor COORDINATE");
15 }
16
17 //------------------------------------------------------------------------------//
18 COORDINATE::COORDINATE(medModeSwitch Mode, int SpaceDimension, int NumberOfNodes):
19                         _nodeNumber(),_coordinateUnit(SpaceDimension),
20                         _coordinateSystem(""),
21                         _coordinateName(SpaceDimension)
22 //------------------------------------------------------------------------------//
23 {
24     BEGIN_OF("Constructor COORDINATE");
25     _coordinate = new MEDARRAY<double>(SpaceDimension,NumberOfNodes,Mode);
26 }
27
28 //------------------------------------------------------------------------------//
29 COORDINATE::COORDINATE(const COORDINATE & m):
30                         _coordinateSystem(m._coordinateSystem)
31 //------------------------------------------------------------------------------//
32 {
33   BEGIN_OF("Copy Constructor COORDINATE");
34   int spaceDimension;
35   int numberOfNodes;
36   if (m._coordinate != NULL)
37     {
38       spaceDimension = (int) m._coordinate->getLeadingValue();
39       numberOfNodes = (int) m._coordinate->getLengthValue();
40       _coordinate = new MEDARRAY<double>(*m._coordinate);
41     }
42   else 
43     {
44       _coordinate = (MEDARRAY<double>*) NULL;
45       spaceDimension = 0;
46       numberOfNodes = 0;
47     } 
48   
49   _coordinateName.set(spaceDimension);
50   for (int i=0; i<spaceDimension; i++)
51     {
52       _coordinateName[i]=m._coordinateName[i];
53     }
54   
55   _coordinateUnit.set(spaceDimension);
56   for (int i=0; i<spaceDimension; i++)
57     {
58       _coordinateUnit[i]=m._coordinateUnit[i];
59     }
60   
61   // PN A VERIFIER
62   _nodeNumber.set(numberOfNodes);
63   if (m._nodeNumber != NULL)
64     {
65       memcpy(_nodeNumber,m._nodeNumber,numberOfNodes*sizeof(int));
66     }
67 }
68
69
70 //----------------------//
71 COORDINATE::~COORDINATE()
72 //----------------------//
73 {
74   MESSAGE("~COORDINATE()");
75   if (_coordinate!=NULL)
76     {
77       MESSAGE("deleting _coordinate" ) ;
78       delete _coordinate ;
79     }
80   // all other attribut are object (not pointer)
81 }
82
83 /*! set the attribute _coordinate with Coordinate           */
84 //----------------------------------------------------------//
85 void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate) 
86 //----------------------------------------------------------//
87
88 //PN a voir ...
89     if ((_coordinate!=NULL) )
90     {
91       MESSAGE("deleting  old _coordinate" ) ;
92       delete _coordinate ;
93     }
94     _coordinate=Coordinate ; 
95 }
96
97 /*! set the attribute _coordinateName with CoordinateName   */
98 //----------------------------------------------------------//
99 void COORDINATE::setCoordinatesNames(string * CoordinateName) 
100 //----------------------------------------------------------//
101 {       
102         _coordinateName=CoordinateName ; 
103 }
104
105 /*! set the attribute _coordinateUnit with CoordinateUnit   */
106 //----------------------------------------------------------//
107 void COORDINATE::setCoordinatesUnits(string * CoordinateUnit) 
108 //----------------------------------------------------------//
109
110         _coordinateUnit.set( CoordinateUnit ) ; 
111 }
112
113 /*! set the attribute _coordinateSystem with CoordinateSystem   */
114 //----------------------------------------------------------//
115 void COORDINATE::setCoordinatesSystem(string CoordinateSystem) 
116 //----------------------------------------------------------//
117
118         _coordinateSystem=CoordinateSystem; 
119 }
120
121 /*! set the attribute _nodeNumber with NodeNumber */
122 //------------------------------------------------//
123 void COORDINATE::setNodesNumbers(int * NodeNumber) 
124 //------------------------------------------------//
125 {       
126         _nodeNumber.set(NodeNumber) ; 
127 }
128
129 /*! returns the number of nodes defined in the mesh*/
130 //-------------------------------------------------//
131 int * COORDINATE::getNodesNumbers() 
132 //-------------------------------------------------//
133 {
134         return  _nodeNumber;
135 }
136
137 /*! returns the mode of coordinates (FULL_INTERLACE or NO_INTERLACE) */
138 //-------------------------------------------------------------------//
139 const double *  COORDINATE::getCoordinates (medModeSwitch Mode) 
140 //-------------------------------------------------------------------//
141 {
142         return _coordinate->get(Mode) ;
143 }
144
145 /* returns the coordinate of node Number on axis Axis */
146 //----------------------------------------------------//
147 double COORDINATE::getCoordinate(int Number,int Axis) 
148 //----------------------------------------------------//
149 {       
150         return _coordinate->getIJ(Number,Axis) ;
151 }
152
153 /* returns all nodes coordinates from  axis Axis      */
154 //----------------------------------------------------//
155 const double *  COORDINATE::getCoordinateAxis(int Axis) 
156 //----------------------------------------------------//
157 {                       //< return all nodes coordinates from axis Axis
158          return _coordinate->getI(MED_NO_INTERLACE,Axis) ;
159 }
160
161 /*! Returns an array with names of coordinates.
162       Example :
163       - x,y,z
164       - r,teta,phi
165       - ... */
166 //--------------------------------------//
167 string * COORDINATE::getCoordinatesNames() 
168 {
169         return _coordinateName ;
170 }
171
172 /* returns the name of axis Axis             */
173 //-------------------------------------------//
174 string COORDINATE::getCoordinateName(int Axis) 
175 //-------------------------------------------//
176 {
177         return _coordinateName[Axis-1];
178 }
179
180 /*!  Returns an array with units of coordinates (cm, m, mm, ...)
181      It could be empty. We suppose we are IS (meter).  */
182 //-----------------------------------------------------//
183 string * COORDINATE::getCoordinatesUnits() 
184 //-----------------------------------------------------//
185 {
186         return _coordinateUnit ;
187 }
188
189 /*! Returns the unit of axis Axis           */
190 //------------------------------------------//
191 string COORDINATE::getCoordinateUnit(int Axis) 
192 //------------------------------------------//
193 {
194         return _coordinateUnit[Axis-1] ;
195 }
196 /*! Returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/
197 //---------------------------------------------------//
198 string COORDINATE::getCoordinatesSystem() const
199 //---------------------------------------------------//
200 {
201   return _coordinateSystem ;
202 }