2 #include "MEDMEM_Coordinate.hxx"
3 #include "MEDMEM_Exception.hxx"
4 #include "MEDMEM_STRING.hxx"
8 /*! Default Constructor : should not be used */
9 //----------------------------------------------------------//
10 COORDINATE::COORDINATE():_coordinateSystem(""),
11 _coordinate(MEDARRAY<double>()),
15 //----------------------------------------------------------//
17 BEGIN_OF("Default Constructor COORDINATE");
20 /*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes./n
21 It will create empty array for optional data (nodeNumber..) */
22 //------------------------------------------------------------------------------//
23 COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode):
24 _coordinateSystem(""),
25 _coordinate(SpaceDimension,NumberOfNodes,Mode),
26 _coordinateName(SpaceDimension),
27 _coordinateUnit(SpaceDimension),
30 //------------------------------------------------------------------------------//
32 BEGIN_OF("Constructor COORDINATE");
35 /*! This constructor will COPY all data (it is a deep copy) included in m./n
36 But only the default storage mode of coordinates array
37 will be copied (not both storage representation modes even if they both
38 exist in original object) : for example only full_interlace mode */
39 //------------------------------------------------------------------------------//
40 COORDINATE::COORDINATE(const COORDINATE & m):
41 _coordinateSystem(m._coordinateSystem),
42 _coordinate(m._coordinate,false)
43 //------------------------------------------------------------------------------//
45 BEGIN_OF("Copy Constructor COORDINATE");
47 int spaceDimension = _coordinate.getLeadingValue();
48 int numberOfNodes = _coordinate.getLengthValue();
50 SCRUTE(spaceDimension);
51 setCoordinatesNames((const string*)m._coordinateName) ;
52 setCoordinatesUnits((const string*)m._coordinateUnit) ;
54 if ( (const int * const) m._nodeNumber != NULL)
55 _nodeNumber.set(numberOfNodes,(const med_int*)m._nodeNumber);
56 // PG : it's default no ?
59 // _nodeNumber.set(0);
64 /* does nothing : all attributs are object (not pointers) */
65 //----------------------//
66 COORDINATE::~COORDINATE()
67 //----------------------//
69 MESSAGE("~COORDINATE()");
72 /*! sets the attribute _coordinate with Coordinate */
73 //----------------------------------------------------------//
74 void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate)
75 //----------------------------------------------------------//
78 const medModeSwitch mode = Coordinate->getMode();
79 // const int spaceDimension = (int) Coordinate->getLeadingValue();
80 // const int numberOfNodes = (int) Coordinate->getLengthValue();
81 if ( Coordinate->get(mode) != NULL)
83 MEDARRAY<double> pourAttribut(*Coordinate,false);
84 _coordinate = pourAttribut;
85 //_coordinate.set(mode,Coordinate->get(mode));
89 throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY<double>
90 *Coordinate)") << "No Coordinate"));
95 Sets the value in attribute _coordinate with Coordinate.
96 _coordinate must be allocated (with
97 COORDINATE::COORDINATE(int,int,medModeSwitch).
99 //----------------------------------------------------------//
100 void COORDINATE::setCoordinates(const medModeSwitch Mode,
101 const double *Coordinate)
102 //----------------------------------------------------------//
104 // if (_coordinate == NULL)
105 // throw MEDEXCEPTION("COORDINATE::setCoordinates(double*) : coordinate array not allocated !");
107 _coordinate.set(Mode,Coordinate);
110 /*! sets the attribute _coordinateName with CoordinateName */
111 //----------------------------------------------------------//
112 void COORDINATE::setCoordinatesNames(const string * CoordinateName)
113 //----------------------------------------------------------//
115 int SpaceDimension = getSpaceDimension() ;
116 _coordinateName.set(SpaceDimension) ;
117 for (int i=0; i<SpaceDimension; i++)
118 _coordinateName[i]=CoordinateName[i];
122 sets the (i+1)^th component of the attribute _coordinateName with
125 //----------------------------------------------------------//
126 void COORDINATE::setCoordinateName(const string CoordinateName, const int i)
127 //----------------------------------------------------------//
129 _coordinateName[i]=CoordinateName;
132 /*! sets the attribute _coordinateUnit with CoordinateUnit */
133 //----------------------------------------------------------//
134 void COORDINATE::setCoordinatesUnits(const string * CoordinateUnit)
135 //----------------------------------------------------------//
137 int SpaceDimension = getSpaceDimension() ;
138 _coordinateUnit.set(SpaceDimension) ;
139 for (int i=0; i<SpaceDimension; i++)
140 _coordinateUnit[i]=CoordinateUnit[i];
144 sets the (i+1)^th component of the attribute _coordinateUnit with
147 //----------------------------------------------------------//
148 void COORDINATE::setCoordinateUnit(const string CoordinateUnit, const int i)
149 //----------------------------------------------------------//
151 _coordinateUnit[i]=CoordinateUnit;
154 /*! sets the attribute _coordinateSystem with CoordinateSystem */
155 //----------------------------------------------------------//
156 void COORDINATE::setCoordinatesSystem(const string CoordinateSystem)
157 //----------------------------------------------------------//
159 _coordinateSystem=CoordinateSystem;
162 /*! sets the attribute _nodeNumber with NodeNumber */
163 //------------------------------------------------//
164 void COORDINATE::setNodesNumbers(const int * NodeNumber)
165 //------------------------------------------------//
167 int NumberOfNodes = getNumberOfNodes() ;
168 _nodeNumber.set(NumberOfNodes,NodeNumber) ;
171 int COORDINATE::getSpaceDimension() const
173 return _coordinate.getLeadingValue() ;
176 int COORDINATE::getNumberOfNodes() const
178 return _coordinate.getLengthValue() ;
182 /*! returns a pointer to the optional array storing
183 eventual nodes numbers */
184 //-------------------------------------------------//
185 const int * COORDINATE::getNodesNumbers() const
186 //-------------------------------------------------//
188 return (const int *)_nodeNumber;
191 /*! returns a Pointer to Coordinates Array in specified mode representation */
192 //--------------------------------------------------------------------------//
193 const double * COORDINATE::getCoordinates (medModeSwitch Mode)
194 //--------------------------------------------------------------------------//
196 return _coordinate.get(Mode) ;
199 /* returns the coordinate of node Number on axis Axis */
200 //----------------------------------------------------//
201 double COORDINATE::getCoordinate(int Number,int Axis)
202 //----------------------------------------------------//
204 return _coordinate.getIJ(Number,Axis) ;
207 /* returns all nodes coordinates from axis Axis */
208 //----------------------------------------------------//
209 const double * COORDINATE::getCoordinateAxis(int Axis)
210 //----------------------------------------------------//
211 { //< return all nodes coordinates from axis Axis
212 return _coordinate.getColumn(Axis) ;
215 /*! returns an array with names of coordinates. /n
220 //--------------------------------------//
221 const string * COORDINATE::getCoordinatesNames() const
223 return _coordinateName ;
226 /* returns the name of axis Axis */
227 //-------------------------------------------//
228 string COORDINATE::getCoordinateName(int Axis) const
229 //-------------------------------------------//
231 return _coordinateName[Axis-1];
234 /*! returns an array with units of coordinates (cm, m, mm, ...)
235 It could be empty. We suppose we are IS (meter). */
236 //-----------------------------------------------------//
237 const string * COORDINATE::getCoordinatesUnits() const
238 //-----------------------------------------------------//
240 return _coordinateUnit ;
243 /*! returns the unit of axis Axis */
244 //------------------------------------------//
245 string COORDINATE::getCoordinateUnit(int Axis) const
246 //------------------------------------------//
248 return _coordinateUnit[Axis-1] ;
250 /*! returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/
251 //---------------------------------------------------//
252 string COORDINATE::getCoordinatesSystem() const
253 //---------------------------------------------------//
255 return _coordinateSystem ;