1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
5 * \file MULTIPR_Utils.hxx
7 * \brief Some useful miscellaneous tools.
9 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
14 #ifndef MULTIPR_UTILS_HXX
15 #define MULTIPR_UTILS_HXX
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.
36 void trim(char* pStr, char pChar=' ');
40 * Returns true iff the given string starts by prefix.
41 * \param pStr any valid C string ending with the char '\0'.
42 * \param pStrPrefix any valid C string ending with the char '\0'.
43 * \return true iff the given string starts by prefix.
45 bool startWith(const char* pStr, const char* pStrPrefix);
49 * Removes the extension (suffix) of a filename.
50 * Example: removeExtension("agregat100grains_12pas.med", ".med") -> "agregat100grains_12pas"
51 * \param pPilename any valid C string ending with the char '\0'.
52 * \param pExtension any valid C string ending with the char '\0'.
53 * \return the filename without extension.
55 std::string removeExtension(const char* pFilename, const char* pExtension);
59 * Prints all the elements of a 2D array.
60 * \param pData all the data (should contain pNumberOfElements * pDimOfElements values)
61 * \param pNumElt number of elements to display.
62 * \param pDimElt Dimension of elements.
63 * \param pPrefix string to display before each element.
66 const med_float* pData,
73 * Converts any float value to a string (remove unecessary 0).
74 * \param mV any float value.
76 std::string realToString(med_float mV);
80 * Returns the name of all meshes contained in a sequential MED file.
81 * \param pMEDfilename name of any valid sequential MED file; must not be NULL.
82 * \return a list of mesh names.
83 * \throw NullArgumentException if pMEDfilename is NULL.
84 * \throw IOException if any other error occurs while reading MED file.
86 std::vector<std::string> getListMeshes(const char* pMEDfilename);
90 * For each scalar field in a sequential MED file, returns its name and the related number of iterations.
91 * Do not returns info about vectorial fields (because, currently, decimation can only be performed on scalar fields).
92 * \param pMEDfilename name of any valid sequential MED file; must not be NULL.
93 * \return a list of (name, #iterations).
94 * \throw NullArgumentException if pMEDfilename is NULL.
95 * \throw IOException if any other error occurs while reading MED file.
97 std::vector<std::pair<std::string, int> > getListScalarFields(const char* pMEDfilename);
99 } // namespace MULTIPR
102 #endif // MULTIPR_UTILS_HXX