Salome HOME
remove a reference to the $MED_ROOT_DIR in the Makefile.in wich is useless
[modules/med.git] / src / MEDMEM / MEDMEM_Coordinate.cxx
index caae4090b3f8b99d65c9a16aaf2c5f8438c3d53f..6b0ab18af11357efbe16aea471735caa13dc0991 100644 (file)
@@ -1,10 +1,13 @@
-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(""),
@@ -17,7 +20,7 @@ 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):
@@ -32,7 +35,26 @@ 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  */
@@ -52,7 +74,7 @@ COORDINATE::COORDINATE(const COORDINATE & m):
   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
 //      {
@@ -71,7 +93,7 @@ COORDINATE::~COORDINATE()
 
 /*! sets the attribute _coordinate with Coordinate           */
 //----------------------------------------------------------//
-void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate) 
+void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate,bool shallowCopy
 //----------------------------------------------------------//
 { 
 
@@ -80,14 +102,20 @@ void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate)
   //  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"));
   }
 }
 
@@ -212,10 +240,10 @@ const double *  COORDINATE::getCoordinateAxis(int Axis)
         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