Skip to content
Snippets Groups Projects
Commit 1181a2eb authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

removed windows.h from Time.h

parent c18a72e1
No related merge requests found
//======================================================================================================================
//
// 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
......@@ -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();
//**********************************************************************************************************************
......
......@@ -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;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment