]> SALOME platform Git repositories - modules/multipr.git/blob - src/MULTIPR/MULTIPR_Utils.hxx
Salome HOME
Module MULTIPR
[modules/multipr.git] / src / MULTIPR / MULTIPR_Utils.hxx
1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
3
4 /**
5  * \file    MULTIPR_Utils.hxx
6  *
7  * \brief   Some useful miscellaneous tools.
8  *
9  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
10  * 
11  * \date    01/2007
12  */
13
14 #ifndef MULTIPR_UTILS_HXX
15 #define MULTIPR_UTILS_HXX
16
17 extern "C"
18 {
19         #include "med.h"
20 }
21
22 #include <string>
23 #include <vector>
24
25
26 namespace multipr
27 {
28
29
30 /**
31  * Removes all the pChar at the end of the string.
32  * \param  pStr  any valid C string ending with the char '\0'.
33  * \param  pChar any char; SPACE by default.
34  * \return the same string where the ending spaces have been removed.
35  */
36 void trim(char* pStr, char pChar=' ');
37
38
39 /**
40  * Removes the extension (suffix) of a filename.
41  * Example: removeExtension("agregat100grains_12pas.med", ".med") -> "agregat100grains_12pas"
42  * \param  pPilename  any valid C string ending with the char '\0'.
43  * \param  pExtension any valid C string ending with the char '\0'.
44  * \return the filename without extension.
45  */
46 std::string removeExtension(const char* pFilename, const char* pExtension);
47
48
49 /**
50  * Prints all the elements of a 2D array.
51  * \param  pData   all the data (should contain pNumberOfElements * pDimOfElements values)
52  * \param  pNumElt number of elements to display.
53  * \param  pDimElt Dimension of elements.
54  * \param  pPrefix string to display before each element.
55  */
56 void printArray2D(
57         const med_float* pData, 
58         const int        pNumElt,
59         const int        pDimElt,
60         const char*      pPrefix);
61         
62
63 /**
64  * Converts any float value to a string (remove unecessary 0).
65  * \param  mV any float value.
66  */
67 std::string realToString(med_float mV);
68
69
70 /**
71  * Returns the name of all meshes contained in a sequential MED file.
72  * \param  pMEDfilename name of any valid sequential MED file; must not be NULL.
73  * \return a list of mesh names.
74  * \throw  NullArgumentException if pMEDfilename is NULL.
75  * \throw  IOException if any other error occurs while reading MED file.
76  */
77  std::vector<std::string> getListMeshes(const char* pMEDfilename);
78
79  
80  /**
81  * For each field in a sequential MED file, returns its name and the related number of iterations.
82  * \param  pMEDfilename name of any valid sequential MED file; must not be NULL.
83  * \return a list of (name, #iterations).
84  * \throw  NullArgumentException if pMEDfilename is NULL.
85  * \throw  IOException if any other error occurs while reading MED file.
86  */
87  std::vector<std::pair<std::string, int> > getListFields(const char* pMEDfilename);
88
89 } // namespace MULTIPR
90
91
92 #endif // MULTIPR_UTILS_HXX
93
94 // EOF