From 1181a2eb9d1e598fc0f079155350b51d90f38d82 Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Fri, 2 Nov 2018 15:27:38 +0100 Subject: [PATCH] removed windows.h from Time.h --- src/core/timing/Time.cpp | 69 +++++++++++++++++++++++++++++++++ src/core/timing/Time.h | 42 +------------------- src/pe/raytracing/Raytracer.cpp | 8 ++-- 3 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 src/core/timing/Time.cpp diff --git a/src/core/timing/Time.cpp b/src/core/timing/Time.cpp new file mode 100644 index 000000000..ca04b5b47 --- /dev/null +++ b/src/core/timing/Time.cpp @@ -0,0 +1,69 @@ +//====================================================================================================================== +// +// 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 +// 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 +// 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/>. +// +//! \file Time.h +//! \ingroup core +//! \author Klaus Iglberger +//! \brief Header file for time functions +//! +//! Copyright (C) 2009 Klaus Iglberger +//! Taken from "pe Physics Engine" with small changes +// +//====================================================================================================================== + +#include "Time.h" + +#include <chrono> + +#if defined(_MSC_VER) +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include <windows.h> +# include <winsock.h> +# include <time.h> +# include <sys/timeb.h> +#else +# include <sys/resource.h> +# include <sys/time.h> +# include <sys/types.h> +#endif + + +namespace walberla { +namespace timing { + +double getCpuTime() +{ +#ifdef WIN32 + FILETIME CreateTime, ExitTime, KernelTime, UserTime; + SYSTEMTIME SysTime; + + if( GetProcessTimes( GetCurrentProcess(), &CreateTime, &ExitTime, &KernelTime, &UserTime ) != 1 ) { + return 0.0; + } + else { + FileTimeToSystemTime( &UserTime, &SysTime ); + return ( static_cast<double>( SysTime.wSecond ) + static_cast<double>( SysTime.wMilliseconds )/1E3 ); + } +#else + struct rusage ruse; + getrusage( RUSAGE_SELF, &ruse ); + return ( static_cast<double>( ruse.ru_utime.tv_sec ) + static_cast<double>( ruse.ru_utime.tv_usec )/1E6 ); +#endif +} + +} // namespace timing +} // namespace walberla diff --git a/src/core/timing/Time.h b/src/core/timing/Time.h index f61128859..374a49f0a 100644 --- a/src/core/timing/Time.h +++ b/src/core/timing/Time.h @@ -33,20 +33,6 @@ #include <chrono> -#if defined(_MSC_VER) -# ifndef NOMINMAX -# define NOMINMAX -# endif -# include <windows.h> -# include <winsock.h> -# include <time.h> -# include <sys/timeb.h> -#else -# include <sys/resource.h> -# include <sys/time.h> -# include <sys/types.h> -#endif - namespace walberla { namespace timing { @@ -58,14 +44,6 @@ namespace timing { // //====================================================================================================================== -//********************************************************************************************************************** -/*!\name Time functions */ -//@{ -inline double getWcTime(); -inline double getCpuTime(); -//@} -//********************************************************************************************************************** - //********************************************************************************************************************** /*!\brief Returns the current wall clock time in seconds. @@ -86,25 +64,7 @@ inline double getWcTime() // // \return The current CPU time in seconds. */ -inline double getCpuTime() -{ -#ifdef WIN32 - FILETIME CreateTime, ExitTime, KernelTime, UserTime; - SYSTEMTIME SysTime; - - if( GetProcessTimes( GetCurrentProcess(), &CreateTime, &ExitTime, &KernelTime, &UserTime ) != 1 ) { - return 0.0; - } - else { - FileTimeToSystemTime( &UserTime, &SysTime ); - return ( static_cast<double>( SysTime.wSecond ) + static_cast<double>( SysTime.wMilliseconds )/1E3 ); - } -#else - struct rusage ruse; - getrusage( RUSAGE_SELF, &ruse ); - return ( static_cast<double>( ruse.ru_utime.tv_sec ) + static_cast<double>( ruse.ru_utime.tv_usec )/1E6 ); -#endif -} +double getCpuTime(); //********************************************************************************************************************** diff --git a/src/pe/raytracing/Raytracer.cpp b/src/pe/raytracing/Raytracer.cpp index 4f94739bc..d7eef3e65 100644 --- a/src/pe/raytracing/Raytracer.cpp +++ b/src/pe/raytracing/Raytracer.cpp @@ -293,7 +293,7 @@ void Raytracer::writeImageToFile(const std::vector<BodyIntersectionInfo>& inters filesystem::path file (fileName); filesystem::path fullPath = dir / file; - std::vector<u_char> lodeImageBuffer(pixelsHorizontal_*pixelsVertical_*3); + std::vector<uint8_t> lodeImageBuffer(pixelsHorizontal_*pixelsVertical_*3); uint32_t l = 0; real_t patchSize = real_c(antiAliasFactor_*antiAliasFactor_); @@ -308,9 +308,9 @@ void Raytracer::writeImageToFile(const std::vector<BodyIntersectionInfo>& inters b_sum += real_c(intersectionsBuffer[i].b); } } - u_char r = (u_char)(255 * (r_sum/patchSize)); - u_char g = (u_char)(255 * (g_sum/patchSize)); - u_char b = (u_char)(255 * (b_sum/patchSize)); + uint8_t r = (uint8_t)(255 * (r_sum/patchSize)); + uint8_t g = (uint8_t)(255 * (g_sum/patchSize)); + uint8_t b = (uint8_t)(255 * (b_sum/patchSize)); lodeImageBuffer[l] = r; lodeImageBuffer[l+1] = g; -- GitLab