2013-04-09 12:00:09 +00:00
|
|
|
// Copyright (C) 2013 CEA/DEN, EDF R&D
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
|
|
//
|
|
|
|
// Author : Frederic Pons (OpenCascade)
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <Utils_SALOME_Exception.hxx>
|
2013-04-25 14:46:57 +00:00
|
|
|
|
|
|
|
#include "Xao.hxx"
|
2013-08-27 11:27:42 +00:00
|
|
|
#include "Field.hxx"
|
2013-04-09 12:00:09 +00:00
|
|
|
#include "XaoUtils.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace XAO;
|
|
|
|
|
2013-08-27 11:27:42 +00:00
|
|
|
/*const char* XaoUtils::intToString(const int value)
|
2013-04-09 12:00:09 +00:00
|
|
|
{
|
2013-08-27 11:27:42 +00:00
|
|
|
std::ostringstream str;
|
2013-04-09 12:00:09 +00:00
|
|
|
str << value;
|
|
|
|
return str.str().c_str();
|
2013-08-27 11:27:42 +00:00
|
|
|
}*/
|
|
|
|
const std::string XaoUtils::intToString(const int value)
|
|
|
|
{
|
|
|
|
std::ostringstream str;
|
|
|
|
str << value;
|
|
|
|
return str.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
const int XaoUtils::stringToInt(const std::string value)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
std::istringstream convert(value);
|
|
|
|
if ( !(convert >> res) )
|
|
|
|
res = 0;
|
|
|
|
return res;
|
2013-04-09 12:00:09 +00:00
|
|
|
}
|
|
|
|
|
2013-08-27 11:27:42 +00:00
|
|
|
const std::string XaoUtils::doubleToString(const double value)
|
|
|
|
{
|
|
|
|
std::ostringstream str;
|
|
|
|
str << value;
|
|
|
|
return str.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* XaoUtils::dimensionToString(const XAO::Dimension dimension)
|
2013-04-09 12:00:09 +00:00
|
|
|
{
|
2013-04-25 14:46:57 +00:00
|
|
|
if (dimension == VERTEX)
|
2013-04-09 12:00:09 +00:00
|
|
|
return "vertex";
|
2013-04-25 14:46:57 +00:00
|
|
|
if (dimension == EDGE)
|
2013-04-09 12:00:09 +00:00
|
|
|
return "edge";
|
2013-04-25 14:46:57 +00:00
|
|
|
if (dimension == FACE)
|
2013-04-09 12:00:09 +00:00
|
|
|
return "face";
|
2013-04-25 14:46:57 +00:00
|
|
|
if (dimension == SOLID)
|
2013-04-09 12:00:09 +00:00
|
|
|
return "solid";
|
2013-08-27 11:27:42 +00:00
|
|
|
if (dimension == WHOLE)
|
|
|
|
return "whole";
|
2013-04-09 12:00:09 +00:00
|
|
|
throw SALOME_Exception("Bad dimension");
|
|
|
|
}
|
|
|
|
|
2013-08-27 11:27:42 +00:00
|
|
|
const XAO::Dimension XaoUtils::stringToDimension(const char* dimension)
|
2013-04-09 12:00:09 +00:00
|
|
|
{
|
|
|
|
if (strcmp(dimension, "vertex") == 0)
|
2013-04-25 14:46:57 +00:00
|
|
|
return VERTEX;
|
2013-04-09 12:00:09 +00:00
|
|
|
if (strcmp(dimension, "edge") == 0)
|
2013-04-25 14:46:57 +00:00
|
|
|
return EDGE;
|
2013-04-09 12:00:09 +00:00
|
|
|
if (strcmp(dimension, "face") == 0)
|
2013-04-25 14:46:57 +00:00
|
|
|
return FACE;
|
2013-04-09 12:00:09 +00:00
|
|
|
if (strcmp(dimension, "solid") == 0)
|
2013-04-25 14:46:57 +00:00
|
|
|
return SOLID;
|
2013-08-27 11:27:42 +00:00
|
|
|
if (strcmp(dimension, "whole") == 0)
|
|
|
|
return WHOLE;
|
2013-04-09 12:00:09 +00:00
|
|
|
throw SALOME_Exception("Bad dimension");
|
|
|
|
}
|
2013-08-27 11:27:42 +00:00
|
|
|
|
|
|
|
const char* XaoUtils::fieldTypeToString(const XAO::Type type)
|
|
|
|
{
|
|
|
|
if (type == BOOLEAN)
|
|
|
|
return "boolean";
|
|
|
|
if (type == INTEGER)
|
|
|
|
return "integer";
|
|
|
|
if (type == DOUBLE)
|
|
|
|
return "double";
|
|
|
|
if (type == STRING)
|
|
|
|
return "string";
|
|
|
|
throw SALOME_Exception("Bad type");
|
|
|
|
}
|
|
|
|
|
|
|
|
const XAO::Type XaoUtils::stringToFieldType(const char* type)
|
|
|
|
{
|
|
|
|
if (strcmp(type, "boolean") == 0)
|
|
|
|
return BOOLEAN;
|
|
|
|
if (strcmp(type, "integer") == 0)
|
|
|
|
return INTEGER;
|
|
|
|
if (strcmp(type, "double") == 0)
|
|
|
|
return DOUBLE;
|
|
|
|
if (strcmp(type, "string") == 0)
|
|
|
|
return STRING;
|
|
|
|
throw SALOME_Exception("Bad type");
|
|
|
|
}
|