diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a33cde159c6bcbf07b2a9e32b6f225b0f822430..4ee98aed1f10105cb528cec3ab58e2d73668431b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -598,10 +598,11 @@ else () list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system ) endif () -if ( WALBERLA_BUILD_WITH_BOOST AND WALBERLA_CXX_COMPILER_IS_IBM ) - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS regex) -endif() - +if (( WALBERLA_CXX_COMPILER_IS_IBM ) OR + ( WALBERLA_CXX_COMPILER_IS_GNU AND CMAKE_CXX_COMPILER_VERSION EQUAL 4.7 ) OR + ( WALBERLA_CXX_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5 ) ) + list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS regex) + endif() if ( WALBERLA_BUILD_WITH_PYTHON AND WALBERLA_CXX_COMPILER_IS_MSVC ) list( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS python3 ) diff --git a/src/core/Regex.h b/src/core/Regex.h index 0acb44a282b3232b88687212fb148be4b65311a6..4d4f167a556b182a7969c79b463e56d21bcb3487 100644 --- a/src/core/Regex.h +++ b/src/core/Regex.h @@ -22,7 +22,11 @@ #pragma once -#ifdef __IBMCPP__ +#if ( defined WALBERLA_CXX_COMPILER_IS_IBM ) +#include <boost/regex.hpp> +#elif ( defined WALBERLA_CXX_COMPILER_IS_CLANG ) && ( ( __clang_major__ == 3 ) && ( __clang_minor__ <= 4 ) ) +#include <boost/regex.hpp> +#elif ( defined WALBERLA_CXX_COMPILER_IS_GNU ) && ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ <= 7 ) ) #include <boost/regex.hpp> #else #include <regex> @@ -31,16 +35,30 @@ namespace walberla { -#ifdef __IBMCPP__ +#if ( defined WALBERLA_CXX_COMPILER_IS_IBM ) +using boost::regex; +using boost::regex_match; +using boost::regex_error; +using boost::regex_search; +using boost::regex_replace; +#elif ( defined WALBERLA_CXX_COMPILER_IS_CLANG ) && ( ( __clang_major__ == 3 ) && ( __clang_minor__ <= 4 ) ) +using boost::regex; +using boost::regex_match; +using boost::regex_error; +using boost::regex_search; +using boost::regex_replace; +#elif ( defined WALBERLA_CXX_COMPILER_IS_GNU ) && ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ <= 7 ) ) using boost::regex; using boost::regex_match; using boost::regex_error; using boost::regex_search; +using boost::regex_replace; #else using std::regex; using std::regex_match; using std::regex_error; using std::regex_search; +using std::regex_replace; #endif } \ No newline at end of file diff --git a/src/geometry/mesh/TriangleMeshIO.cpp b/src/geometry/mesh/TriangleMeshIO.cpp index 611a2d7a76521d4a104ed3372f283da27876d7d5..a880bff033046b595eb65da287a9e18b865a8bd9 100644 --- a/src/geometry/mesh/TriangleMeshIO.cpp +++ b/src/geometry/mesh/TriangleMeshIO.cpp @@ -1,15 +1,15 @@ //====================================================================================================================== // -// This file is part of waLBerla. waLBerla is free software: you can +// This file is part of waLBerla. waLBerla is free software: you can // redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of +// License as published by the Free Software Foundation, either version 3 of // the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. -// +// // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // @@ -28,9 +28,9 @@ #include "core/logging/Logging.h" #include "core/math/AABB.h" #include "core/mpi/Broadcast.h" +#include "core/Regex.h" #include <boost/algorithm/string.hpp> -#include <boost/regex.hpp> #include <fstream> #include <map> @@ -69,7 +69,7 @@ namespace geometry { void writeMesh ( const std::string & meshFilename, const TriangleMesh & mesh ) { WALBERLA_LOG_PROGRESS("Writing mesh " << meshFilename << "..." ); - + std::ofstream os( meshFilename.c_str() ); if( os.fail() ) WALBERLA_ABORT( "Error while opening file " << meshFilename << "!" ); @@ -344,8 +344,8 @@ namespace geometry { // replace multiline comments: /\\*.*?\\*/ // replace single line comments //.*?\n // replace chars: < > , \ n \t - boost::regex r( "/\\*.*?\\*/|//.*?\n|<|>|,|\n|\t" ); - std::string stripped = boost::regex_replace( source , r , " " ) ; + walberla::regex r( "/\\*.*?\\*/|//.*?\n|<|>|,|\n|\t" ); + std::string stripped = walberla::regex_replace( source , r , " " ) ; TriangleMesh::index_t faceOffset = 0u; if( clear ) @@ -645,7 +645,7 @@ namespace geometry { << " </Points>\n"; os << " <Polys>\n"; - + os << " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; os << " "; for( auto it = mesh.getVertexIndices().begin(); it != mesh.getVertexIndices().end(); ++it ) @@ -668,8 +668,8 @@ namespace geometry { os << " <CellData></CellData>\n"; - os << " <PointData" << ( mesh.hasVertexColors() ? " Scalars=\"vertexColors\"" : "" ) - << ( mesh.hasVertexColors() ? " Normals=\"vertexNormals\"" : "" ) + os << " <PointData" << ( mesh.hasVertexColors() ? " Scalars=\"vertexColors\"" : "" ) + << ( mesh.hasVertexColors() ? " Normals=\"vertexNormals\"" : "" ) << ">\n"; if( mesh.hasVertexColors() ) @@ -679,7 +679,7 @@ namespace geometry { for( auto it = mesh.getVertexColors().begin(); it != mesh.getVertexColors().end(); ++it ) { os << static_cast<uint16_t>( (*it)[0] * 255.0f + 0.5f ) << ' ' - << static_cast<uint16_t>( (*it)[1] * 255.0f + 0.5f ) << ' ' + << static_cast<uint16_t>( (*it)[1] * 255.0f + 0.5f ) << ' ' << static_cast<uint16_t>( (*it)[2] * 255.0f + 0.5f ) << ' '; } os << " </DataArray>\n";