-using namespace std;
#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_STRING.hxx"
#include "utilities.h"
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
/*! Default Constructor : should not be used */
//----------------------------------------------------------//
COORDINATE::COORDINATE():_coordinateSystem(""),
BEGIN_OF("Default Constructor COORDINATE");
}
-/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes./n
+/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes.\n
It will create empty array for optional data (nodeNumber..) */
//------------------------------------------------------------------------------//
COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode):
BEGIN_OF("Constructor COORDINATE");
}
-/*! This constructor will COPY all data (it is a deep copy) included in m./n
+/*! This constructor is specialy designed for use in class GRID.\n
+ * The purpose is to create a COORDINATE without allocating memory for nodes (in the MEDARRAY).
+ * The allocation (call to setCoordinates) is performed afterward by GRID, if necessary.
+ * We set _coordinateName & _coordinateUnit in the constructor, because calls to setCoordinateName
+ * and setCoordinateUnit are not possible before allocation of MEDARRAY.
+ */
+//------------------------------------------------------------------------------//
+COORDINATE::COORDINATE(int SpaceDimension,const string * CoordinateName, const string * CoordinateUnit):
+ _coordinateSystem(""), _coordinate(MEDARRAY<double>()), _coordinateName(SpaceDimension),
+ _coordinateUnit(SpaceDimension), _nodeNumber()
+{
+ for (int i=0; i<SpaceDimension; ++i)
+ {
+ _coordinateName[i]=CoordinateName[i];
+ _coordinateUnit[i]=CoordinateUnit[i];
+ }
+}
+
+
+/*! This constructor will COPY all data (it is a deep copy) included in m.\n
But only the default storage mode of coordinates array
will be copied (not both storage representation modes even if they both
exist in original object) : for example only full_interlace mode */
setCoordinatesUnits((const string*)m._coordinateUnit) ;
if ( (const int * const) m._nodeNumber != NULL)
- _nodeNumber.set(numberOfNodes,(const med_int*)m._nodeNumber);
+ _nodeNumber.set(numberOfNodes,(const int*)m._nodeNumber);
// PG : it's default no ?
// else
// {
/*! sets the attribute _coordinate with Coordinate */
//----------------------------------------------------------//
-void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate)
+void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate,bool shallowCopy)
//----------------------------------------------------------//
{
// const int numberOfNodes = (int) Coordinate->getLengthValue();
if ( Coordinate->get(mode) != NULL)
{
- MEDARRAY<double> pourAttribut(*Coordinate,false);
- _coordinate = pourAttribut;
- //_coordinate.set(mode,Coordinate->get(mode));
+ if(shallowCopy)
+ {
+ _coordinate.shallowCopy(*Coordinate);
+ }
+ else
+ {
+ MEDARRAY<double> pourAttribut(*Coordinate,false);
+ _coordinate = pourAttribut;
+ //_coordinate.set(mode,Coordinate->get(mode));
+ }
}
else
{
- throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY<double>
- *Coordinate)") << "No Coordinate"));
+ throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY<double> *Coordinate)") << "No Coordinate"));
}
}
return _coordinate.getColumn(Axis) ;
}
-/*! returns an array with names of coordinates. /n
- Example : /n
- - x,y,z /n
- - r,teta,phi /n
+/*! returns an array with names of coordinates. \n
+ Example : \n
+ - x,y,z \n
+ - r,teta,phi \n
- ... */
//--------------------------------------//
const string * COORDINATE::getCoordinatesNames() const