2 #include "MEDMEM_Coordinate.hxx"
5 /*! This class contains coordinates of the nodes */
6 //----------------------------------------------------------//
7 COORDINATE::COORDINATE():_coordinate(),
10 _coordinateSystem(""),
12 //----------------------------------------------------------//
14 BEGIN_OF("Default Constructor COORDINATE");
17 //------------------------------------------------------------------------------//
18 COORDINATE::COORDINATE(medModeSwitch Mode, int SpaceDimension, int NumberOfNodes):
19 _nodeNumber(),_coordinateUnit(SpaceDimension),
20 _coordinateSystem(""),
21 _coordinateName(SpaceDimension)
22 //------------------------------------------------------------------------------//
24 BEGIN_OF("Constructor COORDINATE");
25 _coordinate = new MEDARRAY<double>(SpaceDimension,NumberOfNodes,Mode);
28 //------------------------------------------------------------------------------//
29 COORDINATE::COORDINATE(const COORDINATE & m):
30 _coordinateSystem(m._coordinateSystem)
31 //------------------------------------------------------------------------------//
33 BEGIN_OF("Copy Constructor COORDINATE");
36 if (m._coordinate != NULL)
38 spaceDimension = (int) m._coordinate->getLeadingValue();
39 numberOfNodes = (int) m._coordinate->getLengthValue();
40 _coordinate = new MEDARRAY<double>(*m._coordinate);
44 _coordinate = (MEDARRAY<double>*) NULL;
49 _coordinateName.set(spaceDimension);
50 for (int i=0; i<spaceDimension; i++)
52 _coordinateName[i]=m._coordinateName[i];
55 _coordinateUnit.set(spaceDimension);
56 for (int i=0; i<spaceDimension; i++)
58 _coordinateUnit[i]=m._coordinateUnit[i];
62 _nodeNumber.set(numberOfNodes);
63 if (m._nodeNumber != NULL)
65 memcpy(_nodeNumber,m._nodeNumber,numberOfNodes*sizeof(int));
70 //----------------------//
71 COORDINATE::~COORDINATE()
72 //----------------------//
74 MESSAGE("~COORDINATE()");
75 if (_coordinate!=NULL)
77 MESSAGE("deleting _coordinate" ) ;
80 // all other attribut are object (not pointer)
83 /*! set the attribute _coordinate with Coordinate */
84 //----------------------------------------------------------//
85 void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate)
86 //----------------------------------------------------------//
89 if ((_coordinate!=NULL) )
91 MESSAGE("deleting old _coordinate" ) ;
94 _coordinate=Coordinate ;
97 /*! set the attribute _coordinateName with CoordinateName */
98 //----------------------------------------------------------//
99 void COORDINATE::setCoordinatesNames(string * CoordinateName)
100 //----------------------------------------------------------//
102 _coordinateName=CoordinateName ;
105 /*! set the attribute _coordinateUnit with CoordinateUnit */
106 //----------------------------------------------------------//
107 void COORDINATE::setCoordinatesUnits(string * CoordinateUnit)
108 //----------------------------------------------------------//
110 _coordinateUnit.set( CoordinateUnit ) ;
113 /*! set the attribute _coordinateSystem with CoordinateSystem */
114 //----------------------------------------------------------//
115 void COORDINATE::setCoordinatesSystem(string CoordinateSystem)
116 //----------------------------------------------------------//
118 _coordinateSystem=CoordinateSystem;
121 /*! set the attribute _nodeNumber with NodeNumber */
122 //------------------------------------------------//
123 void COORDINATE::setNodesNumbers(int * NodeNumber)
124 //------------------------------------------------//
126 _nodeNumber.set(NodeNumber) ;
129 /*! returns the number of nodes defined in the mesh*/
130 //-------------------------------------------------//
131 int * COORDINATE::getNodesNumbers()
132 //-------------------------------------------------//
137 /*! returns the mode of coordinates (FULL_INTERLACE or NO_INTERLACE) */
138 //-------------------------------------------------------------------//
139 const double * COORDINATE::getCoordinates (medModeSwitch Mode)
140 //-------------------------------------------------------------------//
142 return _coordinate->get(Mode) ;
145 /* returns the coordinate of node Number on axis Axis */
146 //----------------------------------------------------//
147 double COORDINATE::getCoordinate(int Number,int Axis)
148 //----------------------------------------------------//
150 return _coordinate->getIJ(Number,Axis) ;
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) ;
161 /*! Returns an array with names of coordinates.
166 //--------------------------------------//
167 string * COORDINATE::getCoordinatesNames()
169 return _coordinateName ;
172 /* returns the name of axis Axis */
173 //-------------------------------------------//
174 string COORDINATE::getCoordinateName(int Axis)
175 //-------------------------------------------//
177 return _coordinateName[Axis-1];
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 //-----------------------------------------------------//
186 return _coordinateUnit ;
189 /*! Returns the unit of axis Axis */
190 //------------------------------------------//
191 string COORDINATE::getCoordinateUnit(int Axis)
192 //------------------------------------------//
194 return _coordinateUnit[Axis-1] ;
196 /*! Returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/
197 //---------------------------------------------------//
198 string COORDINATE::getCoordinatesSystem() const
199 //---------------------------------------------------//
201 return _coordinateSystem ;