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