1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "MEDCouplingSMesh.hxx"
20 #include "MemArray.hxx"
22 using namespace ParaMEDMEM;
24 MEDCouplingSMesh::MEDCouplingSMesh():_x_array(0),_y_array(0),_z_array(0)
28 MEDCouplingSMesh::~MEDCouplingSMesh()
38 MEDCouplingSMesh *MEDCouplingSMesh::New()
40 return new MEDCouplingSMesh;
43 void MEDCouplingSMesh::updateTime()
46 updateTimeWith(*_x_array);
48 updateTimeWith(*_y_array);
50 updateTimeWith(*_z_array);
53 void MEDCouplingSMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
55 const char msg0[]="Invalid ";
56 const char msg1[]=" array ! Must contain more than 1 element.";
58 if(_x_array->getNbOfElems()<2)
60 std::ostringstream os; os << msg0 << 'X' << msg1;
61 throw INTERP_KERNEL::Exception(os.str().c_str());
64 if(_y_array->getNbOfElems()<2)
66 std::ostringstream os; os << msg0 << 'Y' << msg1;
67 throw INTERP_KERNEL::Exception(os.str().c_str());
70 if(_z_array->getNbOfElems()<2)
72 std::ostringstream os; os << msg0 << 'Z' << msg1;
73 throw INTERP_KERNEL::Exception(os.str().c_str());
77 bool MEDCouplingSMesh::isStructured() const
82 int MEDCouplingSMesh::getNumberOfCells() const
86 ret*=_x_array->getNbOfElems()-1;
88 ret*=_y_array->getNbOfElems()-1;
90 ret*=_z_array->getNbOfElems()-1;
94 int MEDCouplingSMesh::getNumberOfNodes() const
98 ret*=_x_array->getNbOfElems();
100 ret*=_y_array->getNbOfElems();
102 ret*=_z_array->getNbOfElems();
106 int MEDCouplingSMesh::getSpaceDimension() const
118 int MEDCouplingSMesh::getMeshDimension() const
130 DataArrayDouble *MEDCouplingSMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception)
141 throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2.");
145 void MEDCouplingSMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coordsY, DataArrayDouble *coordsZ)