Salome HOME
Merge branch 'master' into gni/adaptation
[modules/smesh.git] / src / ADAPTFrontTrack / FrontTrack_Utils.hxx
1 // Copyright (C) 2017-2020  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 // File      : FrontTrack_Utils.hxx
20 // Created   : Tue Apr 25 17:23:33 2017
21 // Author    : Edward AGAPOV (eap)
22
23 #ifndef __FrontTrack_Utils_HXX__
24 #define __FrontTrack_Utils_HXX__
25
26 #include "FrontTrack_Projector.hxx"
27
28 #include <vector>
29 #include <string>
30 #include <map>
31
32 namespace XAO {
33   class Xao;
34   class Group;
35 }
36
37 namespace FT_Utils
38 {
39   // Check if a file exists
40   bool fileExists( const std::string& path );
41
42   // Check if a file can be created/overwritten
43   bool canWrite( const std::string& path );
44
45   // Transform anything printable to a string
46   template< typename T> std::string toStr( const T& t )
47   {
48     std::ostringstream s;
49     s << t;
50     return s.str();
51   }
52
53   //--------------------------------------------------------------------------------------------
54   /*!
55    * \brief Return projectors by group name
56    */
57   struct XaoGroups
58   {
59     XaoGroups( const XAO::Xao* xao );
60
61     int getProjectors( const std::string&                   groupName,
62                        const int                            dim,
63                        const std::vector< FT_Projector > &  allProjectors,
64                        std::vector< const FT_Projector* > & groupProjectors ) const;
65   private:
66
67     typedef std::multimap< std::string, XAO::Group* > TGroupByNameMap;
68     TGroupByNameMap _xaoGroups[ 2 ]; // by dim
69   };
70 }
71
72 #endif