Salome HOME
Copyright update 2022
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_Tools.cpp
1 // Copyright (C) 2014-2022  CEA/DEN, EDF R&D
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <ExchangePlugin_Tools.h>
21
22 #include <sstream>
23
24 std::list<std::string> ExchangePlugin_Tools::split(const std::string& theString, char theDelimiter)
25 {
26   std::list<std::string> theResult;
27   std::istringstream aStream(theString);
28   std::string aSection;
29   while (std::getline(aStream, aSection, theDelimiter))
30     theResult.push_back(aSection);
31   return theResult;
32 }
33
34 std::string ExchangePlugin_Tools::selectionType2xaoDimension(const std::string& theType)
35 {
36   if (theType == "Vertices" || theType == "vertex" || theType == "VERTEX")
37     return "vertex";
38   else if (theType == "Edges" || theType == "edge" || theType == "EDGE")
39     return "edge";
40   else if (theType == "Faces" || theType == "face" || theType == "FACE")
41     return "face";
42   else if (theType == "Solids" || theType == "solid" || theType == "SOLID")
43     return "solid";
44   else if (theType == "Part" || theType == "part" || theType == "PART")
45     return "whole";
46
47   return std::string();
48 }
49
50 std::string ExchangePlugin_Tools::xaoDimension2selectionType(const std::string& theDimension)
51 {
52   if (theDimension == "vertex")
53     return "vertex";
54   else if (theDimension == "edge")
55     return "edge";
56   else if (theDimension == "face")
57     return "face";
58   else if (theDimension == "solid")
59     return "solid";
60
61   return std::string();
62 }
63
64
65 std::string ExchangePlugin_Tools::valuesType2xaoType(
66   const ModelAPI_AttributeTables::ValueType& theType)
67 {
68   switch(theType) {
69   case ModelAPI_AttributeTables::BOOLEAN:
70     return "boolean";
71   case ModelAPI_AttributeTables::INTEGER:
72     return "integer";
73   case ModelAPI_AttributeTables::DOUBLE:
74     return "double";
75   case ModelAPI_AttributeTables::STRING:
76     return "string";
77   }
78   return "";
79 }
80
81 ModelAPI_AttributeTables::ValueType ExchangePlugin_Tools::xaoType2valuesType(std::string theType)
82 {
83   if (theType == "boolean")
84     return ModelAPI_AttributeTables::BOOLEAN;
85   if (theType == "integer")
86     return ModelAPI_AttributeTables::INTEGER;
87   if (theType == "double")
88     return ModelAPI_AttributeTables::DOUBLE;
89   if (theType == "string")
90     return ModelAPI_AttributeTables::STRING;
91   return ModelAPI_AttributeTables::DOUBLE;
92 }