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-04-09 12:00:09 +00:00
|
|
|
#include "XaoUtils.hxx"
|
|
|
|
|
|
|
|
using namespace XAO;
|
|
|
|
|
2013-08-28 15:22:43 +00:00
|
|
|
|
|
|
|
const std::string XaoUtils::intToString(const int& value)
|
2013-08-27 11:27:42 +00:00
|
|
|
{
|
|
|
|
std::ostringstream str;
|
|
|
|
str << value;
|
|
|
|
return str.str();
|
|
|
|
}
|
|
|
|
|
2013-08-28 15:22:43 +00:00
|
|
|
const int XaoUtils::stringToInt(const std::string& value)
|
2013-08-27 11:27:42 +00:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
std::istringstream convert(value);
|
|
|
|
if ( !(convert >> res) )
|
|
|
|
res = 0;
|
|
|
|
return res;
|
2013-04-09 12:00:09 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 15:22:43 +00:00
|
|
|
const std::string XaoUtils::doubleToString(const double& value)
|
2013-08-27 11:27:42 +00:00
|
|
|
{
|
|
|
|
std::ostringstream str;
|
|
|
|
str << value;
|
|
|
|
return str.str();
|
|
|
|
}
|
|
|
|
|
2013-08-28 15:22:43 +00:00
|
|
|
const double XaoUtils::stringToDouble(const std::string& value)
|
|
|
|
{
|
|
|
|
double res;
|
|
|
|
std::istringstream convert(value);
|
|
|
|
if ( !(convert >> res) )
|
|
|
|
res = 0;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string XaoUtils::dimensionToString(const XAO::Dimension& dimension)
|
2013-04-09 12:00:09 +00:00
|
|
|
{
|
2013-08-30 14:13:47 +00:00
|
|
|
if (dimension == XAO::VERTEX)
|
2013-04-09 12:00:09 +00:00
|
|
|
return "vertex";
|
2013-08-30 14:13:47 +00:00
|
|
|
if (dimension == XAO::EDGE)
|
2013-04-09 12:00:09 +00:00
|
|
|
return "edge";
|
2013-08-30 14:13:47 +00:00
|
|
|
if (dimension == XAO::FACE)
|
2013-04-09 12:00:09 +00:00
|
|
|
return "face";
|
2013-08-30 14:13:47 +00:00
|
|
|
if (dimension == XAO::SOLID)
|
2013-04-09 12:00:09 +00:00
|
|
|
return "solid";
|
2013-08-30 14:13:47 +00:00
|
|
|
if (dimension == XAO::WHOLE)
|
2013-08-27 11:27:42 +00:00
|
|
|
return "whole";
|
2013-09-03 15:56:58 +00:00
|
|
|
|
|
|
|
throw SALOME_Exception(MsgBuilder() << "Bad dimension: " << dimension);
|
2013-04-09 12:00:09 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 15:22:43 +00:00
|
|
|
const XAO::Dimension XaoUtils::stringToDimension(const std::string& dimension)
|
2013-04-09 12:00:09 +00:00
|
|
|
{
|
2013-08-28 15:22:43 +00:00
|
|
|
if (dimension == "vertex")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::VERTEX;
|
2013-08-28 15:22:43 +00:00
|
|
|
if (dimension == "edge")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::EDGE;
|
2013-08-28 15:22:43 +00:00
|
|
|
if (dimension == "face")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::FACE;
|
2013-08-28 15:22:43 +00:00
|
|
|
if (dimension == "solid")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::SOLID;
|
2013-08-28 15:22:43 +00:00
|
|
|
if (dimension == "whole")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::WHOLE;
|
2013-09-03 15:56:58 +00:00
|
|
|
|
|
|
|
throw SALOME_Exception(MsgBuilder() << "Bad dimension: " << dimension);
|
2013-04-09 12:00:09 +00:00
|
|
|
}
|
2013-08-27 11:27:42 +00:00
|
|
|
|
2013-08-28 15:22:43 +00:00
|
|
|
const std::string XaoUtils::fieldTypeToString(const XAO::Type& type)
|
2013-08-27 11:27:42 +00:00
|
|
|
{
|
2013-08-30 14:13:47 +00:00
|
|
|
if (type ==XAO:: BOOLEAN)
|
2013-08-27 11:27:42 +00:00
|
|
|
return "boolean";
|
2013-08-30 14:13:47 +00:00
|
|
|
if (type == XAO::INTEGER)
|
2013-08-27 11:27:42 +00:00
|
|
|
return "integer";
|
2013-08-30 14:13:47 +00:00
|
|
|
if (type == XAO::DOUBLE)
|
2013-08-27 11:27:42 +00:00
|
|
|
return "double";
|
2013-08-30 14:13:47 +00:00
|
|
|
if (type == XAO::STRING)
|
2013-08-27 11:27:42 +00:00
|
|
|
return "string";
|
2013-09-03 15:56:58 +00:00
|
|
|
|
|
|
|
throw SALOME_Exception(MsgBuilder() << "Bad type: " << type);
|
2013-08-27 11:27:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 15:22:43 +00:00
|
|
|
const XAO::Type XaoUtils::stringToFieldType(const std::string& type)
|
2013-08-27 11:27:42 +00:00
|
|
|
{
|
2013-08-28 15:22:43 +00:00
|
|
|
if (type == "boolean")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::BOOLEAN;
|
2013-08-28 15:22:43 +00:00
|
|
|
if (type == "integer")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::INTEGER;
|
2013-08-28 15:22:43 +00:00
|
|
|
if (type == "double")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::DOUBLE;
|
2013-08-28 15:22:43 +00:00
|
|
|
if (type == "string")
|
2013-08-30 14:13:47 +00:00
|
|
|
return XAO::STRING;
|
2013-09-03 15:56:58 +00:00
|
|
|
|
|
|
|
throw SALOME_Exception(MsgBuilder() << "Bad type: " << type);
|
2013-08-27 11:27:42 +00:00
|
|
|
}
|
2013-08-30 14:13:47 +00:00
|
|
|
|
|
|
|
const std::string XaoUtils::shapeFormatToString(const XAO::Format& format)
|
|
|
|
{
|
|
|
|
if (format == XAO::BREP)
|
|
|
|
return "BREP";
|
|
|
|
if (format == XAO::STEP)
|
|
|
|
return "STEP";
|
2013-09-03 15:56:58 +00:00
|
|
|
|
|
|
|
throw SALOME_Exception(MsgBuilder() << "Bad format: " << format);
|
2013-08-30 14:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const XAO::Format XaoUtils::stringToShapeFormat(const std::string& format)
|
|
|
|
{
|
|
|
|
if (format == "BREP")
|
|
|
|
return XAO::BREP;
|
|
|
|
if (format == "STEP")
|
|
|
|
return XAO::STEP;
|
2013-09-03 15:56:58 +00:00
|
|
|
|
|
|
|
throw SALOME_Exception(MsgBuilder() << "Bad format: " << format);
|
2013-08-30 14:13:47 +00:00
|
|
|
}
|