Salome HOME
Fix computation height of isocel triangle with base equal zero : NaN
[tools/medcoupling.git] / src / MEDLoader / MEDMESHConverterUtilities.hxx
1 // Copyright (C) 2021-2023  CEA, EDF
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 #ifndef MEDMESHCONVERTERUTILITIES_HXX
21 #define MEDMESHCONVERTERUTILITIES_HXX
22
23 #include "MEDLoaderDefines.hxx"
24
25 # include <string>
26 # include <sstream>
27 #include <iostream>
28 # include <vector>
29 #include <cstring>
30
31 namespace MeshFormat
32 {
33 bool isMeshExtensionCorrect( const std::string& fileName );
34
35 //~void closeMeshFile(const int gmfMeshID);
36
37 enum Status {
38     DRS_OK,
39     DRS_EMPTY,          // a file contains no mesh with the given name
40     DRS_WARN_RENUMBER,  // a file has overlapped ranges of element numbers,
41     // so the numbers from the file are ignored
42     DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data
43     DRS_WARN_DESCENDING, // some elements were skipped due to descending connectivity
44     DRS_FAIL            // general failure (exception etc.)
45 };
46 /*!
47  * \brief Class to generate string from any type
48  */
49 class Comment : public std::string
50 {
51     std::ostringstream _s ;
52
53 public :
54
55     Comment():std::string("") {}
56
57     Comment(const Comment& c):std::string() {
58         _s << c.c_str() ;
59         this->std::string::operator=( _s.str() );
60     }
61
62     Comment & operator=(const Comment& c) {
63         _s << c.c_str() ;
64         this->std::string::operator=( _s.str() );
65         return *this;
66     }
67
68     template <class T>
69     Comment( const T &anything ) {
70         _s << anything ;
71         this->std::string::operator=( _s.str() );
72     }
73
74     template <class T>
75     Comment & operator<<( const T &anything ) {
76         _s << anything ;
77         this->std::string::operator=( _s.str() );
78         return *this ;
79     }
80
81     operator char*() const {
82         return (char*)c_str();
83     }
84
85     std::ostream& Stream() {
86         return _s;
87     }
88 };
89 /*!
90    * \brief Enforce freeing memory allocated by std::vector
91    */
92 template <class TVECTOR>
93 void FreeVector(TVECTOR& vec)
94 {
95     TVECTOR v2;
96     vec.swap( v2 );
97 }
98 template <class TVECTOR>
99 void CompactVector(TVECTOR& vec)
100 {
101     TVECTOR v2( vec );
102     vec.swap( v2 );
103 }
104
105 class Localizer
106 {
107     std::string _locale;
108 public:
109   MEDLOADER_EXPORT Localizer();
110   MEDLOADER_EXPORT ~Localizer();
111 };
112 }
113
114
115 #endif // MEDMESHCONVERTERUTILITIES_HXX